2015-07-12 23:32:09 +03:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
2015-06-30 12:46:07 +03:00
|
|
|
/*
|
|
|
|
* Globals initialization
|
2015-07-12 23:32:09 +03:00
|
|
|
*/
|
|
|
|
#ifndef HOOK_GAMEDLL
|
|
|
|
|
2016-02-23 02:13:52 +03:00
|
|
|
CGameRules *g_pGameRules = NULL;
|
2015-07-12 23:32:09 +03:00
|
|
|
|
2016-02-23 02:13:52 +03:00
|
|
|
#endif
|
2015-07-12 23:32:09 +03:00
|
|
|
|
2015-08-20 13:35:01 +03:00
|
|
|
BOOL CGameRules::__MAKE_VHOOK(CanHaveAmmo)(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry)
|
2015-07-12 23:32:09 +03:00
|
|
|
{
|
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
|
|
|
|
2015-07-12 23:32:09 +03:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-08-20 13:35:01 +03:00
|
|
|
edict_t *CGameRules::__MAKE_VHOOK(GetPlayerSpawnSpot)(CBasePlayer *pPlayer)
|
2015-07-12 23:32:09 +03:00
|
|
|
{
|
2016-01-19 14:54:31 +03:00
|
|
|
// gat valid spawn point
|
2015-09-16 23:19:21 +03:00
|
|
|
edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer);
|
|
|
|
|
2016-01-19 14:54:31 +03:00
|
|
|
// Move the player to the place it said.
|
2015-12-22 21:07:49 +03:00
|
|
|
#ifndef PLAY_GAMEDLL
|
2016-02-23 02:13:52 +03:00
|
|
|
pPlayer->pev->origin = pentSpawnSpot->v.origin + Vector(0, 0, 1);
|
2015-12-22 21:07:49 +03:00
|
|
|
#else
|
2015-11-06 17:58:48 +03:00
|
|
|
// TODO: fix test demo
|
2016-02-23 02:13:52 +03:00
|
|
|
pPlayer->pev->origin = pentSpawnSpot->v.origin;
|
2015-09-16 23:19:21 +03:00
|
|
|
pPlayer->pev->origin.z += 1;
|
2016-02-23 02:13:52 +03:00
|
|
|
#endif
|
2015-09-16 23:19:21 +03:00
|
|
|
|
|
|
|
pPlayer->pev->v_angle = g_vecZero;
|
|
|
|
pPlayer->pev->velocity = g_vecZero;
|
2016-02-23 02:13:52 +03:00
|
|
|
pPlayer->pev->angles = pentSpawnSpot->v.angles;
|
2015-09-16 23:19:21 +03:00
|
|
|
pPlayer->pev->punchangle = g_vecZero;
|
|
|
|
pPlayer->pev->fixangle = 1;
|
|
|
|
|
2015-08-20 13:35:01 +03:00
|
|
|
return pentSpawnSpot;
|
2015-07-12 23:32:09 +03:00
|
|
|
}
|
|
|
|
|
2015-08-20 13:35:01 +03:00
|
|
|
BOOL CGameRules::__MAKE_VHOOK(CanHavePlayerItem)(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
2015-07-12 23:32:09 +03:00
|
|
|
{
|
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
|
|
|
|
2016-02-23 02:13:52 +03:00
|
|
|
if (pPlayer->IsBot() && TheCSBots() != NULL && !TheCSBots()->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;
|
2015-07-12 23:32:09 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CGameRules::__MAKE_VHOOK(RefreshSkillData)()
|
2015-07-12 23:32:09 +03:00
|
|
|
{
|
2016-02-23 02:13:52 +03:00
|
|
|
int iSkill = int(CVAR_GET_FLOAT("skill"));
|
2015-07-12 23:32:09 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
CGameRules *InstallGameRules()
|
2015-12-05 22:40:30 +03:00
|
|
|
{
|
2015-07-02 00:22:46 +03:00
|
|
|
SERVER_COMMAND("exec game.cfg\n");
|
|
|
|
SERVER_EXECUTE();
|
|
|
|
|
|
|
|
if (!gpGlobals->deathmatch)
|
|
|
|
return new CHalfLifeTraining;
|
|
|
|
|
2015-07-12 23:32:09 +03:00
|
|
|
return new CHalfLifeMultiplay;
|
|
|
|
}
|