Jump to content

reading .CRE values and inserting them into a DLG


Recommended Posts

Posted (edited)

I have a rudimentary dialogue designed to let the player change NPCs' stats. It looks something like this:

BEGIN ~D5STTTLK~

IF ~Global("d5stttlk","GLOBAL",1)~ THEN BEGIN 0 
  SAY ~Change Ability Scores?~ 
  IF ~~ THEN REPLY ~Change Strength Score~ GOTO 1
  IF ~~ THEN REPLY ~Change Dexterity Score~ GOTO 2
  IF ~~ THEN REPLY ~Change Constitution Score~ GOTO 3
  IF ~~ THEN REPLY ~Change Intelligence Score~ GOTO 4
  IF ~~ THEN REPLY ~Change Wisdom Score~ GOTO 5
  IF ~~ THEN REPLY ~Change Charisma Score~ GOTO 6
  IF ~~ THEN REPLY ~Done with ability score changes~ EXIT
END

IF ~~ THEN BEGIN 1
  SAY ~Change Strength Score~
  IF ~~ THEN REPLY ~5~ DO ~ApplySpellRES("D5ST_05",Myself)~ GOTO 0
  IF ~~ THEN REPLY ~6~ DO ~ApplySpellRES("D5ST_06",Myself)~ GOTO 0
  IF ~~ THEN REPLY ~7~ DO ~ApplySpellRES("D5ST_07",Myself)~ GOTO 0
  IF ~~ THEN REPLY ~8~ DO ~ApplySpellRES("D5ST_08",Myself)~ GOTO 0
  IF ~~ THEN REPLY ~9~ DO ~ApplySpellRES("D5ST_09",Myself)~ GOTO 0
  IF ~~ THEN REPLY ~10~ DO ~ApplySpellRES("D5ST_10",Myself)~ GOTO 0
  IF ~~ THEN REPLY ~11~ DO ~ApplySpellRES("D5ST_11",Myself)~ GOTO 0
... [etc.]

I would like to change

~Change Ability Scores?~

to

~Initial STR: __
Initial DEX: __
Initial CON: __
Initial INT: __
Initial WIS: __
Initial CHA: __
Change Ability Scores?~

Can I read those scores, maybe in the BCS script that triggers the dialogue, and insert them into the dialogue?

Edited by subtledoctor
Posted (edited)

Alternatively, you can create spells that use opcode # 326 (326) Apply Effects List to set a variable based on the stat value. Which will be applied once every 6 seconds (or more often, or less often).
And through the script, check this value and set the SetTokenGlobal action (You can use Switch().).
True, all this will need to be done for each parameter for each party member. And add variable check with OnCreation ().
Until I thought of another option.

Edited by tipun
Posted
On 10/6/2021 at 12:51 AM, subtledoctor said:
~ApplySpellRES("D5ST_05",Myself)~

You can use ChangeStat() instead, btw.

On 10/6/2021 at 12:51 AM, subtledoctor said:

Can I read those scores, maybe in the BCS script that triggers the dialogue, and insert them into the dialogue?

If it's technical feature, rather than a proper mod, then just run a cutscene script to read all the values and set tokens, yes.

Posted
6 hours ago, tipun said:

you can create spells that use opcode # 326 (326) Apply Effects List to set a variable based on the stat value. Which will be applied once every 6 seconds (or more often, or less often).

Well, it would only have to fire once, since this ability will only be used once. I could also use CheckStat() in the script that calls the dialogue...

10 hours ago, Ardanis said:

If it's technical feature, rather than a proper mod, then just run a cutscene script to read all the values and set tokens, yes.

It's player-initiated. Use an ability, conjure an invisible creature, run an override script on the creature, the script sets some variables and then initiates a dialogue on LastSummonerOf. Presumably I can CheckStat to set some more variables on LastSummonerOf in the script, then SetTokenGlobal on those variables, then initiate the dialogue and... insert the tokens into the text? I've never worked with tokens, need to learn how. But after the dialogue is done it kicks back to the script, which (after some other stuff) sets all variables to zero and kills the summon. Then another NPC can use the spell to set their own stats. Et cetera. It's an alternative to e.g. SCS' "Customize NPCs" component.

Posted
21 minutes ago, subtledoctor said:

Well, it would only have to fire once, since this ability will only be used once. I could also use CheckStat() in the script that calls the dialogue...

Sorry, I thought this would be available many times.

Posted

Stat changes aren't taken stock of during dialogue, neither from ChangeStat nor from Apply. The engine doesn't see new values.

Posted (edited)

The action is probably not in INSTANT.IDS, hence why it gets queued until after dialog mode ends.

BTW it might be possible to just use SoD's QA dialog menu (bddebug.dlg?) to change the stats... It's only triggered from PC's script, but you could have the summon AO() anyone else to start it for themselves.

Edited by Ardanis
Posted

Following up:

Do I have to check every stat individually? This is very annoying:

Spoiler


