The Exiled
http://theexiled.pwnageservers.com/forum/

Spawning a bot by switch
http://theexiled.pwnageservers.com/forum/viewtopic.php?f=7&t=4
Page 1 of 1

Author:  TE-Krogoth [ Wed Jun 08, 2005 8:57 am ]
Post subject:  Spawning a bot by switch

Open up your map in editor mode.
Click MissionGroup
Press Ctrl N
Open MissionGroup
Click on the new simgroup
Name it AI
Now put your bots in there.
Save it

Open your Mission file. (.mis)
Scroll all the way to the very bottom.
Put this in.

Code:
function AI::wieldWeapons(%aiName)
{
   %aiId = AI::getId(%aiName);
   Player::setItemCount(%aiId, Railgun, 1); // this can be any weapon
   Player::setItemCount(%aiId, RailAmmo, 10000); //be sure to give it its ammo
   %rate = Player::getSensorSupression(%aiId) + 5;
   Player::setSensorSupression(%aiId, %rate);
   //GameBase::startFadeout(%aiId);
   Player::mountItem(%aiId, EnergyPack, 1);
   AI::SetVar(%aiName, triggerPct, 0.03 );
   AI::setVar(%aiName, iq, 100 );
   AI::setVar(%aiName, attackMode, 1); //tells it what mode its in
   AI::setAutomaticTargets( %aiName );
   ai::callbackPeriodic(%aiName, 3, ai::AnniWeaponChange);
}

function ai::AnniWeaponChange(%aiName)
{
   %aiId = AI::getId(%aiName);
   %curTarget = ai::getTarget( %aiName );

   if(%curTarget == -1)
   {
   return;
   }

   %targLoc = GameBase::getPosition(Client::getOwnedObject(%curTarget));
   %aiLoc = GameBase::getPosition(Client::getOwnedObject(%aiId));
   %targetDist = Vector::getDistance(%aiLoc, %targLoc);
   if(%targetDist > 25)
   {
      Player::mountItem(%aiId, Railgun, 0); // if you changed the weapon don't forget to change it here too
      AI::SetVar(%aiName, triggerPct, 1.0 );
   }   
   else
   {
      if(Player::isJetting(%curTarget))
      {   
         Player::mountItem(%aiId,  Railgun, 0); // if you changed the weapon don't forget to change it here too
         AI::SetVar(%aiName, triggerPct, 1.0 );
      }
      else
      {
         Player::mountItem(%aiId, Railgun, 0);  // if you changed the weapon don't forget to change it here too
         AI::SetVar(%aiName, triggerPct, 0.05 );
      }   
   }
}
 
function Switch2::onCollision(%this, %object) { //Switch2 is the Static Shape and name of the switch  it can be anything you want
%client = Player::Getclient(%object);
if(GameBase::getMapName(%this) == "Switch2") { //Switch2 is the Static Shape and name of the switch  it can be anything you want
  createAI( Battlebot1 , "MissionGroup\\AI\\sniper1", armorTank, "sniper1" ); //sniper1 was the name of the bot, "sniper1" can be changed to whatever you want its name to be
  createAI( Battlebot2 , "MissionGroup\\AI\\sniper2", armorTank, "sniper2" );
  createAI( Battlebot3 , "MissionGroup\\AI\\sniper3", armorTank, "sniper3" );
  createAI( Battlebot4 , "MissionGroup\\AI\\sniper4", armorTank, "sniper4" );
  createAI( Battlebot5 , "MissionGroup\\AI\\sniper5", armorTank, "sniper5" );
  createAI( Battlebot6 , "MissionGroup\\AI\\sniper6", armorTank, "sniper6" );
  AI::wieldWeapons(Battlebot1); // this is to get the bot to have weapons
  AI::wieldWeapons(Battlebot2);
  AI::wieldWeapons(Battlebot3);
  AI::wieldWeapons(Battlebot4);
  AI::wieldWeapons(Battlebot5);
  AI::wieldWeapons(Battlebot6);

}
}


Here's the switch:

Code:


         instant StaticShape "Switch2" {
            dataBlock = "TowerSwitch";
            name = "Switch2";
            position = "-198.33 -254.434 -143.071";
            rotation = "0 0 0";
            destroyable = "True";
            deleteOnDestroy = "False";
            objectiveLine = "15";
            scoreValue = "1";
         };


I used the switch above for what I hit. It can be anything. I put this on here to show its names. The StaticShape and the name need to be the same as the ones in the function above.

Be sure to read the notes (// are the notes)

If it doesn't work, just ask.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/