How to get loot ID from an enemy in variables?

I can find anything about my enemies with little pieces of script like:

For HP:
Code:
$dataEnemies[X].params[0]

And for ATK:
Code:
$dataEnemies[X].params[2]

I can also find how much EXP or GOLD it frops with
Code:
$dataEnemies[X].exp
and
Code:
$dataEnemies[X].gold

This is very usefull stuff, when I try to make systems that play outside or completely replace the battle scene. I can easily use this in formula's, or save it in a variable to be used by other parts, like event conditions.

However, other useful information would be which loot it drops. I have worked around this for a while now, but it would be real handy if I could use this information in my out-of-battle systems.

So, is there a code that refers to the loot ID? I assume there will be 3 variables needed for 3 pieces of loot. Or probably 3 more for the item-type. (Item/Weapon/Armor)

And since we're at it, maybe we can also get which loot has what drop rate?

---

I don't need a complete formula, or something. If I just know the part that would give me the ID, and if possible also the part that gives the weapon type.
Very
I can find anything about my enemies with little pieces of script like:

For HP:
Code:
$dataEnemies[X].params[0]

And for ATK:
Code:
$dataEnemies[X].params[2]

I can also find how much EXP or GOLD it frops with
Code:
$dataEnemies[X].exp
and
Code:
$dataEnemies[X].gold

This is very usefull stuff, when I try to make systems that play outside or completely replace the battle scene. I can easily use this in formula's, or save it in a variable to be used by other parts, like event conditions.

However, other useful information would be which loot it drops. I have worked around this for a while now, but it would be real handy if I could use this information in my out-of-battle systems.

So, is there a code that refers to the loot ID? I assume there will be 3 variables needed for 3 pieces of loot. Or probably 3 more for the item-type. (Item/Weapon/Armor)

And since we're at it, maybe we can also get which loot has what drop rate?

---

I don't need a complete formula, or something. If I just know the part that would give me the ID, and if possible also the part that gives the weapon type.
Very helpful and informational. If only I knew how to use it LOL. I'm SO bad at technical stuff like that when it comes to scripting, etc. I don't know the first thing about it.
Very

Very helpful and informational. If only I knew how to use it LOL. I'm SO bad at technical stuff like that when it comes to scripting, etc. I don't know the first thing about it.
It's rather easy. And it can even be used without any further coding knowledge. But because I don't want to derail this topic before I have my answer*, send me a DM and I'll teach you how to use it. 😉

(*I'm okay with derailment as soon as I got what I want. Hahaha.)
Each record of $dataEnemies has a field dropItems. It is array of objects, each of which has these properties:
  • kind - 1 (Item), 2 (Weapon), or 3 (Armor).
  • dataId - database ID of the Item, Weapon, or Armor.
  • denominator - the "1 in X" value determining drop chance.
So, in line with your given examples, this gets the first assigned drop item:

$dataEnemies[X].dropItems[0]
Note that kind will be 0 if that item drop is left blank.

Technical:
  • Item drops are generated via the makeDropItems methods of Game_Troop and Game_Enemy.
  • The kind and dataId properties are fed directly to the itemObject method of Game_Enemy.
Perfect! Exactly what I was looking for. This will open so much doors, which have been locked for me for so long. 😛 And I just know there is some treasure behind it. 😉

Thanks again, Caethyril. Once again you're the one to open the doors for me.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-get-loot-id-from-an-enemy-in-variables.158087/