Equip Events for MV?

Discussion in 'JS Plugin Requests' started by InkPotion, Aug 25, 2017.

  1. InkPotion

    InkPotion I've moved accounts! Now RunePotion. Veteran

    Messages:
    82
    Likes Received:
    51
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm looking for a plugin that allows you to run a common event on equip/unequip.
    I've seen this for other engines but haven't had any luck finding something like this for MV.
    I'd be really grateful for any help!
     
    #1
  2. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    529
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    What do you wanna do inside the Common Event?
     
    #2
  3. InkPotion

    InkPotion I've moved accounts! Now RunePotion. Veteran

    Messages:
    82
    Likes Received:
    51
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Things like treasure/etc appearing that otherwise wouldn't be visible unless the amour was equipped,
    I'd like to find out how to have the players sprite change to show them wearing the equipped armor, too. There's probably something for that though, I'll have to look.
     
    #3
  4. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    529
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @InkPotion
    You could use my WAY_CustomOnEquipEval Plugin. It allows you to run code when the actor equips/unequips items.
    https://forums.rpgmakerweb.com/inde...-addons-newest-way_customfaceimageeval.78979/
    It would require the use of Lunatic Code (scriptcalls) tho.

    To change the graphics when the actor equips an item:
    Just change the test, test2, test3 to the actual filenames.
    Code:
    <Custom On Equip Eval>
    user._prevCharName = user._prevCharName || user._characterName;
    user._prevCharIndex = user._prevCharIndex || user._characterIndex;
    user._prevFaceName = user._prevFaceName || user._faceName;
    user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;
    user._prevBattlerName = user._prevBattlerName || user._battlerName;
    
    user.setFaceImage("test", 0);
    user.setCharacterImage("test2", 0);
    user.setBattlerImage("test3");
    user.refresh();
    $gamePlayer.refresh();
    </Custom On Equip Eval>
    This would reset it to the old graphics, when the actor unequips the item:
    Code:
    <Custom On Remove Equip Eval>
    user.setCharacterImage(user._prevCharName, user._prevCharIndex);
    user.setFaceImage(user._prevFaceName, user._prevFaceIndex);
    user.setBattlerImage(user._prevBattlerName );
    user.refresh();
    user._prevCharName = undefined;
    user._prevCharIndex = undefined;
    user._prevFaceName = undefined;
    user._prevFaceIndex = undefined;
    user._prevBattlerName = undefined;
    $gamePlayer.refresh();
    </Custom On Remove Equip Eval>
    Do you use a switch to let the treasure appear on map? Because then you could just turn on the switch when the actor equips an item:
    Code:
    <Custom On Equip Eval>
    $gameSwitches.setValue(ID, true);
    </Custom On Equip Eval>
     
    Last edited: Sep 4, 2017
    #4
  5. InkPotion

    InkPotion I've moved accounts! Now RunePotion. Veteran

    Messages:
    82
    Likes Received:
    51
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks for the reply!
    It automatically put the armor in my inventory when I started the game, and runs the switches without equipping it
    I couldn't seem to make it work how I'd like without using common events, but thank you so much for the help regardless!
     
    #5
  6. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    Hi. Im trying to adapt this to my game. But i get an error.

    <Custom On Equip Eval>
    user._prevFaceName = user._prevFaceName || user._faceName;
    user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;

    if (user.actorId() = 2){
    user.setFaceImage("A2Armadura1", 0);
    user.refresh();
    }if (user.actorId() = 3){
    user.setFaceImage("A3Armadura1", 0);
    user.refresh());
    }
    $gamePlayer.refresh();
    </Custom On Equip Eval>

    I´m trying to have different outcomes whit different actors
     
    #6
  7. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    529
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Tatsumaro
    1. For Comparison you need to use the == or === operator and not the =. Because the = is only for assignment.
    2. On the second refresh, there's a brace too much.

    So it should be:
    Code:
    <Custom On Equip Eval>
    user._prevFaceName = user._prevFaceName || user._faceName;
    user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;
    
    if (user.actorId() === 2){
    user.setFaceImage("A2Armadura1", 0);
    user.refresh();
    }if (user.actorId() === 3){
    user.setFaceImage("A3Armadura1", 0);
    user.refresh();
    }
    $gamePlayer.refresh();
    </Custom On Equip Eval>
     
    #7
    Tatsumaro likes this.
  8. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    thanks great support :)
     
    #8
  9. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    Hello waynee

    sorry to bother you but i'm getting a error msg whit this code.

    <Custom Equip Requirement Condition>
    if ($gameActors.actor($gameParty._targetActorId).skills().contains($dataSkills[648])){
    condition = true;
    } else {
    condition = false;
    }
    </Custom Equip Requirement Condition>

    i'm trying to force the player to learn a skill before he can equip a weapon.

    <Custom Equip Requirement Condition>
    if ($gameActors.actor($gameParty._targetActorId).hasSkill(648)){
    condition = true;
    } else {
    condition = false;
    }
    </Custom Equip Requirement Condition>

    same error
     
    Last edited: Feb 7, 2018
    #9
  10. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    529
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    @Tatsumaro
    But that's not really related to a plugin of mine right? It's from a Yanfly plugin, isnt it?

    Try this.
    Code:
    <Custom Equip Requirement Condition>
    if (user.hasSkill(648)) {
        condition = true;
    } else {
        condition = false;
    }
    </Custom Equip Requirement Condition>
     
    #10
    Tatsumaro likes this.
  11. Tatsumaro

    Tatsumaro Veteran Veteran

    Messages:
    205
    Likes Received:
    40
    First Language:
    Portugues
    Primarily Uses:
    RMMV
    X) sorry you are correct, its YEP_X_EquipRequirements Lunatic Mode... i fill stupid but thanks for the help :)

    I have a problem, do you know if i can use this code in Lunatic Mode=?
    <Custom Equip Requirement Condition>
    if (SceneManager._scene.constructor == Scene_Shop) {
    condition = true;
    } else {
    if (user.hasSkill(648)) {
    condition = true;
    } else {
    condition = false;
    }
    </Custom Equip Requirement Condition>
     
    #11
  12. Annastasija

    Annastasija Villager Member

    Messages:
    25
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    RMMV
    So this works great, I love it. Except one small problem I can't figure out... When I change from one weapon to the next, it uses the unequip code and makes my character hold no weapon, unless I take one weapon on and off again. How can I fix this? I am making my main character be able to use several types of weapons.. so lots of taking on and off of gear... thanks!
     
    #12
  13. waynee95

    waynee95 Lunatic Coder Veteran

    Messages:
    640
    Likes Received:
    529
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
  14. Annastasija

    Annastasija Villager Member

    Messages:
    25
    Likes Received:
    12
    First Language:
    English
    Primarily Uses:
    RMMV
    It works now! yay!! thank you so much
     
    #14
    waynee95 likes this.

Share This Page