Lark_Larkington

Villager
Member
Joined
Mar 2, 2021
Messages
7
Reaction score
2
First Language
Dutch
Primarily Uses
RMMV
Dear all,

I'm just getting started with MV and have little coding experience. I would like to create save points that do the following:
IF [actor] was below 50% of their maximum health, THEN their health is set to 50% of their maximum health.

In other words, this would not trigger if the actor has 50% or more of their maximum health. I don't think I can get this done without coding, so I'd greatly appreciate it if someone who knows JS could type out the required lines for me.

Many thanks <3
 

ScorchedGround

Blizzards most disappointed fan
Veteran
Joined
Apr 12, 2020
Messages
489
Reaction score
698
First Language
German
Primarily Uses
RMMV
Should this affect the entire group or just specific actors?
Should this affect dead characters aswell?

Until then, you can try this Script-Call (It is found on Page 3 At the bottom right of the event tabs):

JavaScript:
let targets = $gameParty.members();
targets.forEach(function(target) {
  if (target.hpRate() < 0.5) {
    target.setHp(target.mhp * 0.5);
  }
});

Alternatively, you can probably do this with just events instead of actual codes, but I don't have enough time to write that out right now.
 
Last edited:

Lark_Larkington

Villager
Member
Joined
Mar 2, 2021
Messages
7
Reaction score
2
First Language
Dutch
Primarily Uses
RMMV
Should this affect the entire group or just specific actors?
Should this affect dead characters aswell?

Thanks! I want certain characters to be unaffected, though, so I want the script to target a specific actor. I figured I'd repeat the script a few times for all actors that I want to be affected.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
947
Reaction score
497
First Language
English
Primarily Uses
RMMV
There's a more efficient way to do this with Javascript and a plugin, but you don't need to - you can do it with just event commands.

Control Variable variableOne Set to Game Data Actor 1 HP
Control Variable variableTwo Set to Game Data Actor 1 Max HP
Control Variable variableTwo Div 2
Conditional Branch variableOne < variableTwo
- do your healing stuff

Then repeat for each party member. This presumes you know which actors are in your party, if you have a system where you'll be swapping out different actors, you'll need to make the plugin (or a really over-convoluted event where you first check whether every possible actor is in your party).
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,551
Reaction score
8,159
First Language
German
Primarily Uses
RMMV
I don't think I can get this done without coding,
you are wrong, it can be done with pure eventing.
However the fact that you don't know this is not unique, because the needed event options are a bit hidden.

go to control variable, set the lower section to game data (the one that defaults to Map ID) and then click on the dots to the right of "map id" to open the game data window.
In that window you can select hundreds of different game data options including the actor HP and actor MaxHP, then use conditional branch and mathematics to compare the numbers and decide whether to heal or not.

ninja'd
 

Lark_Larkington

Villager
Member
Joined
Mar 2, 2021
Messages
7
Reaction score
2
First Language
Dutch
Primarily Uses
RMMV
I got it done with variables and conditionals! Thanks guys. Looks like I can do a lot more than I thought without coding.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,054
Reaction score
2,318
First Language
English
Primarily Uses
RMMV
If you do want to use a script though (which will be useful for expanding which characters are affected, or removing some you realise shouldn't be any more) you can do

var actors = [1, 3, 5, 7];

$gameParty.aliveMembers().forEach(actor => (actors.contains(actor.actorId()) && actor.hpRate() < 0.5) ? actor.setHp(Math.ceil(actor.mhp * 0.5)) : actor);
 

Latest Threads

Latest Profile Posts

here's another RPG Maker remake idea: "Plumbers Don't Wear Ties". I'll salute to whomever does this
I won't finish it today, I only will have time to work on that next Saturday, what a shame... :(
I made something for @LittenDev [as he requested]
It's been a weird while. I've been so torn down that even playing video games has been something I avoided. But I shouldn't forget two things. One, I love RPG Maker for a reason. Two, only way to eat an elephant is a bite at a time.

Forum statistics

Threads
111,388
Messages
1,060,737
Members
144,731
Latest member
ariOwl
Top