Skip to content

-HOW TO DO STUFF IN WEIDU-

1234568

Comments

  • Jaguar_KnightJaguar_Knight Member Posts: 8
    I put it into PDF form so it can be viewable, this is from Steam!
  • SkitiaSkitia Member Posts: 1,059
    The pdf is coming off as corrupted so I can't use it. You can load it as a .txt if it's easier than doing it as a zip.
  • GwendolyneGwendolyne Member Posts: 461
    At first glance, it has nothing to do with the script, but more probably WeiDU can't load it. Did you check any possible typo in your code?
  • Jaguar_KnightJaguar_Knight Member Posts: 8
    Here you are, Skitia, Almost forgot I could make ZIPs for a moment there.

    And no, Gwen, at least, not that I think so. But I'll definitely look around for such.
  • Jaguar_KnightJaguar_Knight Member Posts: 8
    Gwen... you were correct. I was foolish, and one of my files were misspelled. Thank you for that.

    It fully installed... Now to see if the guy shows up.
  • GrammarsaladGrammarsalad Member Posts: 2,582
    edited May 2020
    No formatter is installed for the format deleted

    This should have been saved. It was very useful

    Edit: okay, I'll posta few basics re using splprot later
  • GwendolyneGwendolyne Member Posts: 461
    Gwen... you were correct. I was foolish, and one of my files were misspelled. Thank you for that.

    Usually, this kind of message (without any warning or message error) means that WeiDU did not find the library or file to be loaded or copied. Either you moved it to another place, or you misspelled it in your code. ;)
  • WizardStylesWizardStyles Member Posts: 1
    I need some help with patching existing items and spells.

    Specifically, I have created some items that can inflict conditions (Stunned etc.) accompanied by unique Display String effects.
    I'm now trying to ensure those strings aren't shown if the target is immune to the condition, by way of Opcode 267.

    For that, I need to add effects using Opcode 267 to creatures, spells, items and item abilities that have/confer relevant immunities. In all cases, I can copy existing Opcode 267 effects.

    Here is an example implementation for item (equipped) effects, mostly copy-pasted from Tweaks Anthology:
    COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
      READ_LONG  0x6a fx_off
      READ_SHORT 0x70 fx_num
      FOR (fx_curr = 0 ; fx_curr < fx_num ; ++fx_curr) BEGIN
        READ_SHORT (fx_off +        (fx_curr * 0x30)) opcode
        READ_LONG  (fx_off + 0x04 + (fx_curr * 0x30)) parameter1
          PATCH_IF (opcode = 267) AND (parameter1 = 25807) BEGIN
    	      LPF CLONE_EFFECT INT_VAR multi_match = 999999 match_opcode = 267 match_parameter1 = 25807 parameter1 = RESOLVE_STR_REF (@67) STR_VAR insert = ~last~ END
    	      LPF CLONE_EFFECT INT_VAR multi_match = 999999 match_opcode = 267 match_parameter1 = 25807 parameter1 = RESOLVE_STR_REF (@89) STR_VAR insert = ~last~ END
          END
      END BUT_ONLY
    

    Short summary:
    All items are copied, a for loop finds all existing 267 effects giving immunity to string 25807 ("Confused") and clones all such effects twice giving immunity to two other strings (@67 and @89). If any patching happens the patched item goes into the override folder.

    This works, and a very similar implementation is possible for effects that are part of .CRE files.

    But I don't know right now how exactly I would do this for item and spell abilities. So, to continue the example with string 25807, I'm not sure how to patch Chaotic Commands and all similar spells through a for loop.
    I'm not even sure if CLONE_EFFECT is really applicable in this case.

    Any help with this would be appreciated.
  • ithildurnewithildurnew Member Posts: 273
    edited July 2020
    [edit] slightly off topic, will post elsewhere
  • lroumenlroumen Member Posts: 2,508
    Hi all,

    I want to trigger an action or script upon reading a book. I would prefer not to only check if the item is in the inventory.
    Is it possible to trigger a script on the right-click book and "copy note" actions?
  • tl1942tl1942 Member Posts: 178
    @Jaguar_Knight The pdf and the zip are both corrupt, neither opens for me.
  • ALIENALIEN Member Posts: 1,271
    edited January 2021
    I would post the same topic at this forum but it doesn't have a 'Tutorials' section so it would be quickly lost. I'm posting it here to at least have it where the beginner's stuff is discussed.

    [Tutorial] How to properly handle mod translation by using HANDLE_CHARSETS function:
    https://www.gibberlings3.net/forums/topic/32369-tutorial-how-to-properly-handle-mod-translation-by-using-handle_charsets-function/
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited April 2021
    Fun with opcodes.

    So I'm trying to mod the Cloak of Mirroring (CLCK26.ITM) so it behaves like it did in Shadows of Amn, before Throne of Bhaal brought down the nerf-hammer on it.

    The original cloak used op code 203 to reflect spells back at the caster and that was it.

    The EE cloak uses 205 to protect from offensive spells, plus protection from 15 individual spells via opcode 206.

    I would like to change 205 to 203 as it was originally and clear the individual protections (I could possibly re-add some of them with opcode 197 against their projectile.)

    I'm using the following code to change 205 to 203 but it does nothing; could someone please tell me what I'm doing wrong here?
    ACTION_IF FILE_EXISTS_IN_GAME ~clck26.itm~ BEGIN
    COPY_EXISTING ~clck26.itm~ ~override~
    LPF ALTER_ITEM_EFFECT
    INT_VAR
    check_globals = 0
    match_opcode = 203
    END
    BUT_ONLY
    END
    
  • kjeronkjeron Member Posts: 2,367
    COPY_EXISTING ~clck26.itm~ override
    	LPF ALTER_EFFECT	INT_VAR	check_globals = 0	match_opcode = 205	opcode = 203	END
    	LPF DELETE_EFFECT	INT_VAR	check_globals = 0	match_opcode = 206	END
    BUT_ONLY IF_EXISTS
    
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited April 2021
    Thank you, @kjeron .

    Can LPF be used to alter the number of charges for an item's ability as well?

    Say I wanted to restore infinite charges to Algernon's Cloak, for example.


    EDIT:

    One more query.

    I'm writing a component to apply EE companion colors to vanilla games.

    I'm starting off my code as:
    ACTION_FOR_EACH creature IN ~ajantd~ ~ajanti~ ~ajanti4~ ~ajanti6~ BEGIN
    

    However this is limited these character files for Ajantis. If a mod introduces more variations for Ajantis, my code won't capture them. Is there a way to make my code dynamically pick up all creature files for a given companion regardless?
    Post edited by AndreaColombo on
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited July 2021
    [Deleted]
    Post edited by AndreaColombo on
  • AndreaColomboAndreaColombo Member Posts: 5,525
    If I wanted to remove an item from:

    - a location within an AR file
    - a store
    - a CRE's inventory

    What would be the code to do that?
  • GwendolyneGwendolyne Member Posts: 461
    WeiDU functions might help you:

    DELETE_CRE_ITEM: deletes all matching items from a creature. Regexp allowed. This is a PATCH macro and function
    DELETE_STORE_ITEM: deletes all matching items from a store. Regexp allowed. This is a PATCH macro and function
    DELETE_AREA_ITEM: deletes all matching items from an area. Regexp allowed. This is a PATCH macro and function.
    REMOVE_STORE_ITEM_EX: removes all sale instances matching the specified item name from the current STO file. This is a patch function
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited July 2021
    Thank you, @Gwendolyne !

    One more question: I opened one of the items I want to remove in NI and hit “Find References” to find out where it is; however even selecting all options for Find References, none were found. How can I identify the STO, CRE, or AR where the item is (and where within an AR)?
  • GwendolyneGwendolyne Member Posts: 461
    Very weird. It works fine on my side. Which items are you looking for?
  • AndreaColomboAndreaColombo Member Posts: 5,525
    Essentially I would to remove all items added by the Enhanced Editions to BG1 that are not part of one the EE NPC's plot.
  • GwendolyneGwendolyne Member Posts: 461
    edited July 2021
    It seems NI is still buggy when you run it on a SoD unmerged game. Argent77 will fix this.

    Here is the sw1h34 search result in SoD.
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited July 2021
    Thanks!

    So in the case of SW1H34, in order to remove it from the game I'd have to clear it from both the CREs and the scripts? What is the correct WeiDU command to clear it from the scripts?
    Post edited by AndreaColombo on
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited July 2021
    Nvm.
    Post edited by AndreaColombo on
  • AndreaColomboAndreaColombo Member Posts: 5,525
    Gwendolyne wrote: »
    WeiDU functions might help you:

    DELETE_AREA_ITEM: deletes all matching items from an area. Regexp allowed. This is a PATCH macro and

    For example,
    COPY_EXISTING ~AR0226.ARE~	// BG Sewers
    	LPF DELETE_AREA_ITEM INT_VAR item0 = 0 END	// item 0 = ninja-to +1
    BUT_ONLY
    

    Am I doing this right?
  • GwendolyneGwendolyne Member Posts: 461
    edited July 2021
    No, item_to_delete is a string variable:

    DELETE_CRE_ITEM: deletes all matching items from a creature. Regexp allowed. This is a PATCH macro and function.
    
        SPRINT item_to_delete to the item you want to delete. 
    
    DELETE_STORE_ITEM: deletes all matching items from a store. Regexp allowed. This is a PATCH macro and function.
    
        SPRINT item_to_delete to the item you want to delete. 
    
    DELETE_AREA_ITEM: deletes all matching items from an area. Regexp allowed. This is a PATCH macro and function.
    
        SPRINT item_to_delete to the item you want to delete.
    

    So, in your case:

    LPF DELETE_AREA_ITEM STR_VAR item_to_delete = SW1H49 END
    


    Edit: you can gather all items to delete in a single area:

    PATCH_FOR_EACH item_to_delete IN ~sw1h49~ ~misc48~ ~otheritem~ ... BEGIN
    	LPF DELETE_AREA_ITEM STR_VAR item_to_delete END
    END
    
    Post edited by Gwendolyne on
  • ArunsunArunsun Member Posts: 1,592
    Hi guys,

    Just wanted to share a small series of functions I made while developing kit mods. The goal is basically to simplify and streamline the spell creation process. It can be used to scale spells with level or stats automatically, simply by filling in a table. You may also find a few examples of what it can do.
    https://github.com/ZKArunsun/ZK_Weidu_Stuff

    I'm taking suggestions if you want me to add extra functionalities or functions.

    Happy modding!
  • afrothundaaaaafrothundaaaa Member Posts: 16
    Hello everyone. I am having trouble with the DELETE_ITEM_EFFECT patch function and I'm not sure what i'm doing wrong. I want to allow spellcasting on an item (opcode 145), and i am using this code and its not working, but not giving me errors, any idea what I've done wrong? I don't find many examples of LPF DELETE_ITEM_EFFECT when searching around
    COPY_EXISTING ~chan06.itm~ ~override~
      LPF DELETE_ITEM_EFFECT
      INT_VAR
        opcode_to_delete = 145
      END
    

    Anything obvious?
  • afrothundaaaaafrothundaaaa Member Posts: 16
    edited August 2021
    Deleted
    Hello everyone. I am having trouble with the DELETE_ITEM_EFFECT patch function and I'm not sure what i'm doing wrong. I want to allow spellcasting on an item (opcode 145), and i am using this code and its not working, but not giving me errors, any idea what I've done wrong? I don't find many examples of LPF DELETE_ITEM_EFFECT when searching around
    COPY_EXISTING ~chan06.itm~ ~override~
      LPF DELETE_ITEM_EFFECT
      INT_VAR
        opcode_to_delete = 145
      END
    

    Anything obvious?


    Apparently OPCODE 145 is just an EFFECT not an ITEM effect. I'm gonna herp and derp some more.
  • AndreaColomboAndreaColombo Member Posts: 5,525
    edited August 2021
    This is the code I use to allow spell casting in the crimson chain:

    LPF DELETE_EFFECT	INT_VAR	check_globals = 8	match_opcode = 145	END
    

    You need to tell the code with global has the effect you want to delete.
Sign In or Register to comment.