Tip and trick : second chance, need a tweak!

Chaos17

Dreamer
Veteran
Joined
Mar 13, 2012
Messages
1,311
Reaction score
485
First Language
French
Hi,


I would like a tweak to Yanfly tip a trick : second chance.


I would like the code check if the target is under 30% HP, it will heal him 10% of his HP.


I understand where to change the part but I don't know the code to calculate that in %.

Code:
<Custom React Effect>
// Check to see if the party is in battle.
if ($gameParty.inBattle()) {
  // Sets the flag if the target has more than 1 HP at the time of death.
  target._secondChance = target.hp > 1;
}
</Custom React Effect>

<Custom Respond Effect>
// Check to see if the party is in battle, has the Second Chance flag, and if the target is dead with 0 HP.
if ($gameParty.inBattle() && target._secondChance && target.hp <= 0) {
  // Play the revival animation.
  target.startAnimation(49);
  // Set the target's HP to 1.
  target.setHp(1);
}
</Custom Respond Effect>
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
For the "below 30%" check, try


target._secondChance = target.hp < target.mhp * 0.3 && target.hp > 1;


This should ensure that the target passes the check if it is below 30% health but not dead.


For the healing, do you want to set the target's hp to 10% of its max hp


target.setHp(target.mhp * 0.10);


or adding 10% on top of its current hp?

Code:
target.gainHp(target.mhp * 0.10);
 
Last edited by a moderator:

Chaos17

Dreamer
Veteran
Joined
Mar 13, 2012
Messages
1,311
Reaction score
485
First Language
French
Thank you very much.


The first line didn't worked but I was able to find the formula for it.


The second line you suggested did actualy worked.


:)
 

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
Thank you very much.


The first line didn't worked but I was able to find the formula for it.


The second line you suggested did actualy worked.


:)


I saw a typo in my formulas for the 10% hp.


It should be target.mhp * 0.10 and not target.mhp * 10
 
Last edited by a moderator:

Yoshifull

Veteran
Veteran
Joined
Oct 31, 2015
Messages
49
Reaction score
4
First Language
French
Primarily Uses
While we are at it, I'd like my tweak on the Second Chance state...


I want my version to work no matter the HP the actor had before the fatal blow. It heals more than one HP, but will only work once.


I tried to do this, but it returns that "ressurect is not defined"

Code:
<Custom Battle Effect>
var ressurect = 1;
</Custom Battle Effect>

<Custom Respond Effect>
// Check to see if the party is in battle, has not died once, and if the target is dead with 0 HP.
if ($gameParty.inBattle() && resurrect <=  && target.hp <= ) {
  // Play the revival animation.
  target.startAnimation(49);
  // Set the target's HP to half full.
  target.setHp(target.mhp / 2);
  // Set ressurect to 0, to prevent another reraise.
  ressurect = ;
}
</Custom Respond Effect>
 
Last edited by a moderator:

kiriseo

Veteran
Veteran
Joined
Oct 27, 2015
Messages
245
Reaction score
82
First Language
German
While we are at it, I'd like my tweak on the Second Chance state...


I want my version to work no matter the HP the actor had before the fatal blow. It heals more than one HP, but will only work once.


I tried to do this, but it returns that "ressurect is not defined"


I looked up the info about the Custom Battle Effect.


This occures at the start of a battle only if the character already has the passive state with that tag at that time.


That's why you get that error.


I haven't tested it, but you could try the following:


Give all actors an auto-passive state which only contains this notetag


<Custom Battle Effect>
target._ressurect = 1;
</Custom Battle Effect>




And then try it with this notetage inside your Second Chance state:

Code:
<Custom Respond Effect>
if ($gameParty.inBattle()) {
  if(target._ressurect > 0 && target.hp <= 0 ) {
    target.startAnimation(49);
    target.setHp(target.mhp/2);
    target._ressurect = 0;
  }
}
</Custom Respond Effect>
 
Last edited by a moderator:

Yoshifull

Veteran
Veteran
Joined
Oct 31, 2015
Messages
49
Reaction score
4
First Language
French
Primarily Uses
I looked up the info about the Custom Battle Effect.


This occures at the start of a battle only if the character already has the passive state with that tag at that time.


That's why you get that error.


I haven't tested it, but you could try the following:


Give all actors an auto-passive state which only contains this notetag



<Custom Battle Effect>
target._ressurect = 1;
</Custom Battle Effect>




And then try it with this notetage inside your Second Chance state:

Code:
<Custom Respond Effect>
if ($gameParty.inBattle()) {
  if(target._ressurect > 0 && target.hp <= 0 ) {
    target.startAnimation(49);
    target.setHp(target.mhp/2);
    target._ressurect = ;
  }
}
</Custom Respond Effect>
That worked! Thanks a lot!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,476
Members
137,824
Latest member
dobratemporal
Top