Yanfly's Attachable Augments Questions

Discussion in 'Javascript/Plugin Support' started by Yawgmoth, Aug 15, 2019.

Thread Status:
Not open for further replies.
  1. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi all, I'm using Yanfly's Attachable Augments Plugin along with Yanfly's Equip Core. I was wondering if there was a way using the augments to change a weapon's type to another specific weapon type.

    EX: Lets say you have an Axe but your rogue can't use it he only uses daggers. You now have a special rune that turns other weapons into daggers when it is socketed. It's a fun idea. I think this may be possible via script but I lack the knowledge.

    If this is impossible I would like to know if there is anyway to use Yanfly's Equip Core which allows you to place class restrictions on items, weapons, and armor to place such limitations on an augmented item when it becomes augmented?

    Any answer would be great, thanks to those who took the time to read this and bigger thanks to any who respond.
     
    #1
  2. Silenity

    Silenity Veteran Veteran

    Messages:
    647
    Likes Received:
    238
    Location:
    Oregon
    First Language:
    English
    Primarily Uses:
    RMMV
    <Augment Attach: type>
    Add Passive State: x
    </Augment Attach: type>

    Make state with a trait that allows them to equip whatever weapon type you want.

    EDIT:
    Wait I misread the question.

    The above answer is wrong. I'll keep looking.
     
    #2
  3. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Try this one. Change type to the type of augment, change the number 2 to whatever weapon type your dagger is.
    Code:
    <Augment Attach Eval: type>
     item.wtypeId = 2
    </Augment Attach Eval: type>
     
    #3
  4. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Thanks for all the quick reply's!

    @ramza I tried the code, I typed it in as a notetag. I can equip the augment but the weapon still is not able to be equipped by the class. I changed "type" to the appropriate socket and altered the weapon type ID too. Anymore ideas?

    Also any ideas on adding restrictions such as level and class to weapons and armor after an augment is applied?

    Thanks for all your efforts.
     
    #4
  5. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    I have taken the time to test the note tags I gave you, and they work perfectly.

    For testing, I used the following tag on the augment item:
    Code:
    <Augment Attach Eval: Glyph>
     item._oldType = item.wtypeId
     item.wtypeId = 1
    </Augment Attach Eval: Glyph>
    <Augment Detach Eval: Glyph>
     item.wtypeId = item._oldType
     item._oldType = undefined
    </Augment Detach Eval: Glyph>
    This makes it so that when placed into a 'Glyph' slot on a weapon, it saves the old type, and then changes the weapon to type 1, which is dagger. If you augment the weapon while it's equipped, it is immediately removed (as Harold can't use daggers). The detach eval is used to return it to being it's original wType if the augment is removed, which also works.

    Keep in mind that these things may not always function on an old save game. Sometimes note tags don't always update from old saves, resulting in it appearing that they don't work. Always test from a new save.

    Before augment:
    Before augment.png
    After augment:
    After augment.png

    Harold is no longer able to equip the sword item again until the augment is removed, returning it to the sword type.
     
    #5
  6. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @ramza Thanks so much I got it to work! My problem was I had copied and pasted only a partial amount of my augments name. I was so busy making sure I had copied your code exactly I had missed making sure my note tag was correct. Thank you for being so patient.

    Any ideas on adding requirements such as level or class via augments?
     
    #6
  7. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    @Yawgmoth For those you could use the same sort of setup to change some equipment requirement information on the weapon via functions added by Yanfly's Equip Requirements plugin.

    Looks like changing item.equipRequirements.atLeast[8] will set a minimum level requirement, and pushing a required class to item.equipRequirements.classes would add a class requirement.

    So something like this:

    Code:
    <Augment Attach Eval: Glyph>
     item.equipRequirements.atLeast[8] += 3
    </Augment Attach Eval: Glyph>
    Would add 3 to the level requirement of the item, and something like this:

    Code:
    <Augment Attach Eval: Glyph>
     item.equipRequirements.classes.push(3)
    </Augment Attach Eval: Glyph>
    Should make it so that someone would need to belong to classId 3 to be able to equip the item.

    Naturally you'd need to undo these changes on detach note tags as well, so the item could return to normal.

    Note I haven't tested these ones, but they should work based on what I see in the plugin.
     
    #7
  8. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @ramza these look like they should work, I will hopefully test them sometime this weekend. Thank you for all the help!

    Also all my augments are interchangeable between weapons and armors and because of it I have came across a similar issue with my dagger augment above and wish to disallow it from being used on an armor. What would that piece of code look like for armors and weapons? I assume it should be similar to your possible solutions above?

    EDIT: I tested both of your codes from above and When you select the augment it now asks you to select an actor and it makes the buzz sound on the actors if they meet the conditions without anything happening and without the augment being used. I think you are close, I think it is checking the actors before the augment is placed and we want the restrictions applied to the armor or weapon after the augment has been used, along with equipping the weapon or armor if the actor does not meet the requirement. I think that portion would be automatic though.

    I am more concerned about restricting augments to specific types of equipment though, as the level and class restrictions would just be nice to have but my project needs a way of distinguishing armor and weapons when augmenting.
     
    Last edited: Aug 18, 2019
    #8
  9. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm not sure why it would be showing an actor select screen. I don't actually have much work with the augment plugin, but it sounds like you're using the item from the items menu instead of by going to the weapon/armor in the item/equip menu and attaching the augment from there. This sort of behavior would probably happen if you had a usable item that had no effect on it, and tried to use it on an actor... I think anyway. The scene I screenshotted earlier is the item scene, but I tested it by going to the weapons section, not by using the augment item.

    You're in luck for the other thing though, as I've actually engineered a real janky solution to a similar problem I was having in my own project, where I had an augment that could be applied to all armors, but provided a stat boost to block chance, which meant it should only ever be put on a shield. I used the following code for that:

    Code:
    Window_AugmentItemList.prototype.includes = function(item) {
        if (!item) return false;
        if (DataManager.isIndependent(item)) return false;
        if (!this.containsType(item)) return false;
        if (item.meta.SHIELDONLY == true && this._item.etypeId != 2) return false;
        return true;
    };
    The last if check is checking a line I put in the note tags of the augment item itself, indicating that it is shield only. It checks if this._item (which is the item being augmented) is of etypeId 2, which is my shield type, and returns false if it isn't a shield, hiding this augment from the list of augments usable on the non-shield.

    You can use a tag on augments in the same way, and use a check against either etypeId == 1 (which is weapon by default), or etypeId != 1 (which would be every other type of armor).

    This types are listed in the database on the types tab under the equipment types heading, btw.
     
    #9
  10. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @ramza Your correct I was using the augment from the item menu but had done so with all my augments, your solution does work from the weapon menu, just strange I can use other augments from item menu.

    As for your code I must be doing something wrong because when I go to the armor menu it still allows be to select the augment which sounded like it should be hidden? Anyways it allows me to select it. The code I am using is as follows:

    Code:
    Window_AugmentItemList.prototype.includes = function(item) {
    if (!item) return false;
    if (DataManager.isIndependent(item)) return false;
    if (!this.containsType(item)) return false;
    if (item.meta.WEAPONONLY == true && this._item.etypeId == 1) return false;
    return true;
    };
    };
    Did I type something wrong into the code?

    As always thanks for all the help I really appreciate it.
     
    #10
  11. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Looks like I forgot to mention it in my post, but that item.meta line is actually a really basic note tag reader. In order for it to hide the augment, you need to put a note tag on the augment item in the notebox that matches the capitalized section <WEAPONONLY>.
     
    #11
  12. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @ramza I tried the copied and pasted the <WEAPONONLY> notetag and put it into the augment item's notebox. It doesn't seem to do anything. It still allows me to place the augment onto an armor. Anything else we may be forgetting?
     
    #12
  13. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Did you import that code posted as a plugin into your plugin manager?
     
    #13
  14. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    No I put that code in the notetag. One sec. Ill try that.

    EDIT: OK, so I copied the above code and put it into notepad and saved the file as AugmentRestriction.js and placed it in the plugin folder for my project and turned the plugin on. I tried the augment again and it still does not work. I suspect that I have done something wrong but not sure what.
     
    Last edited: Aug 19, 2019 at 2:22 AM
    #14
  15. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @ramza I know you are probably busy but any help is always appreciated. I'm still trying to get the code you gave me to work. This is what I have set up in my plugin folder. Is everything correct? If not what can I do try now? Thanks for your time.

    Code:
    //=============================================================================
    // AugmentRestriction.js
    //=============================================================================
    /*:
     * @plugindesc A plugin that works with Yanfly's Augment plugin, this plugin adds restrictions via notetags that prevent augments from being used on armors or weapons.
     *
     * @author
     *
     * @help
     *
     *  <WEAPONONLY> and <ARMORONLY>
     *
     * TERMS OF USE
     *
     *
     * COMPATIBILITY
     *
     */
     
    Window_AugmentItemList.prototype.includes = function(item) {
        if (!item) return false;
        if (DataManager.isIndependent(item)) return false;
        if (!this.containsType(item)) return false;
        if (item.meta.WEAPONONLY == true && this._item.etypeId == 1) return false;
        return true;
    };
    
    Window_AugmentItemList.prototype.includes = function(item) {
        if (!item) return false;
        if (DataManager.isIndependent(item)) return false;
        if (!this.containsType(item)) return false;
        if (item.meta.ARMORONLY == true && this._item.etypeId == 4) return false;
        return true;
    };
    
    })();
     
    #15
  16. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    @Yawgmoth I'm not sure what I can tell you here. The code I gave works in my own project specifically for shields. I just retested to make sure I wasn't going crazy and it works.

    One thing that is a problem is that you're overwriting your own changes with the second function. You should combine them into one.

    Code:
    Window_AugmentItemList.prototype.includes = function(item) {
        if (!item) return false;
        if (DataManager.isIndependent(item)) return false;
        if (!this.containsType(item)) return false;
        if (item.meta.WEAPONONLY == true && this._item.etypeId == 1) return false;
        if (item.meta.ARMORONLY == true && this._item.etypeId == 4) return false;
        return true;
    };
    The other thing is that the way you have the armor only tag written implies you only have one type of equipment that is armor, so the augment will only ever go on that one equipment type. I'm not sure if that was deliberate or not, but I'd change the '== 4' to '!= 1' on that line, so the augment will slot in anything that isn't a weapon.

    You mentioned already that some of your augments can be used directly from the item menu and they work. I'm not sure how you managed that, as none of my augment items can be used at all. But as noted with the one that changed the level requirement before, it's possible that using it from the item menu instead of from the augment command window from a weapon/armor is messing with it too.

    The only other thing I can come up with is to ensure that this plugin file is loaded below the attachable augments plugin on your plugin list. We're overwriting functions in the original plugin, so it needs to load after it, or there will be no changes.

    Edit:
    Okay I figured out that your augments have a scope set, either to ally, or self, and an occasion set to 'menu' or 'always'. IMO you should change these to no scope, and 'never', to stop players from using them directly from the item menu.
     
    #16
  17. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    @ramza thanks for the reply

    I took a look and you were correct. The augments I was testing and some of my other augments which were mostly copied and pasted and then altered had a scope set to ally and were usable from the menu. I have since altered all these augments as you suggested. I must of known this at one point and after my break from my project forgot.

    So I now have the following code as a plugin listed below Yanfly's Augment Plugin:

    Code:
    Window_AugmentItemList.prototype.includes = function(item) {
    Window_AugmentItemList.prototype.includes = function(item) {
        if (!item) return false;
        if (DataManager.isIndependent(item)) return false;
        if (!this.containsType(item)) return false;
        if (item.meta.WEAPONONLY == true && this._item.etypeId == 1) return false;
        if (item.meta.ARMORONLY == true && this._item.etypeId != 1) return false;
        return true;
    };
    };

    This was my fault as I have added more equipment slots and armor is 4. I did not realize you could just do weapon or no weapon but it is preferable because of the simplicity. Now the plugin works but not as intended. My notetags are 'reversed'... <ARMORONLY> allows me to place the augment on weapons and <WEAPONONLY> allows it to only be placed on non weapons. I'm not sure why but this took me awhile to figure out. I wonder if this has been my problem since I started using the code you gave me? So now I have a functional code which is great but for the sake of curiosity I would like to know what I have done to cause the note tags to be wrong? Any ideas?

    Thanks again for all your efforts and time.
     
    #17
  18. ramza

    ramza Lunatic Coder Veteran

    Messages:
    531
    Likes Received:
    290
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Ah, the logic was backwards. In my original code it checks for the SHIELD ONLY tag and returns false if the item isn't a shield. Looks like at some point back there we got it reversed. In the code you just posted, swapping WEAPONONLY and ARMORONLY should be all we need to do to fix that.
     
    #18
  19. Yawgmoth

    Yawgmoth Veteran Veteran

    Messages:
    85
    Likes Received:
    6
    Location:
    Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Ok sounds like a simple fix. I'm not home atm. When I get home I'll try it out and let you know the results.

    Thank you again for all the help.

    EDIT: Just checked it with the new altered code. Everything works how it should! Thank you so much Ramza!

    I will be closing this thread now.
     
    Last edited: Aug 25, 2019 at 11:27 AM
    #19
  20. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,405
    Likes Received:
    10,415
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #20
Thread Status:
Not open for further replies.

Share This Page