Status
Not open for further replies.

ShiningRomantica

Villager
Member
Joined
Mar 9, 2020
Messages
18
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
Hi!

I want to make a talk system similar to a SMT game into my project. I don't think a plugin is needed, but if there's any plugin that can solve my problem, It would be great too!

Basically, I want to make a very simple skill that can start a conversation with an enemy based on the enemy ID of the target. I created a Common Event, but I'm unsure of which script call I should use, or how I should use it...

If I can somehow store the target enemy ID into a variable, I think I can then make a Condition for each enemy ID... How should I do it?

Thanks!
 

ShiningRomantica

Villager
Member
Joined
Mar 9, 2020
Messages
18
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
You can use BattleManager.actor()._lastTargetIndex for this.

Thanks! But how should I use it exactly? I tried to paste that line as a script call for a variable, but it didn't work as intended... It simply won't show any messages on battle. What should I do?

01.png
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
It works fine for me; are you remembering the indexes start at 0? (you also don't need it to be parallel process; just have the Talk skill call the common event)
 

ShiningRomantica

Villager
Member
Joined
Mar 9, 2020
Messages
18
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
It works fine for me; are you remembering the indexes start at 0? (you also don't need it to be parallel process; just have the Talk skill call the common event)

Yep, I though it started at 1 lol.

It's working perfectly now. Thanks!
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
618
Reaction score
260
First Language
English
Primarily Uses
RMMV
You can use BattleManager.actor()._lastTargetIndex for this.
Is that actually correct if you have more than one actor in the party, though? What I would expect to get from that in the common event is the last enemy targeted by the actor in the last position in the party.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
No, it stores the index of the most recent target (which will be the enemy you targeted with the skill).

BattleManager.actor() returns the actor that is *currently acting* which when the skill executes will be the one who used the skill that called the common event.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
618
Reaction score
260
First Language
English
Primarily Uses
RMMV
When does that common event actually execute? I know that items "reserve" a common event to execute at the next opportunity... which is when exactly?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
It's executed as part of execution of the skill; the common event happens after damage is applied.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
618
Reaction score
260
First Language
English
Primarily Uses
RMMV
Ah okay, so it should work then.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
Funnily enough I'm currently writing the new Jump into Javascript and I'm on Game_Action, which will break down how this works.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
618
Reaction score
260
First Language
English
Primarily Uses
RMMV
Funnily enough I'm currently writing the new Jump into Javascript and I'm on Game_Action, which will break down how this works.
I glanced at the first entry to that but it seemed a little too basic for me... that is, everything in the first entry was something I already knew or could have easily figured out from the code myself. Do later entries have less of a "just translate the JavaScript code into English prose" angle than the first one did?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
I glanced at the first entry to that but it seemed a little too basic for me... that is, everything in the first entry was something I already knew or could have easily figured out from the code myself. Do later entries have less of a "just translate the JavaScript code into English prose" angle than the first one did?

Nah, not in this series. It was literally designed to be a "just translate the JavaScript into English" though I have started noting interesting aspects of the code and why they were done that way.

What would you find more helpful?
 

ShiningRomantica

Villager
Member
Joined
Mar 9, 2020
Messages
18
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
I did some more tests, and I think I may have done something wrong... It's always returning the variable value as 0, even if I target another enemy.

For example, I want enemy ID below 20 to have a default message, So I set that if Variable 21 is Less than or equal to 19, it will give the default message.

If Variable 21 is equal to 20, it will give message 1.

If Variable 21 is equal to 21, it will give message 2, etc.

From Enemy ID 1 to 20 (which I guess would be from 0 to 19 for the variable), I have set the monsters which you can't talk to. But if I start a battle with Enemy ID 21, it stills shows the default message and, once outside of the battle, it shows Variable 21 as 0 on the debug menu.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
The code I gave you returns the *enemy index* of the last target, not the ID of its entry in the database. Did you want the ID of the actual enemy type selected?
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
618
Reaction score
260
First Language
English
Primarily Uses
RMMV
Nah, not in this series. It was literally designed to be a "just translate the JavaScript into English" though I have started noting interesting aspects of the code and why they were done that way.

What would you find more helpful?
I'm sure that approach is helpful for some people, it's just that I already know JavaScript so I can more or less read the code directly and understand what it's doing.

Basically I need to understand some stuff about how the engine works so I can figure out how to modify it. I have a thread in JS/Plugin support about one of the things I need, but no useful responses yet.

I did some more tests, and I think I may have done something wrong... It's always returning the variable value as 0, even if I target another enemy.

For example, I want enemy ID below 20 to have a default message, So I set that if Variable 21 is Less than or equal to 19, it will give the default message.

If Variable 21 is equal to 20, it will give message 1.

If Variable 21 is equal to 21, it will give message 2, etc.

From Enemy ID 1 to 20 (which I guess would be from 0 to 19 for the variable), I have set the monsters which you can't talk to. But if I start a battle with Enemy ID 21, it stills shows the default message and, once outside of the battle, it shows Variable 21 as 0 on the debug menu.
There are only up to 8 enemies in a battle (unless you have a plugin that adds more), so this method will never return a number greater than or equal to 8. If you want the ID of the enemy in the database, use this instead:

Code:
$gameTroop.members()[BattleManager.actor()._lastTargetIndex].enemyId()

You can see that it incorporates the formula from before but adds more to it. This index will start from 1, rather than 0.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
I'll check out your thread and see if I can help. The plan once I've finished breaking down the default code is expanding into engine customisation and more interesting stuff.
 

ShiningRomantica

Villager
Member
Joined
Mar 9, 2020
Messages
18
Reaction score
1
First Language
Portuguese
Primarily Uses
RMMV
I'm sure that approach is helpful for some people, it's just that I already know JavaScript so I can more or less read the code directly and understand what it's doing.

Basically I need to understand some stuff about how the engine works so I can figure out how to modify it. I have a thread in JS/Plugin support about one of the things I need, but no useful responses yet.

There are only up to 8 enemies in a battle (unless you have a plugin that adds more), so this method will never return a number greater than or equal to 8. If you want the ID of the enemy in the database, use this instead:

Code:
$gameTroop.members()[BattleManager.actor()._lastTargetIndex].enemyId()

You can see that it incorporates the formula from before but adds more to it. This index will start from 1, rather than 0.

Yeah, I wanted to get the enemy ID from the database. I used the line you suggested, but it's still returning only 0... Should I put it somewhere else? I'm using the Script function inside Control Variable.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,745
Reaction score
2,847
First Language
English
Primarily Uses
RMMZ
Whereabouts do you have this line, exactly? Can you show screenshots?
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Happy Friday, y'all! I just got home from work and am sitting down with a nice cider, and I'm ready to chill and enjoy myself. Not sure if I'm gonna dive into any of my game-related projects or not tonight.... we'll see how I feel after unwinding for a bit I guess!
Just found out that mint tea made from chocolate mint tastes a bit like hot cocoa with candy cane stirred in. As I'm allergic to chocolate this makes me very happy.
It's special day for me tomorrow so time to vanish for 24 hours lol.
So Deltarune Chapter 2 is supposed to release today... if it's out already, has anyone played it? And I can't because I have a stinking Mac and not a Windows PC.

Forum statistics

Threads
115,141
Messages
1,087,575
Members
149,661
Latest member
aels
Top