/*** * * 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. * * This source code contains proprietary and confidential information of * Valve LLC and its suppliers. Access to this code is restricted to * persons who have executed a written SDK license with Valve. Any access, * use or distribution of this code by or to any unlicensed person is illegal. * ****/ //========================================================= // Wheelchair monster //========================================================= #include "zombie.h" #define WHEELCHAIR_AE_BLOODSQUIRT 1 #define WHEELCHAIR_AE_WALK 1011 #define WHEELCHAIR_FLINCH_DELAY 5.0f class CWheelchair : public CZombie { public: void Spawn( void ); void Precache( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); int IgnoreConditions(); void AlertSound( void ); void IdleSound( void ); static const char *pAttackSounds[]; static const char *pIdleSounds[]; static const char *pAlertSounds[]; static const char *pPainSounds[]; static const char *pAttackHitSounds[]; static const char *pAttackMissSounds[]; int m_vomitSprite; }; LINK_ENTITY_TO_CLASS( monster_wheelchair, CWheelchair ); const char *CWheelchair::pAttackHitSounds[] = { "zombie/claw_strike1.wav", "zombie/claw_strike2.wav", "zombie/claw_strike3.wav", }; const char *CWheelchair::pAttackMissSounds[] = { "zombie/claw_miss1.wav", "zombie/claw_miss2.wav", }; const char *CWheelchair::pAttackSounds[] = { "zombie/zo_attack1.wav", "zombie/zo_attack2.wav", }; const char *CWheelchair::pIdleSounds[] = { "wheelchair/wheel01.wav", "wheelchair/wheel02.wav", "wheelchair/wheel03.wav", "wheelchair/wheel04.wav" }; const char *CWheelchair::pAlertSounds[] = { "zombie/zo_alert10.wav", "zombie/zo_alert20.wav", "zombie/zo_alert30.wav", }; const char *CWheelchair::pPainSounds[] = { "zombie/zo_pain1.wav", "zombie/zo_pain2.wav", }; void CWheelchair:: AlertSound( void ) { /*int pitch = 95 + RANDOM_LONG(0,9); EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM, 0, pitch );*/ } void CWheelchair :: IdleSound( void ) { // Play a random idle sound EMIT_SOUND( ENT(pev), CHAN_BODY, pIdleSounds[ RANDOM_LONG(0,ARRAYSIZE(pIdleSounds)-1) ], 1.0, ATTN_NORM); } //========================================================= // HandleAnimEvent - catches the monster-specific messages // that occur when tagged animation frames are played. //========================================================= void CWheelchair :: HandleAnimEvent( MonsterEvent_t *pEvent ) { switch( pEvent->event ) { case WHEELCHAIR_AE_WALK: IdleSound(); break; case WHEELCHAIR_AE_BLOODSQUIRT: { EMIT_SOUND_DYN ( ENT(pev), CHAN_BODY, "wheelchair/wcm_squirt.wav", 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); WRITE_BYTE( TE_BLOODSPRITE ); WRITE_COORD( pev->origin.x ); // pos WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z + 40 ); WRITE_SHORT( m_vomitSprite ); // sprite1 WRITE_SHORT( m_vomitSprite ); // sprite2 WRITE_BYTE ( BLOOD_COLOR_RED ); // color WRITE_BYTE ( 6 ); // count MESSAGE_END(); // do stuff for this event. CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.wheelchairDmgAttack, DMG_SLASH ); if ( pHurt ) { if ( pHurt->pev->flags & (FL_MONSTER|FL_CLIENT) ) { pHurt->pev->punchangle.z = -18; pHurt->pev->punchangle.x = 5; pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 100; } // Play a random attack hit sound // EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackHitSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackHitSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); } //else // Play a random attack miss sound //EMIT_SOUND_DYN ( ENT(pev), CHAN_WEAPON, pAttackMissSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackMissSounds)-1) ], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5,5) ); /*if (RANDOM_LONG(0,1)) AttackSound();*/ } break; default: CBaseMonster::HandleAnimEvent( pEvent ); break; } } //========================================================= // Spawn //========================================================= void CWheelchair :: Spawn() { Precache( ); if (pev->model) SET_MODEL(ENT(pev), STRING(pev->model)); //LRC else SET_MODEL(ENT(pev), "models/wheelchair_monster.mdl"); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_STEP; m_bloodColor = BLOOD_COLOR_RED; if (pev->health == 0) pev->health = gSkillData.wheelchairHealth; pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin. m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_MonsterState = MONSTERSTATE_NONE; m_afCapability = bits_CAP_DOORS_GROUP; MonsterInit(); } //========================================================= // Precache - precaches all resources this monster needs //========================================================= void CWheelchair :: Precache() { int i; m_vomitSprite = PRECACHE_MODEL("sprites/wheelchair_vomit.spr"); if (pev->model) PRECACHE_MODEL(STRING(pev->model)); //LRC else PRECACHE_MODEL("models/wheelchair_monster.mdl"); PRECACHE_SOUND( "wheelchair/wcm_squirt.wav" ); for ( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) PRECACHE_SOUND( pAttackHitSounds[i] ); for ( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) PRECACHE_SOUND( pAttackMissSounds[i] ); for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) PRECACHE_SOUND( pAttackSounds[i] ); for ( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) PRECACHE_SOUND( pIdleSounds[i] ); for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) PRECACHE_SOUND( pAlertSounds[i] ); for ( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) PRECACHE_SOUND( pPainSounds[i] ); } //========================================================= // AI Schedules Specific to this monster //========================================================= int CWheelchair::IgnoreConditions() { int iIgnore = CBaseMonster::IgnoreConditions(); if ((m_Activity == ACT_MELEE_ATTACK1) || (m_Activity == ACT_MELEE_ATTACK1)) { #if 0 if (pev->health < 20) iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); else #endif if (m_flNextFlinch >= gpGlobals->time) iIgnore |= (bits_COND_LIGHT_DAMAGE|bits_COND_HEAVY_DAMAGE); } if ((m_Activity == ACT_SMALL_FLINCH) || (m_Activity == ACT_BIG_FLINCH)) { if (m_flNextFlinch < gpGlobals->time) m_flNextFlinch = gpGlobals->time + WHEELCHAIR_FLINCH_DELAY; } return iIgnore; }