Game Development Community


#1
05/30/2005 (8:41 pm)
Hi Matt,
I havn't done much with the default AI, from what I can remeber it's a real basic AI system,
I have used the AIGuard resource here which will provide a more realistic AI, the only thing I got an issue with the resource is the scoring and invitory of bots but I'm working on that.
Hope this helps
#2
02/02/2010 (9:56 pm)
I'm trying to create a simple AI Chaser...


datablock TSShapeConstructor(PlayerDts)
{
baseShape = "~/data/shapes/player/baddie.dts";
sequence0 = "~/data/shapes/player/baddie_root.dsq root";
sequence1 = "~/data/shapes/player/baddie_run.dsq run";
};

datablock PlayerData(baddieBody)
{
renderFirstPerson = false;
shapeFile = "~/data/shapes/baddie/baddie.dts";
};

function PlayerBody::onAdd(%this,%obj)
{

}

function PlayerBody::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
}

function baddieBody::onNewDataBlock(%this,%obj)
{

}

function baddieBody::check(%this, %obj)
{
//HERE I WANT TO CHECK FOR THE PLAYER WITHIN A DISTANCE OF SAY 50,
//AND IF THE PLAYER IS THERE, GETTRANSFORM() TO HIS LOCATION... BUT
//I AM HITTING A WALL RIGHT NOW AND MY BRAIN IS FARTING OUT ON ME...

//I'D THEN NEED TO RUN AN ONCOLLISION TO CHECK IF THEY'VE COLLIDED
//AND THEN DECREASE THE PLAYER HEALTH BASED OFF THAT...
//HELP PLEASE IM KINDA LOST

}
#3
02/02/2010 (10:23 pm)
// Find all player objects within 50 units of %obj
InitContainerRadiusSearch(%obj.getWorldBoxCenter(), 50, $TypeMasks::PlayerObjectType);
while ((%otherPlayer = containerSearchNext()) != 0)
{
   // Insert code to determine if %otherPlayer is actually the player you're looking for.

   // Then do your transform
}
This code loops through all player objects within 50 world units. Not sure I understand what you're doing after that. Are you trying to setTransform to the player? If so you don't need to do an onCollision check because they will be colliding. That would have a sort of teleport action.
#4
02/03/2010 (12:37 pm)
yeah... im trying to make the "baddie" chase the player, im making a platformer with enemies that will chase you if you get to close, and you can loose them by getting ontop of the roofs.

i forgot "transform" would kinda teleport them... i just want them to run, i even made a nice little run animation. the collision is simply to make the baddie hurt the player when they collide.

Im not an amazing programmer, sorry if i sound kinda slow on these things lol
#5
02/03/2010 (12:47 pm)
baddie.setMoveDestination(player.position);
(assuming "baddie" is an aiPlayer)
If you want continuos chasing whenever the player moves try adding something like the above to AIManager.think()
#6
02/03/2010 (4:12 pm)
... on a slightly different note, I keep trying to run methods like "getTransform" or a playerdie(), but i keep getting an error in game saying that the obj trying to call the function cant be found... now i know its gotta be a problem of not passing in the right obj/variable, but i cant seem to figure it out...

in one function i'm checking

else if($playerHealth <= 0)
playerDie();


function playerDie(%this,%spawnPoint)
{
if($playerLives >= 0)
{

$playerLives -= 1;
$playerHealth = 100;
%spawnPoint = pickSpawnPoint();

%tf = %this.player.getTransform();
%this.player.setTransform(%spawnPoint);

}

else
{
//just cuts to a splashscreen
loadStartupDS();
}
}
#7
02/05/2010 (11:02 am)
else if($playerHealth <= 0)
playerDie();

try:
else if($playerHealth <= 0)
playerOrObjectName.playerDie();

no need to pass %spawnPoint to playerDie because it is declared in the function by:
%spawnPoint = pickSpawnPoint();
the %spawnPoint arg that is passed to the function playerDie receives a new value equal to whatever pickSpawnPoint() returns with this line of code.