Separated Freezing Plasma gun from Explosive Plasma gun and added one with both

Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
GreYFoXGTi 2010-08-28 22:32:16 +02:00
parent c6803b405f
commit 8426442936
7 changed files with 88 additions and 68 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 KiB

After

Width:  |  Height:  |  Size: 272 KiB

View file

@ -57,8 +57,9 @@ enum
ENTITY_LASER_O_NORMAL,
ENTITY_LASER_O_FAST,
//DDRace - Plasma
ENTITY_PLASMA=29,
ENTITY_PLASMAE=29,
ENTITY_PLASMAF,
ENTITY_PLASMA,
//DDRace - Shotgun
ENTITY_CRAZY_SHOTGUN_U_EX=33,
ENTITY_CRAZY_SHOTGUN_R_EX,

View file

@ -12,50 +12,52 @@ const int RANGE=700;
//////////////////////////////////////////////////
// CGun
//////////////////////////////////////////////////
CGun::CGun(CGameWorld *pGameWorld, vec2 m_Pos)
CGun::CGun(CGameWorld *pGameWorld, vec2 Pos, bool Freeze, bool Explosive)
: CEntity(pGameWorld, NETOBJTYPE_LASER)
{
DELAY=Server()->TickSpeed()*0.3f;
this->m_Pos = m_Pos;
this->eval_tick=Server()->Tick();
m_Delay = Server()->TickSpeed()*0.3f;
m_Pos = Pos;
m_EvalTick = Server()->Tick();
m_Freeze = Freeze;
m_Explosive = Explosive;
GameWorld()->InsertEntity(this);
}
void CGun::fire()
void CGun::Fire()
{
CCharacter *ents[16];
int num = -1;
num = GameServer()->m_World.FindEntities(m_Pos,RANGE, (CEntity**)ents, 16, NETOBJTYPE_CHARACTER);
int id=-1;
int minlen=0;
for (int i = 0; i < num; i++)
CCharacter *Ents[16];
int Num = -1;
Num = GameServer()->m_World.FindEntities(m_Pos,RANGE, (CEntity**)Ents, 16, NETOBJTYPE_CHARACTER);
int Id=-1;
int MinLen=0;
for (int i = 0; i < Num; i++)
{
CCharacter *target = ents[i];
CCharacter *Target = Ents[i];
int res=0;
vec2 coltile;
res = GameServer()->Collision()->IntersectLine(m_Pos, target->m_Pos,0,0,false);
res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0,false);
if (!res)
{
int len=length(ents[i]->m_Pos - m_Pos);
if (minlen==0)
int Len=length(Ents[i]->m_Pos - m_Pos);
if (MinLen==0)
{
minlen=len;
id=i;
MinLen=Len;
Id=i;
}
else if(minlen>len)
else if(MinLen>Len)
{
minlen=len;
id=i;
MinLen=Len;
Id=i;
}
}
}
if (id!=-1)
if (Id!=-1)
{
CCharacter *target = ents[id];
vec2 fdir = normalize(target->m_Pos - m_Pos);
new CPlasma(&GameServer()->m_World, m_Pos,fdir);
CCharacter *Target = Ents[Id];
vec2 Fdir = normalize(Target->m_Pos - m_Pos);
new CPlasma(&GameServer()->m_World, m_Pos, Fdir, m_Freeze, m_Explosive);
}
}
@ -69,14 +71,14 @@ void CGun::Tick()
{
if (Server()->Tick()%int(Server()->TickSpeed()*0.15f)==0)
{
eval_tick=Server()->Tick();
int index = GameServer()->Collision()->IsCp(m_Pos.x,m_Pos.y);
if (index)
m_EvalTick=Server()->Tick();
int Index = GameServer()->Collision()->IsCp(m_Pos.x,m_Pos.y);
if (Index)
{
core=GameServer()->Collision()->CpSpeed(index);
m_Core=GameServer()->Collision()->CpSpeed(Index);
}
m_Pos+=core;
fire();
m_Pos+=m_Core;
Fire();
}
}
@ -91,5 +93,5 @@ void CGun::Snap(int snapping_client)
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = eval_tick;
pObj->m_StartTick = m_EvalTick;
}

