Help with a script call.

Hopefully i chose the right section for this thread. The script call should be basic MV as far as i know but the reasoning behind using them lies within a plugin.
script.JPG


So I'm using this to equip characters, that are recruitable later, with their initial gears and skills. Reason behind this is Yanflys skill learn system, passive states and classchange. The way my game works, is that actors learn to use different gear via skills.
If i just give the initial gear in the editor, I would also need to give them the skills there in order to be able to actually pick the right gear. This causes the skills to be unlocked by default but show up as "not learned" in the skill system.
To work around that i thought it might be possible to just do it with this script call. The skills seem to unlock just fine but the gear doesn't. Would appreaciate help with this, be it either fixing the script or even finding another/better way to deal with this.
Firstly, why do you need script calls for this? I believe there are normal commands that do this anyway.

Secondly, and I am not 100% sure, but I do believe that in order to use the equip command, you need to have the equipment in your inventory.

For example, if you want actor 3 to equip a "battle axe", you have to put a battle axe in your inventory first before you can equip it.

This should be easily doable.

Something like this (A raw mockup based on your screenshot):

boohoo.png
There's also a method "actor.forceChangeEquip(slotId, item)", maybe this works better.
Oh, is that so? I was thinking the script call would avoid having to have the items in the inventory and just place them in the slot selected, wich is why i used it. I didn't even think about this simple solution. (I should stop overthinking things i guess.)

Does the eventing verision like you show here actually work with the skill learn system tho? They have to be recognized as learned by the plugin or else the player can still purchase them with no effect.

@Aerosys does this also need the equipment in the inventory to work tho?
@Aerosys does this also need the equipment in the inventory to work tho?
So this is the code itself


Code:
Game_Actor.prototype.forceChangeEquip = function(slotId, item) {
    this._equips[slotId].setObject(item);
    this.releaseUnequippableItems(true);
    this.refresh();
};

and as far I can see, nope, it "unlocks" the equipment or item, and even releases items. Whatever that means exactly :thinking:
@Aerosys I guess it would be putting items in your inventory if they are not equipable? Looks like doing it the old fashioned way, that @ScorchedGround suggested, works just aswell. I guess I'll try that first and just leave the script call for the skills in there since they already work.

Thank you both for the quick and helpful replies!

Edit: Alright, i cannot do it the way @ScorchedGround described it. Reason being my character cannot equip the weapon and armor he's supposed to start with by default. So i can also not select it with "Change equipment In the editor. "

I suppose I'll have to go with @Aerosys way. I don't really have a clue about scripting, so question is:
Game_Actor.prototype. is that supposed to be the actors name then? if not, where is it? Or his id?
You have just to use the scriptcall $gameActors.actor(x).forceChangeEquip(slotId, item)
@MisterFu do i have to have the item in my inventory for this to work?
You could simply try. But as @Aerosys said, nope. This function doesn't check if the equipment is in your inventory. But the changeEquip-function does.
So forcechanging it doesn't require the item while normal changin does. I see. Somehow i expected a forcechange to just equip it regardless of restrictions, but still requiring the actual item.
But be aware, if the item is unequipable, it will be added to the inventory. And when the actor is refreshed, he will unequip all equipment which he is not allowed to hold.
That shouldn't be an issues, as they do get the appropriate skills at the same time.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-a-script-call.131134/