How can I store enemy ID for a talk system?
RPG Maker MV SupportDo me a favour: as the very start of the event, write "console.log("test");" (in a script command) and then when you're testing it, open the console window and see if you see that message.
I actually did not think about using the console log before. The "test" message is appearing fine, but...
Well, I'm using YEP_CoreEngine, YEP_BattleEngineCore and YEP_SkillCore. If those plugins are on, the console log shows a error message related to them.
If they're deactivated, the game crashes...
And just to make sure, your Talk skill is calling the common event with that code in it, right?
Change the console.log to
console.log(BattleManager.actor());
And see what it outputs.
console.log(BattleManager.actor());
And see what it outputs.
It's outputing to 'null'.
Take out the brackets and see where it's currently getting that function from. I get the feeling you're using plugins that change the functionality so much this method won't work for you.
console.log(BattleManager.actor);
console.log(BattleManager.actor);
It's still outputting null, I think.
I'm not using many plugins, but even after deactivating all of them it's still not working...
Weird, I did
and it correctly assigned the variable value with no errors.
Could you send me your project and I'll take a look?
Code:
$gameTroop.members()[BattleManager.actor()._lastTargetIndex].enemyId()
Could you send me your project and I'll take a look?
I think the problem is that
_lastTargetIndexactor() is part of the selection process and is cleared once moves actually start. You might need to use the method from my thread a week or so ago. I'll go look it up for you.Ohh, I've been testing it on a game that uses a battle system where turns are executed as soon as the action is selected. That's possible.
I created a new project and it's still showing the same error message for me. I'll upload this new project I created, since the original project has some files I prefer not sharing right now lol
You can download it here: https://www.mediafire.com/file/yoi6ok8hb9e9o2p/Project1.rar/file
Sorry, I meant the actor index, not the target index. The general idea still applies though.
I have an idea. @ShiningRomantica, can multiple party members use the Talk skill or is it just one person that has it?
It's only one character that will be able to do it.
Got it. Use
Replace 10 with the ID of your Talk skill.
Code:
$gameTroop.members()[$gameParty.members().filter(function(member) { return member._lastBattleSkill._itemId == 10; } )[0]._lastTargetIndex].enemyId()
Replace 10 with the ID of your Talk skill.
It seems to be working now. Thanks!
Do you want me to explain that that line is doing or are you happy just accepting that it works? 😛
It would be cool if you explained. Let's see if I can understand it. XD
Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-store-enemy-id-for-a-talk-system.123374/