Jump to content

AIPlayer mountImage problem


Code_Man

Recommended Posts

I cant get a bot to have a weapon, i tried in 3.10.1 and git development.


Following code is what i tried, according to the docs its all in order.

 

function addBot()
{
  %name = "";
  %spawnPoint = pickPlayerSpawnPoint("BotDropPoints");
  %bot = AIPlayer::spawnAtLocation(%name, %spawnPoint.getTransform());
  %bot.clearWeaponCycle();

  %bot.setInventory(Ryder, 1);
  %bot.setInventory(RyderClip, %bot.maxInventory(RyderClip));
  %bot.setInventory(RyderAmmo, %bot.maxInventory(RyderAmmo));    // Start the gun loaded
  %bot.addToWeaponCycle(Ryder);

  %bot.mountImage(Ryder, 0);
  return %bot;
}

 

Did i do something wrong or is the engine bugged?

Link to comment
Share on other sites

//Its been a while since i did this with TGE but , this might help you to understand .
//I am assuming the BOT uses the default player datablock . 
//
//in the file ./scripts /server/item.CS
//
//look at the function
//ItemData::createItem(%data)
//{
//   %obj = new Item()
//
//   {
//      dataBlock = %data;
//      static = true;
//      rotate = true;
//   };
//
//echo(ITEM/WEAPON CREATED = " @ %obj);//check the console for this message and you'll get the
//                                       //item ID .The Image ID >might< be this number + 1 as it it 
//                                       //was with TGE , but I havent tried it recently .
//   return %obj;
//}
//
//=====================================================
//
//in the file
//./scripts/server/player.CS
//
//
//look at the function 
//
//Player::use(%player, %data)
//{
//   // No mounting/using weapons when you're driving!
//   if (%player.isPilot())
//      return(false);
//
//   Parent::use(%player, %data);     //this data should be the ID of the item , dont remember , might be the image ID , or "name" 
//
//}
//
//=====================================================
//
//look at these files
//./scripts/server/weapon.CS and read the function weapon::onUse 
//./scripts /server/inventory.CS shows lots more about the use methodology . if you will .
//
//LONG story short , you might need to use the "use" method to make it happen .
//%obj.use(BOT ID , DATA ID ) . 
//
//
//======================================================
//!!!! check this out !!!!
//The thing to think about here is you'll need a path for the aiPlayer to follow .
//
//./scripts/server/AiPlayer.CS
//
//function AIPlayer::spawn(%path)//------------------------------this path is an ID number or "NAME" <-strings are quoted
//{
//   %player = AIPlayer::spawnOnPath("Shootme", %path);
//
//   if (isObject(%player))
//   {
//      %player.followPath(%path, -1);// ------------------1 will cause the BOT to follow the path in a continous loop , otherwise use the number where you want the bot to stop .
//
//      // slow this sucker down, I'm tired of chasing him!
//      %player.setMoveSpeed(0.5);
//
//      //%player.mountImage(xxxImage, 0);      //------------------------You should find this most interesting
//      //%player.setInventory(xxxAmmo, 1000);  //------------------------
//      //%player.think();                   
//
//      return %player;
//   }
//   else
//      return 0;
//}
//
//=========================================================
//
//So , Im really vague on this , Im a beginner with T3D as well , hope you can use something here . I could not find an addbot function .
Link to comment
Share on other sites

Items are for picking up and adding to the inventory. WeaponImage is a is the actual weapon that the player holds.

If you're using the stock player datablock for your AIPlayer then you can mount weapons and add items to the inventory in the same way the default player does. Check scripts/server/gameCore.cs gameCore::Loadout function for more info.

 

function GameCore::loadOut(%game, %player)
{
   //echo (%game @"\c4 -> "@ %game.class @" -> GameCore::loadOut");
 
   %player.clearWeaponCycle();
 
   %player.setInventory(Ryder, 1);
   %player.setInventory(RyderClip, %player.maxInventory(RyderClip));
   %player.setInventory(RyderAmmo, %player.maxInventory(RyderAmmo));    // Start the gun loaded
   %player.addToWeaponCycle(Ryder);
 
   %player.setInventory(Lurker, 1);
   %player.setInventory(LurkerClip, %player.maxInventory(LurkerClip));
   %player.setInventory(LurkerAmmo, %player.maxInventory(LurkerAmmo));  // Start the gun loaded
   %player.addToWeaponCycle(Lurker);
 
   %player.setInventory(LurkerGrenadeLauncher, 1);
   %player.setInventory(LurkerGrenadeAmmo, %player.maxInventory(LurkerGrenadeAmmo));
   %player.addToWeaponCycle(LurkerGrenadeLauncher);
 
   %player.setInventory(ProxMine, %player.maxInventory(ProxMine));
   %player.addToWeaponCycle(ProxMine);
 
   %player.setInventory(DeployableTurret, %player.maxInventory(DeployableTurret));
   %player.addToWeaponCycle(DeployableTurret);
 
   if (%player.getDatablock().mainWeapon.image !$= "")
   {
      %player.mountImage(%player.getDatablock().mainWeapon.image, 0);
   }
   else
   {
      %player.mountImage(Ryder, 0);
   }
}

 

Now the above script adds maximum values of all available items that the player datablock can carry. Note, that to be able to pick up an item, that item must have an inventory value in the player datablock. AIPlayer does not have "WeaponCycles" as that part of the player's input for selecting which weaponImage to mount.


The loadout chooses which item is the mainWeapon in the player's datablock and gets the .image of that item and mounts it to the player as a weaponImage.


For an AIPlayer try calling this function after the AIPlayer has spawned:

 

function AIPlayer::loadOutBot(%player)
{
   %player.setInventory(Ryder, 1);
   %player.setInventory(RyderClip, %player.maxInventory(RyderClip));
   %player.setInventory(RyderAmmo, %player.maxInventory(RyderAmmo));    // Start the gun loaded
 
   %player.setInventory(Lurker, 1);
   %player.setInventory(LurkerClip, %player.maxInventory(LurkerClip));
   %player.setInventory(LurkerAmmo, %player.maxInventory(LurkerAmmo));  // Start the gun loaded
 
   %player.setInventory(LurkerGrenadeLauncher, 1);
   %player.setInventory(LurkerGrenadeAmmo, %player.maxInventory(LurkerGrenadeAmmo));
 
   if (%player.getDatablock().mainWeapon.image !$= "")
   {
      %player.mountImage(%player.getDatablock().mainWeapon.image, 0);
   }
   else
   {
      %player.mountImage(Ryder, 0);
   }
}
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...