Yanfly's augment attachments: Make augments change variables

Discussion in 'Javascript/Plugin Support' started by Dirge, Jul 24, 2017.

  1. Dirge

    Dirge Sound Engineer Veteran

    Messages:
    413
    Likes Received:
    281
    Location:
    Canada
    First Language:
    English, German
    Primarily Uses:
    N/A
    Hi!

    I'm trying to have an augment that changes specific variables on attachment, and changes them back on detachment. But it needs to change a different variable based on the actor ID of the actor holding the item the augment is attached to.

    With me so far? Cool. Here's my current notetag setup for it:


    <Augment Attach Eval: Utility>
    if (user.actorId == 1) {
    $gameVariables.setValue (302, $gameVariables.value (302)+10)
    }else if (user.actorId == 2) {
    $gameVariables.setValue (312, $gameVariables.value (312)+10)
    }else if (user.actorId == 3) {
    $gameVariables.setValue (322, $gameVariables.value (322)+10)
    }else{
    $gameVariables.setValue (332, $gameVariables.value (332)+10)
    }
    </Augment Attach Eval: Utility>
    <Augment Detach Eval: Utility>
    if (user.actorId == 1) {
    $gameVariables.setValue (302, $gameVariables.value (302)-10)
    }else if (user.actorId == 2) {
    $gameVariables.setValue (312, $gameVariables.value (312)-10)
    }else if (user.actorId == 3) {
    $gameVariables.setValue (322, $gameVariables.value (322)-10)
    }else{
    $gameVariables.setValue (332, $gameVariables.value (332)-10)
    }
    </Augment Detach Eval: Utility>

    However, when I attach the augment, it gives me an error: "User not defined"

    I had an epiphany about this while I was in the shower (actual shower thoughts! lol). I think it's throwing a "user not defined" error because the user.actorId parameter is trying to find an actual user associated with the item, but nobody is actually "using" the item, it's just being attached as an augment.

    So rather than checking for the user.actorId, it needs to identify the actor by some other parameter. Unfortunately, we're pretty firmly in the "Dirge no longer has a clue what he's doing" realm of JS...

    Which brings me to my question. How can I have it identify which actor is using the item the augment is going to be attached to, and modify a particular variable based on that?
     
    #1
  2. Naveed

    Naveed Veteran Veteran

    Messages:
    314
    Likes Received:
    144
    First Language:
    English
    Primarily Uses:
    RMMV
    The issue is, as you said, that the augments attached to an item, not to an actor. Hence there is no code to reference which actor has the attachment, since technically none of the actors have the attachment. You can also think that augments can be attached to items that are not equipped by anybody. What then?

    If you could specify exactly what you're trying to achieve by changing the variables, maybe I could recommend an alternative approach.
     
    #2
  3. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,994
    Likes Received:
    10,107
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    After a good night's sleep I am still not able to work out the solution.
    It's a problem that was partly solved yesterday. Modification of Yanfly's status menu core so that it would show Element damage amplification instead of resistance rates.
    In the end we were able to work out a solution by accessing game variables, but in the solution the weapon augments still don't work...

    It would be working easily with the augments inflicting states, but I'm afraid too many states would make the game laggy.
     
    Last edited: Jul 24, 2017
    #3
  4. Dirge

    Dirge Sound Engineer Veteran

    Messages:
    413
    Likes Received:
    281
    Location:
    Canada
    First Language:
    English, German
    Primarily Uses:
    N/A
    @Naveed What Poryg said, basically, yep. The variables in question pertain to a status menu showing element amplification rates.

    @Poryg I think the state idea might work - I don't think we'll have TOO many states going at any one time. I'll build that and test it tomorrow, thanks for the idea.
     
    #4
  5. Poryg

    Poryg Dark Lord of the Castle of Javascreeps Veteran

    Messages:
    3,994
    Likes Received:
    10,107
    Location:
    Czech Republic
    First Language:
    Czech
    Primarily Uses:
    RMMV
    States would make it easy. Because States allow you to use user.
    So if you let these augments apply states, then just replace <Augment attach eval> with <Custom Apply State> and <Augment detach eval> with <Custom Remove Effect>, it should work.
     
    #5

Share This Page