JadeTheurgist

Villager
Member
Joined
Apr 19, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
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:

//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.
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
83
Reaction score
98
First Language
English
Primarily Uses
RMMZ
This is syntax error, but typeError has priority because the engine doesn't know what type gameParty is resolving to without the "()". Change the first part of your code to this:
JavaScript:
$gameParty.members()[$gameVariables.value(2)]
That's how you access the element of an array by its index when an array is the return value of a method.
 
Last edited:

JadeTheurgist

Villager
Member
Joined
Apr 19, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
Okay, so that fixed the errors popping up, but the system doesn't work as I hoped it would. I've taken screenshots of the common events that I've made.

BluSystem01.jpg
This first one is the action sequence for the skill to be learned. It's very basic: the main focus in the part at the bottom that adjust the variable and start the check common event

BluSystem02.jpg
This is the check event, the one where the coding issue from the first post originated. This event checks the actor designated by the variable to see if they are affected by the learn state, then if they already know the skill. The learn state is essentially an empty state: It's mainly there just for script check.

BluSystem03.jpg
This is the event that should play to teach the skill to the actor and display a Gab message during battle to let the player know the skill has been learned.

Any idea what might be going wrong?
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
83
Reaction score
98
First Language
English
Primarily Uses
RMMZ
If I'm reading that right, the index is out of range.

The variable(TempVar2) has the value of 4 and you're asking $gameParty.members() to return the party member on the 5th index position, except that it can't as arrays in JS are 0-based(the 4th position is 3). You want to change the value of variable(TempVar2) to 3.
 

JadeTheurgist

Villager
Member
Joined
Apr 19, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
I tried setting up the checking common event to cycle through the array of all party members, checking each one for the learn state, and it works now!

BluSystem_2.png

Granted, I do get a TypeError in the console when ever a blue magic skill is used:

TypeError: Cannot read property 'isStateAffected' of undefined

but it works as intended: the actor affected with the learn state learns the skill, won't learn it when not affected by the state, and the gab message displays!
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
83
Reaction score
98
First Language
English
Primarily Uses
RMMZ
I'm happy to hear that it works as intended. As for the TypeError in the console, it means that this(assuming the line in the core script is this.isStateAffected(x)) no longer has the actor object or that it was never there to begin with. So a state is not being checked as it should. You can chose to leave it as is, if it does appear that it's not causing functionality issues(or any in the future), but it if does, we can look at out to solve that.
 

JadeTheurgist

Villager
Member
Joined
Apr 19, 2020
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
I think it's good to leave it. the cause of the error isn't intrusive to the gameplay and everything is working as intended. Thank you for your help!
 

Latest Threads

Latest Profile Posts

One uncomfortable truth that has withstood the test of time, is how most people will stand by while they see a crime happening, unless it's illegal to stand by. We probably wouldn't have stories about "special heroes" or games about heroes if the "everyday common folk" were largely capable of being heroes. Heroes face dangers that most people are not willing to.
I'm having toooo much fun designing the new MP (Mental Psyche) system. I've only worked it out for enemies so far, but it's fun to stun them, then go after their MP and delete them instead to farm for better item drops.
anyone know of a place I can promote my game? sorta like game awards but for indie devs, like a place where I can drop a trailer and like stir up some hype
Doing RPG Maker News for 17th October 2021

That moment when you came up with a very good game title, but when you searched it, it has already been used... T.T

Forum statistics

Threads
115,882
Messages
1,093,688
Members
151,125
Latest member
krawm
Top