Damage Formula for state(s)

hello i am a newbie, i'd like to ask if there is anybody who knows how to give formula towards a state that damage HP/MP. and if possible how to create "Chance" in the state

i am still on my first trial in the game and just finish watching tutorial. i was thinking that i'd like to create an "Electrocute" state when the state gives chance towards the bearer to get a damage and the bearer's turn are skipped. even if its boss. state's effect activate from the start until the state ends, i'd like the state to give "chance" towards the bearer to get the effect while the state is active.

for example lets say Monster A get the Electrocute state on turn 1, electrocute state last for 5 turns. turn 2 and turn 3 it may not get electrocuted however turn 4 it may get electrocuted and it's turn is skipped. also as the title mention, i want the electrocution's damage is not by "HP regeneration -%" but rather by formula damage.

I'd like to ask if anybody here who are obviously more senior than me knows a way to do it or any plugin that can do both or any of those. i was also thinking of creating a buff like "increase critical hit by #% and small chance of inflicting Death" which still needs the "Chance" in a state.

This is a remake of the post in game and mechanics design which got modded probably due to wrong sections. not sure where to post the thread tbh as i am seriously still new and i thought the question first game mechanic design. at least @Silverskingives me a really valuable answer which i can't thank him/her because the post got modded, still wondering if there are other answer
and if possible tell me which section should i post this to

thanks in advance for anybody whose willing to answer.
As mentioned in the last topic, Yanfly's Buff&States Core... and for all those effects, you'll have to use Lunatic Mode too...
yeah i download it already, was about to ask silverskin if the plugins answers the thread's question. before anybody misunderstand, i think the plugins really useful and i am happy someone told me this, but i am still wondering if my question has been answered or not. is it possible to input damage formula with that plugins?

once again thanks though
Possible? Yes.


Give me a sec to make you an example one.
Hey, if you decided to use Yanflys Plugin, I can give you the codes


// Gets Electrocute stat at turn #1

<Custom Apply Effect>


this._turns = 0; //See step 3


var dmg = (origin.mat * 3 - target.def * 2 + 25); //Origin means the one that inflicted the state to the other, target means the one having the state, you can use all damage formula elements, just convert a to origin and b to target


dmg = Math.floor(dmg); //You need to round the damage to an integer (1, 2, 32421, etc.), no fractions


target.gainHp(-dmg); //Caps-sensitive command!


target.startDamagePopup();


</Custom Apply Effect>

// Turn-specific damage

<Custom Turn End Effect> //You can also change End to Start


if (this._turns == 4) {


var dmg = (origin.mat * 3 - target.def * 2 + 25);


dmg = Math.floor(dmg);


target.gainHp(-dmg); 


target.startDamagePopup(); //See above


}


</Custom Turn End Effect>

//For the stun effect at turn 4

<Custom Action Start Effect>


this._turns += 1;


var chance = 0.33; //If you dont want your state to stun every time (it may be conscidered boring or broken)


if (Math.random() < chance && this._turns == 4) {


user.startAnimation(123); //Replace 123 with animation id or delete line if wanted


if (user.currentAction()) {


user.useItem(user.currentAction().item()); //Clear the action pool of inflicted target


this._stateTurns[stateId]--;


}


user.clearActions();


BattleManager.actionWaitForAnimation();


}



This code should work as I am using a similar state in my game Point Zero. Hope I could help you mate 🙂

Original thread: https://forums.rpgmakerweb.com/threads/damage-formula-for-state-s.68932/