Hello, I'm relatively unskilled in javascript and thus require some assistance!
Pretty much what I want to do is have skills "transform" in battle based on an external value, which I currently have as a gameVariable. Basically it's supposed to work like:
Battler uses Fire when the variable is a certain number > Another skill (for example; Earth) is cast instead.
At first I tried looking around for plugins similar to what I want to do in an effort to look at the code and try to incorporate it into my own plugin. I found Mr. Trivel's Different Skill Effects Depending on Target plugin and decided to copy some of the code for it. In the end, my code looks like this:
And this actually works! For example, Fire DOES turn into Earth in the sense that it deals Earth damage and the variable containing the "Field Effect" changes into the value of Earth's elementId. The only issue is that the animation that plays is still the one for Fire. This is where the crux of my problem is.
How do I make it so the skill has the correct animation? Do I need to put the code somewhere else, like Scene_Battle or BattleManager? Quite frankly, I'm stumped. Any help is appreciated!
Pretty much what I want to do is have skills "transform" in battle based on an external value, which I currently have as a gameVariable. Basically it's supposed to work like:
Battler uses Fire when the variable is a certain number > Another skill (for example; Earth) is cast instead.
At first I tried looking around for plugins similar to what I want to do in an effort to look at the code and try to incorporate it into my own plugin. I found Mr. Trivel's Different Skill Effects Depending on Target plugin and decided to copy some of the code for it. In the end, my code looks like this:
JavaScript:
_alias_gma_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target){
if (this.item().meta === 'undefined'){
} else {
this.fieldSkillChange(this.item());
}
_alias_gma_apply.call(this, target);
if (this.isSkill() && target.result().isHit()){
var gaf = this.item().damage.elementId;
$gameVariables.setValue(1, gaf);
}
if(this._tempItem){
this._item = this._tempItem;
this._tempItem = null;
}
}
Game_Action.prototype.fieldSkillChange = function(item){
var chn = parseInt(item.meta.change);
var chnto = parseInt(item.meta.change2);
if ($gameVariables.value(1) === chn){
this._tempItem = this._item;
this.setSkill(chnto);
}
}
And this actually works! For example, Fire DOES turn into Earth in the sense that it deals Earth damage and the variable containing the "Field Effect" changes into the value of Earth's elementId. The only issue is that the animation that plays is still the one for Fire. This is where the crux of my problem is.
How do I make it so the skill has the correct animation? Do I need to put the code somewhere else, like Scene_Battle or BattleManager? Quite frankly, I'm stumped. Any help is appreciated!