cs16-client-legacy/dlls/singleplay_gamerules.cpp

252 lines
5.0 KiB
C++
Raw Normal View History

2015-10-25 16:07:56 +01:00
/***
*
* 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.
2015-10-25 16:07:56 +01:00
* 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 "skill.h"
#include "items.h"
CHalfLifeRules::CHalfLifeRules(void)
2015-10-25 16:07:56 +01:00
{
RefreshSkillData();
}
void CHalfLifeRules::Think(void)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
BOOL CHalfLifeRules::IsMultiplayer(void)
2015-10-25 16:07:56 +01:00
{
return FALSE;
}
BOOL CHalfLifeRules::IsDeathmatch(void)
2015-10-25 16:07:56 +01:00
{
return FALSE;
}
BOOL CHalfLifeRules::IsCoOp(void)
2015-10-25 16:07:56 +01:00
{
return FALSE;
}
BOOL CHalfLifeRules::FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
2015-10-25 16:07:56 +01:00
{
if (!pPlayer->m_pActiveItem)
2015-10-25 16:07:56 +01:00
return TRUE;
if (!pPlayer->m_pActiveItem->CanHolster())
2015-10-25 16:07:56 +01:00
return FALSE;
return TRUE;
}
BOOL CHalfLifeRules::GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon)
2015-10-25 16:07:56 +01:00
{
return FALSE;
}
BOOL CHalfLifeRules::ClientConnected(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
2015-10-25 16:07:56 +01:00
{
return TRUE;
}
void CHalfLifeRules::InitHUD(CBasePlayer *pl)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
void CHalfLifeRules::ClientDisconnected(edict_t *pClient)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
float CHalfLifeRules::FlPlayerFallDamage(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED;
return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED;
}
void CHalfLifeRules::PlayerSpawn(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
pPlayer->pev->weapons |= (1 << WEAPON_MAC10);
pPlayer->GiveNamedItem("weapon_knife");
pPlayer->GiveNamedItem("weapon_usp");
pPlayer->GiveNamedItem("weapon_mp5navy");
pPlayer->GiveNamedItem("weapon_hegrenade");
pPlayer->GiveAmmo(60, "9mm", _9MM_MAX_CARRY);
pPlayer->GiveAmmo(24, "45acp", _45ACP_MAX_CARRY);
2015-10-25 16:07:56 +01:00
}
BOOL CHalfLifeRules::AllowAutoTargetCrosshair(void)
2015-10-25 16:07:56 +01:00
{
return g_iSkillLevel == SKILL_EASY;
2015-10-25 16:07:56 +01:00
}
void CHalfLifeRules::PlayerThink(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
}
2015-10-25 16:07:56 +01:00
BOOL CHalfLifeRules::FPlayerCanRespawn(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
return TRUE;
}
float CHalfLifeRules::FlPlayerSpawnTime(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
return gpGlobals->time;
2015-10-25 16:07:56 +01:00
}
int CHalfLifeRules::IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled)
2015-10-25 16:07:56 +01:00
{
return 1;
}
void CHalfLifeRules::PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
void CHalfLifeRules::DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
void CHalfLifeRules::PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
float CHalfLifeRules::FlWeaponRespawnTime(CBasePlayerItem *pWeapon)
2015-10-25 16:07:56 +01:00
{
return -1;
}
float CHalfLifeRules::FlWeaponTryRespawn(CBasePlayerItem *pWeapon)
2015-10-25 16:07:56 +01:00
{
return 0;
}
Vector CHalfLifeRules::VecWeaponRespawnSpot(CBasePlayerItem *pWeapon)
2015-10-25 16:07:56 +01:00
{
return pWeapon->pev->origin;
}
int CHalfLifeRules::WeaponShouldRespawn(CBasePlayerItem *pWeapon)
2015-10-25 16:07:56 +01:00
{
return GR_WEAPON_RESPAWN_NO;
}
BOOL CHalfLifeRules::CanHaveItem(CBasePlayer *pPlayer, CItem *pItem)
2015-10-25 16:07:56 +01:00
{
return TRUE;
}
void CHalfLifeRules::PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
int CHalfLifeRules::ItemShouldRespawn(CItem *pItem)
2015-10-25 16:07:56 +01:00
{
return GR_ITEM_RESPAWN_NO;
}
float CHalfLifeRules::FlItemRespawnTime(CItem *pItem)
2015-10-25 16:07:56 +01:00
{
return -1;
}
Vector CHalfLifeRules::VecItemRespawnSpot(CItem *pItem)
2015-10-25 16:07:56 +01:00
{
return pItem->pev->origin;
}
BOOL CHalfLifeRules::IsAllowedToSpawn(CBaseEntity *pEntity)
2015-10-25 16:07:56 +01:00
{
return TRUE;
}
void CHalfLifeRules::PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount)
2015-10-25 16:07:56 +01:00
{
2015-10-25 16:07:56 +01:00
}
int CHalfLifeRules::AmmoShouldRespawn(CBasePlayerAmmo *pAmmo)
2015-10-25 16:07:56 +01:00
{
return GR_AMMO_RESPAWN_NO;
}
float CHalfLifeRules::FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo)
2015-10-25 16:07:56 +01:00
{
return -1;
}
Vector CHalfLifeRules::VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo)
2015-10-25 16:07:56 +01:00
{
return pAmmo->pev->origin;
}
float CHalfLifeRules::FlHealthChargerRechargeTime(void)
2015-10-25 16:07:56 +01:00
{
return 0;
2015-10-25 16:07:56 +01:00
}
int CHalfLifeRules::DeadPlayerWeapons(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
return GR_PLR_DROP_GUN_NO;
}
int CHalfLifeRules::DeadPlayerAmmo(CBasePlayer *pPlayer)
2015-10-25 16:07:56 +01:00
{
return GR_PLR_DROP_AMMO_NO;
}
int CHalfLifeRules::PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget)
2015-10-25 16:07:56 +01:00
{
return GR_NOTTEAMMATE;
}
BOOL CHalfLifeRules::FAllowMonsters(void)
2015-10-25 16:07:56 +01:00
{
return TRUE;
}
edict_t *CHalfLifeRules::GetPlayerSpawnSpot(CBasePlayer *pPlayer)
{
CBaseEntity *pSpawnSpot = UTIL_FindEntityByClassname(NULL, "info_player_start");
if (!pSpawnSpot)
{
ALERT(at_error, "PutClientInServer: no info_player_start on level");
return INDEXENT(0);
}
edict_t *pentSpawnSpot = ENT(pSpawnSpot->pev);
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;
}