RestartGame() working and not working within the same function

Started by EmmaGundersen, Mon 20/01/2025 22:09:08

Previous topic - Next topic

Khris

I'm pretty sure I found a fix, but it seems the issue is a combination of a scripting and an engine issue.

The first thing I noticed is that after winning the fight, you can still hear the enemy say "ow" even though they're no longer on screen.
Next I turned on the frame counter using Debug(4, 1); and saw that the game keeps running instead of resetting. It's hanging in the sense that it doesn't react to any input, but the frame counter keeps on trucking.

So what seems to happen is:
1) you reduce the enemy's HP to 0
2) repeatedly_execute_always calls the EndCombat() function which sends the NPC to the other room
3) RestartGame() is called, queuing the loading of savegame 999
4) EndCombat ends and AGS now runs the "if (enemyHurt)" block of repeatedly_execute_always (it shouldn't, that's the script issue)
5) the character's getting hit animation plays, triggering the "ow" sound, then they're locked to the first frame of their AttackView, but since the NPC is in another room, we don't actually see the character
6) the game hangs

You can either fix this by not sending the NPC to the other room (set their .Transparency to 100 instead) or by addressing #4, i.e. turning the "if"s into "else if"s.

Still, animating / view frame locking an NPC in another room before queuing a reset a) shouldn't actually play the animation b) shouldn't move the game into a dead state. So there seems to be an engine issue here, too.

Crimson Wizard

Quote from: Khris on Wed 22/01/2025 00:03:06Still, animating / view frame locking an NPC in another room before queuing a reset a) shouldn't actually play the animation b) shouldn't move the game into a dead state. So there seems to be an engine issue here, too.

I suspect this may be similar to an issue with animating a disabled character (Character.on = 0), engine does not progress an animation so long as the character is disabled, so it will never finish (unless you enabled character again).


SMF spam blocked by CleanTalk