// Copyright (C) 1998 by Ritual Entertainment, Inc. // All rights reserved. // // This source is may not be distributed and/or modified without // expressly written permission by Ritual Entertainment, Inc. // // DESCRIPTION: // Reactive Shields #include "inventoryitem.h" Event EV_Item_ReactiveShields_PowerDown( "shields_powerdown" ); class EXPORT_FROM_DLL ReactiveShields : public InventoryItem { public: CLASS_PROTOTYPE( ReactiveShields ); ReactiveShields(); void Use( Event *ev ); void PowerDown( Event *ev ); }; CLASS_DECLARATION( InventoryItem, ReactiveShields, "powerup_shield" ) ResponseDef ReactiveShields::Responses[] = { { &EV_InventoryItem_Use, ( Response )ReactiveShields::Use }, { &EV_Item_ReactiveShields_PowerDown,( Response )ReactiveShields::PowerDown }, { NULL, NULL } }; ReactiveShields::ReactiveShields ( ) { setModel( "shield.def" ); Set( 1 ); setRespawnTime( 180 + G_Random( 60 ) ); } void ReactiveShields::Use ( Event *ev ) { Event *event; str realname; if(!owner) { CancelPendingEvents(); PostEvent(EV_Remove, 0); return; } if ( owner->PowerupActive() ) { return; } // Make sure there is a reactive shield available assert( amount ); amount--; if (amount <= 0) { owner->RemoveItem( this ); } owner->flags |= FL_SHIELDS; PostEvent( EV_Item_ReactiveShields_PowerDown, 30 ); realname = GetRandomAlias( "snd_activate" ); if ( realname.length() ) owner->sound( realname, 1, CHAN_ITEM, ATTN_NORM ); owner->edict->s.renderfx |= RF_DLIGHT; owner->edict->s.color_r = 0; owner->edict->s.color_g = 0; owner->edict->s.color_b = 1; owner->edict->s.radius = 120; //### remove the player's heat signature owner->edict->s.effects &= ~EF_WARM; //### event = new Event( "poweruptimer" ); event->AddInteger( 30 ); event->AddInteger( P_SHIELDS ); owner->ProcessEvent ( event ); } void ReactiveShields::PowerDown ( Event *ev ) { if ( !owner ) { CancelPendingEvents(); PostEvent( EV_Remove, 0 ); return; } if ( owner->flags & FL_SHIELDS ) { str realname; owner->flags &= ~FL_SHIELDS; realname = GetRandomAlias( "snd_deactivate" ); if ( realname.length() ) owner->sound( realname, 1, CHAN_ITEM, ATTN_NORM ); owner->edict->s.renderfx &= ~RF_DLIGHT; owner->edict->s.color_r = 0; owner->edict->s.color_g = 0; owner->edict->s.color_b = 0; owner->edict->s.radius = 0; //### replace owners heat signature if alive if(!owner->deadflag) owner->edict->s.effects |= EF_WARM; //### } CancelPendingEvents(); PostEvent( EV_Remove, 0 ); }