Hey all,
I'm running into a really weird bug of sorts.
I manually call the
gainSkillAP function on skill Use and whenn users are targeted by a skill that they are currently tracking.
So if this Actor Uses Ember or is targeted by Ember in battle:
Until the meter is maxed out and then the skill can be used without any Equipment.
The weird bug is this.
Say Actor B only has a max MP of 1 ("Pages" in this example)
If they use the skill in battle, they don't accrue the skills AP. But they still get the AP gain if they are targetted.
I am using my own function hooked into Game_Action.apply to give skillAp (see my attached version of the plugin Lines 151 -> 188) and below
///////////////////////////////////////////////
// Puppet Knight Add-in For Use and Targetted by skill
///////////////////////////////////////////////
// Function to check if an actor has a specific skill
function actorHasSkill(actor, skillId) {
return actor.skills().some(function(skill) {
return skill.id === skillId;
});
}
// Alias the Game_Action apply function to gain skill AP when an actor is targeted
const _Game_Action_prototype_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function(target) {
_Game_Action_prototype_apply.call(this, target);
// Call the custom function to gain skill AP
this.gainSkillAPOnTarget(target);
this.gainSkillAPOnUser();
};
// Function to gain skill AP on the target of skill
Game_Action.prototype.gainSkillAPOnTarget = function(target) {
const skill = this.item();
const ap = 1; // Adjust the AP value as needed
if (target.isActor() && skill && actorHasSkill(target, skill.id)) {
target.gainSkillAP(skill.id, ap);
}
};
// Function to gain skill AP on the user of skill
Game_Action.prototype.gainSkillAPOnUser = function() {
const user = this.subject(); // Get the user of the skill
const skill = this.item();
const ap = 1; // Adjust the AP value as needed
if (user.isActor() && skill && actorHasSkill(user, skill.id)) {
user.gainSkillAP(skill.id, ap);
}
};
///////////////////////////////////////////////
///////////////////////////////////////////////