mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Added Deep freeze/unfreeze to switch layer so that it can be controlled with switches
fixed the freeze command Added Freeze Tile to switch layer to set freeze tile custom delay Added sv_freeze_delay to control default freeze time delay
This commit is contained in:
parent
4e36d2f069
commit
5b51295185
Binary file not shown.
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 170 KiB |
|
@ -108,6 +108,7 @@ MACRO_CONFIG_INT(SvServerTest, sv_server_test, 1, 0, 1, CFGFLAG_SERVER, "Whether
|
|||
#endif
|
||||
|
||||
MACRO_CONFIG_INT(SvCheats, sv_cheats, 0, 0, 1, CFGFLAG_SERVER, "Turns cheats on/off", 4)
|
||||
MACRO_CONFIG_INT(SvFreezeDelay, sv_freeze_delay, 3, 1, 30, CFGFLAG_SERVER, "How many seconds the players will remain frozen (applies to all except delayed freeze in switch layer & deepfreeze)", 4)
|
||||
MACRO_CONFIG_INT(ClDDRaceCheats, cl_race_cheats, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "",0)
|
||||
MACRO_CONFIG_INT(SvCheatTime, sv_cheattime, 0, 0, 1, CFGFLAG_SERVER, "Whether the time of players will be stopped on cheating or not", 4)
|
||||
MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off", 4)
|
||||
|
|
|
@ -89,7 +89,7 @@ void CCollision::Init(class CLayers *pLayers)
|
|||
Index = m_pSwitch[i].m_Type;
|
||||
if(Index <= TILE_NPH)
|
||||
{
|
||||
if(Index >= TILE_SWITCHTIMEDOPEN && Index <= TILE_SWITCHCLOSE)
|
||||
if(Index >= TILE_FREEZE && Index <= TILE_SWITCHCLOSE)
|
||||
m_pSwitch[i].m_Type = Index;
|
||||
else
|
||||
m_pSwitch[i].m_Type = 0;
|
||||
|
@ -429,7 +429,7 @@ int CCollision::IsSwitch(int Index)
|
|||
if(!m_pSwitch)
|
||||
return false;
|
||||
|
||||
if(m_pSwitch[Index].m_Type > 0 && m_pSwitch[Index].m_Number > 0)
|
||||
if(m_pSwitch[Index].m_Type > 0)
|
||||
return m_pSwitch[Index].m_Type;
|
||||
|
||||
return 0;
|
||||
|
@ -457,7 +457,7 @@ int CCollision::GetSwitchDelay(int Index)
|
|||
if(!m_pSwitch)
|
||||
return false;
|
||||
|
||||
if(m_pSwitch[Index].m_Type > 0 && m_pSwitch[Index].m_Number > 0)
|
||||
if(m_pSwitch[Index].m_Type > 0)
|
||||
return m_pSwitch[Index].m_Delay;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1101,7 +1101,7 @@ void CLayerSwitch::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
|
||||
continue;
|
||||
|
||||
if((l->m_pTiles[y*l->m_Width+x].m_Index >= (ENTITY_ARMOR_1 + ENTITY_OFFSET) && l->m_pTiles[y*l->m_Width+x].m_Index <= (ENTITY_DOOR + ENTITY_OFFSET)) || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDCLOSE)
|
||||
if((l->m_pTiles[y*l->m_Width+x].m_Index >= (ENTITY_ARMOR_1 + ENTITY_OFFSET) && l->m_pTiles[y*l->m_Width+x].m_Index <= (ENTITY_DOOR + ENTITY_OFFSET)) || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDOPEN || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_SWITCHTIMEDCLOSE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_FREEZE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DFREEZE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DUNFREEZE)
|
||||
{
|
||||
if(m_pEditor->m_SwitchNum != l->m_SwitchNumber || m_pEditor->m_SwitchDelay != l->m_SwitchDelay)
|
||||
{
|
||||
|
@ -1143,6 +1143,17 @@ void CLayerSwitch::BrushDraw(CLayer *pBrush, float wx, float wy)
|
|||
m_pSwitchTile[fy*m_Width+fx].m_Delay = 0;
|
||||
m_pTiles[fy*m_Width+fx].m_Index = 0;
|
||||
}
|
||||
|
||||
if(l->m_pTiles[y*l->m_Width+x].m_Index == TILE_FREEZE)
|
||||
{
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Number = 0;
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Flags = 0;
|
||||
}
|
||||
else if(l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DFREEZE || l->m_pTiles[y*l->m_Width+x].m_Index == TILE_DUNFREEZE)
|
||||
{
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Flags = 0;
|
||||
m_pSwitchTile[fy*m_Width+fx].m_Delay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -441,24 +441,32 @@ void CGameContext::ConTimerReStart(IConsole::IResult *pResult, void *pUserData,
|
|||
void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData, int ClientId)
|
||||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
int time=-1;
|
||||
int Seconds = -1;
|
||||
int Victim = pResult->GetVictim();
|
||||
|
||||
char buf[128];
|
||||
|
||||
if(pResult->NumArguments() >= 1)
|
||||
time = clamp(pResult->GetInteger(1), -1, 29999);
|
||||
if(pResult->NumArguments())
|
||||
Seconds = clamp(pResult->GetInteger(0), -2, 9999);
|
||||
|
||||
CCharacter* chr = pSelf->GetPlayerChar(Victim);
|
||||
if(!chr)
|
||||
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
|
||||
if(!pChr)
|
||||
return;
|
||||
|
||||
if(pSelf->m_apPlayers[Victim])
|
||||
{
|
||||
chr->Freeze(((time!=0&&time!=-1)?(pSelf->Server()->TickSpeed()*time):(-1)));
|
||||
chr->m_pPlayer->m_RconFreeze = true;
|
||||
pChr->Freeze(Seconds);
|
||||
pChr->m_pPlayer->m_RconFreeze = Seconds != -2;
|
||||
CServer* pServ = (CServer*)pSelf->Server();
|
||||
str_format(buf, sizeof(buf), "'%s' ClientId=%d has been Frozen.", pServ->ClientName(ClientId), Victim);
|
||||
if(Seconds >= 0)
|
||||
str_format(buf, sizeof(buf), "'%s' ClientId=%d has been Frozen for %d.", pServ->ClientName(ClientId), Victim, Seconds);
|
||||
else if(Seconds == -2)
|
||||
{
|
||||
pChr->m_DeepFreeze = true;
|
||||
str_format(buf, sizeof(buf), "'%s' ClientId=%d has been Deep Frozen.", pServ->ClientName(ClientId), Victim);
|
||||
}
|
||||
else
|
||||
str_format(buf, sizeof(buf), "'%s' ClientId=%d is Frozen until you unfreeze him.", pServ->ClientName(ClientId), Victim);
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", buf);
|
||||
}
|
||||
|
||||
|
@ -468,13 +476,24 @@ void CGameContext::ConUnFreeze(IConsole::IResult *pResult, void *pUserData, int
|
|||
{
|
||||
CGameContext *pSelf = (CGameContext *)pUserData;
|
||||
int Victim = pResult->GetVictim();
|
||||
|
||||
static bool Warning = false;
|
||||
char buf[128];
|
||||
CCharacter* chr = pSelf->GetPlayerChar(Victim);
|
||||
if(!chr)
|
||||
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
|
||||
if(!pChr)
|
||||
return;
|
||||
chr->m_FreezeTime=2;
|
||||
chr->m_pPlayer->m_RconFreeze = false;
|
||||
if(pChr->m_DeepFreeze && !Warning)
|
||||
{
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "warning", "This client is deeply frozen, repeat the command to defrost him.");
|
||||
Warning = true;
|
||||
return;
|
||||
}
|
||||
if(pChr->m_DeepFreeze && Warning)
|
||||
{
|
||||
pChr->m_DeepFreeze = false;
|
||||
Warning = false;
|
||||
}
|
||||
pChr->m_FreezeTime = 2;
|
||||
pChr->m_pPlayer->m_RconFreeze = false;
|
||||
CServer* pServ = (CServer*)pSelf->Server();
|
||||
str_format(buf, sizeof(buf), "'%s' ClientId=%d has been defrosted.", pServ->ClientName(ClientId), Victim);
|
||||
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", buf);
|
||||
|
|
|
@ -766,8 +766,10 @@ void CCharacter::Tick()
|
|||
m_Input.m_Hook = 0;
|
||||
|
||||
//m_Input.m_Fire = 0;
|
||||
if (m_FreezeTime == 1) {
|
||||
if (m_FreezeTime == 1)
|
||||
{
|
||||
UnFreeze();
|
||||
m_pPlayer->m_RconFreeze = false;
|
||||
}
|
||||
}
|
||||
m_Core.m_Input = m_Input;
|
||||
|
@ -1070,7 +1072,7 @@ void CCharacter::HandleTiles(int Index)
|
|||
}
|
||||
if(((m_TileIndex == TILE_FREEZE) || (m_TileFIndex == TILE_FREEZE)) && !m_Super && !m_DeepFreeze)
|
||||
{
|
||||
Freeze(Server()->TickSpeed()*3);
|
||||
Freeze();
|
||||
}
|
||||
else if(((m_TileIndex == TILE_UNFREEZE) || (m_TileFIndex == TILE_UNFREEZE)) && !m_DeepFreeze)
|
||||
{
|
||||
|
@ -1156,6 +1158,18 @@ void CCharacter::HandleTiles(int Index)
|
|||
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_EndTick[Team()] = 0;
|
||||
GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Type[Team()] = TILE_SWITCHCLOSE;
|
||||
}
|
||||
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_FREEZE && Team() != TEAM_SUPER)
|
||||
{
|
||||
Freeze(GameServer()->Collision()->GetSwitchDelay(MapIndex));
|
||||
}
|
||||
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_DFREEZE && Team() != TEAM_SUPER && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
|
||||
{
|
||||
m_DeepFreeze = true;
|
||||
}
|
||||
else if(GameServer()->Collision()->IsSwitch(MapIndex) == TILE_DUNFREEZE && Team() != TEAM_SUPER && GameServer()->Collision()->m_pSwitchers[GameServer()->Collision()->GetSwitchNumber(MapIndex)].m_Status[Team()])
|
||||
{
|
||||
m_DeepFreeze = false;
|
||||
}
|
||||
int z = GameServer()->Collision()->IsTeleport(MapIndex);
|
||||
if(z && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size())
|
||||
{
|
||||
|
@ -1317,20 +1331,20 @@ void CCharacter::TickDefered()
|
|||
}
|
||||
}
|
||||
|
||||
bool CCharacter::Freeze(int Time)
|
||||
bool CCharacter::Freeze(int Seconds)
|
||||
{
|
||||
if ((Time <= 1 || m_Super || m_FreezeTime == -1) && Time != -1)
|
||||
if ((Seconds <= 0 || m_Super || m_FreezeTime == -1 || m_FreezeTime > Seconds * Server()->TickSpeed()) && Seconds != -1)
|
||||
return false;
|
||||
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed())
|
||||
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed() || Seconds == -1)
|
||||
{
|
||||
for(int i=0;i<NUM_WEAPONS;i++)
|
||||
for(int i = 0; i < NUM_WEAPONS; i++)
|
||||
if(m_aWeapons[i].m_Got)
|
||||
{
|
||||
m_aWeapons[i].m_Ammo = 0;
|
||||
}
|
||||
m_Armor=0;
|
||||
m_FreezeTime=Time;
|
||||
m_FreezeTick=Server()->Tick();
|
||||
m_Armor = 0;
|
||||
m_FreezeTime = Seconds == -1 ? Seconds : Seconds * Server()->TickSpeed();
|
||||
m_FreezeTick = Server()->Tick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1338,28 +1352,12 @@ bool CCharacter::Freeze(int Time)
|
|||
|
||||
bool CCharacter::Freeze()
|
||||
{
|
||||
int Time = Server()->TickSpeed()*3;
|
||||
if (Time <= 1 || m_Super || m_FreezeTime == -1)
|
||||
return false;
|
||||
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed())
|
||||
{
|
||||
for(int i=0;i<NUM_WEAPONS;i++)
|
||||
if(m_aWeapons[i].m_Got)
|
||||
{
|
||||
m_aWeapons[i].m_Ammo = 0;
|
||||
}
|
||||
m_Armor=0;
|
||||
m_Ninja.m_ActivationTick = Server()->Tick();
|
||||
m_FreezeTime=Time;
|
||||
m_FreezeTick=Server()->Tick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return Freeze(g_Config.m_SvFreezeDelay);
|
||||
}
|
||||
|
||||
bool CCharacter::UnFreeze()
|
||||
{
|
||||
if (m_FreezeTime>0)
|
||||
if (m_FreezeTime > 0)
|
||||
{
|
||||
m_Armor=10;
|
||||
for(int i=0;i<NUM_WEAPONS;i++)
|
||||
|
|
|
@ -34,7 +34,7 @@ bool CLight::HitCharacter()
|
|||
for(std::list < CCharacter * >::iterator i = HitCharacters.begin(); i != HitCharacters.end(); i++) {
|
||||
CCharacter * Char = *i;
|
||||
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()]) continue;
|
||||
Char->Freeze(Server()->TickSpeed()*3);
|
||||
Char->Freeze();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ bool CPlasma::HitCharacter()
|
|||
return false;
|
||||
|
||||
if(Hit->Team() != m_ResponsibleTeam) return false;
|
||||
m_Freeze ? Hit->Freeze(Server()->TickSpeed()*3) : Hit->UnFreeze();
|
||||
m_Freeze ? Hit->Freeze() : Hit->UnFreeze();
|
||||
if(m_Explosive)
|
||||
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true, m_ResponsibleTeam, Hit->Teams()->TeamMask(m_ResponsibleTeam));
|
||||
GameServer()->m_World.DestroyEntity(this);
|
||||
|
|
|
@ -130,7 +130,7 @@ void CProjectile::Tick()
|
|||
(m_Owner != -1)? TeamMask : -1);
|
||||
}
|
||||
else if(TargetChr && m_Freeze && ((m_Layer == LAYER_SWITCH && GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[TargetChr->Team()]) || m_Layer != LAYER_SWITCH))
|
||||
TargetChr->Freeze(Server()->TickSpeed()*3);
|
||||
TargetChr->Freeze();
|
||||
if(Collide && m_Bouncing != 0)
|
||||
{
|
||||
m_StartTick = Server()->Tick();
|
||||
|
|
Loading…
Reference in a new issue