Only Mostly Dead

This actually highlighted for me a different hidden bug: dying before victory.
met_his_match

S-ave and L-oad don’t revive, but unfortunately S-aving and restarting the scene will since the player actually does get the gain of health, so it may be a wise idea to add a check. If the killer dies before their target then it is too late to save them.

My reward checks (in Health.cs) have grown now to be

private void ApplyRewards(GameObject killer)
{
    // They were like that when I got here!
    if (killer == null) return; 

    // Don't reward the enemies!
    if (CompareTag("Player")) return; 

     // They went down swinging
    if (killer.GetComponent<Health>().IsDead) return;

    rewardManager.GetReward(killer);
}
1 Like

As the venerated Miracle Max once said, “Mostly dead is partly alive”.
This looks like a good fix!

1 Like

It just occurred to me I have another potential flaw hiding in there : what if the thing that died did not have my RewardManager on it?

so I added one more check to the list before calling GetReward

// Nothing in its pocketses
if (rewardManager == null) return; 
1 Like

As Abraham Lincoln said in the Gettysburg Address (Our lawyers tell me I must point out that Abraham Lincoln never said this).

If it can be null, check for nulls.
1 Like

Privacy & Terms