Game Development Community

Human Controlled AIPlayer Not attacking

by Robert Stewart · in Torque Game Engine · 10/27/2004 (2:19 pm) · 6 replies

I have a Human Controlled AIPlayer, im trying to get the player to auto attack opposing team player, how do i do this? I use this command now, but the player dosent attack.
%player.setAttackTargetObject($opposingplayer);

#1
10/27/2004 (2:22 pm)
Does the Bot, have a weapon? does that weapon have ammo?
#2
10/27/2004 (2:37 pm)
Yes, i get a error with the above code i posted. Unkown Command setattacktargetobject.
So i must be using wrong comman? what are the attack commands? thanks.
#3
10/27/2004 (2:42 pm)
Try this, %player.dump(); it will show you all the commands for that object. . .I have a feeling the player might just be the client and not the real AI player, can you post your code?
#4
10/27/2004 (2:48 pm)
This is my Player Code
function GameConnection::createPlayer(%this, %spawnPoint)
{
   if (%this.player > 0)  {
      // The client should not have a player currently
      // assigned.  Assigning a new one could result in
      // a player ghost.
      error( "Attempting to create an angus ghost!" );
  }   
  // Create the player object
  %player = new AIPlayer()  {
      dataBlock = PlayerBody;
      client = %this;
 };
   MissionCleanup.add(%player);

   // Player setup...
   %player.setTransform(%spawnPoint);

   %player.setEnergyLevel(60);
   %player.setShapeName(%this.name);
   %player.mountImage(CrossbowImage,0);
   %player.setInventory(CrossbowAmmo,1000);


   // Update the camera to start with the player
   %this.camera.setTransform(%player.getEyeTransform());

   // Give the client control of the player
   %this.player = %player;
   %this.setControlObject(%player);

}
#5
10/27/2004 (3:05 pm)
Robert I belive you are the same Robert who had the click and pick questions . . . . I think there are a couple things that could be the problem.

One for instance is that you want setControlObject to be controlling you camera not the player at least if you are aiming for an RTS feel. I think the attack is a result of the old bot, it requires setting an aimobject then when the bot has something in it's Line of Sight you set it's mounted image (the weapon) to true, so it fires

Instead of isolating small things I will do you a favor and let you look at a "game" (if you want to call it that) I made a while back

It is a sorta faked RTS feel. . . . . check the readMe for a desciption of controls.

A quick synopsis: load mission, the mouse controls the camera's movement, if you press M the cursor will pop up you can then click on the landscape to get the orc to move to the location (as long as the location isn't too far "up sceen"), try getting the orc to hit the ball.

File wise look at game.cs and the
OnclientEnterGame function an in turn the createPlayer functions

track down how the bot recieves movement info in the server/scripts/commands.cs and the client/scripts/playGui.cs files

Best of luck let me know how it works out 4 ya
#6
10/27/2004 (4:09 pm)
Thanks ill try that out now.