ReWorked the Freeze System

Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
GreYFoXGTi 2010-08-24 16:32:46 +02:00
parent f6f7699ef1
commit f7aa9c4c2b
2 changed files with 183 additions and 200 deletions

View file

@ -27,7 +27,7 @@ CInputCount CountInput(int Prev, int Cur)
Prev &= INPUT_STATE_MASK;
Cur &= INPUT_STATE_MASK;
int i = Prev;
while(i != Cur)
{
i = (i+1)&INPUT_STATE_MASK;
@ -80,7 +80,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_ReckoningTick = 0;
mem_zero(&m_SendCore, sizeof(m_SendCore));
mem_zero(&m_ReckoningCore, sizeof(m_ReckoningCore));
GameServer()->m_World.InsertEntity(this);
m_Alive = true;
if(m_pPlayer->m_RconFreeze) Freeze(-1);
@ -99,12 +99,12 @@ void CCharacter::SetWeapon(int W)
{
if(W == m_ActiveWeapon)
return;
m_LastWeapon = m_ActiveWeapon;
m_QueuedWeapon = -1;
m_ActiveWeapon = W;
GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SWITCH);
if(m_ActiveWeapon < 0 || m_ActiveWeapon >= NUM_WEAPONS)
m_ActiveWeapon = 0;
}
@ -123,7 +123,7 @@ void CCharacter::HandleNinja()
{
if(m_ActiveWeapon != WEAPON_NINJA)
return;
vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
@ -137,7 +137,7 @@ void CCharacter::HandleNinja()
SetWeapon(m_ActiveWeapon);
return;
}
// force ninja Weapon
SetWeapon(WEAPON_NINJA);
@ -155,7 +155,7 @@ void CCharacter::HandleNinja()
m_Core.m_Vel = m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
vec2 OldPos = m_Pos;
GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f);
// reset velocity so the client doesn't predict stuff
m_Core.m_Vel = vec2(0.f, 0.f);
@ -171,7 +171,7 @@ void CCharacter::HandleNinja()
{
if (aEnts[i] == this)
continue;
// make sure we haven't Hit this object before
bool bAlreadyHit = false;
for (int j = 0; j < m_NumObjectsHit; j++)
@ -191,11 +191,11 @@ void CCharacter::HandleNinja()
// set his velocity to fast upward (for now)
if(m_NumObjectsHit < 10)
m_apHitObjects[m_NumObjectsHit++] = aEnts[i];
aEnts[i]->TakeDamage(vec2(0, 10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA);
}
}
return;
}
@ -218,7 +218,7 @@ void CCharacter::HandleWeaponSwitch()
int WantedWeapon = m_ActiveWeapon;
if(m_QueuedWeapon != -1)
WantedWeapon = m_QueuedWeapon;
// select Weapon
int Next = CountInput(m_LatestPrevInput.m_NextWeapon, m_LatestInput.m_NextWeapon).m_Presses;
int Prev = CountInput(m_LatestPrevInput.m_PrevWeapon, m_LatestInput.m_PrevWeapon).m_Presses;
@ -250,7 +250,7 @@ void CCharacter::HandleWeaponSwitch()
// check for insane values
if(WantedWeapon >= 0 && WantedWeapon < NUM_WEAPONS && WantedWeapon != m_ActiveWeapon && m_aWeapons[WantedWeapon].m_Got)
m_QueuedWeapon = WantedWeapon;
DoWeaponSwitch();
}
@ -258,10 +258,10 @@ void CCharacter::FireWeapon()
{
if(m_ReloadTimer != 0 /*|| m_FreezeTime > 0*/)
return;
DoWeaponSwitch();
vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
bool FullAuto = false;
if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE)
FullAuto = true;
@ -271,13 +271,13 @@ void CCharacter::FireWeapon()
bool WillFire = false;
if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses)
WillFire = true;
if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo)
WillFire = true;
if(!WillFire)
return;
// check for ammo
if(!m_aWeapons[m_ActiveWeapon].m_Ammo)
{
@ -286,7 +286,7 @@ void CCharacter::FireWeapon()
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG);
return;
}
vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f;
switch(m_ActiveWeapon)
{
@ -295,18 +295,18 @@ void CCharacter::FireWeapon()
// reset objects Hit
m_NumObjectsHit = 0;
GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);
if (!g_Config.m_SvHit) break;
CCharacter *aEnts[64];
int Hits = 0;
int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)aEnts,
int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)aEnts,
64, NETOBJTYPE_CHARACTER);
for (int i = 0; i < Num; ++i)
{
CCharacter *Target = aEnts[i];
//for DDRace mod or any other mod, which needs hammer hits through the wall remove second condition
if ((Target == this) /*|| GameServer()->Collision()->IntersectLine(ProjStartPos, Target->m_Pos, NULL, NULL)*/)
continue;
@ -314,22 +314,22 @@ void CCharacter::FireWeapon()
// set his velocity to fast upward (for now)
GameServer()->CreateHammerHit(m_Pos);
aEnts[i]->TakeDamage(vec2(0.f, -1.f), g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon);
vec2 Dir;
if (length(Target->m_Pos - m_Pos) > 0.0f)
Dir = normalize(Target->m_Pos - m_Pos);
else
Dir = vec2(0.f, -1.f);
Target->m_Core.m_Vel += normalize(Dir + vec2(0.f, -1.1f)) * 10.0f * (m_HammerType + 1);
Target->UnFreeze();
Hits++;
}
// if we Hit anything, we have to wait for the reload
if(Hits)
m_ReloadTimer = Server()->TickSpeed()/3;
} break;
case WEAPON_GUN:
@ -339,26 +339,26 @@ void CCharacter::FireWeapon()
ProjStartPos,
Direction,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
0,
0,
0,
-1,
0,
0,
0,
-1,
WEAPON_GUN);
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p;
Proj->FillInfo(&p);
CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
Msg.AddInt(1);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]);
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE);
} break;
case WEAPON_SHOTGUN:
{
new CLaser(&GameServer()->m_World, m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID(), 1);
@ -367,7 +367,7 @@ void CCharacter::FireWeapon()
CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
Msg.AddInt(ShotSpread*2+1);
for(int i = -ShotSpread; i <= ShotSpread; ++i)
{
float Spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
@ -381,17 +381,17 @@ void CCharacter::FireWeapon()
vec2(cosf(a), sinf(a))*Speed,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_Shotm_GunLifetime),
1, 0, 0, -1, WEAPON_SHOTGUN);
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p;
Proj->FillInfo(&p);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]);
}
Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());
Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);*/
} break;
@ -402,44 +402,44 @@ void CCharacter::FireWeapon()
ProjStartPos,
Direction,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime),
0,
true,
0,
0,
true,
0,
SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);
// pack the Projectile and send it to the client Directly
CNetObj_Projectile p;
Proj->FillInfo(&p);
CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
Msg.AddInt(1);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]);
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE);
} break;
case WEAPON_RIFLE:
{
new CLaser(GameWorld(), m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID(), 0);
//GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
} break;
case WEAPON_NINJA:
{
// reset Hit objects
m_NumObjectsHit = 0;
m_AttackTick = Server()->Tick();
m_Ninja.m_ActivationDir = Direction;
//m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000;
m_Ninja.m_CurrentMoveTime = 10;
//GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE);
} break;
}
m_AttackTick = Server()->Tick();
/*
if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0) // -1 == unlimited
@ -453,7 +453,7 @@ void CCharacter::HandleWeapons()
{
//ninja
HandleNinja();
vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
// check reload timer
@ -495,9 +495,9 @@ void CCharacter::HandleWeapons()
bool CCharacter::GiveWeapon(int Weapon, int Ammo)
{
if(m_aWeapons[Weapon].m_Ammo < g_pData->m_Weapons.m_aId[Weapon].m_Maxammo || !m_aWeapons[Weapon].m_Got)
{
{
m_aWeapons[Weapon].m_Got = true;
m_aWeapons[Weapon].m_Ammo = min(g_pData->m_Weapons.m_aId[Weapon].m_Maxammo, Ammo);
if(!m_FreezeTime) m_aWeapons[Weapon].m_Ammo = min(g_pData->m_Weapons.m_aId[Weapon].m_Maxammo, Ammo);
return true;
}
return false;
@ -509,7 +509,7 @@ void CCharacter::GiveNinja()
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA);
m_Ninja.m_ActivationTick = Server()->Tick();
m_aWeapons[WEAPON_NINJA].m_Got = true;
m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
if (!m_FreezeTime) m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
m_LastWeapon = m_ActiveWeapon;
m_ActiveWeapon = WEAPON_NINJA;
}
@ -525,27 +525,27 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
// check for changes
if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0)
m_LastAction = Server()->Tick();
// copy new input
mem_copy(&m_Input, pNewInput, sizeof(m_Input));
m_NumInputs++;
// or are not allowed to aim in the center
if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0)
m_Input.m_TargetY = -1;
m_Input.m_TargetY = -1;
}
void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
{
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput));
if(m_NumInputs > 2 && m_pPlayer->GetTeam() != -1)
{
HandleWeaponSwitch();
FireWeapon();
}
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
}
@ -560,7 +560,7 @@ void CCharacter::Tick()
char Buf[128];
str_format(Buf, sizeof(Buf), "You were moved to %s due to team balancing", GameServer()->m_pController->GetTeamName(m_pPlayer->GetTeam()));
GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID());
m_pPlayer->m_ForceBalanced = false;
}
m_Armor=(m_FreezeTime != -1)?10-(m_FreezeTime/15):0;
@ -573,14 +573,14 @@ void CCharacter::Tick()
{
GameServer()->CreateDamageInd(m_Pos, 0, m_FreezeTime / Server()->TickSpeed());
}
(m_FreezeTime != -1)?m_FreezeTime--:0;
if(m_FreezeTime != -1)
m_FreezeTime--;
else
m_Ninja.m_ActivationTick = Server()->Tick();
m_Input.m_Direction = 0;
m_Input.m_Jump = 0;
m_Input.m_Hook = 0;
m_Ninja.m_ActivationTick = Server()->Tick();
m_aWeapons[WEAPON_NINJA].m_Got=true;
m_aWeapons[WEAPON_NINJA].m_Ammo =0;
m_ActiveWeapon=WEAPON_NINJA;
//m_Input.m_Fire = 0;
if (m_FreezeTime == 1) {
UnFreeze();
@ -588,21 +588,21 @@ void CCharacter::Tick()
}
m_Core.m_Input = m_Input;
m_Core.Tick(true);
m_DoSplash = false;
if (g_Config.m_SvEndlessDrag)
m_Core.m_HookTick = 0;
if (m_Super && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1;
m_Core.m_Jumped = 1;
if (m_Super && g_Config.m_SvEndlessSuperHook)
m_Core.m_HookTick = 0;
/*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/
//DDRace
//DDRace
char aBuftime[128];
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID());
if(Server()->Tick() - m_RefreshTime >= Server()->TickSpeed())
if(Server()->Tick() - m_RefreshTime >= Server()->TickSpeed())
{
if (m_RaceState == RACE_STARTED) {
int IntTime = (int)time;
@ -611,7 +611,7 @@ void CCharacter::Tick()
CNetMsg_Sv_RaceTime Msg;
Msg.m_Time = IntTime;
Msg.m_Check = 0;
if(m_CpActive != -1 && m_CpTick > Server()->Tick())
{
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
@ -620,11 +620,11 @@ void CCharacter::Tick()
Msg.m_Check = (int)Diff;
}
}
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
} else {
str_format(aBuftime, sizeof(aBuftime), "Current Time: %d min %d sec", IntTime/60, IntTime%60);
if(m_CpActive != -1 && m_CpTick > Server()->Tick())
{
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
@ -635,7 +635,7 @@ void CCharacter::Tick()
strcat(aBuftime, aTmp);
}
}
if( g_Config.m_SvBroadcast[0] != 0) {
char aTmp[128];
str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast);
@ -650,12 +650,12 @@ void CCharacter::Tick()
strcat(aBuftime, aTmp);
GameServer()->SendBroadcast(g_Config.m_SvBroadcast, m_pPlayer->GetCID());
}
}
m_RefreshTime = Server()->Tick();
}
int cp = GameServer()->Collision()->IsCheckpoint(MapIndex);
if(cp != -1 && m_RaceState == RACE_STARTED)
{
@ -678,7 +678,7 @@ void CCharacter::Tick()
GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf);
else
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
if(time - pData->m_BestTime < 0)
{
// new record \o/
@ -688,16 +688,16 @@ void CCharacter::Tick()
else
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
}
if(!pData->m_BestTime || time < pData->m_BestTime)
{
// update the score
pData->Set(time, m_CpCurrent);
if(str_comp_num(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
GameServer()->Score()->SaveScore(m_pPlayer->GetCID(), time, this);
}
// update server best time
if(!GameServer()->m_pController->m_CurrentRecord || time < GameServer()->m_pController->m_CurrentRecord)
{
@ -705,13 +705,13 @@ void CCharacter::Tick()
if(str_comp_num(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
GameServer()->m_pController->m_CurrentRecord = time;
}
m_RaceState = RACE_NONE;
// set player score
if(!GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime || GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime > time)
{
GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime = time;
// send it to all players
for(int i = 0; i < MAX_CLIENTS; i++)
{
@ -731,11 +731,11 @@ void CCharacter::Tick()
}
}
}
int TTime = 0-(int)time;
if(m_pPlayer->m_Score < TTime)
m_pPlayer->m_Score = TTime;
}
if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super)
{
@ -884,7 +884,7 @@ void CCharacter::Tick()
vec2 Direction;
int Force;
GameServer()->Collision()->GetSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y, &Direction, &Force);
m_Core.m_Vel += Direction*Force;
}
if(z)
@ -896,7 +896,7 @@ void CCharacter::Tick()
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[z-1];
m_Core.m_HookPos = m_Core.m_Pos;
}
// handle death-tiles
if((GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
@ -917,7 +917,7 @@ void CCharacter::Tick()
{
Die(m_pPlayer->GetCID(), WEAPON_WORLD);
}
// handle Weapons
HandleWeapons();
@ -928,36 +928,36 @@ void CCharacter::Tick()
if (!m_Doored)
{
m_OlderPos = m_OldPos;
m_OldPos = m_Core.m_Pos;
}
m_OldPos = m_Core.m_Pos;
}
m_PrevPos = m_Core.m_Pos;
return;
}
float point_distance(vec2 point, vec2 line_start, vec2 line_end)
float point_distance(vec2 point, vec2 line_start, vec2 line_end)
{
float res = -1.0f;
vec2 dir = normalize(line_end-line_start);
for(int i = 0; i < length(line_end-line_start); i++)
{
vec2 step = dir;
step.x *= i;
step.y *= i;
float dist = distance(step+line_start, point);
if(res < 0 || dist < res)
res = dist;
}
return res;
}
void CCharacter::ResetPos()
{
m_Core.m_Pos = m_OlderPos;
//core.pos-=core.vel;
m_Core.m_Vel = vec2(0,0);
if(m_Core.m_Jumped >= 2)
m_Core.m_Jumped = 1;
}
float res = -1.0f;
vec2 dir = normalize(line_end-line_start);
for(int i = 0; i < length(line_end-line_start); i++)
{
vec2 step = dir;
step.x *= i;
step.y *= i;
float dist = distance(step+line_start, point);
if(res < 0 || dist < res)
res = dist;
}
return res;
}
void CCharacter::ResetPos()
{
m_Core.m_Pos = m_OlderPos;
//core.pos-=core.vel;
m_Core.m_Vel = vec2(0,0);
if(m_Core.m_Jumped >= 2)
m_Core.m_Jumped = 1;
}
void CCharacter::TickDefered()
{
@ -969,12 +969,12 @@ void CCharacter::TickDefered()
m_ReckoningCore.Move();
m_ReckoningCore.Quantize();
}
//lastsentcore
vec2 StartPos = m_Core.m_Pos;
vec2 StartVel = m_Core.m_Vel;
bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
m_Core.Move();
if(m_Doored)
{
@ -985,7 +985,7 @@ void CCharacter::TickDefered()
m_Core.Quantize();
bool StuckAfterQuant = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
m_Pos = m_Core.m_Pos;
if(!StuckBefore && (StuckAfterMove || StuckAfterQuant))
{
// Hackish solution to get rid of strict-aliasing warning
@ -1000,7 +1000,7 @@ void CCharacter::TickDefered()
StartVelX.f = StartVel.x;
StartVelY.f = StartVel.y;
dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x",
dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x",
StuckBefore,
StuckAfterMove,
StuckAfterQuant,
@ -1012,20 +1012,20 @@ void CCharacter::TickDefered()
int Events = m_Core.m_TriggeredEvents;
int Mask = CmaskAllExceptOne(m_pPlayer->GetCID());
if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Mask);
if(Events&COREEVENT_HOOK_ATTACH_PLAYER) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, CmaskAll());
if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Mask);
if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Mask);
if(m_pPlayer->GetTeam() == -1)
{
m_Pos.x = m_Input.m_TargetX;
m_Pos.y = m_Input.m_TargetY;
}
// update the m_SendCore if needed
{
CNetObj_Character Predicted;
@ -1047,80 +1047,70 @@ void CCharacter::TickDefered()
}
bool CCharacter::Freeze(int Time)
{
{
if ((Time <= 1 || m_Super || m_FreezeTime == -1) && Time != -1)
return false;
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_aWeapons[WEAPON_NINJA].m_Got = true;
m_aWeapons[WEAPON_NINJA].m_Ammo = 0;
m_LastWeapon = m_ActiveWeapon;
m_ActiveWeapon = WEAPON_NINJA;
m_FreezeTick=Server()->Tick();
m_FreezeTime=Time;
m_FreezeTick=Server()->Tick();
return true;
}
return false;
}
bool CCharacter::Freeze()
{
}
return false;
}
bool CCharacter::Freeze()
{
int Time = Server()->TickSpeed()*3;
if (Time <= 1 || m_Super || m_FreezeTime == -1)
return false;
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_aWeapons[WEAPON_NINJA].m_Got = true;
m_aWeapons[WEAPON_NINJA].m_Ammo = 0;
m_LastWeapon = m_ActiveWeapon;
m_ActiveWeapon = WEAPON_NINJA;
m_FreezeTick=Server()->Tick();
m_FreezeTime=Time;
m_FreezeTick=Server()->Tick();
return true;
}
return false;
}
bool CCharacter::UnFreeze()
{
}
return false;
}
bool CCharacter::UnFreeze()
{
if (m_FreezeTime>0)
{
m_Armor=10;
m_FreezeTick=0;
for(int i=0;i<NUM_WEAPONS;i++)
if(m_aWeapons[i].m_Got)
{
m_aWeapons[i].m_Ammo = -1;
}
m_FreezeTime=0;
m_aWeapons[WEAPON_NINJA].m_Got = false;
m_ActiveWeapon = m_LastWeapon;
if(m_ActiveWeapon == WEAPON_NINJA)
m_ActiveWeapon = WEAPON_GUN;
SetWeapon(m_ActiveWeapon);
m_Ninja.m_ActivationDir=vec2(0,0);
m_Ninja.m_ActivationTick=0;
m_Ninja.m_CurrentMoveTime=0;
for(int i=0;i<WEAPON_NINJA;i++)
{
if (m_aWeapons[i].m_Got)
{
m_aWeapons[i].m_Ammo = -1;
}
}
return true;
return true;
}
return false;
}
void CCharacter::GiveAllWeapons()
{
for(int i=1;i<NUM_WEAPONS-1;i++)
{
m_aWeapons[i].m_Got = true;
m_aWeapons[i].m_Ammo = -1;
}
return;
}
return false;
}
void CCharacter::GiveAllWeapons()
{
for(int i=1;i<NUM_WEAPONS-1;i++)
{
m_aWeapons[i].m_Got = true;
if(!m_FreezeTime) m_aWeapons[i].m_Ammo = -1;
}
return;
}
bool CCharacter::IncreaseHealth(int Amount)
{
@ -1156,15 +1146,15 @@ void CCharacter::Die(int Killer, int Weapon)
// a nice sound
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE);
// this is for auto respawn after 3 secs
m_pPlayer->m_DieTick = Server()->Tick();
m_Alive = false;
GameServer()->m_World.RemoveEntity(this);
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID());
// we got to wait 0.5 secs before respawning
m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
}
@ -1203,7 +1193,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
m_Health--;
Dmg--;
}
if(Dmg > m_Armor)
{
Dmg -= m_Armor;
@ -1215,7 +1205,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
Dmg = 0;
}
}
m_Health -= Dmg;
}
@ -1229,9 +1219,9 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
if(m_Health <= 0)
{
Die(From, Weapon);
return false;
}
@ -1263,9 +1253,9 @@ void CCharacter::Snap(int SnappingClient)
{
if(NetworkClipped(SnappingClient))
return;
CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character)));
// write down the m_Core
if(!m_ReckoningTick || GameServer()->m_World.m_Paused)
{
@ -1279,7 +1269,7 @@ void CCharacter::Snap(int SnappingClient)
Character->m_Tick = m_ReckoningTick;
m_SendCore.Write(Character);
}
if(m_DoSplash) {
Character->m_Jumped = 3;
}
@ -1295,13 +1285,14 @@ void CCharacter::Snap(int SnappingClient)
Character->m_AmmoCount = 0;
Character->m_Health = 0;
Character->m_Armor = 0;
if (m_FreezeTime > 0)
{
Character->m_Emote = EMOTE_PAIN;
Character->m_Weapon = WEAPON_NINJA;
if (m_FreezeTime > 0 || m_FreezeTime == -1)
{
Character->m_Emote = EMOTE_PAIN;
Character->m_Weapon = WEAPON_NINJA;
Character->m_AmmoCount = 0;
}
else
else
Character->m_Weapon = m_ActiveWeapon;
Character->m_AttackTick = m_AttackTick;
@ -1312,7 +1303,7 @@ void CCharacter::Snap(int SnappingClient)
Character->m_Health = m_Health;
Character->m_Armor = m_Armor;
if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0)
Character->m_AmmoCount = m_aWeapons[m_ActiveWeapon].m_Ammo;
Character->m_AmmoCount = (!m_FreezeTime)?m_aWeapons[m_ActiveWeapon].m_Ammo:0;
}
if (Character->m_Emote == EMOTE_NORMAL)

View file

@ -79,14 +79,6 @@ void CPickup::Tick()
sound = true;
}
}
if(pChr->m_FreezeTime)
{
pChr->m_aWeapons[WEAPON_GUN].m_Ammo = 0;
pChr->m_aWeapons[WEAPON_HAMMER].m_Ammo =0;
}
pChr->m_Ninja.m_ActivationDir=vec2(0,0);
pChr->m_Ninja.m_ActivationTick=0;
pChr->m_Ninja.m_CurrentMoveTime=0;
}
if (sound)
{