コード例 #1
0
void hhProxDoorRotator::Event_PostSpawn( void ) {
	idVec3	sectionOffset;
	idVec3	rotVector;
	float	rotAngle;

	if( !spawnArgs.GetVector("section_offset", "0 0 0", sectionOffset) ) {
		common->Warning( "No section offset found for '%s'", this->GetEntityDefName() );
	}
	if( !spawnArgs.GetVector("rot_vector", "0 0 0", rotVector) ) {
		common->Warning( "No rotation vector found for '%s'", this->GetEntityDefName() );
	}
	if( !spawnArgs.GetFloat("rot_angle", "0 0 0", rotAngle) ) {
		common->Warning( "No rotation angle found for '%s'", this->GetEntityDefName() );
	}

	idDict args;
	args.SetVector( "origin", GetOrigin() + (sectionOffset * GetAxis()) );
	args.SetMatrix( "rotation", GetAxis() );
	args.SetVector( "rot_vector", rotVector );
	args.SetFloat( "rot_angle", rotAngle );
	bindParent = static_cast<hhProxDoorSection*>( gameLocal.SpawnEntityType(hhProxDoorRotMaster::Type, &args) );
	if( !bindParent.IsValid() ) {
		common->Warning( "Failed to spawn bindParent for '%s'", GetEntityDefName() );
	}
	else {
		bindParent->proxyParent = this;
	}
	Bind( bindParent.GetEntity(), true );
}
コード例 #2
0
//--------------------------------
// hhProxDoor::Event_PostSpawn
//--------------------------------
void hhProxDoor::Event_PostSpawn( void ) {
	int numSubObjs;
	int i;
	const char* objDef;

//Parse and spawn our door sections
	numSubObjs = spawnArgs.GetInt( "num_doorobjs", "0" );
	for( i = 0; i < numSubObjs; i++ ) {
		if( !spawnArgs.GetString( va("doorobject%i", i+1), "", &objDef ) ) {
			common->Warning( "failed to find doorobject%i", i+1 );
		}
		else {
			//Set our default rotation/origin.
			idDict args;
			args.SetVector( "origin", this->GetOrigin() );
			args.SetMatrix( "rotation", this->GetAxis() );
			hhProxDoorSection* ent = static_cast<hhProxDoorSection*> ( gameLocal.SpawnObject(objDef, &args) );
			if( !ent ) {
				common->Warning( "failed to spawn doorobject%i for entityDef '%s'", i+1, GetEntityDefName() );
			}
			else {
				ent->proxyParent = this;
				doorPieces.Append( ent );
			}
		}
	} 
//Spawn our trigger and link it up
//	if( doorLocked && !spawnArgs.GetBool("locktrigger") ) {
		//we would never be able to open the door, so don't spawn a trigger
//	}
//	else {
		doorTrigger = new idClipModel( idTraceModel(idBounds(vec3_origin).Expand(maxDistance)) );
		doorTrigger->Link( gameLocal.clip, this, 255, GetOrigin(), GetAxis() );
		doorTrigger->SetContents( CONTENTS_TRIGGER );
//	}

	SpawnSoundTrigger();

	SetAASAreaState( doorLocked );			//close the area state if we are locked...
	SetDoorState( PROXSTATE_Inactive );
}
コード例 #3
0
/*
============
idActor::Damage

this		entity that is being damaged
inflictor	entity that is causing the damage
attacker	entity that caused the inflictor to damage targ
	example: this=monster, inflictor=rocket, attacker=player

dir			direction of the attack for knockback in global space
point		point at which the damage is being inflicted, used for headshots
damage		amount of damage being inflicted

inflictor, attacker, dir, and point can be NULL for environmental effects

Bleeding wounds and surface overlays are applied in the collision code that
calls Damage()
============
*/
void idActor::Damage( idEntity *inflictor, idEntity *attacker, const noVec3 &dir, const char *damageDefName, const float damageScale, const int location ) {
	if ( !fl.takedamage ) {
		return;
	}

	if ( !inflictor ) {
		inflictor = gameLocal.world;
	}
	if ( !attacker ) {
		attacker = gameLocal.world;
	}
#if 0
#ifdef _D3XP
	SetTimeState ts( timeGroup );

	// Helltime boss is immune to all projectiles except the helltime killer
	if ( finalBoss && idStr::Icmp(inflictor->GetEntityDefName(), "projectile_helltime_killer") ) {
		return;
	}

	// Maledict is immume to the falling asteroids
	if ( !idStr::Icmp( GetEntityDefName(), "monster_boss_d3xp_maledict" ) && 
		(!idStr::Icmp( damageDefName, "damage_maledict_asteroid" ) || !idStr::Icmp( damageDefName, "damage_maledict_asteroid_splash" ) ) ) {
			return;
	}
#else
	if ( finalBoss && !inflictor->IsType( idSoulCubeMissile::Type ) ) {
		return;
	}
#endif
#endif
	const idDict *damageDef = gameLocal.FindEntityDefDict( damageDefName );
	if ( !damageDef ) {
		gameLocal.Error( "Unknown damageDef '%s'", damageDefName );
	}

	int	damage = damageDef->GetInt( "damage" ) * damageScale;
	damage = GetDamageForLocation( damage, location );

	// inform the attacker that they hit someone
	attacker->DamageFeedback( this, inflictor, damage );
	if ( damage > 0 ) {
		health -= damage;

#ifdef _D3XP
		//Check the health against any damage cap that is currently set
		if(damageCap >= 0 && health < damageCap) {
			health = damageCap;
		}
#endif

		if ( health <= 0 ) {
			if ( health < -999 ) {
				health = -999;
			}
			Killed( inflictor, attacker, damage, dir, location );
			if ( ( health < -20 ) && spawnArgs.GetBool( "gib" ) && damageDef->GetBool( "gib" ) ) {
			Gib( dir, damageDefName );
			}
		} else {
			Pain( inflictor, attacker, damage, dir, location );
		}
	} else {
		// don't accumulate knockback
		if ( af.IsLoaded() ) {
			// clear impacts
			af.Rest();

			// physics is turned off by calling af.Rest()
			BecomeActive( TH_PHYSICS );
		}
	}

}
コード例 #4
0
/*
===============
idActor::Event_IdleAnim
===============
*/
void idActor::Event_IdleAnim( int channel, const char* animname )
{
	const int anim = GetAnim( channel, animname );
	if( !anim )
	{
		if( ( channel == ANIMCHANNEL_HEAD ) && head.GetEntity() )
		{
			gameLocal.DPrintf( "missing '%s' animation on '%s' (%s)\n", animname, name.c_str(), spawnArgs.GetString( "def_head", "" ) );
		}
		else
		{
			gameLocal.DPrintf( "missing '%s' animation on '%s' (%s)\n", animname, name.c_str(), GetEntityDefName() );
		}
		
		switch( channel )
		{
			case ANIMCHANNEL_HEAD :
				headAnim.BecomeIdle();
				break;
				
			case ANIMCHANNEL_TORSO :
				torsoAnim.BecomeIdle();
				break;
				
			case ANIMCHANNEL_LEGS :
				legsAnim.BecomeIdle();
				break;
				
			default:
				gameLocal.Error( "Unknown anim group" );
		}
		
		idThread::ReturnInt( false );
		return;
	}
		
	if (ANIMCHANNEL_ALL == channel)
	{
		// start from 1, skip ANIMCHANNEL_ALL
		for (int i = 1; i < ANIMCHANNEL_COUNT; ++i)
			InternalIdleAnim(i, anim);
	}
	else
		InternalIdleAnim(channel, anim);
	
	idThread::ReturnInt(1);
}
コード例 #5
0
/*
===============
idActor::Event_PlayCycle
===============
*/
void idActor::Event_PlayCycle( int channel, const char* animname )
{
	animFlags_t	flags;
	int			anim;
	
	anim = GetAnim( channel, animname );
	if( !anim )
	{
		if( ( channel == ANIMCHANNEL_HEAD ) && head.GetEntity() )
		{
			gameLocal.DPrintf( "missing '%s' animation on '%s' (%s)\n", animname, name.c_str(), spawnArgs.GetString( "def_head", "" ) );
		}
		else
		{
			gameLocal.DPrintf( "missing '%s' animation on '%s' (%s)\n", animname, name.c_str(), GetEntityDefName() );
		}
		idThread::ReturnInt( false );
		return;
	}
	
	switch( channel )
	{
		case ANIMCHANNEL_HEAD :
			headAnim.idleAnim = false;
			headAnim.CycleAnim( anim );
			flags = headAnim.GetAnimFlags();
			if( !flags.prevent_idle_override )
			{
				if( torsoAnim.IsIdle() && legsAnim.IsIdle() )
				{
					torsoAnim.animBlendFrames = headAnim.lastAnimBlendFrames;
					SyncAnimChannels( ANIMCHANNEL_TORSO, ANIMCHANNEL_HEAD, headAnim.lastAnimBlendFrames );
					legsAnim.animBlendFrames = headAnim.lastAnimBlendFrames;
					SyncAnimChannels( ANIMCHANNEL_LEGS, ANIMCHANNEL_HEAD, headAnim.lastAnimBlendFrames );
				}
			}
			break;
			
		case ANIMCHANNEL_TORSO :
			torsoAnim.idleAnim = false;
			torsoAnim.CycleAnim( anim );
			flags = torsoAnim.GetAnimFlags();
			if( !flags.prevent_idle_override )
			{
				if( headAnim.IsIdle() )
				{
					headAnim.animBlendFrames = torsoAnim.lastAnimBlendFrames;
					SyncAnimChannels( ANIMCHANNEL_HEAD, ANIMCHANNEL_TORSO, torsoAnim.lastAnimBlendFrames );
				}
				if( legsAnim.IsIdle() )
				{
					legsAnim.animBlendFrames = torsoAnim.lastAnimBlendFrames;
					SyncAnimChannels( ANIMCHANNEL_LEGS, ANIMCHANNEL_TORSO, torsoAnim.lastAnimBlendFrames );
				}
			}
			break;
			
		case ANIMCHANNEL_LEGS :
			legsAnim.idleAnim = false;
			legsAnim.CycleAnim( anim );
			flags = legsAnim.GetAnimFlags();
			if( !flags.prevent_idle_override )
			{
				if( torsoAnim.IsIdle() )
				{
					torsoAnim.animBlendFrames = legsAnim.lastAnimBlendFrames;
					SyncAnimChannels( ANIMCHANNEL_TORSO, ANIMCHANNEL_LEGS, legsAnim.lastAnimBlendFrames );
					if( headAnim.IsIdle() )
					{
						headAnim.animBlendFrames = legsAnim.lastAnimBlendFrames;
						SyncAnimChannels( ANIMCHANNEL_HEAD, ANIMCHANNEL_LEGS, legsAnim.lastAnimBlendFrames );
					}
				}
			}
			break;
			
		default:
			gameLocal.Error( "Unknown anim group" );
	}
	
	idThread::ReturnInt( true );
}
コード例 #6
0
/*
===============
idActor::Event_PlayAnim
===============
*/
void idActor::Event_PlayAnim( int channel, const char* animname )
{
	const int	anim = GetAnim( channel, animname );
	if( !anim )
	{
		if( ( channel == ANIMCHANNEL_HEAD ) && head.GetEntity() )
		{
			gameLocal.DPrintf( "missing '%s' animation on '%s' (%s)\n", animname, name.c_str(), spawnArgs.GetString( "def_head", "" ) );
		}
		else
		{
			gameLocal.DPrintf( "missing '%s' animation on '%s' (%s)\n", animname, name.c_str(), GetEntityDefName() );
		}
		idThread::ReturnInt( 0 );
		return;
	}
	
	if ( ANIMCHANNEL_ALL == channel )
	{
		// start from 1, skip ANIMCHANNEL_ALL
		for ( int i = 1; i < ANIMCHANNEL_COUNT; ++i )
			InternalPlayAnim( i, anim );
	}
	else
		InternalPlayAnim( channel, anim );

	idThread::ReturnInt( 1 );
}