Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

WeiDU parsing: issue with require_predicate or component

Abdel_AdrianAbdel_Adrian Member Posts: 428
edited June 2015 in General Modding
I'm trying to link certain components with ADD_KIT that are necessary for the custom kit. I'd like to install these components only if the kit was installed, but the way it's set up right now, these files will be added regardless of whether or not the kit was added. I get parsing issues if I try to add lines (i.e. COPY ~whatever~ ~override~) between BEGIN and END of ADD_KIT.
I'm trying something like:

BEGIN ~X~
SUBCOMPONENT ~Y~
REQUIRE_PREDICATE ~Z~

But this is where I'm lost. I don't know how to use REQUIRE_PREDICATE (or COMPONENT) other than for GAME_IS, and I'd really like these components to always install with the kit and not give a choice, seeing as they're necessary for the kit to work.

How do I use WeiDU to check if a component is installed and then automatically install a corresponding component? Thanks!

P.S. I've got Bladesinger and Priestess of Lloth kits complete now, just need to polish them up before release. I really appreciate any help.


Edit: not sure if I got it or not.
I used:
ACTION_IF FILE_EXISTS ~override/EMCLABLL.2da~
THEN BEGIN

I'm just not sure if ADD_KIT adds the custom CLAB file that you indicate the class should use.

Post edited by Abdel_Adrian on

