mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Starting to fix Doors
hitted is not a word :p forgot to change from bool to int Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
parent
545171fe91
commit
427fedb79b
|
@ -113,7 +113,7 @@ public:
|
||||||
int m_FreezeTime;
|
int m_FreezeTime;
|
||||||
int m_FreezeTick;
|
int m_FreezeTick;
|
||||||
|
|
||||||
bool m_Doored;
|
int m_Doored;
|
||||||
|
|
||||||
vec2 m_OldPos;
|
vec2 m_OldPos;
|
||||||
vec2 m_OlderPos;
|
vec2 m_OlderPos;
|
||||||
|
@ -188,7 +188,7 @@ public:
|
||||||
STOPPED_BOTTOM=4,
|
STOPPED_BOTTOM=4,
|
||||||
STOPPED_TOP=8
|
STOPPED_TOP=8
|
||||||
};
|
};
|
||||||
|
vec2 m_Intersection;
|
||||||
bool m_EyeEmote;
|
bool m_EyeEmote;
|
||||||
// info for dead reckoning
|
// info for dead reckoning
|
||||||
int m_ReckoningTick; // tick that we are performing dead reckoning From
|
int m_ReckoningTick; // tick that we are performing dead reckoning From
|
||||||
|
|
|
@ -35,17 +35,28 @@ void CDoor::Close(int Team)
|
||||||
|
|
||||||
bool CDoor::HitCharacter(int Team)
|
bool CDoor::HitCharacter(int Team)
|
||||||
{
|
{
|
||||||
vec2 At;
|
std::list < CCharacter * > HitCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 1.f, 0);
|
||||||
std::list < CCharacter * > hittedCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 1.f, At, 0);
|
if(HitCharacters.empty()) return false;
|
||||||
if(hittedCharacters.empty()) return false;
|
for(std::list < CCharacter * >::iterator i = HitCharacters.begin(); i != HitCharacters.end(); i++)
|
||||||
for(std::list < CCharacter * >::iterator i = hittedCharacters.begin(); i != hittedCharacters.end(); i++) {
|
{
|
||||||
CCharacter * Char = *i;
|
CCharacter * Char = *i;
|
||||||
if(Char->Team() == Team)
|
if(Char->Team() == Team)
|
||||||
|
{
|
||||||
|
//DoDoored(Char);
|
||||||
Char->m_Doored = true;
|
Char->m_Doored = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDoor::DoDoored(CCharacter* pChar)
|
||||||
|
{
|
||||||
|
vec2 Pos = closest_point_on_line(m_Pos,m_To,pChar->m_Intersection);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CDoor::Reset()
|
void CDoor::Reset()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CLIENTS; ++i) {
|
for (int i = 0; i < MAX_CLIENTS; ++i) {
|
||||||
|
|
|
@ -11,7 +11,22 @@ class CDoor : public CEntity
|
||||||
int m_EvalTick[MAX_CLIENTS];
|
int m_EvalTick[MAX_CLIENTS];
|
||||||
bool m_Opened[MAX_CLIENTS];
|
bool m_Opened[MAX_CLIENTS];
|
||||||
bool HitCharacter(int Team);
|
bool HitCharacter(int Team);
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
DOORED_R = 1,
|
||||||
|
DOORED_L = 2,
|
||||||
|
DOORED_T = 4,
|
||||||
|
DOORED_B = 8
|
||||||
|
};
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
DOOR_VER = 1,/*LIKE '|' */
|
||||||
|
DOOR_HOR = 2,/*LIKE '--' */
|
||||||
|
DOOR_DIAGBACK = 4,/*LIKE '\' */
|
||||||
|
DOOR_DIAGFORW = 8 /*LIKE '/' *///xD
|
||||||
|
};
|
||||||
|
bool DoDoored(CCharacter* pChar);
|
||||||
|
int m_Angle;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Open(int Tick, bool ActivatedTeam[]);
|
void Open(int Tick, bool ActivatedTeam[]);
|
||||||
|
|
|
@ -27,10 +27,9 @@ CLight::CLight(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length)
|
||||||
|
|
||||||
bool CLight::HitCharacter()
|
bool CLight::HitCharacter()
|
||||||
{
|
{
|
||||||
vec2 nothing;
|
std::list < CCharacter * > HitCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 0.0f, 0);
|
||||||
std::list < CCharacter * > hittedCharacters = GameServer()->m_World.IntersectedCharacters(m_Pos, m_To, 0.0f, nothing, 0);
|
if(HitCharacters.empty()) return false;
|
||||||
if(hittedCharacters.empty()) return false;
|
for(std::list < CCharacter * >::iterator i = HitCharacters.begin(); i != HitCharacters.end(); i++) {
|
||||||
for(std::list < CCharacter * >::iterator i = hittedCharacters.begin(); i != hittedCharacters.end(); i++) {
|
|
||||||
CCharacter * Char = *i;
|
CCharacter * Char = *i;
|
||||||
Char->Freeze(Server()->TickSpeed()*3);
|
Char->Freeze(Server()->TickSpeed()*3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ bool CPlasma::HitCharacter()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(Hit->Team() != m_ResponsibleTeam) return false;
|
if(Hit->Team() != m_ResponsibleTeam) return false;
|
||||||
if(m_Freeze == -1) //TODO: bool m_Freeze; need to fix this is unsafe
|
if(m_Freeze == -1)
|
||||||
Hit->UnFreeze();
|
Hit->UnFreeze();
|
||||||
else if (m_Freeze)
|
else if (m_Freeze)
|
||||||
Hit->Freeze(Server()->TickSpeed()*3);
|
Hit->Freeze(Server()->TickSpeed()*3);
|
||||||
|
|
|
@ -14,7 +14,7 @@ class CPlasma : public CEntity
|
||||||
int m_LifeTime;
|
int m_LifeTime;
|
||||||
|
|
||||||
int m_ResponsibleTeam;
|
int m_ResponsibleTeam;
|
||||||
bool m_Freeze;
|
int m_Freeze;
|
||||||
|
|
||||||
bool m_Explosive;
|
bool m_Explosive;
|
||||||
bool HitCharacter();
|
bool HitCharacter();
|
||||||
|
|
|
@ -224,11 +224,10 @@ CCharacter *CGameWorld::ClosestCharacter(vec2 Pos, float Radius, CEntity *pNotTh
|
||||||
return pClosest;
|
return pClosest;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis)
|
std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis)
|
||||||
{
|
{
|
||||||
std::list< CCharacter * > listOfChars;
|
std::list< CCharacter * > listOfChars;
|
||||||
// Find other players
|
// Find other players
|
||||||
float ClosestLen = distance(Pos0, Pos1) * 100.0f;
|
|
||||||
vec2 LineDir = normalize(Pos1-Pos0);
|
vec2 LineDir = normalize(Pos1-Pos0);
|
||||||
|
|
||||||
CCharacter *p = (CCharacter *)FindFirst(NETOBJTYPE_CHARACTER);
|
CCharacter *p = (CCharacter *)FindFirst(NETOBJTYPE_CHARACTER);
|
||||||
|
@ -241,15 +240,10 @@ std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2
|
||||||
float Len = distance(p->m_Pos, IntersectPos);
|
float Len = distance(p->m_Pos, IntersectPos);
|
||||||
if(Len < p->m_ProximityRadius+Radius)
|
if(Len < p->m_ProximityRadius+Radius)
|
||||||
{
|
{
|
||||||
if(Len < ClosestLen)
|
p->m_Intersection = IntersectPos;
|
||||||
{
|
listOfChars.push_back(p);
|
||||||
NewPos = IntersectPos;
|
|
||||||
ClosestLen = Len;
|
|
||||||
listOfChars.push_back(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return listOfChars;
|
return listOfChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,22 @@ public:
|
||||||
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis);
|
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, vec2 &NewPos, class CEntity *pNotThis);
|
||||||
void ReleaseHooked(int ClientId);
|
void ReleaseHooked(int ClientId);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: interserct_CCharacters
|
||||||
|
Finds all CCharacters that intersect the line.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
pos0 - Start position
|
||||||
|
pos2 - End position
|
||||||
|
radius - How for from the line the CCharacter is allowed to be.
|
||||||
|
new_pos - Intersection position
|
||||||
|
notthis - Entity to ignore intersecting with
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Returns list with all Characters on line.
|
||||||
|
*/
|
||||||
|
std::list<class CCharacter *> IntersectedCharacters(vec2 Pos0, vec2 Pos1, float Radius, class CEntity *pNotThis = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue