Below is a snippet of code from a Gun Game script I’m debugging. When a player is eliminated, this method is called, and if the Eliminating character is a player, then a “PromotePlayer” method is called that gives them a new weapon.
OnPlayerEliminated(Result : elimination_result) : void=
Eliminator := Result.EliminatingCharacter
Eliminated := Result.EliminatedCharacter
if(Eliminator = Eliminated):
Print("Contgratulations, you played yourself")
else:
if (FortCharacter := Eliminator?, EliminatingAgent := FortCharacter.GetAgent[]):
Print("Promoting Player...")
PromotePlayer(EliminatingAgent)
The issue is that, with explosive weapons, a player can eliminate themselves. With this code, the player is still given a new weapon. With line 4, I’ve attempted to account for this by comparing the EliminatingCharacter to the EliminatedCharacter, and if they are the same, do not promote them to the next weapon. But this does not seem to work.
Is there an easy way to check for self-elimination in Verse?