Calling up Id numbers of enemies and items

yoluko

Villager
Member
Joined
Mar 9, 2020
Messages
17
Reaction score
2
First Language
English
Primarily Uses
RMMV
I'm trying to create a capture system like pokemon, but I'm having a little trouble.
My aim is to use a skill to run a common event. I've set it so that each enemy has a corresponding "shard item" for itself. What I want to do is get the event to look up the ID number of the monster it is used against, and then look up the same ID number in the item list. Then it simply adds one shard of that ID to the party's supply.
(Shards will be swapped for a monster companion in a town event).

Any ideas on how to achieve this? or if there is another way, let us know,

Thanks
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,075
Reaction score
13,691
First Language
English
Primarily Uses
RMMV
If you just want it to happen whenever you use the skill, put the following into the damage formula:

Code:
$gameParty.gainItem($dataItems[b.enemyId()], 1)
If you only want it to run when you defeat the enemy, it'll be a little different. Not sure off the top of my head how you'd do that, but you would run into the issue where no more processing is done after the last enemy is defeated, so you wouldn't get the shard for that one.
 

yoluko

Villager
Member
Joined
Mar 9, 2020
Messages
17
Reaction score
2
First Language
English
Primarily Uses
RMMV
If you just want it to happen whenever you use the skill, put the following into the damage formula:

Code:
$gameParty.gainItem($dataItems[b.enemyId()], 1)
If you only want it to run when you defeat the enemy, it'll be a little different. Not sure off the top of my head how you'd do that, but you would run into the issue where no more processing is done after the last enemy is defeated, so you wouldn't get the shard for that one.
I was hoping to run a common event where, if the enemy's HP was below a certain level, you got the shard and it applied the knockout status to the enemy. But I'm not sure if that is possible.

Is there a way to increase the chances of a skill hitting based on enemy HP?

Alternatively, is there a way to apply the effect directly through the skill's coding, without needing a common event?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,300
Reaction score
7,639
First Language
German
Primarily Uses
RMMV
1) yes, it is possible but not easy. you first need to identify which battler is hit (for example place an invisible state on that battler as an additional skill effect and then have the common event check which battler has the state). Then you need a script command to get that enemy ID from that battler and then you can proceed with the rest.

2) by default the HIT% is a fixed number. To change that will require a plugin, and might cause some disruptions in the battleengine depending on what exactly you have as a battlesystem.

3) theoretically yes, but there are limitations. Basically the damage line has a limited size, and that means you can't do everything in it.
Shaz's solution already forced a shortcut on you - it will require you to always have the same ID for the enemy and it's shard, which means you have to set aside the enemy numbers before adding any regular items like potions to the end of the list.
Adding a condition for HP% before adding the item is possible (and doesn't take that much code, I just don't have the exact code available at the moment), but it will restrict the remaining space for further coded effects.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,075
Reaction score
13,691
First Language
English
Primarily Uses
RMMV
Shaz's solution already forced a shortcut on you - it will require you to always have the same ID for the enemy and it's shard
this is what the OP requested:

What I want to do is get the event to look up the ID number of the monster it is used against, and then look up the same ID number in the item list. Then it simply adds one shard of that ID to the party's supply.
 

yoluko

Villager
Member
Joined
Mar 9, 2020
Messages
17
Reaction score
2
First Language
English
Primarily Uses
RMMV
Is there a list of codes that work in the formula bar somewhere, so I can see if I can code that?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,300
Reaction score
7,639
First Language
German
Primarily Uses
RMMV
Is there a list of codes that work in the formula bar somewhere,
That list is called "javascript"

The damage formula is executed as a javascript command-line, and any javascript command as well as any function defined by the engine will work there.
For references of what other people found usable there is a topic specifically about the damage formula:
 

yoluko

Villager
Member
Joined
Mar 9, 2020
Messages
17
Reaction score
2
First Language
English
Primarily Uses
RMMV
That list is called "javascript"

The damage formula is executed as a javascript command-line, and any javascript command as well as any function defined by the engine will work there.
For references of what other people found usable there is a topic specifically about the damage formula:
Ok, thanks, I'll ask there!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

I think I've created a monster.
...and I love it. <3
Today represents my one year anniversary of throwing out the tile map. :LZSexcite: One year ago my game looked like...


And now for those that don't know, it looks like..


What a year, what a year indeed. RIP Tile Map, nobody misses you. :LZSwink:
There is now a demo released for [Beyond the Mirror]! Check the team recruitment thread to learn more!
'Tis the season to see shipping prices and go 'Yikes'.

Forum statistics

Threads
105,696
Messages
1,015,680
Members
137,379
Latest member
ytviews123
Top