"Hedge Risk" variation (Bravely Default) [SOLVED]

Hi everyone,
I'm here again asking for help to implement an idea.
The original power was something like "Hedge Risk" from Bravely Default:
Effects: The damage taken is halved for five turns. However, when you do take damage under this effect, you lose pg equal to the damage taken (or prevented - since it's halved, it goes both ways).

I thought using a state that last for five turns, but it should "react" to the damage, maybe add it to a variable and subtract to the party gold. I'm not sure about the "reacting" part, so I thought changing the power:
A power that heals half of the damage suffered for an ally [(b.mhp-b.hp)/2] and with that cost for gold.

Formula:
Code:
v[1]=(b.mhp-b.hp)/2; v[1]

Notetags (using VS Core Battle) [to show a message]:
Code:
<JS Post-Apply>
$gameParty.loseGold($gameVariables(1));
$gameMessage.setPositionType(1);
$gameMessage.setBackground(1);
$gameMessage.add("<Center>Ganaste /V[1]/G.")
</JS Post-Apply>

But it's not working. It heals half the damage but doesn't lose the gold or show the message.

Can you see why?
Do you have any idea to create something more similar to the original concept of the power?

Thank you in advance.
Hi, I think you have to use $gameVariables.value(1), as for showing a message, I'm not sure but you could use $gameTemp.reserveCommonEvent(index) to call a common event and have the message show from there?
Hi, I think you have to use $gameVariables.value(1), as for showing a message, I'm not sure but you could use $gameTemp.reserveCommonEvent(index) to call a common event and have the message show from there?
Yeah! That works.
Code:
<Custom Cost Text>
\FS[20]\C[17]Daño curado \G.
</Custom Cost Text>
<JS Post-Apply>
$gameParty.loseGold($gameVariables.value(1));
$gameMessage.setPositionType(1);
$gameMessage.setBackground(1);
$gameTemp.reserveCommonEvent(3)
</JS Post-Apply>

The only problem is that the skill can heal more than what it can pay. Any idea of how to check the quantity of gold before the healing?
Code:
<Custom Cost Text>
\FS[20]\C[17]Daño curado \G.
</Custom Cost Text>
<JS Post-Apply>
if ($gameVariables.value(1) >= $gameParty.gold()) {
         $gameVariables.setValue(1, $gameParty.gold());
};
$gameParty.loseGold($gameVariables.value(1));
$gameMessage.setPositionType(1);
$gameMessage.setBackground(1);
$gameTemp.reserveCommonEvent(3);
</JS Post-Apply>

This should set the value of healing equal to the amount of gold held if it exceeds gold on hand.

Maybe try <JS Pre-Apply> or <JS Pre-Damage> to check before healling is applied?

Something like this...

Code:
<Custom Cost Text>
\FS[20]\C[17]Daño curado \G.
</Custom Cost Text>
<JS Pre-Damage>
if ($gameVariables.value(1) >= $gameParty.gold()) {
         $gameVariables.setValue(1, $gameParty.gold());
};
</JS Pre-Damage>

<JS Post-Apply>
$gameParty.loseGold($gameVariables.value(1));
$gameMessage.setPositionType(1);
$gameMessage.setBackground(1);
$gameTemp.reserveCommonEvent(3);
</JS Post-Apply>
Hi Lostboy,
I tried the Pre-Damage but I needed to configure the damage in the pre-damage and I'm not as good as this.

My final solution has been:
Formula:
Code:
$gameParty.gold()>=(b.mhp-b.hp)/2?v[1]=(b.mhp-b.hp)/2:v[1]=$gameParty.gold(); v[1]

Notetags:
Code:
<Custom Cost Text>
\FS[20]\C[17]Daño curado \G.
</Custom Cost Text>


<JS Post-Apply>
$gameParty.loseGold($gameVariables.value(1));
$gameTemp.reserveCommonEvent(3);
</JS Post-Apply>

Common Event (Now it checks if you still have money, if doesn't it alerts you about it):
1602594909708.png


Maybe this is not the cleanest solution, but it works. Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/hedge-risk-variation-bravely-default-solved.128447/