Skip to content

Why is everyone on this forum so insanly knowledgeble?

Gel87Gel87 Member Posts: 331
When i see other people mod, they like have either success at once, or they have 2-3 tries and some has a single pointer and everything is fixed...

This is me adding a projectile to a ranged item ability:
//	WRITE_SHORT 0x098 ~%GelStar%~
//    	ALTER_ITEM_ABILITY ~RANGED~ INT_VAR projectile = %GelStar% END
//    	LFP ~ALTER_ITEM_ABILITY~ INT_VAR ability_type = 2 projectile = %GelStar% END
//    	ALTER_ITEM_ABILITY ~RANGED~ INT_VAR ability_type = 2 projectile = %GelStar% END
//    	ALTER_ITEM_ABILITY ~RANGED~ projectile = %GelStar% END
// 	LPF ALTER_ITEM_ABILITY_HEADER INT_VAR projectile = %GelStar% END
//	ALTER_ITEM_ABILITY ~2~ projectile = %GelStar%
//	ALTER_ITEM_ABILITY 2 projectile = %GelStar%
//	ALTER_ITEM_ABILITY 2 projectile = ~%GelStar%~
//	ALTER_ITEM_ABILITY ~2~ projectile = ~%GelStar%~
//	ALTER_ITEM_ABILITY ~2~ projectile = ~GelStar.pro~
//	ALTER_ITEM_ABILITY ~2~ projectile ~%GelStar%~
// 	LPF ALTER_ITEM_ABILITY_HEADER INT_VAR projectile = %GelSmok% END
//	ALTER_ITEM_ABILITY ~2~ projectile = ~~%GelStar%~~
//    	ALTER_ITEM_ABILITY ~0~ ability_type = 2 projectile = %GelStar%
//	ALTER_ITEM_ABILITY ~0~ projectile = %GelStar%
//	ALTER_ITEM_ABILITY ~0~ projectile EQUALS %GelStar%
//	ALTER_ITEM_ABILITY 0 projectile ~%GelStar%~
//	ALTER_ITEM_ABILITY 0 projectile %GelStar%
//	ALTER_ITEM_ABILITY ~0~ projectile %GelStar%
//	ALTER_ITEM_ABILITY ~0~ projectile ~%GelStar%~
//	ALTER_ITEM_ABILITY ~RANGED~ INT_VAR ability_type = 2 projectile = ~%GelStar%~
//	ALTER_ITEM_ABILITY ~RANGED~ INT_VAR ability_type = 2 projectile = %GelStar%
//  	PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
//    	LPF ~ALTER_ITEM_ABILITY~ INT_VAR type = 2 projectile = %GelStar% END
//  	END
//  	BUT_ONLY
//PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
//    ALTER_ITEM_ABILITY ~RANGED~ projectile = %GelStar%
//END
//BUT_ONLY
//PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
//    ALTER_ITEM_ABILITY 0 projectile = %GelStar%
//END
//BUT_ONLY
//	PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
//    		~ALTER_ITEM_ABILITY 0~ projectile = ~%GelStar%~
//	END
//	BUT_ONLY
//PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
//    LPF ALTER_ITEM_ABILITY 0 projectile = ~%GelStar%~ END
//END
//BUT_ONLY
//PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
//    LPF ~ALTER_ITEMABILITY~ INT_VAR ability_type = 2 projectile = ~%GelStar%~ END
//END
//BUT_ONLY
//ALTER_ITEM_ABILITY 0 INT_VAR type = 2 projectile = %GelStar%
//ALTER_ITEM_ABILITY 0 projectile = ~GelStar.pro~
//SET GelStarProjID = %last_added_projectile%
//ALTER_ITEM_ABILITY projectile = %GelStarProjID%
//ALTER_ITEM_ABILITY INT_VAR projectile = ~GelStar.pro~
//ALTER_ITEM_ABILITY projectile = ~GelStar.pro~
ALTER_ITEM_ABILITY projectile = %GelStar%

You see my struggle? xD

