Blockland Forums > Modification Help

new AiPlayer() issues

(1/2) > >>

Goth77:
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: ---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);
}
}

--- End code ---

I have no idea what I did or why it suddenly broke but it's quite bothersome! Any help would be greatly appreciated  :cookie:

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

Goth77:

--- Quote from: Conan on May 23, 2019, 12:21:12 PM ---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

--- End quote ---
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 :/

jes00:
Works fine for me.

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

Navigation

[0] Message Index

[#] Next page

Go to full version