Author Topic: function for clicking bot?  (Read 996 times)

Hello! I need to know if there is a function for activating a bot? Or would I need to fire a raycast every time you click and check if it hits an AI player, Also is there a way to check If the bots player type is a certain player type? Thanks!

Code: [Select]
fxDTSBrick::onBotActivated(%obj,%client)i think

Code: [Select]
fxDTSBrick::onBotActivated(%obj,%client)i think
Yep.
Code: [Select]
//calls when bot is clicked by a user
function fxDTSBrick::onBotActivated(%obj,%client)
{
$InputTarget_["Self"]   = %obj;
$InputTarget_["Bot"] = %obj.hBot;
$InputTarget_["Player"] = %client.player;
$InputTarget_["Client"] = %client;
$InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);

%obj.processInputEvent("onBotActivated", %client);
}

Also, onBotActivated is called by player::activateStuff if you wanted to know.
Code: [Select]
//Activate stuff parented so you can call onBotActivated, useful for rpgs and giving players items
function Player::ActivateStuff(%obj)
{
if( %obj.isHoleBot && $pref::bot::disableActivate )
return;

parent::ActivateStuff(%obj);

%mask = $TypeMasks::PlayerObjectType | $TypeMasks::FxBrickObjectType;

%eye = %obj.getEyePoint();
%eyeVec = vectorScale(%obj.getEyeVector(),5);

%fPoint = vectorAdd(%eye,%eyeVec);

%target = ContainerRayCast( %eye, %fPoint, %mask, %obj );
if( %target )
{
%target = %target.getID();

if(%target.getClassName() $= "AIPlayer" && isObject(%target.spawnBrick))
{
// check if we're facing the bot correctly
%fov = %target.hFOVCheck( %obj, 1, 1 );

if( %target.hActivateDirection == 0 || ( %fov > 0 && %target.hActivateDirection == 1 ) || ( %fov < 0 && %target.hActivateDirection == 2 ) )
%target.spawnBrick.onBotActivated(%obj.client);
}
}
}

Oh. And you can check the bot's datablock by doing if(%bot.getDataBlock().getName() $= "playerStandardArmor")
« Last Edit: August 28, 2016, 07:40:59 AM by jes00 »


So I chose a different route to use do what I planned on doing since I already have a Raycast to be fired when you press R, But I belive I dont have the type masks set up as this entire code just stops working when I add in the
Code: [Select]
$TypeMasks::PlayerObjectType
Code: [Select]
function serverCmdLight(%client, %brick)
{
%player = %client.player;

    if(!isObject(%object = getWord(containerRaycast(%player.getEyePoint(), vectorAdd(%player.getEyePoint(), vectorScale(%player.getEyeVector(), 7)), $TypeMasks::PlayerObjectType | $TypeMasks::FxBrickObjectType),0)))
        return;
    %brick = %object;


{
%client.X01Legs += 1;
messageClient(%client, '',"<font:Arial Bold:25><color:5bb611>[X-01 PowerArmor Legs Added]");
%brick.disappear(32);
}

if(%object.getDataBlock().getName() $= "PowerArmorCustomizationStand")
{
echo("It Works! IT RLLY WORKS!");
}

}


%brick isn't an argument of serverCmdLight.

You'll want to check if the client's player exists before running your code.

The whole thing isn't working because you have a syntax error. You have an opening and closing bracket, but no if statement for it.

You should be checking if it's an AIPlayer too, or else your if statement will run if it's a player with that datablock also.

You should add some condition where you parent serverCmdLight, or else the light function will be broken for everyone for the whole time the server is up if your add-on is enabled.