fix swap does not swap no collision and no hook

- remove duplicated variable for no collision and no hook
This commit is contained in:
c0d3d3v 2022-05-30 19:33:42 +02:00
parent cfdb97a422
commit 5065bab8b5
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
5 changed files with 27 additions and 38 deletions

View file

@ -829,23 +829,23 @@ void CCharacter::HandleTiles(int Index)
} }
// collide with others // collide with others
if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && m_Core.m_Collision) if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && !m_Core.m_NoCollision)
{ {
m_Core.m_Collision = false; m_Core.m_NoCollision = true;
} }
else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && !m_Core.m_Collision) else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && m_Core.m_NoCollision)
{ {
m_Core.m_Collision = true; m_Core.m_NoCollision = false;
} }
// hook others // hook others
if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && m_Core.m_Hook) if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && !m_Core.m_NoHookHit)
{ {
m_Core.m_Hook = false; m_Core.m_NoHookHit = true;
} }
else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && !m_Core.m_Hook) else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && m_Core.m_NoHookHit)
{ {
m_Core.m_Hook = true; m_Core.m_NoHookHit = false;
} }
// unlimited air jumps // unlimited air jumps
@ -1131,8 +1131,8 @@ void CCharacter::ResetPrediction()
m_Jetpack = false; m_Jetpack = false;
m_NinjaJetpack = false; m_NinjaJetpack = false;
m_Core.m_Jumps = 2; m_Core.m_Jumps = 2;
m_Core.m_Hook = true; m_Core.m_NoHookHit = false;
m_Core.m_Collision = true; m_Core.m_NoCollision = false;
m_NumInputs = 0; m_NumInputs = 0;
m_FreezeTime = 0; m_FreezeTime = 0;
m_Core.m_FreezeTick = 0; m_Core.m_FreezeTick = 0;
@ -1268,8 +1268,8 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende
// set player collision // set player collision
SetSolo(!Tuning()->m_PlayerCollision && !Tuning()->m_PlayerHooking); SetSolo(!Tuning()->m_PlayerCollision && !Tuning()->m_PlayerHooking);
m_Core.m_Collision = Tuning()->m_PlayerCollision; m_Core.m_NoCollision = !Tuning()->m_PlayerCollision;
m_Core.m_Hook = Tuning()->m_PlayerHooking; m_Core.m_NoHookHit = !Tuning()->m_PlayerHooking;
if(m_Core.m_HookTick != 0) if(m_Core.m_HookTick != 0)
m_EndlessHook = false; m_EndlessHook = false;

View file

