void CFuncClock :: Think( void ) { float seconds, ang, pos; seconds = gpGlobals->time + m_flCurTime; pos = seconds / m_iClockType; pos = pos - floor( pos ); ang = 360 * pos; SetLocalAngles( pev->movedir * ang ); if( m_iClockType == SECODNS_PER_DAY ) { int hours = GetLocalAngles().Length() / 30; if( m_iHoursCount != hours ) { // member new hour m_iHoursCount = hours; if( hours == 0 ) hours = 12; // merge for 0.00.00 // send hours info UTIL_FireTargets( pev->netname, this, this, USE_SET, hours ); UTIL_FireTargets( pev->netname, this, this, USE_ON ); } } RelinkEntity( FALSE ); // set clock resolution SetNextThink( 1.0f ); }
void CFuncLight :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { m_hActivator = pActivator; if( IsLockedByMaster( )) return; if( m_iState == STATE_DEAD ) return; // lamp is broken if( useType == USE_TOGGLE ) { if( m_iState == STATE_OFF ) useType = USE_ON; else useType = USE_OFF; } if( useType == USE_ON ) { if( m_flDelay ) { // make flickering delay m_iState = STATE_TURN_ON; LIGHT_STYLE( m_iStyle, "mmamammmmammamamaaamammma" ); pev->frame = 0; // light texture is on SetThink( Flicker ); SetNextThink( m_flDelay ); } else { // instant enable m_iState = STATE_ON; LIGHT_STYLE( m_iStyle, "k" ); pev->frame = 0; // light texture is on UTIL_FireTargets( pev->target, this, this, USE_ON ); } } else if( useType == USE_OFF ) { LIGHT_STYLE( m_iStyle, "a" ); UTIL_FireTargets( pev->target, this, this, USE_OFF ); pev->frame = 1;// light texture is off m_iState = STATE_OFF; } else if( useType == USE_SET ) { // a script die (dramatic effect) Die(); } }
void CEnvLocal :: Think( void ) { if( m_iState == STATE_TURN_ON ) { m_iState = STATE_ON; UTIL_FireTargets( pev->target, m_hActivator, this, USE_ON, pev->scale ); } else if( m_iState == STATE_TURN_OFF ) { m_iState = STATE_OFF; UTIL_FireTargets( pev->target, m_hActivator, this, USE_OFF, pev->scale ); } DontThink(); // break thinking }
void CLight :: Think( void ) { switch (GetState()) { case STATE_TURN_ON: m_iState = STATE_ON; UTIL_FireTargets( pev->target, this, this, USE_ON ); break; case STATE_TURN_OFF: m_iState = STATE_OFF; UTIL_FireTargets(pev->target, this, this, USE_OFF ); break; } SetCorrectStyle(); }
void CMultiSource :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { int i = 0; // find the entity in our list while( i < m_iTotal ) { if( m_rgEntities[i++] == pCaller ) break; } // if we didn't find it, report error and leave if( i > m_iTotal ) { if( pCaller->GetTargetname( )) ALERT( at_error, "multisource \"%s\": Used by non-member %s \"%s\"\n", GetTargetname(), pCaller->GetTargetname( )); else ALERT( at_error, "multisource \"%s\": Used by non-member %s\n", GetTargetname(), pCaller->GetClassname( )); return; } // store the state before the change, so we can compare it to the new state STATE s = GetState(); // do the change m_rgTriggered[i-1] ^= 1; // did we change state? if( s == GetState( )) return; if( s == STATE_ON && !FStringNull( pev->netname )) { // the change disabled me and I have a "fire on disable" field ALERT( at_aiconsole, "Multisource %s deactivated (%d inputs)\n", GetTargetname(), m_iTotal ); if( m_globalstate ) UTIL_FireTargets( STRING( pev->netname ), NULL, this, USE_OFF, 0 ); else UTIL_FireTargets( STRING( pev->netname ), NULL, this, USE_TOGGLE, 0 ); } else if( s == STATE_OFF ) { // the change activated me ALERT( at_aiconsole, "Multisource %s enabled (%d inputs)\n", GetTargetname(), m_iTotal ); if( m_globalstate ) UTIL_FireTargets( STRING( pev->target ), NULL, this, USE_ON, 0 ); else UTIL_FireTargets( STRING( pev->target ), NULL, this, USE_TOGGLE, 0 ); } }
void CItem::ItemTouch( CBaseEntity *pOther ) { //removed this limitation for monsters if ( !pOther->IsPlayer() ) return; CBasePlayer *pPlayer = (CBasePlayer *)pOther; if (!UTIL_IsMasterTriggered(m_sMaster, pPlayer)) return; if (pPlayer->pev->deadflag != DEAD_NO) return; if (AddItem( pPlayer ) != -1 ) { UTIL_FireTargets( pev->target, pOther, this, USE_TOGGLE ); SetTouch( NULL ); if( IsItem() && gmsg.ItemPickup ) { //show icon for item MESSAGE_BEGIN( MSG_ONE, gmsg.ItemPickup, NULL, pPlayer->pev ); WRITE_STRING( STRING(pev->classname) ); MESSAGE_END(); } // play pickup sound EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, (char *)PickSound(), 1, ATTN_NORM ); // tell the owner item was taken if (!FNullEnt( pev->owner )) pev->owner->v.impulse = 0; // enable respawn in multiplayer if ( g_pGameRules->IsMultiplayer() && !FBitSet( pev->spawnflags, SF_NORESPAWN )) Respawn(); else UTIL_Remove( this ); } else if ( gEvilImpulse101 ) UTIL_Remove( this ); }
void CFuncLight :: Flicker( void ) { if( m_iState == STATE_TURN_ON ) { LIGHT_STYLE( m_iStyle, "k" ); UTIL_FireTargets( pev->target, this, this, USE_ON ); m_iState = STATE_ON; DontThink(); return; } if( m_iFlickerMode == 1 ) { pev->frame = 1; LIGHT_STYLE( m_iStyle, "a" ); SetThink( NULL ); return; } if( m_iFlickerMode == 2 ) { switch( RANDOM_LONG( 0, 3 )) { case 0: LIGHT_STYLE( m_iStyle, "abcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); break; case 1: LIGHT_STYLE( m_iStyle, "acaaabaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); break; case 2: LIGHT_STYLE( m_iStyle, "aaafbaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); break; case 3: LIGHT_STYLE( m_iStyle, "aaaaaaaaaaaaagaaaaaaaaacaaaacaaaa" ); break; } m_flNextFlickerTime = RANDOM_FLOAT( 0.5f, 10.0f ); UTIL_Sparks( m_vecLastDmgPoint ); switch( RANDOM_LONG( 0, 2 )) { case 0: EMIT_SOUND( edict(), CHAN_VOICE, "buttons/spark1.wav", 0.4, ATTN_IDLE ); break; case 1: EMIT_SOUND( edict(), CHAN_VOICE, "buttons/spark2.wav", 0.3, ATTN_IDLE ); break; case 2: EMIT_SOUND( edict(), CHAN_VOICE, "buttons/spark3.wav", 0.35, ATTN_IDLE ); break; } if( m_flNextFlickerTime > 6.5f ) m_iFlickerMode = 1; // stop sparking } SetNextThink( m_flNextFlickerTime ); }
void FireOnEntry( CBaseEntity *pOther ) { if ( !IsLockedByMaster(pOther)) { UTIL_FireTargets( pev->target, pOther, this, USE_TOGGLE ); SetThink( Remove ); SetNextThink( 0 ); } }
void CBaseDoor::DoorHitTop( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT )) { STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise1 )); EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise2 ), 1, ATTN_NORM ); } ASSERT( m_iState == STATE_TURN_ON ); m_iState = STATE_ON; // toggle-doors don't come down automatically, they wait for refire. if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN )) { // re-instate touch method, movement is complete if( !FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY )) SetTouch( DoorTouch ); } else { // in flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open SetMoveDoneTime( m_flWait ); SetMoveDone( DoorGoDown ); if( m_flWait == -1 ) { SetNextThink( -1 ); } } // fire the close target (if startopen is set, then "top" is closed) - netname is the close target if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN )) { UTIL_FireTargets( pev->netname, m_hActivator, this, USE_TOGGLE, 0 ); } else { UTIL_FireTargets( pev->message, m_hActivator, this, USE_TOGGLE, 0 ); } if( FBitSet( pev->spawnflags, SF_DOOR_ONOFF_MODE )) SUB_UseTargets( m_hActivator, USE_OFF, 0 ); else SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); // this isn't finished }
// rotatingBlocked - An entity has blocked the brush void CFuncRotating :: Blocked( CBaseEntity *pOther ) { pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); if( gpGlobals->time < pev->dmgtime ) return; pev->dmgtime = gpGlobals->time + 0.5f; UTIL_FireTargets( pev->target, this, this, USE_TOGGLE ); }
void CTriggerCamera::Move( void ) { // Not moving on a path, return if (!m_pGoalEnt) return; // Subtract movement from the previous frame pev->frags -= pev->speed * gpGlobals->frametime; // Have we moved enough to reach the target? if ( pev->frags <= 0 ) { // Fire the passtarget if there is one if ( m_pGoalEnt->pev->message ) { UTIL_FireTargets( m_pGoalEnt->pev->message, this, this, USE_TOGGLE, 0 ); if ( FBitSet( m_pGoalEnt->pev->spawnflags, SF_CORNER_FIREONCE ) ) m_pGoalEnt->pev->message = 0; } if ( FBitSet( m_pGoalEnt->pev->spawnflags, SF_CORNER_TELEPORT ) ) { m_pGoalEnt = m_pGoalEnt->GetNext(); if ( m_pGoalEnt ) UTIL_AssignOrigin( this, m_pGoalEnt->pev->origin ); } if ( FBitSet( m_pGoalEnt->pev->spawnflags, SF_CORNER_WAITFORTRIG ) ) { //strange feature... } // Time to go to the next target m_pGoalEnt = m_pGoalEnt->GetNext(); // Set up next corner if ( !m_pGoalEnt ) UTIL_SetVelocity( this, g_vecZero ); else { pev->message = m_pGoalEnt->pev->targetname; //save last corner pev->armorvalue = m_pGoalEnt->pev->speed; Vector delta = m_pGoalEnt->pev->origin - pev->origin; pev->frags = delta.Length(); pev->movedir = delta.Normalize(); m_flDelay = gpGlobals->time + m_pGoalEnt->GetDelay(); } } if ( m_flDelay > gpGlobals->time ) pev->speed = UTIL_Approach( 0, pev->speed, 500 * gpGlobals->frametime ); else pev->speed = UTIL_Approach( pev->armorvalue, pev->speed, 500 * gpGlobals->frametime ); if( !pTarget ) UTIL_WatchTarget( this, m_pGoalEnt ); // watch for track float fraction = 2 * gpGlobals->frametime; UTIL_SetVelocity( this, ((pev->movedir * pev->speed) * fraction) + (pev->velocity * ( 1 - fraction ))); }
void CFuncLight :: Die( void ) { // lamp is random choose die style if( m_iState == STATE_OFF ) { pev->frame = 1; // light texture is off LIGHT_STYLE( m_iStyle, "a" ); DontThink(); } else { // simple randomization m_iFlickerMode = RANDOM_LONG( 1, 2 ); SetThink( Flicker ); SetNextThink( 0.1f + RANDOM_LONG( 0.1f, 0.2f )); } m_iState = STATE_DEAD; pev->health = 0; pev->takedamage = DAMAGE_NO; UTIL_FireTargets( pev->target, this, this, USE_OFF ); switch( RANDOM_LONG( 0, 1 )) { case 0: EMIT_SOUND( edict(), CHAN_VOICE, "debris/bustglass1.wav", 0.7, ATTN_IDLE ); break; case 1: EMIT_SOUND( edict(), CHAN_VOICE, "debris/bustglass2.wav", 0.8, ATTN_IDLE ); break; } Vector vecSpot = GetAbsOrigin() + (pev->mins + pev->maxs) * 0.5f; MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot ); WRITE_BYTE( TE_BREAKMODEL ); WRITE_COORD( vecSpot.x ); WRITE_COORD( vecSpot.y ); WRITE_COORD( vecSpot.z ); WRITE_COORD( pev->size.x ); WRITE_COORD( pev->size.y ); WRITE_COORD( pev->size.z ); WRITE_COORD( 0 ); WRITE_COORD( 0 ); WRITE_COORD( 0 ); WRITE_BYTE( 10 ); WRITE_SHORT( m_idShard ); WRITE_BYTE( 0 ); WRITE_BYTE( 25 ); WRITE_BYTE( BREAK_GLASS ); MESSAGE_END(); }
void CBaseDoor::DoorHitBottom( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT )) { STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise1 )); EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise2 ), 1, ATTN_NORM ); } ASSERT( m_iState == STATE_TURN_OFF ); m_iState = STATE_OFF; // re-instate touch method, cycle is complete if( FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY )) { // use only door SetTouch( NULL ); } else { // touchable door SetTouch( DoorTouch ); } // fire the close target (if startopen is set, then "top" is closed) - netname is the close target if( !FBitSet( pev->spawnflags, SF_DOOR_START_OPEN )) { UTIL_FireTargets( pev->netname, m_hActivator, this, USE_TOGGLE, 0 ); } else { UTIL_FireTargets( pev->message, m_hActivator, this, USE_TOGGLE, 0 ); } if( FBitSet( pev->spawnflags, SF_DOOR_ONOFF_MODE )) SUB_UseTargets( m_hActivator, USE_ON, 0 ); else SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); }
void CEnvLocal :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( IsLockedByMaster( pActivator )) return; m_hActivator = pActivator; pev->scale = value; if( useType == USE_TOGGLE ) { // set use type if( m_iState == STATE_TURN_OFF || m_iState == STATE_OFF ) useType = USE_ON; else if( m_iState == STATE_TURN_ON || m_iState == STATE_ON ) useType = USE_OFF; } if( useType == USE_ON ) { // enable entity if( m_iState == STATE_TURN_OFF || m_iState == STATE_OFF ) { if( m_flDelay ) { // we have time to turning on m_iState = STATE_TURN_ON; SetNextThink( m_flDelay ); } else { // just enable entity m_iState = STATE_ON; UTIL_FireTargets( pev->target, pActivator, this, USE_ON, pev->scale ); DontThink(); // break thinking } } } else if( useType == USE_OFF ) { // disable entity if( m_iState == STATE_TURN_ON || m_iState == STATE_ON ) // activate turning off entity { if( m_flWait ) { // we have time to turning off m_iState = STATE_TURN_OFF; SetNextThink( m_flWait ); } else { // just enable entity m_iState = STATE_OFF; UTIL_FireTargets( pev->target, pActivator, this, USE_OFF, pev->scale ); DontThink(); // break thinking } } } else if( useType == USE_SET ) { // just set state if( value != 0.0f ) m_iState = STATE_ON; else m_iState = STATE_OFF; DontThink(); // break thinking } }
void FireOnLeave( CBaseEntity *pOther ) { if (!IsLockedByMaster(pOther)) UTIL_FireTargets(pev->netname, pOther, this, USE_TOGGLE ); }
void FireOnEntry( CBaseEntity *pOther ) { if(!IsLockedByMaster(pOther)) UTIL_FireTargets(pev->target, pOther, this, USE_TOGGLE ); }