Verse Library verse

07 Fragment

Hides players on spawn and triggers a visibility flicker effect whenever the character takes damage.

verse-library/triad-infiltration-making-players-invisible-in-verse/07-fragment.verse

# Full version of OnPlayerSpawned that also hooks up damage listening
    OnPlayerSpawned(SpawnedAgent : agent) : void =
        if (Character := SpawnedAgent.GetFortCharacter[]):
            # Hide the character right away
            Character.Hide()
            # Watch for damage on this character in a background task
            spawn { WatchForDamage(SpawnedAgent, Character) }

    # Runs forever for one character; restarts the flicker on each hit
    WatchForDamage(Victim : agent, Character : fort_character)<suspends> : void =
        loop:
            # DamagedEvent fires each time this character takes damage
            Character.DamagedEvent().Await()
            # Run the flicker; when it finishes the loop waits for the next hit
            DoFlicker(Victim, Character)

Comments

    Sign in to vote, comment, or suggest an edit. Sign in