@ -86,8 +86,6 @@ void CCharacterCore::Reset()
m_JumpedTotal = 0; m_JumpedTotal = 0;
m_Jumps = 2; m_Jumps = 2;
m_TriggeredEvents = 0; m_TriggeredEvents = 0;
m_Hook = true;
m_Collision = true;
// DDNet Character // DDNet Character
m_Solo = false; m_Solo = false;
@ -275,7 +273,7 @@ void CCharacterCore::Tick(bool UseInput)
} }
// Check against other players first // Check against other players first
if(this->m_Hook && m_pWorld && m_Tuning.m_PlayerHooking) if(!this->m_NoHookHit && m_pWorld && m_Tuning.m_PlayerHooking)
{ {
float Distance = 0.0f; float Distance = 0.0f;
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
@ -409,7 +407,7 @@ void CCharacterCore::Tick(bool UseInput)
{ {
vec2 Dir = normalize(m_Pos - pCharCore->m_Pos); vec2 Dir = normalize(m_Pos - pCharCore->m_Pos);
bool CanCollide = (m_Super || pCharCore->m_Super) || (pCharCore->m_Collision && m_Collision && !m_NoCollision && !pCharCore->m_NoCollision && m_Tuning.m_PlayerCollision); bool CanCollide = (m_Super || pCharCore->m_Super) || (!m_NoCollision && !pCharCore->m_NoCollision && m_Tuning.m_PlayerCollision);
if(CanCollide && Distance < PhysicalSize() * 1.25f && Distance > 0.0f) if(CanCollide && Distance < PhysicalSize() * 1.25f && Distance > 0.0f)
{ {
@ -426,7 +424,7 @@ void CCharacterCore::Tick(bool UseInput)
} }
// handle hook influence // handle hook influence
if(m_Hook && m_HookedPlayer == i && m_Tuning.m_PlayerHooking) if(!m_NoHookHit && m_HookedPlayer == i && m_Tuning.m_PlayerHooking)
{ {
if(Distance > PhysicalSize() * 1.50f) // TODO: fix tweakable variable if(Distance > PhysicalSize() * 1.50f) // TODO: fix tweakable variable
{ {
@ -482,7 +480,7 @@ void CCharacterCore::Move()
m_Vel.x = m_Vel.x * (1.0f / RampValue); m_Vel.x = m_Vel.x * (1.0f / RampValue);
if(m_pWorld && (m_Super || (m_Tuning.m_PlayerCollision && m_Collision && !m_NoCollision && !m_Solo))) if(m_pWorld && (m_Super || (m_Tuning.m_PlayerCollision && !m_NoCollision && !m_Solo)))
{ {
// check player collision // check player collision
float Distance = distance(m_Pos, NewPos); float Distance = distance(m_Pos, NewPos);
@ -499,7 +497,7 @@ void CCharacterCore::Move()
CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p]; CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p];
if(!pCharCore || pCharCore == this) if(!pCharCore || pCharCore == this)
continue; continue;
if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || !pCharCore->m_Collision || pCharCore->m_NoCollision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p))))) if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || pCharCore->m_NoCollision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)))))
continue; continue;
float D = distance(Pos, pCharCore->m_Pos); float D = distance(Pos, pCharCore->m_Pos);
if(D < PhysicalSize() && D >= 0.0f) if(D < PhysicalSize() && D >= 0.0f)
@ -574,9 +572,6 @@ void CCharacterCore::ReadDDNet(const CNetObj_DDNetCharacter *pObjDDNet)
m_NoHookHit = pObjDDNet->m_Flags & CHARACTERFLAG_NO_HOOK; m_NoHookHit = pObjDDNet->m_Flags & CHARACTERFLAG_NO_HOOK;
m_Super = pObjDDNet->m_Flags & CHARACTERFLAG_SUPER; m_Super = pObjDDNet->m_Flags & CHARACTERFLAG_SUPER;
m_Hook = !m_NoHookHit;
m_Collision = !m_NoCollision;
// Endless // Endless
m_EndlessHook = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_HOOK; m_EndlessHook = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_HOOK;
m_EndlessJump = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_JUMP; m_EndlessJump = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_JUMP;

View file

@ -212,8 +212,6 @@ public:
static constexpr vec2 PhysicalSizeVec2() { return vec2(28.0f, 28.0f); }; static constexpr vec2 PhysicalSizeVec2() { return vec2(28.0f, 28.0f); };
vec2 m_Pos; vec2 m_Pos;
vec2 m_Vel; vec2 m_Vel;
bool m_Hook;
bool m_Collision;
vec2 m_HookPos; vec2 m_HookPos;
vec2 m_HookDir; vec2 m_HookDir;

View file

