Jump to content

Need Help With Forcefully Resetting a World For Gamemode


Recommended Posts

Alright, so I've been looking around throughout the code, but I can't find how to do it so I'll ask here about two things:

- Say I wanted to start to reset the world if everyone but one type of player (with a unique tag) was dead or no player with said tag exist or is dead, how would I go about it?

- Since this is basically a boss vs. player gamemode I want to make, I don't want anyone to just be able to select the boss from the character selection screen.  What I want to occur is that after a minute or two of the world being reset, one player is chosen to be the boss and forcefully becomes him, and not have him appear on the character select.  Is this possible and if so, how would I do it?

Thank you to anyone who can help!

Link to comment
Share on other sites

An update on what I've found out about this topic so far:

- The component shard_players seems to control the world resetting in Survival.  I've attempted to modify it like so:

local UpdatePlayerCounts = _ismastershard and function()
    _task = nil

    if _localDirty then
        _localPlayers, _localGhosts = 0, 0
        for i, v in ipairs(AllPlayers) do
            _localPlayers = _localPlayers + 1
            if v:HasTag("playerghost") or v:HasTag("redphantom") then  --Here's the edit!
                _localGhosts = _localGhosts + 1
            end
        end
        _localDirty = false
    end

    if _slaveDirty then
        _slavePlayers, _slaveGhosts = TheShard:GetSlavePlayerCounts(USERFLAGS.IS_GHOST)
        _slaveDirty = false
    end

    _numPlayers:set(_localPlayers + _slavePlayers)
    _numGhosts:set(_localGhosts + _slaveGhosts)
end or nil

 

This function seems to set everything proper, and I tried using this: TheWorld:PushEvent("ms_respawnedfromghost") when a player gets the "redphantom" tag removed.  The game's clock does start running if everyone has the tag redphantom or playerghost, alas, the clock does not stop running should the "redphantom" tag get removed.  Any ideas?  Also, sorry for the bump, but I feel there's little need to create a new topic for this question, as any future info regarding the OP may be helpful as well.

Edited by Mario384
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...