Hi there,
I'm relatively new to rpg maker, mostly still exploring the program's capabilities. I'm looking for some help figuring out how to have a custom formula that activates once per action instead of once per hit.
Short Version:
I'd like to use the note box to add a custom formula that activates either at the start or end of the action, instead of putting the formula in the damage box so that it activates once each hit.
The Very Long Version:
I'm creating a sample scifi game and wanted to have a gun that would sometimes apply a recoil state.
In the damage formula box I added the following after the damage formula (where state 28 is my recoil state)
;if rand <= 0.8 ; a.add_state(28); else; ; end
This makes it so there's an 80% chance the attacker is inflicted with the recoil state.It works exactly as intended with two exceptions.
1) Skills that hits multiple targets. Instead of having an 80% chance of recoil, the state almost always occurs because the code executes every hit!!!
2) If the attack misses the code never executes.
I managed to solve #1 but I'm still stumped for #2.
To resolve #1 I created another new state to behave as an action switch. The thought process was the state would get added on the first hit and last until the end of the action. I then nested the if statement to first check if the actor had this new state before executing the recoil code.
So first hit, the state would not be present and the custom formula would execute.
Second+ hits, the state would be present and the custom formula would not execute.
At the end of the action, the state would disappear so everything is reset for next time.
I managed to get this working after reading Fomar0153's custom formulae tutorial. I even made the percentage a variable
class Game_Battler < Game_BattlerBase
def recoil(a,b,prob_perc)
if a.state?(32); ; else; a.add_state(32); if rand <= prob_perc ; a.add_state(28); else; ; end; end
end
end
Where state 32 is a custom state that acts as a switch that gets reset at the end of the action and state 28 is my custom recoil state. So now I just add ";a.recoil(a,b,0.8)" to my damage formula and the code activates.
However, since I'm using the damage formula box this script only activates on a hit. Is there a way to make separate it from the damage completely? Ideally I want to use the note box rather than having to hardcode this into the script editor for every skill.
I'm relatively new to rpg maker, mostly still exploring the program's capabilities. I'm looking for some help figuring out how to have a custom formula that activates once per action instead of once per hit.
Short Version:
I'd like to use the note box to add a custom formula that activates either at the start or end of the action, instead of putting the formula in the damage box so that it activates once each hit.
The Very Long Version:
I'm creating a sample scifi game and wanted to have a gun that would sometimes apply a recoil state.
In the damage formula box I added the following after the damage formula (where state 28 is my recoil state)
;if rand <= 0.8 ; a.add_state(28); else; ; end
This makes it so there's an 80% chance the attacker is inflicted with the recoil state.It works exactly as intended with two exceptions.
1) Skills that hits multiple targets. Instead of having an 80% chance of recoil, the state almost always occurs because the code executes every hit!!!
2) If the attack misses the code never executes.
I managed to solve #1 but I'm still stumped for #2.
To resolve #1 I created another new state to behave as an action switch. The thought process was the state would get added on the first hit and last until the end of the action. I then nested the if statement to first check if the actor had this new state before executing the recoil code.
So first hit, the state would not be present and the custom formula would execute.
Second+ hits, the state would be present and the custom formula would not execute.
At the end of the action, the state would disappear so everything is reset for next time.
I managed to get this working after reading Fomar0153's custom formulae tutorial. I even made the percentage a variable
class Game_Battler < Game_BattlerBase
def recoil(a,b,prob_perc)
if a.state?(32); ; else; a.add_state(32); if rand <= prob_perc ; a.add_state(28); else; ; end; end
end
end
Where state 32 is a custom state that acts as a switch that gets reset at the end of the action and state 28 is my custom recoil state. So now I just add ";a.recoil(a,b,0.8)" to my damage formula and the code activates.
However, since I'm using the damage formula box this script only activates on a hit. Is there a way to make separate it from the damage completely? Ideally I want to use the note box rather than having to hardcode this into the script editor for every skill.