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
488
Reaction score
696
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
943
Reaction score
495
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,545
Reaction score
8,155
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,053
Reaction score
2,313
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 Posts

Latest Profile Posts

After gathering, sorting out & reconsidering hundreds of enemy battlers over the last two das, finally my favorite part begins: Inventing names and lore for them all :D
I'm running a sale for Learn RPG Maker MV on Itch.io, can I compete with NSFW games earning goals?
Another Friday and another Zoom call that could have been an email. Working from home is awesome.
Finished with the semester; finally have some time to play around with MV :kaopride:
Started work on the fishing Mini-Game

Forum statistics

Threads
111,368
Messages
1,060,527
Members
144,696
Latest member
Asher491351
Top