Barrier Script Version 1.0 (Finished)

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Barrier Script, Version 1.0 (Completed)
by bgillisp

Introduction
This script allows you to create a state that will add a barrier to a character. All attacks to the character will hit the barrier instead of their HP, until the barrier falls. Also, barriers can fall due to time running out and will be auto-removed at that point.

Features
Adds a barrier which can be used to protect characters until the barrier falls.

How to Use
-Add the script in the materials section, but below main

-Start a new game to use! If you don't, some of the variables will not exist, and it WILL crash when you add the state.

-If you have any battle engines, you may wish to add this below the battle engine script.
-To add a barrier, first add the state to the skill that adds the barrier. Then in the notes section of the skill, add a notetag to either make the barrier a static barrier (fixed HP), or based on the caster's MAT.

Example:

<HP Barrier: 100> will make a 100 HP barrier

<HP Barrier MAT: 2.50> will make a barrier that has HP equal to 2.5 * the caster's MAT.

You can now heal your barriers with skills or items! To do this, set the item or skill to be hp restore, and use the damage formula box to set it up. Then, add the notetag <HP Barrier: Restore> in the notes box to tell it to apply this to a barrier, and not an actor or enemy.

Also, you can now set a barrier's max HP to block with the notetag: <HP Barrier MAX: x>, where x is the highest HP you ever want that barrier to have.

Finally, you can make it so that equipment enhances or weakens your barriers, and actors and enemies can have stronger or weaker barriers than the norm. To do this, add the notetag <HP Barrier Modify: x>, where x is the number you want multiplied to the barrier (use 2 to double all barriers, 0.5 to half all barriers, 0 to make no barriers work, etc). Be advised at the moment this only affects barriers cast *on* the wearer, not cast by the wearer. Currently investigating how to fix this.

If you are using version 0.96b onwards, read the directions in the header of the script, as you now have to use skills/items, and not states. Short version, set up the skill which creates the barrier first, fill in the damage box with the formula which creates the barrier, and set it to HP Restore. Then, add the notetag <HP Barrier: Create>  in the notebox of the skill or item which creates the barrier. Once you do this,

the barrier will last until it runs out of HP. More details on how to do things like make the barrier last x turns or only until a battle ends are in the script directions.

Demo
A short one is available here with the script: https://www.mediafir...vvmgdw426re527a

Script

The script without the demo is available here, version 0.96. This version uses states for the barriers http://pastebin.com/03HRqB0Z

For version 0.96b onwards of this script (it says 0.96a in the pastebin, will change that next upload) using skills/items for the barriers: http://pastebin.com/5T5ZKcSd

FAQ

Q: I add the notetag and it didn't work!
A: Spacing is important. Did you remember the space between the : and the number? Also I think it is case-sensitive, so make sure to use caps for HP.

Q: I added a barrier and it was ridiculously huge!

A: I have the script set up to where you post the number that is being multiplied, not the percent. So if you want it to be 250% of MAT, you pass 2.5. Passing 250% will result in a really high number being multiplied and near invincible enemies.
 

Q: This script does not work with script xxxx.

A: I can *try* to add a fix. If you wish me to try it, please post a link to a demo with the conflicting script and my script included, and I'll do what I can between my project and work schedules. However, work has gotten really busy and will be until December, so fixes might be a couple weeks to implement.  

Q: I would like to see feature  yyyy added.

A: Post said feature below and I'll see what I can do.
 

Author's Notes
This is now version 1.0! I would like to thank spaceman5 for the idea (and testing), and Zevia, Supernurse, and Ryidamist for the bug catches and posts on here, and anyone else who tested it and didn't post suggestions.

Terms of Use

Free for use in commercial and non-commercial games with credit given.

Mods, if you want to move this to the completed scripts forum since it is considered completed now, feel free.
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,203
First Language
Binary
Primarily Uses
RMMZ
I would have liked, but I done gone and reached my quota of positive votes for the day.
Haven't seen the code, but the I've always liked barrier type skills from FF games :)
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
seem really interesting script indeed !  i will test it later ;3
 

SuperNurse

RPG RN
Member
Joined
Apr 30, 2012
Messages
17
Reaction score
0
First Language
English
Primarily Uses
Excellent stuff.  Working great in my project.   :)  Thanks!

EDIT: If I could make a feature request?  Instead of being based off the caster MAT, would it be possible for the barrier to be based off a certain percentage of the receiver's maximum HP?  So that way that it's more effective casted on tankier characters and not so much on frail characters.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I never thought of that idea, basing it on HP percentage. Will try to implement it via a notetag in the next few days. I also got a request asking for the ability to heal the barrier via a skill, so will work on that as well.

