DecoyJackal

Villager
Member
Joined
Jun 24, 2020
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm making a magic attack right now called "Cast" where it has a chance to...
  • 10% to backfire on the user. (User takes decreased damage from their attack instead.)
  • 20% to fail. (It does nothing.)
  • 60% to succeed and hit its target.
  • 10% to still and deal bonus damage to its target.
Referencing some of the code from this post, I've created my own chance-based system by defining a variable and accessing it later on the action, but it doesn't work... for whatever reason. Whenever I try to start a battle with a enemy with the skill, it imminently crashes with the message saying about: "cannot read property 'height' of undefined".

Code:
<setup action>
display action
eval: $gameVariables.setValue(11, Math.random())
</setup action>

<target action>
action animation
wait for animation
if $gameVariables.value(11) <  0.1
   eval: BattleManager.addText("...but it backfires.", 0)
else if ($gameVariables.value(11) >=  0.1 && $gameVariables.value(11) <  0.3)
   SE: Buzzer1
   eval: BattleManager.addText("...but nothing happens.", 0)
else if ($gameVariables.value(11) >=  0.3 && $gameVariables.value(11) <  0.9)
   action effect: target
   eval: BattleManager.addText("...and fires a magical beam!", 0)
else if $gameVariables.value(11) >=  0.9
   eval: BattleManager.addText("crit.", 0)
end
</target action>

<finish action>
wait: 60
clear battle log
</finish action>

Mind you, the code is very bare bones right now, it's just for reference.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,930
Reaction score
3,130
First Language
English
Primarily Uses
RMMV
Undefined means you're trying to use something that doesn't exist. In this case, it's your repeated use of BattleManager.addText() - I don't know where you saw that, but it isn't a member function of the BattleManager.

Try SceneManager._scene._logWindow.addText()

You'll need to also use SceneManager._scene._logWindow.clear(); to get rid of the text later.

