Skip to content

Commit

Permalink
Added argument about type awards to CBasePlayer::AddAccount
Browse files Browse the repository at this point in the history
Some adjustments in RadiusDamage
  • Loading branch information
s1lentq committed May 25, 2016
1 parent b6e0420 commit 9203344
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 40 deletions.
12 changes: 6 additions & 6 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)

bEnoughMoney = true;
pPlayer->m_bHasNightVision = true;
pPlayer->AddAccount(-NVG_PRICE);
pPlayer->AddAccount(-NVG_PRICE, RT_PLAYER_BOUGHT_SOMETHING);

SendItemStatus(pPlayer);
}
Expand Down Expand Up @@ -1283,7 +1283,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)
MESSAGE_END();

pPlayer->pev->body = 1;
pPlayer->AddAccount(-DEFUSEKIT_PRICE);
pPlayer->AddAccount(-DEFUSEKIT_PRICE, RT_PLAYER_BOUGHT_SOMETHING);

EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/kevlar.wav", VOL_NORM, ATTN_NORM);
SendItemStatus(pPlayer);
Expand All @@ -1301,7 +1301,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)
DropPrimary(pPlayer);

pPlayer->GiveShield(true);
pPlayer->AddAccount(-SHIELDGUN_PRICE);
pPlayer->AddAccount(-SHIELDGUN_PRICE, RT_PLAYER_BOUGHT_SOMETHING);

EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM);
}
Expand All @@ -1323,7 +1323,7 @@ void BuyItem(CBasePlayer *pPlayer, int iSlot)
if (pszItem != NULL)
{
pPlayer->GiveNamedItem(pszItem);
pPlayer->AddAccount(-iItemPrice);
pPlayer->AddAccount(-iItemPrice, RT_PLAYER_BOUGHT_SOMETHING);
}

if (TheTutor != NULL)
Expand Down Expand Up @@ -1365,7 +1365,7 @@ void BuyWeaponByWeaponID(CBasePlayer *pPlayer, WeaponIdType weaponID)
}

pPlayer->GiveNamedItem(info->entityName);
pPlayer->AddAccount(-info->cost);
pPlayer->AddAccount(-info->cost, RT_PLAYER_BOUGHT_SOMETHING);

if (TheTutor != NULL)
{
Expand Down Expand Up @@ -2013,7 +2013,7 @@ bool BuyGunAmmo(CBasePlayer *player, CBasePlayerItem *weapon, bool bBlinkMoney)
if (player->m_iAccount >= info->clipCost)
{
player->GiveNamedItem(info->ammoName);
player->AddAccount(-info->clipCost);
player->AddAccount(-info->clipCost, RT_PLAYER_BOUGHT_SOMETHING);
return true;
}

Expand Down
17 changes: 11 additions & 6 deletions regamedll/dlls/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,14 +1176,15 @@ void RadiusDamage(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker
#endif
}

#ifdef REGAMEDLL_FIXES
// not allow inflict to the player damage is less than 1.0f and to entities not less than 0.0f
if ((pEntity->Classify() == CLASS_PLAYER && flAdjustedDamage < 1.0f) || flAdjustedDamage <= 0.0f)
continue;
#else
if (flAdjustedDamage < 0)
flAdjustedDamage = 0;

#ifdef REGAMEDLL_FIXES
if (flAdjustedDamage > 0)
#endif
pEntity->TakeDamage(pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType);

}
}
}
Expand All @@ -1198,23 +1199,27 @@ void RadiusDamage2(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacke
if (flRadius)
falloff = flDamage / flRadius;
else
falloff = 1;
falloff = 1.0;

int bInWater = (UTIL_PointContents(vecSrc) == CONTENTS_WATER);

// in case grenade is lying on the ground
vecSrc.z += 1;

if (!pevAttacker)
pevAttacker = pevInflictor;

// iterate on all entities in the vicinity.
while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius)) != NULL)
{
if (pEntity->pev->takedamage != DAMAGE_NO)
{
// UNDONE: this should check a damage mask, not an ignore
if (iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore)
continue;

if (bInWater && !pEntity->pev->waterlevel)
// blast's don't tavel into or out of water
if (bInWater && pEntity->pev->waterlevel == 0)
continue;

if (!bInWater && pEntity->pev->waterlevel == 3)
Expand Down
3 changes: 2 additions & 1 deletion regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ enum RewardAccount
REWARD_KILLED_VIP = 2500,
REWARD_VIP_HAVE_SELF_RESCUED = 2500,

REWARD_TAKEN_HOSTAGE = 1000
REWARD_TAKEN_HOSTAGE = 1000,
REWARD_TOOK_HOSTAGE = 150

};

Expand Down
8 changes: 4 additions & 4 deletions regamedll/dlls/hostage/hostage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void CHostage::IdleThink()

if (player != NULL)
{
player->AddAccount(REWARD_TAKEN_HOSTAGE);
player->AddAccount(REWARD_TAKEN_HOSTAGE, RT_HOSTAGE_RESCUED);
UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Rescued_A_Hostage\"\n", STRING(player->pev->netname),
GETPLAYERUSERID(player->edict()), GETPLAYERAUTHID(player->edict()));
}
Expand Down Expand Up @@ -453,7 +453,7 @@ int CHostage::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAt

