cs16-client-legacy/dlls/gamerules.cpp

116 lines
2.6 KiB
C++

/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#include "stdafx.h"
#include "cbase.h"
#include "player.h"
#include "weapons.h"
#include "gamerules.h"
#include "training_gamerules.h"
#include "skill.h"
#include "game.h"
extern edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer);
DLL_GLOBAL CHalfLifeMultiplay *g_pGameRules = NULL;
extern DLL_GLOBAL BOOL g_fGameOver;
extern int gmsgDeathMsg;
extern int gmsgMOTD;
BOOL CGameRules::CanHaveAmmo(CBasePlayer *pPlayer, const char *pszAmmoName, int iMaxCarry)
{
if (pszAmmoName)
{
int iAmmoIndex = pPlayer->GetAmmoIndex(pszAmmoName);
if (iAmmoIndex > -1)
{
if (pPlayer->AmmoInventory(iAmmoIndex) < iMaxCarry)
return TRUE;
}
}
return FALSE;
}
edict_t *CGameRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer)
{
edict_t *pentSpawnSpot = EntSelectSpawnPoint(pPlayer);
pPlayer->pev->origin = VARS(pentSpawnSpot)->origin + Vector(0, 0, 1);
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 = TRUE;
return pentSpawnSpot;
}
BOOL CGameRules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
{
if (pPlayer->pev->deadflag != DEAD_NO)
return FALSE;
if (pWeapon->pszAmmo1())
{
if (!CanHaveAmmo(pPlayer, pWeapon->pszAmmo1(), pWeapon->iMaxAmmo1()))
{
if (pPlayer->HasPlayerItem(pWeapon))
return FALSE;
}
}
else
{
if (pPlayer->HasPlayerItem(pWeapon))
return FALSE;
}
return TRUE;
}
void CGameRules::RefreshSkillData(void)
{
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.bullsquidDmgBite = 8;
gSkillData.bullsquidHealth = 3;
gSkillData.bigmommaRadiusBlast = 5;
gSkillData.bullsquidDmgWhip = 75;
gSkillData.bullsquidDmgSpit = 15;
gSkillData.gargantuaHealth = 50;
gSkillData.gargantuaDmgSlash = 15;
}
CGameRules *InstallGameRules(void)
{
SERVER_COMMAND("exec game.cfg\n");
SERVER_EXECUTE();
if (!gpGlobals->deathmatch)
return new CHalfLifeTraining;
return new CHalfLifeMultiplay;
}