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"
|
2022-06-16 16:06:35 +00:00
|
|
|
|
|
|
|
#include "collision.h"
|
2022-05-29 12:11:29 +00:00
|
|
|
#include "mapitems.h"
|
2022-06-16 16:06:35 +00:00
|
|
|
#include "teamscore.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[] =
|
2020-09-26 19:41:58 +00:00
|
|
|
{
|
|
|
|
#define MACRO_TUNING_PARAM(Name, ScriptName, Value, Description) #ScriptName,
|
|
|
|
#include "tuning.h"
|
|
|
|
#undef MACRO_TUNING_PARAM
|
2008-02-02 12:38:36 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
bool CTuningParams::Get(int Index, float *pValue) const
|
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;
|
|
|
|
}
|
|
|
|
|
2021-02-08 21:26:26 +00:00
|
|
|
bool CTuningParams::Get(const char *pName, float *pValue) const
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
2020-09-26 19:41:58 +00:00
|
|
|
return 1.0f / powf(Curvature, (Value - Start) / Range);
|
2008-03-16 22:32:17 +00:00
|
|
|
}
|
|
|
|
|
2020-09-26 19:41:58 +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;
|
2021-05-12 16:57:50 +00:00
|
|
|
|
|
|
|
// fail safe, if core's tuning didn't get updated at all, just fallback to world tuning.
|
2022-06-30 22:36:32 +00:00
|
|
|
m_Tuning = m_pWorld->m_aTuning[g_Config.m_ClDummy];
|
2020-10-10 11:10:02 +00:00
|
|
|
Reset();
|
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
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
m_Pos = vec2(0, 0);
|
|
|
|
m_Vel = vec2(0, 0);
|
2013-07-18 22:27:17 +00:00
|
|
|
m_NewHook = false;
|
2020-09-26 19:41:58 +00:00
|
|
|
m_HookPos = vec2(0, 0);
|
|
|
|
m_HookDir = vec2(0, 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookTick = 0;
|
|
|
|
m_HookState = HOOK_IDLE;
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
|
|
|
m_AttachedPlayers.clear();
|
2010-05-29 07:25:38 +00:00
|
|
|
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;
|
2019-04-19 09:17:28 +00:00
|
|
|
|
|
|
|
// DDNet Character
|
2019-04-12 14:29:13 +00:00
|
|
|
m_Solo = false;
|
2019-04-19 09:17:28 +00:00
|
|
|
m_Jetpack = false;
|
2022-07-08 13:31:58 +00:00
|
|
|
m_CollisionDisabled = false;
|
2019-04-19 09:17:28 +00:00
|
|
|
m_EndlessHook = false;
|
|
|
|
m_EndlessJump = false;
|
2022-07-08 13:31:58 +00:00
|
|
|
m_HammerHitDisabled = false;
|
|
|
|
m_GrenadeHitDisabled = false;
|
|
|
|
m_LaserHitDisabled = false;
|
|
|
|
m_ShotgunHitDisabled = false;
|
|
|
|
m_HookHitDisabled = false;
|
2019-04-19 09:17:28 +00:00
|
|
|
m_Super = false;
|
|
|
|
m_HasTelegunGun = false;
|
|
|
|
m_HasTelegunGrenade = false;
|
|
|
|
m_HasTelegunLaser = false;
|
2022-05-24 15:26:49 +00:00
|
|
|
m_FreezeStart = 0;
|
2019-04-23 15:57:26 +00:00
|
|
|
m_FreezeEnd = 0;
|
2022-03-31 16:05:16 +00:00
|
|
|
m_IsInFreeze = false;
|
2019-04-19 09:17:28 +00:00
|
|
|
m_DeepFrozen = false;
|
2022-01-07 15:53:40 +00:00
|
|
|
m_LiveFrozen = false;
|
2020-10-17 16:17:13 +00:00
|
|
|
|
|
|
|
// never initialize both to 0
|
|
|
|
m_Input.m_TargetX = 0;
|
|
|
|
m_Input.m_TargetY = -1;
|
2008-02-24 18:41:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-19 16:34:49 +00:00
|
|
|
void CCharacterCore::Tick(bool UseInput, bool DoDeferredTick)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2018-08-15 15:47:07 +00:00
|
|
|
m_MoveRestrictions = m_pCollision->GetMoveRestrictions(UseInput ? IsSwitchActiveCb : 0, this, m_Pos);
|
2010-05-29 07:25:38 +00:00
|
|
|
m_TriggeredEvents = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-09-23 07:43:41 +00:00
|
|
|
// get ground state
|
2010-05-29 07:25:38 +00:00
|
|
|
bool Grounded = false;
|
2022-05-28 17:28:44 +00:00
|
|
|
if(m_pCollision->CheckPoint(m_Pos.x + PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5))
|
2010-05-29 07:25:38 +00:00
|
|
|
Grounded = true;
|
2022-05-28 17:28:44 +00:00
|
|
|
if(m_pCollision->CheckPoint(m_Pos.x - PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 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
|
|
|
|
2021-05-12 16:57:50 +00:00
|
|
|
m_Vel.y += m_Tuning.m_Gravity;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2021-05-12 16:57:50 +00:00
|
|
|
float MaxSpeed = Grounded ? m_Tuning.m_GroundControlSpeed : m_Tuning.m_AirControlSpeed;
|
|
|
|
float Accel = Grounded ? m_Tuning.m_GroundControlAccel : m_Tuning.m_AirControlAccel;
|
|
|
|
float Friction = Grounded ? m_Tuning.m_GroundFriction : m_Tuning.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
|
2022-05-10 16:41:46 +00:00
|
|
|
float TmpAngle = atan2f(m_Input.m_TargetY, m_Input.m_TargetX);
|
|
|
|
if(TmpAngle < -(pi / 2.0f))
|
2022-04-10 16:49:10 +00:00
|
|
|
{
|
2022-05-10 16:41:46 +00:00
|
|
|
m_Angle = (int)((TmpAngle + (2.0f * pi)) * 256.0f);
|
2022-04-10 16:49:10 +00:00
|
|
|
}
|
2008-09-23 07:43:41 +00:00
|
|
|
else
|
2022-04-10 16:49:10 +00:00
|
|
|
{
|
2022-05-10 16:41:46 +00:00
|
|
|
m_Angle = (int)(TmpAngle * 256.0f);
|
2022-04-10 16:49:10 +00:00
|
|
|
}
|
2008-09-23 07:43:41 +00:00
|
|
|
|
2022-05-20 19:37:05 +00:00
|
|
|
// Special jump cases:
|
|
|
|
// m_Jumps == -1: A tee may only make one ground jump. Second jumped bit is always set
|
|
|
|
// m_Jumps == 0: A tee may not make a jump. Second jumped bit is always set
|
|
|
|
// m_Jumps == 1: A tee may do either a ground jump or an air jump. Second jumped bit is set after the first jump
|
2022-05-20 20:55:01 +00:00
|
|
|
// The second jumped bit can be overridden by special tiles so that the tee can nevertheless jump.
|
2022-05-20 19:37:05 +00:00
|
|
|
|
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
|
|
|
{
|
2022-05-20 19:37:05 +00:00
|
|
|
if(!(m_Jumped & 1))
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2022-05-20 20:55:01 +00:00
|
|
|
if(Grounded && (!(m_Jumped & 2) || m_Jumps != 0))
|
2008-09-23 07:43:41 +00:00
|
|
|
{
|
2013-08-24 00:25:58 +00:00
|
|
|
m_TriggeredEvents |= COREEVENT_GROUND_JUMP;
|
2021-05-12 16:57:50 +00:00
|
|
|
m_Vel.y = -m_Tuning.m_GroundJumpImpulse;
|
2022-05-16 21:17:19 +00:00
|
|
|
if(m_Jumps > 1)
|
|
|
|
{
|
|
|
|
m_Jumped |= 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Jumped |= 3;
|
|
|
|
}
|
|
|
|
m_JumpedTotal = 0;
|
2013-08-24 00:25:58 +00:00
|
|
|
}
|
2022-05-20 19:37:05 +00:00
|
|
|
else if(!(m_Jumped & 2))
|
2013-08-24 00:25:58 +00:00
|
|
|
{
|
|
|
|
m_TriggeredEvents |= COREEVENT_AIR_JUMP;
|
2021-05-12 16:57:50 +00:00
|
|
|
m_Vel.y = -m_Tuning.m_AirJumpImpulse;
|
2013-08-24 00:25:58 +00:00
|
|
|
m_Jumped |= 3;
|
|
|
|
m_JumpedTotal++;
|
2008-09-23 07:43:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2022-05-16 21:17:19 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Jumped &= ~1;
|
2022-05-16 21:17:19 +00:00
|
|
|
}
|
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;
|
2022-05-28 17:28:44 +00:00
|
|
|
m_HookPos = m_Pos + TargetDirection * PhysicalSize() * 1.5f;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookDir = TargetDirection;
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
2022-02-14 16:36:54 +00:00
|
|
|
m_HookTick = (float)SERVER_TICK_SPEED * (1.25f - m_Tuning.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
|
|
|
|
{
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
2010-05-29 07:25:38 +00:00
|
|
|
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
|
|
|
|
2022-05-20 19:37:05 +00:00
|
|
|
// handle jumping
|
|
|
|
// 1 bit = to keep track if a jump has been made on this input (player is holding space bar)
|
|
|
|
// 2 bit = to track if all air-jumps have been used up (tee gets dark feet)
|
|
|
|
if(Grounded)
|
|
|
|
{
|
|
|
|
m_Jumped &= ~2;
|
|
|
|
m_JumpedTotal = 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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
|
|
|
{
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
2010-05-29 07:25:38 +00:00
|
|
|
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_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
|
|
|
{
|
2021-05-12 16:57:50 +00:00
|
|
|
vec2 NewPos = m_HookPos + m_HookDir * m_Tuning.m_HookFireSpeed;
|
|
|
|
if((!m_NewHook && distance(m_Pos, NewPos) > m_Tuning.m_HookLength) || (m_NewHook && distance(m_HookTeleBase, NewPos) > m_Tuning.m_HookLength))
|
2008-03-22 13:03:52 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookState = HOOK_RETRACT_START;
|
2021-05-12 16:57:50 +00:00
|
|
|
NewPos = m_Pos + normalize(NewPos - m_Pos) * m_Tuning.m_HookLength;
|
2022-06-30 22:36:32 +00:00
|
|
|
m_Reset = 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;
|
2020-09-26 19:41:58 +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;
|
2022-06-30 22:36:32 +00:00
|
|
|
m_Reset = 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
|
2022-07-08 13:31:58 +00:00
|
|
|
if(!this->m_HookHitDisabled && m_pWorld && m_Tuning.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];
|
2020-10-10 21:46:01 +00:00
|
|
|
if(!pCharCore || pCharCore == this || (!(m_Super || pCharCore->m_Super) && ((m_Id != -1 && !m_pTeams->CanCollide(i, m_Id)) || pCharCore->m_Solo || m_Solo)))
|
2007-09-22 18:55:00 +00:00
|
|
|
continue;
|
|
|
|
|
2020-10-17 18:22:13 +00:00
|
|
|
vec2 ClosestPoint;
|
|
|
|
if(closest_point_on_line(m_HookPos, NewPos, pCharCore->m_Pos, ClosestPoint))
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2022-05-28 17:28:44 +00:00
|
|
|
if(distance(pCharCore->m_Pos, ClosestPoint) < PhysicalSize() + 2.0f)
|
2009-01-09 22:41:26 +00:00
|
|
|
{
|
2020-10-17 18:22:13 +00:00
|
|
|
if(m_HookedPlayer == -1 || distance(m_HookPos, pCharCore->m_Pos) < Distance)
|
|
|
|
{
|
|
|
|
m_TriggeredEvents |= COREEVENT_HOOK_ATTACH_PLAYER;
|
|
|
|
m_HookState = HOOK_GRABBED;
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(i);
|
2020-10-17 18:22:13 +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
|
|
|
|
2022-01-22 12:54:25 +00:00
|
|
|
if(GoingThroughTele && m_pWorld && m_pTeleOuts && !m_pTeleOuts->empty() && !(*m_pTeleOuts)[teleNr - 1].empty())
|
2013-07-18 22:27:17 +00:00
|
|
|
{
|
2013-07-18 23:23:48 +00:00
|
|
|
m_TriggeredEvents = 0;
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
2013-07-18 22:27:17 +00:00
|
|
|
|
|
|
|
m_NewHook = true;
|
2020-09-26 19:41:58 +00:00
|
|
|
int RandomOut = m_pWorld->RandomOr0((*m_pTeleOuts)[teleNr - 1].size());
|
2022-05-28 17:28:44 +00:00
|
|
|
m_HookPos = (*m_pTeleOuts)[teleNr - 1][RandomOut] + TargetDirection * PhysicalSize() * 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
|
|
|
{
|
2021-05-19 10:58:04 +00:00
|
|
|
if(m_HookedPlayer != -1 && m_pWorld)
|
2007-09-22 18:55:00 +00:00
|
|
|
{
|
2011-02-12 10:40:36 +00:00
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[m_HookedPlayer];
|
2020-10-10 21:46:01 +00:00
|
|
|
if(pCharCore && m_Id != -1 && 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
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
2010-05-29 07:25:38 +00:00
|
|
|
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)
|
2020-09-26 19:41:58 +00:00
|
|
|
//release_hooked();
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
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
|
|
|
{
|
2021-05-12 16:57:50 +00:00
|
|
|
vec2 HookVel = normalize(m_HookPos - m_Pos) * m_Tuning.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
|
|
|
|
2020-09-26 19:41:58 +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
|
2021-05-12 16:57:50 +00:00
|
|
|
if(length(NewVel) < m_Tuning.m_HookDragSpeed || length(NewVel) < length(m_Vel))
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Vel = NewVel; // no problem. apply
|
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++;
|
2021-05-19 10:58:04 +00:00
|
|
|
if(m_HookedPlayer != -1 && (m_HookTick > SERVER_TICK_SPEED + SERVER_TICK_SPEED / 5 || (m_pWorld && !m_pWorld->m_apCharacters[m_HookedPlayer])))
|
2007-12-09 15:56:56 +00:00
|
|
|
{
|
2022-05-22 19:40:15 +00:00
|
|
|
SetHookedPlayer(-1);
|
2010-05-29 07:25:38 +00:00
|
|
|
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
|
|
|
|
2022-07-19 16:34:49 +00:00
|
|
|
if(DoDeferredTick)
|
|
|
|
TickDeferred();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCharacterCore::TickDeferred()
|
|
|
|
{
|
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)
|
|
|
|
|
2019-04-21 12:57:45 +00:00
|
|
|
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
|
|
|
|
2019-04-21 12:57:45 +00:00
|
|
|
if(!(m_Super || pCharCore->m_Super) && (m_Solo || pCharCore->m_Solo))
|
|
|
|
continue;
|
|
|
|
|
2014-08-28 14:20:11 +00:00
|
|
|
// handle player <-> player collision
|
|
|
|
float Distance = distance(m_Pos, pCharCore->m_Pos);
|
2020-10-17 18:00:18 +00:00
|
|
|
if(Distance > 0)
|
|
|
|
{
|
|
|
|
vec2 Dir = normalize(m_Pos - pCharCore->m_Pos);
|
2019-04-21 12:57:45 +00:00
|
|
|
|
2022-07-08 13:31:58 +00:00
|
|
|
bool CanCollide = (m_Super || pCharCore->m_Super) || (!m_CollisionDisabled && !pCharCore->m_CollisionDisabled && m_Tuning.m_PlayerCollision);
|
2019-04-21 12:57:45 +00:00
|
|
|
|
2022-05-28 17:28:44 +00:00
|
|
|
if(CanCollide && Distance < PhysicalSize() * 1.25f && Distance > 0.0f)
|
2020-10-17 18:00:18 +00:00
|
|
|
{
|
2022-05-28 17:28:44 +00:00
|
|
|
float a = (PhysicalSize() * 1.45f - Distance);
|
2020-10-17 18:00:18 +00:00
|
|
|
float Velocity = 0.5f;
|
2014-08-27 12:14:32 +00:00
|
|
|
|
2020-10-17 18:00:18 +00:00
|
|
|
// make sure that we don't add excess force by checking the
|
|
|
|
// direction against the current velocity. if not zero.
|
2022-03-21 06:10:44 +00:00
|
|
|
if(length(m_Vel) > 0.0001f)
|
2022-03-23 17:30:18 +00:00
|
|
|
Velocity = 1 - (dot(normalize(m_Vel), Dir) + 1) / 2; // Wdouble-promotion don't fix this as this might change game physics
|
2014-08-28 14:20:11 +00:00
|
|
|
|
2020-10-17 18:00:18 +00:00
|
|
|
m_Vel += Dir * a * (Velocity * 0.75f);
|
|
|
|
m_Vel *= 0.85f;
|
|
|
|
}
|
2014-08-28 14:20:11 +00:00
|
|
|
|
2020-10-17 18:00:18 +00:00
|
|
|
// handle hook influence
|
2022-07-08 13:31:58 +00:00
|
|
|
if(!m_HookHitDisabled && m_HookedPlayer == i && m_Tuning.m_PlayerHooking)
|
2014-08-28 14:20:11 +00:00
|
|
|
{
|
2022-05-28 17:28:44 +00:00
|
|
|
if(Distance > PhysicalSize() * 1.50f) // TODO: fix tweakable variable
|
2020-10-17 18:00:18 +00:00
|
|
|
{
|
2022-03-20 11:57:50 +00:00
|
|
|
float HookAccel = m_Tuning.m_HookDragAccel * (Distance / m_Tuning.m_HookLength);
|
2021-05-12 16:57:50 +00:00
|
|
|
float DragSpeed = m_Tuning.m_HookDragSpeed;
|
2020-10-17 18:00:18 +00:00
|
|
|
|
|
|
|
vec2 Temp;
|
|
|
|
// add force to the hooked player
|
2022-03-20 11:57:50 +00:00
|
|
|
Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x, HookAccel * Dir.x * 1.5f);
|
|
|
|
Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y, HookAccel * Dir.y * 1.5f);
|
2020-10-17 18:00:18 +00:00
|
|
|
pCharCore->m_Vel = ClampVel(pCharCore->m_MoveRestrictions, Temp);
|
|
|
|
// add a little bit force to the guy who has the grip
|
2022-03-20 11:57:50 +00:00
|
|
|
Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -HookAccel * Dir.x * 0.25f);
|
|
|
|
Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -HookAccel * Dir.y * 0.25f);
|
2020-10-17 18:00:18 +00:00
|
|
|
m_Vel = ClampVel(m_MoveRestrictions, Temp);
|
|
|
|
}
|
2014-08-28 14:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
if(m_HookState != HOOK_FLYING)
|
2014-08-28 14:20:11 +00:00
|
|
|
{
|
|
|
|
m_NewHook = false;
|
|
|
|
}
|
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
|
|
|
{
|
2021-05-12 16:57:50 +00:00
|
|
|
float RampValue = VelocityRamp(length(m_Vel) * 50, m_Tuning.m_VelrampStart, m_Tuning.m_VelrampRange, m_Tuning.m_VelrampCurvature);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +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;
|
2022-05-28 17:28:44 +00:00
|
|
|
m_pCollision->MoveBox(&NewPos, &m_Vel, PhysicalSizeVec2(), 0);
|
2011-03-27 14:15:10 +00:00
|
|
|
|
2014-06-22 16:07:28 +00:00
|
|
|
m_Colliding = 0;
|
2019-07-08 21:08:42 +00:00
|
|
|
if(m_Vel.x < 0.001f && m_Vel.x > -0.001f)
|
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
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
m_Vel.x = m_Vel.x * (1.0f / RampValue);
|
2011-03-27 14:15:10 +00:00
|
|
|
|
2022-07-08 13:31:58 +00:00
|
|
|
if(m_pWorld && (m_Super || (m_Tuning.m_PlayerCollision && !m_CollisionDisabled && !m_Solo)))
|
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);
|
2020-10-17 16:45:59 +00:00
|
|
|
if(Distance > 0)
|
2011-04-09 06:41:31 +00:00
|
|
|
{
|
2020-10-17 16:45:59 +00:00
|
|
|
int End = Distance + 1;
|
|
|
|
vec2 LastPos = m_Pos;
|
|
|
|
for(int i = 0; i < End; i++)
|
2011-04-09 06:41:31 +00:00
|
|
|
{
|
2020-10-17 16:45:59 +00:00
|
|
|
float a = i / Distance;
|
|
|
|
vec2 Pos = mix(m_Pos, NewPos, a);
|
|
|
|
for(int p = 0; p < MAX_CLIENTS; p++)
|
2011-12-26 13:31:05 +00:00
|
|
|
{
|
2020-10-17 16:45:59 +00:00
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p];
|
|
|
|
if(!pCharCore || pCharCore == this)
|
|
|
|
continue;
|
2022-07-08 13:31:58 +00:00
|
|
|
if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || pCharCore->m_CollisionDisabled || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)))))
|
2020-10-17 16:45:59 +00:00
|
|
|
continue;
|
|
|
|
float D = distance(Pos, pCharCore->m_Pos);
|
2022-05-28 17:28:44 +00:00
|
|
|
if(D < PhysicalSize() && D >= 0.0f)
|
2020-10-17 16:45:59 +00:00
|
|
|
{
|
|
|
|
if(a > 0.0f)
|
|
|
|
m_Pos = LastPos;
|
|
|
|
else if(distance(NewPos, pCharCore->m_Pos) > D)
|
|
|
|
m_Pos = NewPos;
|
|
|
|
return;
|
|
|
|
}
|
2011-12-26 13:31:05 +00:00
|
|
|
}
|
2020-10-17 16:45:59 +00:00
|
|
|
LastPos = Pos;
|
2011-04-09 06:41:31 +00:00
|
|
|
}
|
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
|
|
|
|
2020-09-26 19:41:58 +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);
|
2020-09-26 19:41:58 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-07-08 19:27:28 +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;
|
2020-09-26 19:41:58 +00:00
|
|
|
m_Vel.x = pObjCore->m_VelX / 256.0f;
|
|
|
|
m_Vel.y = pObjCore->m_VelY / 256.0f;
|
2010-05-29 07:25:38 +00:00
|
|
|
m_HookState = pObjCore->m_HookState;
|
|
|
|
m_HookTick = pObjCore->m_HookTick;
|
|
|
|
m_HookPos.x = pObjCore->m_HookX;
|
|
|
|
m_HookPos.y = pObjCore->m_HookY;
|
2020-09-26 19:41:58 +00:00
|
|
|
m_HookDir.x = pObjCore->m_HookDx / 256.0f;
|
|
|
|
m_HookDir.y = pObjCore->m_HookDy / 256.0f;
|
2022-05-26 05:45:34 +00:00
|
|
|
SetHookedPlayer(pObjCore->m_HookedPlayer);
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Jumped = pObjCore->m_Jumped;
|
|
|
|
m_Direction = pObjCore->m_Direction;
|
|
|
|
m_Angle = pObjCore->m_Angle;
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-30 21:47:33 +00:00
|
|
|
void CCharacterCore::ReadDDNet(const CNetObj_DDNetCharacter *pObjDDNet)
|
|
|
|
{
|
|
|
|
// Collision
|
|
|
|
m_Solo = pObjDDNet->m_Flags & CHARACTERFLAG_SOLO;
|
2021-08-08 10:36:25 +00:00
|
|
|
m_Jetpack = pObjDDNet->m_Flags & CHARACTERFLAG_JETPACK;
|
2022-07-08 13:31:58 +00:00
|
|
|
m_CollisionDisabled = pObjDDNet->m_Flags & CHARACTERFLAG_COLLISION_DISABLED;
|
|
|
|
m_HammerHitDisabled = pObjDDNet->m_Flags & CHARACTERFLAG_HAMMER_HIT_DISABLED;
|
|
|
|
m_ShotgunHitDisabled = pObjDDNet->m_Flags & CHARACTERFLAG_SHOTGUN_HIT_DISABLED;
|
|
|
|
m_GrenadeHitDisabled = pObjDDNet->m_Flags & CHARACTERFLAG_GRENADE_HIT_DISABLED;
|
|
|
|
m_LaserHitDisabled = pObjDDNet->m_Flags & CHARACTERFLAG_LASER_HIT_DISABLED;
|
|
|
|
m_HookHitDisabled = pObjDDNet->m_Flags & CHARACTERFLAG_HOOK_HIT_DISABLED;
|
2019-06-30 21:47:33 +00:00
|
|
|
m_Super = pObjDDNet->m_Flags & CHARACTERFLAG_SUPER;
|
|
|
|
|
|
|
|
// Endless
|
2022-01-09 17:39:13 +00:00
|
|
|
m_EndlessHook = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_HOOK;
|
2019-06-30 21:47:33 +00:00
|
|
|
m_EndlessJump = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_JUMP;
|
|
|
|
|
|
|
|
// Freeze
|
|
|
|
m_FreezeEnd = pObjDDNet->m_FreezeEnd;
|
|
|
|
m_DeepFrozen = pObjDDNet->m_FreezeEnd == -1;
|
2022-07-08 13:31:58 +00:00
|
|
|
m_LiveFrozen = (pObjDDNet->m_Flags & CHARACTERFLAG_MOVEMENTS_DISABLED) != 0;
|
2019-06-30 21:47:33 +00:00
|
|
|
|
|
|
|
// Telegun
|
|
|
|
m_HasTelegunGrenade = pObjDDNet->m_Flags & CHARACTERFLAG_TELEGUN_GRENADE;
|
|
|
|
m_HasTelegunGun = pObjDDNet->m_Flags & CHARACTERFLAG_TELEGUN_GUN;
|
|
|
|
m_HasTelegunLaser = pObjDDNet->m_Flags & CHARACTERFLAG_TELEGUN_LASER;
|
|
|
|
|
2022-03-21 22:50:41 +00:00
|
|
|
// Weapons
|
|
|
|
m_aWeapons[WEAPON_HAMMER].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_HAMMER) != 0;
|
|
|
|
m_aWeapons[WEAPON_GUN].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_GUN) != 0;
|
|
|
|
m_aWeapons[WEAPON_SHOTGUN].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_SHOTGUN) != 0;
|
|
|
|
m_aWeapons[WEAPON_GRENADE].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_GRENADE) != 0;
|
|
|
|
m_aWeapons[WEAPON_LASER].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_LASER) != 0;
|
2022-03-24 00:05:41 +00:00
|
|
|
m_aWeapons[WEAPON_NINJA].m_Got = (pObjDDNet->m_Flags & CHARACTERFLAG_WEAPON_NINJA) != 0;
|
2022-03-21 22:50:41 +00:00
|
|
|
|
|
|
|
// Available jumps
|
2019-06-30 21:47:33 +00:00
|
|
|
m_Jumps = pObjDDNet->m_Jumps;
|
|
|
|
|
2022-05-24 15:26:49 +00:00
|
|
|
// Display Information
|
|
|
|
// We only accept the display information when it is received, which means it is not -1 in each case.
|
|
|
|
if(pObjDDNet->m_JumpedTotal != -1)
|
|
|
|
{
|
|
|
|
m_JumpedTotal = pObjDDNet->m_JumpedTotal;
|
|
|
|
}
|
|
|
|
if(pObjDDNet->m_NinjaActivationTick != -1)
|
|
|
|
{
|
|
|
|
m_Ninja.m_ActivationTick = pObjDDNet->m_NinjaActivationTick;
|
|
|
|
}
|
|
|
|
if(pObjDDNet->m_FreezeStart != -1)
|
|
|
|
{
|
|
|
|
m_FreezeStart = pObjDDNet->m_FreezeStart;
|
|
|
|
m_IsInFreeze = pObjDDNet->m_Flags & CHARACTERFLAG_IN_FREEZE;
|
|
|
|
}
|
2022-03-27 16:18:53 +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);
|
2022-07-08 19:27:28 +00:00
|
|
|
Read(&Core);
|
2007-09-22 18:55:00 +00:00
|
|
|
}
|
2011-01-06 03:46:10 +00:00
|
|
|
|
2022-05-22 19:40:15 +00:00
|
|
|
void CCharacterCore::SetHookedPlayer(int HookedPlayer)
|
|
|
|
{
|
|
|
|
if(HookedPlayer != m_HookedPlayer)
|
|
|
|
{
|
|
|
|
if(m_HookedPlayer != -1 && m_Id != -1 && m_pWorld)
|
|
|
|
{
|
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[m_HookedPlayer];
|
|
|
|
if(pCharCore)
|
|
|
|
{
|
|
|
|
pCharCore->m_AttachedPlayers.erase(m_Id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(HookedPlayer != -1 && m_Id != -1 && m_pWorld)
|
|
|
|
{
|
|
|
|
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[HookedPlayer];
|
|
|
|
if(pCharCore)
|
|
|
|
{
|
|
|
|
pCharCore->m_AttachedPlayers.insert(m_Id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_HookedPlayer = HookedPlayer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
// DDRace
|
2011-01-06 03:46:10 +00:00
|
|
|
|
2021-01-12 23:29:20 +00:00
|
|
|
void CCharacterCore::SetTeamsCore(CTeamsCore *pTeams)
|
|
|
|
{
|
|
|
|
m_pTeams = pTeams;
|
|
|
|
}
|
|
|
|
|
2021-01-12 23:12:08 +00:00
|
|
|
void CCharacterCore::SetTeleOuts(std::map<int, std::vector<vec2>> *pTeleOuts)
|
|
|
|
{
|
|
|
|
m_pTeleOuts = pTeleOuts;
|
|
|
|
}
|
|
|
|
|
2018-08-15 15:47:07 +00:00
|
|
|
bool CCharacterCore::IsSwitchActiveCb(int Number, void *pUser)
|
2011-01-06 03:46:10 +00:00
|
|
|
{
|
2018-08-15 15:47:07 +00:00
|
|
|
CCharacterCore *pThis = (CCharacterCore *)pUser;
|
2022-06-11 19:38:18 +00:00
|
|
|
if(pThis->m_pWorld && !pThis->m_pWorld->m_vSwitchers.empty())
|
2020-10-10 21:46:01 +00:00
|
|
|
if(pThis->m_Id != -1 && pThis->m_pTeams->Team(pThis->m_Id) != (pThis->m_pTeams->m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER))
|
2022-06-30 22:36:32 +00:00
|
|
|
return pThis->m_pWorld->m_vSwitchers[Number].m_aStatus[pThis->m_pTeams->Team(pThis->m_Id)];
|
2018-08-22 06:33:28 +00:00
|
|
|
return false;
|
2011-01-06 03:46:10 +00:00
|
|
|
}
|
2022-02-13 19:57:27 +00:00
|
|
|
|
2022-05-01 23:54:29 +00:00
|
|
|
void CWorldCore::InitSwitchers(int HighestSwitchNumber)
|
2022-02-13 19:57:27 +00:00
|
|
|
{
|
2022-05-01 23:54:29 +00:00
|
|
|
if(HighestSwitchNumber > 0)
|
2022-06-11 19:38:18 +00:00
|
|
|
m_vSwitchers.resize(HighestSwitchNumber + 1);
|
2022-05-01 23:54:29 +00:00
|
|
|
else
|
2022-06-11 19:38:18 +00:00
|
|
|
m_vSwitchers.clear();
|
2022-02-13 19:57:27 +00:00
|
|
|
|
2022-06-11 19:38:18 +00:00
|
|
|
for(auto &Switcher : m_vSwitchers)
|
2022-02-13 19:57:27 +00:00
|
|
|
{
|
2022-05-01 23:54:29 +00:00
|
|
|
Switcher.m_Initial = true;
|
2022-02-13 19:57:27 +00:00
|
|
|
for(int j = 0; j < MAX_CLIENTS; j++)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
Switcher.m_aStatus[j] = true;
|
|
|
|
Switcher.m_aEndTick[j] = 0;
|
|
|
|
Switcher.m_aType[j] = 0;
|
|
|
|
Switcher.m_aLastUpdateTick[j] = 0;
|
2022-02-13 19:57:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|