if (pAttacker != NULL)
{
pAttacker->AddAccount(-20 * int(flActualDamage));
pAttacker->AddAccount(-20 * int(flActualDamage), RT_HOSTAGE_DAMAGED);

if (TheBots != NULL)
{
Expand All @@ -479,7 +479,7 @@ int CHostage::__MAKE_VHOOK(TakeDamage)(entvars_t *pevInflictor, entvars_t *pevAt

if (pAttacker != NULL)
{
pAttacker->AddAccount(20 * (-25 - int(flActualDamage)));
pAttacker->AddAccount(20 * (-25 - int(flActualDamage)), RT_HOSTAGE_KILLED);
AnnounceDeath(pAttacker);
ApplyHostagePenalty(pAttacker);
}
Expand Down Expand Up @@ -756,7 +756,7 @@ void CHostage::GiveCTTouchBonus(CBasePlayer *pPlayer)
m_bTouched = TRUE;
CSGameRules()->m_iAccountCT += 100;

pPlayer->AddAccount(150);
pPlayer->AddAccount(REWARD_TOOK_HOSTAGE, RT_HOSTAGE_TOOK);
UTIL_LogPrintf("\"%s<%i><%s><CT>\" triggered \"Touched_A_Hostage\"\n", STRING(pPlayer->pev->netname), GETPLAYERUSERID(pPlayer->edict()), GETPLAYERAUTHID(pPlayer->edict()));
}

Expand Down
12 changes: 6 additions & 6 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)()

if (hostage->pev->solid != SOLID_NOT)
{
acct_tmp += 150;
acct_tmp += REWARD_TOOK_HOSTAGE;

if (hostage->pev->deadflag == DEAD_DEAD)
{
Expand Down Expand Up @@ -2039,7 +2039,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)()
{
if (!player->m_bReceivesNoMoneyNextRound)
{
player->AddAccount(m_iAccountCT);
player->AddAccount(m_iAccountCT, RT_ROUND_BONUS);
}
}
else if (player->m_iTeam == TERRORIST)
Expand All @@ -2049,7 +2049,7 @@ void CHalfLifeMultiplay::__API_VHOOK(RestartRound)()

if (!player->m_bReceivesNoMoneyNextRound)
{
player->AddAccount(m_iAccountTerrorist);
player->AddAccount(m_iAccountTerrorist, RT_ROUND_BONUS);
}

// If it's a prison scenario then remove the Ts guns
Expand Down Expand Up @@ -3668,7 +3668,7 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars
// if a player dies by from teammate
pKiller->frags -= IPointsForKill(peKiller, pVictim);

killer->AddAccount(PAYBACK_FOR_KILLED_TEAMMATES);
killer->AddAccount(PAYBACK_FOR_KILLED_TEAMMATES, RT_TEAMMATES_KILLED);
killer->m_iTeamKills++;
killer->m_bJustKilledTeammate = true;

Expand Down Expand Up @@ -3701,7 +3701,7 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars
if (pVictim->m_bIsVIP)
{
killer->HintMessage("#Hint_reward_for_killing_vip", TRUE);
killer->AddAccount(REWARD_KILLED_VIP);
killer->AddAccount(REWARD_KILLED_VIP, RT_VIP_KILLED);

MESSAGE_BEGIN(MSG_SPEC, SVC_DIRECTOR);
WRITE_BYTE(9);
Expand All @@ -3714,7 +3714,7 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars
UTIL_LogPrintf("\"%s<%i><%s><TERRORIST>\" triggered \"Assassinated_The_VIP\"\n", STRING(killer->pev->netname), GETPLAYERUSERID(killer->edict()), GETPLAYERAUTHID(killer->edict()));
}
else
killer->AddAccount(REWARD_KILLED_ENEMY);
killer->AddAccount(REWARD_KILLED_ENEMY, RT_ENEMY_KILLED);

if (!(killer->m_flDisplayHistory & DHF_ENEMY_KILLED))
{
Expand Down
8 changes: 4 additions & 4 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3070,9 +3070,9 @@ NOXREF void CBasePlayer::ThrowPrimary()
DropShield();
}

LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, AddAccount, (int amount, bool bTrackChange), amount, bTrackChange);
LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, AddAccount, (int amount, RewardType type, bool bTrackChange), amount, type, bTrackChange);

