Status
Not open for further replies.

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Hi!
I'm using a few VS plugins:
1608857752745.png

And am using $gameVariables.setValue(1, b.enemyId()) in the damage formula for a skill to save the enemy's ID, which is working great.

However, when I test play this pops up on the dev tools, apparently an issue with VS BattleCore. It's not crashing, but should I be concerned about it?
b.enemyid.PNG

I appreciate any advice on this, sorry if it's a silly question.
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
206
Reaction score
314
First Language
French, German
Primarily Uses
RMMZ
Well, you're trying to call b.enemyId(), which implies that enemyId is a function, but dev tools is telling you that enemyId is not a function. As a result, your damage formula causes an exception. This would typically lead to a crash, unless wrapped inside the "try" part of a try-catch block. Your game will thus skip whatever code remains in the current try block, and execute the catch block instead.

Should you be concerned about it? Well, yes. Your game is not doing what you want it to do, after all.
It's not properly evaluating the damage formula (probably defaulting to 0 damage), and Variable 1 is not set to the opponent's enemyId.

The simplest fix would be to change your formula to the following instead:
Code:
$gameVariables.setValue(1, b.enemyId)

Notice how there are no brackets after enemyId (except the closing one belonging to setValue).
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
You would also need to ensure this skill cannot be used BY enemies, as actors don't have an enemy id.

The reason this doesn't crash the game is that the damage formula calculation is wrapped in a try/catch block. If it fails, it simply returns 0 rather than crashing.
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Well, you're trying to call b.enemyId(), which implies that enemyId is a function, but dev tools is telling you that enemyId is not a function. As a result, your damage formula causes an exception. This would typically lead to a crash, unless wrapped inside the "try" part of a try-catch block. Your game will thus skip whatever code remains in the current try block, and execute the catch block instead.

Should you be concerned about it? Well, yes. Your game is not doing what you want it to do, after all.
It's not properly evaluating the damage formula (probably defaulting to 0 damage), and Variable 1 is not set to the opponent's enemyId.

The simplest fix would be to change your formula to the following instead:
Code:
$gameVariables.setValue(1, b.enemyId)

Notice how there are no brackets after enemyId (except the closing one belonging to setValue).

Thanks for the reply Nolonar :)

I just noticed that I somehow had the common event autorunning (it's a mystery) and when I turned off autorun I don't get the error anymore. I don't understand why, but yay.
Interestingly, before I noticed the autorun, when I tried removing the second bracket, this happened, though hopefully it will remain a non issue now:
1608867377011.png
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
You would also need to ensure this skill cannot be used BY enemies, as actors don't have an enemy id.

The reason this doesn't crash the game is that the damage formula calculation is wrapped in a try/catch block. If it fails, it simply returns 0 rather than crashing.
Cheers Shaz,
It's an ability only available to one character, so all good :)
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
Could the character be given a state that would cause them to attack their allies?
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Could the character be given a state that would cause them to attack their allies?
Good question. Do states override scope?
1608868746979.png
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
Yes, they do. But I'm talking about a state on the actor who will use the skill you've entered that damage formula on. If they can get such a state, and it makes them target the player party, then that skill will not work because the target is a party member and not an enemy, therefore has no enemyId property.
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Thanks for the reply Nolonar :)

