Fix nade drops

Move m_bHasSecondaryAttack to CCSPlayerWeapon
This commit is contained in:
s1lent 2017-11-03 23:33:17 +07:00
parent c0edbd551d
commit 10ee63d807
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
10 changed files with 73 additions and 20 deletions

View File

@ -129,7 +129,7 @@ void CTriggerSetOrigin::SetupEntities()
m_bSetupEntities = false; m_bSetupEntities = false;
m_entityNum = 0; m_entityNum = 0;
m_hCopyPointer = UTIL_FindEntityByTargetname(m_hCopyPointer, STRING(m_copyPointer)); m_hCopyPointer = UTIL_FindEntityByTargetname(m_hCopyPointer, m_copyPointer);
if (!m_hCopyPointer.IsValid() && hPrevEnt.IsValid()) if (!m_hCopyPointer.IsValid() && hPrevEnt.IsValid())
{ {
@ -137,7 +137,7 @@ void CTriggerSetOrigin::SetupEntities()
} }
CBaseEntity *pEntity = nullptr; CBaseEntity *pEntity = nullptr;
while ((pEntity = UTIL_FindEntityByTargetname(pEntity, STRING(pev->target)))) while ((pEntity = UTIL_FindEntityByTargetname(pEntity, pev->target)))
{ {
if (m_entityNum > MAX_SETORIGIN_ENTITIES) if (m_entityNum > MAX_SETORIGIN_ENTITIES)
break; break;

View File

@ -169,10 +169,6 @@ bool CCSBotManager::IsWeaponUseable(CBasePlayerItem *item) const
if ((!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN) if ((!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN)
|| (!AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN) || (!AllowMachineGuns() && weaponClass == WEAPONCLASS_MACHINEGUN)
|| (!AllowRifles() && weaponClass == WEAPONCLASS_RIFLE) || (!AllowRifles() && weaponClass == WEAPONCLASS_RIFLE)
#ifndef REGAMEDLL_FIXES
// TODO: already is checked shotguns!
|| (!AllowShotguns() && weaponClass == WEAPONCLASS_SHOTGUN)
#endif
|| (!AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE) || (!AllowSnipers() && weaponClass == WEAPONCLASS_SNIPERRIFLE)
|| (!AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN) || (!AllowSubMachineGuns() && weaponClass == WEAPONCLASS_SUBMACHINEGUN)
|| (!AllowTacticalShield() && item->m_iId == WEAPON_SHIELDGUN) || (!AllowTacticalShield() && item->m_iId == WEAPON_SHIELDGUN)
@ -722,13 +718,6 @@ void CCSBotManager::ServerCommand(const char *pcmd)
BOOL CCSBotManager::ClientCommand(CBasePlayer *pPlayer, const char *pcmd) BOOL CCSBotManager::ClientCommand(CBasePlayer *pPlayer, const char *pcmd)
{ {
#ifndef REGAMEDLL_FIXES
if (pPlayer && UTIL_GetLocalPlayer())
{
UTIL_GetLocalPlayer();
}
#endif
return FALSE; return FALSE;
} }

View File

@ -1298,7 +1298,7 @@ void PackPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
break; break;
} }
if ((pPlayer->pev->button & IN_ATTACK) && pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] <= 0) { if (pItem->m_flStartThrow && pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] <= 0) {
return; return;
} }

View File

@ -795,7 +795,7 @@ bool CBasePlayerWeapon::HasSecondaryAttack()
} }
#ifdef REGAMEDLL_API #ifdef REGAMEDLL_API
if (CSPlayerItem()->m_bHasSecondaryAttack) if (CSPlayerWeapon()->m_bHasSecondaryAttack)
{ {
return true; return true;
} }
@ -1092,7 +1092,7 @@ void CBasePlayerWeapon::Spawn()
CSPlayerItem()->SetItemInfo(&info); CSPlayerItem()->SetItemInfo(&info);
} }
CSPlayerItem()->m_bHasSecondaryAttack = HasSecondaryAttack(); CSPlayerWeapon()->m_bHasSecondaryAttack = HasSecondaryAttack();
} }
// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal

View File

