Beispiel #1
0
//--------------------------------------------------------------
//
// Name:			processGameplayData
// Class:			HealthInventoryItem
//
// Description:		Called usually from the tiki file after all other
//					server side events are called.
//
// Parameters:		Event *ev -- not used
//
// Returns:			None
//
//--------------------------------------------------------------
void HealthInventoryItem::processGameplayData( Event * )
{
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm->hasObject(getArchetype()) )
		return;

	str objname = getArchetype();
	str useanim, usetype, usethread;
	if ( gpm->hasProperty(objname, "useanim") )
		useanim = gpm->getStringValue(objname, "useanim");
	if ( gpm->hasProperty(objname, "usethread") )
		usethread = gpm->getStringValue(objname, "usethread");
	if ( gpm->hasProperty(objname + ".Pickup", "icon") )
		usetype = gpm->getStringValue(objname + ".Pickup", "icon");

	// If any of these strings were set, add to our UseData object.
	if ( useanim.length() || usethread.length() || usetype.length() )
	{
		if ( !useData )
			useData = new UseData();
		
		useData->setUseAnim(useanim);
		useData->setUseThread(usethread);
		useData->setUseType(usetype);
	}
}
Beispiel #2
0
void Health::PickupHealth( Event *ev )
{
	Sentient *sen;
	Entity *other;
	
	other = ev->GetEntity( 1 );
	if ( !other || !other->isSubclassOf( Sentient ) )
	{
		return;
	}
	
	sen = ( Sentient * )other;
	
	if ( sen->health >= sen->max_health )
		return;
	
	if ( !ItemPickup( other, false ) )
	{
		return;
	}
	
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( gpm->hasObject(getArchetype()) )
	{
		if ( gpm->hasFormula("HealthPotion") )
		{
			GameplayFormulaData fd(this);
			amount = gpm->calculate("HealthPotion", fd, sen->max_health);
		}
		str snd = gpm->getStringValue(getArchetype() + ".Use", "wav");
		if ( snd.length() )
		{
			int channel = CHAN_BODY;
			float volume = -1.0f;
			float mindist = -1.0f;
			if ( gpm->hasProperty(getArchetype() + ".Use","channel") )
				channel = (int)gpm->getFloatValue(getArchetype() + ".Use", "channel");
			if ( gpm->hasProperty(getArchetype() + ".Use","volume") )
				volume = (int)gpm->getFloatValue(getArchetype() + ".Use", "volume");
			if ( gpm->hasProperty(getArchetype() + ".Use","mindist") )
				mindist = (int)gpm->getFloatValue(getArchetype() + ".Use", "mindist");
			Sound(snd, channel, volume, mindist);
		}
	}
	
	sen->health += (float)amount;
	
	if ( sen->health > sen->max_health )
	{
		sen->health = sen->max_health;
	}
	
	// If we are on fire stop it
	
	sen->ProcessEvent( EV_Sentient_StopOnFire );
}
Beispiel #3
0
/*
============
PlaceItem

Puts an item back in the world
============
*/
void Item::PlaceItem( void )
{
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( gpm->hasProperty(getArchetype(), "noautopickup") )
	{
		setContents( CONTENTS_USABLE );
		setSolidType( SOLID_BBOX );
	}
	else
	{
		setSolidType( SOLID_TRIGGER );
	}
	
	setMoveType( MOVETYPE_TOSS );
	showModel();
	
	groundentity = NULL;
}
Beispiel #4
0
void HealthInventoryItem::Use( Event *ev )
{
	Entity      *other;
	Sentient    *sen;
	//Event			*event;
	str			sound_name;
	
	
	other = ev->GetEntity<Entity>( 1 );
	if ( !other || !other->isSubclassOf( Sentient ) )
	{
		return;
	}
	
	sen = ( Sentient * )other;
	
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( gpm->hasObject(getArchetype()) )
	{
		if ( gpm->hasFormula("HealthPotion") )
		{
			GameplayFormulaData fd(this);
			amount = gpm->calculate("HealthPotion", fd, sen->max_health);
		}
		str snd = gpm->getStringValue(getArchetype() + ".Use", "wav");
		if ( snd.length() )
		{
			int channel = CHAN_BODY;
			float volume = -1.0f;
			float mindist = -1.0f;
			if ( gpm->hasProperty(getArchetype() + ".Use","channel") )
				channel = (int)gpm->getFloatValue(getArchetype() + ".Use", "channel");
			if ( gpm->hasProperty(getArchetype() + ".Use","volume") )
				volume = (int)gpm->getFloatValue(getArchetype() + ".Use", "volume");
			if ( gpm->hasProperty(getArchetype() + ".Use","mindist") )
				mindist = (int)gpm->getFloatValue(getArchetype() + ".Use", "mindist");
			Sound(snd, channel, volume, mindist);
		}
	}
	
	sen->health += (float)amount;
	
	if ( sen->health > sen->max_health )
	{
		sen->health = sen->max_health;
	}
	
	// If we are on fire stop it
	
	sen->ProcessEvent( EV_Sentient_StopOnFire );
	
	// Spawn special effect around sentient
	
	// Uncomment if we need it
	/*sound_name = GetRandomAlias( "snd_use" );
	
	if ( sound_name )
	other->Sound( sound_name.c_str(), 0 );
	  
	event = new Event( EV_AttachModel );
	event->AddString( "models/fx_tikifx2.tik" );
	event->AddString( "Bip01 Spine" );
	// set scale
	event->AddFloat( 1.0f );
	// set targetname
	event->AddString( "regen" );
	// set detach_at_death
	event->AddInteger( 1 );
	// set remove_time
	event->AddFloat( 2.0f );
	other->ProcessEvent( event );*/
	
	PostEvent( EV_Remove, 0.0f );
}
Beispiel #5
0
Item * Item::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean checkautopickup )
{
	Sentient * sent;
	Item * item = NULL;
	str realname;
	
	// Query the gameplay manager and see if we should not auto-pickup this item
	if ( checkautopickup )
	{
		GameplayManager *gpm = GameplayManager::getTheGameplayManager();
		if ( gpm->hasProperty(getArchetype(), "noautopickup") )
			return NULL;
	}
	
	if ( !Pickupable( other ) )
	{
		return NULL;
	}
	
	sent = ( Sentient * )other;
	
	if ( add_to_inventory )
	{
		item = sent->giveItem( model, getAmount(), true );
		
		
		if ( !item )
			return NULL;
	}
	else
	{
		item = this;
	}
	
	//
	// make sure to copy over the coolness factor :)
	//
	item->coolitem = coolitem;
	item->cool_dialog = cool_dialog;
	item->cool_anim = cool_anim;
	item->coolitemforced = coolitemforced;
	
	//
	// let our sent know they received it
	// we put this here so we can transfer information from the original item we picked up
	//

	if ( !isSubclassOf( Weapon ) || add_to_inventory )
		sent->ReceivedItem( item );
	
	realname = GetRandomAlias( "snd_pickup" );
	if ( realname.length() > 1 )
		sent->Sound( realname, CHAN_ITEM );
	
	if ( !Removable() )
	{
		// leave the item for others to pickup
		return item;
	}
	
	look_at_me = false;
	
	CancelEventsOfType( EV_Item_DropToFloor );
	CancelEventsOfType( EV_Item_Respawn );
	CancelEventsOfType( EV_FadeOut );
	
	setSolidType( SOLID_NOT );
	
	if ( animate && animate->HasAnim( "pickup" ) )
		animate->RandomAnimate( "pickup", EV_Item_PickupDone );
	else
	{
		if ( !no_remove )
		{
			if ( _missingSkin )
			{
				ChangeSkin( _missingSkin, true );
			}
			else
			{
				hideModel();
			}
			
			if ( !Respawnable() )
				PostEvent( EV_Remove, FRAMETIME );
		}
	}
	
	if ( Respawnable() )
		PostEvent( EV_Item_Respawn, RespawnTime() );
	
	// fire off any pickup_thread's
	if ( pickup_thread.length() )
	{
		ExecuteThread( pickup_thread );
	}
	
	
	if ( item && multiplayerManager.checkFlag( MP_FLAG_INSTANT_ITEMS ) )
	{
		Event *ev;
		
		ev = new Event( EV_InventoryItem_Use );
		ev->AddEntity( other );
		
		item->ProcessEvent( ev );
	}
	
	return item;
}
Beispiel #6
0
//--------------------------------------------------------------
// Name:		init()
// Class:		TorsoAimAndFireWeapon
//
// Description:	Initializes the behavior
//
// Parameters:	Actor &self
//
// Returns:		None
//--------------------------------------------------------------
void TorsoAimAndFireWeapon::init( Actor &self )
{
	_self = &self;

	//Set Our Controller Tag and set up our angles
	self.SetControllerTag( ActorTorsoTag, gi.Tag_NumForName( self.edict->s.modelindex, "Bip01 Spine1" ) );
	_currentTorsoAngles = self.GetControllerAngles( ActorTorsoTag );

	_animDone = false;
	_canAttack = true;

	_aimAnim		= "idle";
	_preFireAnim	= "idle";
	_fireAnim		= "idle";
	_postFireAnim	= "idle";

	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm->hasObject(self.getArchetype()) )
		return;
		
	str objname = self.combatSubsystem->GetActiveWeaponArchetype();	
	objname = "Hold" + objname;

	if ( gpm->hasProperty(objname, "Aim") )
		_aimAnim = gpm->getStringValue( objname , "Aim" );
	
	if ( gpm->hasProperty( objname , "PreFire" ) )
		_preFireAnim = gpm->getStringValue( objname , "PreFire" );

	if ( gpm->hasProperty( objname , "Fire" ) )
		_fireAnim = gpm->getStringValue( objname , "Fire" );

	if ( gpm->hasProperty( objname , "PostFire" ) )
		_postFireAnim = gpm->getStringValue( objname , "PostFire" );

	
	if ( gpm->hasProperty( objname , "AimTimeMin" ) )
		_aimTimeMin = gpm->getFloatValue( objname , "AimTimeMin" );

	if ( gpm->hasProperty( objname , "AimTimeMax" ) )
		_aimTimeMax = gpm->getFloatValue( objname , "AimTimeMax" );

	if ( gpm->hasProperty( objname , "FireTimeMin" ) )
		_fireTimeMin = gpm->getFloatValue( objname , "FireTimeMin" );

	if ( gpm->hasProperty( objname , "FireTimeMax" ) )
		_fireTimeMax = gpm->getFloatValue( objname , "FireTimeMax" );


	if ( gpm->hasProperty( objname , "ShotCount" ) )
		_shots = (int)gpm->getFloatValue( objname , "ShotCount" );

	float spreadX, spreadY;
	spreadX = self.combatSubsystem->GetDataForMyWeapon( "spreadx" );
	spreadY = self.combatSubsystem->GetDataForMyWeapon( "spready" );
	self.combatSubsystem->OverrideSpread( spreadX , spreadY );


	//Clear Out Our VolleyCount
	_self->shotsFiredThisVolley = 0;

	updateEnemy();
	
}
Beispiel #7
0
//--------------------------------------------------------------
// Name:		init()
// Class:		GotoCurrentHelperNode
//
// Description:	Initializes the behavior
//
// Parameters:	Actor &self
//
// Returns:		None
//--------------------------------------------------------------
void GotoCurrentHelperNode::init( Actor &self )
{
	str objname;
	str movementMode;
	str stateName;
	GameplayManager *gpm;

	self.movementSubsystem->setFaceEnemy( _faceEnemy );
	//
	// Animation Selection
	// 1st We check if we have an explicit animation in the GPD for our state, if we
	// do, we're going to use that.
	//
	// Next, we'll check for StateVar, and pull the animation from that...
	// If we have nothing there, then we'll just assume the animation passed in
	// is the animation we are going to try and use

	//
	//First check if we're even in the GPM
	gpm = GameplayManager::getTheGameplayManager();
	if ( gpm->hasObject(self.getArchetype()) )
		{
			//Now we're going to check and see if we have state data
			//in the GPM for our current state that has our movement
			//mode in it.
			objname = self.getArchetype();
			stateName = self.currentState->getName();
			objname = objname + "." + stateName;
			
			//If we have a MovementMode property, use its value, else use
			//the default value of RUN
			if ( gpm->hasProperty( objname , "MovementMode" ) )
				movementMode = gpm->getStringValue( objname , "MovementMode" );
			else
				movementMode = "RUN";


			//Now, depending on what our movementMode is, we set a proper
			//movement animation
			objname = self.getArchetype();
			objname = objname + "." + self.GetAnimSet();

			if ( movementMode == "RUN" )
				{
				if ( gpm->hasProperty(objname, "Run") )
					_movementAnim = gpm->getStringValue( objname , "Run" );

				return;		
				}

			if ( movementMode == "WALK" )
				{
				if ( gpm->hasProperty(objname, "Walk") )
					_movementAnim = gpm->getStringValue( objname , "Walk" );
				return;				
				}

			}

	// We didn't find anything in the GPD, so let's check for 
	// state vars
	str movementAnim = self.GetStateVar( _movementAnim );

	if ( movementAnim.length() )
		_movementAnim = movementAnim;	

}