Author Topic: Odd AI Bug: Flying Renderman [SOLVED, NEVER MIND]  (Read 783 times)

My Renderman AI code keeps messing up and thinking that the area 2 TUs in front of it is actually in mid-air; this causes constant death from above.

Here's all the relevant code:
Code: [Select]
function AIPlayer::getPosInFrontOfRenderman(%this,%dist)
{
    return vectorAdd(%this.getEyePoint(),vectorScale(%this.getEyeVector(),%dist));
    //TRIES to get the area in front of the bot at normal ground level through the eyevector
}

Code: [Select]
   %mf = %this.getPosInFrontOfRenderman(2); // the bot support in BL is terrible, so we'll slowly tp the bot towards the player instead, effectively allowing him to walk through some walls
    %this.setTransform(%mf);
    if(getRandom(1,46) == 5) { // teleport?
        %pPos = %this.RendermanTarget.getPosition();
        %tPos = vectorAdd(%pPos, getRandom(-40,40) SPC getRandom(-40,40) SPC 0 ); // this also allows the renderman to jump RIGHT in front of the player - caution
        %this.setTransform(%tPos);

I'm trying to get the bot to just jump forwards a set number of TUs, without sinking through the ground, flying or walking normally.  Can anyone help?

Edit: Nevermind, got it working with a vectorSub
« Last Edit: February 07, 2013, 11:33:29 AM by chrisbot6 »

You might want to use .setMoveY() instead, and if for some reason you don't want to, your problem is:

Code: [Select]
return vectorAdd(%this.getEyePoint(), vectorScale(%this.getEyeVector, %dist));which should be:
Code: [Select]
return vectorAdd(%this.getPosition(), vectorScale(%this.getEyeVector, %dist));

Don't overcomplicate things. If you have a vectorSub from the eye point, then you'll only end up having to vary it for whether the bot is crouching or not.

Also, if you insist on teleportation, you should probably make sure that the bot doesn't already have a control object:

Code: [Select]
if(!isObject(%this.getControllingClient()))or, if you've given it one:
Code: [Select]
if(!isObject(%cl = %this.getControllingClient()) || %cl != %this.botClient)
This will ensure that your bot's AI doesn't try to teleport around when it's 'possessed' by another player.


EDIT: BBcode doesn't work inside code tags. Well then.
« Last Edit: February 07, 2013, 06:21:33 PM by Xalos »