mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Teleport Randomness now works
in the past if you have many tele out tiles only 1 was working Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
ac36e562a5
commit
5a6a508204
|
@ -37,6 +37,8 @@ void CCollision::Init(class CLayers *pLayers)
|
||||||
m_pSwitch = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->SwitchLayer()->m_Switch));
|
m_pSwitch = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->SwitchLayer()->m_Switch));
|
||||||
m_pDoor = new CDoorTile[m_Width*m_Height];
|
m_pDoor = new CDoorTile[m_Width*m_Height];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
m_pDoor = 0;
|
||||||
if(m_pLayers->FrontLayer())
|
if(m_pLayers->FrontLayer())
|
||||||
{
|
{
|
||||||
m_pFront = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front));
|
m_pFront = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front));
|
||||||
|
|
|
@ -994,7 +994,7 @@ void CCharacter::Tick()
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[z-1];
|
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleOuts[z-1][rand()%(((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[z-1] - 1)];
|
||||||
m_Core.m_HookPos = m_Core.m_Pos;
|
m_Core.m_HookPos = m_Core.m_Pos;
|
||||||
}
|
}
|
||||||
int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex);
|
int evilz = GameServer()->Collision()->IsEvilTeleport(MapIndex);
|
||||||
|
@ -1005,7 +1005,7 @@ void CCharacter::Tick()
|
||||||
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
||||||
m_Core.m_HookState = HOOK_RETRACTED;
|
m_Core.m_HookState = HOOK_RETRACTED;
|
||||||
GameWorld()->ReleaseHooked(GetPlayer()->GetCID());
|
GameWorld()->ReleaseHooked(GetPlayer()->GetCID());
|
||||||
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[evilz-1];
|
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleOuts[evilz-1][rand()%(((CGameControllerDDRace*)GameServer()->m_pController)->m_pNumTele[evilz-1] - 1)];
|
||||||
m_Core.m_HookPos = m_Core.m_Pos;
|
m_Core.m_HookPos = m_Core.m_Pos;
|
||||||
m_Core.m_Vel = vec2(0,0);
|
m_Core.m_Vel = vec2(0,0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
|
||||||
|
|
||||||
CGameControllerDDRace::~CGameControllerDDRace()
|
CGameControllerDDRace::~CGameControllerDDRace()
|
||||||
{
|
{
|
||||||
delete[] m_pTeleporter;
|
delete[] m_pNumTele;
|
||||||
|
delete[][] m_pTeleOuts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameControllerDDRace::Tick()
|
void CGameControllerDDRace::Tick()
|
||||||
|
@ -26,6 +27,7 @@ void CGameControllerDDRace::Tick()
|
||||||
void CGameControllerDDRace::InitTeleporter()
|
void CGameControllerDDRace::InitTeleporter()
|
||||||
{
|
{
|
||||||
int ArraySize = 0;
|
int ArraySize = 0;
|
||||||
|
m_TotalTele = 0;
|
||||||
if(GameServer()->Collision()->Layers()->TeleLayer())
|
if(GameServer()->Collision()->Layers()->TeleLayer())
|
||||||
{
|
{
|
||||||
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
||||||
|
@ -38,18 +40,40 @@ void CGameControllerDDRace::InitTeleporter()
|
||||||
|
|
||||||
if(!ArraySize)
|
if(!ArraySize)
|
||||||
{
|
{
|
||||||
m_pTeleporter = 0x0;
|
m_pNumTele = 0x0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int *Count;
|
||||||
|
m_pNumTele = new int[ArraySize];
|
||||||
|
Count = new int[ArraySize];
|
||||||
|
m_pTeleOuts = new vec2*[ArraySize];
|
||||||
|
mem_zero(m_pTeleOuts, ArraySize*sizeof(vec2));
|
||||||
|
mem_zero(m_pNumTele, ArraySize*sizeof(int));
|
||||||
|
mem_zero(Count, ArraySize*sizeof(int));
|
||||||
|
for (int i = 0; i < ArraySize; ++i)
|
||||||
|
Count[i] = m_pNumTele[i] = 0;
|
||||||
|
|
||||||
m_pTeleporter = new vec2[ArraySize];
|
// Count
|
||||||
mem_zero(m_pTeleporter, ArraySize*sizeof(vec2));
|
|
||||||
|
|
||||||
// assign the values
|
|
||||||
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
||||||
{
|
{
|
||||||
if(GameServer()->Collision()->TeleLayer()[i].m_Number > 0 && GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELEOUT)
|
if(GameServer()->Collision()->TeleLayer()[i].m_Number > 0 && GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELEOUT)
|
||||||
m_pTeleporter[GameServer()->Collision()->TeleLayer()[i].m_Number-1] = vec2(i%GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16, i/GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16);
|
{
|
||||||
|
m_pNumTele[GameServer()->Collision()->TeleLayer()[i].m_Number-1]++;
|
||||||
|
Count[GameServer()->Collision()->TeleLayer()[i].m_Number-1]++;
|
||||||
|
m_TotalTele++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < ArraySize; ++i)
|
||||||
|
{
|
||||||
|
m_pTeleOuts[i] = new vec2[m_pNumTele[i]];
|
||||||
|
mem_zero(m_pTeleOuts[i], m_pNumTele[i]*sizeof(vec2));
|
||||||
|
}
|
||||||
|
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
|
||||||
|
{
|
||||||
|
if(GameServer()->Collision()->TeleLayer()[i].m_Number > 0 && GameServer()->Collision()->TeleLayer()[i].m_Type == TILE_TELEOUT)
|
||||||
|
{
|
||||||
|
m_pTeleOuts[GameServer()->Collision()->TeleLayer()[i].m_Number-1][--Count[GameServer()->Collision()->TeleLayer()[i].m_Number-1]] = vec2(i%GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16, i/GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ public:
|
||||||
|
|
||||||
CGameTeams m_Teams;
|
CGameTeams m_Teams;
|
||||||
|
|
||||||
vec2 *m_pTeleporter;
|
int *m_pNumTele;
|
||||||
|
vec2 **m_pTeleOuts;
|
||||||
|
int m_TotalTele;
|
||||||
|
|
||||||
void InitTeleporter();
|
void InitTeleporter();
|
||||||
void InitSwitcher();
|
void InitSwitcher();
|
||||||
|
|
Loading…
Reference in a new issue