Howdy, Stranger!

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

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Custom Tokens

wolpakwolpak Member Posts: 384
edited March 2014 in General Modding
Is there a way I can set a stat to a custom token?

I'd like for to display CharNames strength in dialog. Is that possible?

@CamDawg‌ bat signal

Post edited by wolpak on

Comments

  • IllustairIllustair Member Posts: 822
    You might want to call on some of the veteran modders/devs for this specific question like CamDawg or Cuv.

  • wolpakwolpak Member Posts: 384
    Good call. I assume it still notifies on an edit.

  • wolpakwolpak Member Posts: 384
  • wolpakwolpak Member Posts: 384
    @argent77‌

    Thanks for the help. I was just trying a basic If True() and all my problems were caused since I was setting my token as instead of STR.

    Can I just have this run all of the time with True() and it will constantly check the stat I am looking at? Basically, in my mod I have altered armor to have slashing/piercing/crushing/missile defense, but I have been having a heckuva time trying to mod the guiinv or guirec chus to display this natively. I can move stuff around, but cnnot figure out how to change the actual text displayed.

    So, I figured I'd try to add it in. Of course, it would need to be updated as it changes. I figured there were a couple ways to do this. First, run through all 100 possibilities for all 4 stats and then pop the number up there. That seems like it would be very intensive. Second, run through all the possibilities initially on game load. Then, save that number just as a global variable and compare that number to the stat I am looking at and then run the possibilities if they are different. Since this will be occurring mostly on armor changes, it shouldn't impact the game much (I assume).

    Doesn't baldur.bcs always run and thus should always update the stat in question?

    Thanks again.

  • argent77argent77 Member Posts: 2,809
    edited March 2014
    wolpak said:

    Can I just have this run all of the time with True() and it will constantly check the stat I am looking at?

    You can do that. But then you shouldn't place it into your character's script. Because each time one of your script blocks is executed, it will reset that character's current action.
    This is an example script that will check your character's strength constantly. It will update your tokens only if the strength value has been changed:
    IF
    CheckStat(Player1, 1, STR)
    OR(2)
    OnCreation() // needed to force a first-time initialization of your token
    !Global("MySTR", "GLOBAL", 1)
    THEN RESPONSE #100
    SetGlobal("MySTR", "GLOBAL", 1)
    SetTokenGlobal("MySTR", "GLOBAL", "MY_STR_TOKEN")
    Continue()
    END

    IF
    CheckStat(Player1, 2, STR)
    OR(2)
    OnCreation()
    !Global("MySTR", "GLOBAL", 2)
    THEN RESPONSE #100
    SetGlobal("MySTR", "GLOBAL", 2)
    SetTokenGlobal("MySTR", "GLOBAL", "MY_STR_TOKEN")
    Continue()
    END

    // ...and so on for the remaining strength values 3..25
    I'm not certain if global variables are updated immediately in the same script block. If the token isn't updated correctly, then you'll have to use a separate script block to set the token (as done in my previous script example).

    wolpak said:

    Doesn't baldur.bcs always run and thus should always update the stat in question?

    Not using the baldur.bcs is just a precaution. That script contains lots of script blocks already. Furthermore, megamod installations will add countless of new script blocks that have to be processed by the game, increasing the chance that your own blocks are not executed in time. If one of the mods installed a faulty script, chances are that your script blocks will never be executed at all.

  • wolpakwolpak Member Posts: 384
    Basically I am looking at 400 If Then statements if I wanted to do the 4 physical resistances. It's not hard with copying and pasting but seems ridiculously inefficient. Its ridiculous I can not just be able to print out a variable. Even so, it appears that CheckStat HAS to use an integer as it's second argument and not even a global variable that is an integer. Not sure what I was expecting with the scripting, but maybe something a little smarter than this.

    I am wondering if it would be more efficient to use the HasItemEquipped and just set the global variables there.

  • argent77argent77 Member Posts: 2,809
    You can reduce the number of script blocks if you only need to check for stat ranges via CheckStatLT() and CheckStatGT().

  • wolpakwolpak Member Posts: 384
    That would actually increase the number of scripts, but maybe then reduce the amount of computational work.

    IE: Script checks GT 50
    True, check GT 25
    and so forth until it has to get to a specific value. That would remove the need to run each other and just run down the trees. In the end, I am not sure if it is worth the effort...especially if nobody ends up playing the mod :)

  • wolpakwolpak Member Posts: 384
    After realizing none of this was going to work, I came across tokentxt.2da which, appears, to be exactly what I need. Of course, I am not sure how it works (though I am trial and erroring). Sending out another batsignal.

    @CamDawg‌

    Illustair
Sign In or Register to comment.