Jump to content


Photo

[solved] Coding Looped Dialogue: transactions do not get performed


14 replies to this topic

#1 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 08 May 2017 - 01:10 AM

I have a dialogue like this:
 

IF ~~ THEN BEGIN giveitems
SAY ~So, what can you give me?~
+ ~PartyHasItem("xxxitem1") Global("Locals1","LOCALS",0)~ + ~Here is item 1.~ DO ~SetGlobal("Locals1","LOCALS",1) TakePartyItemAll("xxxitem1") IncrementGlobal("Itemcounter","GLOBAL",1) DestroyItem("xxxitem1") AddexperienceParty(50)~ + intermediate
+ ~PartyHasItem("xxxitem2") Global("Locals2","LOCALS",0)~ + ~Here is item 2.~ DO ~SetGlobal("Locals2","LOCALS",1) TakePartyItemAll("xxxitem2") IncrementGlobal("Itemcounter","GLOBAL",1) DestroyItem("xxxitem2") AddexperienceParty(50)~ + intermediate
+ ~PartyHasItem("xxxitem3") Global("Locals3","LOCALS",0)~ + ~Here is item 3.~ DO ~SetGlobal("Locals3","LOCALS",1) TakePartyItemAll("xxxitem3") IncrementGlobal("Itemcounter","GLOBAL",1) DestroyItem("xxxitem3") AddexperienceParty(50)~ + intermediate
+ ~PartyHasItem("xxxitem4") Global("Locals4","LOCALS",0)~ + ~Here is item 4.~ DO ~SetGlobal("Locals4","LOCALS",1) TakePartyItemAll("xxxitem4") IncrementGlobal("Itemcounter","GLOBAL",1) DestroyItem("xxxitem4") AddexperienceParty(50)~ + intermediate
++ ~That's all I have.~ EXIT
END

IF ~~ THEN intermediate
SAY ~Aha. I see.~
IF ~~ THEN + giveitems
END

 
 
For the classic BGII engine (BGT game), the actions do not get performed - at all. Neither gets the local variables set so the reply options diminish after choosing them while looping through the dialogue, nor are the items taken.
Before I start narrowing this down to certain transaction etc.pp - Does anyone have experience with this? I know it takes 2-3 lines until the engine manages to set variables in a dialogue, but why isn't any of the transactions working in this case?


Edited by jastey, 15 May 2017 - 07:44 AM.


#2 Roxanne

Roxanne
  • Modders
  • 1333 posts
  • Gender:Not Telling

Posted 08 May 2017 - 01:49 AM

Have you tested the whole thing without a subsequent transition to (+intermediate)? The mix of actions you have in the DO may only work at the dialogue end due to the timings. 

(In EE you could trigger a script to do the actions with  a single global/local, but in classic game such a script would only fire after you completed the dialogue.)

 

Does anyone have experience with this?

My experience is that dialogues like this create endless loops - yours has the emergency exit, so at least you can always use that.


Edited by Roxanne, 08 May 2017 - 01:54 AM.

The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#3 Avenger

Avenger
  • Modders
  • 3681 posts
  • Gender:Male
  • Location:Hungary

Posted 08 May 2017 - 06:34 AM

As far as i know. Blocking actions are not executed until you exit the dialog (or switch dialog owner?), and non-blocking actions are executed one response later than they were written.

In the EE, you can flag a block of actions as 'execute immediate'. 



#4 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 08 May 2017 - 10:09 AM

Avenger: how do I know what a blocking action is?

 

Problem with the above structure was that not even the local variables were set during dialogue.



#5 argent77

argent77
  • Modders
  • 647 posts
  • Gender:Male

Posted 08 May 2017 - 10:31 AM

Script actions listed in INSTANT.IDS should be executed directly within dialog states.



#6 Roxanne

Roxanne
  • Modders
  • 1333 posts
  • Gender:Not Telling

Posted 08 May 2017 - 10:50 AM

Another question - who is the *owner* of those LOCALS you set?


The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#7 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 08 May 2017 - 10:50 AM

