Think I got this one.
The crash occurs during the HandleEventsForPlayerDeath routine at the point where it checks to see which monster performed the kill. It hits problems, however, if the monster happens to have been deleted.
Normal monsters aren't deleted - just moved to a dead monsters list. But a piece of a "
big"
monster is deleted when the monster is killed, just leaving the parent monster in the dead monster list.
So the problem comes back to Splitter.cpp, where it sets which monster killed the player. Currently, whichever monster "
piece"
stepped on the player is the killer, and this hits a problem if the piece is then removed (because the Rock Giant is killed).
So I think the fix would probably be the following in Splitter.cpp's MovePiece routine:
//Did monster step on swordsman?
if (pMonster && pMonster->IsPiece())
{
CMonsterPiece *pPiece = DYN_CAST(CMonsterPiece*, CMonster*, (CMonster*)pMonster);
pMonster = pPiece->pMonster;
}
if (wDestX == wSX && wDestY == wSY)
{
if (wDestX == this->pCurrentGame->swordsman.wX &&
wDestY == this->pCurrentGame->swordsman.wY)
CueEvents.Add(CID_MonsterKilledPlayer, pMonster);
else
CueEvents.Add(CID_NPCBeethroDied, pMonster);
}
That should redirect the killer to the main Rock Giant rather than one of the pieces. I don't *think* it matters which piece gets the kill overall, since as far as I can see, the only time it's ever checked is the routine in HandleEventsForPlayerDeath that I mentioned.
===
While I'm looking into this, Rock Giants have another little 'bug' in that if a monster piece gets the kill, the Rock Giant won't do the killing animation.
This is because the "
chomp"
animation is done by calling SwitchAnimationFrame at Beethro's location, but if a monster piece is there instead of the monster itself, it won't work. (Note: the 'main' location of a Rock Giant is its NW square, so if a Rock Giant kills you with that piece, the animation plays.) It'd probably need another check for Rock Giants in particular and a relocation of the tile location as a result.
Oh, and there seem to be a bunch of NPC Beethro oddities on death (not least when a serpent kills an NPC Beethro - *you're* the one who goes into death spasms, regardless of your player role), but I haven't fully looked into it, so I'll just mention it in passing for now in case someone else wants to check up on it.