Equip change affect variables(SOLVED)

● ARCHIVED · READ-ONLY
Started by Angel Carlito 5 posts View original ↗
  1. Hi all,

    im looking for a way to change a in game variable when someone from the party changes his equipment.
    The only way that comes in my mind is doing it with if commands for each piece of weapon/armor in the game.
    I consider using weapon/armor notetags but i have to learn and understand that first.
    Thats what i got so far:

    Code:
    Scene_Armor.prototype.onItemOk = function() {
        SoundManager.playEquip();
        this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
        this._slotWindow.activate();
        this._slotWindow.refresh();
        this._itemWindow.deselect();
        this._itemWindow.refresh();
    
        
        if (this._actor._name == "Devon") {
            
            if (this._actor._equips[2]._itemId == 21) {
                var tempvalue = $gameVariables.value(16);
                tempvalue = tempvalue + 1;
                $gameVariables.setValue(16, tempvalue);
                var helmset = true;
            };
            
        if (helmset == true) {
            if (this._actor._equips[2]._itemId != 21) {
                var tempvalue = $gameVariables.value(16);
                tempvalue = tempvalue - 1;
                $gameVariables.setValue(16, tempvalue);
                helmset = false;
                };
            };
            
        };
        
        this._statusWindow.refresh();
    };

    What we see here is if the actor Devon has equiped the item with the id 21 in the 3rd slot the variable nr. 16 will increase by 1
    (equips[2] 3rd slot in the array is used for helms in my game, itemId 21 is a helm named bandana).
    The problem here is first that it will take really long time to make that for every weapn/armor in the game and
    the boolean helmset changes back to false once the script runned once.
    If i would declare a local boolean above the if condition it would work but not correctly since it would always decrease the variable16 by 1 everytime the item with the id 21 isnt weared.
    I made a custom scene based on the scene_equip and changed a few things.

    I were thinking of using a for loop to go once through the whole arrays (_equips[]) and read the itemIds but that would end up in the same direction i guess.

    Anyone gotn idea to making this work correctly. That means if itemId 21 is equiped variable16 increasese by 1 and if it is deequiped once it was equiped it should decrease by 1.
    And a few tips in terms of notetags would be awsome as well.

    The script im using are:
    yanfly core engine
    and the onces i made by myself:
    custom main menu
    custom stat menu
    custom equip menu
    custom cursor
  2. You could do that with my "CustomOnEquipEval" plugin.

    This adds Lunatic Code that will be executed when an actor equips or de-equips an item.

    Weapon and Armor Notetag:
    <Custom On Equip Eval>
    code
    </Custom On Equip Eval>
    This code will run when the actor equips the item.

    <Custom On Remove Equip Eval>
    code
    </Custom On Remove Equip Eval>
    This code will run when the actor unequips the item.

    You can find it here https://forums.rpgmakerweb.com/inde...s-newest-way_messagewindowfaceposition.78979/
  3. Awsome ! It does work perfect. You saved me a lot lot lot of work. Thank you very much.

    Code:
    <Custom On Equip Eval>
    var tempvalue = $gameVariables.value(16);
    tempvalue = tempvalue + 1;
    $gameVariables.setValue(16, tempvalue);
    </Custom On Equip Eval>
    
    <Custom On Remove Equip Eval>
    var tempvalue = $gameVariables.value(16);
    tempvalue = tempvalue - 1;
    $gameVariables.setValue(16, tempvalue);
    </Custom On Remove Equip Eval>

    Is it possible to make an if coniditon to check wich actor equips the item?
    Because every item will change other variables on the same equipment.
  4. I am glad it helps you! :kaohi:

    To get the user of the item you can use user

    <Custom On Equip Eval>
    if (user.actorId () === 1) {
    //do stuff
    } else if (user.actorId() === 2) {
    // do stuff
    } else {
    // do stuff
    }
    </Custom On Equip Eval>
  5. Great thanks a lot. You will get a special thanks in my credits :).