Battle Log not Showing State change with addState Script

tas38

Warper
Member
Joined
Jun 8, 2021
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Hello, this is my first game and first post on this forum.
I am using this script to add states to enemies, from a common event
$gameTroop._enemies[n].addState(13)

This works for giving the enemies the state exactly as it should. However the battle log does not display the "If an enemy is afflicted with the state" message. If I add the state the more normal way with effects inside skills/items, then the message shows correctly. It is only when adding the state from a common event that the message doesn't work.

I see this message from the DevTools window. It looks like that is where the problem is, but I have no real idea what it means or how to fix it.
Script Call Error VisuMZ_0_CoreEngine.js:6907 TypeError: Cannot read property 'addState' of undefined at eval (eval at Game_Interpreter.command355 (rmmz_objects.js:11252), <anonymous>:2:24) at Game_Interpreter.command355 (rmmz_objects.js:11252) at Game_Interpreter.<computed>.<computed> [as command355] (VisuMZ_0_CoreEngine.js:6907) at Game_Interpreter.executeCommand (rmmz_objects.js:9621) at Game_Interpreter.update (rmmz_objects.js:9526) at Game_Troop.updateInterpreter (rmmz_objects.js:5848) at Function.BattleManager.updateEventMain (rmmz_managers.js:2379) at Function.BattleManager.updateEvent (rmmz_managers.js:2372) at Function.BattleManager.update (rmmz_managers.js:2335) at Scene_Battle.updateBattleProcess (rmmz_scenes.js:2977)

Disabling all plugins doesn't change anything.
I know how to add the messages manually with SceneManager._scene._logWindow.addText(text)
But that seems very messy and not ideal.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,898
Reaction score
14,995
First Language
English
Primarily Uses
RMMV
The error is saying you are trying to add a state to an enemy that doesn't exist. So there is something wrong with your script call.

"It is only when adding the state from a common event that the message doesn't work."

Is this really true? Or is it because you're trying to add the state via a script call? What if you use the Change Enemy State event command (3rd page)? How are you setting the value of n? If you got that command from the script call list, those are not meant to be simply copy/pasted - you have to ensure that n is either set to a value correctly, or replace n with a number.


Can you please show a screenshot of your common event so we can see exactly how you are calling it?
 

tas38

Warper
Member
Joined
Jun 8, 2021
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Sorry for the late reply

The error is because of the loop I'm using, so if there's less than 8 enemies It keeps trying to add the state to non-existent enemies. I understand that now, and I will fix it.
With 8 enemies I do NOT get the error message. So that isn't the issue.

This is the common event I am using. It really does work correctly in game. I also attached a screenshot of the game, so you can see the enemies have the stunned status symbol above their heads.

I tried removing the script section, and replacing it with Change Enemy State event command (3rd page). This gives the same result, the enemy is stunned but there is no battle message stating they are stunned.
Script.JPGGamecap.JPG
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,898
Reaction score
14,995
First Language
English
Primarily Uses
RMMV
Arrays start with element 0. So if you want enemy 7, it's $gameTroop._enemies[6], not $gameTroop._enemies[7].
 

tas38

Warper
Member
Joined
Jun 8, 2021
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Alright thank you I have the loop error fixed.
However I am back to square one. I would like the battle log to display the state change. After reading some other posts such as this one, this is not a problem with my game. It's just how RPG Maker is intended to work. addState does not trigger the battleLog,

The closest I can get to what I want to do is using forceAction with a dummy skill that just stuns the enemy.
The only problem I have with this is that it causes a casting(?) animation each time. It would be extremely annoying for the player after several battles. I don't know how to get rid of this. I have all the cast animations set to 0 in VisuMZ battle core.

Writing the message manually like this is a last resort but I can deal with it if there's no better option.
var text = "Your text goes in there." SceneManager._scene._logWindow.addText(text)
Instead of this, Is there some kind of command that tells the battle log a state was changed and to display it just like it would if it happened directly from a skill instead of common event?

CorrectScript.JPG
(I commented out that one line just to save it, doesn't affect the code)
 

Latest Threads

Latest Posts

Latest Profile Posts

So Dad broke the blinds two days ago and he finally decided to try to fix them. I doubt he'll do very well without some help. And I can't help him myself--I don't know how the stink to fix those blinds. My knowledge is just plushies, mascots, computers, animation, and video game design. And also, I've had to stop family and friends from downloading viruses too many times to count.
IlluminaughtyStore.jpg
:kaojoy:
Welcome to the Illuminaughty store.
Yes... they are "wearing Illuminati branded everything, reclining on huge Illuminati body pillows. Occasionally they'll "teehee" at each other and have pillow fights with Illuminati branded pillows full of hundred dollar bills."
BCj
Working on Escalia again, feels good. Have this overwhelming urge to map as well, but need to get some extra tiles commissioned first :D
Lee Sang wrote on Bandito's profile.
Hi, I've just tried your plugin "Game is Active" and when I tested it on Android, it gave me an error, something about "Cannot read property 'underfined' of underfined.
With my project, I want the player to have access to all the tools they need to get from New Game to Credits as soon as possible; I want the player's progress to only be impeded by the player not knowing how to use the tools the game provides.

Forum statistics

Threads
113,869
Messages
1,078,067
Members
147,961
Latest member
Garnoct
Top