ReGameDLL_CS/regamedll/dlls/gamerules.cpp

133 lines
3.0 KiB
C++
Raw Normal View History

#include "precompiled.h"
2015-06-30 12:46:07 +03:00
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
CHalfLifeMultiplay *g_pGameRules = NULL;
#endif //HOOK_GAMEDLL
/* <ad93d> ../cstrike/dlls/gamerules.cpp:36 */
2015-08-20 13:35:01 +03:00
BOOL CGameRules::__MAKE_VHOOK(CanHaveAmmo)(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry)
{
2015-08-20 13:35:01 +03:00
int iAmmoIndex;
if (pszAmmoName != NULL)
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
iAmmoIndex = pPlayer->GetAmmoIndex(pszAmmoName);
2015-06-30 12:46:07 +03:00
if (iAmmoIndex > -1)
{
if (pPlayer->AmmoInventory(iAmmoIndex) < iMaxCarry)
2015-08-20 13:35:01 +03:00
{
// player has room for more of this type of ammo
2015-06-30 12:46:07 +03:00
return TRUE;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
}
}
2015-08-20 13:35:01 +03:00
return FALSE;
}
/* <ad89d> ../cstrike/dlls/gamerules.cpp:59 */
2015-08-20 13:35:01 +03:00
edict_t *CGameRules::__MAKE_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer)
{
// gat valid spawn point
2015-09-16 23:19:21 +03:00
edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer);
// Move the player to the place it said.
#ifndef PLAY_GAMEDLL
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1);
#else
// TODO: fix test demo
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin;
2015-09-16 23:19:21 +03:00
pPlayer->pev->origin.z += 1;
#endif // PLAY_GAMEDLL
2015-09-16 23:19:21 +03:00
pPlayer->pev->v_angle = g_vecZero;
pPlayer->pev->velocity = g_vecZero;
pPlayer->pev->angles = VARS(pentSpawnSpot)->angles;
pPlayer->pev->punchangle = g_vecZero;
pPlayer->pev->fixangle = 1;
2015-08-20 13:35:01 +03:00
return pentSpawnSpot;
}
/* <ad9a3> ../cstrike/dlls/gamerules.cpp:75 */
2015-08-20 13:35:01 +03:00
BOOL CGameRules::__MAKE_VHOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
{
2015-08-20 13:35:01 +03:00
// only living players can have items
if (pPlayer->pev->deadflag != DEAD_NO)
{
2015-06-30 12:46:07 +03:00
return FALSE;
2015-08-20 13:35:01 +03:00
}
2015-06-30 12:46:07 +03:00
CCSBotManager *ctrl = TheCSBots();
2015-08-20 13:35:01 +03:00
if (pPlayer->IsBot() && ctrl != NULL && !ctrl->IsWeaponUseable(pWeapon))
2015-06-30 12:46:07 +03:00
{
2015-08-20 13:35:01 +03:00
return FALSE;
}
2015-09-16 23:19:21 +03:00
if (pWeapon->pszAmmo1())
{
if (!CanHaveAmmo(pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1()))
{
// we can't carry anymore ammo for this gun. We can only
// have the gun if we aren't already carrying one of this type
if (pPlayer->HasPlayerItem(pWeapon))
{
return FALSE;
}
}
}
else
{
// weapon doesn't use ammo, don't take another if you already have it.
if (pPlayer->HasPlayerItem(pWeapon))
{
return FALSE;
}
2015-08-20 13:35:01 +03:00
}
2015-09-16 23:19:21 +03:00
// note: will fall through to here if GetItemInfo doesn't fill the struct!
2015-08-20 13:35:01 +03:00
return TRUE;
}
/* <ad85d> ../cstrike/dlls/gamerules.cpp:119 */
void CGameRules::__MAKE_VHOOK(RefreshSkillData)()
{
int iSkill = (int)CVAR_GET_FLOAT("skill");
if (iSkill < 1)
iSkill = 1;
else if (iSkill > 3)
iSkill = 3;
gSkillData.iSkillLevel = iSkill;
ALERT(at_console, "\nGAME SKILL LEVEL:%d\n", iSkill);
gSkillData.monDmg12MM = 8;
gSkillData.monDmgMP5 = 3;
gSkillData.monDmg9MM = 5;
gSkillData.suitchargerCapacity = 75;
gSkillData.batteryCapacity = 15;
gSkillData.healthchargerCapacity = 50;
gSkillData.healthkitCapacity = 15;
}
/* <ada23> ../cstrike/dlls/gamerules.cpp:157 */
CGameRules *InstallGameRules()
{
SERVER_COMMAND("exec game.cfg\n");
SERVER_EXECUTE();
if (!gpGlobals->deathmatch)
return new CHalfLifeTraining;
return new CHalfLifeMultiplay;
}