I just noticed that I somehow had the common event autorunning (it's a mystery) and when I turned off autorun I don't get the error anymore. I don't understand why, but yay.
Interestingly, before I noticed the autorun, when I tried removing the second bracket, this happened, though hopefully it will remain a non issue now:
View attachment 172694
Dang, I just discovered I'm still getting the error about b.enemyId() at the end of each round - I thought it was fixed cause I wasn't reaching the end of any rounds :(

But if I do as you suggested, I get the above thing happening.

Any ideas?
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Yes, they do. But I'm talking about a state on the actor who will use the skill you've entered that damage formula on. If they can get such a state, and it makes them target the player party, then that skill will not work because the target is a party member and not an enemy, therefore has no enemyId property.

I see what you mean. I don't really understand how states work but if my character with this ability gets a state on them that causes them to attack allies, does the code consider them enemies during that state?

Do you know another way to grab the enemyID during battle that doesn't include the damage formula?
I need the enemyID to get the enemy name and also align it to the actorID to be added to the party.

Strange that $gameTemp.lastActionData(type) can do the last enemy targeted index but not ID.
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Thanks for the reply Nolonar :)

I just noticed that I somehow had the common event autorunning (it's a mystery) and when I turned off autorun I don't get the error anymore. I don't understand why, but yay.
Interestingly, before I noticed the autorun, when I tried removing the second bracket, this happened, though hopefully it will remain a non issue now:
View attachment 172694

This is the common event, if it helps :)

1608872456045.png
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
if my character with this ability gets a state on them that causes them to attack allies, does the code consider them enemies during that state?

If your character with this skill gets a state that causes them to attack allies, and they use this skill, it will cause the damage formula to look for an enemyId on your ally, and there won't be one, because they are an ally, not an enemy. Only enemies, set up in the Enemies tab, will have an enemy id. So even if you gave this skill TO an enemy and they used it on a party member, there will still be no enemyId because your party member was set up under the Actors tab and not the Enemies tab.

It isn't whether the target is an enemy/opponent of the character performing the action - it is which tab they are set up in in the database. Only enemies have an enemyId. Actors have an actorId.

Edit: I see this is probably going to confuse you too, because it looks like you have some kind of monster catching game, so you will be setting them up in both tabs. Anyone in your party is an actor, not an enemy. So if this skill is used on anyone in your party, it will not work.

Strange that $gameTemp.lastActionData(type) can do the last enemy targeted index but not ID.
last enemy targeted index is their position in the troop lineup (in what order you added them to the troop) and has nothing to do with enemy id. If you have the index, you could get to the id from there.
 
Last edited:

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
If your character with this skill gets a state that causes them to attack allies, and they use this skill, it will cause the damage formula to look for an enemyId on your ally, and there won't be one, because they are an ally, not an enemy. Only enemies, set up in the Enemies tab, will have an enemy id. So even if you gave this skill TO an enemy and they used it on a party member, there will still be no enemyId because your party member was set up under the Actors tab and not the Enemies tab.

It isn't whether the target is an enemy/opponent of the character performing the action - it is which tab they are set up in in the database. Only enemies have an enemyId. Actors have an actorId.

Edit: I see this is probably going to confuse you too, because it looks like you have some kind of monster catching game, so you will be setting them up in both tabs. Anyone in your party is an actor, not an enemy. So if this skill is used on anyone in your party, it will not work.


last enemy targeted index is their position in the troop lineup (in what order you added them to the troop) and has nothing to do with enemy id. If you have the index, you could get to the id from there.

Thanks for your quick reply Shaz :)

I think I may have worded my question poorly, sorry.
I believe I understand what enemyIds and actorIds are, and your point about it causing an issue if you tried to use this ability on a party member because they don't have an enemyId.
What I'm wondering is whether setting the ability up to have the scope of '1 enemy' will prevent the character from being able to use it on a party member in the first place because they aren't (hopefully) considered an enemy and whether this will just prevent the situation from occurring. I hope that makes sense :/

RE getting the enemyId from the last enemy targeted - I tried doing it in the common event and couldn't get it to work, which is very likely me doing something wrong.

I used $gameVariables.setValue(1, $gameTroop.members()[$gameTemp.lastActionData(5)].enemyId())
but it just returns blank and causes this error, I'm guessing because the common event runs after the attack?

1608875564750.png

I really appreciate your advice :)
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
it is saying $gameTroop.members()[$gameTemp.lastActionData(5)] is undefined. Not sure why that is - I haven't messed around a lot with the battle stuff. Control Variables > Game Data has an option to put the last action data into a variable so it might be worth trying to use that.

I don't think it'd be because of the common event ... unless you have some plugin that makes the common event run first.

About your other question ... you can set the scope to 1 enemy. But if your character is hit with a state that confuses them and makes them target allies, then all of their skills that target enemies will be turned to target allies instead, while that state is on them. So yes, the state will override the scope of the skill.
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Thanks for your quick reply Shaz :)

I think I may have worded my question poorly, sorry.
I believe I understand what enemyIds and actorIds are, and your point about it causing an issue if you tried to use this ability on a party member because they don't have an enemyId.
What I'm wondering is whether setting the ability up to have the scope of '1 enemy' will prevent the character from being able to use it on a party member in the first place because they aren't (hopefully) considered an enemy and whether this will just prevent the situation from occurring. I hope that makes sense :/

