- Joined
- Apr 2, 2015
- Messages
- 145
- Reaction score
- 52
- First Language
- English
- Primarily Uses
- RMMV
Hey guys, I have something that seems fairly simple but I can't quite figure out how to get it to work right. Basically as the title says, I want to be able to add chance to cause a stun state, to targets when they are hit with an attack element they are weak against.
I've searched the forums and found this awesome plugin code that Tsukihime came up with about a year ago. But it's giving me trouble. Mainly for some reason, instead of waiting to be hit from an elemental attack, if an actor has a skill that does extra damage to an enemy, the enemy will just automatically become stunned at the beginning of the encounter.
So currently it has a 35% chance to inflicting the state at the start of the battle. Interesting enough, if the target doesn't receive the stun state at the beginning, the code works as intended! Anyone have some insight on how to edit this code to make it wait for a hit? Or is there an even better way to go about it?
I've searched the forums and found this awesome plugin code that Tsukihime came up with about a year ago. But it's giving me trouble. Mainly for some reason, instead of waiting to be hit from an elemental attack, if an actor has a skill that does extra damage to an enemy, the enemy will just automatically become stunned at the beginning of the encounter.
So currently it has a 35% chance to inflicting the state at the start of the battle. Interesting enough, if the target doesn't receive the stun state at the beginning, the code works as intended! Anyone have some insight on how to edit this code to make it wait for a hit? Or is there an even better way to go about it?
Code:
(function() {
var TH_GameAction_calcElementRate = Game_Action.prototype.calcElementRate;
Game_Action.prototype.calcElementRate = function(target) {
var rate = TH_GameAction_calcElementRate.call(this, target);
if (rate > 1) {
// random number between 0 and 1
if (Math.random() < 0.35) {
target.addState( 13 )
}
}
return rate;
};
})();

