Selecting a target
by Christian · in Torque Game Engine · 03/28/2007 (12:27 am) · 0 replies
This is Jon Jorajuria's code, tried to contact him to ask but his e-mails are not updated. My question is how do I initialize an ai that will work with this? Such as -
Thanks.
%ai = new AIPlayer() {
datablock = "Default";
position = "149 150 151";
};function serverCmdSelectNearestTarget(%client)
{
%actor = %client.actor;
%searchMasks = $TypeMasks::ShapeBaseObjectType;
%radius = 150;
%pos = %actor.getPosition();
InitContainerRadiusSearch(%pos, %radius, %searchMasks);
while ((%targetObject = containerSearchNext()) != 0)
{
%id = %targetObject.getId();
%name = %targetObject.getName();
%class = %targetObject.getClassName();
if(%id == %actor.getId())
continue;
if(%class !$= "Actor" && %class !$= "AIActor")
continue;
%ghostIndex = %client.GetGhostIndex(%targetObject);
commandToClient(%client, 'SelectObj', %ghostIndex);
return;
}
return;
}Thanks.