-HOW TO DO STUFF IN WEIDU-
System
Administrator Posts: 199
In the last year or two, I have picked up a lot of little techniques to mod many aspects of the game. Occasionally people ask me for advice (even though I am still a rank amateur), and I try to help. But rather than answer this question here, that question there, etc., I thought it would be nice to publish a FAQ-style thread with lots of tips and stuff. The goal is, people can pick up this code and drop it into a mod they are working on, rather than having to reinvent the wheel. Every mod is individual and involves individual effort, but say someone want to make stat-based kit effects; I can at least help you drop in to code for handling opcode 326 and splprot.2da, and then you can focus on making whatever cool effects you can imagine.
There will be no particular order for this stuff; I'll publish what I can, when I have time, if the mood strikes.
First up, in answer to a request from @Reddbane: how to make stat-based effects with opcode 326.
Second: how to add kit effects to all kits of a given class (including mod-added ones)
Third: how to target your mod kit with unique effects
Fourth: how to alter class/kit descriptions and not worry about string references
There will be no particular order for this stuff; I'll publish what I can, when I have time, if the mood strikes.
First up, in answer to a request from @Reddbane: how to make stat-based effects with opcode 326.
Second: how to add kit effects to all kits of a given class (including mod-added ones)
Third: how to target your mod kit with unique effects
Fourth: how to alter class/kit descriptions and not worry about string references
Post edited by Tresset on
20
Comments
Edit: Also, someone should sticky this thread. @JuliusBorisov
https://forums.beamdog.com/discussion/comment/752484/#Comment_752484
Edit: But it may have been this one:
https://forums.beamdog.com/discussion/comment/795058/#Comment_795058
In my TP2 file I write:
ACTION_IF (FILE_EXISTS_IN_GAME ~clastext.2da~) BEGIN
COPY_EXISTING ~clastext.2da~ ~override~
COUNT_2DA_COLS cols // amount of columns
READ_2DA_ENTRIES_NOW rows cols // read all file into memory
FOR (row = 1; row < rows; ++row) BEGIN // iterate over rows
READ_2DA_ENTRY_FORMER rows row 0 ~kit_name~ // read column value
PATCH_IF ~%kit_name%~ STRING_EQUAL_CASE ~SUN_SOUL~ BEGIN
SET patch_row = %row%
END
END
SET_2DA_ENTRY %patch_row% 5 cols RESOLVE_STR_REF (@20002)
BUT_ONLY
END
ACTION_IF (FILE_EXISTS_IN_GAME ~kitlist.2da~) BEGIN
COPY_EXISTING ~kitlist.2da~ ~override~
COUNT_2DA_COLS cols // amount of columns
READ_2DA_ENTRIES_NOW rows cols // read all file into memory
FOR (row = 1; row < rows; ++row) BEGIN // iterate over rows
READ_2DA_ENTRY_FORMER rows row 1 ~kit_name~ // read column value
PATCH_IF ~%kit_name%~ STRING_EQUAL_CASE ~SUN_SOUL~ BEGIN
SET patch_row = %row%
END
END
SET_2DA_ENTRY %patch_row% 5 cols RESOLVE_STR_REF (@20003)
BUT_ONLY
END
The part I don't understand is, "change the @_____ tra references to your own strings"
So I need to create a .tra file and put my new class description text in there? What is a .tra file and how do I create one? Sorry for the really basic questions. I only learned what TP2 files were and how to make/open them by asking in this thread: https://forums.beamdog.com/discussion/15010/short-introduction-to-weidu-and-simple-mod-template/p3
I figure by asking maybe other aspiring modders will be able to search and find the answers. Because I spent a while searching back when I knew absolutely nothing and most of the tutorials already assumed I knew many things that I didn't know. Like a book telling me how to row when I live in the desert, don't know how to swim, and have never seen a body of water.
Thanks.
Also what's the easiest way to edit a single line of a file? For example with my monk mod I change HPCLASS.2DA and change only monks to HBBARB and leave the rest intact. I could create a whole new file with Near Infinity (that's what I'm doing now) but then that creates compatibility issues with other mods. I'd prefer just to edit one line and I'm assuming there's an easy code to do that in my TP2 file in WeiDU and then I wouldn't have to overwrite the whole HPCLASS.2DA file.
So the first part of my tp2 file looks like this:
BACKUP ~WarriorMonkMod/backup~
AUTHOR ~Brandon Caesar at caesarbran@gmx.com~
VERSION ~Version1.03~
BEGIN ~BCaesar's Warrior Monk Mod~
COPY ~WarriorMonkMod/copy~ ~override~
COPY_EXISTING ~alignmnt.2da~ ~override~
SET_2DA_ENTRY 49 4 9 ~1~
SET_2DA_ENTRY 57 4 9 ~1~
SET_2DA_ENTRY 49 5 9 ~1~
SET_2DA_ENTRY 49 6 9 ~1~
SET_2DA_ENTRY 56 6 9 ~1~
COPY_EXISTING ~clsrcreq.2da~ ~override~
SET_2DA_ENTRY 55 2 7 ~1~
SET_2DA_ENTRY 55 3 7 ~1~
SET_2DA_ENTRY 55 4 7 ~1~
SET_2DA_ENTRY 55 5 7 ~1~
SET_2DA_ENTRY 55 6 7 ~1~
SET_2DA_ENTRY 55 7 7 ~1~
SET_2DA_ENTRY 57 2 7 ~1~
SET_2DA_ENTRY 57 3 7 ~1~
SET_2DA_ENTRY 57 4 7 ~1~
SET_2DA_ENTRY 57 5 7 ~1~
SET_2DA_ENTRY 57 6 7 ~1~
SET_2DA_ENTRY 57 7 7 ~1~
SET_2DA_ENTRY 58 2 7 ~1~
SET_2DA_ENTRY 58 3 7 ~1~
SET_2DA_ENTRY 58 4 7 ~1~
SET_2DA_ENTRY 58 5 7 ~1~
SET_2DA_ENTRY 58 6 7 ~1~
SET_2DA_ENTRY 58 7 7 ~1~
COPY_EXISTING ~hpclass.2da~ ~override~
SET_2DA_ENTRY 44 1 2 ~HPBARB~
SET_2DA_ENTRY 45 1 2 ~HPBARB~
SET_2DA_ENTRY 46 1 2 ~HPBARB~
COPY_EXISTING ~profs.2da~ ~override~
SET_2DA_ENTRY 19 1 3 ~5~
SET_2DA_ENTRY 19 2 3 ~2~
COPY_EXISTING ~profsmax.2da~ ~override~
SET_2DA_ENTRY 19 1 6 ~1~
SET_2DA_ENTRY 19 2 6 ~1~
SET_2DA_ENTRY 19 3 6 ~1~
SET_2DA_ENTRY 19 4 6 ~2~
COPY_EXISTING ~thiefscl.2da~ ~override~
SET_2DA_ENTRY 3 48 58 ~0~
SET_2DA_ENTRY 3 52 58 ~0~
SET_2DA_ENTRY 3 56 58 ~0~
SET_2DA_ENTRY 6 48 58 ~100~
SET_2DA_ENTRY 6 52 58 ~100~
SET_2DA_ENTRY 6 56 58 ~100~
COPY_EXISTING ~thiefskl.2da~ ~override~
SET_2DA_ENTRY 7 1 2 ~24~
SET_2DA_ENTRY 7 2 2 ~24~
But that brings me to WEAPPROF.2DA and the way I'm doing it now I'd need a separate entry for each weapon per each monk (which comes to something like 60 entries). Please tell me there's a better way to do that, like one single long entry that changes every row for a column or every column for a row.
Also I did what you suggested for the classes and it worked! I did it for clastext.2da for the monk and both kits and then for kitlist.2da for both kits. But I didn't use a .tra file instead I did it all in my .tp2 file using the way you mentioned. It makes my .tp2 file really long though, so I'm going to try the .tra thing tomorrow when I have time.
Question, is there a tool that can create a blank .tp2 or .tra file, or is the easiest way just to download a mod with a .tra file, delete what they wrote and write mine instead? That's how I got the .tp2 file I'm using.
Ok I think I'm almost able to consider this mod a finished product and get it added to the mod list, but I have another couple of questions (for you or anyone else reading this) if you're willing.
First is, I want to use WeiDU to modify WEAPPROF.2DA instead of overwriting the whole file and the way I did everything else in WeiDU I'd need a separate entry for each weapon per each monk (which comes to something like 60 entries). Do you know of a better way to do that, like one single long entry that changes every row for a column or every column for a row?
Secondly, for editing each file I followed your example and used:
SET_2DA_ENTRY #1 #2 #3 ~XXX~
With XXX being what I wanted to set it to, #1 being the row (minus the first three rows which are not part of the table), and #2 being the column (minus the first column as that's not part of the table either).
However I wasn't really sure what to put in #3. For the example you gave there were two columns total (including the 1st column which doesn't count for #2) so you used 2. So when I did it for the other files I usually put in a number equal to the total number of columns in the file, but often it edited a different line then the one I wanted and then I would keep trying slightly different numbers until it became right, but I'm sure there's a correct way for me to do it that avoids the futzing. Any advice?
One last questions, which I believe will actually be my final question for this mod:
In this mod I add two rows to STYLBONU.2DA. How would I do that in WeiDU (I'm not editing any rows, just adding two at the bottom.)
I add:
SINGLEWEAPON-3 0 0 0 0 -3 0 0 1
TWOHANDED-3 1 0 0 0 -1 0 -4 1
which just allows monks to put a 3rd point on Single weapon or two handed weapon which will give a 1 point AC bonus.
Thanks for all of your help!
APPEND ~stylbonu.2da~ ~SINGLEWEAPON-3 0 0 0 0 -3 0 0 1~
APPEND ~stylbonu.2da~ ~TWOHANDED-3 1 0 0 0 -1 0 -4 1~
and it worked (in the tp2 file there's a lot more space in between all the numbers so they line up right, but it doesn't show in this post).
So that's it! I'm done. Thank you so much for all of your help. And hopefully this helps other future modders searching for how to do stuff.
I tried this code:
LPF ADD_CRE_EFFECT INT_VAR opcode=37 target=1 timing=9 parameter1-=50 parameter2=0 END
But when I look at the effect in the file, the first parameter is equal to 0. I don't know how to make it negative.
It doesn't work.
LPF ADD_CRE_EFFECT INT_VAR opcode=37 target=1 timing=9 parameter1 = (0 - 50) parameter2=0 END
It produces an error message:
ERROR: cannot convert 0-50 or %0-50% to an integer
Never mind, I caught my problem. It works. Thank you!
I want a spell to display a custom string in the dialog box or over a character's head.
PS Sorry, didn't see ti was about opcode.
1. If your spell contains only a single Display String opcode you can use ALTER_SPELL_EFFECT to modify an existing opcode that you have already added to the spell via NI or DLTCEP:
COPY ~%MOD_FOLDER%/spells/myspell.spl~ ~override~ LPF ALTER_SPELL_EFFECT INT_VAR match_opcode = 139 // Display String parameter1 = RESOLVE_STR_REF(@123) // resolves tra reference into strref END
2. You can also create new opcodes completely in WeiDU:
COPY ~%MOD_FOLDER%/spells/myspell.spl~ ~override~ LPF ADD_SPELL_EFFECT INT_VAR opcode = 139 // Display String target = 2 // Preset target parameter1 = RESOLVE_STR_REF(@123) // resolves tra reference into strref timing = 1 // Instant/Permanent until death resist_dispel = 1 END
You can use opcode 330 (Float text) if you want to display text over the target's head instead.
This didn't work for me:
COPY blah blah blah
SAY blah blah blah
COPY blah blah blah
ADD_PROJECTILE blah blah blah
But this did work for me:
COPY blah blah blah
ADD_PROJECTILE blah blah blah
SAY blah blah blah
This way, WeiDu will add the projectile and still keep the right name and description. This probably applies to spells as well as items.
EDIT: Corrected a mistake and updated with advice from @argent77.
Example:
COPY ~%MOD_FOLDER%/items/myitem.itm~ ~override~ SAY NAME1 ~blah~ COPY_EXISTING ~myitem.itm~ ~override~ // do some other stuff...