mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Revert "Same hook strength for everyone (by cinaera)"
This reverts commit 2b08464527
.
This commit is contained in:
parent
e213ea27b4
commit
b3e9041768
|
@ -518,7 +518,6 @@ static void Evolve(CNetObj_Character *pCharacter, int Tick)
|
|||
{
|
||||
pCharacter->m_Tick++;
|
||||
TempCore.Tick(false, true);
|
||||
TempCore.PostTick();
|
||||
TempCore.Move();
|
||||
TempCore.Quantize();
|
||||
}
|
||||
|
@ -1198,7 +1197,6 @@ void CGameClient::OnPredict()
|
|||
if(!World.m_apCharacters[c])
|
||||
continue;
|
||||
|
||||
World.m_apCharacters[c]->PostTick();
|
||||
World.m_apCharacters[c]->Move();
|
||||
World.m_apCharacters[c]->Quantize();
|
||||
}
|
||||
|
|
|
@ -89,7 +89,6 @@ void CCharacterCore::Reset()
|
|||
{
|
||||
m_Pos = vec2(0,0);
|
||||
m_Vel = vec2(0,0);
|
||||
m_VelDiff = vec2(0,0);
|
||||
m_NewHook = false;
|
||||
m_HookPos = vec2(0,0);
|
||||
m_HookDir = vec2(0,0);
|
||||
|
@ -226,9 +225,9 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
|
|||
|
||||
// add the speed modification according to players wanted direction
|
||||
if(m_Direction < 0)
|
||||
m_Vel.x += SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, -Accel);
|
||||
m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, -Accel);
|
||||
if(m_Direction > 0)
|
||||
m_Vel.x += SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, Accel);
|
||||
m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, Accel);
|
||||
if(m_Direction == 0)
|
||||
m_Vel.x *= Friction;
|
||||
|
||||
|
@ -439,9 +438,9 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
|
|||
float DragSpeed = m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragSpeed;
|
||||
|
||||
// add force to the hooked player
|
||||
vec2 Temp = pCharCore->m_VelDiff;
|
||||
Temp.x += SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x + pCharCore->m_VelDiff.x, Accel*Dir.x*1.5f);
|
||||
Temp.y += SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y + pCharCore->m_VelDiff.y, Accel*Dir.y*1.5f);
|
||||
vec2 Temp = pCharCore->m_Vel;
|
||||
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);
|
||||
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)))
|
||||
|
@ -451,11 +450,19 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
|
|||
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;
|
||||
|
||||
pCharCore->m_VelDiff = Temp;
|
||||
|
||||
// add a little bit force to the guy who has the grip
|
||||
m_Vel.x += SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -Accel*Dir.x*0.25f);
|
||||
m_Vel.y += SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -Accel*Dir.y*0.25f);
|
||||
pCharCore->m_Vel = Temp;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -580,14 +587,6 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
|
|||
m_Vel = normalize(m_Vel) * 6000;
|
||||
}
|
||||
|
||||
void CCharacterCore::PostTick()
|
||||
{
|
||||
// apply velocity difference caused by external forces AFTER the tick
|
||||
// to prevent errors in physics calculation (e.g different hook strengths)
|
||||
m_Vel += m_VelDiff;
|
||||
m_VelDiff = vec2(0,0);
|
||||
}
|
||||
|
||||
void CCharacterCore::Move()
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -120,30 +120,27 @@ inline vec2 CalcPos(vec2 Pos, vec2 Velocity, float Curvature, float Speed, float
|
|||
return n;
|
||||
}
|
||||
|
||||
// Saturated adds Modifier on Current
|
||||
// Returns the difference between new and old value
|
||||
|
||||
template<typename T>
|
||||
inline T SaturatedAdd(T Min, T Max, T Current, T Modifier)
|
||||
{
|
||||
T Old = Current;
|
||||
|
||||
if(Modifier < 0)
|
||||
{
|
||||
if(Current < Min)
|
||||
return Current - Old;
|
||||
return Current;
|
||||
Current += Modifier;
|
||||
if(Current < Min)
|
||||
Current = Min;
|
||||
return Current - Old;
|
||||
return Current;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Current > Max)
|
||||
return Current - Old;
|
||||
return Current;
|
||||
Current += Modifier;
|
||||
if(Current > Max)
|
||||
Current = Max;
|
||||
return Current - Old;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,7 +188,6 @@ class CCharacterCore
|
|||
public:
|
||||
vec2 m_Pos;
|
||||
vec2 m_Vel;
|
||||
vec2 m_VelDiff; // caused by external forces, applied on posttick
|
||||
bool m_Hook;
|
||||
bool m_Collision;
|
||||
|
||||
|
@ -221,8 +217,6 @@ public:
|
|||
void Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore* pTeams, std::map<int, std::vector<vec2> > *pTeleOuts);
|
||||
void Reset();
|
||||
void Tick(bool UseInput, bool IsClient);
|
||||
void PostTick();
|
||||
void PostTick(bool IsClient);
|
||||
void Move();
|
||||
|
||||
void Read(const CNetObj_CharacterCore *pObjCore);
|
||||
|
|
|
@ -756,13 +756,11 @@ void CCharacter::TickDefered()
|
|||
m_ReckoningCore.Init(&TempWorld, GameServer()->Collision(), &((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.m_Core, &((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts);
|
||||
m_ReckoningCore.m_Id = m_pPlayer->GetCID();
|
||||
m_ReckoningCore.Tick(false, false);
|
||||
m_ReckoningCore.PostTick();
|
||||
m_ReckoningCore.Move();
|
||||
m_ReckoningCore.Quantize();
|
||||
}
|
||||
|
||||
//lastsentcore
|
||||
m_Core.PostTick();
|
||||
vec2 StartPos = m_Core.m_Pos;
|
||||
vec2 StartVel = m_Core.m_Vel;
|
||||
bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
|
||||
|
|
Loading…
Reference in a new issue