Esempio n. 1
0
//
// Name:        ItemPickup()
// Class:       Armor
//
// Description: Handles Sentients Picking up armor... In this case, however,
//              Only Actors are allowed to actually pick up armor
//
// Parameters:  Entity *other - The entity doing the picking up
//              qboolean add_to_inventory - Here to make parameters match
//
// Returns:     NULL -- This function doesn't actually return the armor, instead
//              it has the entity picking it up process and armor event
//
Item *Armor::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean )
{
	Sentient *sent;
	str      realname;

	Q_UNUSED(add_to_inventory);
	
	// For right now, we only want players to pick up armor
	if ( !other->isSubclassOf( Player ) )
		return NULL;

	if ( !Pickupable( other ) )
		return NULL;
	
	sent = (Sentient*)other;
	
	// Check if we NEED to pick up the armor, if the armor we are about to pick up is
	// less than the armor we have, we don't want to pick it up
	if ( !_needThisArmor(sent) )
		return NULL;
	
	// Handle the actual "Picking Up"
	_pickupArmor(sent);
	
	// Give the Sentient the Armor
	Event *armorEvent;
	armorEvent = new Event(EV_Sentient_GiveArmor);
	armorEvent->AddString( item_name.c_str() );
	armorEvent->AddFloat( amount );
	armorEvent->AddInteger( true );
	
	sent->ProcessEvent(armorEvent);	
	
	return NULL; // This doesn't create any items
}
Esempio n. 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 );
}
Esempio n. 3
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 );
}