Hello fellow coders (and hopefully Badspot or anyone else with the power to tell me what the hell the engine is doing here)!
As some of you might know, i am working on a dual wielding script.
In case you did not know this, you do now.
But i seem to have some issues with the engine which can be solved but are just plain silly.
The issue is that if you use setImageTrigger to set the trigger of an image in mount slot 1 to true, it will cause something similar to setting the trigger to 1 and immediatly to 0.
Example:
I have equipped the sword in mount slot 1 by some means and redirect my jet key to set the imageTrigger accordingly to the input of the jet trigger.
So in theory, by holding my jet key, it should swing constantly.
In theory, this should be the same as having the sword equipped like normal and holding the fire key.
However, the sword does 1 swing and then stops.
However, after placing some echo's to see if the trigger gets set to 0 before i let go of my jet key, i do not see anything strange, it sets the trigger when i want it.
In fact, after some looking around, i found that Badspot even uses this mechanic in the Akimbo Gun code.
As he sets the trigger for the left handed gun to shoot, but never resets it to 0, which is odd, because in working theory it should then never be able to shoot after that initial shot.
To make things worse, as far as i can see, mount slot 1 is the only slot with such behavior.
I can and probably will use mount slot 2 without this problem, but it is just very weird and unnecessary behavior of this mount slot and it's image.
Can this be fixed by either a script i can write or can this be patched in an update?
I know it is minor, but things like this are a slap in the face of logics when trying to find out what is going on.
EDIT:
I have attached the script as is for reference.
When you have executed the code, just load as normal, open item inventory when you have spawned, right click to equip an item in mount slot 1, close item inventory, use Jet key to fire from mount slot 1.
Most relevant piece:
function Armor::onTrigger (%data, %player, %slot, %io)
{
%noParent = 0;
if (%player.isEquipping)
{
%noParent = 1;
if (%io)
{
if (%slot == 4) //JET
{
%player.mountImage(%player.equipImage, 1);
%player.client.bottomPrint("You equipped the item to your Jet key.",100,1);
}
else if (%slot == 0 || %slot == 1) //FIRE
{
%player.mountImage(%player.equipImage, 0);
%player.client.bottomPrint("You equipped the item to your Fire key.",100,1);
}
}
}
else if (%slot == 0 || %slot == 1)
{
%noParent = %data.redirectTrigger(%player, 0, %io);
}
else if (%slot == 4)
{
%noParent = %data.redirectTrigger(%player, 1, %io);
if (%player.getMountedImage(1) != 0)
{
%noParent = 1;
%player.setImageTrigger(1, %io);
}
}
if (!%noParent)
Parent::onTrigger(%data, %player, %slot, %io);
}
//TRACKING
function ShapeBase::setImageTrigger(%player, %slot, %io)
{
echo("SET IMAGE TRIGGER DOING: PLAYER" SPC %player SPC "| SLOT" SPC %slot SPC "| IO" SPC %io);
Parent::setImageTrigger(%player, %slot, %io);
}
Yes this is packaged properly. :)
And do not mind the redirectTrigger, that is a function that always returns 0 for now.
I might have written a lot of code before i checked if every step before that worked.
I was not counting on this silly engine quirk.