MZ Coding questions and possible script plug-in help???

This is probably a thread I'm going to keep coming back to to keep asking new questions.
I'm want to learn coding on a practical level for CryEngine and Unity on my own time. Mostly C# and Linux, but not really JavaScript. I don't see myself using it too much going forward once I'm done wth this game I'm currently working on.

Long story short, I'm fairly dumbfounded when it comes to RPGMaker MZ.

I keep coming up with new ideas for items and mechanics, but some of them are hard to implement via the vanilla system.
I've found plenty of plug-ins that cover what I want, and stuff like a crafting system is fairly easy to replicate to meet my wants and needs and nothing more or less.

So I guess this is mostly for stuff I'd either like a point in the right direction for a plug-in that meets a similarity for what I'm looking for, or directions to easy-to-understand tutorials to teach me how to script for (or the general script that I'd need to write out).

I have a quite a list of ideas I'm already dead set on, so don't mind me if I just dump my current favorites here:

- Getting the program to recognize a certain HP percentage as "Critical Health"

- Scripting an skill/item/equipment piece to increase damage or ignore enemy Defense/Magic Defense when you're sitting at "Critical Health"

- I have an idea for a specific accessory that prevents you from being downed as long as you're above "Critical Health", like "Hang Tough" from Octopath Traveler (and other similar skills/accessories form other series)

- Scripting a piece of equipment to roll a percentage that may occasionally double damage dealt by any attack

- In correspondence to VisuStella's plug-ins to increase your party size, I also want to be able to make certain characters exclusive to party slots 9 & 10 (yes you read that right, i have increased the main party size to 8), solely to act as support units that can't attack or be attacked (I have that last part done so no big worries there). I even have little platforms on every battleback for them to stand on.

and I'm bound to keep coming up with stuff

and i'm also open to new ideas as well

so if anyone knows MZ'z JavaScript coding or any decent plug-ins, help a brother out?????
thanks in advance!
Mostly C# and Linux, but not really JavaScript.
Linux isn't a programming language--it's an operating system. As far as learning C# (and not JavaScript) goes, it's important to understand that learning a specific programming language is not really a big deal--especially when moving from one C-based language to another. Like, if you're adept at JavaScript, you could likely read C# code without any problem, and you could probably learn to write C# in about an hour... and vice versa. The actual time consuming part about learning to program is learning general programming concepts--not learning the specific language. You can learn those concepts in JavaScript, and they would still mostly transfer over to C#, so it wouldn't really be any kind of a loss if you were to just go ahead and start learning some JavaScript while you're working with RPG Maker.

- Getting the program to recognize a certain HP percentage as "Critical Health"
Every battle entity has a hpRate() method that you can call to get its hp percentage (as a ratio). So for example, $gameActors.actor(1).hpRate() will return 1 if actor #1 has 100% hp, .75 if they have 75%, etc. You can use that to test for "critical health" in your formulas and such.

- Scripting an skill/item/equipment piece to increase damage or ignore enemy Defense/Magic Defense when you're sitting at "Critical Health"
Just use what I mentioned above inside your damage formulas. You can use JavaScript's conditional ternary operator to test for conditions:
Code:
condtion ? formula when true : formula when false
So for example, suppose I've got a skill that originally had this damage formula: a.atk * 4 - b.def * 2... and I want to make it ignore defense when the user has less than 25% hp, here would be the new damage formula:
JavaScript:
a.hpRate() >= .25 ? a.atk * 4 - b.def * 2 : a.atk * 4

You can also check if the user is wearing a specific piece of armor, using a.hasArmor($dataArmors[id]), replacing id with the numerical ID of the armor. You could also work that into your damage formulas if you wanted to.

You can also unlock some more flexibility and options using VisuStella's note tags. Battle Core has note tags that let you use JavaScript to manipulate the damage of skills, which can sometimes be a bit easier than trying to cram a bunch of crap into your damage formulas. Items and Equips Core lets you use JavaScript to manipulate the parameters added by a specific piece of equipment. Skills and States core adds some more options too. There are a lot of ways to go about it.

- I have an idea for a specific accessory that prevents you from being downed as long as you're above "Critical Health", like "Hang Tough" from Octopath Traveler (and other similar skills/accessories form other series)
There are lots of ways to go about this as well. One example would be to have VisuStella Battle Core installed, and add a note tag such as this one to the armor's note box:
Code:
<JS Pre-Damage as Target>
  if (target.hpRate() >= .25) {
    value = Math.min(value, target.hp - 1);
  }
</JS Pre-Damage as Target>

That will make it so that if a user is wearing that item, and their current HP percentage is 25% or greater, and they would take lethal damage, it will reduce the damage so that they wind up with 1 hp instead. You could spice it up with a message and an animation and whatnot as well.

That's just one possible way to do it. Variations are generally going to include giving the actor the Immortal state, so that they can't die. Then after an attack, check if they're at 0 hp and if the conditions are met for a Guts type move to happen, and then either heal them, or remove the immortal state.

- Scripting a piece of equipment to roll a percentage that may occasionally double damage dealt by any attack
You could use Battle Core and add this note tag to the equipment:
Code:
<JS Pre-Damage as User>
  const roll = Math.randomInt(10);
  if (roll === 0) {
    value *= 2;
  }
</JS Pre-Damage as User>

That would give the equipment a 10% chance to double your damage on any given attack.
Linux isn't a programming language--it's an operating system. As far as learning C# (and not JavaScript) goes, it's important to understand that learning a specific programming language is not really a big deal--especially when moving from one C-based language to another. Like, if you're adept at JavaScript, you could likely read C# code without any problem, and you could probably learn to write C# in about an hour... and vice versa. The actual time consuming part about learning to program is learning general programming concepts--not learning the specific language. You can learn those concepts in JavaScript, and they would still mostly transfer over to C#, so it wouldn't really be any kind of a loss if you were to just go ahead and start learning some JavaScript while you're working with RPG Maker.


Every battle entity has a hpRate() method that you can call to get its hp percentage (as a ratio). So for example, $gameActors.actor(1).hpRate() will return 1 if actor #1 has 100% hp, .75 if they have 75%, etc. You can use that to test for "critical health" in your formulas and such.


Just use what I mentioned above inside your damage formulas. You can use JavaScript's conditional ternary operator to test for conditions:
Code:
condtion ? formula when true : formula when false
So for example, suppose I've got a skill that originally had this damage formula: a.atk * 4 - b.def * 2... and I want to make it ignore defense when the user has less than 25% hp, here would be the new damage formula:
JavaScript:
a.hpRate() >= .25 ? a.atk * 4 - b.def * 2 : a.atk * 4

You can also check if the user is wearing a specific piece of armor, using a.hasArmor($dataArmors[id]), replacing id with the numerical ID of the armor. You could also work that into your damage formulas if you wanted to.

You can also unlock some more flexibility and options using VisuStella's note tags. Battle Core has note tags that let you use JavaScript to manipulate the damage of skills, which can sometimes be a bit easier than trying to cram a bunch of crap into your damage formulas. Items and Equips Core lets you use JavaScript to manipulate the parameters added by a specific piece of equipment. Skills and States core adds some more options too. There are a lot of ways to go about it.


There are lots of ways to go about this as well. One example would be to have VisuStella Battle Core installed, and add a note tag such as this one to the armor's note box:
Code:
<JS Pre-Damage as Target>
  if (target.hpRate() >= .25) {
    value = Math.min(value, target.hp - 1);
  }
</JS Pre-Damage as Target>

That will make it so that if a user is wearing that item, and their current HP percentage is 25% or greater, and they would take lethal damage, it will reduce the damage so that they wind up with 1 hp instead. You could spice it up with a message and an animation and whatnot as well.

That's just one possible way to do it. Variations are generally going to include giving the actor the Immortal state, so that they can't die. Then after an attack, check if they're at 0 hp and if the conditions are met for a Guts type move to happen, and then either heal them, or remove the immortal state.


You could use Battle Core and add this note tag to the equipment:
Code:
<JS Pre-Damage as User>
  const roll = Math.randomInt(10);
  if (roll === 0) {
    value *= 2;
  }
</JS Pre-Damage as User>

That would give the equipment a 10% chance to double your damage on any given attack.
Holy moly, thank you!

Also, thanks for the heads up with coding itself. I haven't even started learning anything yet, it was mostly a whim when I first downloaded RPGMaker and heard about CryEngine. Hearing that actually makes me less anxious about getting started.

And baba-booey, big thanks for all the answers!!! All things considered, I'm still extremely new when it comes to RPGMaker, let alone the MZ version. Trying to wrap my head around how this program works beyond a surface level hurts my head sometimes.
- Getting the program to recognize a certain HP percentage as "Critical Health"
If this means you want to change the percentage of HP at which your battlers go into the Near Death motion, the default function is:
Code:
Game_BattlerBase.prototype.isDying = function() {
    return this.isAlive() && this._hp < this.mhp / 4;
};

so you can see the default is 25% health. You could copy that function, change the equation to whatever you want, and save it in a .js file to include as a plugin.
If this means you want to change the percentage of HP at which your battlers go into the Near Death motion, the default function is:
Code:
Game_BattlerBase.prototype.isDying = function() {
    return this.isAlive() && this._hp < this.mhp / 4;
};

so you can see the default is 25% health. You could copy that function, change the equation to whatever you want, and save it in a .js file to include as a plugin.
Noted and saved.

thank you internet friend

Original thread: https://forums.rpgmakerweb.com/threads/coding-questions-and-possible-script-plug-in-help.149550/