Comments

  • jmerryjmerry Member Posts: 4,106
    Well, for a start, it would help to use the right name for the function. It's "ALTER_ITEM_HEADER".

    How did I know that? I have a copy of the WeiDU documentation open in another tab, and I ran a search for ALTER_ITEM. It's a very useful reference. (No link, because the address of a file on my computer wouldn't help you. It can be found online, but I don't have a URL handy)

    Now, about those various ~~ and %% bits ...
    Both tildes and percent signs are string delimiters. If you have one layer of that, it means "treat whatever's inside as a string". And if you don't have that ... well, what you put there is already a string. So there's no difference between GelStar, ~GelStar~, and %GelStar%; the delimiters would only matter if they were enclosing something with spaces or other format-relevant characters.
    The second layer? Well, %% when you're already inside a string means "evaluate this as a variable". If you have an EVAL layer, as in AUTO_EVALUATE_STRINGS. Which would matter, except that the field you're trying to fill is looking for an integer - feed it a string, and it'll already automatically evaluate it as a variable in an attempt to get an integer out of it. So ~%GelStar%~ is also the same as GelStar.
    In this case, none of those ~~ and %% actually matter. Once you get the right function and the right syntax to launch it, any of those versions will work. Assuming you have in fact previously defined that variable, which isn't part of the code in this thread.
  • Gel87Gel87 Member Posts: 331
    edited February 28
    Okay, well i was actually inside weidu documentation looking, but my ctrl+f search probarly had wrong names so did not find it xD
    After i have attemped like 30-40 things im starting to understand some.
    The last string/code here actually worked :P
    I could not copy all because item had long descriptions etc.

    But it was something like:
    ADD_PROJECTILE ~GelNinj/Pro/GelStar.Pro~
    COPY ~GelNinj/Items/Gelshu1.itm~      ~Override~
    SAY NAME1 ~Ninja Star~
    SAY NAME2 ~Ninja Star +1~
    SAY UNIDENTIFIED_DESC ~Blabla~
    SAY IDENTIFIED_DESC ~BlaBlaMoreBla~
    ALTER_ITEM_ABILITY projectile = %GelStar%
    

    In the end i understood that ADD_PROJECTILE has autofunctions which stores last added projectile and refresh IDS. As well as i guess this is a kind of function block i now work on undearneath? And that this is the reason why i use %GelStar% function?

    As you can see i was close to ur version:
    // LPF ALTER_ITEM_ABILITY_HEADER INT_VAR projectile = %GelSmok% END
    So if i Scratched ABILITY in this line, would it work? I kinda struggle to see what i target now. I think i would need:
    LPF ALTER_ITEM_HEADER INT_VAR type = 2 projectile = %GelSmok% END
    But the issue there is that i have no referense to ability... So im trying to add a projectile to the item itself, and the item itself has no projectile. Its the ability that has it...
    So i would need something like:
    LPF ALTER_ITEM_HEADER INT_VAR ABILITY type = 2 projectile = %GelSmok% END
    But that is probarly wrongly formulated...
    So in the end the shortest working method which im actually understanding somewhat what im doing ended up wokring:
    ALTER_ITEM_ABILITY projectile = %GelStar%
    But it took me like 4 hours to add that single line correctly xD

    I also tried ALTER_ITEM_ABILITY 0, but lets say you had 3 different ranged albilities, and i wanted to specify one of them, then i think the issue is that NearInfinity Starts at Item Albility 0, meanwhile weidu maby starts counting from 1?

    Im kinda stuck offshore at work, so i dont have my previous mods to look on. And im using a new libary for kits which makes people like me struggle heavy. As I dont know enough sadly :(
    Even a simple Spell description ended up at the wrong place.
    I tried SAY DESC on that.
    Dno what i should use :P
    Post edited by Gel87 on
  • Gel87Gel87 Member Posts: 331
    edited February 28
    You are ofc 100% correct.
    The code i used just allowed me to install my mod, and it also blocked the previous projectile i add to a spell to also add it to my ninja stars.

    So I thought i had success due to item files copied already had the projectile added manual and exported.

    So when i try to install it to bgee instead of bg2ee they end up with same projectile id, only its flamestrike or something xD

    So now i dont know again.
    I understand i should use ALTER_ITEM_HEADER, but not how to properly target the item ability etc xD

    This would be my best guess:
    ALTER_ITEM_HEADER ability = 2 projectile = %GelStar%

    Is that correct or even remotely close?
    Ranged(2) so ability should be = 2? To make sure i enter the ability section.

    ALTER_ITEM_HEADER item ability = 2 projectile = %GelStar%

    ALTER_ITEM_HEADER ability 1 = 2 projectile = %GelStar%

    LPF ALTER_ITEM_HEADER ability = 2 projectile = %GelStar% END

    See, i have no idea what im doing xD
  • jmerryjmerry Member Posts: 4,106
    The LPF/LAF (or its unabbreviated form LAUNCH_PATCH_FUNCTION/LAUNCH_ACTION_FUNCTION) is not optional. Neither is the INT_VAR/STR_VAR declaration for the variables you're setting, if you're setting any variables. Though you can at least batch those and only have one variable type declaration per type used. And a function call is always closed with an END.

    So, a minimal call of this function to do what you're trying to do:
    LPF ALTER_ITEM_HEADER INT_VAR ability = 2 projectile = GelStar END
    
    This will change the item's second ability to use your new projectile. Leave any of the pieces I mentioned out, and the function call will fail with a syntax error.
  • Gel87Gel87 Member Posts: 331
    edited March 1
    When i look on weidu documentation:
    ALTER_ITEM_HEADER: patch ability headers on items. This is a PATCH function. All integer variables except match_icon and header default to -1 and negative values result in no change to the corresponding field. The integer variables match_icon and header default to 0. In the case of flags, a value of 1 will set the flag and a value of 0 will unset it. The string variable icon defaults to the string "same", which results in no change to the corresponding field.

    header_type is used to limit the scope of matching. The default value of -1 will match all types of headers while values of 0-4 will match headers with those values. If match_icon is 1, the icon resource reference will be match with the icon variable as an additional qualifier. This is useful for items which have multiple magic abilities. header can also be used to limit patching to the Nth header, counting from 1 as the first header. The default is 0, which will match all headers.

    So based on weidu documentation and bolded sections its a patch function.
    - So then i understand it so that i should use LPF (launch patch function)
    - ALTER_ITEM_HEADER is the correct one.
    - If i want to target specific albility, i need to choose between 1-4, meanwhile in nearinfinity this will be counting from 0. "Item Ability 0" in nearinfinity, should be 1 in weidu.

    INT_VAR projectile to the new projectile.
    - This one does not have any examples, so i better guess correct.
    So i guess either of theese should be correct:
    LPF ALTER_ITEM_HEADER INT_VAR projectile %GelStar% END
    
    LPF ~ALTER_ITEM_HEADER~ INT_VAR projectile %GelStar% END
    

    Google gave me an pretty excact example on how to formulate :D
    COPY ~%MOD_FOLDER%/kits/Objets/GWFlePu.itm~    ~override/GWFlePu.itm~    SAY NAME1 @7729309    SAY NAME2 @7729309
        LPF ALTER_ITEM_HEADER INT_VAR projectile = (IDS_OF_SYMBOL (projectl GWFlePu) + 1) END    // 3-Arrow Exploding (ARROWEX) : Only Enemy
        PATCH_IF (GW_EE) BEGIN
            LPF DELETE_EFFECT INT_VAR multi_match = 1 match_opcode = 12 match_savingthrow = 0 END
            LPF ALTER_EFFECT INT_VAR match_opcode = 12 dicenumber = 4 special = 256 END
        END
    BUT_ONLY
    

    This topic was actually genious for me xD
    https://www.gibberlings3.net/forums/topic/30658-weidu-items-basic-coding-problems/
    Post edited by Gel87 on
  • jmerryjmerry Member Posts: 4,106
    No. Neither of those are correct. Your level of cluelessness here ... have you ever coded anything before? These are the sort of errors that even an introductory programming course would train you out of. Specifically, that "projectile %GelStar%" phrase needs a verb. You have a variable name and a number there, and no relation between them.
    (That's my level of formal training: introductory courses.)

    Also, are you trying to match a specific header, or a specific type of header, or everything? And what do you think those percent signs do? (In this context, they don't do anything useful.)
  • Gel87Gel87 Member Posts: 331
    jmerry wrote: »
    No. Neither of those are correct. Your level of cluelessness here ... have you ever coded anything before? These are the sort of errors that even an introductory programming course would train you out of. Specifically, that "projectile %GelStar%" phrase needs a verb. You have a variable name and a number there, and no relation between them.
    (That's my level of formal training: introductory courses.)

    Also, are you trying to match a specific header, or a specific type of header, or everything? And what do you think those percent signs do? (In this context, they don't do anything useful.)

    I have only made kits for baldur's gate. Zero training other than learning some PLC programming on school 2 decades ago, and a calculator in visual basic 2 decades ago. And it took a long time before i even tried anything other than naming spells and adding kits in tp2 file.

    LPF ALTER_ITEM_HEADER INT_VAR projectile = %GelStar% END
    So the = is the verb?

    And those %, thats my issue. Lack of knowledge. All i know is that they are used if something has stored their referanse earlier, and i think ADD_PROJECTILE stores that?
    To be honest, when to use ~~ % and when its a string or something else than a string is hard for me to judge.

    So for me its like a need a full example, then i know how it should look like. And i learn more and more piece by piece :P
    Like this kit is the first time i actually made a BAM other than portraits or simple colour changes.

    It basicly takes me 10 minutes to build the spells and items in near infinity. And then it can take months to to finnish the mod because it requires a script to do what i want it to ingame :P
  • Gel87Gel87 Member Posts: 331
    jmerry wrote: »
    The LPF/LAF (or its unabbreviated form LAUNCH_PATCH_FUNCTION/LAUNCH_ACTION_FUNCTION) is not optional. Neither is the INT_VAR/STR_VAR declaration for the variables you're setting, if you're setting any variables. Though you can at least batch those and only have one variable type declaration per type used. And a function call is always closed with an END.

    So, a minimal call of this function to do what you're trying to do:
    LPF ALTER_ITEM_HEADER INT_VAR ability = 2 projectile = GelStar END
    
    This will change the item's second ability to use your new projectile. Leave any of the pieces I mentioned out, and the function call will fail with a syntax error.

    Thanks man :D
    I will remember this in the future :)
  • Gel87Gel87 Member Posts: 331
    edited July 3
    jmerry wrote: »
    No. Neither of those are correct. Your level of cluelessness here ... have you ever coded anything before? These are the sort of errors that even an introductory programming course would train you out of. Specifically, that "projectile %GelStar%" phrase needs a verb. You have a variable name and a number there, and no relation between them.
    (That's my level of formal training: introductory courses.)

    Also, are you trying to match a specific header, or a specific type of header, or everything? And what do you think those percent signs do? (In this context, they don't do anything useful.)

    Hello, im in dire need of help again.
    Im trying to add an effect inside a item ability, which is melee.

    I have tried loads of different stuff:
    PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
        		LPF ~ADD_ITEM_EFFECT~ INT_VAR ability = 1 opcode = 139 target = 2 timing = 1 parameter1 = RESOLVE_STR_REF (~Blinded~) resist_dispel = 3 power = 0 END
      	END
      	BUT_ONLY
    

    Also tried without the ~~ around ADD_ITEM_EFFECT



    And this:
    // Copy items
    COPY ~GelGlaB/Items/GEGLA10.itm~ ~override~
      SAY NAME1 ~Glass Sword +3~
      SAY NAME2 ~Glass Sword +3~
      PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
        READ_LONG  0x64 abil_off
        READ_SHORT 0x68 abil_num
        FOR (i = 0; i < abil_num; ++i) BEGIN
          READ_SHORT (abil_off + (i * 0x38)) ability_type
          PATCH_IF (ability_type = 1) BEGIN // 1 = melee
            LPF ADD_ITEM_EFFECT
              INT_VAR
                ability = i
                opcode = 139
                target = 2
                power = 0
                parameter1 = RESOLVE_STR_REF (~Blinded~)
                timing = 1
                resist_dispel = 0
    	    probability1 = 100
    	    probability2 = 0
    	    savingthrow = 1
    	    savebonus = 2
    
    
            END
          END
        END
      END
      BUT_ONLY
    

    And many more.

    Any idea?
    I want to add OP code (139) Display string. on melee item ability.
    Target preset(2)
    Power 0
    String Blinded
    Timing instant/permanent(1)
    Dispel/resistance Natural/nonmagical (0)
    Duration 0
    Probability 1 100
    Probability 2 0
    Save type (Spell)
    Save bonus (2)

    Last attempt this evening:
    COPY ~GelGlaB/Items/GEGLA10.itm~ ~override~
      SAY NAME1 ~Glass Sword +3~
      SAY NAME2 ~Glass Sword +3~
      PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
        LPF ADD_ITEM_EFFECT
          INT_VAR
            ability = 0 // Also tried ability 1, im kinda trying to target ability index 0, ability type melee and add effect.
            opcode = 139
            target = 2
            power = 0
            string = RESOLVE_STR_REF(~Blinded~)
            timing = 1
            resist_dispel = 0
            probability1 = 100
            probability2 = 0
            savingthrow = 1
            savebonus = 2
        END
      END
      BUT_ONLY
    

    Do it need to stay on 1 line like this?
    // Copy items
    COPY ~GelGlab/Items/GEGLA10.itm~ ~override~
      SAY NAME1 ~Glass Sword +3~
      SAY NAME2 ~Glass Sword +3~
      PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
      	LPF ADD_ITEM_EFFECT INT_VAR ability = 0 opcode = 139 target = 2 power = 0 string = RESOLVE_STR_REF(~Blinded~) timing = 1 resist_dispel = 0 probability1 = 100 probability2 = 0 savingthrow = 1 savebonus = 2 END
      END
      BUT_ONLY
    
  • Gel87Gel87 Member Posts: 331
    Maby this?
    COPY ~GelGlaB/Items/GEGLA10.itm~ ~override~
    SAY NAME1 ~Glass Sword +3~
    SAY NAME2 ~Glass Sword +3~

    PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    LPF ADD_ITEM_EFFECT
    INT_VAR
    ability = 0 // 1 or 0?
    opcode = 139 // Display string
    target = 2 // Preset target
    power = 0
    string = RESOLVE_STR_REF(~Blinded~)
    timing = 1 // Instant / Permanent
    resist_dispel = 0 // Ikke magisk
    probability1 = 100
    probability2 = 0
    savingthrow = 1
    savebonus = 2
    insert_point = -1 // Legg effekten sist
    END
    END
    BUT_ONLY
  • Gel87Gel87 Member Posts: 331
    edited July 4
    Okay, im trying to find different ways:
    Adding new OP code in item ability:
    COPY_EXISTING ~itemname.itm~ ~override~
      READ_LONG 0x64 abil_off
      READ_SHORT 0x68 abil_num
      READ_LONG 0x6a fx_off
      READ_SHORT 0x6e fx_num
    
      // Finn første ability (0)
      READ_SHORT (abil_off + 0x00) type
      PATCH_IF (type = 1) BEGIN // type 1 = melee
        READ_SHORT (abil_off + 0x1e) fx_idx
        READ_SHORT (abil_off + 0x20) fx_num
    
        // Sett inn ny effekt på slutten av eksisterende effekter
        WRITE_SHORT (abil_off + 0x20) (fx_num + 1)
    
        // Sett inn ny effekt på slutten av effektblokken
        INSERT_BYTES (fx_off + (fx_idx + fx_num) * 0x30) 0x30
        WRITE_SHORT (fx_off + (fx_idx + fx_num) * 0x30 + 0x00) 139 // opcode
        WRITE_SHORT (fx_off + (fx_idx + fx_num) * 0x30 + 0x02) 1   // target (self)
        WRITE_LONG  (fx_off + (fx_idx + fx_num) * 0x30 + 0x04) 0   // power
        WRITE_LONG  (fx_off + (fx_idx + fx_num) * 0x30 + 0x08) ~strref~ // strref til teksten
        // legg til andre felter som timing, varighet, etc. etter behov
      END
    BUT_ONLY_IF_IT_EXISTS
    

    Changing based on op code.
    PATCH_IF (type = 1) BEGIN
      FOR (i = 0; i < fx_num; ++i) BEGIN
        READ_SHORT (fx_off + (fx_idx + i) * 0x30 + 0x00) opcode
        PATCH_IF (opcode = 139) BEGIN
          WRITE_LONG (fx_off + (fx_idx + i) * 0x30 + 0x08) ~ny_strref~
        END
      END
    END
    

    Another change based on OP code:
    COPY ~override\mittitem.itm~ ~override~
      READ_LONG 0x64 abil_off
      READ_SHORT 0x68 abil_num
    
      // Les første ability (0)
      READ_SHORT (abil_off + 0x00) type
      PATCH_IF (type = 1) BEGIN // type 1 = melee
        READ_SHORT (abil_off + 0x1e) fx_idx
        READ_SHORT (abil_off + 0x20) fx_num
        READ_LONG 0x6a fx_off
        // Finn første ledige plass og skriv inn stringref
        FOR (i = 0; i < fx_num; ++i) BEGIN
          READ_SHORT (fx_off + (fx_idx + i) * 0x30 + 0x00) opcode
          PATCH_IF (opcode = 139) BEGIN
            WRITE_LONG (fx_off + (fx_idx + i) * 0x30 + 0x08) RESOLVE_STR_REF(~Blinded~)
          END
        END
    

    Add new effect.
    COPY ~override\mittitem.itm~ ~override~
      READ_LONG 0x64 abil_off
      READ_SHORT 0x68 abil_num
      READ_LONG 0x6a fx_off
      READ_SHORT 0x6e fx_num
    
      // Ability 0
      READ_SHORT (abil_off + 0x00) type
      PATCH_IF (type = 1) BEGIN
        READ_SHORT (abil_off + 0x1e) fx_idx
        READ_SHORT (abil_off + 0x20) fx_num
        // Oppdater antall effekter
        WRITE_SHORT (abil_off + 0x20) (fx_num + 1)
    
        // Sett inn ny effekt
        INSERT_BYTES (fx_off + (fx_idx + fx_num) * 0x30) 0x30
        WRITE_SHORT (fx_off + (fx_idx + fx_num) * 0x30 + 0x00) 139 // opcode
        WRITE_SHORT (fx_off + (fx_idx + fx_num) * 0x30 + 0x02) 2   // target: preset target
        WRITE_BYTE  (fx_off + (fx_idx + fx_num) * 0x30 + 0x04) 0   // power
        WRITE_BYTE  (fx_off + (fx_idx + fx_num) * 0x30 + 0x06) 1   // timing: instant/permanent
        WRITE_BYTE  (fx_off + (fx_idx + fx_num) * 0x30 + 0x0c) 1   // saving throw type
        WRITE_BYTE  (fx_off + (fx_idx + fx_num) * 0x30 + 0x0d) 2   // save bonus
        WRITE_LONG  (fx_off + (fx_idx + fx_num) * 0x30 + 0x08) RESOLVE_STR_REF(~Blinded~)
      END
    BUT_ONLY_IF_IT_EXISTS
    

    Now i have some new stuff to try out. Again my hope is active^^

    And also add death effect:
    COPY ~mymod/creatures/GEGLA8.cre~ ~override~
      SAY NAME1 ~Glass Sword~
      SAY NAME2 ~Glass Sword~
      WRITE_ASCII 0x270 ~mydeathspell~ #8 // Setter Death Spell
    COMPILE ~mymod/scripts/GEGLA8.baf~
    
  • Gel87Gel87 Member Posts: 331
    edited July 4
    Is the string ref 14674 always blind in every baldur's gate version?
    COPY ~GelGlaB/Items/GeGla10.itm~ ~Override~
    BEGIN ~Copy and modify Item~
    
    COPY ~GelGlaB/Items/GeGla10.itm~ ~Override~ 
    	SAY NAME1 ~Glass Sword +3~ // Unindentified name 
    	SAY NAME2 ~Glass Sword +3~ // Identified name  
      	PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    		LPF ALTER_ITEM_HEADER INT_VAR ability = 1 effect = 2 string = 14674 END
    	END  	
    BUT_ONLY
    CLEAR_IDS_MAP
    
Sign In or Register to comment.