I also thought of allowing the barrier to regenerate over time. This could then let someone make a sci-fi game where the barrier was a character's shielding, and the once it fell, the HP was damaged. Though it may take some work to figure out how to keep the barrier regenerating if it hits 0, due to linking it to a state. I

Has anyone tested this with other battle systems than the ones I listed? I"d like to know how compatible it is with them for reference. Once we confirm this is working well for most people (or as well as it can) I'll post it over to the completed scripts, but since I still consider it a beta, its here for now.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
I never thought of that idea, basing it on HP percentage. Will try to implement it via a notetag in the next few days. I also got a request asking for the ability to heal the barrier via a skill, so will work on that as well.

I also thought of allowing the barrier to regenerate over time. This could then let someone make a sci-fi game where the barrier was a character's shielding, and the once it fell, the HP was damaged. Though it may take some work to figure out how to keep the barrier regenerating if it hits 0, due to linking it to a state. I

Has anyone tested this with other battle systems than the ones I listed? I"d like to know how compatible it is with them for reference. Once we confirm this is working well for most people (or as well as it can) I'll post it over to the completed scripts, but since I still consider it a beta, its here for now.
I will test it with tankentai (journey SYstem) and I will tell you after if the script is compatible

this is possible to make this Barrier system to only aply when he block? 

like when you do a shield break 

if you want I can help you for this part ;3
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Ok, thanks! All methods are aliased, so it should work, but my concern is if a battle system overwrites how damage flows in the game, it might apply the damage before it gets to my script. If so, that will be really hard to fix though, but still would like to know.

Also, sometimes the HP bar for the barrier does not show well on other systems. On the default, it is a little below the HP bar, and on Yanfly's it replaces your HP bar while the barrier is in effect. For other systems it will try to draw it a little below the HP bar, but some battle systems don't call the method draw_actor_hp, as they elected to draw the bar their own way. In those cases, the HP bar for the barrier will fail to show, and those are the ones I want to locate so I know of them.

As for only apply on block? Do you mean using guard, or something else?
 

SpacemanFive

Meteor Mage
Veteran
Joined
Jun 25, 2013
Messages
207
Reaction score
24
First Language
English
Primarily Uses
RMMZ
I will test it with tankentai (journey SYstem) and I will tell you after if the script is compatible

this is possible to make this Barrier system to only aply when he block? 

like when you do a shield break 

if you want I can help you for this part ;3
If I understood you correctly, would it be possible to implement this via modifying the default block skill in your game to add a barrier state with a single turn duration when used?
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
There's two implementations I can think of here. One is using a guard adds a fixed barrier, which will block x damage. The other is having guard add a barrier based on one's defense stat, which blocks x damage for one turn. The second would be easier to implement as all I'd have to do is add a notetag for a barrier based on DEF, then one adds that to the default guard skill (and adds a duration of 1 turn to guard too).

Edit: You can now apply a barrier when you guard. Add the notetag <HP Barrier x: y> to the guard state, where x is the stat you want the barrier based on, and y is the value to be multiplied to that value. So, if you want the barrier to be 2.5 * the actor's defense, you would use

<HP Barrier DEF: 2.5> in the notes section of your guard state.
 
Last edited by a moderator:

SpacemanFive

Meteor Mage
Veteran
Joined
Jun 25, 2013
Messages
207
Reaction score
24
First Language
English
Primarily Uses
RMMZ
I never thought of that idea, basing it on HP percentage. Will try to implement it via a notetag in the next few days. I also got a request asking for the ability to heal the barrier via a skill, so will work on that as well.

I also thought of allowing the barrier to regenerate over time. This could then let someone make a sci-fi game where the barrier was a character's shielding, and the once it fell, the HP was damaged. Though it may take some work to figure out how to keep the barrier regenerating if it hits 0, due to linking it to a state. I

Has anyone tested this with other battle systems than the ones I listed? I"d like to know how compatible it is with them for reference. Once we confirm this is working well for most people (or as well as it can) I'll post it over to the completed scripts, but since I still consider it a beta, its here for now.
I'm surprised I hadn't thought about barrier regeneration before, considering at least one of my projects is a sci-fi which would definitely be using a regenerative energy shield system. (Mainly for vehicles.)

Would it be possible to implement it via a check process triggered by a specific type of tag (Such as <Regen HP Barrier: Y> or <Regen HP Barrier X: Y>), then modified by another?

What I thought of would only start a check process when this tag runs, which would "scan" for either a present barrier or depleted barrier.

In the event of a present barrier (which has all or some HP left), the script would then continue the regen. In the event of a depleted (empty) barrier, it would replace it after a specified period of time (in config) at a value determined by a modifier tag.

