RMMV Winning a battle on either full or empty enemy HP bar

in_viv0

Warper
Member
Joined
Sep 23, 2022
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
I’m after two things

  • The enemy HP to start at whatever % I set it to, e.g. 50%
  • A win condition to be met at either enemy HP = 0% OR 100%, with different consequences for going either way. Both conditions should award xp and items. The different consequences atm would be increasing/decreasing the actor’s reputation/charisma depending on which way the fight ends. This would be like having a choice of killing the enemy or healing it to win the battle.
Implementation for #1: changing enemy HP in the troops database on turn zero. Okay for now. But atm the default battle system shows the bar decrease from 100 to what I set it to, I will probably want to change this later so this doesn’t happen.

Implementation for #2: I have been trying to make a duplicate of the knockout state, that is automatically added at 100% health rather than 0%.

Current solution for #2:

Enemies are given a skill which activates at 100% percent health. This skill applies the knockout state and a common event is applied to increase a reputation variable. This is clunky, because it takes one extra turn for the knockout state to be applied. Even if the player then reduces the HP back down in that turn, it still counts as a win, which doesn’t make sense.

I’ve also tried following this alternate victory guide (https://forums.rpgmakerweb.com/index.php?threads/alternate-victory-system.68577/), but this has the same problem of the extra turn, unless I am doing something wrong.



Other things I’ve tried that haven’t worked:

The Passive States plugin. Link: http://www.yanfly.moe/wiki/Auto_Passive_States_(YEP) This allows states to be added at certain conditions, and then giving the state to each enemy.

I can’t seem to make a second knockout state that is applied at >99% or 100% health (state is applied but it doesn’t knock the enemy out), or make it so can add a 100% health condition in the KO state, then give the knockout state to the enemy (instant knockout happens).

These are the notes I’ve tried for the states. I’ve tried applying the states globally in the plug in manager or to each individual enemy. I think it’s because I can’t make a new state that behaves exactly like knockout.

Edit: In other words, I can get a passive state to apply when the enemy's HP is full, but the state doesn't do anything. Makes sense as the battle probably only ends when state 1 (KO) has been applied to all enemies, rather than my own state?

<Passive Condition: HP Above 99%>
m.addState(1)


OR


<Custom Passive Condition>
if (user.hp == 100) {
condition = true;
}
</Custom Passive Condition>


Plugin writing hints appreciated
I am a javascript beginner, and I'm just learning how to write plugins. Hints to the location of the original functions around the knockout state and win conditions are also appreciated.


Thanks for reading.
 
Last edited:

eomereolsson

Veteran
Veteran
Joined
Sep 29, 2021
Messages
543
Reaction score
462
First Language
German
Primarily Uses
RMMV
<Passive Condition: HP Above 99%>
m.addState(1)
This will make it so that if a battler has the state where you put this in the notebox anyways as a passive state, they need their hp above 99% in addition for the state to actually be active. If they don't have the state already, it will do nothing.
In addition, the m.addState(1) will not be evaluated since it is not inside any notetag of any plugin. The notefield itself does nothing. Only if a plugin uses its content does code inside it get executed. Even if it were to be executed, I believe it would just produce an error that m is undefined.

<Custom Passive Condition>
if (user.hp == 100) {
condition = true;
}
</Custom Passive Condition>
This has the same pitfall as above: a battler that already has this state as a passive will need to fulfill this condition in addition for the state to become added. It will not automatically add the state to any battler fulfilling the condition.
The condition can be shortened to the following while retaining the same meaning:
JavaScript:
condition = (user.hp == 100);
Finally this condition is only equivalent to "user is at 100% hp" if the actual max hp of that user are in fact 100. The hp property contains the actual current number of hp of that battler. To actually check for wether the hp are at 100% you can use the following:
JavaScript:
condition = (user.hpRate() == 1);
 

in_viv0

Warper
Member
Joined
Sep 23, 2022
Messages
2
Reaction score
1
First Language
English
Primarily Uses
RMMV
Thanks for your help!

JavaScript:
<Passive Condition: HP Above 99%>
m.addState(1)

You're right, m.addState(1) threw an error*, and it should have been a.addState(1) anyway.
Anyway <Passive Condition: HP Above 99%> seems to do the same thing as condition = (user.hpRate() == 1); but that just applies my new state. Lets call it state 17 for clarity.

The problem is I can't make state 17 KO the enemy(even if I duplicated state 1 to create state 17). So, I am trying to make state 17 also immediately apply the KO state 1 but haven't managed. Correctly adding 'a.addState(1)' to state 17 within the tags results on immediate KO as soon as the battle starts. (The only tag on the enemy is <Passive State: 17>).

Next, I've tried to put 'a.addState(1)' into the if statement of state 17 (to also add the KO state along with my state when enemy HP is full), but that also results in insta KO. removing 'a.addState(1)' from it makes the if statement work as intended without knocking out, state 17 applies at full health, but that's the same as <Passive Condition: HP Above 99%> anyway.

JavaScript:
  <Custom Passive Condition>
  if condition = (user.hp == 1); {
    condition = true;
    a.addState(1);
  } else {
    condition = false;
  }
  </Custom Passive Condition>


Edit: I'm not sure if this would work as I don't understand how notetags work beyond what's in the wiki description for the plugin.

*I found I broke the passive states plug in somehwere along the way so nothing related to it was working anyway and didn't get the error. Now fixed.
 
Last edited:

Latest Threads

Latest Profile Posts

The real "fun" is about to begin.
image.png

Uh, how do I render the glass effect again?
Today I will find ouf if I can make homemade reese's peanut butter dipped pretzels :3
I'm thinking about studying Latin.
Playing with more game sound effects and fake sound attenuation in 30 minutes or so. Definitely a lot of game dev this week.

Funny how 90% of my usual struggles vanished when I used Frontview battle xD

Forum statistics

Threads
129,827
Messages
1,205,552
Members
170,954
Latest member
Carum
Top