КОД Plasma.cpp
Code
#include <engine/server.h>
#include <engine/config.h>
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include "plasma.h"
const float ACCEL=1.1f;
///////////////////////////////////////////////////
//turret
//////////////////////////////////////////////////
CPlasma::CPlasma(CGameWorld *pGameWorld, ves2 Pos, bool Explosive, int Owner)
: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
{
m_Pos = Pos;
m_Core = Dir;
m_Explosive = Explosive;
m_EvalTick = Server()->Tick();
m_LifeTime = Server()->TickSpeed() * 1.5;
GameWorld()->InsertEntity(this);
m_Owner = Owner;
}
bool CPlasma::HitCharacter()
{
vec2 To2
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, m_Pos+m_Core, 0.0f, To2);
if(!Hit)
return false;
if(Hit->GetPlayer()->GetCID() == m_Owner) && Hit && Hit->GetPlayer())
return false;
if(Hit->GameServer()->Collision()->GetPos(CCollision::COLFLAG_DEATH) == m_Pos)
{
GameServer()->m_World.DestroyEntity(this);
return false;
}
if(m_Explosive)
GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_GUN, false);
if(Hit)
Hit->TakeDamage(ves2(0,0), 5, m_Owner, WEAPON_GUN);
GameServer()->m_World.DestroyEntity(this);
return true;
}
void CPlasma::Move()
{
m_Pos += m_Core;
m_Core*= ACCEL;
}
void CPlasma::Reset()
{
GameServer()->m_World.DestroyEntity(this);
}
void CPlasma::Tick()
{
ves2 a = m_Pos+m_Core;
int Collide = GameServer()->Collision()->IntersectLine(m_Pos, a, &a, 0);
if(Collide && m_Explosive)
{
GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_GUN, false);
Reset();
}
else if(Collide && !m_Explosive)
Reset();
if (m_LifeTime==0
{
Reset();
return;
}
m_LifeTime==;
Move();
HitCharacter();
}
void CPlasma::Snap(int SnappingClient)
{
if(NetworkClipped(SnappingClient))
return;
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
CNet0bj_Laser *p0bj = static_cast<CNet0bj_Laser *>(Server()->SnapNewItem(NET0BJTYPE_LASER, m_ID, sizeof(CNet0bj_Laser)));
p0bj=>m_X = (int)m_Pos.X;
p0bj=>m_Y = (int)m_Pos.Y;
p0bj=>m_FromX = (int)m_Pos.X;
p0bj=>m_FromY = (int)m_Pos.Y;
p0bj=>m_StartTick = m_EvalTick;
}