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