2015-10-25 16:07:56 +01:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
2015-12-27 12:06:55 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****/
|
2015-12-27 12:06:55 +01:00
|
|
|
|
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::Think(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::IsMultiplayer(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::IsDeathmatch(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::IsCoOp(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::FShouldSwitchWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
if (!pPlayer->m_pActiveItem)
|
2015-10-25 16:07:56 +01:00
|
|
|
return TRUE;
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
if (!pPlayer->m_pActiveItem->CanHolster())
|
2015-10-25 16:07:56 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::GetNextBestWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::InitHUD(CBasePlayer *pl)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::ClientDisconnected(edict_t *pClient)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +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;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::PlayerSpawn(CBasePlayer *pPlayer)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +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
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::AllowAutoTargetCrosshair(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
return g_iSkillLevel == SKILL_EASY;
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::PlayerThink(CBasePlayer *pPlayer)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
}
|
2015-10-25 16:07:56 +01:00
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::FPlayerCanRespawn(CBasePlayer *pPlayer)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
float CHalfLifeRules::FlPlayerSpawnTime(CBasePlayer *pPlayer)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
return gpGlobals->time;
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::IPointsForKill(CBasePlayer *pAttacker, CBasePlayer *pKilled)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::PlayerKilled(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::DeathNotice(CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::PlayerGotWeapon(CBasePlayer *pPlayer, CBasePlayerItem *pWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
float CHalfLifeRules::FlWeaponRespawnTime(CBasePlayerItem *pWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
float CHalfLifeRules::FlWeaponTryRespawn(CBasePlayerItem *pWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
Vector CHalfLifeRules::VecWeaponRespawnSpot(CBasePlayerItem *pWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return pWeapon->pev->origin;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::WeaponShouldRespawn(CBasePlayerItem *pWeapon)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return GR_WEAPON_RESPAWN_NO;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::CanHaveItem(CBasePlayer *pPlayer, CItem *pItem)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::PlayerGotItem(CBasePlayer *pPlayer, CItem *pItem)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::ItemShouldRespawn(CItem *pItem)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return GR_ITEM_RESPAWN_NO;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
float CHalfLifeRules::FlItemRespawnTime(CItem *pItem)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
Vector CHalfLifeRules::VecItemRespawnSpot(CItem *pItem)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return pItem->pev->origin;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::IsAllowedToSpawn(CBaseEntity *pEntity)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
void CHalfLifeRules::PlayerGotAmmo(CBasePlayer *pPlayer, char *szName, int iCount)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::AmmoShouldRespawn(CBasePlayerAmmo *pAmmo)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return GR_AMMO_RESPAWN_NO;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
float CHalfLifeRules::FlAmmoRespawnTime(CBasePlayerAmmo *pAmmo)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
Vector CHalfLifeRules::VecAmmoRespawnSpot(CBasePlayerAmmo *pAmmo)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return pAmmo->pev->origin;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
float CHalfLifeRules::FlHealthChargerRechargeTime(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
2015-12-27 12:06:55 +01:00
|
|
|
return 0;
|
2015-10-25 16:07:56 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::DeadPlayerWeapons(CBasePlayer *pPlayer)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return GR_PLR_DROP_GUN_NO;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::DeadPlayerAmmo(CBasePlayer *pPlayer)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return GR_PLR_DROP_AMMO_NO;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
int CHalfLifeRules::PlayerRelationship(CBaseEntity *pPlayer, CBaseEntity *pTarget)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return GR_NOTTEAMMATE;
|
|
|
|
}
|
|
|
|
|
2015-12-27 12:06:55 +01:00
|
|
|
BOOL CHalfLifeRules::FAllowMonsters(void)
|
2015-10-25 16:07:56 +01:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2015-12-27 12:06:55 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|