MV Shield

Shield
Author: Vyndicate


This will add shield feature into the battle
The UI a bit messy because I'm not really pro about it. But mostly it's functional

The gauge is based on ally available shield / max hp. Currently only for allies. Party, Troop, and Enemies will not have gauge and they will have text instead

Skill Notetag:
<Shield: x>
<Shield: formula>
Gain of x amount of shield for each target
You can put either flat amount or using formula with a is user and b is target

<Team Shield: x>
<Team Shield: formula>
Gain of x amount of shield for team, either troop or party
You can put either flat amount or using formula with a is user and b is target

<Target Shield: x>
Target you want to add shield using scope from game + additional scope

Scope from game:
0: None
1: 1 Enemy
2: All Enemies
3: 1 Random Enemy
4: 2 Random Enemies
5: 3 Random Enemies
6: 4 Random Enemies
7: 1 Ally
8: All Allies
9: 1 Ally (Dead)
10: All Allies (Dead)
11: User

Additional Scope:
12: All Allies (Excluding User)
13: Team (Either Party or Troop)

Available to use Target Shield Notetag => 2, 8, 11, 12, 13

Scope 13 is for gainTeamShield only

If using number other that mentioned above, it will use default scope from
what database has been set

<Shield Drain: x>
When using skill to damage, it will drain some of the shield from opponent to user or any ally targeted scope. Number is percentage, x is value from 0 to 100. If you put more than 100, it will more than 100% technically

<Pierce: x>
When using skill to damage, it will bypass the damage straight to decrease H instead of decrease shield. Number is percentage, x is value from 0 to 100. If you put more than 100, it will more than 100% technically

State Notetag:
<Block Shield>
Using this in state will block all shield that gain with positive value, including from drain shield
Negative value or getting damage by opponents will not affected by this

YEP_X_ActSeqPack1:
You can use inside action sequence provided by Yanfly Plugin Action Sequence Pack 1
=============================================================================
ADD SHIELD: (target), (value)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Add the amount of value to desired target. Target is same as what mentioned in YEP_X_ActSeqPack1. The value can be either flat number or formula with a is user and b is target
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Usage Example: add shield: actors, 300
add shield: enemies, b.mhp / 4
add shield: all members, a.atk * 2
=============================================================================
ADD (PARTY/TROOP) TEAM SHIELD: (value), true/false
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Add the amount of value to either for party or troop. The value can be either flat number or formula with a is user and b is alive member of the team. Set true if you want to calculate only from user without other party members. It will set to false if using flat number or not write the boolean value
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Usage Example: add party team shield: 250
add troop team shield: b.mhp / 4, false
add party team shield: a.mhp / 2, true =============================================================================

Script Calls:
You can directly call through script call. The available functions are:
(actor/enemy).getShield()
Get current shield of character

(actor/enemy).setShield(value)
Adjust shield of character

(actor/enemy).addShield(value)
Add shield of character. Value can be negative
Minimum value result is 0

(actor/enemy).removeShield(value)
Remove shield of character
Minimum value result is 0

(party/troop).getTeamShield()
Get current team shield of party or troop

(party/troop).setTeamShield(value)
Adjust team shield of party or troop

(party/troop).addTeamShield(value)
Add team shield of party or troop. Value can be negative
Minimum value result is 0

(party/troop).removeTeamShield(value)
Remove team shield of party or troop
Minimum value result is 0

(actor/enemy).shieldRate()
Get current shield rate of character. It will return based on current shield / max hp. In code, mostly used for gauge display
Return between 0 to 1
To make it percentage. You can use like this"
Math.floor(actor.shieldRate() * 100)
use + "%" if you want to make it display

(actor/enemy).shieldRateWithoutLimit()
Same as above, but it will show more than 1 instead
between 0 and 1

From predefined variables, can be used anywhere when script call is allowed, including for debuging:
$gameParty.setTeamShield(value);
$gameParty.getTeamShield();
$gameTroop.setTeamShield(value);
$gameTroop.getTeamShield();
$gameActors.actor(id).setShield(value);
$gameActors.actor(id).getShield();
$gameTroop.aliveMembers()[index].setShield(value);
$gameTroop.aliveMembers()[index].getShield();
$gameActors.actor(id).shieldRate();
$gameActors.actor(id).shieldRateWithoutLimit();
$gameTroop.aliveMembers()[index].shieldRate();
$gameTroop.aliveMembers()[index].shieldRateWithoutLimit();

Enemy doesn't have predefined variable, so it needs to called through $gameTroop and do either a loop or direct index call
The function of enemy list can be anything like allMembers(), members(), aliveMembers(), etc

From damage formula:
a.getShield()
b.getShield()
a.removeShield(value)
b.removeShield(value)

Example:
a.atk * 4 - b.def * 2 + a.getShield() / 2
a.atk * 4 - b.def * 2; b.removeShield(a.atk * 3)

From eval on Yanfly. This might be very rare situation, but can be very useful too:
this._action.subject().getShield()
"this" is refer to BattleManager
_action is currently doing action
subject is the user who use it
Example
<target action>
eval: $gameVariables.setValue(1, this._action.subject().getShield() * 2);
</target action>
============================================================================
You can also set it to variables or switch depend on what your need
$gameVariables.setValue(1, $gameActors.actor(id).getShield());
$gameSwitches.setValue(1, $gameTroop.aliveMembers()[index].getShield() > 0);

Note: You can adjust the code as you desire. The shield calculation should be work as intended

Terms of Use:
Free for commercial and non commercial use with credits

