Variable HP Costs to Increase Skill effectiveness.

So, I got it to work:


Skill 1:

Spoiler
RoW1R25.png



Skill Notetag:




<setup action>
eval: $gameVariables.setValue(1,user)
eval: $gameVariables.setValue(2,target)
common event: 1
break action
</setup action>


1: store user in variable 1


2: store target in variable 2


3: call common event1


4: stop action execution



Common Event:

Spoiler



Script call:




var user = $gameVariables.value(1);
var target = $gameVariables.value(2);
user.forceAction(21, $gameTroop.members().indexOf(target));
BattleManager.forceAction(user);


21 is the ID of Skill2 in my game.


Input is the name of variable 3.



Skill2:

Spoiler
WUfrFC1.png



3 is the variable id in which we stored the number.



Result:

Spoiler
Input:


dQ1cXPq.png



Dmg + Cost:


vVhOAUI.png



9 hp is appropriately withdrawn from casting actor, and 9 damage is dealt to the appropriate target. Succes!



This example requires: Yanfly Core engine, Yanfly Battle Engine Core, Action sequence Pack 1, Yanfly skill core.


All script calls used in this screenshot can be found in the "RMMV script call equivalent of event commands" google doc I linked to earlier.

Edit;

Alright, so it works like a charm! I'm playing with the formula right now, to see if I get a damage conversion value based on the amount spent, instead of it being a 1 for 1 conversion. Thanks a lot for your help so far.


Still need to figure out something for debuffs and armor breaks, but I think I can wing it. Thank you to all of you!
So, I liked that idea and I was toying with it but wasn't satified with my solution using 2 skills, a common event and multiple variables.


Here is a solution that requires only one skill, one variable, no common event and doesn't require yanfly's skill core to boot:

Spoiler
DuWN0Xp.png



Notetag:



<setup action>
eval: $gameMessage.setBackground(1)
eval: $gameMessage.setPositionType(1)
eval: $gameMessage.add("How much HP do you want to spend?")
eval: $gameMessage.setNumberInput(3, 1);
if $gameVariables.value(3) >= user.hp
break action
else
HP -VARIABLE 3: user, show
end
</setup action>


This will display a message, ask for player input, and, if the player has enough hp, go through with the spell, and abort if he doesn't.



The downside is that because it doesn't go through a common event it's much less intuitive for a game developper unfamiliar with action sequences and javacript, both to use and to modify.
So, I liked that idea and I was toying with it but wasn't satified with my solution using 2 skills, a common event and multiple variables.


Here is a solution that requires only one skill, one variable, no common event and doesn't require yanfly's skill core to boot:

Spoiler
DuWN0Xp.png



Notetag:




<setup action>
eval: $gameMessage.setBackground(1)
eval: $gameMessage.setPositionType(1)
eval: $gameMessage.add("How much HP do you want to spend?")
eval: $gameMessage.setNumberInput(3, 1);
if $gameVariables.value(3) >= user.hp
break action
else
HP -VARIABLE 3: user, show
end
</setup action>


This will display a message, ask for player input, and, if the player has enough hp, go through with the spell, and abort if he doesn't.



The downside is that because it doesn't go through a common event it's much less intuitive for a game developper unfamiliar with action sequences and javacript, both to use and to modify.

So by what you're saying, if I wanted something that was easier to tether to action sequences, I'd use the old style, but if I wanted to optimize my skill/menu useage, I'd use this style?
If your game is massive, the number of skills and common events could be a limiting factor.


Having a self contained skill is also less error prone, and is easier to copy paste should you need several skills based on this one.


Lowering plugin requirements is also better in terms of possible incompatibilities.


On the other hand, having a common event called allows you to use the event commands to make your skill effects and calcultations for more advanced skills.


Action sequences allow you to do the same, but require a specific syntax to be learnt or straight up to know javascript.


You could probably do an hybrid of the two possibilites too, calling a common event to do the display and calculations but keeping it contained to a single skill.


Use whatever you're most comfortable with is my advice. I'm just providing another way to do such a skill.
If your game is massive, the number of skills and common events could be a limiting factor.


Having a self contained skill is also less error prone, and is easier to copy paste should you need several skills based on this one.


Lowering plugin requirements is also better in terms of possible incompatibilities.


On the other hand, having a common event called allows you to use the event commands to make your skill effects and calcultations for more advanced skills.


Action sequences allow you to do the same, but require a specific syntax to be learnt or straight up to know javascript.


You could probably do an hybrid of the two possibilites too, calling a common event to do the display and calculations but keeping it contained to a single skill.


Use whatever you're most comfortable with is my advice. I'm just providing another way to do such a skill.

Alright, I'll keep all this in mind. Thanks again man.

Original thread: https://forums.rpgmakerweb.com/threads/variable-hp-costs-to-increase-skill-effectiveness.72859/