Ejemplo n.º 1
0
bool HoldableItemProtection::use( void )
{
	Event *event;

	if ( _owner && !multiplayerManager.checkFlag( MP_FLAG_NO_POWERUPS ) )
	{
		if ( !_owner->isSubclassOf( Player ) )
			return false;

		Powerup *powerup;
		Player *player;

		player = (Player *)_owner;

		powerup = Powerup::CreatePowerup( "Protection", "models/item/powerup_protection.tik", player );

		event = new Event( EV_Item_SetAmount );
		event->AddFloat( 15.0f );
		powerup->ProcessEvent( event );

		if ( powerup )
		{
			player->setPowerup( powerup );
			return true;
		}
	}

	return false;
}
Ejemplo n.º 2
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
}
Ejemplo n.º 3
0
void RuneDeathQuad::specificUpdate( float frameTime )
{
	Event *event;

	if ( _owner )
	{
		event = new Event( EV_Hurt );
		event->AddFloat( frameTime * 5.0f );
		event->AddString( "deathQuad" );
		_owner->ProcessEvent( event );
	}
}
Ejemplo n.º 4
0
void Powerup::givePlayerItem( Player *player )
{
	Powerup *powerup;
	const char *modelName;

	modelName = gi.NameForNum( edict->s.modelindex );

	if ( !modelName )
		return;

	powerup = Powerup::CreatePowerup( item_name, modelName, player );

	Event *event = new Event( EV_Item_SetAmount );
	event->AddFloat( amount );
	powerup->ProcessEvent( event );

	player->setPowerup( powerup );
}
Ejemplo n.º 5
0
float RuneEmpathyShield::getDamageTaken( Entity *attacker, float damage, int meansOfDeath )
{
	float realDamage;
	Event *event;

	realDamage = damage;

	if ( attacker && ( meansOfDeath != MOD_EMPATHY_SHIELD ) )
	{
		realDamage *= 0.5;

		event = new Event( EV_Hurt );
		event->AddFloat( realDamage );
		event->AddString( "empathyShield" );
		attacker->ProcessEvent( event );
	}

	return realDamage;
}
Ejemplo n.º 6
0
//====================
//Player::SpawnActor
//====================
void Player::SpawnActor
	(
	Event *ev
	)

	{
	Entity   *ent;
   str      name;
   str      text;
   Vector	forward;
	Vector	up;
   Vector	delta;
	Vector	v;
	int		n;
	int		i;
	ClassDef	*cls;
   Event    *e;

   if ( ev->NumArgs() < 1 )
		{
		ScriptError( "Usage: actor [modelname] [keyname] [value]..." );
		return;
		}

   name = ev->GetString( 1 );
   if ( !name[ 0 ] )
		{
		ScriptError( "Must specify a model name" );
		return;
		}

   if ( !strstr( name.c_str(), ".tik" ) )
      {
      name += ".tik";
      }

   // create a new entity
	SpawnArgs args;

   args.setArg( "model", name.c_str() );

   cls = args.getClassDef();

   if ( cls == &Object::ClassInfo )
      {
      cls = &Actor::ClassInfo;
      }

   if ( !cls || !checkInheritance( &Actor::ClassInfo, cls ) )
      {
      ScriptError( "%s is not a valid Actor", name.c_str() );
      return;
      }
   
   ent = ( Entity * )cls->newInstance();
   e = new Event( EV_Model );
   e->AddString( name.c_str() );
   ent->PostEvent( e, EV_SPAWNARG );

   angles.AngleVectors( &forward, NULL, &up );
   v = origin + ( forward + up ) * 40;

   e = new Event( EV_SetOrigin );
   e->AddVector( v );
   ent->PostEvent( e, EV_SPAWNARG );

   delta = origin - v;
	v = delta.toAngles();

   e = new Event( EV_SetAngle );
   e->AddFloat( v[ 1 ] );
   ent->PostEvent( e, EV_SPAWNARG );

   if ( ev->NumArgs() > 2 )
		{
		n = ev->NumArgs();
		for( i = 2; i <= n; i += 2 )
			{
         e = new Event( ev->GetString( i ) );
         e->AddToken( ev->GetString( i + 1 ) );
         ent->PostEvent( e, EV_SPAWNARG );
			}
		}
   }
void ClientServerCommandManager::ExecuteCommand( char *arguments[], int num_arguments )
{
	const char *command = arguments[ 0 ];
	const char *formatspec;
	int k;

	char **args = arguments + 1;

	Event *ev = new Event( command, EV_NORMAL );

	if( ev->eventnum == 0 )
	{
		delete ev;
		return;
	}

	formatspec = ev->GetFormat();

	for( int i = 0, k = 0; k < num_arguments - 1; k++ )
	{
		const char *argument = args[ i ];
		str vec;

		if( formatspec[ k ] == '\0' ) {
			break;
		}

		if( argument == NULL || *argument == '\0' ) {
			continue;
		}

		switch( formatspec[ k ] )
		{
		case 'b':
		case 'B':
			ev->AddInteger( atoi( argument ) );
			i++;
			break;

		case 's':
		case 'S':
			ev->AddString( argument );
			i++;
			break;

		case 'i':
		case 'I':
			ev->AddInteger( atoi( argument ) );
			i++;
			break;

		case 'f':
		case 'F':
			ev->AddFloat( ( float )atof( argument ) );
			i++;
			break;

		case 'v':
		case 'V':
			vec = args[ i ];
			vec += str( " " ) + args[ i + 1 ];
			vec += str( " " ) + args[ i + 2 ];

			ev->AddVector( Vector( vec.c_str() ) );
			i += 3;
			break;

		default:
			ev->AddString( argument );
			i++;
		}
	}

	try
	{
		ProcessEvent( ev );
	}
	catch( ScriptException exc )
	{
		cgi.Printf( exc.string );
	}
}