Has any source code random player spawn points,
or does anyone have a code?
thx
Has any source code random player spawn points,
or does anyone have a code?
thx
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?)
hmm i dont find it at vusion's release ..
i must look again exactly, when you mean there is in it
- - - Updated - - -
this is my Code at the moment , can you say me what i do to changeCode: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"); }
Last edited by Ronnyxx99; 12-08-14 at 03:51 PM.
It depends at which maps you want a random spawnpoint.
If you want it for every change this code
toCode:// 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; }
This'll give a player a new spawn everytime he revives.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; }
Last edited by Septus10; 12-08-14 at 05:05 PM.
if I do that so I always spawn at the bottom left of the map all the time...hmm
show me the code in the function (ServerGameLogic.cpp)
And also the code in (BasePlayerSpawnPoint.h)Code:void ServerGameLogic::GetSpawnPositionNewPlayer(const r3dPoint3D& GamePos, r3dPoint3D* pos, float* dir)
pleaseCode:void getSpawnPoint(r3dPoint3D& pos, float& dir) const
andCode: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; }
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