PDA

View Full Version : AI Fire Weapon from Unrealscript



Dode
02-22-2011, 11:32 AM
Hey I was just wondering if anybody has working code to make the AI shoot at the player through Unrealscript?

Right now I am extending from AIController for my AI and UTPawn for my custom bot.

Kinos
02-22-2011, 12:07 PM
extend from gameAIController, use pawn.botFire(true). DONE!!
FYI, true is a boolean, if you want them to stop, use false instead of true.

Dode
02-22-2011, 12:10 PM
Thanks for replying to my question twice Kinos in both threads haha I really want my bots to just shoot at me. I'll give your method a try.

Dode
02-22-2011, 12:20 PM
The custom Pawn is still not firing Kinos... Heres my AI Controller class.

class MyAIController extends gameAIController;

...farther down in class Guard variable is just an instance of my custom bot class.
//Where the bot attacks player...
state Attack
{
Begin:
Pawn.Acceleration = vect(0,0,0);
Guard.SetAttacking(true);


while(true && thePlayer.Health > 0)
{
Worldinfo.Game.Broadcast(self, "Attacking Player");
distanceToPlayer = VSize(thePlayer.Location - Pawn.Location);

//Move to player again out of shooting range distance
//Don't worry about the commenting below it's just failed attempts
//to get the bot to shoot the player
//Out of range to shoot player
if (distanceToPlayer > attackDistance)
{
Worldinfo.Game.Broadcast(self, "Stopped firing");
Guard.SetAttacking(false);
Pawn.BotFire(false);
GotoState('Chaseplayer');
break;
}
//Within range to shoot player
else
{
Worldinfo.Game.Broadcast(self, "firing");
Pawn.BotFire(true);
}
Sleep(1);
}
//Done attacking or player is dead
Guard.SetAttacking(false);

}

Dode
02-22-2011, 04:37 PM
Still can't manage to get bots to fire any help?