void CBasePlayer::__API_HOOK(AddAccount)(int amount, bool bTrackChange)
void CBasePlayer::__API_HOOK(AddAccount)(int amount, RewardType type, bool bTrackChange)
{
m_iAccount += amount;

Expand Down Expand Up @@ -3300,7 +3300,7 @@ void CBasePlayer::JoiningThink()
{
m_iAccount = 0;
CheckStartMoney();
AddAccount(startmoney.value);
AddAccount(startmoney.value, RT_INTO_GAME);
}

if (g_pGameRules->FPlayerCanRespawn(this))
Expand Down Expand Up @@ -5499,7 +5499,7 @@ void CBasePlayer::Reset()

RemoveShield();
CheckStartMoney();
AddAccount(startmoney.value);
AddAccount(startmoney.value, RT_PLAYER_RESET);

MESSAGE_BEGIN(MSG_ALL, gmsgScoreInfo);
WRITE_BYTE(ENTINDEX(edict()));
Expand Down
22 changes: 20 additions & 2 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@
#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav"
#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav"

// custom enum
enum RewardType
{
RT_NONE,
RT_ROUND_BONUS,
RT_PLAYER_RESET,
RT_PLAYER_BOUGHT_SOMETHING,
RT_HOSTAGE_TOOK,
RT_HOSTAGE_RESCUED,
RT_HOSTAGE_DAMAGED,
RT_HOSTAGE_KILLED,
RT_TEAMMATES_KILLED,
RT_ENEMY_KILLED,
RT_INTO_GAME,
RT_VIP_KILLED,
RT_VIP_RESCUED_MYSELF
};

typedef enum
{
PLAYER_IDLE,
Expand Down Expand Up @@ -424,8 +442,8 @@ class CBasePlayer: public CBaseMonster {
void SmartRadio();
void ThrowWeapon(char *pszItemName);
void ThrowPrimary();
void AddAccount(int amount, bool bTrackChange = true);
void AddAccount_(int amount, bool bTrackChange = true);
void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true);
void AddAccount_(int amount, RewardType type = RT_NONE, bool bTrackChange = true);
void Disappear();
void MakeVIP();
bool CanPlayerBuy(bool display = false);
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/triggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ void CVIP_SafetyZone::VIP_SafetyTouch(CBaseEntity *pOther)
p->m_bEscaped = true;

p->Disappear();
p->AddAccount(REWARD_VIP_HAVE_SELF_RESCUED);
p->AddAccount(REWARD_VIP_HAVE_SELF_RESCUED, RT_VIP_RESCUED_MYSELF);
}
}

Expand Down
18 changes: 18 additions & 0 deletions regamedll/extra/cssdk/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@
#define SOUND_FLASHLIGHT_ON "items/flashlight1.wav"
#define SOUND_FLASHLIGHT_OFF "items/flashlight1.wav"

// custom enum
enum RewardType
{
RT_NONE,
RT_ROUND_BONUS,
RT_PLAYER_RESET,
RT_PLAYER_BOUGHT_SOMETHING,
RT_HOSTAGE_TOOK,
RT_HOSTAGE_RESCUED,
RT_HOSTAGE_DAMAGED,
RT_HOSTAGE_KILLED,
RT_TEAMMATES_KILLED,
RT_ENEMY_KILLED,
RT_INTO_GAME,
RT_VIP_KILLED,
RT_VIP_RESCUED_MYSELF
};