View file

@ -10,15 +10,17 @@ class CCharacter;
class CGun : public CEntity
{
int eval_tick;
int m_EvalTick;
vec2 core;
vec2 m_Core;
bool m_Freeze;
bool m_Explosive;
void fire();
int DELAY;
void Fire();
int m_Delay;
public:
CGun(CGameWorld *pGameWorld, vec2 pos);
CGun(CGameWorld *pGameWorld, vec2 Pos, bool Freeze, bool Explosive);
virtual void Reset();
virtual void Tick();

View file

@ -11,31 +11,36 @@ const float ACCEL=1.1f;
//////////////////////////////////////////////////
// turret
//////////////////////////////////////////////////
CPlasma::CPlasma(CGameWorld *pGameWorld, vec2 pos,vec2 dir)
CPlasma::CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze, bool Explosive)
: CEntity(pGameWorld, NETOBJTYPE_LASER)
{
this->m_Pos = pos;
this->core = dir;
this->eval_tick=Server()->Tick();
this->lifetime=Server()->TickSpeed()*1.5;
m_Pos = Pos;
m_Core = Dir;
m_Freeze = Freeze;
m_Explosive = Explosive;
m_EvalTick = Server()->Tick();
m_LifeTime = Server()->TickSpeed() * 1.5;
GameWorld()->InsertEntity(this);
}
bool CPlasma::hit_character()
bool CPlasma::HitCharacter()
{
vec2 to2;
CCharacter *hit = GameServer()->m_World.IntersectCharacter(m_Pos, m_Pos+core, 0.0f,to2);
if(!hit)
vec2 To2;
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, m_Pos+m_Core, 0.0f,To2);
if(!Hit)
return false;
hit->Freeze(Server()->TickSpeed()*3);
if(m_Freeze)
Hit->Freeze(Server()->TickSpeed()*3);
else
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, false);
GameServer()->m_World.DestroyEntity(this);
return true;
}
void CPlasma::move()
void CPlasma::Move()
{
m_Pos += core;
core *= ACCEL;
m_Pos += m_Core;
m_Core *= ACCEL;
}
void CPlasma::Reset()
@ -45,20 +50,21 @@ void CPlasma::Reset()
void CPlasma::Tick()
{
if (lifetime==0)
if (m_LifeTime==0)
{
Reset();
return;
}
lifetime--;
move();
hit_character();
m_LifeTime--;
Move();
HitCharacter();
int res=0;
res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos+core,0, 0);
if(res)
int Res=0;
Res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos+m_Core,0, 0);
if(Res)
{
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, false);
if(m_Explosive)
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, false);
Reset();
}
@ -74,5 +80,5 @@ void CPlasma::Snap(int snapping_client)
pObj->m_Y = (int)m_Pos.y;
pObj->m_FromX = (int)m_Pos.x;
pObj->m_FromY = (int)m_Pos.y;
pObj->m_StartTick = eval_tick;
pObj->m_StartTick = m_EvalTick;
}

View file

@ -9,14 +9,15 @@ class CGun;
class CPlasma : public CEntity
{
vec2 core;
int eval_tick;
int lifetime;
bool hit_character();
void move();
vec2 m_Core;
int m_EvalTick;
int m_LifeTime;
bool m_Freeze;
bool m_Explosive;
bool HitCharacter();
void Move();
public:
CPlasma(CGameWorld *pGameWorld, vec2 pos,vec2 dir);
CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze, bool Explosive);
virtual void Reset();
virtual void Tick();
@ -24,4 +25,4 @@ public:
};
#endif
#endif

View file

@ -288,9 +288,17 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
{
new CDragger(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true);
}
else if(Index==ENTITY_PLASMAE)
{
new CGun(&GameServer()->m_World, Pos, false, true);
}
else if(Index==ENTITY_PLASMAF)
{
new CGun(&GameServer()->m_World, Pos, true, false);
}
else if(Index==ENTITY_PLASMA)
{
new CGun(&GameServer()->m_World, Pos);
new CGun(&GameServer()->m_World, Pos, true, true);
}
if(Type != -1)
{