The modifier tag would determine how much HP the renewed barrier would have, either being a fixed value or a percentage. (You could even set it up so a barrier regens at 100% a few turns after being depleted, although that might be more boss mechanic material.)

Dang. This is getting really complicated. I can see what you mean about it taking some work to implement.

There's two implementations I can think of here. One is using a guard adds a fixed barrier, which will block x damage. The other is having guard add a barrier based on one's defense stat, which blocks x damage for one turn. The second would be easier to implement as all I'd have to do is add a notetag for a barrier based on DEF, then one adds that to the default guard skill (and adds a duration of 1 turn to guard too).

Edit: You can now apply a barrier when you guard. Add the notetag <HP Barrier x: y> to the guard state, where x is the stat you want the barrier based on, and y is the value to be multiplied to that value. So, if you want the barrier to be 2.5 * the actor's defense, you would use

<HP Barrier DEF: 2.5> in the notes section of your guard state.
That's a pretty neat new mechanic for it. Great job!

I originally hadn't thought of that for my projects, but I can see places where it could be useful or would fit, now that I've gotten thinking about it. Thanks both to you and the person who suggested it!

It could work for Sci-fi games, such as with a personal barrier field generator, but it could also work in fantasy games, such as with a pendant, bracelet, ring, or even weapon with a protective barrier enchantment.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Yeah, it can get complicated. I'm thinking the idea of a barrier that regenerates like shields in sci fi games is probably a different script, just because I'd have to

overhaul the variables and such, since people would want ways to level up the shields and such. Plus, in most sci-fi games, shields are up by default in battles, though...I think you could use this still if you added a raise shields/lower shields command to the current system, and based the power on MAT or something?

I'll have to check into that idea on the item notetag. I'm still new at notetag reading in scripts, so it may take a while to implement that idea.

Also...in my game I realized I wanted a barrier to block MP damage too (as some monsters are nasty in their MP drains), so I do plan to add the ability to use it on MP too. Though I probably will clean up the add_state code first, as there are a lot of redundant lines buried in the if that could be modulated. After that, maybe then check into regen, work schedules permitting? The other thing is I have it all tagged to states, not too sure about adding it to items or other things yet.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Was hunting for something like this for quite some time, very glad to see it! Thanks for taking the time to create it.

In my game, I notice that it completely erases your HP bar and draws a new one (I'm using Yanfly's battle engine, so it's his method of drawing) - would it be possible to make it so that it overlaps your HP bar? That is, when using the Barrier_Max_HP_Display option of 0 (showing it relative to the actor's max HP), could the actor's HP bar be drawn underneath it? Alternatively, since you mentioned that you can draw it slightly below the HP bar in other battle systems, could that be made an option for people who are using Yanfly?

EDIT: I noticed if I went down into draw_actor_barrier and changed "line height*2+offset" to "line height*1.5+offset," it will draw the shield bar above the HP bar, and that works just fine for me.

Also, would it be possible to do calculations in the state notetag somehow so you could have a variable added to a static number? Something like: "HP Barrier MAT: 0.5 + 100", such that if the actor has 50 MAT, it would apply a barrier of 125?

I also noticed that when I set my default_shatter and default_opposite element to -1, a normal attack immediately removes the shield, even if 0 damage is done. When I changed those to -2, that behavior stopped occurring. I noticed that the attack skill has an effect of "add state normal attack," so I'm wondering if the game already treats -1 as the normal attack state by default.

EDIT: If you try to reapply the barrier before it's removed, it will refresh the state's duration, but not refresh its absorb amount - is there a way to alter that?
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Due to the way Yanfly draws the HP bars, and a HP bar draw wipes everything under it, I couldn't get it to show the regular HP underneath it. I was trying to get it to display above, but that was proving problematic, but glad ot hear 1.5 added to the offset works!

Static calcuations might be tough, I don't yet know how to read two variables in a notetag at once. Though maybe I can add a seperate notetag for anyone who wants that?

Yes, -1 will cause normal attacks to shatter. That is because normal attacks have -1 for the element applied. I noticed that in the code for the battle engine. And shatter is meant to be a shatter on any hit, regardless of damage (so you can put a counter barrier skill if you wish, and give it that element).

And it appears I will need something to allow it to refresh the hp bar on reapply. I have all of mine set to a 5 turn cooldown and 5 turn states, so a reapply was not possible in my game. Good to know..off to search what function needs to be edited to fix that.
 
Last edited by a moderator:

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Yes, -1 will cause normal attacks to shatter. That is because normal attacks have -1 for the element applied. I noticed that in the code for the battle engine. And shatter is meant to be a shatter on any hit, regardless of damage (so you can put a counter barrier skill if you wish, and give it that element).
Well, what I mean is, in your script's instructions, you have this line: "Default shatter element. If do not wish to use, set this to -1, or an element not actually in your game." However, setting it to -1 does not actually mean "I don't want to use this," it means the shatter state is a normal attack. Setting it to -2 seems to work, though.

