From 604d0eef409d296969919ff80ec0ec12f0c52c26 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Thu, 8 Dec 2022 20:05:41 +0300 Subject: [PATCH 1/9] Init --- regamedll/dlls/triggers.cpp | 21 +++++++++++++++++++ regamedll/dlls/triggers.h | 7 +++++++ regamedll/public/regamedll/API/CSInterfaces.h | 1 + 3 files changed, 29 insertions(+) diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index f454806ce..34a3e1921 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -1814,6 +1814,27 @@ void CTriggerTeleport::Spawn() SetTouch(&CTriggerTeleport::TeleportTouch); } +LINK_ENTITY_TO_CLASS(trigger_bomb_reset, CTriggerBombReset, CCSTriggerBombReset) + +void CTriggerBombReset::Spawn() +{ + InitTrigger(); + SetTouch(&CTriggerBombReset::Touch); +} + +void CTriggerBombReset::Touch(CBaseEntity *pOther) +{ + CWeaponBox *pWeaponBox = static_cast(pOther); + + if (pWeaponBox && !pWeaponBox->m_bIsBomb) + { + return; + } + + // If the bomb touches this trigger, tell it to reset to its last known valid position. + // TODO... +} + LINK_ENTITY_TO_CLASS(info_teleport_destination, CPointEntity, CCSPointEntity) LINK_ENTITY_TO_CLASS(func_buyzone, CBuyZone, CCSBuyZone) diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index c16f969c8..b1fd0633d 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -395,6 +395,13 @@ class CTriggerTeleport: public CBaseTrigger virtual void Spawn(); }; +class CTriggerBombReset: public CBaseTrigger +{ +public: + virtual void Spawn(); + virtual void Touch(CBaseEntity *pOther); +}; + class CBuyZone: public CBaseTrigger { public: diff --git a/regamedll/public/regamedll/API/CSInterfaces.h b/regamedll/public/regamedll/API/CSInterfaces.h index 98e9ea145..41d16ecec 100644 --- a/regamedll/public/regamedll/API/CSInterfaces.h +++ b/regamedll/public/regamedll/API/CSInterfaces.h @@ -213,6 +213,7 @@ class CCSChangeLevel: public CCSTrigger {}; class CCSLadder: public CCSTrigger {}; class CCSTriggerPush: public CCSTrigger {}; class CCSTriggerTeleport: public CCSTrigger {}; +class CCSTriggerBombReset: public CCSTrigger {}; class CCSBuyZone: public CCSTrigger {}; class CCSBombTarget: public CCSTrigger {}; class CCSHostageRescue: public CCSTrigger {}; From b6499d3c609c558037fe2be743b20a986d058a70 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Fri, 9 Dec 2022 17:12:12 +0300 Subject: [PATCH 2/9] Implementation --- regamedll/dlls/player.cpp | 1 + regamedll/dlls/triggers.cpp | 10 ++++------ regamedll/dlls/weapons.cpp | 18 ++++++++++++++++++ regamedll/dlls/weapons.h | 12 ++++++++++++ regamedll/dlls/wpn_shared/wpn_c4.cpp | 28 ++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 7c0b62e19..8e13da29a 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8030,6 +8030,7 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte pWeaponBox->m_bIsBomb = true; pWeaponBox->SetThink(&CWeaponBox::BombThink); pWeaponBox->pev->nextthink = gpGlobals->time + 1.0f; + pWeaponBox->SetLastValidHeldPosition(((CC4 *)pWeapon)->GetLastValidHeldPosition()); if (TheCSBots()) { diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index 34a3e1921..96ef8e7d7 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -1824,15 +1824,13 @@ void CTriggerBombReset::Spawn() void CTriggerBombReset::Touch(CBaseEntity *pOther) { - CWeaponBox *pWeaponBox = static_cast(pOther); + CWeaponBox *pWeaponBox = dynamic_cast(pOther); - if (pWeaponBox && !pWeaponBox->m_bIsBomb) + if (pWeaponBox && pWeaponBox->m_bIsBomb) { - return; + // If the bomb touches this trigger, tell it to reset to its last known valid position. + pWeaponBox->ResetToLastValidPlayerHeldPosition(); } - - // If the bomb touches this trigger, tell it to reset to its last known valid position. - // TODO... } LINK_ENTITY_TO_CLASS(info_teleport_destination, CPointEntity, CCSPointEntity) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 22d61fc9f..19c42e9ca 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -2179,6 +2179,24 @@ void CWeaponBox::SetObjectCollisionBox() pev->absmax = pev->origin + Vector(16, 16, 16); } +void CWeaponBox::ResetToLastValidPlayerHeldPosition() +{ + if (pev->origin == m_vecLastValidPlayerHeldPosition) + { + return; + } + + Vector const vecResetPos = m_vecLastValidPlayerHeldPosition + Vector(0.0f, 0.0f, 8.0f); + Vector const angResetAng = Vector(0.0f, RANDOM_FLOAT(0.0f, 360.0f), 0.0f); + + // Teleport + pev->velocity = Vector(0.0f, 0.0f, 0.0f); + pev->movetype = MOVETYPE_NONE; + pev->flags |= FL_ONGROUND; + pev->angles = angResetAng; + UTIL_SetOrigin(pev, vecResetPos); +} + char *CArmoury::m_ItemModels[] = { "models/w_mp5.mdl", "models/w_tmp.mdl", diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index bd22989e3..6ae938be4 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -483,6 +483,9 @@ class CWeaponBox: public CBaseEntity void SetModel_OrigFunc(const char *pszModelName); #endif + void SetLastValidHeldPosition(const Vector &vecPositon) { m_vecLastValidPlayerHeldPosition = vecPositon; } + void ResetToLastValidPlayerHeldPosition(); + public: static TYPEDESCRIPTION m_SaveData[]; @@ -491,6 +494,9 @@ class CWeaponBox: public CBaseEntity int m_rgAmmo[MAX_AMMO_SLOTS]; int m_cAmmoTypes; bool m_bIsBomb; + +private: + Vector m_vecLastValidPlayerHeldPosition; }; @@ -843,6 +849,7 @@ class CAWP: public CBasePlayerWeapon const float C4_MAX_SPEED = 250.0f; const float C4_ARMING_ON_TIME = 3.0f; +constexpr float WEAPON_C4_UPDATE_LAST_VALID_PLAYER_HELD_POSITION_INTERVAL = 0.2f; enum c4_e { @@ -862,6 +869,8 @@ class CC4: public CBasePlayerWeapon virtual int GetItemInfo(ItemInfo *p); virtual BOOL Deploy(); virtual void Holster(int skiplocal); + virtual void AttachToPlayer(CBasePlayer* pPlayer); + virtual void Think(); virtual float GetMaxSpeed(); virtual int iItemSlot() { return C4_SLOT; } virtual void PrimaryAttack(); @@ -875,6 +884,8 @@ class CC4: public CBasePlayerWeapon #endif } + Vector GetLastValidHeldPosition() const { return m_vecLastValidPlayerHeldPosition; } + public: bool m_bStartedArming; bool m_bBombPlacedAnimation; @@ -882,6 +893,7 @@ class CC4: public CBasePlayerWeapon private: bool m_bHasShield; + Vector m_vecLastValidPlayerHeldPosition; }; diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index f5c52b01a..e4dfa5bf3 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -382,3 +382,31 @@ float CC4::GetMaxSpeed() return C4_MAX_SPEED; } + +void CC4::AttachToPlayer(CBasePlayer* pPlayer) +{ + CBasePlayerWeapon::AttachToPlayer(pPlayer); + +#ifdef REGAMEDLL_ADD + SetThink(&CC4::Think); + pev->nextthink = gpGlobals->time + WEAPON_C4_UPDATE_LAST_VALID_PLAYER_HELD_POSITION_INTERVAL; +#endif +} + +void CC4::Think() +{ +#ifdef REGAMEDLL_ADD + pev->nextthink = gpGlobals->time + WEAPON_C4_UPDATE_LAST_VALID_PLAYER_HELD_POSITION_INTERVAL; + + // If the bomb is held by an alive player standing on the ground, then we can use this + // position as the last known valid position to respawn the bomb if it gets reset. + + if (m_pPlayer && m_pPlayer->IsPlayer() && m_pPlayer->IsAlive() && (m_pPlayer->pev->flags & FL_ONGROUND)) + { + entvars_t* pevPlayer = m_pPlayer->pev; + m_vecLastValidPlayerHeldPosition = pevPlayer->origin + pevPlayer->mins; + } +#else + CBasePlayerWeapon::Think(); +#endif +} From d9d11fb835d8c33cc625c0d917e721d77a033fff Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Fri, 9 Dec 2022 18:16:40 +0300 Subject: [PATCH 3/9] Add `trigger_bomb_reset` to `.fgd` --- regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd index 0e6838732..f9bf99a52 100644 --- a/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd +++ b/regamedll/extra/Toolkit/GameDefinitionFile/regamedll-cs.fgd @@ -2272,6 +2272,10 @@ ] ] +@SolidClass base(Trigger) = trigger_bomb_reset : "Trigger bomb reset" +[ +] + // Function entities @SolidClass = func_bomb_target : "Bomb target zone" [ From 38b1b6d47e2375278f67fffe9e5f00ca8aa2ad95 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Sat, 10 Dec 2022 01:18:27 +0300 Subject: [PATCH 4/9] Set CC4 position on CC4::AttachToPlayer() --- regamedll/dlls/wpn_shared/wpn_c4.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index e4dfa5bf3..87b49a304 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -390,6 +390,12 @@ void CC4::AttachToPlayer(CBasePlayer* pPlayer) #ifdef REGAMEDLL_ADD SetThink(&CC4::Think); pev->nextthink = gpGlobals->time + WEAPON_C4_UPDATE_LAST_VALID_PLAYER_HELD_POSITION_INTERVAL; + + if (pPlayer->IsPlayer() && pPlayer->IsAlive()) + { + entvars_t* pevPlayer = pPlayer->pev; + m_vecLastValidPlayerHeldPosition = pevPlayer->origin + pevPlayer->mins; + } #endif } From 95130844394f8517590f04d62004f2af5d1fe5dc Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Tue, 13 Dec 2022 17:33:55 +0300 Subject: [PATCH 5/9] move to `addons/trigger_bomb_reset` --- regamedll/CMakeLists.txt | 1 + regamedll/dlls/addons/trigger_bomb_reset.cpp | 38 ++++++++++++++++++++ regamedll/dlls/addons/trigger_bomb_reset.h | 28 +++++++++++++++ regamedll/dlls/triggers.cpp | 19 ---------- regamedll/dlls/triggers.h | 7 ---- regamedll/msvc/ReGameDLL.vcxproj | 4 ++- regamedll/msvc/ReGameDLL.vcxproj.filters | 8 ++++- regamedll/regamedll/dlls.h | 1 + 8 files changed, 78 insertions(+), 28 deletions(-) create mode 100644 regamedll/dlls/addons/trigger_bomb_reset.cpp create mode 100644 regamedll/dlls/addons/trigger_bomb_reset.h diff --git a/regamedll/CMakeLists.txt b/regamedll/CMakeLists.txt index 1b329ca95..8e78fa6bb 100644 --- a/regamedll/CMakeLists.txt +++ b/regamedll/CMakeLists.txt @@ -228,6 +228,7 @@ set(GAMEDLL_SRCS "dlls/API/CSPlayerItem.cpp" "dlls/addons/item_airbox.cpp" "dlls/addons/point_command.cpp" + "dlls/addons/trigger_bomb_reset.cpp" "dlls/addons/trigger_random.cpp" "dlls/addons/trigger_setorigin.cpp" "dlls/wpn_shared/wpn_ak47.cpp" diff --git a/regamedll/dlls/addons/trigger_bomb_reset.cpp b/regamedll/dlls/addons/trigger_bomb_reset.cpp new file mode 100644 index 000000000..999fc6595 --- /dev/null +++ b/regamedll/dlls/addons/trigger_bomb_reset.cpp @@ -0,0 +1,38 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/ + +#include "precompiled.h" + +LINK_ENTITY_TO_CLASS(trigger_bomb_reset, CTriggerBombReset, CCSTriggerBombReset) + +void CTriggerBombReset::Spawn() +{ + InitTrigger(); + SetTouch(&CTriggerBombReset::Touch); +} + +void CTriggerBombReset::Touch(CBaseEntity *pOther) +{ + CWeaponBox *pWeaponBox = dynamic_cast(pOther); + + if (pWeaponBox && pWeaponBox->m_bIsBomb) + { + // If the bomb touches this trigger, tell it to reset to its last known valid position. + pWeaponBox->ResetToLastValidPlayerHeldPosition(); + } +} diff --git a/regamedll/dlls/addons/trigger_bomb_reset.h b/regamedll/dlls/addons/trigger_bomb_reset.h new file mode 100644 index 000000000..60e21bfcf --- /dev/null +++ b/regamedll/dlls/addons/trigger_bomb_reset.h @@ -0,0 +1,28 @@ +/* +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at +* your option) any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +*/ + +#pragma once + +#include "triggers.h" + +class CTriggerBombReset: public CBaseTrigger +{ +public: + virtual void Spawn(); + virtual void Touch(CBaseEntity *pOther); +}; diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index 96ef8e7d7..f454806ce 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -1814,25 +1814,6 @@ void CTriggerTeleport::Spawn() SetTouch(&CTriggerTeleport::TeleportTouch); } -LINK_ENTITY_TO_CLASS(trigger_bomb_reset, CTriggerBombReset, CCSTriggerBombReset) - -void CTriggerBombReset::Spawn() -{ - InitTrigger(); - SetTouch(&CTriggerBombReset::Touch); -} - -void CTriggerBombReset::Touch(CBaseEntity *pOther) -{ - CWeaponBox *pWeaponBox = dynamic_cast(pOther); - - if (pWeaponBox && pWeaponBox->m_bIsBomb) - { - // If the bomb touches this trigger, tell it to reset to its last known valid position. - pWeaponBox->ResetToLastValidPlayerHeldPosition(); - } -} - LINK_ENTITY_TO_CLASS(info_teleport_destination, CPointEntity, CCSPointEntity) LINK_ENTITY_TO_CLASS(func_buyzone, CBuyZone, CCSBuyZone) diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index b1fd0633d..c16f969c8 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -395,13 +395,6 @@ class CTriggerTeleport: public CBaseTrigger virtual void Spawn(); }; -class CTriggerBombReset: public CBaseTrigger -{ -public: - virtual void Spawn(); - virtual void Touch(CBaseEntity *pOther); -}; - class CBuyZone: public CBaseTrigger { public: diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj index 3e882d9e6..0f6646af5 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj +++ b/regamedll/msvc/ReGameDLL.vcxproj @@ -1,4 +1,4 @@ - + @@ -25,6 +25,7 @@ + @@ -616,6 +617,7 @@ + diff --git a/regamedll/msvc/ReGameDLL.vcxproj.filters b/regamedll/msvc/ReGameDLL.vcxproj.filters index d8c27981d..7f1692dd5 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj.filters +++ b/regamedll/msvc/ReGameDLL.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -549,6 +549,9 @@ dlls\addons + + dlls\addons + public @@ -1049,5 +1052,8 @@ dlls\addons + + dlls\addons + \ No newline at end of file diff --git a/regamedll/regamedll/dlls.h b/regamedll/regamedll/dlls.h index 2bef63d6d..51f4a2e4d 100644 --- a/regamedll/regamedll/dlls.h +++ b/regamedll/regamedll/dlls.h @@ -134,6 +134,7 @@ using FloatRef = float; #include "addons/trigger_setorigin.h" #include "addons/trigger_random.h" #include "addons/point_command.h" +#include "addons/trigger_bomb_reset.h" // Tutor #include "tutor.h" From 28e6782c03c643bd80b0294d1102759744bf99e7 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Thu, 15 Dec 2022 16:39:22 +0300 Subject: [PATCH 6/9] rename method & member --- regamedll/dlls/addons/trigger_bomb_reset.cpp | 2 +- regamedll/dlls/player.cpp | 2 +- regamedll/dlls/weapons.cpp | 6 +++--- regamedll/dlls/weapons.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/regamedll/dlls/addons/trigger_bomb_reset.cpp b/regamedll/dlls/addons/trigger_bomb_reset.cpp index 999fc6595..176240656 100644 --- a/regamedll/dlls/addons/trigger_bomb_reset.cpp +++ b/regamedll/dlls/addons/trigger_bomb_reset.cpp @@ -33,6 +33,6 @@ void CTriggerBombReset::Touch(CBaseEntity *pOther) if (pWeaponBox && pWeaponBox->m_bIsBomb) { // If the bomb touches this trigger, tell it to reset to its last known valid position. - pWeaponBox->ResetToLastValidPlayerHeldPosition(); + pWeaponBox->ResetToLastValidPlayerHeldC4Position(); } } diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 8e13da29a..b89784b5f 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -8030,7 +8030,7 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(DropPlayerItem)(const char *pszIte pWeaponBox->m_bIsBomb = true; pWeaponBox->SetThink(&CWeaponBox::BombThink); pWeaponBox->pev->nextthink = gpGlobals->time + 1.0f; - pWeaponBox->SetLastValidHeldPosition(((CC4 *)pWeapon)->GetLastValidHeldPosition()); + pWeaponBox->SetLastValidHeldC4Position(((CC4 *)pWeapon)->GetLastValidHeldPosition()); if (TheCSBots()) { diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 19c42e9ca..bb1a5654d 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -2179,14 +2179,14 @@ void CWeaponBox::SetObjectCollisionBox() pev->absmax = pev->origin + Vector(16, 16, 16); } -void CWeaponBox::ResetToLastValidPlayerHeldPosition() +void CWeaponBox::ResetToLastValidPlayerHeldC4Position() { - if (pev->origin == m_vecLastValidPlayerHeldPosition) + if (pev->origin == m_vecLastValidPlayerHeldC4Position) { return; } - Vector const vecResetPos = m_vecLastValidPlayerHeldPosition + Vector(0.0f, 0.0f, 8.0f); + Vector const vecResetPos = m_vecLastValidPlayerHeldC4Position + Vector(0.0f, 0.0f, 8.0f); Vector const angResetAng = Vector(0.0f, RANDOM_FLOAT(0.0f, 360.0f), 0.0f); // Teleport diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 6ae938be4..3726e28fd 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -483,8 +483,8 @@ class CWeaponBox: public CBaseEntity void SetModel_OrigFunc(const char *pszModelName); #endif - void SetLastValidHeldPosition(const Vector &vecPositon) { m_vecLastValidPlayerHeldPosition = vecPositon; } - void ResetToLastValidPlayerHeldPosition(); + void SetLastValidHeldC4Position(const Vector &vecPositon) { m_vecLastValidPlayerHeldC4Position = vecPositon; } + void ResetToLastValidPlayerHeldC4Position(); public: static TYPEDESCRIPTION m_SaveData[]; @@ -496,7 +496,7 @@ class CWeaponBox: public CBaseEntity bool m_bIsBomb; private: - Vector m_vecLastValidPlayerHeldPosition; + Vector m_vecLastValidPlayerHeldC4Position; }; From b176040f95f78e672fe6761ebf7e84a8bfebf6c5 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Sun, 18 Dec 2022 00:06:44 +0300 Subject: [PATCH 7/9] CTriggerBombReset: Add `SetUse()` --- regamedll/dlls/addons/trigger_bomb_reset.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/regamedll/dlls/addons/trigger_bomb_reset.cpp b/regamedll/dlls/addons/trigger_bomb_reset.cpp index 176240656..3765cbdb8 100644 --- a/regamedll/dlls/addons/trigger_bomb_reset.cpp +++ b/regamedll/dlls/addons/trigger_bomb_reset.cpp @@ -24,6 +24,7 @@ void CTriggerBombReset::Spawn() { InitTrigger(); SetTouch(&CTriggerBombReset::Touch); + SetUse(&CTriggerBombReset::ToggleUse); } void CTriggerBombReset::Touch(CBaseEntity *pOther) From d97482640a3e87edff05094926e609c3ced7d28c Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Wed, 21 Dec 2022 22:52:46 +0300 Subject: [PATCH 8/9] fix: do not overwrite `CC4::Think()` Co-authored-by: Garey27 Co-authored-by: s1lentq --- regamedll/dlls/weapons.h | 2 +- regamedll/dlls/wpn_shared/wpn_c4.cpp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 3726e28fd..b352f8ef2 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -870,7 +870,6 @@ class CC4: public CBasePlayerWeapon virtual BOOL Deploy(); virtual void Holster(int skiplocal); virtual void AttachToPlayer(CBasePlayer* pPlayer); - virtual void Think(); virtual float GetMaxSpeed(); virtual int iItemSlot() { return C4_SLOT; } virtual void PrimaryAttack(); @@ -884,6 +883,7 @@ class CC4: public CBasePlayerWeapon #endif } + void EXPORT TrackPlayerHeldPosition(); Vector GetLastValidHeldPosition() const { return m_vecLastValidPlayerHeldPosition; } public: diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index 87b49a304..898511173 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -388,7 +388,7 @@ void CC4::AttachToPlayer(CBasePlayer* pPlayer) CBasePlayerWeapon::AttachToPlayer(pPlayer); #ifdef REGAMEDLL_ADD - SetThink(&CC4::Think); + SetThink(&CC4::TrackPlayerHeldPosition); pev->nextthink = gpGlobals->time + WEAPON_C4_UPDATE_LAST_VALID_PLAYER_HELD_POSITION_INTERVAL; if (pPlayer->IsPlayer() && pPlayer->IsAlive()) @@ -399,9 +399,8 @@ void CC4::AttachToPlayer(CBasePlayer* pPlayer) #endif } -void CC4::Think() +void CC4::TrackPlayerHeldPosition() { -#ifdef REGAMEDLL_ADD pev->nextthink = gpGlobals->time + WEAPON_C4_UPDATE_LAST_VALID_PLAYER_HELD_POSITION_INTERVAL; // If the bomb is held by an alive player standing on the ground, then we can use this @@ -412,7 +411,4 @@ void CC4::Think() entvars_t* pevPlayer = m_pPlayer->pev; m_vecLastValidPlayerHeldPosition = pevPlayer->origin + pevPlayer->mins; } -#else - CBasePlayerWeapon::Think(); -#endif } From f83ef99714997bbd8cad85dc3f49810c839c3dcd Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Wed, 12 Jul 2023 08:01:02 +0300 Subject: [PATCH 9/9] fix pointers style (right alignment) --- regamedll/dlls/weapons.h | 2 +- regamedll/dlls/wpn_shared/wpn_c4.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index d18201b82..b2928f017 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -869,7 +869,7 @@ class CC4: public CBasePlayerWeapon virtual int GetItemInfo(ItemInfo *p); virtual BOOL Deploy(); virtual void Holster(int skiplocal); - virtual void AttachToPlayer(CBasePlayer* pPlayer); + virtual void AttachToPlayer(CBasePlayer *pPlayer); virtual float GetMaxSpeed(); virtual int iItemSlot() { return C4_SLOT; } virtual void PrimaryAttack(); diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index 898511173..d35a7ab01 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -383,7 +383,7 @@ float CC4::GetMaxSpeed() return C4_MAX_SPEED; } -void CC4::AttachToPlayer(CBasePlayer* pPlayer) +void CC4::AttachToPlayer(CBasePlayer *pPlayer) { CBasePlayerWeapon::AttachToPlayer(pPlayer); @@ -393,7 +393,7 @@ void CC4::AttachToPlayer(CBasePlayer* pPlayer) if (pPlayer->IsPlayer() && pPlayer->IsAlive()) { - entvars_t* pevPlayer = pPlayer->pev; + entvars_t *pevPlayer = pPlayer->pev; m_vecLastValidPlayerHeldPosition = pevPlayer->origin + pevPlayer->mins; } #endif @@ -408,7 +408,7 @@ void CC4::TrackPlayerHeldPosition() if (m_pPlayer && m_pPlayer->IsPlayer() && m_pPlayer->IsAlive() && (m_pPlayer->pev->flags & FL_ONGROUND)) { - entvars_t* pevPlayer = m_pPlayer->pev; + entvars_t *pevPlayer = m_pPlayer->pev; m_vecLastValidPlayerHeldPosition = pevPlayer->origin + pevPlayer->mins; } }