Comments

  • subtledoctorsubtledoctor Member Posts: 11,468
    edited June 2015
    SUBCOMPONENT is for optional components that are alternatives to each other. I.e. install the Corsair as a fighter kit, or alternatively as a ranger kit. You would use SUBCOMPONENT to do something like that.

    If you want to do various COPY commands along with your ADD_KIT, guaranteed that they both do, or do not, get installed together, just include those lines after the ADD_KIT stuff. Basically, after the fl#add_kit_ee routine is called. Here's an example from my mod (Scales of Balance):
    BEGIN @3200
    DESIGNATED 320

    ADD_KIT ~D5CORSA~
    //___________________________________________________________________________________

    //WEAPON PROFICIENCIES________________________________________________________________
    //11 T S F Q S S
    //10 L S W C L U W I
    //9 A M B L S O I W A A O N
    //8 R A A O H H M A I R C S R G
    //7 G L M S N O A I R H L T R L H 2 D L 2 E E E E E E E E E E E
    //6 E L S I T G R N K T D H A M E O O O H A E W E E E E E E E E X X X X X X X X X X X
    //5 S S S B P S A S T D A A A A S L O R S N R S A N W E X X X X X X X X T T T T T T T T T T T
    //4 W W P L I S R W S E T R G M C P B R M S S G T D L N D E A T T T T T T T T R R R R R R R R R R R
    //3 O O B E U K A I D O W A D A W G M L E E N A T B B B A I D S A P R R R R R R R R A A A A A A A A A A A
    //2 R R O A N E X L S R O X S N A E E U A R I C A O O O R N E H P O A A A A A A A A 1 1 1 1 1 1 1 1 1 1 2
    //1 D D W R T D E E W D R E W A K R R B R D N E F W W W T G D I O N 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
    ~D5CORSA 5 5 2 0 2 2 0 2~
    ~D5CORSA 5 5 2 0 2 2 0 2 0 5 5 2 0 0 5 5 2 2 0 0 2 2 2 2 0 2 0 2 0 0 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0~

    //MINIMUM KIT STATS_________________________________________________________________
    // STR DEX CON INT WIS CHR
    ~D5CORSA 9 12 0 9 0 9~

    //KIT STAT MODIFIERS________________________________________________________________
    // STR DEX CON INT WIS CHR
    ~D5CORSA 0 0 0 0 0 0~

    //REQUIREMENTS TO DUAL TO THIS KIT_________________________________________________
    // STR DEX CON INT WIS CHR
    ~D5CORSA 15 15 0 0 0 0~

    //REQUIREMENTS TO DUAL FROM THIS KIT________________________________________________
    // STR DEX CON INT WIS CHR
    ~D5CORSA 15 15 0 0 0 0~

    //ALIGNMENT RESTRICTIONS____________________________________________________________
    // LG LN LE NG TN NE CG CN CE
    ~D5CORSA 0 0 0 1 1 1 1 1 1~

    //DUAL CLASS OPTIONS________________________________________________________________
    // FT CL MA TH DR RA
    ~D5CORSA 0 1 1 0 0 0~

    //KIT ABILITIES 2DA FILE______________________________________________________________
    ~scales_of_balance/fighter/d5_corsa.2da~

    //RACIAL KIT AVAILABILITY_____________________________________________________________
    ~K_F_H K_F_G K_F_E K_F_HE K_F_HL K_F_HO~

    //UNUSABLE FLAGS AND KIT BASE CLASS_________________________________________________
    //CLASSES: Mage = 1, Fighter = 2, Cleric=3, Thief = 4, Bard = 5
    // Paladin 6, Druid = 11, Ranger = 12, Sorcerer = 19
    // Monk = 20
    ~0x00010000 2~

    //HIGH LEVEL ABILITIES ABBREVIATION_________________________________________________
    ~Fi0~

    //TOB STARTING EQUIPMENT_____________________________________________________________
    ~LEAT14 * HELM07 BAG20 RING06 RING31 CLCK02 BOOT01 AMUL19 BRAC16 BELT06 AROW11,40 BULL03,40 BOLT06,40 POTN52,5 POTN04,2 POTN14,5 HAMM07 SW1H39 STAF08~

    //CHARACTER CREATION KIT DESCRIPTION________________________________________________
    SAY @3201
    SAY @3202
    SAY @3205
    //___________________________________________________________________________________

    //EE KIT EXTRAS_____________________________________________________________________
    ACTION_IF GAME_IS ~bgee bg2ee iwdee~ THEN BEGIN
    LAF fl#add_kit_ee
    INT_VAR
    briefdesc = RESOLVE_STR_REF (@3204)
    STR_VAR
    kit_name = D5CORSA
    END
    END
    //____________________________________________________________________________________

    //CORSAIR ABILITY FILES______________________________________________________________
    //
    COPY ~scales_of_balance/misc/d5_bsvbo.spl~ ~override~
    SAY NAME1 @17
    COPY ~scales_of_balance/misc/d5_luckp.spl~ ~override~
    SAY NAME1 @3208
    SAY UNIDENTIFIED_DESC @3208
    COPY ~scales_of_balance/fighter/d5_swapr.spl~ ~override~
    COPY ~scales_of_balance/fighter/d5_swash.spl~ ~override~
    SAY NAME1 @3206
    SAY UNIDENTIFIED_DESC @3207
    //___________________________________________________________________________________

    Notice that there is no "END" needed at the end of the ADD_KIT routine, or at the end of a component. The only time you ever need an END line is (generally) after something with an "_IF" (e.g. ACTION_IF, PATCH_IF) or at the end of a macro/function (e.g. LAF, LPF). If this component was installed in the non-EE game, I could eliminate the whole "EE kit extras" block and there would be no "END" in the whole thing. I would just have all the commands one after the other (the COPY commands can be immediately after the last SAY line in the ADD_KIT routine), and then I would immediately go to the BEGIN line for the next component. That extra "END" may be what's tripping you up.

    There may also be an issue with terminology here. A "component" is a set of commands that are all grouped together, linked by asking the user if they want to install them. Like when Weidu asks the user "do you want to install ______?" then everything associated with that _____ is all grouped together in a single component.

    If you want a separate component, and in that separate component you want to check whether a kit is installed, there are a couple ways to do it.

    1) An easy one, as you've mentioned in your edited post, is to simply look for the kit's .2da file. I do this a few times in my mod. The .2da file you put in the ADD_KIT routine gets copied over as part of the routine, so the following will work:
    REQUIRE_PREDICATE (FILE_EXISTS_IN_GAME ~d5_corsa.2da~)
    2) You could add a marker file with the kit component (I make little text files that say "hello!" and call them things like "d5_profs.d5") and then in the next component, check for that marker file by adding this just after the BEGIN line:
    REQUIRE_PREDICATE (FILE_EXISTS_IN_GAME ~d5_profs.d5~)
    3) You can give the kit component a DESIGNATED number (like my example above is DESIGNATED 320) and then in the next component, add something like this just after the BEGIN line:
    REQUIRE_PREDICATE (MOD_IS_INSTALLED "MYMOD.TP2" "320")
    EDIT - re-reading, I think these three options in the second half of my post are not what you want. So, pay more attention to the first half of my post. :)

    Post edited by subtledoctor on
    Abdel_AdrianMusigny
  • Abdel_AdrianAbdel_Adrian Member Posts: 428
    Thanks a ton @subtledoctor , that really helped clear some things up. I'm going to fiddle around a bit with the placing of my ENDs, but I'm definitely liking option 1. It was very easy to work in for my priestess kit, but the bladesinger will be a bit more difficult since it has so many bard - changing components after add kit.
    From what you said before the spoiler though, it seems like all the lines of COPY are already attached to the kit, I just don't think every component is at the moment. I think I can figure it out now.

    Musigny
  • Abdel_AdrianAbdel_Adrian Member Posts: 428
    edited June 2015
  • MusignyMusigny Member Posts: 1,018


    But this is where I'm lost. I don't know how to use REQUIRE_PREDICATE (or COMPONENT) other than for GAME_IS, and I'd really like these components to always install with the kit and not give a choice, seeing as they're necessary for the kit to work.

    I am not 100% sure about what you intend to do but If you want to directly use the REQUIRE_COMPONENT flag, the syntax is the following. Reusing @subtledoctor example:
    BEGIN ~component name~
    REQUIRE_COMPONENT ~relative_path_to/mymod.tp2~ ~320~ ~message if the component cannot be installed~
    See the weidu doc - chapter 9.

    Abdel_Adrian
  • Abdel_AdrianAbdel_Adrian Member Posts: 428
    Musigny said:


    But this is where I'm lost. I don't know how to use REQUIRE_PREDICATE (or COMPONENT) other than for GAME_IS, and I'd really like these components to always install with the kit and not give a choice, seeing as they're necessary for the kit to work.

    I am not 100% sure about what you intend to do but If you want to directly use the REQUIRE_COMPONENT flag, the syntax is the following. Reusing @subtledoctor example:
    BEGIN ~component name~
    REQUIRE_COMPONENT ~relative_path_to/mymod.tp2~ ~320~ ~message if the component cannot be installed~
    See the weidu doc - chapter 9.
    Thanks. What I intend to do is have a bunch of lines of COPY ~whatever~ ~override~ following the installation of a kit, but to only install if the kit did and to not give the user the option to not install those components, since the kit wouldn't really work then. I think anything of a BEGIN ~component~ nature will give the user the option to not install it, so I'm trying out ACTION_IF FILE_EXISTS ~override/[....CLAB...].2da~
    THEN BEGIN
    I'm going to try placing the COPY lines within ADD_KIT after the last SAY, like subtledoctor suggested, just haven't done so yet, but there are a few more complex lines that may not be as simple.

  • Abdel_AdrianAbdel_Adrian Member Posts: 428
    Actually, placing things before LAF fl#add_kit_ee seems to be the best way to go for me, I really don't even need many ACTION_IFs.

  • subtledoctorsubtledoctor Member Posts: 11,468
    edited June 2015

    What I intend to do is have a bunch of lines of COPY ~whatever~ ~override~ following the installation of a kit, but to only install if the kit did and to not give the user the option to not install those components, since the kit wouldn't really work then. I think anything of a BEGIN ~component~ nature will give the user the option to not install it, so I'm trying out ACTION_IF FILE_EXISTS ~override/[....CLAB...].2da~
    THEN BEGIN

    In that case, those COPY commands should not be in their own component. They should be bundled with the ADD_KIT stuff, in a single component.

    You cannot put a component within an ACTION_IF block. The only way to make a component not present itself to the user is to tag it with something like REQUIRE_PREDICATE, REQUIRE_COMPONENT, FORBID_COMPONENT, etc.

    But again, here you shouldn't be doing that. You should be installing the kit and any abilities/items/etc. associated with it, together in a single component.

    I'm going to try placing the COPY lines within ADD_KIT after the last SAY, like subtledoctor suggested

    It's not *within* ADD_KIT, it's after. "ADD_KIT" is a command, just like COPY. That particular command takes a bunch of arguments to help define what it will do; those arguments are everything down to the three SAY lines. A component can have an unlimited number of commands inside it. So you can do this:
    BEGIN ~mod component~
    > ADD_KIT ~your kit~
    [various add_kit arguments]
    > LPF fl#add_kit_ee
    [various fl#add_kit_ee arguments]
    > COPY ~1st kit ability~ ~override~
    SAY NAME1 ~spell name~
    SAY UNIDENTIFIED_DESC ~spell description~
    > COPY ~2nd kit ability~ ~override~
    SAY NAME1 ~spell name~
    SAY UNIDENTIFIED_DESC ~spell description~
    Each line that begins with ">" is a command. (You won't have that ">" in your code, of course.)

    And to reiterate, you do *not* need an "END" at the end of the ADD_KIT command, or at the end of the component. Extra ENDs will screw things up.

    MusignyAbdel_Adrian
  • MusignyMusigny Member Posts: 1,018
    A tp2 component is the code starting with BEGIN and ending when another BEGIN is met (or the end of file).
    If both your kit and the related copied files are in the same component then follow @subtledoctor example, the additional files (your copy commands) will not be installed if the component fails, weidu will rollback every command of that component.
    If for some reasons you want to test the presence of the kit in another component you can either detect a particular file, a preset variable or use a variation of the third example: ACTION_IF or PATCH_IF (MOD_IS_INSTALLED ~relative_path_to/mymod.tp2~ ~component-number as seen in the weidu.log~).

    Abdel_Adrian
  • Abdel_AdrianAbdel_Adrian Member Posts: 428
    You're totally right @subtledoctor , I think it's just the terminology I'm getting wrong here. I don't want these actions to be a separate component, and I guess they're not within add kit, but rather between the say lines and LAF, which seems to be working, but I see you posted them after the LAF. That's how I had it originally, but I thought those actions were taking place even if the user chose not to install the kit.

    This is what I have right now for one of my kits, I haven't done enough testing to be sure it's doing exactly what I want, but it seems to be installing every part of the kit, all the COPY lines, and the EE functions:
    BEGIN Priestess_of_Lloth
    REQUIRE_PREDICATE GAME_IS ~bgee bg2ee iwdee~ @25

    INCLUDE ~Bladesinger/lib/fl#add_kit_ee.tpa~

    ADD_KIT ~PRIEST_LLOTH~ /* this is the "internal" name of your kit, like BERSERKER or LATHANDER */
    ~PRIEST_LLOTH 0 0 1 1 0 1 0 0~ /* this line is appened to CLASWEAP.2DA */
    ~PRIEST_LLOTH 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0~ /* this string is appened column-wise to WEAPPROF.2DA, starting with the third line*/
    ~PRIEST_LLOTH 3 7 6 8 9 8~ /* this line is appened to ABCLASRQ.2DA */
    ~PRIEST_LLOTH 0 1 0 1 0 -2~ /* this line is appened to ABCLSMOD.2DA */
    ~PRIEST_LLOTH 17 17 17 17 0 0~ /* this line is appened to ABDCDSRQ.2DA */
    ~PRIEST_LLOTH 15 15 15 15 0 0~ /* this line is appened to ABDCSCRQ.2DA */
    ~PRIEST_LLOTH 0 0 0 0 0 0 0 0 1~ /* this line is appened to ALIGNMNT.2DA */
    ~PRIEST_LLOTH 0 0 0 0 0 0~ /* this line goes to DUALCLAS.2DA */
    ~Bladesinger/2DA/EMCLABLL.2da~ /* this is the name of your abilities 2DA file, in the style of clabrn02.2da */
    ~K_C_H K_C_D K_C_G K_C_E K_C_HE K_C_HL K_C_HO~ /* These are the 2da files listed in KITTABLE.2DA that you want your kit to be a part of. List as many as you like. */
    ~0x01000000 3~ /* This is the "unusable" value you want for your kit and also the class value. These would normally appear at the end of KITLIST.2DA */
    ~Cl0~ /* This is the High Level Ability Abbreviation (see LUABBR.2DA) Normal values are Fi0, Pa0, etc. */
    ~CHAN09 * HELM07 BAG26 RING06 RING31 * BOOT01 AMUL20 BRAC10 BELT06 AROW11,40 BULL03,40 BOLT06,40 POTN52,5 POTN04,2 POTN14,5 HAMM07 SW1H27 STAF08~
    SAY ~priestess of lloth~
    SAY ~Priestess of Lloth~
    SAY @250

    COPY ~Bladesinger/Spells/EMCDSYM.spl~ ~override~
    COPY ~Bladesinger/Spells/EMLLOTH.spl~ ~override~
    COPY ~Bladesinger/Spells/EMMRES.spl~ ~override~
    COPY ~Bladesinger/Spells/EMVENOM.spl~ ~override~
    COPY ~Bladesinger/Spells/EMWEB.spl~ ~override~
    COPY ~Bladesinger/ITM/EMLLOTH.itm~ ~override~ // Holy Symbol of Lloth
    SAY NAME1 ~~
    SAY NAME2 @136
    SAY UNIDENTIFIED_DESC ~~
    SAY DESC @137

    ACTION_IF GAME_IS ~bgee~
    THEN BEGIN

    COPY ~Bladesinger/Spells/EMSPCLL1.spl~ ~override~
    COPY ~Bladesinger/Spells/EMSPCLL2.spl~ ~override~

    END

    ACTION_IF GAME_IS ~bg2ee~
    THEN BEGIN

    COPY ~Bladesinger/Spells2/EMSPCLL1.spl~ ~override~
    COPY ~Bladesinger/Spells2/EMSPCLL2.spl~ ~override~

    END

    LAF fl#add_kit_ee
    INT_VAR
    biography = ~-1~
    briefdesc = 31255 // Normal briefdesc for clerics
    fallen = 0
    fallen_notice = ~-1~
    STR_VAR
    kit_name = PRIEST_LLOTH
    clswpbon = ~0 0 3~
    numwslot = ~2~
    clascolr = ~25 83 66 28 23~
    clasiskl = ~0 0 0 0 0 0 0~
    clasthac = ~0~
    thiefscl = ~0 0 0 0 0 0 0 0~
    hpclass = ~HPPRS~
    clsrcreq = ~0 1 0 0 0 0 0~

    END

    Musigny
Sign In or Register to comment.