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
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