How do I make a respawn system like in Horde Rush?

I have verse code that keeps track of the storm phases by registering for an event from the storm controller. I can check which storm phase it is and then trigger a respawn at special storm phases.

There are two things I am not sure how to do:

  • How to configure the Island Settings, and
  • How to respawn either through Verse, the devices, or some combination of them.
1 Like

I believe I got it working now. I had the settings configured to work with the reboot vans initially, but then I turned off the drop reboot card option.

I had game start spawn pads that are disabled 10 seconds after a game start by hooking up their disable function with the timer completing. I had another set of 3 spawn pads for each storm phase that are initially disabled. The island setting are set to use Spawn Pads by default for spawning, so I figured in order for this to work I had to only enable the spawn pads that are associated with a specific storm phase.

I created a verse device respawn_zone_device for each storm phase that I wanted players to spawn at.

respawn_zone_device := class(creative_device):

    @editable
    StormPhase<public> : int = 0

    @editable
    RaspawnPoints<public> : []player_spawner_device = array{}

    RespawnEliminatedPlayers<public>():void=
        var PointIndex : int = 0
        for(Player : GetPlayspace().GetPlayers(), Character := Player.GetFortCharacter[]):
            if(Character.IsActive[]):
            else if(RaspawnPoint := RaspawnPoints[PointIndex]):
                RaspawnPoint.Enable()
                Player.Respawn(RaspawnPoint.GetTransform().Translation, RaspawnPoint.GetTransform().Rotation)
                RaspawnPoint.Disable()
                set PointIndex += 1

If anyone can clean up my code that would be nice. For example, I am not sure how to do a not boolean for the inner if statement, but also I have these weird if else checks in that function above.

Anyways, there is one respawn_zone_device instance per desired storm phase. Then in the other code that monitors the storm phases I put each of these devices in a map keyed on storm phase integer and valued on the respawn_zone_device object. Then if there is a respawn_zone_device for that phase I get it and call the RespawnEliminatedPlayers.

Anyways, it appears to work so far given the tests that I’ve done. But so far only tested this using a duos match. I am not sure if this works with more players yet. It looks hopeful.

1 Like

Hey there, I think this should do it :

    RespawnEliminatedPlayers<public>():void=
        var PointIndex : int = 0
        ShuffledSpawners := Shuffle(RaspawnPoints)

        for(
            Player : GetPlayspace().GetPlayers(),
            Character := Player.GetFortCharacter[],
            not Character.IsActive[],
            Spawner := ShuffledSpawners[PointIndex]
        ):
                Player.Respawn(Spawner.GetTransform().Translation + vector3{Z:=100.0}, Spawner.GetTransform().Rotation)
                set PointIndex += 1

So for the cleaning, I moved the if() statement directly into the for loop filter, which acts the exact same way, I renamed SpawnPoint to Spawner since it is what they are, I removed the Enable()/Disable() calls, because we don’t use them actually, we’re Spawning through the (Agent:agent).Respawn() method which only requires a position and a rotation. I let the typo error in RaspawnPoints because I guess you don’t want to refill the array again. If you don’t use the spawners as island start, I guess you could disable them at start.

For the bonus, I added a Shuffle() so that it doesn’t spawn players at the same spawners everytime. Also added a vector3{Z := 100.0} just in case you could have players already standing in the spawner when you call the function so that they don’t get spawned under the ground or whatever.

2 Likes

Thanks so much, this looks like it should work. I didn’t realize that you can just put a “not” keyword to perform a conditional negation. I’ll definitely keep that for late. Also putting everything in the filter of the for loop I like. Good point, it’s better named as Spawner. I didn’t even notice the typo in RaspawnPoints. I had no idea it was that easy to randomly shuffle an array like that. Appreciate the tips Fenzy. :smiley: :+1:

As for the Enable()/Disable() logic, I agree that it should not be necessary. I think I have something wrong with my setup because I noticed that players spawned at random disabled spawn pads using the (Agent:agent).Respawn() which seemed to ignore the position and rotation that I supply it. I have Spawn Limit = 1, Spawn Location = Spawn Pads, and Spawn Pad Location = Random.

1 Like

You should maybe open another issue about your respawn problem because it should respawn where you tell them to respawn, no matter the available spawners left.

Maybe you can just disable all the spawners at the start of the game and only use your custom code ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.