Fixed NoWall Draggers

Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
GreYFoXGTi 2010-08-21 19:32:42 +02:00
parent 19e379afdf
commit 3580547297
4 changed files with 43 additions and 15 deletions

View file

@ -293,6 +293,32 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2
return 0;
}
int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 Pos = mix(Pos0, Pos1, a);
if(IsNoLaser(round(Pos.x), round(Pos.y)))
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return GetCollisionAt(Pos.x, Pos.y);
}
Last = Pos;
}
if(pOutCollision)
*pOutCollision = Pos1;
if(pOutBeforeCollision)
*pOutBeforeCollision = Pos1;
return 0;
}
int CCollision::IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
float d = distance(Pos0, Pos1);

View file

@ -3,15 +3,15 @@
#include <engine/server.h>
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include "drager.h"
#include "dragger.h"
//////////////////////////////////////////////////
// CDrager
// CDragger
//////////////////////////////////////////////////
const int LENGTH=700;
CDrager::CDrager(CGameWorld *pGameWorld, vec2 pos, float strength, bool nw)
CDragger::CDragger(CGameWorld *pGameWorld, vec2 pos, float strength, bool nw)
: CEntity(pGameWorld, NETOBJTYPE_LASER)
{
this->m_Pos = pos;
@ -21,7 +21,7 @@ CDrager::CDrager(CGameWorld *pGameWorld, vec2 pos, float strength, bool nw)
GameWorld()->InsertEntity(this);
}
void CDrager::move()
void CDragger::move()
{
if (target)
return;
@ -35,6 +35,8 @@ void CDrager::move()
target = ents[i];
int res=0;
if (!nw)
res = GameServer()->Collision()->IntersectNoLaserNW(m_Pos, target->m_Pos, 0, 0);
else
res = GameServer()->Collision()->IntersectNoLaser(m_Pos, target->m_Pos, 0, 0);
if (res==0)
@ -57,7 +59,7 @@ void CDrager::move()
}
}
void CDrager::drag()
void CDragger::drag()
{
if (target)
{
@ -78,12 +80,12 @@ void CDrager::drag()
}
}
void CDrager::Reset()
void CDragger::Reset()
{
GameServer()->m_World.DestroyEntity(this);
}
void CDrager::Tick()
void CDragger::Tick()
{
if (Server()->Tick()%int(Server()->TickSpeed()*0.15f)==0)
{
@ -102,7 +104,7 @@ void CDrager::Tick()
}
void CDrager::Snap(int snapping_client)
void CDragger::Snap(int snapping_client)
{
if (target)
{

View file

@ -1,13 +1,13 @@
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
#ifndef GAME_SERVER_ENTITY_DRAGER_H
#define GAME_SERVER_ENTITY_DRAGER_H
#ifndef GAME_SERVER_ENTITY_DRAGGER_H
#define GAME_SERVER_ENTITY_DRAGGER_H
#include <game/server/entity.h>
class CCharacter;
class CDrager : public CEntity
class CDragger : public CEntity
{
vec2 core;
float strength;
@ -19,7 +19,7 @@ class CDrager : public CEntity
public:
CDrager(CGameWorld *pGameWorld, vec2 pos, float strength, bool nw=false);
CDragger(CGameWorld *pGameWorld, vec2 pos, float strength, bool nw=false);
virtual void Reset();
virtual void Tick();

View file

@ -9,7 +9,7 @@
#include "gamecontext.h"
#include "entities/light.h"
#include "entities/drager.h"
#include "entities/dragger.h"
#include "entities/gun.h"
#include "entities/projectile.h"
#include "entities/plasma.h"
@ -293,11 +293,11 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
}
else if(Index>=ENTITY_DRAGGER_WEAK && Index <=ENTITY_DRAGGER_STRONG)
{
new CDrager(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1);
new CDragger(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1);
}
else if(Index>=ENTITY_DRAGGER_WEAK_NW && Index <=ENTITY_DRAGGER_STRONG_NW)
{
new CDrager(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true);
new CDragger(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true);
}
else if(Index==ENTITY_PLASMA)
{