So I'm trying to create my first ever bot item (The Infinity Gauntlet) and unsurprisingly I'm running into a
lot of issues. But I wanna take things one step at a time and just want to know how to fix this strange item mounting that changes depending on where my player is looking. I am really not much of a coder and have tried to get help on the issue.
Possibly Relevant Pieces of Code:datablock PlayerData(InfinityGauntletArmor : PlayerStandardArmor) {
shapeFile = "./Shapes/Infinity Gauntlet.dts";
uiName = "";
boundingBox = vectorScale("1 1 1", 4);
crouchBoundingBox = vectorScale("1 1 1", 4);
keepWhenDead = 1;
};
datablock ItemData(InfinityGauntletItem : HammerItem) {
shapeFile = "./Shapes/Infinity Gauntlet.dts";
uiName = "Infinity Gauntlet";
doColorShift = false;
botDatablock = InfinityGauntletBot;
iconName = "./icon_ShortSword";
image = InfinityGauntlet_Image;
};
function equipGauntlet(%pl)
{
if (!isObject(%pl.InfinityGauntletBot))
{
%pl.InfinityGauntletBot = new AIPlayer()
{
datablock = InfinityGauntletArmor;
player = %pl;
//class = %sword;
};
%pl.InfinityGauntletBot.kill();
%pl.InfinityGauntletBot.setScale(%pl.getScale());
}
if (!isObject(%pl.emptyBot))
{
%pl.emptyBot = new AIPlayer()
{
datablock = InfinityGauntletArmor;
};
%pl.emptyBot.kill();
%pl.emptyBot.hideNode("ALL");
%pl.InfinityGauntletBot.setScale(%pl.getScale());
}
%pl.mountObject(%pl.emptyBot, 1);
%pl.emptyBot.mountObject(%pl.InfinityGauntletBot, 8);
%pl.playThread(1, armReadyLeft);
}
function InfinityGauntlet_Image::onMount(%this, %obj, %slot)
{
equipGauntlet(%obj);
%obj.triggerDown = 0;
}
SOLVED: I guess I didn't develop this weapon enough. I needed to create a proper unequip function to delete the bot properly as it only spawns at the appropriate orientation as it's first spawned and then reoriented every subsequent time I re-equip it (as the bot is not deleted). Here's the code I needed in case anyone ever has to deal with this:
function InfinityGauntlet_Image::onUnMount(%this, %obj, %slot)
{
if(%obj.getMountedObject(0).getDatablock() == InfinityGauntletArmor.getID() && %obj.getMountedObject(0).getMountedObject(0).getDatablock() == InfinityGauntletArmor.getID())
{
%obj.getMountedObject(0).getMountedObject(0).delete();
%obj.getMountedObject(0).delete();
}
%obj.client.applyBodyParts();
%obj.client.applyBodyColors();
}