RE getting the enemyId from the last enemy targeted - I tried doing it in the common event and couldn't get it to work, which is very likely me doing something wrong.

I used $gameVariables.setValue(1, $gameTroop.members()[$gameTemp.lastActionData(5)].enemyId())
but it just returns blank, I'm guessing because the common event runs after the attack?

I really appreciate your advice :)
it is saying $gameTroop.members()[$gameTemp.lastActionData(5)] is undefined. Not sure why that is - I haven't messed around a lot with the battle stuff. Control Variables > Game Data has an option to put the last action data into a variable so it might be worth trying to use that.

I don't think it'd be because of the common event ... unless you have some plugin that makes the common event run first.

About your other question ... you can set the scope to 1 enemy. But if your character is hit with a state that confuses them and makes them target allies, then all of their skills that target enemies will be turned to target allies instead, while that state is on them. So yes, the state will override the scope of the skill.

Well, bummer. I'll keep looking.
Thank you Shaz!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
Just use Control Variables to put the last troop index into a variable, and make your common event show a message with the variable, so you can see if it puts anything there. You've just got to take baby steps - play around with one thing until it works, then expand it a bit and play around with the next thing ...
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Just use Control Variables to put the last troop index into a variable, and make your common event show a message with the variable, so you can see if it puts anything there. You've just got to take baby steps - play around with one thing until it works, then expand it a bit and play around with the next thing ...

I just tried that before, I can get the index returned but on its own it's not of any use - it just becomes a 1, 2, or 3 and without specific code to return the value of an enemy id from a common event I'm not sure what to do. Doing it from the damage formula is causing its own issues. I'm glad I decided to test functionality of my main mechanics before making the actual game lol.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
The secret is in here:

Code:
Game_Action.prototype.updateLastTarget = function(target) {
    if (target.isActor()) {
        $gameTemp.setLastTargetActorId(target.actorId());
    } else {
        $gameTemp.setLastTargetEnemyIndex(target.index() + 1);
    }
};

So if the last target was an actor, it will set the actor id. But if it's an enemy, it will set the enemy's index plus 1. So you have to -1 before you try and get the enemy itself. Then when you're looking at the enemy from the game troop, enemyId actually IS a function. So try something like this:

Code:
Control Variables [0001 - ...] = Script:  $gameTroop.members()[$gameTemp.lastActionData(5) - 1].enemyId()
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
The secret is in here:

Code:
Game_Action.prototype.updateLastTarget = function(target) {
    if (target.isActor()) {
        $gameTemp.setLastTargetActorId(target.actorId());
    } else {
        $gameTemp.setLastTargetEnemyIndex(target.index() + 1);
    }
};

So if the last target was an actor, it will set the actor id. But if it's an enemy, it will set the enemy's index plus 1. So you have to -1 before you try and get the enemy itself. Then when you're looking at the enemy from the game troop, enemyId actually IS a function. So try something like this:

Code:
Control Variables [0001 - ...] = Script:  $gameTroop.members()[$gameTemp.lastActionData(5) - 1].enemyId()

IT'S WORKING! I am so relieved. Thank you so much!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,452
Reaction score
14,815
First Language
English
Primarily Uses
RMMV
I'll assume it's okay to close this thread. In future, when a question you post has been answered, just report one of your posts and let the mods know, and they'll close it up for you.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

image_2021-06-13_213812.png

Todays Lesson: Tiles are a pain to make xD
The game is not even 2% complete, but i just wanted to release something for funsies. :)
It's on my google drive.
It would be awesome if i could get a couple ideas and the like!
So yesterday Dad took me to Volcano Bay, and it was almost ruined by a thunderstorm... then it passed by and the lightning warning got lifted, leading to an awesome time sliding and swimming. Hopefully we get to go to the arcade tonight. The one we're planning on has a restaurant built in with AWESOME food. Not to mention how big the arcade itself is!
image_2021-06-13_150033.png

Maybe I'll actually try making a retro pack. Already have the shark fin made so why not xD
Hey everyone, for everybody following along with my RPG Maker MZ streams: There will unfortunately not be a stream tonight. There is a big exciting event that will go live next week that has been taking all my time, so look forward to that!

Forum statistics

Threads
112,201
Messages
1,066,542
Members
145,809
Latest member
StShiner
Top