Ramza's Shield Block Plugin -UPDATED SEP 11 2017-

Discussion in 'JS Plugin Releases (RMMV)' started by ramza, Nov 30, 2016.

  1. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Greetings. I come yet again with a new plugin. One that by itself doesn't do much, but allows other plugins to get a lot of use out of it.


    TL;DR Shield block chance as an xparam download here. Free for commercial or non-commercial use with credit.


    To explain what this plugin does, it's best to start from the beginning... As a few of you might know, I had/have a workshop topic where I often shared custom states that I'd made, for general use, to spice up other peoples game mechanics. The first state I released in the topic was a shield block state, where with a % chance, with a shield equipped, an actor could 'block' an incoming physical attack, displaying a quick little shield animation, and taking no damage. Right off, this was pretty basic, but quite in depth.


    Perfection required me to set various shield types to have different block chances, it wouldn't make sense, after all, that a buckler and a tower shield would have the same chance to block, right? Well, with the state as it was, the only was to do this was to bloat the notebox up with if conditions. This was compounded when I later decided that shields should also look different, as each block now required a check to see which shield was equipped, and how much block chance that shield had. This became messy, and if I added any more shield later? More if conditions. And then it hit me. Why not store the block chance on the actor, as a parameter, and store the animation as values on the actual equipment. And thus, this plugin was born.

    Updated to v 2.16:

    • Aliased Game_ActionResult.prototype.clear() instead of overwriting it. This has no effect on the actual functionality of the plugin, but should make it more compatible with other plugins that also modify the ActionResult sequence.
    Updated to v2.15
    • Equipment optimization will now take shield block chance into account when comparing shields, at a rate of 1% block chance == 1 param. As such, a shield with a higher chance to block will be equipped over another shield that is otherwise the same.
    • Added some backend compatibility changes to make this plugin more compatible with some of my other plugins.
    Updated to v2.11
    • Added support for a new note tag on equipment, enemies and states, <Lower Block Chance: x>. Replacing x with a positive whole number will reduce the block chance of the battler with the state/item equipped by x percent.
    Updated to v2.10
    • YEP_BattleEngineCore is now the only required plugin. Place this plugin directly below it on your plugin manager.
    • Added new Note Tags for Armor and Enemies:
      • <Block Percent: x> Reduces incoming damage by x%. This is an integer value from 0-100.
      • <Block Value: x> Reduces incoming damage by x when an attack is successfully blocked. This value is removed from the remaining incoming damage after Block Percent is processed.
    • Added new plugin parameters:
      • Hide Damage Popup
        • The plugin will hide a damage popup that was successfully blocked and dealt zero damage
      • Flat Block Value
        • The default flat block value for all enemies and shields
      • Block Percent
        • The default block percentage for all enemies and shields
      • Partial Block Effect
        • When this is true, an attack that was blocked, but still dealt some damage will apply any effects it would've applied as if the attack had been successful.
    • Updated the block state paste code to use the blockPercent and blockValue values.

    Updated to v2.00
    • Block success now happens as an action.result(). This means that react effects (or action sequences) can check if the result of their action was a block. This will return true under the following conditions:
      • The incoming skill is blockable (as set in the plugin parameters, all physical skills are blockable)
      • The defender is affected by the block state, allowing them to block (the default is 36)
      • A random percentile check is equal to or less than the target's .blk parameter (which comes from equipment, or states)
    • Successfully blocking an attack no longer causes that attack to apply states or debuffs/buffs that it would've applied on a successful hit.
    • Successfully blocking an incoming attack no longer removes states on the defender that would've been removed by a successful attack (ex: confusion)
    • Blocking an attack no longer shows a damage popup for zero damage
    • Added plugin param to set the id of your block state
      • Make sure that you set this, as if a target has block chance, but no block state applied, the action result will say a block happened, even when the user doesn't have a shield, if the block chance check succeeds.
    • Updated the exParam to be a value from 0-1 instead of 0-100. Note tags remain unchanged.
    • Yep_BattleEngineCore and YEP_BuffsStatesCore are now required dependencies
    • I have updated the YEP_StatusMenuCore edit I made for use with this plugin.
    • New block state paste below to make use of the action.result() change.

    Updated to v1.1
    • Added a plugin parameter to set all physical skills as either blockable or unblockable by default
    • Added new note tags for skills only <BLOCKABLE>, <UNBLOCKABLE> which override the plugin parameter on a skill-by-skill basis, allowing non-physical skills to be blocked.
    • Added compatibility with the <BLOCK CHANCE: X>, <BLOCK ANIMATION: X>, and <SLAM ANIMATION: X> note tags so that they could be used on enemies. The default block/slam animations will play if these are not set on the enemy note box.
    • Modified the block state paste in the help file, and below to support monsters blocking, as well as the blockable/unblockable note tags.

    Updated to v1.02:
    • Fixed compatibility with YEP_ExtraParamFormula, which was causing the block exParam to return a NaN value.

    Updated to v1.01 to fix an engine crash on (possibly?) newest version of rpg maker. Links updated.


    What it does:
    This plugin gives you access to three notetags. The first can be on armor, enemy, or on a state (for easy increasing of player block values)
    <BLOCK CHANCE: X>
    Gives the actor a block chance of X% (do not put the % in the note tag). These values are additive, meaning if you have a state that adds 10% and a shield that adds 15% you have 25% total.
    The other note tags are for armor and enemies only:
    <BLOCK ANIMATION: X>
    <SLAM ANIMATION: X>

    The first tells the engine what animation to play on your actor when he successfully blocks. This is handled by our shield block state, which I will post below.

    Slam animation is only used in an action sequence in which your character strikes with a shield. This is the animation that plays on your actor when they do that. For reference, this can be pulled from the actors equipment by doing an eval to user.equips()[1].slamAnimation which will give the animation Id you specified in the notetag.

    Version 1.10 of the plugin also adds the following note tags for use on skills only:
    <BLOCKABLE>
    <UNBLOCKABLE>
    These note tags can be used to denote a skill that can or cannot be blocked.

    The State:
    Add the following note tags to a passive state, and have that state on any shield that can be blocked with, and your actor will be capable of blocking.

    May 9, 2017:
    This state copy paste is useful only for version 2.00 (or higher) of the plugin.

    Code:
    <Custom React Effect>
    var blockValue = (target.isEnemy() ? target.enemy().blockValue : target.equips()[1].blockValue)
    var blockPercent = (target.isEnemy() ? target.enemy().blockPercent : target.equips()[1].blockPercent)
    if (target.result().isBlocked()) {
        value -= Math.round(value * (blockPercent/100));
        value -= blockValue
        value = Math.max(value, 0)
        var blockAnim = (target.isEnemy() ? target.enemy().blockAnimation : target.equips()[1].blockAnimation)
          target.startAnimation(blockAnim, true, 0);
          target.requestMotion('guard')
    }
    </Custom React Effect>
    <Custom Deselect Effect>
    setTimeout(function () {
     target.requestMotion('walk')
    }, 180);
    </Custom Deselect Effect>
    

    Additional notes:


    The more java-savvy of you guys might be able to figure out ways to bring this into other plugins. For those of you who aren't as good, I have modified Yanfly's StatusMenuCore plugin to allow block chance to be a value on the status menu's parameters screen. In your plugin settings, simply set one of the parameters to 'blk'. You can pick that up here.


    That's all for now, and if you're following my state workshop topic, I promise I'll be around soon. Thanks for holding out.


    Edit:


    I'm feeling pretty good about this shield slam thing, so I made an action sequence you can use to make your own shield slam-like skill. Here's what it looks like in action.


    Code:
    <Setup Action>
    display action
    move user: target, front base, 20
    wait for move
    immortal: target, true
    </Setup Action>
    <Target Action>
    wait: 15
    motion spell: user
    if (user.isActor())
      eval: user.startAnimation(user.equips()[1].slamAnimation, true)
    end
    if (user.isEnemy())
      eval: user.startAnimation(user.enemy().slamAnimation, true)
    end
    action effect: target
    if target.result().isHit()
     se: hammer, 90, 100, 0
     action animation: target
     wait for animation
    end
    wait: 20
    </Target Action>
    <Finish Action>
    clear battle log
    perform finish
    wait: 10
    immortal: target, false
    </Finish Action>

    Enjoy.

    Things you may do with this plugin:
    • Use it in your commercial or non-commercial project, with credit
    • Edit the state paste-code to better fit your project
    • Edit the plugin in any way necessary for your own use
    • Create and share add-ons to this plugin via your own plugin
    You may not share direct edits to this plugin unless previously discussed with me
     

    Attached Files:

    Last edited: Sep 12, 2017
    #1
  2. Lionheart_84

    Lionheart_84 Veteran Veteran

    Messages:
    416
    Likes Received:
    25
    First Language:
    Italian
    I can give you a tip ??? why not make sure that when a hit is blocked for a moment above the pg show the graphics of the equipped shield ???


    Like Tankentai for Rpg maker vx ace???... you know ???
     
    #2
  3. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    This is how the state I posted works, you just have to make an animation for your shield yourself. I figured this was better than pulling an icon and showing that, as the default RMMV icons don't match the style of an actual worn shield.


    See for yourself.
     
    #3
  4. Lionheart_84

    Lionheart_84 Veteran Veteran

    Messages:
    416
    Likes Received:
    25
    First Language:
    Italian
    I see ... so it's a unique graphic for each type of shield ???
     
    #4
  5. Rayhaku808

    Rayhaku808 Chubbizard Veteran

    Messages:
    204
    Likes Received:
    52
    Location:
    Hawaii, USA
    First Language:
    English
    Primarily Uses:
    N/A
    This feels good to have with your TGR plugin!
     
    #5
  6. icomefordl

    icomefordl Villager Member

    Messages:
    5
    Likes Received:
    0
    not sure what happen here  ;_; ;_;

    23V1.jpg

    wqve.jpg
     
    #6
  7. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm not sure what happened there either. When did this error come up? It looks like it happened during boot, which is weird because I don't think this plugin does anything during boot. I'm not too sure if it matters, but I tested the plugin with yanfly's plugins (most of them anyway) and always loaded it at the end, so maybe that has something to do with it.

    Yeah. The plugin parameters let you set a default animation for all shields, but you can use the <block animation: x> tag to make the block animation unique to each shield. The ones I used for the slam and block animations above were just a few frames of an RMVX shield icon moving around a bit. It could look better, but not bad for a few minutes work eh?
     
    #7
  8. icomefordl

    icomefordl Villager Member

    Messages:
    5
    Likes Received:
    0
    it show up when i start the game


    hope that you can release a demo i can load it for test, sorry about that . ;_;
     
    #8
  9. Lionheart_84

    Lionheart_84 Veteran Veteran

    Messages:
    416
    Likes Received:
    25
    First Language:
    Italian


    Indeed, you have been very good !!! I liked very much is the animation with the attack with the shield !!! good idea!!!  ;)


    Only one thing



    Where should I paste it ??? :unsure:
     
    #9
  10. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    You're going to need a couple of yanfly's plugins to fully make use of that. Buffs & States Core to be more specific. But also Auto Passive states will help you out a lot here as well.


    You're going to make a state, which you will passively put on your shield items using the <Passive State: x> tag on the individual items, and then the paste code I gave in the OP will go on that state. It should look something like this:


    blockchance.PNG


    Of course, my personal code is slightly different than what I have in this thread, but you should get the idea.


    Lunatic mode tags are special tags in the YEP plugins that allow experienced scripters to make all kinds of things happen. In this case, I'd stick to what I posted in here, but always know you can add or remove features on your own using these tags too.
     
    #10
  11. Nol

    Nol Veteran Veteran

    Messages:
    91
    Likes Received:
    6
    First Language:
    english
    Funny how sometimes, you need a specific feature, and someone did that only a few days prior !
    I couldn't get it to work though. No errors, either, so i guess thats somthing !

    I made the shield, added


    <BLOCK CHANCE: 100>


    <Passive State: 29>


    To it (29 is my block stat with your piece of code.


    Got into a fight.


    Did not block 100%.


    Died.


    I'm sure i missed something though.


    Potential idea : Adding a way for a parameter to add value to the block chance ; Exemple : My warrior has a stronger arm, or better reflexes, and adds +1% of his Agility


    to block rate of any shields.


    The wizard however... well, not so strong armed : Maybe he gets a malus.


    I can code the formulas i would need, but i cant include them into your work ^^


    Idea n° 2 : How about Parrying as a retooled block : A parrying dagger adding a small block value, and eventually a different animation


    (Oooooooor.....I could just make a shield called parying dagger)
     
    #11
  12. icomefordl

    icomefordl Villager Member

    Messages:
    5
    Likes Received:
    0
    only two script i am using .

    delll.jpg
     
    #12
  13. Nol

    Nol Veteran Veteran

    Messages:
    91
    Likes Received:
    6
    First Language:
    english
    @icomefordl You need yanfly states and core and then some, setup action comes from action sequence i think, so you need that too, and probably battle core.


    Reread the help section of the plugin.
     
    Last edited by a moderator: Dec 2, 2016
    #13
  14. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, so I had to fix a scripting error that was apparently causing the plugin to cause the game to crash in the boot phase for some reason. It wasn't happening in my own project, but a brand new project with the latest version of RMMV caused the issue. I haven't seen this cause any problems yet, and have confirmed in the brand new project, that when set up correctly, blocking will work.


    You can get that update here.


    Also, since someone was looking for it, I have created a small demo project, which contains a couple of the yanfly plugins, a block state, a block and slam animation that uses an RMVX icon (which you can't legally use in a commercial game unless you also own VX), and the mangled modified statusmenu core plugin with the settings already set to show block chance on the menu. You can get that here.



    You're going to need some other plugins to make use of this plugin. For now, with just the block plugin enabled, you can see that it's doing all it does by opening the console in-game and typing $dataArmors[x].blockAnimation which should return the ID you put in the note tag of the armor item Id X. Alternatively, you can type in $gameParty.members()[0].blk which will return the block chance of the actor in slot 1 of your party (or give an undefined message if the plugin isn't loaded).


    I'm not sure if it's a configuration issue or a compatibility issue with something else you have, but try copy+pasting out of my demo in this post and see if it works for you then.


    I want to say it could be possible in the future for me to add the functionality of allowing other params to affect block chance, but as of right now, it puts the block values on the shields and states when the game first opens, and wouldn't be able to update a live value (ie: your ever changing strength score), so it wouldn't work at present.


    You can probably set up some extra passive states that add to your block chance, and require a certain level of ATK to become active, as a workaround, I mean.


    The parry thing is a good idea, and I also considered it myself, but I haven't figured out how to animate a battler from the state react effect, yet. It'd look weird showing the dagger but him just standing there. Maybe in the future,


    Second Edit:


    I will be adding this to the OP as well, but thanks to the folks in the JS Learning forum, I have figured out how to cause battlers to change motions when a block occurs.


    In the default battle system, this looks just awesome. In the CTB system it doesn't quite look as good, but it gets the job done.


    Here is the new state note tag to put on your block command:


    <Custom React Effect>
    if (value > 0 && this.isHpEffect() && this.isPhysical()) {
    var rnd = (Math.floor(Math.random() * 99 + 1))
    var shd = target.blk
    if (rnd < shd){
    value -= value;
    target.startAnimation(target.equips()[1].blockAnimation, true, 0);
    target.requestMotion('guard')
    }
    }
    </Custom React Effect>
    <Custom Deselect Effect>
    setTimeout(function () {
    target.requestMotion('walk')
    }, 180);
    </Custom Deselect Effect>


    Here's how it looks in the Default system:


    [​IMG]


    And here it is in the CTB (looks weird because they don't stand in their ready pose before getting hit I think):


    [​IMG]
     
    Last edited by a moderator: Dec 2, 2016
    #14
  15. Nol

    Nol Veteran Veteran

    Messages:
    91
    Likes Received:
    6
    First Language:
    english
    Copy pasted demo, didnt wokr in my project.


    Most likely a compatibility issue
     
    #15
  16. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    I don't doubt that it is, but I don't think there'd be many plugins that would directly interfere with the blocking process.


    If you open the console and type in $gameParty.members()[0].blk does it give you a value? Hopefully it should be the value of the block chance on the actor in slot 0's shield. If it doesn't work, something may be overwriting the Object.defineProperties(Game_BattlerBase.prototype function that I overwrote in this plugin. Any other plugins you have that add custom parameters might be using this function too, so try loading my plugin before them.


    Alternatively, it could be that the attack you are testing block against simply isn't a physical attack. I've accidentally had my share of 'certain' hits messing me up when trying to test blocking before. XD
     
    Last edited by a moderator: Dec 2, 2016
    #16
  17. icomefordl

    icomefordl Villager Member

    Messages:
    5
    Likes Received:
    0
    thank you so much Ramza, I can load yr demo and work fine ! 


    it is a nice script , gdjob  :rock-left:
     
    #17
  18. Nol

    Nol Veteran Veteran

    Messages:
    91
    Likes Received:
    6
    First Language:
    english
    Tested for actor 0 and 1 (since i dont have an actor 0 ^^)


    Actor 0 returns "undefined"


    Actor 1 returns Uncaught TypeError: Cannot read property 'blk' of undefined


    Tried it at the top of all those plugins, same thing (which is fairly odd and means it's probably on my end)

    Sans titre-1 copie.png

    Sans titre-1.png
     
    #18
  19. ramza

    ramza Lunatic Coder Veteran

    Messages:
    449
    Likes Received:
    224
    Location:
    Nova Scotia, Canada
    First Language:
    English
    Primarily Uses:
    RMMV
    Hmm... The only YEP Plugins in your list I'm not sure of compatibility with are the parameter control ones. The rest of them I'm using in my own project. If you're going to end up turning off plugins to see which one is causing the problem, I'd start with those ones. Let me know if you figure it out, I might be able to scrape together a compatibility patch or something.
     
    #19
  20. Nol

    Nol Veteran Veteran

    Messages:
    91
    Likes Received:
    6
    First Language:
    english
    I tried to set it up in my base project, but deactivating plugins sent everything to hell : /


    Started a debug project, got the boot error, used your fix, couldn't make it work with, or without the extra parameter


    Will try adding it to your base blk project


    Tested with extra parameter in your BLK project, works without, doesnt work anymore with it
     
    Last edited by a moderator: Dec 8, 2016
    #20

Share This Page