[Help] Random Player Spawn Point

Results 1 to 7 of 7
  1. #1
    Enthusiast Ronnyxx99 is offline
    MemberRank
    Jul 2014 Join Date
    GERLocation
    39Posts

    [Help] Random Player Spawn Point

    Has any source code random player spawn points,

    or does anyone have a code?

    thx


  2. #2
    Custom Title Enabled GigaToni is offline
    MemberRank
    Aug 2009 Join Date
    GER / FRLocation
    2,329Posts

    Re: [Help] Random Player Spawn Point

    I think it already is random in vusion's release.

    If not search the code for spawning a new player and copy that over to one with gameflag 1 (I think it was 1?)

  3. #3
    Enthusiast Ronnyxx99 is offline
    MemberRank
    Jul 2014 Join Date
    GERLocation
    39Posts

    Re: [Help] Random Player Spawn Point

    hmm i dont find it at vusion's release ..
    i must look again exactly, when you mean there is in it

    - - - Updated - - -

    Code:
    void ServerGameLogic::GetStartSpawnPosition(const wiCharDataFull& loadout, r3dPoint3D* pos, float* dir,DWORD peerId)
    {
        // If not assigned a map, not assigned a new map, or this is a new character
        if(loadout.GameMapId == 0 || loadout.GameMapId != ginfo_.mapId || loadout.Alive == 3)
        {
            GetSpawnPositionNewPlayer(loadout.GamePos, pos, dir);
            pos->x += u_GetRandom(10, 120);
            pos->z += u_GetRandom(10, 120);
            return;
        } 
    
        // Alive and logging back in game
        /*if(loadout.GameMapId && (loadout.GameMapId == ginfo_.mapId) && loadout.Alive == 1)
        {
            *pos = loadout.GamePos;
            *dir = loadout.GameDir;
            //r3dOutToLog("alive at position %f %f %f\n", pos->x, pos->y, pos->z);
            return;
        }*/
    
        // Early Revive Spawn at location of Death
        if(loadout.GameMapId && loadout.Alive == 1 || loadout.Alive == 2)
        {
            GetSpawnPositionAfterDeath(loadout.GamePos, pos, dir);
            // move spawn pos at radius
            pos->x += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
            pos->z += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
            //r3dOutToLog("revived at position %f %f %f\n", pos->x, pos->y, pos->z);
            return;
        }
    
        r3d_assert(false && "GetStartSpawnPosition");
    }
    this is my Code at the moment , can you say me what i do to change
    Last edited by Ronnyxx99; 12-08-14 at 03:51 PM.

  4. #4
    Apprentice Septus10 is offline
    MemberRank
    Apr 2013 Join Date
    15Posts

    Re: [Help] Random Player Spawn Point

    It depends at which maps you want a random spawnpoint.

    If you want it for every change this code
    Code:
        // Early Revive Spawn at location of Death
        if(loadout.GameMapId && loadout.Alive == 1 || loadout.Alive == 2)
        {
            GetSpawnPositionAfterDeath(loadout.GamePos, pos, dir);
            // move spawn pos at radius
            pos->x += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
            pos->z += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
            //r3dOutToLog("revived at position %f %f %f\n", pos->x, pos->y, pos->z);
            return;
        }
    to
    Code:
        // Early Revive Spawn at location of Death
        if(loadout.GameMapId && loadout.Alive == 1 || loadout.Alive == 2)
        {
            GetSpawnPositionNewPlayer(loadout.GamePos, pos, dir);
            // move spawn pos at radius
            // I don't like having a random spawn pos at a certain radius as it sometimes will spawn you in the air.
            // So just comment this out
            //pos->x += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
            //pos->z += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
            //r3dOutToLog("revived at position %f %f %f\n", pos->x, pos->y, pos->z);
            return;
        }
    This'll give a player a new spawn everytime he revives.
    Last edited by Septus10; 12-08-14 at 05:05 PM.

  5. #5
    Enthusiast Ronnyxx99 is offline
    MemberRank
    Jul 2014 Join Date
    GERLocation
    39Posts

    Re: [Help] Random Player Spawn Point

    if I do that so I always spawn at the bottom left of the map all the time...hmm

  6. #6
    Apprentice Septus10 is offline
    MemberRank
    Apr 2013 Join Date
    15Posts

    Re: [Help] Random Player Spawn Point

    show me the code in the function (ServerGameLogic.cpp)
    Code:
    void ServerGameLogic::GetSpawnPositionNewPlayer(const r3dPoint3D& GamePos, r3dPoint3D* pos, float* dir)
    And also the code in (BasePlayerSpawnPoint.h)
    Code:
    void getSpawnPoint(r3dPoint3D& pos, float& dir) const
    please

  7. #7
    Enthusiast Ronnyxx99 is offline
    MemberRank
    Jul 2014 Join Date
    GERLocation
    39Posts

    Re: [Help] Random Player Spawn Point

    Code:
    void ServerGameLogic::GetSpawnPositionNewPlayer(const r3dPoint3D& GamePos, r3dPoint3D* pos, float* dir)
    {
        if(gCPMgr.numBaseControlPoints == 0)
        {
            r3dOutToLog("!!!!!!!!!!!! THERE IS NO BASE CONTROL POINTS !!!!!!!\n");
            *pos = r3dPoint3D(0, 0, 0);
            *dir = 0;
            return;
        }
    
        int idx1 = u_random(gCPMgr.numBaseControlPoints);
        r3d_assert(idx1 < gCPMgr.numBaseControlPoints);
        const BasePlayerSpawnPoint* spawn = gCPMgr.baseControlPoints[idx1];
        spawn->getSpawnPoint(*pos, *dir);
        return;
    }
    and

    Code:
    void getSpawnPoint(r3dPoint3D& pos, float& dir) const
        {
            r3d_assert(m_NumSpawnPoints > 0 && m_NumSpawnPoints <= MAX_SPAWN_POINTS);
            int i = random(m_NumSpawnPoints-1);
            r3d_assert(i>=0 && i < MAX_SPAWN_POINTS);
            pos = m_SpawnPoints[i].pos;
            dir = m_SpawnPoints[i].dir;
        }

    or is there a way to increase the spawn radius?
    Last edited by Ronnyxx99; 14-08-14 at 08:52 AM. Reason: up



Advertisement