IF
	CheckStat(LastSummonerOf(Myself),3,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",3)
END
IF
	CheckStat(LastSummonerOf(Myself),4,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",4)
END
IF
	CheckStat(LastSummonerOf(Myself),5,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",5)
END
IF
	CheckStat(LastSummonerOf(Myself),6,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",6)
END
IF
	CheckStat(LastSummonerOf(Myself),7,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",7)
END
IF
	CheckStat(LastSummonerOf(Myself),8,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",8)
END
IF
	CheckStat(LastSummonerOf(Myself),9,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",9)
END
IF
	CheckStat(LastSummonerOf(Myself),10,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",10)
END
IF
	CheckStat(LastSummonerOf(Myself),11,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",11)
END
IF
	CheckStat(LastSummonerOf(Myself),12,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",12)
END
IF
	CheckStat(LastSummonerOf(Myself),13,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",13)
END
IF
	CheckStat(LastSummonerOf(Myself),14,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",14)
END
IF
	CheckStat(LastSummonerOf(Myself),15,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",15)
END
IF
	CheckStat(LastSummonerOf(Myself),16,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",16)
END
IF
	CheckStat(LastSummonerOf(Myself),17,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",17)
END
IF
	CheckStat(LastSummonerOf(Myself),18,STR)
THEN
	RESPONSE #100
	SetToken("mystrength",18)
END

IF
	Global("D5STTTLK","GLOBAL",0)
	Global("D5KITTLK","GLOBAL",1)
THEN
	RESPONSE #100
	SetGlobal("D5STTTLK","GLOBAL",1)
	SetNumTimesTalkedTo(0)
	ActionOverride(LastSummonerOf(Myself),StartDialogOverride("d5stttlk",Myself))
END

Further, is that the correct usage - SetToken in a script and then call a dialogue? In the resulting dialogue can I just insert that token like this? I haven't seen any examples of the syntax for this sort of thing.

IF ~Global("d5stttlk","GLOBAL",1)~ THEN BEGIN d5stttlk
 SAY ~ STR: mystrength
 DEX: mydexterity
 CON: myconstitution
 INT: myintelligence
 WIS: mywisdom
 CHA: mycharisma
Change Ability Scores?~

IF ~~ THEN REPLY @2052 GOTO d5stttlk_20
IF ~~ THEN REPLY @2053 GOTO d5stttlk_30
IF ~~ THEN REPLY @2054 GOTO d5stttlk_40
IF ~~ THEN REPLY @2055 GOTO d5stttlk_50
IF ~~ THEN REPLY @2056 GOTO d5stttlk_60
IF ~~ THEN REPLY @2057 GOTO d5stttlk_70
IF ~~ THEN REPLY @2080 EXIT
END

IF ~~ THEN BEGIN d5stttlk_20 
[...]

Finally, can I add 

DO ~SetToken ("mystrength",[#])~ GOTO d5stttlk

to the responses, to send the dialogue back to the main trunk, and have the token updated so that it will display the new value?

Posted
47 minutes ago, subtledoctor said:

Do I have to check every stat individually?

Well, if you set it via casting after a dialog, you don't need to check the current one at all, you just need to check a variable that the dialog sets, and make the current script to cast the then set spell.

Posted
5 minutes ago, Jarno Mikkola said:

Well, if you set it via casting after a dialog, you don't need to check the current one at all, you just need to check a variable that the dialog sets, and make the current script to cast the then set spell.

I want to

  1. Read each stat's value
  2. Display the values in a dialogue
  3. Change them if desired

When I ask "Do I have to check every stat individually?" I am asking about step 1.

Posted

And people cannot look at the characters stats in-game ? There's a stats screen for that. You really don't NEED to, you can, but that's a different thing. As changing a stat to 10 if it's already 10, is the same thing as doing nothing or submitting the creature to the spell effect anyways that does "nothing" cause it's already at ten.

Posted

Sigh. You can't go to the record screen when you're in the middle of a dialogue. I want to make something visible in a dialogue. I want to know if you can obtain the value of a creature's stats in a script without running CheckStat 138 times.

You're not being helpful. Please try to be actually helpful, or GTFO and let normal people discuss.

Posted (edited)

So, for anyone who wants to skip past Jarno's nonsense, I still can't figure out what the syntax should look like for tokens. When my .BAF file does this:

IF
	Global("D5STRSET","GLOBAL",0)
	CheckStat(LastSummonerOf(Myself),9,STR)
THEN
	RESPONSE #100
	SetToken("d5_cur_str","9")
	SetGlobal("D5STRSET","GLOBAL",1)
END

...and the following .D does this:

SAY ~Current Strength: <d5_cur_str>~

...the result for Imoen in the game is this:

Quote

Current Strength: If we can find it and return it to the playhouse, the reward offered by our Stagemistress, Raelis Shai, shall be yours. Come, then, let us search for it: Free money does not come often in the arts.

...which is the text in STRREF #9. In other words, the dialogue is turning my token into a STRREF instead of a string. How do I make it simply display the number 9? Do I have to use RESOLVE_STR_REF or something?

-----------

Also, I put 138 CheckStat checks into my .BAF file... boy was that fun. Now, when the compiled script runs, it takes a solid six seconds. I'm afraid a player will think it's broken and do something like make an area transition while the invisible creature is running the script. I ask again, is there any way to make the stat lookup more efficient?

EDIT - Continue() is your friend

-----------

Also, reading more about tokens, I see this:

Quote

If you use the action SetTokenObject("TARGET",Myself), you can then use [TARGET] as an object in subsequent blocks/scripts.

Would it make sense to use this at the top of any script run by an invisible creature - SetTokenObject("TARGET",LastSummonerOf(Myself)) - in order to simplify such scripts? Or is it basically six of one, half-dozen of the other?

Edited by subtledoctor
Posted

Another update: when I do this in the .tp2:

OUTER_SET stat_9_strref = RESOLVE_STR_REF (~9~)

...and then this in the .BAF:

IF
	Global("D5STRSET","GLOBAL",0)
	CheckStat(LastSummonerOf(Myself),9,STR)
THEN
	RESPONSE #100
	SetToken("d5_cur_str","%stat_9_strref%")
	SetGlobal("D5STRSET","GLOBAL",1)
	Continue()
END

...and this in the .D:

SAY ~Current Strength: <d5_cur_str>~

...it just shows up as blank:

Quote

Current Strength:

I'm really at a loss for how this is supposed to work.

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...