Adding a state to targets with elemental weaknesses?

KingKraken

Veteran
Veteran
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?

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;
};
})();
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
Instead of editing calcElementRate, why not use Buffs & States Core and Auto Passive States to give enemies a passive state which has a <custom respond effect> notetag which checks whether the action hit, and if so stuns the target if the random check succeeds?
 

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
145
Reaction score
52
First Language
English
Primarily Uses
RMMV
Instead of editing calcElementRate, why not use Buffs & States Core and Auto Passive States to give enemies a passive state which has a <custom respond effect> notetag which checks whether the action hit, and if so stuns the target if the random check succeeds?
That seems like it could be a good idea!

But would I be able to generalize with it? Say, make one state that checks for elemental weaknesses? Or would I have to make a custom state for each elemental weakness?

I'm no scripter, so my knowledge of what the game can and can't calculate is weak.
 

Zemtax

Secret Open World Game Dev
Veteran
Joined
Jul 17, 2014
Messages
42
Reaction score
22
First Language
German
Primarily Uses
RMMV
You can put any javascript code into the notetags using Yanflys Plugins, so you should be able to do almost anything. I'm not much of a scripter myself but I'd say look over Yanfly's Tips and Tricks videos, check the code on their site and use bits of their code to make your custom states :)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,604
Reaction score
1,959
First Language
English
Primarily Uses
RMMV
As Zemtax said, the limit is essentially your imagination and knowledge of Javascript. You can have one state that checks for element weakness based on the element of the attack that hit.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,990
Members
137,562
Latest member
tamedeathman
Top