예제 #1
0
/*
================
idMoveable::Event_Activate
================
*/
void idMoveable::Event_Activate( idEntity *activator ) {
	float delay;
	idVec3 init_velocity, init_avelocity;

	Show();

	if ( !spawnArgs.GetInt( "notPushable" ) ) {
		physicsObj.EnableImpact();
	}

	physicsObj.Activate();

	spawnArgs.GetVector( "init_velocity", "0 0 0", init_velocity );
	spawnArgs.GetVector( "init_avelocity", "0 0 0", init_avelocity );

	delay = spawnArgs.GetFloat( "init_velocityDelay", "0" );
	if ( delay == 0.0f ) {
		physicsObj.SetLinearVelocity( init_velocity );
	} else {
		PostEventSec( &EV_SetLinearVelocity, delay, init_velocity );
	}

	delay = spawnArgs.GetFloat( "init_avelocityDelay", "0" );
	if ( delay == 0.0f ) {
		physicsObj.SetAngularVelocity( init_avelocity );
	} else {
		PostEventSec( &EV_SetAngularVelocity, delay, init_avelocity );
	}

	InitInitialSpline( gameLocal.time );
}
예제 #2
0
파일: Fx.cpp 프로젝트: revelator/MHDoom
/*
================
idEntityFx::Event_ClearFx

  Clears any visual fx started when item(mob) was spawned
================
*/
void idEntityFx::Event_ClearFx( void )
{

	if( g_skipFX.GetBool() )
	{
		return;
	}
	
	Stop();
	CleanUp();
	BecomeInactive( TH_THINK );
	
	if( spawnArgs.GetBool( "test" ) )
	{
		PostEventMS( &EV_Activate, 0, this );
	}
	else
	{
		if( spawnArgs.GetFloat( "restart" ) || !spawnArgs.GetBool( "triggered" ) )
		{
			float rest = spawnArgs.GetFloat( "restart", "0" );
			if( rest == 0.0f )
			{
				PostEventSec( &EV_Remove, 0.1f );
			}
			else
			{
				rest *= gameLocal.random.RandomFloat();
				PostEventSec( &EV_Activate, rest, this );
			}
		}
	}
}
예제 #3
0
/*
================
idItem::Pickup
================
*/
bool idItem::Pickup(idPlayer *player)
{

	if (!GiveToPlayer(player)) {
		return false;
	}

	if (gameLocal.isServer) {
		ServerSendEvent(EVENT_PICKUP, NULL, false, -1);
	}

	// play pickup sound
	StartSound("snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL);

	// trigger our targets
	ActivateTargets(player);

	// clear our contents so the object isn't picked up twice
	GetPhysics()->SetContents(0);

	// hide the model
	Hide();

	// add the highlight shell
	if (itemShellHandle != -1) {
		gameRenderWorld->FreeEntityDef(itemShellHandle);
		itemShellHandle = -1;
	}

	float respawn = spawnArgs.GetFloat("respawn");
	bool dropped = spawnArgs.GetBool("dropped");
	bool no_respawn = spawnArgs.GetBool("no_respawn");

	if (gameLocal.isMultiplayer && respawn == 0.0f) {
		respawn = 20.0f;
	}

	if (respawn && !dropped && !no_respawn) {
		const char *sfx = spawnArgs.GetString("fxRespawn");

		if (sfx && *sfx) {
			PostEventSec(&EV_RespawnFx, respawn - 0.5f);
		}

		PostEventSec(&EV_RespawnItem, respawn);
	} else if (!spawnArgs.GetBool("inv_objective") && !no_respawn) {
		// give some time for the pickup sound to play
		// FIXME: Play on the owner
		if (!spawnArgs.GetBool("inv_carry")) {
			PostEventMS(&EV_Remove, 5000);
		}
	}

	BecomeInactive(TH_THINK);
	return true;
}
예제 #4
0
/*
================
idSecurityCamera::Think
================
*/
void idSecurityCamera::Think( void ) {
	float pct;
	float travel;
	if( thinkFlags & TH_THINK ) {
		if( g_showEntityInfo.GetBool() ) {
			DrawFov();
		}
		if( health <= 0 ) {
			BecomeInactive( TH_THINK );
			return;
		}
	}
	// run physics
	RunPhysics();
	if( thinkFlags & TH_THINK ) {
		if( CanSeePlayer() ) {
			if( alertMode == SCANNING ) {
				float	sightTime;
				SetAlertMode( ALERT );
				stopSweeping = gameLocal.time;
				if( sweeping ) {
					CancelEvents( &EV_SecurityCam_Pause );
				} else {
					CancelEvents( &EV_SecurityCam_ReverseSweep );
				}
				sweeping = false;
				StopSound( SND_CHANNEL_ANY, false );
				StartSound( "snd_sight", SND_CHANNEL_BODY, 0, false, NULL );
				sightTime = spawnArgs.GetFloat( "sightTime", "5" );
				PostEventSec( &EV_SecurityCam_Alert, sightTime );
			}
		} else {
			if( alertMode == ALERT ) {
				float	sightResume;
				SetAlertMode( LOSINGINTEREST );
				CancelEvents( &EV_SecurityCam_Alert );
				sightResume = spawnArgs.GetFloat( "sightResume", "1.5" );
				PostEventSec( &EV_SecurityCam_ContinueSweep, sightResume );
			}
			if( sweeping ) {
				idAngles a = GetPhysics()->GetAxis().ToAngles();
				pct = ( gameLocal.time - sweepStart ) / ( sweepEnd - sweepStart );
				travel = pct * sweepAngle;
				if( negativeSweep ) {
					a.yaw = angle + travel;
				} else {
					a.yaw = angle - travel;
				}
				SetAngles( a );
			}
		}
	}
	Present();
}
/*
================
hhProjectileCrawlerGrenade::Launch
================
*/
void hhProjectileCrawlerGrenade::Launch( const idVec3 &start, const idMat3 &axis, const idVec3 &pushVelocity, const float timeSinceFire, const float launchPower, const float dmgPower ) {
	hhProjectile::Launch( start, axis, pushVelocity, timeSinceFire, launchPower, dmgPower );

	if( modelProxy.IsValid() ) {
		modelProxy->CycleAnim( "flight", ANIMCHANNEL_ALL );
	}

	float delayBeforeDying = spawnArgs.GetFloat( "delayBeforeDying" );
	float fuse = spawnArgs.GetFloat( "fuse" );

	inflateDuration = SEC2MS( hhMath::ClampFloat(0.0f, fuse, fuse - delayBeforeDying) );

	PostEventSec( &EV_DyingState, delayBeforeDying );
	PostEventSec( &EV_DeadState, fuse );
}
/*
================
idItem::Pickup
================
*/
bool idItem::Pickup( idPlayer *player ) {
	if ( !GiveToPlayer( player ) ) {
		return false;
	}

	// play pickup sound
	StartSound( "snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL );
	// sikk - play the sounds through the player
	//player->StartSoundShader( declManager->FindSound( spawnArgs.GetString( "snd_acquire" ) ), SND_CHANNEL_ITEM, SSF_PRIVATE_SOUND, false, NULL );

	// trigger our targets
	ActivateTargets( player );

	// clear our contents so the object isn't picked up twice
	GetPhysics()->SetContents( 0 );

	// hide the model
	Hide();

	FreeLightDef();	// sikk - Crumb Light

	// add the highlight shell
	if ( itemShellHandle != -1 ) {
		gameRenderWorld->FreeEntityDef( itemShellHandle );
		itemShellHandle = -1;
	}

	float respawn = spawnArgs.GetFloat( "respawn" );
	bool dropped = spawnArgs.GetBool( "dropped" );
	bool no_respawn = spawnArgs.GetBool( "no_respawn" );

	if ( respawn && !dropped && !no_respawn ) {
		const char *sfx = spawnArgs.GetString( "fxRespawn" );
		if ( sfx && *sfx ) {
			PostEventSec( &EV_RespawnFx, respawn - 0.5f );
		} 
		PostEventSec( &EV_RespawnItem, respawn );
	} else if ( !spawnArgs.GetBool( "inv_objective" ) && !no_respawn ) {
		// give some time for the pickup sound to play
		// FIXME: Play on the owner
		if ( !spawnArgs.GetBool( "inv_carry" ) ) {
			PostEventMS( &EV_Remove, 5000 );
		}
	}

	BecomeInactive( TH_THINK );
	return true;
}
예제 #7
0
void hhGibbable::Explode(idEntity *activator) {
	hhFxInfo fxInfo;

	Hide();
	fl.takedamage = false;
	GetPhysics()->SetContents( 0 );
	ActivateTargets( activator );
	SetSkinByName(NULL);
	if ( spawnArgs.GetFloat( "respawn", "0" ) ) {
		PostEventSec( &EV_Respawn, spawnArgs.GetFloat( "respawn", "0" ) );
	} else {
		PostEventMS( &EV_Remove, 200 );	// Remove after a small delay to allow sound commands to execute
	}
	StartSound( "snd_gib", SND_CHANNEL_ANY );

	// Find thinnest axis in the bounds and use for fx normal
	idVec3 thinnest = vec3_origin;
	int axisIndex = DetermineThinnestAxis();
	thinnest[axisIndex] = 1.0f;
	thinnest *= GetAxis();

	fxInfo.RemoveWhenDone( true );
	fxInfo.SetNormal(thinnest);
	// Spawn FX system for gib
	BroadcastFxInfo( spawnArgs.GetString("fx_gib"), GetOrigin(), GetAxis(), &fxInfo );

	// Spawn gibs
	if (spawnArgs.FindKey("def_debrisspawner")) {
		hhUtils::SpawnDebrisMass(spawnArgs.GetString("def_debrisspawner"), this );
	}
}
예제 #8
0
/*
================
idTrigger_EntityName::Event_Trigger

the trigger was just activated
activated should be the entity that originated the activation sequence (ie. the original target)
activator should be set to the activator so it can be held through a delay
so wait for the delay time before firing
================
*/
void idTrigger_EntityName::Event_Trigger( idEntity *activator ) {
	if ( nextTriggerTime > gameLocal.time ) {
		// can't retrigger until the wait is over
		return;
	}

	if ( !activator || ( activator->name != entityName ) ) {
		return;
	}

	if ( triggerFirst ) {
		triggerFirst = false;
		return;
	}

	// don't allow it to trigger twice in a single frame
	nextTriggerTime = gameLocal.time + 1;

	if ( delay > 0 ) {
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, activator );
	} else {
		TriggerAction( activator );
	}
}
/*
=================
hhProjectileCrawlerGrenade::Event_ApplyExpandWound
=================
*/
void hhProjectileCrawlerGrenade::Event_ApplyExpandWound() {
	trace_t trace;

	if( !modelProxy.IsValid() || !modelProxy->GetCombatModel() ) {
		return;
	}

	idBounds clipBounds( modelProxy->GetRenderEntity()->bounds );
	idVec3 traceEnd = GetOrigin();
	idVec3 traceStart = traceEnd + hhUtils::RandomPointInShell( clipBounds.Expand(1.0f).GetRadius(), clipBounds.Expand(2.0f).GetRadius() );
	idVec3 jointOrigin, localOrigin, localNormal;
	idMat3 jointAxis, axisTranspose;
	jointHandle_t jointHandle = INVALID_JOINT;

	CancelEvents( &EV_ApplyExpandWound );
	PostEventSec( &EV_ApplyExpandWound, spawnArgs.GetFloat("expandWoundDelay") );

	if( !gameLocal.clip.TracePoint(trace, traceStart, traceEnd, modelProxy->GetCombatModel()->GetContents(), NULL) ) {
		return;
	}
	
	if( trace.c.entityNum != entityNumber ) {//Make sure we hit ourselves
		return;
	}
			
	modelProxy->AddDamageEffect( trace, vec3_zero, spawnArgs.GetString("def_expandDamage"), (!fl.networkSync || netSyncPhysics) );
}
예제 #10
0
/*
================
idTrigger_EntityName::Event_Touch
================
*/
void idTrigger_EntityName::Event_Touch( idEntity *other, trace_t *trace )
{
	if( triggerFirst )
	{
		return;
	}
	
	if( nextTriggerTime > gameLocal.time )
	{
		// can't retrigger until the wait is over
		return;
	}
	
	if( !other || ( other->name != entityName ) )
	{
		return;
	}
	
	nextTriggerTime = gameLocal.time + 1;
	if( delay > 0 )
	{
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, other );
	}
	else
	{
		TriggerAction( other );
	}
}
예제 #11
0
/*
================
idEntityFx::Event_Trigger
================
*/
void idEntityFx::Event_Trigger( idEntity *activator ) {

	if ( g_skipFX.GetBool() ) {
		return;
	}

	float		fxActionDelay;
	const char *fx;

	if ( gameLocal.time < nextTriggerTime ) {
		return;
	}

	if ( spawnArgs.GetString( "fx", "", &fx) ) {
		Setup( fx );
		Start( gameLocal.time );
		PostEventMS( &EV_Fx_KillFx, Duration() );
		BecomeActive( TH_THINK );
	}

	fxActionDelay = spawnArgs.GetFloat( "fxActionDelay" );
	if ( fxActionDelay != 0.0f ) {
		nextTriggerTime = gameLocal.time + SEC2MS( fxActionDelay );
	} else {
		// prevent multiple triggers on same frame
		nextTriggerTime = gameLocal.time + 1;
	}
	PostEventSec( &EV_Fx_Action, fxActionDelay, activator );
}
예제 #12
0
/*
================
idSound::Event_Trigger

this will toggle the idle idSound on and off
================
*/
void idSound::Event_Trigger( idEntity *activator ) {
	if ( wait > 0.0f ) {
		if ( timerOn ) {
			timerOn = false;
			CancelEvents( &EV_Speaker_Timer );
		} else {
			timerOn = true;
			DoSound( true );
			PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random );
		}
	} else {
		if ( gameLocal.isMultiplayer ) {
			if ( refSound.referenceSound && ( gameLocal.time < playingUntilTime ) ) {
				DoSound( false );
			} else {
				DoSound( true );
			}
		} else {
			if ( refSound.referenceSound && refSound.referenceSound->CurrentlyPlaying() ) {
				DoSound( false );
			} else {
				DoSound( true );
			}
		}
	}
}
예제 #13
0
파일: Sound.cpp 프로젝트: revelator/MHDoom
/*
================
idSound::Spawn
================
*/
void idSound::Spawn( void )
{
	spawnArgs.GetVector( "move", "0 0 0", shakeTranslate );
	spawnArgs.GetAngles( "rotate", "0 0 0", shakeRotate );
	spawnArgs.GetFloat( "random", "0", random );
	spawnArgs.GetFloat( "wait", "0", wait );
	
	if( ( wait > 0.0f ) && ( random >= wait ) )
	{
		random = wait - 0.001;
		gameLocal.DWarning( "speaker '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString( 0 ) );
	}
	
	soundVol		= 0.0f;
	lastSoundVol	= 0.0f;
	
	if( ( shakeRotate != ang_zero ) || ( shakeTranslate != vec3_zero ) )
	{
		BecomeActive( TH_THINK );
	}
	
	if( !refSound.waitfortrigger && ( wait > 0.0f ) )
	{
		timerOn = true;
		PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random );
	}
	else
	{
		timerOn = false;
	}
}
예제 #14
0
/*
================
idTrigger_Multi::Event_Trigger

the trigger was just activated
activated should be the entity that originated the activation sequence (ie. the original target)
activator should be set to the activator so it can be held through a delay
so wait for the delay time before firing
================
*/
void idTrigger_Multi::Event_Trigger( idEntity *activator ) {
// RAVEN BEGIN
// bdube: moved trigger first
    if ( triggerFirst ) {
        triggerFirst = false;
        return;
    }

    if ( nextTriggerTime > gameLocal.time ) {
        // can't retrigger until the wait is over
        return;
    }

    // see if this trigger requires an item
    if ( !gameLocal.RequirementMet( activator, requires, removeItem ) ) {
        return;
    }

    if ( !CheckFacing( activator ) ) {
        return;
    }
// RAVEN END

    // don't allow it to trigger twice in a single frame
    nextTriggerTime = gameLocal.time + 1;

    if ( delay > 0 ) {
        // don't allow it to trigger again until our delay has passed
        nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
        PostEventSec( &EV_TriggerAction, delay, activator );
    } else {
        TriggerAction( activator );
    }
}
예제 #15
0
/*
================
idTrigger_Timer::Enable
================
*/
void idTrigger_Timer::Enable( void ) {
    // if off, turn it on
    if ( !on ) {
        on = true;
        PostEventSec( &EV_Timer, delay );
    }
}
예제 #16
0
/*
================
idSound::Spawn
================
*/
void idSound::Spawn( void ) {
	spawnArgs.GetVector( "move", "0 0 0", shakeTranslate );
	spawnArgs.GetAngles( "rotate", "0 0 0", shakeRotate );
	spawnArgs.GetFloat( "random", "0", random );
	spawnArgs.GetFloat( "wait", "0", wait );

	if ( ( wait > 0.0f ) && ( random >= wait ) ) {
		random = wait - 0.001;
		gameLocal.Warning( "speaker '%s' at (%s) has random >= wait", name.c_str(), GetPhysics()->GetOrigin().ToString(0) );
	}

	soundVol		= 0.0f;
	lastSoundVol	= 0.0f;

	if ( ( shakeRotate != ang_zero ) || ( shakeTranslate != vec3_zero ) ) {
		BecomeActive( TH_THINK );
	}

	if ( !refSound.waitfortrigger && ( wait > 0.0f ) ) {
		timerOn = true;
		PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random );
	} else {
		timerOn = false;
	}
	// add this speaker to the list of ambient music speakers affected by tdm_music_volume
    if ( spawnArgs.GetBool( "s_music" ) ) {
       gameLocal.musicSpeakers.Append( entityNumber );
    }
}
예제 #17
0
/*
================
idSound::Event_On
================
*/
void idSound::Event_On( void ) {
	if ( wait > 0.0f ) {
		timerOn = true;
		PostEventSec( &EV_Speaker_Timer, wait + gameLocal.random.CRandomFloat() * random );
	}
	DoSound( true );
}
예제 #18
0
/*
================
idTrigger_EntityName::Event_Touch
================
*/
void idTrigger_EntityName::Event_Touch( idEntity *other, trace_t *trace ) {
    if( triggerFirst ) {
        return;
    }

    if ( nextTriggerTime > gameLocal.time ) {
        // can't retrigger until the wait is over
        return;
    }

// RAVEN BEGIN
// abahr: so we can exclude an entity by name
    if( !other ) {
        return;
    }

    if( spawnArgs.GetBool("excludeEntityName") && other->name == entityName ) {
        return;
    }

    if( !spawnArgs.GetBool("excludeEntityName") && other->name != entityName ) {
        return;
    }
// RAVEN END

    nextTriggerTime = gameLocal.time + 1;
    if ( delay > 0 ) {
        // don't allow it to trigger again until our delay has passed
        nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
        PostEventSec( &EV_TriggerAction, delay, other );
    } else {
        TriggerAction( other );
    }
}
예제 #19
0
/*
================
idExplodingBarrel::Event_Respawn
================
*/
void idExplodingBarrel::Event_Respawn() {
	int i;
	int minRespawnDist = spawnArgs.GetInt( "respawn_range", "256" );
	if ( minRespawnDist ) {
		float minDist = -1;
		for ( i = 0; i < gameLocal.numClients; i++ ) {
			if ( !gameLocal.entities[ i ] || !gameLocal.entities[ i ]->IsType( idPlayer::Type ) ) {
				continue;
			}
			idVec3 v = gameLocal.entities[ i ]->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin();
			float dist = v.Length();
			if ( minDist < 0 || dist < minDist ) {
				minDist = dist;
			}
		}
		if ( minDist < minRespawnDist ) {
			PostEventSec( &EV_Respawn, spawnArgs.GetInt( "respawn_again", "10" ) );
			return;
		}
	}
	const char *temp = spawnArgs.GetString( "model" );
	if ( temp && *temp ) {
		SetModel( temp );
	}
	health = spawnArgs.GetInt( "health", "5" );
	fl.takedamage = true;
	physicsObj.SetOrigin( spawnOrigin );
	physicsObj.SetAxis( spawnAxis );
	physicsObj.SetContents( CONTENTS_SOLID );
	physicsObj.DropToFloor();
	state = NORMAL;
	Show();
	UpdateVisuals();
}
예제 #20
0
/*
================
idTrigger_Timer::Event_Timer
================
*/
void idTrigger_Timer::Event_Timer( void ) {
	ActivateTargets( this );
	// set time before next firing
	if( wait >= 0.0f ) {
		PostEventSec( &EV_Timer, wait + gameLocal.random.CRandomFloat() * random );
	}
}
예제 #21
0
/*
================
idMoveable::EnableDamage
================
*/
void idMoveable::EnableDamage(bool enable, float duration)
{
	canDamage = enable;

	if (duration) {
		PostEventSec(&EV_EnableDamage, duration, (!enable) ? 0.0f : 1.0f);
	}
}
예제 #22
0
/*
================
idSecurityCamera::Event_Pause
================
*/
void idSecurityCamera::Event_Pause( void ) {
	float	sweepWait;
	sweepWait = spawnArgs.GetFloat( "sweepWait", "0.5" );
	sweeping = false;
	StopSound( SND_CHANNEL_ANY, false );
	StartSound( "snd_stop", SND_CHANNEL_BODY, 0, false, NULL );
	PostEventSec( &EV_SecurityCam_ReverseSweep, sweepWait );
}
예제 #23
0
/*
================
idTrigger_Multi::Event_Touch
================
*/
void idTrigger_Multi::Event_Touch( idEntity *other, trace_t *trace )
{
	if( triggerFirst )
	{
		return;
	}
	
	bool player = other->IsType( idPlayer::Type );
	if( player )
	{
		if( !touchClient )
		{
			return;
		}
		if( static_cast< idPlayer * >( other )->spectating )
		{
			return;
		}
	}
	else if( !touchOther )
	{
		return;
	}
	
	if( nextTriggerTime > gameLocal.time )
	{
		// can't retrigger until the wait is over
		return;
	}
	
	// see if this trigger requires an item
	if( !gameLocal.RequirementMet( other, requires, removeItem ) )
	{
		return;
	}
	
	if( !CheckFacing( other ) )
	{
		return;
	}
	
	if( spawnArgs.GetBool( "toggleTriggerFirst" ) )
	{
		triggerFirst = true;
	}
	
	nextTriggerTime = gameLocal.time + 1;
	if( delay > 0 )
	{
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, other );
	}
	else
	{
		TriggerAction( other );
	}
}
예제 #24
0
/*
================
idSecurityCamera::Event_Alert
================
*/
void idSecurityCamera::Event_Alert( void ) {
	float	wait;
	SetAlertMode( ACTIVATED );
	StopSound( SND_CHANNEL_ANY, false );
	StartSound( "snd_activate", SND_CHANNEL_BODY, 0, false, NULL );
	ActivateTargets( this );
	CancelEvents( &EV_SecurityCam_ContinueSweep );
	wait = spawnArgs.GetFloat( "wait", "20" );
	PostEventSec( &EV_SecurityCam_ContinueSweep, wait );
}
예제 #25
0
파일: Moveable.cpp 프로젝트: c4tnt/DLR
/*
================
idMoveable::EnableDamage
================
*/
void idMoveable::EnableDamage( bool enable, float duration ) {
	if ( canDamage == enable ) {
		return;
	}

	canDamage = enable;
	if ( duration ) {
		PostEventSec( &EV_EnableDamage, NULL, duration, ( !enable ) ? 0.0f : 0.0f );
	}
}
예제 #26
0
파일: Target.cpp 프로젝트: alepulver/dhewm3
/*
================
idTarget_Tip::Event_Activate
================
*/
void idTarget_Tip::Event_Activate( idEntity *activator ) {
	idPlayer *player = gameLocal.GetLocalPlayer();
	if ( player ) {
		if ( player->IsTipVisible() ) {
			PostEventSec( &EV_Activate, 5.1f, activator );
			return;
		}
		player->ShowTip( spawnArgs.GetString( "text_title" ), spawnArgs.GetString( "text_tip" ), false );
		PostEventMS( &EV_GetPlayerPos, 2000 );
	}
}
예제 #27
0
/*
================
idMoveable::EnableDamage
================
*/
void idMoveable::EnableDamage(bool enable, float duration) {
#ifdef _D3XP
	if (canDamage == enable) {
		return;
	}
#endif
	canDamage = enable;
	if (duration) {
		PostEventSec(&EV_EnableDamage, duration, ( /*_D3XP*/enable) ? 0.0f : 1.0f);
	}
}
예제 #28
0
파일: Target.cpp 프로젝트: alepulver/dhewm3
/*
================
idTarget_SetInfluence::Event_Flash
================
*/
void idTarget_SetInfluence::Event_Flash( float flash, int out ) {
	idPlayer *player = gameLocal.GetLocalPlayer();
	player->playerView.Fade( idVec4( 1, 1, 1, 1 ), flash );
	const idSoundShader *shader = NULL;
	if ( !out && flashInSound.Length() ){
		shader = declManager->FindSound( flashInSound );
		player->StartSoundShader( shader, SND_CHANNEL_VOICE, 0, false, NULL );
	} else if ( out && ( flashOutSound.Length() || flashInSound.Length() ) ) {
		shader = declManager->FindSound( flashOutSound.Length() ? flashOutSound : flashInSound );
		player->StartSoundShader( shader, SND_CHANNEL_VOICE, 0, false, NULL );
	}
	PostEventSec( &EV_ClearFlash, flash, flash );
}
예제 #29
0
/*
================
idTrigger_EntityName::Event_Touch
================
*/
void idTrigger_EntityName::Event_Touch( idEntity* other, trace_t* trace )
{
	if( common->IsClient() )
	{
		return;
	}
	
	if( triggerFirst )
	{
		return;
	}
	
	if( nextTriggerTime > gameLocal.time )
	{
		// can't retrigger until the wait is over
		return;
	}
	
	bool validEntity = false;
	if( other )
	{
		if( testPartialName )
		{
			if( other->name.Find( entityName, false ) >= 0 )
			{
				validEntity = true;
			}
		}
		if( other->name == entityName )
		{
			validEntity = true;
		}
	}
	
	if( !validEntity )
	{
		return;
	}
	
	nextTriggerTime = gameLocal.time + 1;
	if( delay > 0 )
	{
		// don't allow it to trigger again until our delay has passed
		nextTriggerTime += SEC2MS( delay + random_delay * gameLocal.random.CRandomFloat() );
		PostEventSec( &EV_TriggerAction, delay, other );
	}
	else
	{
		TriggerAction( other );
	}
}
예제 #30
0
/*
================
idTrigger_Count::Event_Trigger
================
*/
void idTrigger_Count::Event_Trigger( idEntity *activator ) {
    // goal of -1 means trigger has been exhausted
    if (goal >= 0) {
        count++;
        if ( count >= goal ) {
            if (spawnArgs.GetBool("repeat")) {
                count = 0;
            } else {
                goal = -1;
            }
            PostEventSec( &EV_TriggerAction, delay, activator );
        }
    }
}