Howdy, Stranger!

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

Categories

Axis & Allies 1942 Online is now available in Early Access! Buy it on Steam. The FAQ is available.
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

-HOW TO DO STUFF IN WEIDU-

subtledoctorsubtledoctor Member Posts: 11,174
edited December 2016 in General Modding
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

Post edited by subtledoctor on
mf2112AquadrizztRavenslightargent77GrammarsaladJuliusBorisovBillyYanktbone1elminsterProontNoloirlolien
«134567

Comments

  • subtledoctorsubtledoctor Member Posts: 11,174
    By the way, I don't mean for every post in this thread to be by me; if anyone has any questions about these or any other techniques, please post them and we'll discuss them. If anyone has suggestions or requests for stuff to talk about, again, let us know here in the comments.

    Also, I very much welcome "guest lecturers" here. If anyone has developed a snippet of code that is useful and/or adaptable, go ahead and post about it. I think @Aquadrizzt might talk about some techniques from his mods. Anyone else is welcome as well! I'll put links to any substantive posts up in the top of the thread, for easy access.

  • BillyYankBillyYank Member Posts: 2,687
    edited November 2016
    You should add your tutorial/template on how to add an item here also.

    Edit: Also, someone should sticky this thread. @JuliusBorisov

    JuliusBorisov
  • subtledoctorsubtledoctor Member Posts: 11,174
    BillyYank said:

    You should add your tutorial/template on how to add an item here also.

    Did I do that? I don't even remember. :lol:

    If you can find it, I'll happily post it here (and update it if necessary.

    I don't mind stickying, but I do notice that there are a ton of stickied threads in this forum, it should probably be cleaned up a bit.

  • subtledoctorsubtledoctor Member Posts: 11,174
    edited September 2018
    HOW TO TARGET YOUR MOD KIT WITH UNIQUE EFFECTS

    Let's say you are making a kit mod, and you want to target your kit with opcode 177 "use .eff" effects, or opcode 326 "apply effects list" effects. Here's an example:

    Say you make a sorcerer kit, and the theme is that it channels magical energy better than most sorcerers. Call it a "Channeler." Of course you will have read the excellent tutorial on creating KIT mods, so you know the first line of your ADD_KIT routine will look like this:
    ADD_KIT ~D5_CHANNELER~
    That name is how the engine recognizes your kit... sometimes. Other times, it refers to the kit's value in the KIT.IDS file.

    Say you want to add a special disadvantage, that every time a Channeler is struck by Magic Missile, they take an extra 2d4 magic damage. Because magic just flows through them too easily. The way to do this is to add an effect to the Magic Missile, using opcode 177 and targeting your kit, and making an .eff file that applies the damage. Opcode 177 uses the kit's value in KIT.IDS. For vanilla kits this is easy, they are listed in KIT.IDS and you can look up their value there and plug it into the 177 effect.

    But mod-added kits are added to KIT.IDS sequentially, and you have no idea how many kit mods a player might install, or in what order. So how do you add that 177 effect to Magic Missile?

    Well, each kit is listed in KITLIST.2DA, with its name and .2da clab table and description strings, etc. And in the EEs there is an extra column that contains the kit's IDS value. So with this file we can link the kit's name (which you will know, because you named it) to the kit's IDS value (which you will never know ahead of time. The following code will read the contents of that .2da file, find the line with your kit's name, and spit out the associated IDS value as a variable that you can use elsewhere.
    COPY_EXISTING ~kit.ids~ ~override~
    COUNT_2DA_COLS cols
    READ_2DA_ENTRIES_NOW rows cols
    FOR (row = 1; row < rows; ++row) BEGIN
    READ_2DA_ENTRY_FORMER rows row 1 ~this_kit~
    PATCH_IF ~%this_kit%~ STRING_EQUAL_CASE ~D5_CHANNELER~ BEGIN
    SET this_row = %row%
    READ_2DA_ENTRY_FORMER rows this_row 0 channeler_code
    END
    END
    BUT_ONLY
    That is a bit hard to digest; I find the READ_2DA_FORMER/NOW stuff difficult to understand. But the nice thing is, there is no need to actually understand this. You can copy that and drop it directly into your own .tp2 code. The only thing you need to worry about is where it says: "...STRING_EQUAL_CASE ~D5_CHANNELER~..." J
    just put your own kit's name between those two tildes: ~...~. The IDS value for your kit will be encoded into the %channeler_code% variable at the end there. (You can rename that variable if you like.)

    Now, armed with that variable, we can edit Magic Missile:
    COPY_EXISTING ~spwi112.spl~ ~override~
    LPF ADD_SPELL_EFFECT INT_VAR opcode = 177 parameter1 = %channeler_code% STR_VAR resource = ~D5_MDMG~ END
    (Where "D5_MDMG.EFF" is the name of the .eff file you created that does the extra magic damage.)

    You could also edit items to have unique characteristics with your kit, using ADD_ITEM_EFFECT or ADD_ITEM_EQEFFECT. Maybe the Staff of Power's thunderbolt ability does extra damage when used by a Channneler. Maybe a fleet-of-foot thief kit gets 2 extra APR when using Belm, instead of just one. The sky is the limit; you just need to know your kit's IDS value in order to make effects like that, and this code gives you that.

    Post edited by subtledoctor on
    GrammarsaladNoobaccaJuliusBorisovProont
  • BCaesarBCaesar Member Posts: 180
    Ok so I want to change the description (column 5) for the Sun Soul Monk for example (and the Trueclass Monk and Dark Moon Monk, but lets start with Sun Soul). I only need to change the SWASHBUCKLER to SUN_SOUL and then I'm only patching column 5 in both files. So it looks like this:

    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.

  • BCaesarBCaesar Member Posts: 180
    edited December 2016
    Also while I'm asking questions, if I have a mod that is only for Baldur's Gate 1:EE version 2.0 and later without SoD, so I am fine with editing a single string of dialog.tlk how to I do that?

    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.

  • subtledoctorsubtledoctor Member Posts: 11,174
    edited December 2016
    BCaesar said:

    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.

    No worries! First, I don't believe you need to use a .tra file... you can just put a string in quotes/tildes/delimiters there, so it could look like this (I think):
        SET_2DA_ENTRY %patch_row% 5 cols RESOLVE_STR_REF (~Your text here!~)
    I've been using .tra files for a while... it's just a text file, like the .tp2. It has a list of "@" references like this:
    @1  = ~text~
    @2 = ~other text~
    @4 = ~et cetera~
    See, connected to each "@number" is a string that looks just like you have in your mod. You move all the strings out to en external document and put matching "@number" references into your .tp2 file. This way, if you want to add support for other languages to your mod, a translator only has to translate the .tra file, put the translated version into a different language directory, and your .tp2 file can use it automatically, by adding something like this in the front:
    LANGUAGE
    ~English~
    ~english~
    ~scales_of_balance/language/en_US/setup.tra~
    LANGUAGE
    ~Polski (Translation by etamin)~
    ~polish~
    ~scales_of_balance/language/en_US/setup.tra~
    ~scales_of_balance/language/pl_PL/setup.tra~
    Otherwise, to get a translation of the mod, you would have to make a translated duplicate of the whole .tp2 file. And then what if you want to change something later? You would have to meticulously keep all versions of the .tp2 file in sync... it would be a nightmare.
    BCaesar said:

    Also while I'm asking questions, if I have a mod that is only for Baldur's Gate 1:EE version 2.0 and later without SoD, so I am fine with editing a single string of dialog.tlk how to I do that?

    Not sure exactly what you mean by this. If you know a particular string reference (but remember, they are different in each game!), you can replace that string using SET_STRING.
    BCaesar said:

    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.

    This depends. For any given file, there may or may not be a good way to do something like this. But specifically for .2da files, which are always sort of arranged like a spreadsheet, Weidu has nice tools to analyze and edit them. Some of which I've used in the posts above.

    For your edit to HPCLASS.2DA, it is a simple matter: you wan to use SET_2DA_ENTRY:
    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~
    That will change the entries for Monk, Sun Soul, and Dark Moon. (Which are in the 44th, 45th, and 46th rows of that file that have at least two colunms. That explains the 1st and 3rd numbers in those lines. The 2nd number, "1," is slightly trickier: it tells Weidu to edit the entry in the second column... because for whatever reason, in this instance, it starts counting at zero.)

  • BCaesarBCaesar Member Posts: 180



    This depends. For any given file, there may or may not be a good way to do something like this. But specifically for .2da files, which are always sort of arranged like a spreadsheet, Weidu has nice tools to analyze and edit them. Some of which I've used in the posts above.

    For your edit to HPCLASS.2DA, it is a simple matter: you wan to use SET_2DA_ENTRY:

    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~
    That will change the entries for Monk, Sun Soul, and Dark Moon. (Which are in the 44th, 45th, and 46th rows of that file that have at least two colunms. That explains the 1st and 3rd numbers in those lines. The 2nd number, "1," is slightly trickier: it tells Weidu to edit the entry in the second column... because for whatever reason, in this instance, it starts counting at zero.)
    Ok so for my monk mod here, I deleted a bunch of my 2da files and achieved the same thing using my tp2 file. It took a number of tests to get it right but it seems to work now.

    So the first part of my tp2 file looks like this:
    BACKUP ~WarriorMonkMod/backup~

    AUTHOR ~Brandon Caesar at [email protected]~

    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.

  • subtledoctorsubtledoctor Member Posts: 11,174
    @BCaesar Look up the --traify argument. I forget exactly how, but you run Weidu with that argument and it generates one automatically.

  • BCaesarBCaesar Member Posts: 180

    @BCaesar Look up the --traify argument. I forget exactly how, but you run Weidu with that argument and it generates one automatically.

    Thanks, I just copied the .tra file from the Imoen Romance and then wiped it and set mine up the same way they did and that worked fine.

    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?

  • subtledoctorsubtledoctor Member Posts: 11,174
    @BCaesar There's no shorter way to deal with weapprof.2da. One of my mods affects every class and kit, it has like 800 lines of SET_2DA_ENTRY's. It's insane.

    The #3 number is the "minimum column count." So when you say row # whatever, if that row has fewer columns than the number in #3, it will be ignored. WHat this really means is that there are only two things you should put here: 1, or the actual column count of the 2da table. For a file like weapprof.2da, just put 1. The only issue this causes is that some rows, like the very first one with some garbage text, get counted in your row count - because that garbage is considered a column. All this means is that your row number might be different. But that doesn't matter because you just put whatever row number works.

    If you use 1 in #3 with weapprof, I believe row 11 is bastard sword, and row 34 is dual-wielding, and everything else you could possibly want to change is between those two rows. (I think those are the numbers you would use in #1... easy enough to double-check.)

  • BCaesarBCaesar Member Posts: 180

    @BCaesar There's no shorter way to deal with weapprof.2da. One of my mods affects every class and kit, it has like 800 lines of SET_2DA_ENTRY's. It's insane.

    The #3 number is the "minimum column count." So when you say row # whatever, if that row has fewer columns than the number in #3, it will be ignored. WHat this really means is that there are only two things you should put here: 1, or the actual column count of the 2da table. For a file like weapprof.2da, just put 1. The only issue this causes is that some rows, like the very first one with some garbage text, get counted in your row count - because that garbage is considered a column. All this means is that your row number might be different. But that doesn't matter because you just put whatever row number works.

    If you use 1 in #3 with weapprof, I believe row 11 is bastard sword, and row 34 is dual-wielding, and everything else you could possibly want to change is between those two rows. (I think those are the numbers you would use in #1... easy enough to double-check.)

    Thanks! I did all that and it worked. I also changed the 3rd column for all of my previous .tp2 file edits to be 1 and that worked better (for anyone reading this who wants to know the details of what I did it's all in my thread here: https://forums.beamdog.com/discussion/62614/warrior-monk-mod-version-1-05-for-bg1-ee

    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!

  • subtledoctorsubtledoctor Member Posts: 11,174
    edited January 2017
    @BCaesar look up APPEND

    EDIT - in fact I use it in the 2nd post in this thread. Just:
    APPEND ~stylbonu.2da~ ~string~
    Just, with .2da files, make sure you get the number of columns right.

  • BCaesarBCaesar Member Posts: 180
    edited January 2017

    @BCaesar look up APPEND

    EDIT - in fact I use it in the 2nd post in this thread. Just:

    APPEND ~stylbonu.2da~ ~string~
    Just, with .2da files, make sure you get the number of columns right.
    Ok I used:
    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.

  • OlvynChuruOlvynChuru Member Posts: 2,237
    I'm having trouble figuring out how to give effects to creatures in WeiDU. For example, I want to give the level 6 Minsc file "MINSC6" a minimum damage effect (opcode 250) and set the first parameter to 20. What would be the code for that?

  • subtledoctorsubtledoctor Member Posts: 11,174

    I'm having trouble figuring out how to give effects to creatures in WeiDU. For example, I want to give the level 6 Minsc file "MINSC6" a minimum damage effect (opcode 250) and set the first parameter to 20. What would be the code for that?

    Something like
    COPY_EXISTING ~minsc6.cre~ ~override~
    LPF ADD_CRE_EFFECT INT_VAR opcode=250 target=1 timing=9 parameter1=20 resist_dispel=0 END
    BUT_ONLY
    I didn't test that, but it should work.

    OlvynChuru
  • OlvynChuruOlvynChuru Member Posts: 2,237
  • OlvynChuruOlvynChuru Member Posts: 2,237
    Now I'm wondering how to set a parameter in an effect to a negative value in WeiDU. For example, I want to give Dorn a large penalty to Save vs Spell.

    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.

  • subtledoctorsubtledoctor Member Posts: 11,174
    parameter1 = (0 - 50)

    But be aware, negative values do not work in all of these functions. I *think* it works in this one, but it does not work in ALTER_EFFECT or CLONE_EFFECT.

    Grammarsalad
  • OlvynChuruOlvynChuru Member Posts: 2,237
    edited February 2017
    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!

  • semiticgodsemiticgod Member, Moderator Posts: 13,325
    I know how to assign new strings to items and spells, but how do you create a custom string that you can use in the Display String opcode?

    I want a spell to display a custom string in the dialog box or over a character's head.

  • ArdanisArdanis Member Posts: 1,617
    edited February 2017
    DisplayStringHead(Myself,@123) // where @123 is a standard .tra reference

    PS Sorry, didn't see ti was about opcode.

    Post edited by Ardanis on
  • argent77argent77 Member Posts: 2,733

    I know how to assign new strings to items and spells, but how do you create a custom string that you can use in the Display String opcode?

    I want a spell to display a custom string in the dialog box or over a character's head.

    There are several options.

    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.

    ArdanissemiticgodCrevsDaak
  • semiticgodsemiticgod Member, Moderator Posts: 13,325
    @argent77: I forgot to mention--your solution worked! I got the message to display properly using yoru code and the Float Text opcode. Thank you!

    GrammarsaladCrevsDaak
  • semiticgodsemiticgod Member, Moderator Posts: 13,325
    edited February 2017
    I made a discovery: adding a projectile to an item in WeiDu using the ADD_PROJECTILE function can overwrite any custom name or description you've given to the item using the SAY function, if you've used the COPY function earlier in your TP2 file. To solve this, put both the ADD_PROJECTILE and SAY functions right after the COPY function. Otherwise, using COPY twice will overwrite previous functions.

    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.

    Post edited by semiticgod on
  • argent77argent77 Member Posts: 2,733
    edited February 2017
    You shouldn't use COPY twice. The second call will simply overwrite the file from your first call because you're using the original file from your mod again. Use COPY_EXISTING instead for your second call.

    Example:
    COPY ~%MOD_FOLDER%/items/myitem.itm~ ~override~ SAY NAME1 ~blah~ COPY_EXISTING ~myitem.itm~ ~override~ // do some other stuff...

    GrammarsaladCrevsDaak
Sign In or Register to comment.