じ☆ve冰风 发表于 4 天前

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().setShield(value);
$gameTroop.aliveMembers().getShield();
$gameActors.actor(id).shieldRate();
$gameActors.actor(id).shieldRateWithoutLimit();
$gameTroop.aliveMembers().shieldRate();
$gameTroop.aliveMembers().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().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:





本贴来自国际rpgmaker官方论坛作者:Vyndicate处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/shield.183637/
页: [1]
查看完整版本: Shield