@ -317,6 +317,7 @@ inline CCSPlayerItem *CBasePlayerItem::CSPlayerItem() const
#endif #endif
// inventory items that // inventory items that
class CCSPlayerWeapon;
class CBasePlayerWeapon: public CBasePlayerItem class CBasePlayerWeapon: public CBasePlayerItem
{ {
public: public:
@ -375,6 +376,10 @@ public:
bool ShieldSecondaryFire(int iUpAnim, int iDownAnim); bool ShieldSecondaryFire(int iUpAnim, int iDownAnim);
void InstantReload(bool bCanRefillBPAmmo = false); void InstantReload(bool bCanRefillBPAmmo = false);
#ifdef REGAMEDLL_API
CCSPlayerWeapon *CSPlayerWeapon() const;
#endif
public: public:
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
@ -417,6 +422,13 @@ public:
float m_flLastFireTime; float m_flLastFireTime;
}; };
#ifdef REGAMEDLL_API
inline CCSPlayerWeapon *CBasePlayerWeapon::CSPlayerWeapon() const
{
return reinterpret_cast<CCSPlayerWeapon *>(this->m_pEntity);
}
#endif
class CWeaponBox: public CBaseEntity class CWeaponBox: public CBaseEntity
{ {
public: public:

View File

@ -270,10 +270,14 @@ void BotProfileManager::Init(const char *filename, unsigned int *checksum)
profile->m_name = CloneString(SharedGetToken()); profile->m_name = CloneString(SharedGetToken());
#ifdef REGAMEDLL_FIXES
if (RANDOM_LONG(0, 2) == 2)
#else
// HACK HACK // HACK HACK
// Until we have a generalized means of storing bot preferences, we're going to hardcode the bot's // Until we have a generalized means of storing bot preferences, we're going to hardcode the bot's
// preference towards silencers based on his name. // preference towards silencers based on his name.
if (profile->m_name[0] % 2) if (profile->m_name[0] % 2)
#endif
{ {
profile->m_prefersSilencer = true; profile->m_prefersSilencer = true;
} }

View File

@ -39,7 +39,6 @@ class CCSShield: public CCSEntity {};
class CCSDeadHEV: public CCSMonster {}; class CCSDeadHEV: public CCSMonster {};
class CCSSprayCan: public CCSEntity {}; class CCSSprayCan: public CCSEntity {};
class CCSBloodSplat: public CCSEntity {}; class CCSBloodSplat: public CCSEntity {};
class CCSPlayerWeapon: public CCSPlayerItem {};
class CCSWorld: public CCSEntity {}; class CCSWorld: public CCSEntity {};
class CCSDecal: public CCSEntity {}; class CCSDecal: public CCSEntity {};
class CCSCorpse: public CCSEntity {}; class CCSCorpse: public CCSEntity {};

View File

@ -29,6 +29,7 @@
#pragma once #pragma once
#include <API/CSPlayerItem.h> #include <API/CSPlayerItem.h>
#include <API/CSPlayerWeapon.h>
class CCSPlayer: public CCSMonster { class CCSPlayer: public CCSMonster {
public: public:

View File

@ -32,8 +32,7 @@ class CBasePlayerItem;
class CCSPlayerItem: public CCSAnimating class CCSPlayerItem: public CCSAnimating
{ {
public: public:
CCSPlayerItem() : CCSPlayerItem()
m_bHasSecondaryAttack(false)
{ {
Q_memset(&m_ItemInfo, 0, sizeof(m_ItemInfo)); Q_memset(&m_ItemInfo, 0, sizeof(m_ItemInfo));
} }
@ -44,7 +43,6 @@ public:
public: public:
ItemInfo m_ItemInfo; ItemInfo m_ItemInfo;
bool m_bHasSecondaryAttack;
}; };
// Inlines // Inlines

View File

@ -0,0 +1,50 @@
/*
*
* 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
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
class CBasePlayerWeapon;
class CCSPlayerWeapon: public CCSPlayerItem
{
public:
CCSPlayerWeapon() :
m_bHasSecondaryAttack(false)
{
}
CBasePlayerWeapon *BasePlayerWeapon() const;
public:
bool m_bHasSecondaryAttack;
};
// Inlines
inline CBasePlayerWeapon *CCSPlayerWeapon::BasePlayerWeapon() const
{
return reinterpret_cast<CBasePlayerWeapon *>(this->m_pContainingEntity);
}