Fixed crash when tossing plushie while cacodemon is spawned.

This commit is contained in:
Kiri 2022-10-15 13:04:52 -07:00
parent 68f110a010
commit 1ba3f0673f

View File

@ -253,21 +253,25 @@ class KiriCacodemonPlushie : HDWeapon {
{
// Refuse to feed active monsters.
if(invoker.spawned_creature || invoker.spawned_spawnball) {
if(invoker.owner) {
invoker.owner.A_Log(
String.format(
"Cannot feed blood to %s when they're not in their plushie!",
invoker.getMonsterName()),
true);
}
return;
}
// Refuse to feed monsters that don't need any more.
if(invoker.getMonsterHealth() == invoker.getMonsterMaxHealth()) {
if(invoker.owner) {
invoker.owner.A_Log(
String.format(
"%s doesn't need any more food for now.",
invoker.getMonsterName()),
true);
}
return;
}
@ -457,10 +461,13 @@ class KiriCacodemonPlushie : HDWeapon {
if(spawned_creature) {
spawned_creature.A_SpawnItemEx("TeleFog");
spawned_creature.destroy();
if(owner) {
owner.A_Log(
String.format("%s has returned to the plushie.", getMonsterName()),
true);
}
}
// Adjust help text because the context changed. Now we can
// feed it and possibly deploy it.
@ -527,8 +534,10 @@ class KiriCacodemonPlushie : HDWeapon {
if(fainted_monster_despawn_countdown ==
KIRI_CACOPLUSHIE_FAINTED_MONSTER_COOLDOWN)
{
if(owner) {
owner.A_Log(String.format("%s has fainted!", getMonsterName()), true);
}
}
// After some number of frames, actually despawn the
// monster.
@ -549,11 +558,13 @@ class KiriCacodemonPlushie : HDWeapon {
// Shields were totally broken. Extremely low chance
// to restore shields each frame.
if(frandom(0, 100) < 0.1) {
if(owner) {
owner.A_Log(
String.format(
"%s's shields have started charging.",
getMonsterName()),
true);
}
setMonsterShield(0);
}
@ -587,11 +598,13 @@ class KiriCacodemonPlushie : HDWeapon {
// spawn.
if(invoker.getMonsterFainted())
{
if(invoker.owner) {
invoker.owner.A_Log(
String.format(
"%s has fainted and cannot manifest yet.",
invoker.getMonsterName()),
true);
}
spawn_ball.A_SpawnItemEx("TeleFog");
@ -754,9 +767,11 @@ class KiriCacodemonPlushie : HDWeapon {
} else {
// Tell the player we failed.
if(invoker.owner) {
invoker.owner.A_Log(
String.format("Failed to summon %s: Not enough room.", invoker.getMonsterName()),
true);
}
}
}