From 6c6733a2c3db6355528a6f44f88e9c711f2f8812 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 7 Nov 2017 23:07:33 +0500 Subject: [PATCH] add item_armor and item_helmet implementations. --- dlls/items.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index 45edeb5e..10e28c1c 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -205,12 +205,22 @@ class CItemBattery : public CItem void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_battery.mdl" ); + if( FClassnameIs( pev, "item_helmet" ) ) + SET_MODEL( ENT( pev ), "models/w_helmet.mdl" ); + else if( FClassnameIs( pev, "item_armor" ) ) + SET_MODEL( ENT( pev ), "models/w_armor.mdl" ); + else + SET_MODEL( ENT( pev ), "models/w_battery.mdl" ); CItem::Spawn(); } void Precache( void ) { - PRECACHE_MODEL( "models/w_battery.mdl" ); + if( FClassnameIs( pev, "item_helmet" ) ) + PRECACHE_MODEL( "models/w_helmet.mdl" ); + else if( FClassnameIs( pev, "item_armor" ) ) + PRECACHE_MODEL( "models/w_armor.mdl" ); + else + PRECACHE_MODEL( "models/w_battery.mdl" ); PRECACHE_SOUND( "items/gunpickup2.wav" ); } BOOL MyTouch( CBasePlayer *pPlayer ) @@ -226,7 +236,10 @@ class CItemBattery : public CItem int pct; char szcharge[64]; - pPlayer->pev->armorvalue += gSkillData.batteryCapacity; + if( FClassnameIs( pev, "item_armor" ) ) + pPlayer->pev->armorvalue += gSkillData.batteryCapacity * 1.5; + else + pPlayer->pev->armorvalue += gSkillData.batteryCapacity; pPlayer->pev->armorvalue = Q_min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); @@ -252,7 +265,9 @@ class CItemBattery : public CItem } }; +LINK_ENTITY_TO_CLASS( item_armor, CItemBattery ) LINK_ENTITY_TO_CLASS( item_battery, CItemBattery ) +LINK_ENTITY_TO_CLASS( item_helmet, CItemBattery ) class CItemAntidote : public CItem {