Title Quest: Doing Duncan a Favor -- dialog loop
Priority important Status resolved
Assigned To matthiaskrgr Keywords dialog, quest
Linked issues Watchers matthiaskrgr

Submitted on 2011-09-27 00h55 by Robr3rd, last changed by salimiles.

Author: Robr3rd Date: 2011-09-27   01h17
In the quest "Doing Duncan a Favor" you are given the choice to either kill 
Koan, or decide not to do so.

If you kill him, you get Pandora's Cube and may return to Duncan for a reward.
This works fine.

If you let him live, you may return to Duncan and (paraphrasing) he says, "Oh, 
that's a shame."
This works fine.

If, however, you tell Koan you will not kill him (so Koan gives you his 
reward), then kill Koan afterward (with the "Use Weapon" skill) you will also 
obtain Pandora's Cube. This creates an interesting scenario.

With the cube in your inventory, you talk to Duncan and the "I didn't kill him" 
conversation is triggered and the dialog screen closes. If you attempt to 
discuss it with him again (still with the Cube in your Inventory), the same 
thing happens. No matter how many times you try to talk to him, the "I didn't 
kill Koan" dialog is automatically triggered.

However, if you drop the Cube from your Inventory onto the ground some place, 
you are then able to discuss other things. One such thing is, "Here is your 
Cube" for which Duncan then rewards you as if you were giving him the Cube, yet 
after the dialog, the Cube is still lying soundly on the ground. The quest is 
completed, but the Cube is not taken (as there is nothing to take from the 

So in a nutshell the order of events is:
1.) Instigate the "Doing Duncan a Favor" quest.
2.) Say you'll take care of Koan.
3.) Go to the Forgotten Bunker in the desert where Koan resides.
4.) Tell him you will not kill him.
5.) Koan rewards you.
6.) Kill him anyway afterward (using "Use Weapon" skill).
7.) Obtain Pandora's Cube.
8.) Report back to Duncan (with the Cube in your Inventory) and witness the 
conversation loop.
9.) Drop the cube, and witness the new choices.
10.) Get rewarded. Check the ground and see the cube still there.

My suggestion: Instead of trying to write a bunch of if's/else's for "if cube, 
reward, remove cube (properly), else, blahblahblah," etc. -- Just make it so if 
you decide NOT to kill Koan, the quest is completed, and if the quest is 
completed, those lines of dialog with Duncan never get triggered.
Author: matthiaskrgr Date: 2011-09-29   18h12
Currently we check for a cookie to know if Koan is alive or not.
       if (has_cookie("koan_spared")) then 
which is the actual problem since we don't give the cookie when we "manually"
kill him.

I think the issue can be easily fixed by replacing
       if (has_cookie("koan_spared")) then 
       if (npc_dead("Koan")) then
which directly checks if Koan is alive or not.
Author: Henker Date: 2011-10-23   23h02
I think you should check both, e.g.
      if (has_cookie("koan_spared") && !npc_dead("Koan")) then

As I understand, if you only check if he is alive, the quest could be completed
immediately after obtaining the quest from Duncan - since Koan is alive before
beeing spared, too.
Author: salimiles Date: 2011-10-24   05h49
To me it looks like there are several issues;
1) Node 60 should not be tripped if you have the Cube, but have decided not to
give it to Duncan (node 68).

2) If Koan is dead (i.e. npc_dead("Koan")), Tux should tell Duncan, regardless
of Tux's possession of the Cube.

3) If Koan is dead, Tux should not have the "koan_spared" cookie. It can be
removed as part of the logic for #2. 

Also, the logic on node 60 could probably use a bit of work...
Author: matthiaskrgr Date: 2011-10-24   10h29
This bug indeed a little tricky.

My current attempt to fix this looks like

diff --git a/dialogs/Duncan.dialog b/dialogs/Duncan.dialog
index 1f5fced..5d12443 100644
--- a/dialogs/Duncan.dialog
+++ b/dialogs/Duncan.dialog
@@ -35,6 +35,7 @@ Beginning of new chat dialog for character="XXXXX"
        if (has_item_backpack("Pandora's Cube") > 0) then
+               add_cookie("has_pandoras_cube")
                if (has_cookie("koan_spared")) and
@@ -187,25 +188,27 @@ NO_TEXT
        if (has_cookie("koan_spared")) then 
                tux_says(_"I could not find him anywhere in the desert. I don't
think he is there anymore.")
                npc_says(_"I see.")
-               end_quest(_"Doing Duncan a favor", _"I lied to Duncan about not
finding Koan.")
-               end_dialog()
-       end
-       if (has_item_backpack("Pandora's Cube") > 0) then
-               show(62, 63)
+               if (has_cookie("has_pandoras_cube")) then
+                       tux_says(_"However I think I found the thing I was
supposed to get you?")
+                       show(62, 63)
+               else
+                       end_quest(_"Doing Duncan a favor", _"I lied to Duncan
about not finding Koan.")
+                       end_dialog()
+               end
-Nr=62 Text=_"Yeah. I got him. I think this is your cube."
+Nr=62 Text=_"I think this is your cube."
        npc_says(_"Yes. I appreciate your help.")
        hide(62, 63) next(69)
-Nr=63 Text=_"Yeah, I got him. Now, what is this big cube that you had me carry
all the way here?"
+Nr=63 Text=_"Now, what is this big cube that you had me carry all the way here?"
        npc_says(_"Just a memento from a friend.")
        npc_says(_"A little more than a portable end of the world, which I am
looking forward to disassembling and learning its secrets.")
diff --git a/map/events.dat b/map/events.dat
index 81546ff..90207bb 100644
--- a/map/events.dat
+++ b/map/events.dat
@@ -354,6 +354,26 @@ Silent=1
 * End of trigger *
+* New event trigger *
+Trigger entering level=0
+if (npc_dead("Koan")) then
+       add_cookie("murdered_koan")
+* End of trigger *
 ## Level  1 ##

however, it still lacks some more testing and probably a few more tweaks
Author: salimiles Date: 2011-11-01   15h13
Patch uploaded in r5101 .
Date User Action Args
2011-11-01 15:13:34salimilessetstatus: open -> resolved
messages: + msg1839
2011-10-24 10:29:04matthiaskrgrsetmessages: + msg1738
2011-10-24 05:49:57salimilessetmessages: + msg1726
2011-10-23 23:02:10Henkersetmessages: + msg1725
2011-09-29 18:12:50matthiaskrgrsetmessages: + msg1701
2011-09-29 17:48:29matthiaskrgrsetassignedto: matthiaskrgr
nosy: + matthiaskrgr
2011-09-27 01:17:34Robr3rdsetmessages: + msg1683
title: Dialog: Duncan regarding quest Doing Duncan a Favor -> Quest: Doing Duncan a Favor -- dialog loop
2011-09-27 00:55:30Robr3rdcreate