If you happen to find out a way to refresh the barrier and do calculations within the notetag, I'd be greatly appreciative - but no rush. My project still has lots to be done, and I'm actually happy to have the functionality as it is. Thank you again for taking the time to make this script and respond to requests.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Well, what I mean is, in your script's instructions, you have this line: "Default shatter element. If do not wish to use, set this to -1, or an element not actually in your game." However, setting it to -1 does not actually mean "I don't want to use this," it means the shatter state is a normal attack. Setting it to -2 seems to work, though.

If you happen to find out a way to refresh the barrier and do calculations within the notetag, I'd be greatly appreciative - but no rush. My project still has lots to be done, and I'm actually happy to have the functionality as it is. Thank you again for taking the time to make this script and respond to requests.
Ooops...guess I have something else to fix then. Making the change for version 0.94 then, which is now available on the pastebin link. Also you can now use multiple notetags, so a barrier can use <HP Barrier MAT: 2.50> and <HP Barrier: 50>, which will have it make the barrier 50 HP + 2.5 times the caster's MAT. Now to figure out how to add in the ability to refresh the barrier....probably need a new function for that. In the short term, you might be able to fix this with Yanfly's state/buff manager and the <reapply reset> tag.
 
Last edited by a moderator:

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Using multiple notetags works wonderfully, thank you very much.

I do have Yanfly's buff/state manager already, but unfortunately <reapply reset> only resets the number of turns the state will last. However, I tried just having the skill have the effects: "Remove state shield, add state shield," and that properly "refreshes" it. It makes the state popup as "-Shield" "+Shield," so it's not exactly *perfect*, but it certainly has the functionality I'm looking for with a very minor graphical quibble.

EDIT: I have another issue, but I haven't narrowed down if it's the script yet or not - I have to get going, so I don't have time to test it right this moment. Whenever an enemy attacks a character with a barrier on them with anything that applies a state, it's removing the barrier. The actual barrier state remains, but the shield itself vanishes and the actor takes damage as if he didn't have it.

So let's say Actor1 has a state "Shield" on them with a barrier of 230. An enemy attacks with a skill that does 0 damage, but applies the state "silence." The Shield state will remain on Actor1, but the barrier will vanish. Now if the barrier is reapplied, and the enemy attacks with a skill that does 30 damage, but applies the state "poison," the Shield state will remain on Actor1, but the barrier will vanish. It's pretty much all states except ones that the Shield state otherwise makes the actor resistant to.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Appears there is a bug in the way I applied multiple notetags, as it is resetting the barrier on all states. I'll need to rewrite the notetag code to fix that. You could fix that short term by commenting out the line 222 (if you made no edits), it says self.hp_barrier = 0. What is happening is that is being applied on all states, so it is wiping the barrier. If you comment that out, the clear/reset lines *should* still be enough, but there is the slim chance of someone using a spell and the barrier picking up where it left off this way.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Commenting out line 222 seems to have worked. Since my shield skill removes the barrier state and reapplies it, it appears to be resetting the shield strength properly as well.

Appreciate the quick feedback on issues, thank you again. Near as I can tell, everything seems to be OK for now - I'll let you know if I stumble across anything else.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Not a problem! This is called how I watch college football (code and listen at once). I posted the updated code, and a temporary way to heal barriers. It will not work well as it is flagged to states, but it will make a good stop-gap solution. Now to look into that refresh bug, then the healing ability.​
 

RydiaMist

Veteran
Veteran
Joined
Jan 29, 2013
Messages
31
Reaction score
4
First Language
English
Primarily Uses
Great idea for a script! I'm not sure if I'm doing something terribly wrong but it doesn't seem to work for me. I tried this in a fresh project, and the <HP Barrier: x> tag does not work at all. The <HP Barrier MAT: x> tag causes a strange behavior. It absorbs damage, but for some reason when the barrier is broken the HP values of damage are displayed with decimal points, which also causes the HP display in the battlestatus to show a decimal point as well. Here's a screen of what it looks like:

barriererror.png

In my own project which uses Tankentai, the damage popups also display crazy numbers when the barrier is broken as well. This is obviously not a problem with your script though, unless it's tied to whatever is causing the wonky damage display. Thanks for looking, and again great script that was desperately needed! The only other script like this I could find was Tsukihime's, and it has the problem of always blocking the full damage from the next attack regardless of the barrier strength.

EDIT: For what it's worth, I tried the old version from your demo, and it seems to work great, even with the Tankentai damage popups! So maybe that will help you track down the problem.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top