Jump to content

Appending new states


Recommended Posts


I was going through some old coding of mine (for BGT) and part of it was about editing an existing .dlg file (LOTHAN.DLG). And part of such editing was this:

APPEND ~lothan~
IF WEIGHT #-1 ~StateCheck(Myself,STATE_CHARMED)~ THEN BEGIN lothannewstate1
SAY @297
IF ~~ THEN DO ~AddexperienceParty(1500) TakePartyItem("SCRLJALA") GiveItem("LOPOTN20",LastTalkedToBy(Myself)) SetGlobal("MarekMove","GLOBAL",1) SetGlobal("LothanderMove","GLOBAL",5) EscapeAreaDestroy(90)~ UNSOLVED_JOURNAL @235 /* ~Find an antidote for poison.

Lothander has given us half of the antidote. He told us that the other half is possessed by Marek, who stays at the Blushing Mermaid.~ */ EXIT
IF WEIGHT #-1 ~!HasItem("LOPOTN20",Myself) Global("LothanderMove","GLOBAL",5)~ THEN BEGIN lothannewstate2
SAY @302
IF ~~ THEN DO ~SetGlobal("LothanderSneakAttack","GLOBAL",1) CreateItem("potn10",1,0,0) UseItem("potn10",Myself) Enemy()~ EXIT

When I checked LOTHAND-DLG inside Near Infinity, I noticed that the new states I added are at the end of the tree. But their WEIGHT is 0 and 1.


I obviously intended for the CHARMED state (State 19 in the image above) to be the first state for the .DLG to check on. In the tree, it does not look like it is so but perhaps the WEIGHT matters and State 19 and 20 (which have weight 0 and 1) are actually verified first?

If not, how do I make my added CHARMED state be the very first state being checked on?

When I export the edited .DLG file above as .D file, I get the following warning:

// WARNING: this file contains non-trivial WEIGHTs

which I assume is due to my messing with the WEIGHTs. State 0 have now in fact Weight 2 and in the D. file there is the following comment with it: 

/* Triggers after states #: 20 19 even though they appear after this state */

Thanks for your help.

Link to comment
31 minutes ago, Salk said:

the WEIGHT matters and State 19 and 20 (which have weight 0 and 1) are actually verified first?

Yes. Weight 0 is the higherst, with increasing numbers it's less weighted. i.e. 0 first, then 1, then 2 will be evaluated, regardless of the place of the dialogue state.

The states are numbered and these numbers are fix, if mods would add states at the top the numbers would need to shift and the dialogue transitions inside the game would implode. That's why the WEIGHTs are a possibility to have the engine evaluate states even if they are further down in the file, i.e. the WEIGHTs circumvent the "top to bottom" evaluation in a dlg file.

So, it all looks good in your example.

One suggestion: right now, he could be talked to while charmed several times and would each time give the group an antidote. I suggest adding another check variable to the charmed state so this doesn't happen. OK; didn't heed the EscapeArea at the end. Should be good then. Sorry for the false alarm.

Link to comment

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.

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...