Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

338 lines
10 KiB

9 years ago
/***
*
* 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.
*
****/
//
// teamplay_gamerules.cpp
//
9 years ago
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "player.h"
#include "weapons.h"
#include "gamerules.h"
#include "skill.h"
#include "items.h"
extern DLL_GLOBAL CGameRules *g_pGameRules;
extern DLL_GLOBAL BOOL g_fGameOver;
extern int gmsgDeathMsg; // client dll messages
extern int gmsgScoreInfo;
extern int gmsgMOTD;
//=========================================================
//=========================================================
CHalfLifeRules::CHalfLifeRules( void )
{
RefreshSkillData();
}
//=========================================================
//=========================================================
9 years ago
void CHalfLifeRules::Think( void )
9 years ago
{
}
//=========================================================
//=========================================================
BOOL CHalfLifeRules::IsMultiplayer( void )
{
return FALSE;
}
//=========================================================
//=========================================================
9 years ago
BOOL CHalfLifeRules::IsDeathmatch( void )
9 years ago
{
return FALSE;
}
//=========================================================
//=========================================================
BOOL CHalfLifeRules::IsCoOp( void )
{
return FALSE;
}
//=========================================================
//=========================================================
BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon )
{
9 years ago
if( !pPlayer->m_pActiveItem )
9 years ago
{
// player doesn't have an active item!
return TRUE;
}
if( !pPlayer->m_iAutoWepSwitch )
{
return FALSE;
}
if( pPlayer->m_iAutoWepSwitch == 2
&& pPlayer->m_afButtonLast & ( IN_ATTACK | IN_ATTACK2 ) )
{
return FALSE;
}
9 years ago
if( !pPlayer->m_pActiveItem->CanHolster() )
9 years ago
{
return FALSE;
}
return TRUE;
}
//=========================================================
//=========================================================
9 years ago
BOOL CHalfLifeRules::GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon )
9 years ago
{
return FALSE;
}
//=========================================================
//=========================================================
9 years ago
BOOL CHalfLifeRules::ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] )
9 years ago
{
return TRUE;
}
9 years ago
void CHalfLifeRules::InitHUD( CBasePlayer *pl )
9 years ago
{
}
//=========================================================
//=========================================================
9 years ago
void CHalfLifeRules::ClientDisconnected( edict_t *pClient )
9 years ago
{
}
//=========================================================
//=========================================================
float CHalfLifeRules::FlPlayerFallDamage( CBasePlayer *pPlayer )
{
// subtract off the speed at which a player is allowed to fall without being hurt,
// so damage will be based on speed beyond that, not the entire fall
pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED;
return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED;
}
//=========================================================
//=========================================================
9 years ago
void CHalfLifeRules::PlayerSpawn( CBasePlayer *pPlayer )
9 years ago
{
}
//=========================================================
//=========================================================
9 years ago
BOOL CHalfLifeRules::AllowAutoTargetCrosshair( void )
9 years ago
{
return ( g_iSkillLevel == SKILL_EASY );
}
//=========================================================
//=========================================================
9 years ago
void CHalfLifeRules::PlayerThink( CBasePlayer *pPlayer )
9 years ago
{
}
//=========================================================
//=========================================================
9 years ago
BOOL CHalfLifeRules::FPlayerCanRespawn( CBasePlayer *pPlayer )
9 years ago
{
return TRUE;
}
//=========================================================
//=========================================================
9 years ago
float CHalfLifeRules::FlPlayerSpawnTime( CBasePlayer *pPlayer )
9 years ago
{
return gpGlobals->time;//now!
}
//=========================================================
// IPointsForKill - how many points awarded to anyone
// that kills this player?
//=========================================================
9 years ago
int CHalfLifeRules::IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled )
9 years ago
{
return 1;
}
//=========================================================
// PlayerKilled - someone/something killed this player
//=========================================================
9 years ago
void CHalfLifeRules::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
9 years ago
{
}
//=========================================================
// Deathnotice
//=========================================================
void CHalfLifeRules::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
{
}
//=========================================================
// PlayerGotWeapon - player has grabbed a weapon that was
// sitting in the world
//=========================================================
9 years ago
void CHalfLifeRules::PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon )
9 years ago
{
}
//=========================================================
// FlWeaponRespawnTime - what is the time in the future
// at which this weapon may spawn?
//=========================================================
9 years ago
float CHalfLifeRules::FlWeaponRespawnTime( CBasePlayerItem *pWeapon )
9 years ago
{
return -1;
}
//=========================================================
// FlWeaponRespawnTime - Returns 0 if the weapon can respawn
// now, otherwise it returns the time at which it can try
// to spawn again.
//=========================================================
9 years ago
float CHalfLifeRules::FlWeaponTryRespawn( CBasePlayerItem *pWeapon )
9 years ago
{
return 0;
}
//=========================================================
// VecWeaponRespawnSpot - where should this weapon spawn?
// Some game variations may choose to randomize spawn locations
//=========================================================
9 years ago
Vector CHalfLifeRules::VecWeaponRespawnSpot( CBasePlayerItem *pWeapon )
9 years ago
{
return pWeapon->pev->origin;
}
//=========================================================
// WeaponShouldRespawn - any conditions inhibiting the
// respawning of this weapon?
//=========================================================
9 years ago
int CHalfLifeRules::WeaponShouldRespawn( CBasePlayerItem *pWeapon )
9 years ago
{
return GR_WEAPON_RESPAWN_NO;
}
//=========================================================
//=========================================================
BOOL CHalfLifeRules::CanHaveItem( CBasePlayer *pPlayer, CItem *pItem )
{
return TRUE;
}
//=========================================================
//=========================================================
void CHalfLifeRules::PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem )
{
}
//=========================================================
//=========================================================
int CHalfLifeRules::ItemShouldRespawn( CItem *pItem )
{
return GR_ITEM_RESPAWN_NO;
}
//=========================================================
// At what time in the future may this Item respawn?
//=========================================================
float CHalfLifeRules::FlItemRespawnTime( CItem *pItem )
{
return -1;
}
//=========================================================
// Where should this item respawn?
// Some game variations may choose to randomize spawn locations
//=========================================================
Vector CHalfLifeRules::VecItemRespawnSpot( CItem *pItem )
{
return pItem->pev->origin;
}
//=========================================================
//=========================================================
BOOL CHalfLifeRules::IsAllowedToSpawn( CBaseEntity *pEntity )
{
return TRUE;
}
//=========================================================
//=========================================================
void CHalfLifeRules::PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount )
{
}
//=========================================================
//=========================================================
int CHalfLifeRules::AmmoShouldRespawn( CBasePlayerAmmo *pAmmo )
{
return GR_AMMO_RESPAWN_NO;
}
//=========================================================
//=========================================================
float CHalfLifeRules::FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo )
{
return -1;
}
//=========================================================
//=========================================================
Vector CHalfLifeRules::VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo )
{
return pAmmo->pev->origin;
}
//=========================================================
//=========================================================
float CHalfLifeRules::FlHealthChargerRechargeTime( void )
{
return 0;// don't recharge
}
//=========================================================
//=========================================================
int CHalfLifeRules::DeadPlayerWeapons( CBasePlayer *pPlayer )
{
return GR_PLR_DROP_GUN_NO;
}
//=========================================================
//=========================================================
int CHalfLifeRules::DeadPlayerAmmo( CBasePlayer *pPlayer )
{
return GR_PLR_DROP_AMMO_NO;
}
//=========================================================
//=========================================================
int CHalfLifeRules::PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget )
{
// why would a single player in half life need this?
return GR_NOTTEAMMATE;
}
//=========================================================
//=========================================================
9 years ago
BOOL CHalfLifeRules::FAllowMonsters( void )
9 years ago
{
return TRUE;
}