argent77: Thank you for the link. All actions from above are listed there. :-(

 

Roxanne: The dialogue is all about handing over a lot of collected items one after the other. I wouldn't know how to do it without a looping dialogue (it loops on purpose).



#8 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 08 May 2017 - 10:51 AM

Roxanne: The whole dialogue is for one NPC only, so she is the owner.

If I put the above actions into her script triggered by the local variables, they are executed after the dialogue (in vanilla BG1+TotSC For the BGII engine, I am not that far into testing yet.)

 

EDIT. That was the funny part: in vanilla BG1:TotSC, (at least) the locals get set and the reply options vanish during the dialogue. In BGII, this didn't work.


Edited by jastey, 08 May 2017 - 10:53 AM.


#9 Roxanne

Roxanne
  • Modders
  • 1333 posts
  • Gender:Not Telling

Posted 08 May 2017 - 11:09 AM

The whole dialogue is for one NPC only, so she is the owner.

I was just asking because it might have been a summoned or re-appearing creatures . so Locals would not be stored...

 

Maybe for your purpose you should consider to do it like it is done for Cespenar (Botsmith.dlg) or what-is-his-name-in-the-docks-smith instead of the loop?

 

PS - I remember a number of discussions on the Instant.ids and how it actually works in dialogues, i.e there is a discrepancy between specification and what we observe in the game - especially like in the case here where 4 of those actions are supposed to be *instant* at the same time (like I said earlier, those actions take different durations, e.g. the take all party items from all the NPCs inventories...). I have seen some single instant actions work but more often I have seen situations like the problem presented here. I have learned to avoid them.


Edited by Roxanne, 08 May 2017 - 11:16 AM.

The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#10 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 08 May 2017 - 11:09 PM

I can specify the problem now.

 

For the BGII engine, if I split the "intermediate" dialogue state into two, the DestroyItem (and probably the SetGlobal, too) gets executed upon transition during the dialogue, but only for the first item / reply option I click.

 

All others are executed upon exiting the whole dialogue. This is also true for the SetGlobal() action, meaning that the reply option do not diminish while cycling teh loop.

 

Thus, the intended behavior works for the first item, after that, I can click on the remaining reply options indefinitely while I'm in the loop, and the items /variables are taken care of when I exit the dialogue.

 

(This is actually a case where the BG1 engine seems to be superior to the BGII engine. There, the SetGlobal() works during the dialogue so the reply options diminish while stating in the dialogue that the PC hands over the items. The BG1 engine then doesn't execute the DestroyItems, though.)



#11 argent77

argent77
  • Modders
  • 647 posts
  • Gender:Male

Posted 09 May 2017 - 03:43 AM

The EE engine provides additional flags for dialog transitions:
 

Bit 0: Text associated
Bit 1: Has trigger
Bit 2: Has action
Bit 3: Terminates dialogue
Bit 4: Journal entry
Bit 5: Interrupt (it's supposed to be used for interjections, but I haven't seen it used yet)
Bit 6: Add unsolved quest
Bit 7: Add journal note
Bit 8: Add solved quest
Bit 9: EE: Execute immediate (executes non-blocking script actions instantly)
Bit 10: EE: Clear actions

Bit 9 "Execute immediate" might be of interest to you. WeiDU supports setting these flags directly (by using FLAGS keyword).



#12 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 10 May 2017 - 05:25 AM

Thanks, I need to test the dialogue on BG:EE first, and all in all I'll have to think about a solution that fits for all games, I fear.



#13 Roxanne

Roxanne
  • Modders
  • 1333 posts
  • Gender:Not Telling

Posted 10 May 2017 - 11:54 AM

Thanks, I need to test the dialogue on BG:EE first, and all in all I'll have to think about a solution that fits for all games, I fear.

One possibility may be to start cutscene mode and a cutscene with your DO. In that cutscene you execute the actions and set the globals (maybe add some effect to illustrate how the taken items are destroyed or used, if appropriate for your scene) - then at the end of the cutscene let your NPC start dialogue again for the next round of the loop.


The Sandrah Saga

another piece of *buggy, cheesy, unbalanced junk*


#14 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 10 May 2017 - 12:22 PM

That's a good idea. Thank you!



#15 jastey

jastey
  • Gibberlings
  • 6718 posts
  • Gender:Female

Posted 15 May 2017 - 07:47 AM

Thank you again for the idea to use cutscenes after giving each of the items. This solved the problem.





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users