ElminatedEvent() fires and completes even with IsActive[] when a player leaves the game

Summary

I had a issue and with how my brain works this seems very strange so i feel its a potential bug but if its not then please let me know so i can request an additional check.

Basically when a player leaves a game the EliminatedEvent() will fire and even if you have the IsActive check this will always pass

I spawn{} the event result and use Sleep(0.0) to ensure the check will fail.

Not Working and always passes the IsActive

OnPlayerEliminated(Result : elimination_result)<suspends>:void=
        Print("On Player Eliminated")
        if:
            Victim := Result.EliminatedCharacter
            VictimAgent := Victim.GetAgent[]
            VictimPlayer:=player[VictimAgent]
            VictimPlayer.IsActive[]
        then:
            PlayerEliminatedEvent.Signal(VictimPlayer)
            ResetPlayerZoneMap(VictimAgent)
        else:
            Print("Player is not active")

The fix to combat this is…

HandleOnPlayerEliminated(Result : elimination_result):void=
        spawn{OnPlayerEliminated(Result)}

    OnPlayerEliminated(Result : elimination_result)<suspends>:void=
        Print("On Player Eliminated")
        Sleep(0.0)
        if:
            Victim := Result.EliminatedCharacter
            VictimAgent := Victim.GetAgent[]
            VictimPlayer:=player[VictimAgent]
            VictimPlayer.IsActive[]
        then:
            PlayerEliminatedEvent.Signal(VictimPlayer)
            ResetPlayerZoneMap(VictimAgent)
        else:
            Print("Player is not active")

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

Sub to the elim event and leave a game. It counts as an elimination and will run code even if the player is leaving.

Expected Result

I would assume the IsActive would fail but also i dnt understand why when a player is leaving the game it would trigger the elim event anyways ? Isnt this why we have the PlayerRemovedEvent()

Observed Result

Could be my thinking but this is abit backwards

Platform(s)

pc

The main thing i dont understand is why the elim event would fire if a player leaves the game.

I request could be

(ElimResult : elimination_result).HasLeft<native><public>()<transacts><decides>:logic

cred to @Vidxon for ^^^

1 Like

This is correct, Player is active and working during the tick he lefts the game (so you can do stuff such as saving his data to persistable, changing states of stuff on the world and so on)

Only on the next ticks it will start failing (ex. if you sleep after player leaving before trying to change states or save persistable, will fail or even crash).

Think about it being like a “Before Player Leave” instead of “After Player Left”, just to have a little more sense on how it works…
You still has full control over the logic, by knowing it will pass the check during the tick and fail all the subsequent ones, so you can code your logic as needed for the behaviors you want.

PlayerJoinedEvent = fires after player join (ensures IsActive[­] to pass to load persistable)
PlayerLeftEvent = fires before player leave (ensures IsActive[­] to pass to save persistable)

Also keep in mind that player.IsActive[­] should not be relied upon for most logics that are not persistable related (it was not even supposed to exist at first), in the future when persistable gets support to offline players, this check will always pass…

Another thing is, don’t mix agent API with player API and fortChar API, doing a player.IsActive[] check is just for player related APIs (player ui, persistable, send to lobby). Besides player being a subclass of agent, they are not the same thing, and the IsActive check for player should not be used to “confirm” agent related API functionality (most devices and other features). The same with FortCharacter, they are all different things.
Player = the real player user definition on the ecossystem, it “exist” even when outside an island (future stuff)
Agent = the user instance inside the running island (can be players or non-player npcs/AIs too)
FortCharacter = the controller for the agent pawns on the world with its specific behaviors and logic

Thank you for the detailed response. I understand how all the diff types and subclasses ect work. The confusion I’m having is that the elim event is firing when a player is leaving the playspace. This doesn’t seem right to me at all. The player is not eliminated and is instead leaving the world.

Do you see this as being intended by design ?

I think this is expected since how eliminations are handled (even outside creative).

For example, if you are fighting with someone in Battle Royale, if the player quits his user still goes through the elimination proccess (drop items, drone abducting animation, kill feed message, granting the kill to the last player who damaged him).
IIRC the game even holds “instigator” for something like 60 or 90 seconds (ex. Player can run away from you but being killed by fall damage even with you having nothing to do with it, you still getting the kill). This in specific we can’t control in our creator islands sadly…

Also since we can control the logic to take that into count, this is not much a problem at all…
If we don’t want to consider the kill event we have ways to do it and filter on the game logic. Similarly, if was the other way around (player leaving without having kill events), we still would be able to “simulate” kill behavior if we needed through code, there is no “wrong” or “correct” behavior on this case…

So IMO it is completely normal to behave like that. Both methods would be fine to be honest (leaving without or with kill events), at the end is just a design decision of the game devs and not a rule or something that doesn’t make sense…