So as the title of the post implies, I'm trying to recreate a system akin to FF's Blue Magic. I know Yanfly made a Tips and Tricks for how to do so for MV, which I've referenced when making this, but I wanted to see if I could adjust it to use common events instead of having to write out the code in every skill, mainly so that I can have the learn message be displayed in a Gab window so the flow of battle doesn't get interrupted.
To explain, my plan uses three variables, one holds the skill id, another holds the id of the actor who will be learning the skill (the blue mage) and the third holds the id of a state the actor can toggle for learning the skill (if the skill is present, the actor can learn the skill. if not, the skill isn't learned). The first variable (skill id) gets set in an action sequence for the skill, then the first common event triggers to check the requirements (if the actor is affected by the learn state and if the actor has already learned the skill). if both conditions are met, another common event is triggered that teaches the actor the skill and displays the gab message. At least, that's how I have it planned and hope it should work.
In the checking common event, I have two common events with scripted conditional branches:
When I go into a test battle with an enemy that knows the skill that triggers the blue magic event chain, they use the skill, but nothing happens after and I get the following error in the console:
TypeError: Cannot read property 'isStateAffected' of undefined
I also originally had the two conditional branch codes in one event instead of two separate, but I got a similar error with that configuration:
TypeError: Cannot read property 'isLearnedSkill' of undefined
I feel like I'm on the right track, but I have an issue when it comes to coding where I miss some very obvious mistakes in my code. If anyone could look over my code and let me know what I might have done wrong, I'd really appreciate it.
To explain, my plan uses three variables, one holds the skill id, another holds the id of the actor who will be learning the skill (the blue mage) and the third holds the id of a state the actor can toggle for learning the skill (if the skill is present, the actor can learn the skill. if not, the skill isn't learned). The first variable (skill id) gets set in an action sequence for the skill, then the first common event triggers to check the requirements (if the actor is affected by the learn state and if the actor has already learned the skill). if both conditions are met, another common event is triggered that teaches the actor the skill and displays the gab message. At least, that's how I have it planned and hope it should work.
In the checking common event, I have two common events with scripted conditional branches:
//this checks if the actor (variable 2) is affected by the learn state (variable 3)
$gameParty.members[$gameVariables.value(2)].isStateAffected($gameVariables.value(3))
//this checks if the actor (variable 2) has already learned the skill being used (variable 1)
!$gameParty.members[$gameVariables.value(2)].isLearnedSkill($gameVariables.value(1))
When I go into a test battle with an enemy that knows the skill that triggers the blue magic event chain, they use the skill, but nothing happens after and I get the following error in the console:
TypeError: Cannot read property 'isStateAffected' of undefined
I also originally had the two conditional branch codes in one event instead of two separate, but I got a similar error with that configuration:
TypeError: Cannot read property 'isLearnedSkill' of undefined
I feel like I'm on the right track, but I have an issue when it comes to coding where I miss some very obvious mistakes in my code. If anyone could look over my code and let me know what I might have done wrong, I'd really appreciate it.