Script call for setting a variable to an enemy's EXP amount?

Hi!

Is there a way to get the exp of an enemy with a script call? In the normal Variable command, the enemy EXP value cannot be referenced, the drop down menu is restricted to enemy's HP, ATK, DEF, AGI, LUK etc, not EXP.

I'm creating a system where, the player can raise fallen enemies as zombies. But when the battle ends the zombie doesn't drop as much EXP as the original enemy it was transformed from. If i could store the EXP of the original enemy in a variable before the transformation happens I could solve this problem quite easily.

Any help is very much appreciated! 🙂
$game_troop.members[index of enemy].exp
Please not that the answer above is for the index (#1 to #8) of the enemy in the troop and only works during battle.
The number has nothing to do with the enemy ID from the database
And just in case its unclear because of previous post: In code, array-index starts at 0, not 1.

~炬燵あ
$game_troop.members[index of enemy].exp
Thanks a lot!
Quick question... Is there a way to change the EXP drop of an enemy during the battle? Is there a script call for that?
Without heavier modification, there is none.

You can change the EXP-drop of an enemy-type, but not for their individuals in the troop.

Ruby:
$data_enemies[123].exp = 123456

If that's not enough, some changes are needed first.

Spoiler
At the very start of Game_Enemy after the class-line, add this block:

Ruby:
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :exp

At the end of content of Game_Enemy#initialize, add the following line:

Ruby:
    @exp = $data_enemies[@enemy_id].exp

Last, scroll down to definition of Game_Enemy#exp and remove it, or comment-out with #.
It may look like this then:

Ruby:
  # def exp
  #   return $data_enemies[@enemy_id].exp
  # end

Afterwards, this should work aswell:

Ruby:
$game_troop.members[0].exp = 123456

~炬燵あ
Without heavier modification, there is none.

You can change the EXP-drop of an enemy-type, but not for their individuals in the troop.

Ruby:
$data_enemies[123].exp = 123456

If that's not enough, some changes are needed first.

Spoiler
At the very start of Game_Enemy after the class-line, add this block:

Ruby:
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :exp

At the end of content of Game_Enemy#initialize, add the following line:

Ruby:
    @exp = $data_enemies[@enemy_id].exp

Last, scroll down to definition of Game_Enemy#exp and remove it, or comment-out with #.
It may look like this then:

Ruby:
  # def exp
  #   return $data_enemies[@enemy_id].exp
  # end

Afterwards, this should work aswell:

Ruby:
$game_troop.members[0].exp = 123456

~炬燵あ
Thanks a lot it works great <3
Without heavier modification, there is none.

You can change the EXP-drop of an enemy-type, but not for their individuals in the troop.

Ruby:
$data_enemies[123].exp = 123456

If that's not enough, some changes are needed first.

Spoiler
At the very start of Game_Enemy after the class-line, add this block:

Ruby:
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :exp

At the end of content of Game_Enemy#initialize, add the following line:

Ruby:
    @exp = $data_enemies[@enemy_id].exp

Last, scroll down to definition of Game_Enemy#exp and remove it, or comment-out with #.
It may look like this then:

Ruby:
  # def exp
  #   return $data_enemies[@enemy_id].exp
  # end

Afterwards, this should work aswell:

Ruby:
$game_troop.members[0].exp = 123456

~炬燵あ
Hi this helped me a lot! Just wondering if this also works with atk?
Hi this helped me a lot! Just wondering if this also works with atk?
You should be able to do it with any of the stats.
atk is defined in Game_BattlerBase, so you DON'T want to change that.
def atk; param(2); end
But you should be able to simply put the attr_accessor in Game_Enemy and set the value in initialize like you did for the exp.
attr_accessor :atk
@atk = $data_enemies[@enemy_id].params[2]


This won't work because RPG::Enemy (the module $data_enemies derives its content from) doesn't have an atk property; you'd need to use $data_enemies[@enemy_id].params[2]
thanks, but would it not simply go looking in the parent class to the parent class?
You should be able to do it with any of the stats.
atk is defined in Game_BattlerBase, so you DON'T want to change that.
def atk; param(2); end
But you should be able to simply put the attr_accessor in Game_Enemy and set the value in initialize like you did for the exp.
attr_accessor :atk
@atk = $data_enemies[@enemy_id].atk
This won't work because RPG::Enemy (the module $data_enemies derives its content from) doesn't have an atk property; you'd need to use $data_enemies[@enemy_id].params[2]

Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-setting-a-variable-to-an-enemys-exp-amount.156888/