@ -1231,9 +1231,9 @@ void CCharacter::Snap(int SnappingClient)
pDDNetCharacter->m_Flags |= CHARACTERFLAG_SUPER; pDDNetCharacter->m_Flags |= CHARACTERFLAG_SUPER;
if(m_EndlessHook) if(m_EndlessHook)
pDDNetCharacter->m_Flags |= CHARACTERFLAG_ENDLESS_HOOK; pDDNetCharacter->m_Flags |= CHARACTERFLAG_ENDLESS_HOOK;
if(!m_Core.m_Collision || !GameServer()->Tuning()->m_PlayerCollision) if(m_Core.m_NoCollision || !GameServer()->Tuning()->m_PlayerCollision)
pDDNetCharacter->m_Flags |= CHARACTERFLAG_NO_COLLISION; pDDNetCharacter->m_Flags |= CHARACTERFLAG_NO_COLLISION;
if(!m_Core.m_Hook || !GameServer()->Tuning()->m_PlayerHooking) if(m_Core.m_NoHookHit || !GameServer()->Tuning()->m_PlayerHooking)
pDDNetCharacter->m_Flags |= CHARACTERFLAG_NO_HOOK; pDDNetCharacter->m_Flags |= CHARACTERFLAG_NO_HOOK;
if(m_SuperJump) if(m_SuperJump)
pDDNetCharacter->m_Flags |= CHARACTERFLAG_ENDLESS_JUMP; pDDNetCharacter->m_Flags |= CHARACTERFLAG_ENDLESS_JUMP;
@ -1577,36 +1577,32 @@ void CCharacter::HandleTiles(int Index)
} }
// collide with others // collide with others
if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && m_Core.m_Collision) if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && !m_Core.m_NoCollision)
{ {
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't collide with others"); GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't collide with others");
m_Core.m_Collision = false;
m_Core.m_NoCollision = true; m_Core.m_NoCollision = true;
m_NeededFaketuning |= FAKETUNE_NOCOLL; m_NeededFaketuning |= FAKETUNE_NOCOLL;
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings
} }
else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && !m_Core.m_Collision) else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && m_Core.m_NoCollision)
{ {
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can collide with others"); GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can collide with others");
m_Core.m_Collision = true;
m_Core.m_NoCollision = false; m_Core.m_NoCollision = false;
m_NeededFaketuning &= ~FAKETUNE_NOCOLL; m_NeededFaketuning &= ~FAKETUNE_NOCOLL;
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings
} }
// hook others // hook others
if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && m_Core.m_Hook) if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && !m_Core.m_NoHookHit)
{ {
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't hook others"); GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't hook others");
m_Core.m_Hook = false;
m_Core.m_NoHookHit = true; m_Core.m_NoHookHit = true;
m_NeededFaketuning |= FAKETUNE_NOHOOK; m_NeededFaketuning |= FAKETUNE_NOHOOK;
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings
} }
else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && !m_Core.m_Hook) else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && m_Core.m_NoHookHit)
{ {
GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can hook others"); GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can hook others");
m_Core.m_Hook = true;
m_Core.m_NoHookHit = false; m_Core.m_NoHookHit = false;
m_NeededFaketuning &= ~FAKETUNE_NOHOOK; m_NeededFaketuning &= ~FAKETUNE_NOHOOK;
GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings

View file

@ -77,8 +77,8 @@ void CSaveTee::Save(CCharacter *pChr)
// Core // Core
m_CorePos = pChr->m_Core.m_Pos; m_CorePos = pChr->m_Core.m_Pos;
m_Vel = pChr->m_Core.m_Vel; m_Vel = pChr->m_Core.m_Vel;
m_Hook = pChr->m_Core.m_Hook; m_Hook = !pChr->m_Core.m_NoHookHit;
m_Collision = pChr->m_Core.m_Collision; m_Collision = !pChr->m_Core.m_NoCollision;
m_ActiveWeapon = pChr->m_Core.m_ActiveWeapon; m_ActiveWeapon = pChr->m_Core.m_ActiveWeapon;
m_Jumped = pChr->m_Core.m_Jumped; m_Jumped = pChr->m_Core.m_Jumped;
m_JumpedTotal = pChr->m_Core.m_JumpedTotal; m_JumpedTotal = pChr->m_Core.m_JumpedTotal;
@ -170,8 +170,8 @@ void CSaveTee::Load(CCharacter *pChr, int Team, bool IsSwap)
// Core // Core
pChr->m_Core.m_Pos = m_CorePos; pChr->m_Core.m_Pos = m_CorePos;
pChr->m_Core.m_Vel = m_Vel; pChr->m_Core.m_Vel = m_Vel;
pChr->m_Core.m_Hook = m_Hook; pChr->m_Core.m_NoHookHit = !m_Hook;
pChr->m_Core.m_Collision = m_Collision; pChr->m_Core.m_NoCollision = !m_Collision;
pChr->m_Core.m_ActiveWeapon = m_ActiveWeapon; pChr->m_Core.m_ActiveWeapon = m_ActiveWeapon;
pChr->m_Core.m_Jumped = m_Jumped; pChr->m_Core.m_Jumped = m_Jumped;
pChr->m_Core.m_JumpedTotal = m_JumpedTotal; pChr->m_Core.m_JumpedTotal = m_JumpedTotal;