Team Fortress 2 Source Code as on 22/4/2020
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.

741 lines
36 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: The Half-Life 1 game rules, such as the relationship tables and ammo
  4. // damage cvars.
  5. //
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "hl1_gamerules.h"
  10. #include "ammodef.h"
  11. #ifdef CLIENT_DLL
  12. #else
  13. #include "player.h"
  14. #include "game.h"
  15. #include "gamerules.h"
  16. #include "teamplay_gamerules.h"
  17. #include "hl1_player.h"
  18. #include "voice_gamemgr.h"
  19. #include "hl1mp_weapon_satchel.h"
  20. #endif
  21. REGISTER_GAMERULES_CLASS( CHalfLife1 );
  22. ConVar sk_plr_dmg_crowbar ( "sk_plr_dmg_crowbar", "0", FCVAR_REPLICATED );
  23. ConVar sk_npc_dmg_9mm_bullet ( "sk_npc_dmg_9mm_bullet", "0", FCVAR_REPLICATED );
  24. ConVar sk_plr_dmg_9mm_bullet ( "sk_plr_dmg_9mm_bullet", "0", FCVAR_REPLICATED );
  25. ConVar sk_max_9mm_bullet ( "sk_max_9mm_bullet", "0", FCVAR_REPLICATED );
  26. ConVar sk_npc_dmg_9mmAR_bullet ( "sk_npc_dmg_9mmAR_bullet", "0", FCVAR_REPLICATED );
  27. ConVar sk_plr_dmg_357_bullet ( "sk_plr_dmg_357_bullet", "0", FCVAR_REPLICATED );
  28. ConVar sk_max_357_bullet ( "sk_max_357_bullet", "0", FCVAR_REPLICATED );
  29. ConVar sk_plr_dmg_buckshot ( "sk_plr_dmg_buckshot", "0", FCVAR_REPLICATED );
  30. ConVar sk_max_buckshot ( "sk_max_buckshot", "0", FCVAR_REPLICATED );
  31. ConVar sk_plr_dmg_mp5_grenade ( "sk_plr_dmg_mp5_grenade", "0", FCVAR_REPLICATED );
  32. ConVar sk_max_mp5_grenade ( "sk_max_mp5_grenade", "0", FCVAR_REPLICATED );
  33. ConVar sk_mp5_grenade_radius ( "sk_mp5_grenade_radius", "0", FCVAR_REPLICATED );
  34. ConVar sk_plr_dmg_rpg ( "sk_plr_dmg_rpg", "0", FCVAR_REPLICATED );
  35. ConVar sk_max_rpg_rocket ( "sk_max_rpg_rocket", "0", FCVAR_REPLICATED );
  36. ConVar sk_plr_dmg_xbow_bolt_plr ( "sk_plr_dmg_xbow_bolt_plr", "0", FCVAR_REPLICATED );
  37. ConVar sk_plr_dmg_xbow_bolt_npc ( "sk_plr_dmg_xbow_bolt_npc", "0", FCVAR_REPLICATED );
  38. ConVar sk_max_xbow_bolt ( "sk_max_xbow_bolt", "0", FCVAR_REPLICATED );
  39. ConVar sk_plr_dmg_egon_narrow ( "sk_plr_dmg_egon_narrow", "0", FCVAR_REPLICATED );
  40. ConVar sk_plr_dmg_egon_wide ( "sk_plr_dmg_egon_wide", "0", FCVAR_REPLICATED );
  41. ConVar sk_max_uranium ( "sk_max_uranium", "0", FCVAR_REPLICATED );
  42. ConVar sk_plr_dmg_gauss ( "sk_plr_dmg_gauss", "0", FCVAR_REPLICATED );
  43. ConVar sk_plr_dmg_grenade ( "sk_plr_dmg_grenade", "0", FCVAR_REPLICATED );
  44. ConVar sk_max_grenade ( "sk_max_grenade", "0", FCVAR_REPLICATED );
  45. ConVar sk_plr_dmg_hornet ( "sk_plr_dmg_hornet", "0", FCVAR_REPLICATED );
  46. ConVar sk_npc_dmg_hornet ( "sk_npc_dmg_hornet", "0", FCVAR_REPLICATED );
  47. ConVar sk_max_hornet ( "sk_max_hornet", "0", FCVAR_REPLICATED );
  48. ConVar sk_max_snark ( "sk_max_snark", "0", FCVAR_REPLICATED );
  49. ConVar sk_plr_dmg_tripmine ( "sk_plr_dmg_tripmine", "0", FCVAR_REPLICATED );
  50. ConVar sk_max_tripmine ( "sk_max_tripmine", "0", FCVAR_REPLICATED );
  51. ConVar sk_plr_dmg_satchel ( "sk_plr_dmg_satchel", "0", FCVAR_REPLICATED );
  52. ConVar sk_max_satchel ( "sk_max_satchel", "0", FCVAR_REPLICATED );
  53. ConVar sk_npc_dmg_12mm_bullet ( "sk_npc_dmg_12mm_bullet", "0", FCVAR_REPLICATED );
  54. ConVar sk_mp_dmg_multiplier ( "sk_mp_dmg_multiplier", "2.0" );
  55. // Damage Queries.
  56. //-----------------------------------------------------------------------------
  57. // Purpose:
  58. //-----------------------------------------------------------------------------
  59. int CHalfLife1::Damage_GetShowOnHud( void )
  60. {
  61. int iDamage = (DMG_POISON | DMG_ACID | DMG_DISSOLVE/*DMG_FREEZE | DMG_SLOWFREEZE*/ | DMG_DROWN | DMG_BURN | DMG_SLOWBURN | DMG_NERVEGAS | DMG_RADIATION | DMG_SHOCK);
  62. return iDamage;
  63. }
  64. #ifndef CLIENT_DLL
  65. extern bool g_fGameOver;
  66. const char *CHalfLife1::GetGameDescription( void )
  67. {
  68. if ( IsMultiplayer() )
  69. {
  70. return "Half-Life 1: Deathmatch";
  71. }
  72. else
  73. {
  74. return "Half-Life 1";
  75. }
  76. }
  77. class CVoiceGameMgrHelper : public IVoiceGameMgrHelper
  78. {
  79. public:
  80. virtual bool CanPlayerHearPlayer( CBasePlayer *pListener, CBasePlayer *pTalker, bool &bProximity )
  81. {
  82. return true;
  83. }
  84. };
  85. CVoiceGameMgrHelper g_VoiceGameMgrHelper;
  86. IVoiceGameMgrHelper *g_pVoiceGameMgrHelper = &g_VoiceGameMgrHelper;
  87. //-----------------------------------------------------------------------------
  88. // Purpose:
  89. // Input :
  90. // Output :
  91. //-----------------------------------------------------------------------------
  92. CHalfLife1::CHalfLife1()
  93. {
  94. }
  95. //-----------------------------------------------------------------------------
  96. // Purpose: called each time a player uses a "cmd" command
  97. // Input : *pEdict - the player who issued the command
  98. // Use engine.Cmd_Argv, engine.Cmd_Argv, and engine.Cmd_Argc to get
  99. // pointers the character string command.
  100. //-----------------------------------------------------------------------------
  101. bool CHalfLife1::ClientCommand( CBaseEntity *pEdict, const CCommand &args )
  102. {
  103. if( BaseClass::ClientCommand( pEdict, args ) )
  104. return true;
  105. CHL1_Player *pPlayer = (CHL1_Player *) pEdict;
  106. if ( pPlayer->ClientCommand( args ) )
  107. return true;
  108. return false;
  109. }
  110. //-----------------------------------------------------------------------------
  111. // Purpose: Player has just spawned. Equip them.
  112. //-----------------------------------------------------------------------------
  113. void CHalfLife1::PlayerSpawn( CBasePlayer *pPlayer )
  114. {
  115. // pPlayer->EquipSuit();
  116. }
  117. //-----------------------------------------------------------------------------
  118. // Purpose: MULTIPLAYER BODY QUE HANDLING
  119. //-----------------------------------------------------------------------------
  120. class CCorpse : public CBaseAnimating
  121. {
  122. DECLARE_CLASS( CCorpse, CBaseAnimating );
  123. public:
  124. DECLARE_SERVERCLASS();
  125. virtual int ObjectCaps( void ) { return FCAP_DONT_SAVE; }
  126. public:
  127. CNetworkVar( int, m_nReferencePlayer );
  128. };
  129. IMPLEMENT_SERVERCLASS_ST(CCorpse, DT_Corpse)
  130. SendPropInt( SENDINFO(m_nReferencePlayer), 10, SPROP_UNSIGNED )
  131. END_SEND_TABLE()
  132. LINK_ENTITY_TO_CLASS( bodyque, CCorpse );
  133. CCorpse *g_pBodyQueueHead;
  134. void InitBodyQue(void)
  135. {
  136. CCorpse *pEntity = ( CCorpse * )CreateEntityByName( "bodyque" );
  137. pEntity->AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES );
  138. g_pBodyQueueHead = pEntity;
  139. CCorpse *p = g_pBodyQueueHead;
  140. // Reserve 3 more slots for dead bodies
  141. for ( int i = 0; i < 3; i++ )
  142. {
  143. CCorpse *next = ( CCorpse * )CreateEntityByName( "bodyque" );
  144. next->AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES );
  145. p->SetOwnerEntity( next );
  146. p = next;
  147. }
  148. p->SetOwnerEntity( g_pBodyQueueHead );
  149. }
  150. //-----------------------------------------------------------------------------
  151. // Purpose: make a body que entry for the given ent so the ent can be respawned elsewhere
  152. // GLOBALS ASSUMED SET: g_eoBodyQueueHead
  153. //-----------------------------------------------------------------------------
  154. void CopyToBodyQue( CBaseAnimating *pCorpse )
  155. {
  156. if ( pCorpse->IsEffectActive( EF_NODRAW ) )
  157. return;
  158. CCorpse *pHead = g_pBodyQueueHead;
  159. pHead->CopyAnimationDataFrom( pCorpse );
  160. pHead->SetMoveType( MOVETYPE_FLYGRAVITY );
  161. pHead->SetAbsVelocity( pCorpse->GetAbsVelocity() );
  162. pHead->ClearFlags();
  163. pHead->m_nReferencePlayer = ENTINDEX( pCorpse );
  164. pHead->SetLocalAngles( pCorpse->GetAbsAngles() );
  165. UTIL_SetOrigin(pHead, pCorpse->GetAbsOrigin());
  166. UTIL_SetSize(pHead, pCorpse->WorldAlignMins(), pCorpse->WorldAlignMaxs());
  167. g_pBodyQueueHead = (CCorpse *)pHead->GetOwnerEntity();
  168. }
  169. //------------------------------------------------------------------------------
  170. // Purpose : Initialize all default class relationships
  171. // Input :
  172. // Output :
  173. //------------------------------------------------------------------------------
  174. void CHalfLife1::InitDefaultAIRelationships( void )
  175. {
  176. int i, j;
  177. // Allocate memory for default relationships
  178. CBaseCombatCharacter::AllocateDefaultRelationships();
  179. // --------------------------------------------------------------
  180. // First initialize table so we can report missing relationships
  181. // --------------------------------------------------------------
  182. for (i=0;i<NUM_AI_CLASSES;i++)
  183. {
  184. for (j=0;j<NUM_AI_CLASSES;j++)
  185. {
  186. // By default all relationships are neutral of priority zero
  187. CBaseCombatCharacter::SetDefaultRelationship( (Class_T)i, (Class_T)j, D_NU, 0 );
  188. }
  189. }
  190. // ------------------------------------------------------------
  191. // > CLASS_NONE
  192. // ------------------------------------------------------------
  193. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_NONE, D_NU, 0 );
  194. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_PLAYER, D_NU, 0 );
  195. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_HUMAN_PASSIVE, D_NU, 0 );
  196. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_PLAYER_ALLY, D_NU, 0 );
  197. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_ALIEN_PREY, D_NU, 0 );
  198. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_ALIEN_MILITARY, D_NU, 0 );
  199. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_ALIEN_MONSTER, D_NU, 0 );
  200. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_ALIEN_PREDATOR, D_NU, 0 );
  201. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_HUMAN_MILITARY, D_NU, 0 );
  202. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_MACHINE, D_NU, 0 );
  203. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  204. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  205. CBaseCombatCharacter::SetDefaultRelationship( CLASS_NONE, CLASS_INSECT, D_NU, 0 );
  206. // ------------------------------------------------------------
  207. // > CLASS_HUMAN_PASSIVE
  208. // ------------------------------------------------------------
  209. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_NONE, D_NU, 0 );
  210. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_PLAYER, D_LI, 0 );
  211. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_HUMAN_PASSIVE, D_LI, 0 );
  212. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_PLAYER_ALLY, D_LI, 0 );
  213. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_ALIEN_PREY, D_FR, 0 );
  214. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_ALIEN_MILITARY, D_FR, 0 );
  215. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_ALIEN_MONSTER, D_HT, 0 );
  216. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_ALIEN_PREDATOR, D_FR, 0 );
  217. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_HUMAN_MILITARY, D_HT, 0 );
  218. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_MACHINE, D_NU, 0 );
  219. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  220. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  221. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_PASSIVE, CLASS_INSECT, D_NU, 0 );
  222. // ------------------------------------------------------------
  223. // > CLASS_PLAYER
  224. // ------------------------------------------------------------
  225. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_NONE, D_NU, 0 );
  226. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_PLAYER, D_LI, 0 );
  227. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_HUMAN_PASSIVE, D_LI, 0 );
  228. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_PLAYER_ALLY, D_LI, 0 );
  229. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_ALIEN_PREY, D_HT, 0 );
  230. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_ALIEN_MILITARY, D_HT, 0 );
  231. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_ALIEN_MONSTER, D_HT, 0 );
  232. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_ALIEN_PREDATOR, D_HT, 0 );
  233. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_HUMAN_MILITARY, D_HT, 0 );
  234. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_MACHINE, D_HT, 0 );
  235. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_ALIEN_BIOWEAPON, D_HT, 0 );
  236. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_PLAYER_BIOWEAPON, D_HT, 0 );
  237. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER, CLASS_INSECT, D_NU, 0 );
  238. // ------------------------------------------------------------
  239. // > CLASS_PLAYER_ALLY
  240. // ------------------------------------------------------------
  241. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_NONE, D_NU, 0 );
  242. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_PLAYER, D_LI, 0 );
  243. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_HUMAN_PASSIVE, D_LI, 0 );
  244. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_PLAYER_ALLY, D_LI, 0 );
  245. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_ALIEN_PREY, D_HT, 0 );
  246. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_ALIEN_MILITARY, D_HT, 0 );
  247. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_ALIEN_MONSTER, D_HT, 0 );
  248. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_ALIEN_PREDATOR, D_HT, 0 );
  249. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_HUMAN_MILITARY, D_HT, 0 );
  250. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_MACHINE, D_HT, 0 );
  251. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  252. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  253. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_ALLY, CLASS_INSECT, D_NU, 0 );
  254. // ------------------------------------------------------------
  255. // > CLASS_ALIEN_PREY
  256. // ------------------------------------------------------------
  257. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_NONE, D_NU, 0 );
  258. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_PLAYER, D_HT, 0 );
  259. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_PLAYER_ALLY, D_HT, 0 );
  260. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  261. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_ALIEN_PREY, D_NU, 0 );
  262. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_ALIEN_MILITARY, D_NU, 0 );
  263. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_ALIEN_MONSTER, D_NU, 0 );
  264. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_ALIEN_PREDATOR, D_FR, 0 );
  265. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_HUMAN_MILITARY, D_HT, 0 );
  266. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_MACHINE, D_NU, 0 );
  267. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  268. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  269. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREY, CLASS_INSECT, D_NU, 0 );
  270. // ------------------------------------------------------------
  271. // > CLASS_ALIEN_MILITARY
  272. // ------------------------------------------------------------
  273. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_NONE, D_NU, 0 );
  274. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_PLAYER, D_HT, 0 );
  275. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_PLAYER_ALLY, D_HT, 0 );
  276. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  277. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_ALIEN_PREY, D_NU, 0 );
  278. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_ALIEN_MILITARY, D_NU, 0 );
  279. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_ALIEN_MONSTER, D_NU, 0 );
  280. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_ALIEN_PREDATOR, D_NU, 0 );
  281. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_HUMAN_MILITARY, D_HT, 0 );
  282. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_MACHINE, D_HT, 0 );
  283. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  284. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  285. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MILITARY, CLASS_INSECT, D_NU, 0 );
  286. // ------------------------------------------------------------
  287. // > CLASS_ALIEN_MONSTER
  288. // ------------------------------------------------------------
  289. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_NONE, D_NU, 0 );
  290. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_PLAYER, D_HT, 0 );
  291. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_PLAYER_ALLY, D_HT, 0 );
  292. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  293. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_ALIEN_PREY, D_NU, 0 );
  294. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_ALIEN_MILITARY, D_NU, 0 );
  295. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_ALIEN_MONSTER, D_NU, 0 );
  296. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_ALIEN_PREDATOR, D_NU, 0 );
  297. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_HUMAN_MILITARY, D_HT, 0 );
  298. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_MACHINE, D_HT, 0 );
  299. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  300. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  301. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_MONSTER, CLASS_INSECT, D_NU, 0 );
  302. // ------------------------------------------------------------
  303. // > CLASS_ALIEN_PREDATOR
  304. // ------------------------------------------------------------
  305. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_NONE, D_NU, 0 );
  306. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_PLAYER, D_HT, 0 );
  307. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_PLAYER_ALLY, D_HT, 0 );
  308. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  309. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_ALIEN_PREY, D_HT, 0 );
  310. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_ALIEN_MILITARY, D_NU, 0 );
  311. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_ALIEN_MONSTER, D_NU, 0 );
  312. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_ALIEN_PREDATOR, D_NU, 0 );
  313. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_HUMAN_MILITARY, D_HT, 0 );
  314. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_MACHINE, D_NU, 0 );
  315. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  316. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  317. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_PREDATOR, CLASS_INSECT, D_NU, 0 );
  318. // ------------------------------------------------------------
  319. // > CLASS_HUMAN_MILITARY
  320. // ------------------------------------------------------------
  321. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_NONE, D_NU, 0 );
  322. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_PLAYER, D_HT, 0 );
  323. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_PLAYER_ALLY, D_HT, 0 );
  324. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  325. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_ALIEN_PREY, D_HT, 0 );
  326. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_ALIEN_MILITARY, D_HT, 0 );
  327. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_ALIEN_MONSTER, D_HT, 0 );
  328. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_ALIEN_PREDATOR, D_HT, 0 );
  329. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_HUMAN_MILITARY, D_NU, 0 );
  330. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_MACHINE, D_NU, 0 );
  331. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  332. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  333. CBaseCombatCharacter::SetDefaultRelationship( CLASS_HUMAN_MILITARY, CLASS_INSECT, D_NU, 0 );
  334. // ------------------------------------------------------------
  335. // > CLASS_MACHINE
  336. // ------------------------------------------------------------
  337. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_NONE, D_NU, 0 );
  338. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_MACHINE, D_NU, 0 );
  339. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_PLAYER, D_HT, 0 );
  340. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  341. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_HUMAN_MILITARY, D_NU, 0 );
  342. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_ALIEN_MILITARY, D_HT, 0 );
  343. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_ALIEN_MONSTER, D_HT, 0 );
  344. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_ALIEN_PREY, D_HT, 0 );
  345. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_ALIEN_PREDATOR, D_HT, 0 );
  346. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_PLAYER_ALLY, D_HT, 0 );
  347. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_ALIEN_BIOWEAPON, D_HT, 0 );
  348. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_PLAYER_BIOWEAPON, D_HT, 0 );
  349. CBaseCombatCharacter::SetDefaultRelationship( CLASS_MACHINE, CLASS_INSECT, D_NU, 0 );
  350. // ------------------------------------------------------------
  351. // > CLASS_ALIEN_BIOWEAPON
  352. // ------------------------------------------------------------
  353. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_NONE, D_NU, 0 );
  354. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_MACHINE, D_NU, 0 );
  355. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_PLAYER, D_HT, 0 );
  356. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  357. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_HUMAN_MILITARY, D_HT, 0 );
  358. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_ALIEN_MILITARY, D_LI, 0 );
  359. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_ALIEN_MONSTER, D_HT, 0 );
  360. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_ALIEN_PREY, D_HT, 0 );
  361. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_ALIEN_PREDATOR, D_NU, 0 );
  362. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_PLAYER_ALLY, D_HT, 0 );
  363. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  364. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_PLAYER_BIOWEAPON, D_HT, 0 );
  365. CBaseCombatCharacter::SetDefaultRelationship( CLASS_ALIEN_BIOWEAPON, CLASS_INSECT, D_NU, 0 );
  366. // ------------------------------------------------------------
  367. // > CLASS_PLAYER_BIOWEAPON
  368. // ------------------------------------------------------------
  369. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_NONE, D_NU, 0 );
  370. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_MACHINE, D_NU, 0 );
  371. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_PLAYER, D_HT, 0 );
  372. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_HUMAN_PASSIVE, D_HT, 0 );
  373. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_HUMAN_MILITARY, D_HT, 0 );
  374. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_ALIEN_MILITARY, D_HT, 0 );
  375. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_ALIEN_MONSTER, D_HT, 0 );
  376. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_ALIEN_PREY, D_HT, 0 );
  377. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_ALIEN_PREDATOR, D_HT, 0 );
  378. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_PLAYER_ALLY, D_HT, 0 );
  379. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_ALIEN_BIOWEAPON, D_HT, 0 );
  380. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  381. CBaseCombatCharacter::SetDefaultRelationship( CLASS_PLAYER_BIOWEAPON, CLASS_INSECT, D_NU, 0 );
  382. // ------------------------------------------------------------
  383. // > CLASS_INSECT
  384. // ------------------------------------------------------------
  385. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_NONE, D_FR, 0 );
  386. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_MACHINE, D_FR, 0 );
  387. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_PLAYER, D_FR, 0 );
  388. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_HUMAN_PASSIVE, D_FR, 0 );
  389. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_HUMAN_MILITARY, D_FR, 0 );
  390. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_ALIEN_MILITARY, D_NU, 0 );
  391. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_ALIEN_MONSTER, D_FR, 0 );
  392. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_ALIEN_PREY, D_FR, 0 );
  393. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_ALIEN_PREDATOR, D_FR, 0 );
  394. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_PLAYER_ALLY, D_FR, 0 );
  395. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_ALIEN_BIOWEAPON, D_NU, 0 );
  396. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_PLAYER_BIOWEAPON, D_NU, 0 );
  397. CBaseCombatCharacter::SetDefaultRelationship( CLASS_INSECT, CLASS_INSECT, D_NU, 0 );
  398. }
  399. //------------------------------------------------------------------------------
  400. // Purpose : Return classify text for classify type
  401. // Input :
  402. // Output :
  403. //------------------------------------------------------------------------------
  404. const char* CHalfLife1::AIClassText(int classType)
  405. {
  406. switch (classType)
  407. {
  408. case CLASS_NONE: return "CLASS_NONE";
  409. case CLASS_HUMAN_PASSIVE: return "CLASS_HUMAN_PASSIVE";
  410. case CLASS_PLAYER_ALLY: return "CLASS_PLAYER_ALLY";
  411. case CLASS_PLAYER: return "CLASS_PLAYER";
  412. case CLASS_ALIEN_PREY: return "CLASS_ALIEN_PREY";
  413. case CLASS_ALIEN_MILITARY: return "CLASS_ALIEN_MILITARY";
  414. case CLASS_ALIEN_MONSTER: return "CLASS_ALIEN_MONSTER";
  415. case CLASS_ALIEN_PREDATOR: return "CLASS_ALIEN_PREDATOR";
  416. case CLASS_HUMAN_MILITARY: return "CLASS_HUMAN_MILITARY";
  417. case CLASS_MACHINE: return "CLASS_MACHINE";
  418. case CLASS_ALIEN_BIOWEAPON: return "CLASS_ALIEN_BIOWEAPON";
  419. case CLASS_PLAYER_BIOWEAPON: return "CLASS_PLAYER_BIOWEAPON";
  420. default: return "MISSING CLASS in ClassifyText()";
  421. }
  422. }
  423. void CHalfLife1::PlayerThink( CBasePlayer *pPlayer )
  424. {
  425. }
  426. bool CHalfLife1::CanHavePlayerItem( CBasePlayer *pPlayer, CBaseCombatWeapon *pWeapon )
  427. {
  428. if ( FClassnameIs( pWeapon, "weapon_satchel" ) )
  429. {
  430. CWeaponSatchel *satchel = static_cast< CWeaponSatchel * >( pPlayer->Weapon_OwnsThisType( "weapon_satchel" ) );
  431. if ( satchel )
  432. {
  433. if ( satchel->HasChargeDeployed() )
  434. {
  435. return false;
  436. }
  437. }
  438. }
  439. return true;
  440. }
  441. float CHalfLife1::FlPlayerFallDamage( CBasePlayer *pPlayer )
  442. {
  443. CBaseEntity *pGroundEntity = pPlayer->GetGroundEntity();
  444. if( pGroundEntity && pGroundEntity->ClassMatches( "func_breakable" ) )
  445. {
  446. // FIXME touchtrace will be wrong.
  447. pGroundEntity->Touch( pPlayer );
  448. if( pGroundEntity->m_iHealth <= 0 )
  449. {
  450. // The breakable broke when we hit it, don't take falling damage
  451. return 0;
  452. }
  453. }
  454. return BaseClass::FlPlayerFallDamage( pPlayer );
  455. }
  456. class CTraceFilterHitAllExcept : public CTraceFilter
  457. {
  458. public:
  459. // It does have a base, but we'll never network anything below here..
  460. DECLARE_CLASS_NOBASE( CTraceFilterHitAllExcept );
  461. CTraceFilterHitAllExcept( const IHandleEntity *passedict )
  462. {
  463. m_pPassEnt = passedict;
  464. }
  465. bool ShouldHitEntity( IHandleEntity *pServerEntity, int contentsMask )
  466. {
  467. if ( m_pPassEnt && ( m_pPassEnt == pServerEntity ) )
  468. {
  469. return false;
  470. }
  471. return true;
  472. }
  473. private:
  474. const IHandleEntity *m_pPassEnt;
  475. };
  476. void CHalfLife1::RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore )
  477. {
  478. CBaseEntity *pEntity = NULL;
  479. trace_t tr;
  480. float flAdjustedDamage, falloff;
  481. Vector vecSpot;
  482. Vector vecSrc = vecSrcIn;
  483. if ( flRadius )
  484. falloff = info.GetDamage() / flRadius;
  485. else
  486. falloff = 1.0;
  487. int bInWater = (UTIL_PointContents ( vecSrc ) & MASK_WATER) ? true : false;
  488. vecSrc.z += 1;// in case grenade is lying on the ground
  489. // iterate on all entities in the vicinity.
  490. for ( CEntitySphereQuery sphere( vecSrc, flRadius ); ( pEntity = sphere.GetCurrentEntity() ) != NULL; sphere.NextEntity() )
  491. {
  492. if ( pEntity->m_takedamage != DAMAGE_NO )
  493. {
  494. // UNDONE: this should check a damage mask, not an ignore
  495. if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )
  496. {// houndeyes don't hurt other houndeyes with their attack
  497. continue;
  498. }
  499. // blast's don't tavel into or out of water
  500. if (bInWater && pEntity->GetWaterLevel() == 0)
  501. continue;
  502. if (!bInWater && pEntity->GetWaterLevel() == 3)
  503. continue;
  504. // radius damage can only be blocked by the world
  505. vecSpot = pEntity->BodyTarget( vecSrc );
  506. CTraceFilterHitAllExcept traceFilter( info.GetInflictor() );
  507. UTIL_TraceLine( vecSrc, vecSpot, CONTENTS_SOLID, &traceFilter, &tr );
  508. if ( tr.fraction == 1.0 || tr.m_pEnt == pEntity )
  509. {// the explosion can 'see' this entity, so hurt them!
  510. if (tr.startsolid)
  511. {
  512. // if we're stuck inside them, fixup the position and distance
  513. tr.endpos = vecSrc;
  514. tr.fraction = 0.0;
  515. }
  516. // decrease damage for an ent that's farther from the bomb.
  517. flAdjustedDamage = ( vecSrc - tr.endpos ).Length() * falloff;
  518. flAdjustedDamage = info.GetDamage() - flAdjustedDamage;
  519. if ( flAdjustedDamage > 0 )
  520. {
  521. CTakeDamageInfo adjustedInfo = info;
  522. adjustedInfo.SetDamage( flAdjustedDamage );
  523. Vector vecDir = vecSpot - vecSrc;
  524. VectorNormalize( vecDir );
  525. // If we don't have a damage force, manufacture one
  526. if ( adjustedInfo.GetDamagePosition() == vec3_origin || adjustedInfo.GetDamageForce() == vec3_origin )
  527. {
  528. CalculateExplosiveDamageForce( &adjustedInfo, vecDir, vecSrc );
  529. }
  530. else
  531. {
  532. // Assume the force passed in is the maximum force. Decay it based on falloff.
  533. float flForce = adjustedInfo.GetDamageForce().Length() * falloff;
  534. adjustedInfo.SetDamageForce( vecDir * flForce );
  535. adjustedInfo.SetDamagePosition( vecSrc );
  536. }
  537. if (tr.fraction != 1.0)
  538. {
  539. ClearMultiDamage( );
  540. Vector dir = tr.endpos - vecSrc;
  541. VectorNormalize( dir );
  542. pEntity->DispatchTraceAttack( adjustedInfo, dir, &tr );
  543. ApplyMultiDamage();
  544. }
  545. else
  546. {
  547. pEntity->TakeDamage( adjustedInfo );
  548. }
  549. // Now hit all triggers along the way that respond to damage...
  550. Vector dir = tr.endpos - vecSrc;
  551. pEntity->TraceAttackToTriggers( adjustedInfo, vecSrc, tr.endpos, dir );
  552. }
  553. }
  554. }
  555. }
  556. }
  557. #endif
  558. // ------------------------------------------------------------------------------------- //
  559. // CHalfLife1 shared implementation.
  560. // ------------------------------------------------------------------------------------- //
  561. bool CHalfLife1::ShouldCollide( int collisionGroup0, int collisionGroup1 )
  562. {
  563. // HL2 treats movement and tracing against players the same, so just remap here
  564. if ( collisionGroup0 == COLLISION_GROUP_PLAYER_MOVEMENT )
  565. {
  566. collisionGroup0 = COLLISION_GROUP_PLAYER;
  567. }
  568. if( collisionGroup1 == COLLISION_GROUP_PLAYER_MOVEMENT )
  569. {
  570. collisionGroup1 = COLLISION_GROUP_PLAYER;
  571. }
  572. if ( collisionGroup0 > collisionGroup1 )
  573. {
  574. // swap so that lowest is always first
  575. int tmp = collisionGroup0;
  576. collisionGroup0 = collisionGroup1;
  577. collisionGroup1 = tmp;
  578. }
  579. return BaseClass::ShouldCollide( collisionGroup0, collisionGroup1 );
  580. }
  581. // ------------------------------------------------------------------------------------- //
  582. // Global functions.
  583. // ------------------------------------------------------------------------------------- //
  584. // shared ammo definition
  585. // JAY: Trying to make a more physical bullet response
  586. #define BULLET_MASS_GRAINS_TO_LB(grains) (0.002285*(grains)/16.0f)
  587. #define BULLET_MASS_GRAINS_TO_KG(grains) lbs2kg(BULLET_MASS_GRAINS_TO_LB(grains))
  588. // exaggerate all of the forces, but use real numbers to keep them consistent
  589. #define BULLET_IMPULSE_EXAGGERATION 3
  590. // convert a velocity in ft/sec and a mass in grains to an impulse in kg in/s
  591. #define BULLET_IMPULSE(grains, ftpersec) ((ftpersec)*12*BULLET_MASS_GRAINS_TO_KG(grains)*BULLET_IMPULSE_EXAGGERATION)
  592. CAmmoDef *GetAmmoDef()
  593. {
  594. static CAmmoDef def;
  595. static bool bInitted = false;
  596. if ( !bInitted )
  597. {
  598. bInitted = true;
  599. def.AddAmmoType( "9mmRound", DMG_BULLET | DMG_NEVERGIB, TRACER_LINE, "sk_plr_dmg_9mm_bullet", "sk_npc_dmg_9mm_bullet","sk_max_9mm_bullet", BULLET_IMPULSE(500, 1325), 0 );
  600. def.AddAmmoType( "357Round", DMG_BULLET | DMG_NEVERGIB, TRACER_NONE, "sk_plr_dmg_357_bullet", NULL, "sk_max_357_bullet", BULLET_IMPULSE(650, 6000), 0 );
  601. def.AddAmmoType( "Buckshot", DMG_BULLET | DMG_BUCKSHOT, TRACER_LINE, "sk_plr_dmg_buckshot", NULL, "sk_max_buckshot", BULLET_IMPULSE(200, 1200), 0 );
  602. def.AddAmmoType( "XBowBolt", DMG_BULLET | DMG_NEVERGIB, TRACER_LINE, "sk_plr_dmg_xbow_bolt_plr",NULL, "sk_max_xbow_bolt", BULLET_IMPULSE( 200, 1200), 0 );
  603. def.AddAmmoType( "MP5_Grenade", DMG_BURN | DMG_BLAST, TRACER_NONE, "sk_plr_dmg_mp5_grenade", NULL, "sk_max_mp5_grenade", 0, 0 );
  604. def.AddAmmoType( "RPG_Rocket", DMG_BURN | DMG_BLAST, TRACER_NONE, "sk_plr_dmg_rpg", NULL, "sk_max_rpg_rocket", 0, 0 );
  605. def.AddAmmoType( "Uranium", DMG_ENERGYBEAM, TRACER_NONE, NULL, NULL, "sk_max_uranium", 0, 0 );
  606. def.AddAmmoType( "Grenade", DMG_BURN | DMG_BLAST, TRACER_NONE, "sk_plr_dmg_grenade", NULL, "sk_max_grenade", 0, 0 );
  607. def.AddAmmoType( "Hornet", DMG_BULLET, TRACER_NONE, "sk_plr_dmg_hornet", "sk_npc_dmg_hornet", "sk_max_hornet", BULLET_IMPULSE(100, 1200), 0 );
  608. def.AddAmmoType( "Snark", DMG_SLASH, TRACER_NONE, "sk_snark_dmg_bite", NULL, "sk_max_snark", 0, 0 );
  609. def.AddAmmoType( "TripMine", DMG_BURN | DMG_BLAST, TRACER_NONE, "sk_plr_dmg_tripmine", NULL, "sk_max_tripmine", 0, 0 );
  610. def.AddAmmoType( "Satchel", DMG_BURN | DMG_BLAST, TRACER_NONE, "sk_plr_dmg_satchel", NULL, "sk_max_satchel", 0, 0 );
  611. def.AddAmmoType( "12mmRound", DMG_BULLET | DMG_NEVERGIB, TRACER_LINE, NULL, "sk_npc_dmg_12mm_bullet",NULL, BULLET_IMPULSE(300, 1200), 0 );
  612. def.AddAmmoType( "Gravity", DMG_CRUSH, TRACER_NONE, 0, 0, 8, 0, 0 );
  613. }
  614. return &def;
  615. }