Skip to content

General mod Questions thread

1222325272870

Comments

  • BubbBubb Member Posts: 999
    edited May 2018
    Is there a WeiDU equivalent of a conventional switch statement, or perhaps an else-if? At the moment I am using this to set the base directory for all of my copy operations, but as I add more and more entries, the chain gets more and more unmanageable:

    ACTION_IF GAME_IS ~bgee~ AND GAME_INCLUDES ~sod~ BEGIN OUTER_SPRINT game_directory ~bubb_spell_menu_extended\bgee+sod~ END ELSE BEGIN ACTION_IF GAME_IS ~bg2ee~ BEGIN OUTER_SPRINT game_directory ~bubb_spell_menu_extended\bg2ee~ END ELSE BEGIN ACTION_IF GAME_IS ~iwdee~ BEGIN OUTER_SPRINT game_directory ~bubb_spell_menu_extended\iwdee~ END ELSE BEGIN FAIL ~Game not supported.~ END END END
    As you can see, the indentation increases for every single new entry I check for. Is there a cleaner way to do this?
  • argent77argent77 Member Posts: 3,431
    Yes, there are several options.

    You can use the MATCH construct, e.g.
    ACTION_MATCH ~%WEIDU_OS%~ WITH ~win32~ BEGIN // equivalent to ~%WEIDU_OS%~ STR_EQ ~win32~ END ~osx~ ~unix~ BEGIN // matches either ~osx~ or ~unix~ END DEFAULT // the "ELSE" branch END
    Or you could simplify the IF/ELSE construct by combining ELSE directly with another ACTION_IF, e.g.
    ACTION_IF GAME_IS ~bgee~ BEGIN // ... END ELSE ACTION_IF GAME_IS ~bg2ee~ BEGIN // ... END ELSE ACTION_IF GAME_IS ~iwdee~ BEGIN // ... END ELSE BEGIN // ... END
    Bubblefreut
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    Does WeiDU have any mathematical operators for variables? Could I read a creature file's Strength and Constitution and use it to calculate their Dexterity? For example, would it be possible to patch creatures so that their DEX would always be the average of their STR and CON?
  • [Deleted User][Deleted User] Posts: 0
    edited May 2018
    The user and all related content has been deleted.
    semiticgoddess
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited May 2018
    Could someone help me edit rebalanced_profs.tpa (Tweaks Anthology)?
    I'd like to:
    • combine Long swords and Bastard swords into a single proficiency;
    • combine Longbows and Shortbows into a single proficiency;
    • combine Halberds and Spears into a single proficiency.
  • The user and all related content has been deleted.
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    Yeah, the problem is that your solution is quite different from that of @CamDawg ....
    For example, he doesn't modify any opcode 233 and uses regular expressions together with OUTER_SPRINT in order to edit the relevant strings on the fly....
  • The user and all related content has been deleted.
    _Luke_
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    edited May 2018

    Well, if you post the relevant code from Tweaks I can talk you through what it does...

    Here is the file (attached to this post)

    It for sure addresses all your 4 points (I've already played the game with this component...).
  • [Deleted User][Deleted User] Posts: 0
    edited May 2018
    The user and all related content has been deleted.
    Post edited by [Deleted User] on
  • _Luke__Luke_ Member, Mobile Tester Posts: 1,535
    @subtledoctor Macro prof_descripts is at line 4 of rebalanced_profs.tpa.

    And yes, it's kind of hard to understand this code....
    Maybe @kjeron is able to provide some help.....
  • The user and all related content has been deleted.
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    I have a complex command I'd like to give in WeiDu. See, mage scrolls in IWD2 are hard-coded to their spell schools. So, you can try to rig a Diviner to be able to learn Invocation spells by editing a .2da table and make a Fireball scroll usable by Diviners, but the Diviner can't scribe the scroll--they can only cast it.

    You can, however, add a "Learn Spell" opcode to the scroll, so it automatically adds Fireball to the user's spellbook the moment they cast Fireball via the scroll. Note that the Learn Spell opcode has to come after the Cast Spell opcode.

    How could I automate this process? All scrolls have two abilities, one with a Cast Spell opcode and one with a Learn Spell opcode. How would I attach a Learn Spell opcode to the Cast Spell ability while making sure that Learn Spell comes after Cast Spell?
  • The user and all related content has been deleted.
    semiticgoddess
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    @subtledoctor: How do I use this command? That is, how do I target the ability in question? The online descriptions of the command are opaque and I'm not sure if they apply to items or just spells.
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    Okay, I found an easier template to work with. Looks like the end result was this:

    COPY_EXISTING ~spwi103z.itm~ ~override~
    LPF CLONE_EFFECT INT_VAR match_opcode = 148 opcode = 147 parameter1 = 0 parameter2 = 0 END

    ...which apparently finds the ability with opcode 148, duplicates that opcode and switches it to 147, and then sets both parameters to zero.
  • [Deleted User][Deleted User] Posts: 0
    edited May 2018
    The user and all related content has been deleted.
    semiticgoddess
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    I've actually found the WeiDU readme to be extremely difficult to understand. I have trouble understanding it even when it's talking about a command I already know how to do.

    But now that you mention WeiDU readme rather than WeiDU "documentation," I get the feeling that you might be referring to a different document. The one I keep seeing, and keep having trouble understanding, is the WeiDU Documentation by Weimer himself. But when I look up the readme, I see a document by The Bigg and Wisp that's much easier to understand.
    mashedtaters
  • kjeronkjeron Member Posts: 2,367

    The one I keep seeing, and keep having trouble understanding, is the WeiDU Documentation by Weimer himself. But when I look up the readme, I see a document by The Bigg and Wisp that's much easier to understand.

    That first one is outdated, longer than I know.
    The second one is what I have bookmarked.
    semiticgoddess
  • The user and all related content has been deleted.
  • semiticgoddesssemiticgoddess Member Posts: 14,903
    I'm trying to use ADD_CRE_EFFECT to patch all critters with a set of effects. Since I can't put negative values for the parameters, I decided to try using Apply Effects List, opcode 402, to apply all the effects from a spell, USSTSD01.spl, to all critters. But WeiDU fails when I try to run this code, saying it can't resolve USSTSD01 or %USSTSD01% to an integer:

    COPY_EXISTING_REGEXP ~.*\.cre~ ~override~
    LPF ADD_CRE_EFFECT INT_VAR opcode = 402 target = 1 parameter1 = 0 parameter2 = 0 timing = 9 sourceslot = USSTSD01 END
  • BubbBubb Member Posts: 999
    @semiticgod
    The error is because sourceslot is supposed to be an integer, and you've given it a string. In other circumstances, when you want to pass a variable into a function as a string, you add a STR_VAR section, like so:

    LPF ADD_CRE_EFFECT INT_VAR opcode = 402 target = 1 parameter1 = 0 parameter2 = 0 timing = 9 STR_VAR resource = ~USSTSD01~ END
    I don't think sourceslot is the correct variable for you to use in this circumstance; it has something to do with what inventory slot an effect is originating from (I think? The WeiDU docs are very confusing in this circumstance, IMO).

    Anyways, when I was trying to test how this all works, I noticed that ADD_CRE_EFFECT does literally *nothing* when used with Icewind Dale 2; maybe it doesn't understand v2.2 CRE files? Sorry I wasn't much help, you can consider me quite confused as well - I just wanted to post my confusing results ...
    semiticgoddess
  •  TheArtisan TheArtisan Member Posts: 3,277
    edited May 2018
    I'm working on a mod component that replaces the druid's shapeshift abilities with a wild shape ability. How could I write a WeiDU command to replace all of the relevant GA_ with either a blank **** or a GA_ of my custom spell?
  • mashedtatersmashedtaters Member Posts: 2,266
    edited May 2018
    Hey this is a great thread, just stumbled across it.

    Here’s my question:

    Can you use CHAIN to cause more than two NPCs to banter? How would this be written? For example, would you just call up the third NPC, just like you would the second NPC?

    CHAIN
    IF~~THEN
    J3TEST samplechain
    ~heya, it’s me imoen!~
    IMOEN2J
    == ~Heya, that’s my line!~
    JAHEIRAJ
    == ~Oh no, not another one!~
    = ~Please, no more~
    OTHERNPC
    == ~what??!~
    J3TEST
    == ~Sorry, guys~
    EXIT

    I’m sorry if this question has been answered in this thread, but I can’t seem to find an answer to it anywhere online in the dozens of CHAIN tutorials I’ve read. I’m too unfamiliar with modding at this point to know if it’s doable before I write any more dialogue.
  • ArunsunArunsun Member Posts: 1,592

    Hey this is a great thread, just stumbled across it.

    Here’s my question:

    Can you use CHAIN to cause more than two NPCs to banter? How would this be written? For example, would you just call up the third NPC, just like you would the second NPC?

    CHAIN
    IF~~THEN
    J3TEST samplechain
    ~heya, it’s me imoen!~
    IMOEN2J
    == ~Heya, that’s my line!~
    JAHEIRAJ
    == ~Oh no, not another one!~
    = ~Please, no more~
    OTHERNPC
    == ~what??!~
    J3TEST
    == ~Sorry, guys~
    EXIT

    I’m sorry if this question has been answered in this thread, but I can’t seem to find an answer to it anywhere online in the dozens of CHAIN tutorials I’ve read. I’m too unfamiliar with modding at this point to know if it’s doable before I write any more dialogue.

    You may use a chain to have more than 2 npcs to banter but the syntax on chain would be:


    CHAIN
    IF~~THEN
    J3TEST samplechain
    ~heya, it’s me imoen!~
    == IMOEN2J
    ~Heya, that’s my line!~
    == JAHEIRAJ
    ~Oh no, not another one!~
    = ~Please, no more~
    ==OTHERNPC
    ~what??!~
    ==J3TEST
    ~Sorry, guys~
    EXIT


    So basically "== dialogfilename ~string~"
  • mashedtatersmashedtaters Member Posts: 2,266
    @Arunsun Oh yeah! Sorry, my bad, I knew that. Lol.

    Thanks!

    So how would you insert a player dialogue reply into the middle of that?
  • mashedtatersmashedtaters Member Posts: 2,266
    I’m guessing you would have to END it, then do a SAY, and then jump back to a CHAIN? It seems that the PC could only respond to J3TEST in a scenario like that.
  • ArunsunArunsun Member Posts: 1,592

    @Arunsun Oh yeah! Sorry, my bad, I knew that. Lol.

    Thanks!

    So how would you insert a player dialogue reply into the middle of that?


    Chain is designed for long discussions between NPCs. If you want a player dialog reply, you will have to cut the chain in the middle, using "END Filename StateNumber" instead of exit. This ends the chain and transfers to the state StateNumber of the file Filename. Then this state would send you to another chain. I would advise only doing that for very long banters with seldom player interventions, as it is pretty easy to get lost.

    For a banter like yours I'd just use the normal dialog structure with EXTERNs.
  • mashedtatersmashedtaters Member Posts: 2,266
    So basically, if I were to design two mods that conversed together with another NPC, and the PC were to reply to any/all of them, then I would have to create new files for the each NPC mod and APPEND to the existing NPC and create new SAY blocks.
  • kjeronkjeron Member Posts: 2,367

    I'm trying to use ADD_CRE_EFFECT to patch all critters with a set of effects. Since I can't put negative values for the parameters, I decided to try using Apply Effects List, opcode 402, to apply all the effects from a spell, USSTSD01.spl, to all critters. But WeiDU fails when I try to run this code, saying it can't resolve USSTSD01 or %USSTSD01% to an integer:

    COPY_EXISTING_REGEXP ~.*\.cre~ ~override~
    LPF ADD_CRE_EFFECT INT_VAR opcode = 402 target = 1 parameter1 = 0 parameter2 = 0 timing = 9 sourceslot = USSTSD01 END

    Negative values must be entered as expressions or string (they are still not usable in the "ALTER_/CLONE_/DELETE_" functions, since those use negative values for other purposes).
    String variables must have delimeters, and an EVAL if they themselves contain variables.
    
    COPY_EXISTING_REGEXP ~.*\.cre~ ~override~
    LPF ADD_CRE_EFFECT
     INT_VAR	//	integer variables
    	opcode = (0 - 1)	// expression
    	target = "-1"	// various delimeters
    	parameter1 = %-1%
    	parameter2 = ~-1~
    	timing = ~~~~~-1~~~~~
     STR_VAR	//	string variables
    	resource = ~USSTSD01~	//	Primary resource field, same as used in Spells/Items
    	resource2 = EVAL ~%file%~	// extra Resource field only used by a few opcodes
    	vvcresource = "USSTSD02"	// extra Resource field only used by a few opcodes
    	effsource = %USSTSD03%	// parent resource field, only used in specific situations, but must always be in ALLCAPS when it used.
    	effvar = ~~~~~scriptvariablename~~~~~	// only used by opcode 187 AFAIK
    END
    "sourceslot" is not one that you will ever likely need to use.
Sign In or Register to comment.