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
457
Reaction score
667
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
700
Reaction score
377
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,345
Reaction score
8,078
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
2,953
Reaction score
2,226
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

When you don't find any time to work... :kaocry:
First Ten Minutes of my Caretaker inspired game

Finally, I got a good Gmail message [from smg5urded]
"This game does look a bit plain, but, I'm sure this does not destroy the experience as a whole. Monsters fit your style of game-play, mapping looks crude but I'm sure you can make it better if you do a remake of Forgotten Eclipse"
Going to start a new project today. OMG, it will be on RPGMaker MV. :D
Paid material WIP~
EysZO9cVEAEWy9W

This is Alchemy pack.
I decided to add more witch elements.

Now we have wooden props, candles, pots, and potion bottles.
We also want to add herbs, kettles, fireplaces, etc.

Forum statistics

Threads
110,395
Messages
1,052,928
Members
143,447
Latest member
WarriorsFanatic
Top