Jump to content

Brennan Risling script bug


khelban12

Recommended Posts

Posted (edited)

Greetings and congratulations to the team for the 0.8.5 release.

 

There is a bug that i see for some time now but as always i forget to report a bug until i see a release announcement :)

 

In the "Menkar Pebblecrusher" fight there is a thief NPC named Brennan Risling (sevpat05) who, if hurt sufficiently, leaves the area. So, in order for you to kill him, you have to hit him hard and kill him quickly before his script triggers.

 

sevpat05.bcs contains the following code:

IF
	HPPercentLT(Myself,50)
	Global("Hurt","LOCALS",0)
	See([PC])
THEN
	RESPONSE #100
		Wait(2)
		StartDialogueNoSet([PC])
END
sevpat05.dlg contains the following:

Trigger:
HPPercentLT(Myself,50)
Global("Hurt","LOCALS",0)
Action:
SetGlobal("Hurt","LOCALS",1)
EscapeArea()
So, if he reaches less than 50% HP, he leaves. In the original engine, this works perfectly (though it seems to me that 50% is quite large and the party should never be able to kill him before the script triggers but maybe there is a delay). In GemRB, there is a weird behavior. The script triggers perfectly if you can't kill him quickly enough but it also triggers even when he is dead.

 

1)

Steps to reproduce:

* Create a character (preferably a hard-hitting character like a fighter, paladin, archer ranger, etc)

* Escape Irenicus's Dungeon and in Waukeen's Promenade go to the upper floor of "Den of the Seven Vales" (AR0712 if you want to jump there)

* Trigger the fight

* Kill everyone else with ctrl+y and fight Brennan

 

Observed result:

Brennan dies and then his script triggers and he "escapearea"s so his loot is gone. Even killing him in one blow with the killsw01 or with ctrl+shift+y results in the script triggering.

 

Can anyone else reproduce this or is it a bug in my installation ?

 

2) If there is a bug in my installation, of course disregard my post. If not, can this be fixed ?

I found the HPPercentLT function in core/GameScript/Triggers.cpp. As always i blindly tried to find how to make it ignore dead people and found some code in another function.

 

 

diff --git a/gemrb/core/GameScript/Triggers.cpp b/gemrb/core/GameScript/Triggers.cpp
index 18345428f..5329ce4fe 100644
--- a/gemrb/core/GameScript/Triggers.cpp
+++ b/gemrb/core/GameScript/Triggers.cpp
@@ -2007,6 +2007,11 @@ int GameScript::HPPercentLT(Scriptable* Sender, Trigger* parameters)
 	if (!scr) {
 		return 0;
 	}
+	Actor *act = (Actor *) scr;
+	//don't allow dead, don't allow maze and similar effects
+	if (!act->ValidTarget(GA_NO_DEAD) || act->GetStat(IE_AVATARREMOVAL) != 0) {
+		return 0;
+	}
 	if (GetHPPercent( scr ) < parameters->int0Parameter) {
 		return 1;
 	}

 

If i modify HPPercentLT as shown above, then it works and doesn't trigger for dead Brennan but something else weird happens. If i don't kill him fast enough, then the script triggers, he says the dialog but does not escape and you continue fighting him until you kill him. So this isn't the correct solution.

 

Thank you for your time.

Edited by khelban12
Posted

You're right, either HPPercent* or See shouldn't match for dead actors. The loot dumping would happen in the next tick IIRC, so that death script is problematic. The second case looks like something managed to interrupt him, but it needs further inspection. Is that behaviour consistently reproducible?

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