Author Topic: new AiPlayer() issues  (Read 447 times)

I seem to be having a bit of trouble with creating aiplayers through code. It was working a few days ago until I modified it and forgot what I changed.

Here is a short list of the issues at hand:

- Ai do not trigger bot events (ex: onBotTouch > Bot > Kill)
- Ai cannot be mounted normally in a minigame unless "Use all players bricks" is enabled (not a major issue but I would prefer a proper fix)

Here is the function I typed up
Code: [Select]
function GameConnection::buyHorse(%this,%color)
{
//You can only own one horse at a time
if(%this.ownsHorse != 1)
{
//Spawn the specified horse
%horse = new AiPlayer()
{
datablock = "HorseArmor";
position = %this.player.getTransform();
minigame = getMiniGameFromObject(%this);
rideable = true;
canRide = false;
isHoleBot = true;
};
//Set the color and owner
%paint = getColorIDTable(%color);
%horse.isHorse = 1;
%horse.setNodeColor("ALL",%paint);
%horse.buyer = %this;
%horse.owner = %this;
%horse.ownerName = %this.name;
%horse.setShapeName(""@%this.name@"'s Horse","-snip-");
%horse.stolen = 0;
%this.ownsHorse = 1;
%this.ownedHorse = %horse;
//Mount the player to it and give them control
%horse.controlOnMount = 1;
%horse.mountObject(%this.player,2);
//%this.player.setControlObject(%horse);
}
else
{
bottomPrint(%this,"<color:ff5500>You already own a horse!", 4);
}
}

I have no idea what I did or why it suddenly broke but it's quite bothersome! Any help would be greatly appreciated  :cookie:
« Last Edit: May 23, 2019, 04:19:48 PM by Goth77 »

try removing isHoleBot = true - unless you're actually running holebots on it, it might screw with the bot ownership checks, which i believe checks for spawnbrick to determine ownership

try removing isHoleBot = true - unless you're actually running holebots on it, it might screw with the bot ownership checks, which i believe checks for spawnbrick to determine ownership
I actually added that in there more recently hoping it would fix the bot events problem but it didn't do anything

If all else fails I suppose I could use recuva and try to find an older version I deleted but that could take a while :/

Works fine for me.

try a trace then when jumping onto the horse (to mount it) and also when the horse is touching a kill evented brick. you'll be looking for Armor::onCollision callbacks, sounds like some package/addon you have is not calling the parent properly/adding extra checks that stops it from calling parent

try a trace then when jumping onto the horse (to mount it) and also when the horse is touching a kill evented brick. you'll be looking for Armor::onCollision callbacks, sounds like some package/addon you have is not calling the parent properly/adding extra checks that stops it from calling parent
I get Armor::onCollision when I use a regular horse spawned from a hole brick, and the bot events work fine. However, I do not get that callback when using the script-spawned horse; instead it seems to have called fxDTSBrick::onPlayerTouch - but even using the onPlayerTouch events did not work for the horse either

Ok I found out something odd. If I'm hosting the server as LAN the bot events work just fine, but when I host an internet server the bot events will not work with my ai.....
« Last Edit: May 23, 2019, 04:03:37 PM by Goth77 »

I got some help from a friend of mine, I guess the bot needs a spawnBrick for internet servers

Set isBot to 1 on new aiplayer