Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#598489 16/01/17 04:06 AM
Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Hey guys, I've been having some crash reports from users of my mod, Epic Encounters, when characters slip and fall in combat. Recently, I also had this happen to me while playing and it put me at a loss for why it could be happening.

Essentially a character slips on ice and falls, the falling animation plays twice. The character gets up on a subsequent turn, slips again, plays the falling animation twice, and the game crashes.

Epic Encounters sends out a character event when a character is knocked down on ice, but I had a user test a version without this event and the crash still happened. Additionally, I thought it might have been related to the knockdown immunity buff, but this crash happened without the buff present. Do any of you have some insight as to why it might be crashing? Perhaps related to behavior conflicts? I'm not certain it's even related to the mod at this point...

Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
I've thought about a bit more and I remember that, FrauBlake, you mentioned that crashes could occur if an event removes the status that called it. Do you think this could still cause a crash even if the status was removed in a different function, called from the event? Would it fix the crash to impose a tiny delay from a timer?

Last edited by Ameranth; 16/01/17 09:17 AM.
Joined: Sep 2015
A
addict
Offline
addict
A
Joined: Sep 2015
It definitely causes a crash when CharacterStatusRemoved is called during an OnCharacterStatus event (if both refer to the same status of the same character). And OnCharacterStatus seems to last until all actions of this event are executed, even if they are in a different event block or executed by another character!

Code
EVENT Status
VARS
	CHARACTER:_Char
ON
	OnCharacterStatus(_Char,STUNNED)
ACTIONS
IF "!c1"
	IsEqual(_Char,__Me)
THEN
	CharacterEvent(_Char,"Remove")
ENDIF

EVENT RemoveStatus
ON
	OnCharacterEvent(__Me,"Remove")
ACTIONS
	CharacterRemoveStatus(__Me,STUNNED)

--> crash

To see the order of executed actions:

Code
EVENT Status
VARS
	CHARACTER:_Char
ON
	OnCharacterStatus(_Char,STUNNED)
ACTIONS
	IF "!c1"
		IsEqual(_Char,__Me)
	THEN
		CharacterEvent(_Char,"Remove")
		CharacterApplyStatus(_Char,CRIPPLED)
	ENDIF

EVENT RemoveStatus
ON
	OnCharacterEvent(__Me,"Remove")
ACTIONS
	CharacterSetAnimationOverride(__Me,"cower")
	CharacterApplyStatus(__Me,DRUNK)
	CharacterApplyStatus(__Me,WEAK)

--> The result for _Char is always: (stunned,) cower, drunk, weak, crippled. CharacterApplyStatus(_Char,CRIPPLED) from __Me seems to be delayed until _Char executed all actions, triggered by the character event "Remove".

A timer can prevent the game from crashing, since the status will be removed after the OnCharacterStatus event. Why this is a problem for the engine overall I don't know. I know nothing about programming.


My mods for DOS 1 EE: FasterAnimations - QuietDay - Samaritan
Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Thanks for the input, Abraxas*! I think I'll do some testing using the timer method then.

Joined: Jun 2015
F
enthusiast
Offline
enthusiast
F
Joined: Jun 2015
This is interesting.

I found out that in Osiris 'event' are queued, never immediately executed but it looks like 'events' in char (and item) scripts work differently, more like function calls. (I have a hard time to believe that they work like interrupts in computer systems.)
If it's like function calls, it could explain why a char event cannot remove the status, because it inherits it's caller's environment or is executed within it.
And the RemoveStatus() event (... or function) might destroy this environment to a point where the original handler crashes and pulls the whole engine into the abyss.

A timer *MUST* be detached because otherwise it could block the whole system. A char event handler can be directly called like a simple function.

Only speculation, as always ... ;-)


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5