2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "gamecore.h"
|
2007-09-22 18:55:00 +00:00
|
|
|
|
2010-10-31 17:47:10 +00:00
|
|
|
#include <engine/shared/config.h>
|
2018-02-06 01:35:27 +00:00
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
const char *CTuningParams::ms_apNames[] =
|
2008-02-02 12:38:36 +00:00
|
|
|
{
|
2015-03-29 01:52:33 +00:00
|
|
|
#define MACRO_TUNING_PARAM(Name,ScriptName,Value,Description) #ScriptName,
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "tuning.h"
|
2008-02-02 12:38:36 +00:00
|
|
|
#undef MACRO_TUNING_PARAM
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool CTuningParams::Set(int Index, float Value)
|
2008-02-02 12:38:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Index < 0 || Index >= Num())
|
2008-02-02 12:38:36 +00:00
|
|
|
return false;
|
2010-05-29 07:25:38 +00:00
|
|
|
((CTuneParam *)this)[Index] = Value;
|
2008-02-02 12:38:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool CTuningParams::Get(int Index, float *pValue)
|
2008-02-02 12:38:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Index < 0 || Index >= Num())
|
2008-02-02 12:38:36 +00:00
|
|
|
return false;
|
2010-05-29 07:25:38 +00:00
|
|
|
*pValue = (float)((CTuneParam *)this)[Index];
|
2008-02-02 12:38:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool CTuningParams::Set(const char *pName, float Value)
|
2008-02-02 12:38:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < Num(); i++)
|
2017-03-21 10:24:44 +00:00
|
|
|
if(str_comp_nocase(pName, ms_apNames[i]) == 0)
|
2010-05-29 07:25:38 +00:00
|
|
|
return Set(i, Value);
|
2008-02-02 12:38:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool CTuningParams::Get(const char *pName, float *pValue)
|
2008-02-02 12:38:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < Num(); i++)
|
2017-03-21 10:24:44 +00:00
|
|
|
if(str_comp_nocase(pName, ms_apNames[i]) == 0)
|
2010-05-29 07:25:38 +00:00
|
|
|
return Get(i, pValue);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-02-02 12:38:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-13 06:47:51 +00:00
|
|
|
float HermiteBasis1(float v)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2011-02-13 06:47:51 +00:00
|
|
|
return 2*v*v*v - 3*v*v+1;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float VelocityRamp(float Value, float Start, float Range, float Curvature)
|
2008-03-16 22:32:17 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Value < Start)
|
|
|
|
return 1.0f;
|
|
|
|
return 1.0f/powf(Curvature, (Value-Start)/Range);
|
2008-03-16 22:32:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
void CCharacterCore::Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore *pTeams)
|
2013-07-22 15:20:34 +00:00
|
|
|
{
|
|
|
|
m_pWorld = pWorld;
|
|
|
|
m_pCollision = pCollision;
|
2013-12-12 13:35:01 +00:00
|
|
|
m_pTeleOuts = NULL;
|
2013-07-22 15:20:34 +00:00
|
|
|
|
|
|
|
m_pTeams = pTeams;
|
|
|
|
m_Id = -1;
|
2013-08-05 17:58:51 +00:00
|
|
|
m_Hook = true;
|
|
|
|
m_Collision = true;
|
2013-08-24 00:25:58 +00:00
|
|
|
m_JumpedTotal = 0;
|
|
|
|
m_Jumps = 2;
|
2013-07-22 15:20:34 +00:00
|
|
|
}
|
|
|
|
|
2017-03-21 10:24:44 +00:00
|
|
|
void CCharacterCore::Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore *pTeams, std::map<int, std::vector<vec2> > *pTeleOuts)
|
2008-03-16 22:32:17 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_pWorld = pWorld;
|
|
|
|
m_pCollision = pCollision;
|
2013-07-18 22:27:17 +00:00
|
|
|
m_pTeleOuts = pTeleOuts;
|
2011-04-09 06:41:31 +00:00
|
|
|
|
2010-08-30 12:13:43 +00:00
|
|
|
m_pTeams = pTeams;
|
2010-09-08 16:22:11 +00:00
|
|
|
m_Id = -1;
|
2013-08-05 17:58:51 +00:00
|
|
|
m_Hook = true;
|
|
|
|
m_Collision = true;
|
2013-08-24 00:25:58 +00:00
|
|
|
m_JumpedTotal = 0;
|
|
|
|
m_Jumps = 2;
|
2008-03-16 22:32:17 +00:00
|
|
|
}
|
2008-02-24 18:41:02 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CCharacterCore::Reset()
|
2008-02-24 18:41:02 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Pos = vec2(0,0);
|
|
|
|
m_Vel = vec2(0,0);
|
2013-07-18 22:27:17 +00:00
|
|
|
m_NewHook = false;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookPos = vec2(0,0);
|
|
|
|
m_HookDir = vec2(0,0);
|
|
|
|
m_HookTick = 0;
|
|
|
|
m_HookState = HOOK_IDLE;
|
|
|
|
m_HookedPlayer = -1;
|
|
|
|
m_Jumped = 0;
|
2013-08-23 23:03:45 +00:00
|
|
|
m_JumpedTotal = 0;
|
|
|
|
m_Jumps = 2;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents = 0;
|
2013-08-05 17:58:51 +00:00
|
|
|
m_Hook = true;
|
|
|
|
m_Collision = true;
|
2008-02-24 18:41:02 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 00:13:46 +00:00
|
|
|
void CCharacterCore::Tick(bool UseInput, bool IsClient)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
float PhysSize = 28.0f;
|
2018-08-24 07:34:54 +00:00
|
|
|
int MapIndex = Collision()->GetPureMapIndex(m_Pos);
|
|
|
|
int MapIndexL = Collision()->GetPureMapIndex(vec2(m_Pos.x + (28/2)+4,m_Pos.y));
|
|
|
|
int MapIndexR = Collision()->GetPureMapIndex(vec2(m_Pos.x - (28/2)-4,m_Pos.y));
|
|
|
|
int MapIndexT = Collision()->GetPureMapIndex(vec2(m_Pos.x,m_Pos.y + (28/2)+4));
|
|
|
|
int MapIndexB = Collision()->GetPureMapIndex(vec2(m_Pos.x,m_Pos.y - (28/2)-4));
|
|
|
|
m_TileIndex = Collision()->GetTileIndex(MapIndex);
|
|
|
|
m_TileFlags = Collision()->GetTileFlags(MapIndex);
|
|
|
|
m_TileIndexL = Collision()->GetTileIndex(MapIndexL);
|
|
|
|
m_TileFlagsL = Collision()->GetTileFlags(MapIndexL);
|
|
|
|
m_TileIndexR = Collision()->GetTileIndex(MapIndexR);
|
|
|
|
m_TileFlagsR = Collision()->GetTileFlags(MapIndexR);
|
|
|
|
m_TileIndexB = Collision()->GetTileIndex(MapIndexB);
|
|
|
|
m_TileFlagsB = Collision()->GetTileFlags(MapIndexB);
|
|
|
|
m_TileIndexT = Collision()->GetTileIndex(MapIndexT);
|
|
|
|
m_TileFlagsT = Collision()->GetTileFlags(MapIndexT);
|
|
|
|
m_TileFIndex = Collision()->GetFTileIndex(MapIndex);
|
|
|
|
m_TileFFlags = Collision()->GetFTileFlags(MapIndex);
|
|
|
|
m_TileFIndexL = Collision()->GetFTileIndex(MapIndexL);
|
|
|
|
m_TileFFlagsL = Collision()->GetFTileFlags(MapIndexL);
|
|
|
|
m_TileFIndexR = Collision()->GetFTileIndex(MapIndexR);
|
|
|
|
m_TileFFlagsR = Collision()->GetFTileFlags(MapIndexR);
|
|
|
|
m_TileFIndexB = Collision()->GetFTileIndex(MapIndexB);
|
|
|
|
m_TileFFlagsB = Collision()->GetFTileFlags(MapIndexB);
|
|
|
|
m_TileFIndexT = Collision()->GetFTileIndex(MapIndexT);
|
|
|
|
m_TileFFlagsT = Collision()->GetFTileFlags(MapIndexT);
|
|
|
|
m_TileSIndex = (UseInput && IsRightTeam(MapIndex))?Collision()->GetDTileIndex(MapIndex):0;
|
|
|
|
m_TileSFlags = (UseInput && IsRightTeam(MapIndex))?Collision()->GetDTileFlags(MapIndex):0;
|
|
|
|
m_TileSIndexL = (UseInput && IsRightTeam(MapIndexL))?Collision()->GetDTileIndex(MapIndexL):0;
|
|
|
|
m_TileSFlagsL = (UseInput && IsRightTeam(MapIndexL))?Collision()->GetDTileFlags(MapIndexL):0;
|
|
|
|
m_TileSIndexR = (UseInput && IsRightTeam(MapIndexR))?Collision()->GetDTileIndex(MapIndexR):0;
|
|
|
|
m_TileSFlagsR = (UseInput && IsRightTeam(MapIndexR))?Collision()->GetDTileFlags(MapIndexR):0;
|
|
|
|
m_TileSIndexB = (UseInput && IsRightTeam(MapIndexB))?Collision()->GetDTileIndex(MapIndexB):0;
|
|
|
|
m_TileSFlagsB = (UseInput && IsRightTeam(MapIndexB))?Collision()->GetDTileFlags(MapIndexB):0;
|
|
|
|
m_TileSIndexT = (UseInput && IsRightTeam(MapIndexT))?Collision()->GetDTileIndex(MapIndexT):0;
|
|
|
|
m_TileSFlagsT = (UseInput && IsRightTeam(MapIndexT))?Collision()->GetDTileFlags(MapIndexT):0;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2018-08-24 07:34:54 +00:00
|
|
|
vec2 PrevPos = m_Pos;
|
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// get ground state
|
2010-05-29 07:25:38 +00:00
|
|
|
bool Grounded = false;
|
2010-08-29 03:46:09 +00:00
|
|
|
if(m_pCollision->CheckPoint(m_Pos.x+PhysSize/2, m_Pos.y+PhysSize/2+5))
|
2010-05-29 07:25:38 +00:00
|
|
|
Grounded = true;
|
2010-08-29 03:46:09 +00:00
|
|
|
if(m_pCollision->CheckPoint(m_Pos.x-PhysSize/2, m_Pos.y+PhysSize/2+5))
|
2010-05-29 07:25:38 +00:00
|
|
|
Grounded = true;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec2 TargetDirection = normalize(vec2(m_Input.m_TargetX, m_Input.m_TargetY));
|
2007-09-22 18:55:00 +00:00
|
|
|
|
2014-04-29 01:34:23 +00:00
|
|
|
m_Vel.y += m_pWorld->m_Tuning[g_Config.m_ClDummy].m_Gravity;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2014-04-29 01:34:23 +00:00
|
|
|
float MaxSpeed = Grounded ? m_pWorld->m_Tuning[g_Config.m_ClDummy].m_GroundControlSpeed : m_pWorld->m_Tuning[g_Config.m_ClDummy].m_AirControlSpeed;
|
|
|
|
float Accel = Grounded ? m_pWorld->m_Tuning[g_Config.m_ClDummy].m_GroundControlAccel : m_pWorld->m_Tuning[g_Config.m_ClDummy].m_AirControlAccel;
|
|
|
|
float Friction = Grounded ? m_pWorld->m_Tuning[g_Config.m_ClDummy].m_GroundFriction : m_pWorld->m_Tuning[g_Config.m_ClDummy].m_AirFriction;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// handle input
|
2010-05-29 07:25:38 +00:00
|
|
|
if(UseInput)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Direction = m_Input.m_Direction;
|
2008-09-23 07:43:41 +00:00
|
|
|
|
|
|
|
// setup angle
|
2011-02-13 06:47:51 +00:00
|
|
|
float a = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Input.m_TargetX == 0)
|
2011-02-13 06:47:51 +00:00
|
|
|
a = atanf((float)m_Input.m_TargetY);
|
2008-09-23 07:43:41 +00:00
|
|
|
else
|
2011-02-13 06:47:51 +00:00
|
|
|
a = atanf((float)m_Input.m_TargetY/(float)m_Input.m_TargetX);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Input.m_TargetX < 0)
|
2011-02-13 06:47:51 +00:00
|
|
|
a = a+pi;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-02-13 06:47:51 +00:00
|
|
|
m_Angle = (int)(a*256.0f);
|
2008-09-23 07:43:41 +00:00
|
|
|
|
|
|
|
// handle jump
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Input.m_Jump)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2013-08-24 00:25:58 +00:00
|
|
|
if(!(m_Jumped&1))
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2013-08-24 00:25:58 +00:00
|
|
|
if(Grounded)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2013-08-24 00:25:58 +00:00
|
|
|
m_TriggeredEvents |= COREEVENT_GROUND_JUMP;
|
2014-04-29 01:34:23 +00:00
|
|
|
m_Vel.y = -m_pWorld->m_Tuning[g_Config.m_ClDummy].m_GroundJumpImpulse;
|
2013-08-24 00:25:58 +00:00
|
|
|
m_Jumped |= 1;
|
|
|
|
m_JumpedTotal = 1;
|
|
|
|
}
|
|
|
|
else if(!(m_Jumped&2))
|
|
|
|
{
|
|
|
|
m_TriggeredEvents |= COREEVENT_AIR_JUMP;
|
2014-04-29 01:34:23 +00:00
|
|
|
m_Vel.y = -m_pWorld->m_Tuning[g_Config.m_ClDummy].m_AirJumpImpulse;
|
2013-08-24 00:25:58 +00:00
|
|
|
m_Jumped |= 3;
|
|
|
|
m_JumpedTotal++;
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Jumped &= ~1;
|
2008-09-23 07:43:41 +00:00
|
|
|
|
|
|
|
// handle hook
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Input.m_Hook)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_HookState == HOOK_IDLE)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookState = HOOK_FLYING;
|
|
|
|
m_HookPos = m_Pos+TargetDirection*PhysSize*1.5f;
|
|
|
|
m_HookDir = TargetDirection;
|
|
|
|
m_HookedPlayer = -1;
|
2014-12-27 11:05:02 +00:00
|
|
|
m_HookTick = SERVER_TICK_SPEED * (1.25f - m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDuration);
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents |= COREEVENT_HOOK_LAUNCH;
|
2011-04-13 18:37:12 +00:00
|
|
|
}
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookedPlayer = -1;
|
|
|
|
m_HookState = HOOK_IDLE;
|
2011-04-13 18:37:12 +00:00
|
|
|
m_HookPos = m_Pos;
|
|
|
|
}
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// add the speed modification according to players wanted direction
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Direction < 0)
|
2014-05-01 01:03:31 +00:00
|
|
|
m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, -Accel);
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Direction > 0)
|
2014-05-01 01:03:31 +00:00
|
|
|
m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, Accel);
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Direction == 0)
|
|
|
|
m_Vel.x *= Friction;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2007-09-22 18:55:00 +00:00
|
|
|
// handle jumping
|
2014-12-29 14:54:55 +00:00
|
|
|
// 1 bit = to keep track if a jump has been made on this input (player is holding space bar)
|
|
|
|
// 2 bit = to keep track if a air-jump has been made (tee gets dark feet)
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Grounded)
|
2013-08-23 23:03:45 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Jumped &= ~2;
|
2013-08-23 23:03:45 +00:00
|
|
|
m_JumpedTotal = 0;
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// do hook
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_HookState == HOOK_IDLE)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookedPlayer = -1;
|
|
|
|
m_HookState = HOOK_IDLE;
|
|
|
|
m_HookPos = m_Pos;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(m_HookState >= HOOK_RETRACT_START && m_HookState < HOOK_RETRACT_END)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookState++;
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(m_HookState == HOOK_RETRACT_END)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookState = HOOK_RETRACTED;
|
|
|
|
m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
|
|
|
|
m_HookState = HOOK_RETRACTED;
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(m_HookState == HOOK_FLYING)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2014-04-29 01:34:23 +00:00
|
|
|
vec2 NewPos = m_HookPos+m_HookDir*m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookFireSpeed;
|
|
|
|
if((!m_NewHook && distance(m_Pos, NewPos) > m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookLength)
|
|
|
|
|| (m_NewHook && distance(m_HookTeleBase, NewPos) > m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookLength))
|
2008-03-22 13:03:52 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookState = HOOK_RETRACT_START;
|
2014-04-29 01:34:23 +00:00
|
|
|
NewPos = m_Pos + normalize(NewPos-m_Pos) * m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookLength;
|
2010-08-21 02:20:01 +00:00
|
|
|
m_pReset = true;
|
2008-03-19 23:08:26 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// make sure that the hook doesn't go though the ground
|
2010-05-29 07:25:38 +00:00
|
|
|
bool GoingToHitGround = false;
|
|
|
|
bool GoingToRetract = false;
|
2013-07-18 22:27:17 +00:00
|
|
|
bool GoingThroughTele = false;
|
|
|
|
int teleNr = 0;
|
2015-11-08 09:20:44 +00:00
|
|
|
int Hit = m_pCollision->IntersectLineTeleHook(m_HookPos, NewPos, &NewPos, 0, &teleNr);
|
2013-07-18 22:27:17 +00:00
|
|
|
|
|
|
|
//m_NewHook = false;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Hit)
|
2008-09-23 14:38:13 +00:00
|
|
|
{
|
2015-11-08 09:20:10 +00:00
|
|
|
if(Hit == TILE_NOHOOK)
|
2010-05-29 07:25:38 +00:00
|
|
|
GoingToRetract = true;
|
2015-11-08 09:20:10 +00:00
|
|
|
else if (Hit == TILE_TELEINHOOK)
|
2013-07-18 22:27:17 +00:00
|
|
|
GoingThroughTele = true;
|
2008-09-23 14:38:13 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
GoingToHitGround = true;
|
2010-08-21 02:20:01 +00:00
|
|
|
m_pReset = true;
|
2008-09-23 14:38:13 +00:00
|
|
|
}
|
2007-09-22 18:55:00 +00:00
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// Check against other players first
|
2014-04-29 01:34:23 +00:00
|
|
|
if(this->m_Hook && m_pWorld && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerHooking)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2011-02-13 06:47:51 +00:00
|
|
|
float Distance = 0.0f;
|
2007-09-22 18:55:00 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i];
|
2011-02-13 05:35:13 +00:00
|
|
|
if(!pCharCore || pCharCore == this || !m_pTeams->CanCollide(i, m_Id))
|
2007-09-22 18:55:00 +00:00
|
|
|
continue;
|
|
|
|
|
2011-02-12 10:40:36 +00:00
|
|
|
vec2 ClosestPoint = closest_point_on_line(m_HookPos, NewPos, pCharCore->m_Pos);
|
2013-07-19 01:22:47 +00:00
|
|
|
if(distance(pCharCore->m_Pos, ClosestPoint) < PhysSize+2.0f)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2011-02-13 06:47:51 +00:00
|
|
|
if (m_HookedPlayer == -1 || distance(m_HookPos, pCharCore->m_Pos) < Distance)
|
2009-01-09 22:41:26 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents |= COREEVENT_HOOK_ATTACH_PLAYER;
|
|
|
|
m_HookState = HOOK_GRABBED;
|
|
|
|
m_HookedPlayer = i;
|
2011-02-13 06:47:51 +00:00
|
|
|
Distance = distance(m_HookPos, pCharCore->m_Pos);
|
2009-01-09 22:41:26 +00:00
|
|
|
}
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_HookState == HOOK_FLYING)
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
|
|
|
// check against ground
|
2010-05-29 07:25:38 +00:00
|
|
|
if(GoingToHitGround)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents |= COREEVENT_HOOK_ATTACH_GROUND;
|
|
|
|
m_HookState = HOOK_GRABBED;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(GoingToRetract)
|
2008-09-23 14:38:13 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents |= COREEVENT_HOOK_HIT_NOHOOK;
|
|
|
|
m_HookState = HOOK_RETRACT_START;
|
2008-09-23 14:38:13 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2013-12-12 13:35:01 +00:00
|
|
|
if(GoingThroughTele && m_pTeleOuts && m_pTeleOuts->size() && (*m_pTeleOuts)[teleNr-1].size())
|
2013-07-18 22:27:17 +00:00
|
|
|
{
|
2013-07-18 23:23:48 +00:00
|
|
|
m_TriggeredEvents = 0;
|
|
|
|
m_HookedPlayer = -1;
|
2013-07-18 22:27:17 +00:00
|
|
|
|
|
|
|
m_NewHook = true;
|
2013-12-12 13:35:01 +00:00
|
|
|
int Num = (*m_pTeleOuts)[teleNr-1].size();
|
2014-12-30 13:43:02 +00:00
|
|
|
m_HookPos = (*m_pTeleOuts)[teleNr-1][(Num==1)?0:rand() % Num]+TargetDirection*PhysSize*1.5f;
|
2013-07-18 22:27:17 +00:00
|
|
|
m_HookDir = TargetDirection;
|
2014-01-27 04:06:23 +00:00
|
|
|
m_HookTeleBase = m_HookPos;
|
2013-07-18 22:27:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_HookPos = NewPos;
|
|
|
|
}
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_HookState == HOOK_GRABBED)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_HookedPlayer != -1)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[m_HookedPlayer];
|
2015-02-28 00:18:35 +00:00
|
|
|
if(pCharCore && (IsClient || m_pTeams->CanKeepHook(m_Id, pCharCore->m_Id)))
|
2015-02-23 23:04:16 +00:00
|
|
|
m_HookPos = pCharCore->m_Pos;
|
2007-12-09 15:58:24 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// release hook
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookedPlayer = -1;
|
|
|
|
m_HookState = HOOK_RETRACTED;
|
2011-04-13 18:37:12 +00:00
|
|
|
m_HookPos = m_Pos;
|
2007-12-09 15:58:24 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2007-09-22 18:55:00 +00:00
|
|
|
// keep players hooked for a max of 1.5sec
|
2010-05-29 07:25:38 +00:00
|
|
|
//if(Server()->Tick() > hook_tick+(Server()->TickSpeed()*3)/2)
|
2007-09-22 18:55:00 +00:00
|
|
|
//release_hooked();
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2007-12-15 10:49:47 +00:00
|
|
|
// don't do this hook rutine when we are hook to a player
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_HookedPlayer == -1 && distance(m_HookPos, m_Pos) > 46.0f)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2014-04-29 01:34:23 +00:00
|
|
|
vec2 HookVel = normalize(m_HookPos-m_Pos)*m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragAccel;
|
2007-09-22 18:55:00 +00:00
|
|
|
// the hook as more power to drag you up then down.
|
|
|
|
// this makes it easier to get on top of an platform
|
2010-05-29 07:25:38 +00:00
|
|
|
if(HookVel.y > 0)
|
|
|
|
HookVel.y *= 0.3f;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2007-09-22 18:55:00 +00:00
|
|
|
// the hook will boost it's power if the player wants to move
|
|
|
|
// in that direction. otherwise it will dampen everything abit
|
2011-04-13 18:37:12 +00:00
|
|
|
if((HookVel.x < 0 && m_Direction < 0) || (HookVel.x > 0 && m_Direction > 0))
|
2010-05-29 07:25:38 +00:00
|
|
|
HookVel.x *= 0.95f;
|
2007-09-22 18:55:00 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
HookVel.x *= 0.75f;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec2 NewVel = m_Vel+HookVel;
|
2008-01-29 21:39:41 +00:00
|
|
|
|
2007-09-22 18:55:00 +00:00
|
|
|
// check if we are under the legal limit for the hook
|
2014-04-29 01:34:23 +00:00
|
|
|
if(length(NewVel) < m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragSpeed || length(NewVel) < length(m_Vel))
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Vel = NewVel; // no problem. apply
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
2007-12-09 15:56:56 +00:00
|
|
|
|
2014-12-27 11:05:02 +00:00
|
|
|
// release hook (max default hook time is 1.25 s)
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookTick++;
|
|
|
|
if(m_HookedPlayer != -1 && (m_HookTick > SERVER_TICK_SPEED+SERVER_TICK_SPEED/5 || !m_pWorld->m_apCharacters[m_HookedPlayer]))
|
2007-12-09 15:56:56 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookedPlayer = -1;
|
|
|
|
m_HookState = HOOK_RETRACTED;
|
2011-04-13 18:37:12 +00:00
|
|
|
m_HookPos = m_Pos;
|
2007-12-09 15:56:56 +00:00
|
|
|
}
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-08-06 11:57:59 +00:00
|
|
|
if(m_pWorld)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
|
|
|
for(int i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i];
|
|
|
|
if(!pCharCore)
|
2007-09-22 18:55:00 +00:00
|
|
|
continue;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2007-09-22 18:55:00 +00:00
|
|
|
//player *p = (player*)ent;
|
2011-04-09 06:41:31 +00:00
|
|
|
//if(pCharCore == this) // || !(p->flags&FLAG_ALIVE)
|
|
|
|
|
|
|
|
if(pCharCore == this || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, i)))
|
2007-09-22 18:55:00 +00:00
|
|
|
continue; // make sure that we don't nudge our self
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2014-08-28 14:20:11 +00:00
|
|
|
// handle player <-> player collision
|
|
|
|
float Distance = distance(m_Pos, pCharCore->m_Pos);
|
|
|
|
vec2 Dir = normalize(m_Pos - pCharCore->m_Pos);
|
|
|
|
if(pCharCore->m_Collision && this->m_Collision && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision && Distance < PhysSize*1.25f && Distance > 0.0f)
|
|
|
|
{
|
|
|
|
float a = (PhysSize*1.45f - Distance);
|
|
|
|
float Velocity = 0.5f;
|
2014-08-27 12:14:32 +00:00
|
|
|
|
2014-08-28 14:20:11 +00:00
|
|
|
// make sure that we don't add excess force by checking the
|
|
|
|
// direction against the current velocity. if not zero.
|
|
|
|
if (length(m_Vel) > 0.0001)
|
|
|
|
Velocity = 1-(dot(normalize(m_Vel), Dir)+1)/2;
|
|
|
|
|
|
|
|
m_Vel += Dir*a*(Velocity*0.75f);
|
|
|
|
m_Vel *= 0.85f;
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle hook influence
|
|
|
|
if(m_Hook && m_HookedPlayer == i && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerHooking)
|
|
|
|
{
|
|
|
|
if(Distance > PhysSize*1.50f) // TODO: fix tweakable variable
|
|
|
|
{
|
|
|
|
float Accel = m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragAccel * (Distance/m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookLength);
|
|
|
|
float DragSpeed = m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragSpeed;
|
|
|
|
|
|
|
|
// add force to the hooked player
|
2018-08-24 07:34:54 +00:00
|
|
|
vec2 Temp = pCharCore->m_Vel;
|
2014-08-28 14:20:11 +00:00
|
|
|
Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x, Accel*Dir.x*1.5f);
|
|
|
|
Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y, Accel*Dir.y*1.5f);
|
2018-08-24 07:34:54 +00:00
|
|
|
if(Temp.x > 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_270) || (pCharCore->m_TileIndexL == TILE_STOP && pCharCore->m_TileFlagsL == ROTATION_270) || (pCharCore->m_TileIndexL == TILE_STOPS && (pCharCore->m_TileFlagsL == ROTATION_90 || pCharCore->m_TileFlagsL ==ROTATION_270)) || (pCharCore->m_TileIndexL == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_270) || (pCharCore->m_TileFIndexL == TILE_STOP && pCharCore->m_TileFFlagsL == ROTATION_270) || (pCharCore->m_TileFIndexL == TILE_STOPS && (pCharCore->m_TileFFlagsL == ROTATION_90 || pCharCore->m_TileFFlagsL == ROTATION_270)) || (pCharCore->m_TileFIndexL == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_270) || (pCharCore->m_TileSIndexL == TILE_STOP && pCharCore->m_TileSFlagsL == ROTATION_270) || (pCharCore->m_TileSIndexL == TILE_STOPS && (pCharCore->m_TileSFlagsL == ROTATION_90 || pCharCore->m_TileSFlagsL == ROTATION_270)) || (pCharCore->m_TileSIndexL == TILE_STOPA)))
|
|
|
|
Temp.x = 0;
|
|
|
|
if(Temp.x < 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_90) || (pCharCore->m_TileIndexR == TILE_STOP && pCharCore->m_TileFlagsR == ROTATION_90) || (pCharCore->m_TileIndexR == TILE_STOPS && (pCharCore->m_TileFlagsR == ROTATION_90 || pCharCore->m_TileFlagsR == ROTATION_270)) || (pCharCore->m_TileIndexR == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_90) || (pCharCore->m_TileFIndexR == TILE_STOP && pCharCore->m_TileFFlagsR == ROTATION_90) || (pCharCore->m_TileFIndexR == TILE_STOPS && (pCharCore->m_TileFFlagsR == ROTATION_90 || pCharCore->m_TileFFlagsR == ROTATION_270)) || (pCharCore->m_TileFIndexR == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_90) || (pCharCore->m_TileSIndexR == TILE_STOP && pCharCore->m_TileSFlagsR == ROTATION_90) || (pCharCore->m_TileSIndexR == TILE_STOPS && (pCharCore->m_TileSFlagsR == ROTATION_90 || pCharCore->m_TileSFlagsR == ROTATION_270)) || (pCharCore->m_TileSIndexR == TILE_STOPA)))
|
|
|
|
Temp.x = 0;
|
|
|
|
if(Temp.y < 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_180) || (pCharCore->m_TileIndexB == TILE_STOP && pCharCore->m_TileFlagsB == ROTATION_180) || (pCharCore->m_TileIndexB == TILE_STOPS && (pCharCore->m_TileFlagsB == ROTATION_0 || pCharCore->m_TileFlagsB == ROTATION_180)) || (pCharCore->m_TileIndexB == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_180) || (pCharCore->m_TileFIndexB == TILE_STOP && pCharCore->m_TileFFlagsB == ROTATION_180) || (pCharCore->m_TileFIndexB == TILE_STOPS && (pCharCore->m_TileFFlagsB == ROTATION_0 || pCharCore->m_TileFFlagsB == ROTATION_180)) || (pCharCore->m_TileFIndexB == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_180) || (pCharCore->m_TileSIndexB == TILE_STOP && pCharCore->m_TileSFlagsB == ROTATION_180) || (pCharCore->m_TileSIndexB == TILE_STOPS && (pCharCore->m_TileSFlagsB == ROTATION_0 || pCharCore->m_TileSFlagsB == ROTATION_180)) || (pCharCore->m_TileSIndexB == TILE_STOPA)))
|
|
|
|
Temp.y = 0;
|
|
|
|
if(Temp.y > 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_0) || (pCharCore->m_TileIndexT == TILE_STOP && pCharCore->m_TileFlagsT == ROTATION_0) || (pCharCore->m_TileIndexT == TILE_STOPS && (pCharCore->m_TileFlagsT == ROTATION_0 || pCharCore->m_TileFlagsT == ROTATION_180)) || (pCharCore->m_TileIndexT == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_0) || (pCharCore->m_TileFIndexT == TILE_STOP && pCharCore->m_TileFFlagsT == ROTATION_0) || (pCharCore->m_TileFIndexT == TILE_STOPS && (pCharCore->m_TileFFlagsT == ROTATION_0 || pCharCore->m_TileFFlagsT == ROTATION_180)) || (pCharCore->m_TileFIndexT == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_0) || (pCharCore->m_TileSIndexT == TILE_STOP && pCharCore->m_TileSFlagsT == ROTATION_0) || (pCharCore->m_TileSIndexT == TILE_STOPS && (pCharCore->m_TileSFlagsT == ROTATION_0 || pCharCore->m_TileSFlagsT == ROTATION_180)) || (pCharCore->m_TileSIndexT == TILE_STOPA)))
|
|
|
|
Temp.y = 0;
|
|
|
|
|
2014-08-28 14:20:11 +00:00
|
|
|
// add a little bit force to the guy who has the grip
|
2018-08-24 07:34:54 +00:00
|
|
|
pCharCore->m_Vel = Temp;
|
2014-08-28 14:20:11 +00:00
|
|
|
Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -Accel*Dir.x*0.25f);
|
|
|
|
Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -Accel*Dir.y*0.25f);
|
2018-08-24 07:34:54 +00:00
|
|
|
if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)))
|
|
|
|
Temp.x = 0;
|
|
|
|
if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)))
|
|
|
|
Temp.x = 0;
|
|
|
|
if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)))
|
|
|
|
Temp.y = 0;
|
|
|
|
if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)))
|
|
|
|
Temp.y = 0;
|
|
|
|
m_Vel = Temp;
|
2014-08-28 14:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_HookState != HOOK_FLYING)
|
|
|
|
{
|
|
|
|
m_NewHook = false;
|
|
|
|
}
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2018-08-24 07:34:54 +00:00
|
|
|
int Index = MapIndex;
|
2014-08-27 12:14:32 +00:00
|
|
|
if(g_Config.m_ClPredictDDRace && IsClient && m_pCollision->IsSpeedup(Index))
|
|
|
|
{
|
|
|
|
vec2 Direction, MaxVel, TempVel = m_Vel;
|
|
|
|
int Force, MaxSpeed = 0;
|
|
|
|
float TeeAngle, SpeederAngle, DiffAngle, SpeedLeft, TeeSpeed;
|
|
|
|
m_pCollision->GetSpeedup(Index, &Direction, &Force, &MaxSpeed);
|
|
|
|
if(Force == 255 && MaxSpeed)
|
|
|
|
{
|
|
|
|
m_Vel = Direction * (MaxSpeed/5);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(MaxSpeed > 0 && MaxSpeed < 5) MaxSpeed = 5;
|
|
|
|
if(MaxSpeed > 0)
|
|
|
|
{
|
|
|
|
if(Direction.x > 0.0000001f)
|
|
|
|
SpeederAngle = -atan(Direction.y / Direction.x);
|
|
|
|
else if(Direction.x < 0.0000001f)
|
|
|
|
SpeederAngle = atan(Direction.y / Direction.x) + 2.0f * asin(1.0f);
|
|
|
|
else if(Direction.y > 0.0000001f)
|
|
|
|
SpeederAngle = asin(1.0f);
|
|
|
|
else
|
|
|
|
SpeederAngle = asin(-1.0f);
|
|
|
|
|
|
|
|
if(SpeederAngle < 0)
|
|
|
|
SpeederAngle = 4.0f * asin(1.0f) + SpeederAngle;
|
|
|
|
|
|
|
|
if(TempVel.x > 0.0000001f)
|
|
|
|
TeeAngle = -atan(TempVel.y / TempVel.x);
|
|
|
|
else if(TempVel.x < 0.0000001f)
|
|
|
|
TeeAngle = atan(TempVel.y / TempVel.x) + 2.0f * asin(1.0f);
|
|
|
|
else if(TempVel.y > 0.0000001f)
|
|
|
|
TeeAngle = asin(1.0f);
|
|
|
|
else
|
|
|
|
TeeAngle = asin(-1.0f);
|
|
|
|
|
|
|
|
if(TeeAngle < 0)
|
|
|
|
TeeAngle = 4.0f * asin(1.0f) + TeeAngle;
|
|
|
|
|
|
|
|
TeeSpeed = sqrt(pow(TempVel.x, 2) + pow(TempVel.y, 2));
|
|
|
|
|
|
|
|
DiffAngle = SpeederAngle - TeeAngle;
|
|
|
|
SpeedLeft = MaxSpeed / 5.0f - cos(DiffAngle) * TeeSpeed;
|
2015-04-18 20:29:28 +00:00
|
|
|
if(abs((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f)
|
2014-08-27 12:14:32 +00:00
|
|
|
TempVel += Direction * Force;
|
2015-04-18 20:29:28 +00:00
|
|
|
else if(abs((int)SpeedLeft) > Force)
|
2014-08-27 12:14:32 +00:00
|
|
|
TempVel += Direction * -Force;
|
|
|
|
else
|
|
|
|
TempVel += Direction * SpeedLeft;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TempVel += Direction * Force;
|
|
|
|
|
2018-08-24 07:34:54 +00:00
|
|
|
|
|
|
|
if(TempVel.x > 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_270) || (this->m_TileIndexL == TILE_STOP && this->m_TileFlagsL == ROTATION_270) || (this->m_TileIndexL == TILE_STOPS && (this->m_TileFlagsL == ROTATION_90 || this->m_TileFlagsL ==ROTATION_270)) || (this->m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)))
|
|
|
|
TempVel.x = 0;
|
|
|
|
if(TempVel.x < 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_90) || (this->m_TileIndexR == TILE_STOP && this->m_TileFlagsR == ROTATION_90) || (this->m_TileIndexR == TILE_STOPS && (this->m_TileFlagsR == ROTATION_90 || this->m_TileFlagsR == ROTATION_270)) || (this->m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)))
|
|
|
|
TempVel.x = 0;
|
|
|
|
if(TempVel.y < 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_180) || (this->m_TileIndexB == TILE_STOP && this->m_TileFlagsB == ROTATION_180) || (this->m_TileIndexB == TILE_STOPS && (this->m_TileFlagsB == ROTATION_0 || this->m_TileFlagsB == ROTATION_180)) || (this->m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)))
|
|
|
|
TempVel.y = 0;
|
|
|
|
if(TempVel.y > 0 && ((this->m_TileIndex == TILE_STOP && this->m_TileFlags == ROTATION_0) || (this->m_TileIndexT == TILE_STOP && this->m_TileFlagsT == ROTATION_0) || (this->m_TileIndexT == TILE_STOPS && (this->m_TileFlagsT == ROTATION_0 || this->m_TileFlagsT == ROTATION_180)) || (this->m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)))
|
|
|
|
TempVel.y = 0;
|
|
|
|
|
|
|
|
|
|
|
|
m_Vel = TempVel;
|
2014-08-27 12:14:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-14 17:55:50 +00:00
|
|
|
// jetpack and ninjajetpack prediction
|
|
|
|
if(IsClient && UseInput && (m_Input.m_Fire&1) && (m_ActiveWeapon == WEAPON_GUN || m_ActiveWeapon == WEAPON_NINJA)) {
|
2014-04-29 01:34:23 +00:00
|
|
|
m_Vel += TargetDirection * -1.0f * (m_pWorld->m_Tuning[g_Config.m_ClDummy].m_JetpackStrength / 100.0f / 6.11f);
|
2014-04-13 23:34:50 +00:00
|
|
|
}
|
2015-03-14 17:55:50 +00:00
|
|
|
|
2014-03-28 22:53:12 +00:00
|
|
|
if(g_Config.m_ClPredictDDRace && IsClient)
|
2014-03-27 10:19:25 +00:00
|
|
|
{
|
2018-08-24 07:34:54 +00:00
|
|
|
if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)) && m_Vel.x > 0)
|
|
|
|
{
|
|
|
|
if((int)m_pCollision->GetPos(MapIndexL).x < (int)m_Pos.x)
|
|
|
|
m_Pos = PrevPos;
|
|
|
|
m_Vel.x = 0;
|
|
|
|
}
|
|
|
|
if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)) && m_Vel.x < 0)
|
|
|
|
{
|
|
|
|
if((int)m_pCollision->GetPos(MapIndexR).x)
|
|
|
|
if((int)m_pCollision->GetPos(MapIndexR).x < (int)m_Pos.x)
|
|
|
|
m_Pos = PrevPos;
|
|
|
|
m_Vel.x = 0;
|
|
|
|
}
|
|
|
|
if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)) && m_Vel.y < 0)
|
|
|
|
{
|
|
|
|
if((int)m_pCollision->GetPos(MapIndexB).y)
|
|
|
|
if((int)m_pCollision->GetPos(MapIndexB).y < (int)m_Pos.y)
|
|
|
|
m_Pos = PrevPos;
|
|
|
|
m_Vel.y = 0;
|
|
|
|
}
|
|
|
|
if(((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)) && m_Vel.y > 0)
|
2014-03-27 10:19:25 +00:00
|
|
|
{
|
2018-08-24 07:34:54 +00:00
|
|
|
if((int)m_pCollision->GetPos(MapIndexT).y)
|
|
|
|
if((int)m_pCollision->GetPos(MapIndexT).y < (int)m_Pos.y)
|
|
|
|
m_Pos = PrevPos;
|
|
|
|
m_Vel.y = 0;
|
2014-03-27 10:19:25 +00:00
|
|
|
m_Jumped = 0;
|
|
|
|
m_JumpedTotal = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
}
|
2008-01-20 15:19:30 +00:00
|
|
|
|
|
|
|
// clamp the velocity to something sane
|
2010-05-29 07:25:38 +00:00
|
|
|
if(length(m_Vel) > 6000)
|
|
|
|
m_Vel = normalize(m_Vel) * 6000;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
|
2018-08-22 06:33:21 +00:00
|
|
|
void CCharacterCore::Move()
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2014-04-29 01:34:23 +00:00
|
|
|
float RampValue = VelocityRamp(length(m_Vel)*50, m_pWorld->m_Tuning[g_Config.m_ClDummy].m_VelrampStart, m_pWorld->m_Tuning[g_Config.m_ClDummy].m_VelrampRange, m_pWorld->m_Tuning[g_Config.m_ClDummy].m_VelrampCurvature);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Vel.x = m_Vel.x*RampValue;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
vec2 NewPos = m_Pos;
|
2014-06-21 22:50:11 +00:00
|
|
|
|
|
|
|
vec2 OldVel = m_Vel;
|
2018-08-22 06:33:28 +00:00
|
|
|
m_pCollision->MoveBox(&NewPos, &m_Vel, vec2(28.0f, 28.0f), 0);
|
2011-03-27 14:15:10 +00:00
|
|
|
|
2014-06-22 16:07:28 +00:00
|
|
|
m_Colliding = 0;
|
2014-06-22 16:07:00 +00:00
|
|
|
if(m_Vel.x < 0.001 && m_Vel.x > -0.001)
|
2014-06-21 22:50:11 +00:00
|
|
|
{
|
|
|
|
if(OldVel.x > 0)
|
|
|
|
m_Colliding = 1;
|
|
|
|
else if(OldVel.x < 0)
|
|
|
|
m_Colliding = 2;
|
|
|
|
}
|
2014-06-23 12:46:27 +00:00
|
|
|
else
|
|
|
|
m_LeftWall = true;
|
2014-06-21 22:50:11 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Vel.x = m_Vel.x*(1.0f/RampValue);
|
2011-03-27 14:15:10 +00:00
|
|
|
|
2014-04-29 01:34:23 +00:00
|
|
|
if(m_pWorld && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision && this->m_Collision)
|
2011-03-27 14:15:10 +00:00
|
|
|
{
|
2011-04-09 06:41:31 +00:00
|
|
|
// check player collision
|
|
|
|
float Distance = distance(m_Pos, NewPos);
|
|
|
|
int End = Distance+1;
|
2011-07-30 16:08:24 +00:00
|
|
|
vec2 LastPos = m_Pos;
|
2011-04-09 06:41:31 +00:00
|
|
|
for(int i = 0; i < End; i++)
|
|
|
|
{
|
|
|
|
float a = i/Distance;
|
|
|
|
vec2 Pos = mix(m_Pos, NewPos, a);
|
|
|
|
for(int p = 0; p < MAX_CLIENTS; p++)
|
|
|
|
{
|
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p];
|
2014-11-27 21:38:25 +00:00
|
|
|
if(!pCharCore || pCharCore == this || !pCharCore->m_Collision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)))
|
2011-04-09 06:41:31 +00:00
|
|
|
continue;
|
|
|
|
float D = distance(Pos, pCharCore->m_Pos);
|
2011-07-30 16:08:24 +00:00
|
|
|
if(D < 28.0f && D > 0.0f)
|
|
|
|
{
|
|
|
|
if(a > 0.0f)
|
|
|
|
m_Pos = LastPos;
|
|
|
|
else if(distance(NewPos, pCharCore->m_Pos) > D)
|
2011-04-09 06:41:31 +00:00
|
|
|
m_Pos = NewPos;
|
|
|
|
return;
|
|
|
|
}
|
2011-12-26 13:31:05 +00:00
|
|
|
else if(D <= 0.001f && D >= -0.001f)
|
|
|
|
{
|
|
|
|
if(a > 0.0f)
|
|
|
|
m_Pos = LastPos;
|
|
|
|
else if(distance(NewPos, pCharCore->m_Pos) > D)
|
|
|
|
m_Pos = NewPos;
|
|
|
|
return;
|
|
|
|
}
|
2011-04-09 06:41:31 +00:00
|
|
|
}
|
2011-07-30 16:08:24 +00:00
|
|
|
LastPos = Pos;
|
2011-04-01 19:32:16 +00:00
|
|
|
}
|
2011-03-27 14:15:10 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-04-01 19:32:16 +00:00
|
|
|
m_Pos = NewPos;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CCharacterCore::Write(CNetObj_CharacterCore *pObjCore)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2014-04-22 21:46:55 +00:00
|
|
|
pObjCore->m_X = round_to_int(m_Pos.x);
|
|
|
|
pObjCore->m_Y = round_to_int(m_Pos.y);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2014-04-22 21:46:55 +00:00
|
|
|
pObjCore->m_VelX = round_to_int(m_Vel.x*256.0f);
|
|
|
|
pObjCore->m_VelY = round_to_int(m_Vel.y*256.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
pObjCore->m_HookState = m_HookState;
|
|
|
|
pObjCore->m_HookTick = m_HookTick;
|
2014-04-22 21:46:55 +00:00
|
|
|
pObjCore->m_HookX = round_to_int(m_HookPos.x);
|
|
|
|
pObjCore->m_HookY = round_to_int(m_HookPos.y);
|
|
|
|
pObjCore->m_HookDx = round_to_int(m_HookDir.x*256.0f);
|
|
|
|
pObjCore->m_HookDy = round_to_int(m_HookDir.y*256.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
pObjCore->m_HookedPlayer = m_HookedPlayer;
|
|
|
|
pObjCore->m_Jumped = m_Jumped;
|
|
|
|
pObjCore->m_Direction = m_Direction;
|
|
|
|
pObjCore->m_Angle = m_Angle;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CCharacterCore::Read(const CNetObj_CharacterCore *pObjCore)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Pos.x = pObjCore->m_X;
|
|
|
|
m_Pos.y = pObjCore->m_Y;
|
|
|
|
m_Vel.x = pObjCore->m_VelX/256.0f;
|
|
|
|
m_Vel.y = pObjCore->m_VelY/256.0f;
|
|
|
|
m_HookState = pObjCore->m_HookState;
|
|
|
|
m_HookTick = pObjCore->m_HookTick;
|
|
|
|
m_HookPos.x = pObjCore->m_HookX;
|
|
|
|
m_HookPos.y = pObjCore->m_HookY;
|
|
|
|
m_HookDir.x = pObjCore->m_HookDx/256.0f;
|
|
|
|
m_HookDir.y = pObjCore->m_HookDy/256.0f;
|
|
|
|
m_HookedPlayer = pObjCore->m_HookedPlayer;
|
|
|
|
m_Jumped = pObjCore->m_Jumped;
|
|
|
|
m_Direction = pObjCore->m_Direction;
|
|
|
|
m_Angle = pObjCore->m_Angle;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CCharacterCore::Quantize()
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CNetObj_CharacterCore Core;
|
|
|
|
Write(&Core);
|
|
|
|
Read(&Core);
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
2011-01-06 03:46:10 +00:00
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
// DDRace
|
2011-01-06 03:46:10 +00:00
|
|
|
|
2018-08-24 07:34:54 +00:00
|
|
|
bool CCharacterCore::IsRightTeam(int MapIndex)
|
2011-01-06 03:46:10 +00:00
|
|
|
{
|
2018-08-24 07:34:54 +00:00
|
|
|
if(Collision()->m_pSwitchers)
|
|
|
|
if(m_pTeams->Team(m_Id) != (m_pTeams->m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER))
|
|
|
|
return Collision()->m_pSwitchers[Collision()->GetDTileNumber(MapIndex)].m_Status[m_pTeams->Team(m_Id)];
|
2018-08-22 06:33:28 +00:00
|
|
|
return false;
|
2011-01-06 03:46:10 +00:00
|
|
|
}
|
2014-12-01 00:31:58 +00:00
|
|
|
|
2018-08-24 07:34:54 +00:00
|
|
|
void CCharacterCore::LimitForce(vec2 *Force)
|
2014-12-01 00:31:58 +00:00
|
|
|
{
|
2018-08-24 07:34:54 +00:00
|
|
|
vec2 Temp = *Force;
|
|
|
|
if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA)))
|
|
|
|
Temp.x = 0;
|
|
|
|
if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA)))
|
|
|
|
Temp.x = 0;
|
|
|
|
if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA)))
|
|
|
|
Temp.y = 0;
|
|
|
|
if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA)))
|
|
|
|
Temp.y = 0;
|
|
|
|
*Force = Temp;
|
2014-12-01 00:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCharacterCore::ApplyForce(vec2 Force)
|
|
|
|
{
|
|
|
|
vec2 Temp = m_Vel + Force;
|
2018-08-24 07:34:54 +00:00
|
|
|
LimitForce(&Temp);
|
2014-12-01 00:31:58 +00:00
|
|
|
m_Vel = Temp;
|
|
|
|
}
|