MCPcopy Create free account
hub / github.com/ddnet/ddnet / HandleNinja

Method HandleNinja

src/game/server/entities/character.cpp:284–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284void CCharacter::HandleNinja()
285{
286 if(m_Core.m_ActiveWeapon != WEAPON_NINJA)
287 return;
288
289 if((Server()->Tick() - m_Core.m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
290 {
291 // time's up, return
292 RemoveNinja();
293 return;
294 }
295
296 int NinjaTime = m_Core.m_Ninja.m_ActivationTick + (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000) - Server()->Tick();
297
298 if(NinjaTime % Server()->TickSpeed() == 0 && NinjaTime / Server()->TickSpeed() <= 5)
299 {
300 GameServer()->CreateDamageInd(m_Pos, 0, NinjaTime / Server()->TickSpeed(), TeamMask() & GameServer()->ClientsMaskExcludeClientVersionAndHigher(VERSION_DDNET_NEW_HUD));
301 }
302
303 GameServer()->m_pController->SetArmorProgress(this, NinjaTime);
304
305 // force ninja Weapon
306 SetWeapon(WEAPON_NINJA);
307
308 m_Core.m_Ninja.m_CurrentMoveTime--;
309
310 if(m_Core.m_Ninja.m_CurrentMoveTime == 0)
311 {
312 // reset velocity
313 m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * m_Core.m_Ninja.m_OldVelAmount;
314 }
315
316 if(m_Core.m_Ninja.m_CurrentMoveTime > 0)
317 {
318 // Set velocity
319 m_Core.m_Vel = m_Core.m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
320 vec2 OldPos = m_Pos;
321 vec2 GroundElasticity = vec2(
322 GetTuning(m_TuneZone)->m_GroundElasticityX,
323 GetTuning(m_TuneZone)->m_GroundElasticityY);
324
325 Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(GetProximityRadius(), GetProximityRadius()), GroundElasticity);
326
327 // reset velocity so the client doesn't predict stuff
328 ResetVelocity();
329
330 // check if we Hit anything along the way
331 {
332 CEntity *apEnts[MAX_CLIENTS];
333 float Radius = GetProximityRadius() * 2.0f;
334 int Num = GameServer()->m_World.FindEntities(OldPos, Radius, apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
335
336 // check that we're not in solo part
337 if(Teams()->m_Core.GetSolo(m_pPlayer->GetCid()))
338 return;
339
340 for(int i = 0; i < Num; ++i)
341 {

Callers

nothing calls this directly

Calls 14

distanceFunction · 0.85
TickSpeedMethod · 0.80
CreateDamageIndMethod · 0.80
MoveBoxMethod · 0.80
GetSoloMethod · 0.80
CreateSoundMethod · 0.80
ServerClass · 0.50
TickMethod · 0.45
SetArmorProgressMethod · 0.45
FindEntitiesMethod · 0.45
GetCidMethod · 0.45

Tested by

no test coverage detected