Jump to content

Counting creature deaths via scripting should not produce incorrect results


Recommended Posts

Based on the report in this thread I did a more thorough search in BGEE/SoD and found several more instances where specific death states can screw up the scripting.

[BG1] OGRES.BCS (Sarhedra's mini-quest to kill two Ogres)
Result: Sarhedra doesn't acknowledge that you defeated the ogres; quest cannot be completed (SARHED.DLG).

[BG1] GNOLLDR.BCS (Help Drizzt to defeat a couple of Gnolls)
Result: Drizzt does not respond when you try to talk to him after all gnolls have been defeated (DRIZZT.DLG).

[BG1] NEGOBLIN.BCS (Neera's personal quest)
Result: The ranger Magreb doesn't recogize that you've killed all the goblins (NEMAGREB.DLG).

[BG1] DOPALD.BCS (Help Aldeth Sashenstar to kill all doppelgangers in the Merchants' League estate)
Result: Aldeth thanks you prematurely for killing all doppelgangers (ALDETH.DLG). Other dialogs may be affected as well (e.g. Brandilar or Scar).

[SoD] BDFFDOP1.BCS (Doppelganger found in the Iron Throne Basement after helping "him" out in the castle basement)
Result: Continuously creates inventory items on the ground (lots of valuable stuff).

[SoD] BDHELP.BCS (Underground River Entrance area: Animals summoned by druids help you to attack the Crusader Encampment)
Result: An endless stream of new animals are continuously summoned if you petrify or freeze one of the animals.

Spoiler

Baldr021.thumb.jpg.7e2c549d294937de801a1aa2a6c0331a.jpg

[SoD] BDWE1STR.BCS (Wizard trying to bind Water Elementals in the Underground River area)
Result: Petrifying/freezing a water elemental summons the Nereid prematurely, and killing her, the wizard and the elementals doesn't trigger the "Completed Quest" journal entry.

In all of these cases the culprit is "StateCheck(Myself,STATE_REALLY_DEAD)" where this trigger can be true while the script keeps running, e.g. for petrified or frozen deaths. The least intrusive way to fix it is probably by adding a guard variable to ensure that the block is executed only once. There are several instances in the game where this option is already implemented.

Change this code:

IF
  StateCheck(Myself,STATE_REALLY_DEAD)
THEN
  RESPONSE #100
    IncrementGlobal("xxx","GLOBAL",1)
END

to this:

IF
  StateCheck(Myself,STATE_REALLY_DEAD)
  Global("dead","LOCALS",0)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    SetGlobal("dead","LOCALS",1)
    IncrementGlobal("xxx","GLOBAL",1)
    SetInterrupt(TRUE)
END

 

Link to comment
43 minutes ago, kjeron said:

Why not just check STATE_DEAD.  Every death type except Stoned/Frozen sets it, and those two set it once the target explodes.

Sounds even better if it catches all the remaining cases.

 

18 minutes ago, Sam. said:

I'm not in a position to check the scripts at the moment, but how about the BG1 zombie farm?  I've had the farmer not acknowledge that I had killed all the zombies, but maybe not in the EEs...

These zombies use the "Die()" trigger. This trigger is valid only for a single script round and should therefore count correctly (provided there is no way to prevent the script from running.)

Edit: Looks like I spoke too soon. Apparently they may (theoretically) count twice if they die a stoned/frozen death. But zombies are immune to cold damage and petrification, so in this case it should be fine.

Edited by argent77
Link to comment

I'd think it should check both Die() and StateCheck(Myself,STATE_DEAD) as triggers in the top block, Die() reliably cycles once unlike state checks and then there's no need for a variable.

Die() is also triggered by Imprisonment opcode #211 iirc, so can cause problems with variables set by creature deaths outside the party, being reversible and repeatable... probably irrelevant for Siege of Dragonspear unless you're a solo sorcerer with way too much xp.

Water elementals shouldn't be affected by Flesh to Stone anyway, I mean, they're water.

Link to comment
47 minutes ago, polytope said:

Water elementals shouldn't be affected by Flesh to Stone anyway, I mean, they're water.

I agree that they should be immune to petrification. It's probably a copy-paste error from the IWD Water Elementals, which aren't directly immune to petrification either. However, IWD spells contain checks for various creature types which also cover elementals. This is not the case in BG(2). I was able to petrify the water elementals with a high-level Chromatic Orb.

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.

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