Changelog
v1.1.5
Fix static number value cause NaN error
Fix shield will not retain if the battler has shield, killed, and revived from death
Add block shield state notetag, prevent gain positive shield

v1.1.4
Add shieldRateWithoutLimit()
Add complete description
Add new parameter, display with percentage or not. Only used for actors and enemies

v1.1.1
Prevent wrong value for Boolean type and fix troop position shield text

v1.1.0
Add YEP_X_ActSeqPack1 compatibility

v1.0.2
Prevent negative shield

v1.0.1
Add battle end reset option

v1.0.0
Init plugin

Showcase:
Screenshot 2026-05-16 112744.png
this is nice, can come in handy (but my modify it for personal use).
if you allow me for my own project =)
this is nice, can come in handy (but my modify it for personal use).
if you allow me for my own project =)
sure. just only need to credit me if you want to use it
Changelog v1.1.0
Now you can adjust shield inside action sequence of Yanfly Plugin (YEP_X_ActSeqPack1)
I saw you use this: Boolean(VynPlugin.parameters
as Boolean may give unwanted result, as if type is boolean,
you may be better off using JSON.parse(VynPlugin.parameters) as
this parse the boolean better.

also this one: /ADD[ ]SHIELD/i can be tricky as its safer for /ADD\s*SHIELD/i
from my own experience.

the 2nd allow any space, so it always falls back nicely if they accidently
add 2 spaces instead of 1 🙂

other than that (the first version I use) for testing works nice, as I can make
something around this when starting on the battles.
I saw you use this: Boolean(VynPlugin.parameters
as Boolean may give unwanted result, as if type is boolean,
you may be better off using JSON.parse(VynPlugin.parameters) as
this parse the boolean better.

also this one: /ADD[ ]SHIELD/i can be tricky as its safer for /ADD\s*SHIELD/i
from my own experience.

the 2nd allow any space, so it always falls back nicely if they accidently
add 2 spaces instead of 1 🙂

other than that (the first version I use) for testing works nice, as I can make
something around this when starting on the battles.
thanks for the insight. I'll make an update regarding this alongside with ui positioning fix

I was copying the format from yanfly plugin, so that's why I'm using same as yanfly
go with let/const, and the regex may work, but its only my own experience.
using "\s*" is safer than "[ ]" out of my own experience to allow spaces.

but you can use whatever you find works best, but position is nice or rotate to make
it vertical, so it can be used too.

another optional is to easy grab the value (or explain how too) so they may
be used inside SRD_HUDMaker as grabbing those values can handle the update ^^

so keep it up, its a nice shield for both sides.
Changelog v1.1.1
Prevent boolean type into wrong value and fix ui positioning

Troop now align to right instead of align to left
another optional is to easy grab the value (or explain how too) so they may
be used inside SRD_HUDMaker as grabbing those values can handle the update ^^
I'm sorry, could you elaborate more about this? I'm not English native, so not quite understand :hswt:
there is this function:
JavaScript:
Game_Battler.prototype.setShield = function (value) {
    this._shield = value;
};

which can set it, but also read the value of the current shield.

which is a, b, enemy, party, actorId etc which can grab them.

what isn't said is "how to read" the function (so while debugging)
use scriptcall => this scriptcall for debug to check shield value
can also be used in SRD_HUDMaker => to use shield as image or change
image based on value left.

only adding this part, as how to check debug is also directly link
to use in another plugin (for easy grab) or hudmaker (which reads values).

and I use HUDMaker to create my hud, so having this scriptcall by hand is an easy grab.
So I just add a comment about it to make it known what's the function used for?
yes, so it can also be used in variable to know the value outside battle
if needed like help description or else where.

it can have many purposes that way if its in the document how to debug,
use it to get the value/maxValue for example.
interesting, I can update those for clear usage
Update plugin a bit with comments
Update plugin a bit with comments
not quite what I meant in the document, (which is the helpfile), more like those
what I can track down the functions:
Code:
Actor 1 shield
$gameActors.actor(1).getShield()

Party Leader
$gameParty.leader().getShield()

Party member 3
$gameParty.members()[2].getShield()

GameTroop member 1 shield
$gameTroop.members()[0].getShield()

in formula's
a.getShield() * 2

or as:
b.removeShield(100)

in event command scriptcall
$gameVariables.setValue(1, $gameActors.actor(1).getShield());

or inside the variable script:
$gameActors.actor(1).getShield()

Adding shield points
$gameActors.actor(1).addShield(100)

Remove shield points
$gameActors.actor(1).removeShield(50)

set shield to value
$gameActors.actor(1).setShield(250)

get shieldRate (between 0 and 1) (percentage)
$gameActors.actor(1).shieldRate()

ShieldRate percentage
Math.floor($gameActors.actor(1).shieldRate() * 100)

this give others the oppertunity what they can do inside troop event
if they need scriptcalls, variables, etc to increase/decrease values =)

hope this makes more sense, but the other comments are still useful though.
Ahh, I was misunderstanding then. I will do it again on next update
Changelog v1.1.4
Add shieldRateWithoutLimit(), can use if you want to return value with more than 1
Add complete description in plugin and this post
Add new parameter, display with percentage or not. Currently only used for actors and enemies

Thanks to @ShadowDragon for insight about description!
sweet, thank you, this keep a good reference ^^

thank you for the update and new function ^^
Changelog v1.1.5
Fix static value cause NaN error
Fix shield will not retain the battler is killed when having shield, and then revived
Adding a <Block Shield> through state notetag. Shield will not gained when having this in inflicted state

Original thread: https://forums.rpgmakerweb.com/threads/shield.183637/