//--------------------------------------------------------------
//
// Name:			processGameplayData
// Class:			WeaponDualWield
//
// Description:		Process gameplay data
//
// Parameters:		Event *ev -- not used
//
// Returns:			None
//
//--------------------------------------------------------------
void WeaponDualWield::processGameplayData( Event * )
{
	ClassDef *cls;

	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm->hasObject(getArchetype()) )
		return;

	str leftmodel = gpm->getStringValue(getArchetype(), "leftmodel");
	str rightmodel = gpm->getStringValue(getArchetype(), "rightmodel");

	if ( !_leftweapon )
	{
		cls = getClass( leftmodel );
		if ( !cls )
		{
			SpawnArgs args;
			args.setArg( "model", leftmodel );
			cls = args.getClassDef();
			if ( !cls )
				return;
		}
		_leftweapon = ( Weapon * )cls->newInstance();
		_leftweapon->setModel( leftmodel );
		_leftweapon->ProcessPendingEvents();
		_leftweapon->hideModel();
	}

	if ( !_rightweapon )
	{
		cls = getClass( rightmodel );
		if ( !cls )
		{
			SpawnArgs args;
			args.setArg( "model", rightmodel );
			cls = args.getClassDef();
			if ( !cls )
				return;
		}
		_rightweapon = ( Weapon * )cls->newInstance();
		_rightweapon->setModel( rightmodel );
		_rightweapon->ProcessPendingEvents();
		_rightweapon->hideModel();
	}
	
	// Process gameplay data on myself.
	Weapon::processGameplayData( NULL );
}
Exemple #2
0
HoldableItem *HoldableItem::createHoldableItem( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	HoldableItem *holdableItem;


	fullname = "HoldableItem";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &HoldableItem::ClassInfo, cls ) )
		return NULL;

	holdableItem = (HoldableItem *)cls->newInstance();

	if ( !holdableItem )
		return NULL;

	holdableItem->init( modelName, sentient );

	return holdableItem;
}
Exemple #3
0
Rune *Rune::CreateRune( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	Rune *rune;


	fullname = "Rune";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &Rune::ClassInfo, cls ) )
		return NULL;

	rune = (Rune *)cls->newInstance();

	if ( !rune )
		return NULL;

	rune->init( modelName, sentient );

	return rune;
}
Exemple #4
0
Powerup *Powerup::CreatePowerup( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	Powerup *powerup;


	fullname = "Powerup";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &Powerup::ClassInfo, cls ) )
		return NULL;

	powerup = (Powerup *)cls->newInstance();

	if ( !powerup )
		return NULL;

	powerup->init( modelName, sentient );

	return powerup;
}
Exemple #5
0
//--------------------------------------------------------------
//
// Name:			G_DropItemCmd
// Class:			None
//
// Description:		Drops an item that is clicked on from the inventory
//
// Parameters:		gentity_t -- the entity issuing the command.  This
//							 is the player who issued the command.
//
// Returns:			qboolean -- true if the command was executed.	
//
//--------------------------------------------------------------
qboolean G_DropItemCmd( const gentity_t *ent )
{
	if ( gi.argc() < 1 ) return false ;
	if ( !ent->entity->isSubclassOf( Player ) ) return false ;
	
	Player		*player			= (Player*)ent->entity ;
	str			 objectName		= gi.argv( 1 );
	str			 propertyName	= gi.argv( 2 );
	
	GameplayManager *gpm = GameplayManager::getTheGameplayManager();
	if ( !gpm ) return false ;
	
	str itemName	= gpm->getStringValue( objectName, propertyName );
	if ( itemName == "Empty" )
		return false;
	
	str tikiName	= gpm->getStringValue( itemName, "model" );
	str itemType	= gpm->getStringValue( itemName, "class" );
	str	playerItem("CurrentPlayer." + itemType);
	
	if ( !gpm->hasObject(playerItem) )
	{
		gi.WPrintf( "Warning: Unknown item type %s for item %s", itemType.c_str(), itemName.c_str() );
		return false ;
	}
	
	// Empty the slot
	gpm->setStringValue( objectName, propertyName, "Empty" );
	
	// Give the player the item to drop
	//Item *givenItem = player->giveItem(tikiName);
	
	Weapon *dropweap;
	ClassDef *cls;
	cls = getClass( tikiName.c_str() );
	if ( !cls )
	{
		SpawnArgs args;
		args.setArg( "model", tikiName.c_str() );
		cls = args.getClassDef();
		if ( !cls )
			return false;
	}
	dropweap = ( Weapon * )cls->newInstance();
	dropweap->setModel( tikiName.c_str() );
	dropweap->ProcessPendingEvents();
	dropweap->SetOwner(player);
	dropweap->hideModel();
	dropweap->setAttached(true);
	dropweap->Drop();
	
	return true ;
}
//====================
//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 );
			}
		}
   }
//====================
//Player::SpawnEntity
//====================
void Player::SpawnEntity
	(
	Event *ev
	)

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

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

   name = ev->GetString( 1 );
   if ( !name.length() )
		{
		ScriptError( "Must specify an entity name" );
		return;
		}

   // create a new entity
   SpawnArgs args;

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

   cls = args.getClassDef();
   if ( !cls )
      {
      cls = &Entity::ClassInfo;
      }

   if ( !checkInheritance( &Entity::ClassInfo, cls ) )
      {
      ScriptError( "%s is not a valid Entity", name.c_str() );
      return;
      }

   ent = ( Entity * )cls->newInstance();

   e = new Event( EV_Model );
   e->AddString( name.c_str() );
   ent->PostEvent( e, EV_PRIORITY_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.x = 0;
   v.y = delta.toYaw();
   v.z = 0;

   e = new Event( EV_SetAngles );
   e->AddVector( v );
   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 );
			}
		}

   e = new Event( EV_SetAnim );
   e->AddString( "idle" );
   ent->PostEvent( e, EV_SPAWNARG );
   }