As a quick coding tip, you can get rid of half of your conditional statements.
Code:
if $gameVariables.value(11) <  0.1
...
else if ($gameVariables.value(11) >=  0.1
^^ This is meaningless, the code wouldn't look at this line unless it failed the first if statement, so it must already be >= 0.1. So you can simply do if <0.1, else if <0.3, etc...and then the last one should simply be "else," there's no point or reason to put an "else if" condition there.
 

DecoyJackal

Villager
Member
Joined
Jun 24, 2020
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
Undefined means you're trying to use something that doesn't exist. In this case, it's your repeated use of BattleManager.addText() - I don't know where you saw that, but it isn't a member function of the BattleManager.

Try SceneManager._scene._logWindow.addText()

You'll need to also use SceneManager._scene._logWindow.clear(); to get rid of the text later.

As a quick coding tip, you can get rid of half of your conditional statements.
Code:
if $gameVariables.value(11) <  0.1
...
else if ($gameVariables.value(11) >=  0.1
^^ This is meaningless, the code wouldn't look at this line unless it failed the first if statement, so it must already be >= 0.1. So you can simply do if <0.1, else if <0.3, etc...and then the last one should simply be "else," there's no point or reason to put an "else if" condition there.

Despite following all of your advice (also thank you for the coding tip), it throws me the error: "cannot read property 'height' of undefined", and I'm betting something with trying to set the variable.

This the new code for future reference:
Code:
<setup action>
display action
eval: $gameVariables.setValue(11, Math.random())
</setup action>

<target action>
action animation
wait for animation
if $gameVariables.value(11) <  0.1
   eval: SceneManager._scene._logWindow.addText("...but it backfires.")
else if $gameVariables.value(11) <  0.3
   SE: Buzzer1
   eval: SceneManager._scene._logWindow.addText("...but nothing happens.")
else if $gameVariables.value(11) <  0.9
   action effect: target
   eval: SceneManager._scene._logWindow.addText("...and fires a magical beam!")
else
   eval: SceneManager._scene._logWindow.addText("crits.")
end
</target action>

<finish action>
wait: 60
eval: SceneManager._scene._logWindow.clear()
</finish action>

Also just in case if you or anyone else asks for what plugins I'm using, I'm leaving a list right now.
  • YEP_CoreEngine
  • YEP_BattleEngineCore
  • YEP_BattleAICore
  • YEP_TargetCore
  • YEP_X_SelectionControl
  • YEP_SkillCore
  • YEP_DamageCore
  • YEP_BuffStatesCore
  • MOG_BattlerMotion
  • YEP_X_ActSeqPack 1 to 3
  • YEP_ItemCore
  • YEP_EquipCore
  • YEP_ShopMenuCore
(For as the battlemanager.addtext() thing, I saw Yanfly doing it multiple times before and I've used a few times and they worked for me.)
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,930
Reaction score
3,130
First Language
English
Primarily Uses
RMMV
Huh, it might be something Yanfly added into the core for general use...I only know it's not listed when I look at the MV code library (and I didn't find any references when I Googled it).

So you're not referencing much else that could be not existing. You call the action animation - do you have an animation defined in the skill window? Double check that the animation still exists in your list and hasn't been deleted or something. The setValue function wouldn't be trying to look at anything called "height" of the variable, so I don't see how it could be that.

Can you hit F8, go to the Console, and paste a screenshot of the full error stack?

Edit: I just pasted it into the online Action Sequence Editor, and it ran without a hitch. So there's something specific to your end, not anything in the code that's causing the problem. Check that you have an animation defined, check that your plugins are in the order listed on Yanfly's site. Post screenshots of the error stack and your skill page.
 

DecoyJackal

Villager
Member
Joined
Jun 24, 2020
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
So here what I've done so far, I rearranged the plugins, there's a animation already defined, and nothing has really changed about the error. So... I'm dumping the full error log here.

YEP_CoreEngine.js:1098 TypeError: Cannot read property 'height' of undefined
at Sprite_Enemy.updateFrame (rpg_sprites.js:981)
at Sprite_Enemy.Sprite_Battler.updateMain (rpg_sprites.js:512)
at Sprite_Enemy.Sprite_Battler.update (rpg_sprites.js:493)
at Sprite_Enemy.Sprite_Battler.update (YEP_BattleEngineCore.js:2900)
at Sprite_Enemy.Sprite_Battler.update (YEP_X_ActSeqPack2.js:1197)
at Sprite_Enemy.Sprite_Battler.update (MOG_BattlerMotion.js:1804)
at Sprite_Enemy.update (rpg_sprites.js:952)
at Sprite_Enemy.update (YEP_BattleEngineCore.js:3223)
at rpg_core.js:4068
at Array.forEach (<anonymous>)
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,930
Reaction score
3,130
First Language
English
Primarily Uses
RMMV
1 - try disabling the MOG Battler Motion and see if anything changes.

2 - try disabling all of your plugins except Yanfly's Battle Engine Core and the Action Sequences. If that doesn't work, there's something wrong with your skill setup or a database entry.

2a - if that does work, enable your plugins one at a time until you get the error.

To post a screenshot of your skill, open the skill in your database and press the Print Screen (prt scr) button on your keyboard. Open up Windows Paint (or any image editor) and Ctrl+V to paste the image in. Save it, and upload it here using Attach Files on the bottom.
 

DecoyJackal

Villager
Member
Joined
Jun 24, 2020
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I've already tried disabling MOG_BattlerMotion in advance and nothing changed. So I followed your suggestion and tried disabling all of my plugins except for the necessary ones, still nothing changed. So now I'm dropping the screenshot of my skill now.
 

Attachments

  • a.PNG
    a.PNG
    124.4 KB · Views: 1

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,930
Reaction score
3,130
First Language
English
Primarily Uses
RMMV
This wouldn't be causing this specific problem, but you shouldn't have Scope: Always on a skill that requires an enemy target. It doesn't make sense for that to be showing up in the menu as an option to cast outside of battle.

So can you provide a new screenshot of the error stack? If you disabled all of the other plugins, that must be different because it won't have lines referencing the Battler Motion plugin.

If you're having the problem with all of those other plugins disabled, it has to be something wrong in your database. The game is trying to look at an animation or sprite or something that isn't actually there.

Are you always testing against the same troop? Try going to a different map with different enemies. For that matter, is it happening in the actual game, that you're starting a New Game after you make your changes, or are you trying to do it in a Battle Test from the Troop screen? That works unreliably when you have plugins or variables involved.
 

DecoyJackal

Villager
Member
Joined
Jun 24, 2020
Messages
11
Reaction score
0
First Language
English
Primarily Uses
RMMV
I always play though the actual game, and whenever something breaks, I start a new save. So I tried everything you said: trying it in a new map, putting on another enemy, putting in new troop, and somehow it fixed itself. I discovered that the troop I was using has a blank enemy, and it somehow broke my entire game. I know this because another enemy popped up in it when I was creating a new one to test out. And my skill doesn't even work, but the fix is pretty simple as I have to multiply the random() by a 100.

So I uhh... apologize for spending your time with my dumb problem, and thank you for staying all the way though this.
 

Latest Threads

Forum statistics

Threads
124,331
Messages
1,162,836
Members
163,132
Latest member
Muzel007
Top