typedef enum
{
PLAYER_IDLE,
Expand Down
4 changes: 2 additions & 2 deletions regamedll/extra/cssdk/dlls/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ typedef IVoidHookChain<const char *> IReGameHook_CBasePlayer_GiveNamedItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;

// CBasePlayer::AddAccount hook
typedef IVoidHookChain<int, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
typedef IVoidHookChain<int, enum RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, enum RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;

// CBasePlayer::GiveShield hook
typedef IVoidHookChain<bool> IReGameHook_CBasePlayer_GiveShield;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/extra/cssdk/dlls/regamedll_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class ICSPlayer: public ICSMonster {
virtual bool IsConnected() const = 0;

virtual void SetAnimation(PLAYER_ANIM playerAnim) = 0;
virtual void AddAccount(int amount, bool bTrackChange = true) = 0;
virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true) = 0;
virtual void GiveNamedItem(const char *pszName) = 0;
virtual void GiveNamedItemEx(const char *pszName) = 0;
virtual void GiveDefaultItems() = 0;
Expand Down
4 changes: 2 additions & 2 deletions regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ typedef IVoidHookChain<const char *> IReGameHook_CBasePlayer_GiveNamedItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_GiveNamedItem;

// CBasePlayer::AddAccount hook
typedef IVoidHookChain<int, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, bool> IReGameHookRegistry_CBasePlayer_AddAccount;
typedef IVoidHookChain<int, enum RewardType, bool> IReGameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClass<class CBasePlayer, int, enum RewardType, bool> IReGameHookRegistry_CBasePlayer_AddAccount;

// CBasePlayer::GiveShield hook
typedef IVoidHookChain<bool> IReGameHook_CBasePlayer_GiveShield;
Expand Down
2 changes: 1 addition & 1 deletion regamedll/public/regamedll/regamedll_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class ICSPlayer: public ICSMonster {
virtual bool IsConnected() const = 0;

virtual void SetAnimation(PLAYER_ANIM playerAnim) = 0;
virtual void AddAccount(int amount, bool bTrackChange = true) = 0;
virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true) = 0;
virtual void GiveNamedItem(const char *pszName) = 0;
virtual void GiveNamedItemEx(const char *pszName) = 0;
virtual void GiveDefaultItems() = 0;
Expand Down
6 changes: 3 additions & 3 deletions regamedll/regamedll/regamedll_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ typedef IVoidHookChainClassImpl<CBasePlayer, const char *> CRegameHook_CBasePlay
typedef IVoidHookChainRegistryClassImpl<CBasePlayer, const char *> CReGameHookRegistry_CBasePlayer_GiveNamedItem;

// CBasePlayer::AddAccount hook
typedef IVoidHookChainClassImpl<CBasePlayer, int, bool> CRegameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClassImpl<CBasePlayer, int, bool> CReGameHookRegistry_CBasePlayer_AddAccount;
typedef IVoidHookChainClassImpl<CBasePlayer, int, RewardType, bool> CRegameHook_CBasePlayer_AddAccount;
typedef IVoidHookChainRegistryClassImpl<CBasePlayer, int, RewardType, bool> CReGameHookRegistry_CBasePlayer_AddAccount;

// CBasePlayer::AddAccount hook
// CBasePlayer::GiveShield hook
typedef IVoidHookChainClassImpl<CBasePlayer, bool> CRegameHook_CBasePlayer_GiveShield;
typedef IVoidHookChainRegistryClassImpl<CBasePlayer, bool> CReGameHookRegistry_CBasePlayer_GiveShield;

Expand Down
2 changes: 1 addition & 1 deletion regamedll/regamedll/regamedll_interfaces_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class CCSPlayer: public CCSMonster {
virtual bool IsConnected() const { return m_pEntity->has_disconnected == false; }

virtual void SetAnimation(PLAYER_ANIM playerAnim) { ((CBasePlayer *)m_pEntity)->SetAnimation(playerAnim); }
virtual void AddAccount(int amount, bool bTrackChange = true) { ((CBasePlayer *)m_pEntity)->AddAccount(amount, bTrackChange); }
virtual void AddAccount(int amount, RewardType type = RT_NONE, bool bTrackChange = true) { ((CBasePlayer *)m_pEntity)->AddAccount(amount, type, bTrackChange); }
virtual void GiveNamedItem(const char *pszName) { ((CBasePlayer *)m_pEntity)->GiveNamedItem(pszName); }
virtual void GiveNamedItemEx(const char *pszName) { ((CBasePlayer *)m_pEntity)->GiveNamedItemEx(pszName); }
virtual void GiveDefaultItems() { ((CBasePlayer *)m_pEntity)->GiveDefaultItems(); }
Expand Down

0 comments on commit 9203344

Please sign in to comment.