เกิดที่เดิม Cr.Wang Natthawut
เกิดที่เดิมนะvoid ServerGameLogic::GetStartSpawnPosition(const wiCharDataFull& loadout, r3dPoint3D* pos, float* dir, bool& needsSpawnProtection)
{
needsSpawnProtection = false;
// if no map assigned yet, or new map, or newly created character (alive == 3) or joining PTE map
if(loadout.GameMapId == 0 || loadout.GameMapId != ginfo_.mapId || loadout.Alive == 3
#ifdef DISABLE_GI_ACCESS_ON_PTE_MAP
|| ginfo_.channel == 6
#endif
#ifdef DISABLE_GI_ACCESS_ON_PTE_STRONGHOLD_MAP
|| (ginfo_.channel == 6 && ginfo_.mapId==GBGameInfo::MAPID_WZ_Cliffside)
#endif
#ifdef DISABLE_GI_ACCESS_FOR_CALI_SERVER
|| (gServerLogic.ginfo_.mapId==GBGameInfo::MAPID_WZ_California)
#endif
)
{
needsSpawnProtection = true;
GetSpawnPositionNewPlayer(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("new spawn at position %f %f %f\n", pos->x, pos->y, pos->z);
return;
}
//ตายเกิดบนแมพ
// alive at current map
if(loadout.GameMapId && (loadout.GameMapId == ginfo_.mapId) && loadout.Alive == 1)
{
needsSpawnProtection = true;
GetSpawnPositionAfterDeath2(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;
}
needsSpawnProtection = false;
PxRaycastHit hit;
PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK,0,0,0), PxSceneQueryFilterFlags(PxSceneQueryFilterFlag::eSTATIC|PxSceneQueryFilterFlag::eDYNAMIC));
bool hitResult = g_pPhysicsWorld->raycastSingle(PxVec3(loadout.GamePos.x, loadout.GamePos.y + 0.5f, loadout.GamePos.z), PxVec3(0, -1, 0), 500.0f, PxSceneQueryFlags(PxSceneQueryFlag::eIMPACT), hit, filter);
r3dPoint3D posForWater = loadout.GamePos;
if( hitResult )
posForWater = r3dPoint3D(hit.impact.x, hit.impact.y, hit.impact.z); // This is the ground position underwater.
float waterDepth = getWaterDepthAtPos(posForWater);
//r3dOutToLog("!!! WaterCheck Hit: %d, Depth: %.3f, Impact: %.3f, %.3f, %.3f\n", (int)hitResult, waterDepth, posForWater.x, posForWater.y, posForWater.z);
const float allowedDepth = 1.5f;
if(waterDepth > allowedDepth) // too deep, start swimming
{
*pos = r3dPoint3D(posForWater.x, posForWater.y + (waterDepth - allowedDepth), posForWater.z); // adjust to water, in case player logged out while swimming
}
else
{
*pos = AdjustPositionToFloor(loadout.GamePos); // adjust to floor, in case if player logged out while being on top of other player or anything like that
}
*dir = loadout.GameDir;
//r3dOutToLog("alive at position %.3f %.3f %.3f\n", pos->x, pos->y, pos->z);
return;
}
// revived (alive == 2) - spawn to closest spawn point
if(loadout.GameMapId && (loadout.Alive == 1)
{
needsSpawnProtection = true;
GetSpawnPositionAfterDeath2(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;
}
r3dOutToLog("%d %d %d\n", loadout.GameMapId, loadout.Alive, ginfo_.mapId);
r3d_assert(false && "GetStartSpawnPosition");
}
หน้า:
[1]