Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How do you set monster stats in-game?

My question is: How do you set monster stats in-game? Say your character is fighting an evil version of himself that has all the same stats. So, you put all of the hero's stats into variables. But how do you shift the stats over to the monster? There's no Change Monster Stat command, so do I have to script it in or is it even possible without the database?
 
Is this going to be on VX or XP? I keep seeing similar questions on this forum, I'll probably see if I can write a script for it because it seems to be a pretty hot need lately!

Basically, to get started, you'll have to make a new script, with the class "Game Enemy < Game_Battler", and go ahead and write all the alias methods too before you get started.

Code:
alias_method :actor_dup_initialize,         :initialize
alias_method :actor_dup_base_maxhp,         :base_maxhp
alias_method :actor_dup_base_maxsp,         :base_maxsp
alias_method :actor_dup_base_atk,           :base_atk
alias_method :actor_dup_base_pdef,          :base_pdef
alias_method :actor_dup_base_mdef,          :base_mdef
alias_method :actor_dup_base_eva,           :base_eva
alias_method :actor_dup_base_str,           :base_str
alias_method :actor_dup_base_dex,           :base_dex
alias_method :actor_dup_base_agi,           :base_agi
alias_method :actor_dup_base_int,           :base_int

Now, you'll need to alias the initialize method, but you're going to alias the method too, and call it a little differently.

Instead of...

Code:
def initialize(troop_id, member_index)

Write this...

Code:
def initialize(troop_id, member_index, actor_dup = nil)
  # Alias the method
  actor_dup_initialize
  unless actor_dup == nil
    @dup_temp = true
    @actor = $game_actor[actor_dup]
  end
end

Then, alias each of the base_ stats for the enemy

Code:
def base_maxhp
  unless @dup_temp
    actor_dup_base_maxhp
  else
    return @actor.maxhp
  end
end

It should be as easy as that, although I'm away from my XP/VX so I could've missed something. That should give you a good start if you feel like doing the script yourself, otherwise you could wait until tomorrow and I could probably write one for you.

For Scene_Battle, or maybe even for Sprite_Battler, you'll have to add something you can call with a call script for the 'actor_dup' to work, right before you call the battle, so you can call it like so...

Code:
@> Call Script: Enemy::ActorDup[1, 5] # Actor ID to Enemy ID
@> Call Battle: Hell Demons x 2, Evil Actor x 1

When I have time, I'm definately going to take my own swing at writting this.

So... here's a start, it should work, I'll leave you to do the rest. I left the spoiler of everything before I wrote this, so you should hopefully get an idea of what to do next.

Code:
#===============================================================================
# ** Game_Enemy
#-------------------------------------------------------------------------------
#   This class has been enhanced so an enemy's stats will reflect all of an
# actor's stats, so it's like you're fighting your own.
#===============================================================================
class Game_Enemy < Game_Battler
  #-----------------------------------------------------------------------------
  alias_method :actor_dup_initialize,         :initialize
  alias_method :actor_dup_base_maxhp,         :base_maxhp
  alias_method :actor_dup_base_maxsp,         :base_maxsp
  alias_method :actor_dup_base_atk,           :base_atk
  alias_method :actor_dup_base_pdef,          :base_pdef
  alias_method :actor_dup_base_mdef,          :base_mdef
  alias_method :actor_dup_base_eva,           :base_eva
  alias_method :actor_dup_base_str,           :base_str
  alias_method :actor_dup_base_dex,           :base_dex
  alias_method :actor_dup_base_agi,           :base_agi
  alias_method :actor_dup_base_int,           :base_int
  #-----------------------------------------------------------------------------
  # * Object Initialization (*Aliased*)
  #-----------------------------------------------------------------------------
  def initialize(troop_id, member_index, actor_id = nil)
    # Call origional method
    actor_dup_initialize
    unless actor_id == nil
      @actor_dup = true
      @actor = $game_actor[actor_id]
    end
  end
  #-----------------------------------------------------------------------------
  # * Base MaxHP (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_maxhp
    unless @dup_temp
      actor_dup_base_maxhp
    else
      return @actor.maxhp
    end
  end
  #-----------------------------------------------------------------------------
  # * Base MaxSP (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_maxsp
    unless @dup_temp
      actor_dup_base_maxsp
    else
      return @actor.maxsp
    end
  end
  #-----------------------------------------------------------------------------
  # * Base Strength (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_str
    unless @dup_temp
      actor_dup_base_str
    else
      return @actor.str
    end
  end
  #-----------------------------------------------------------------------------
  # * Base Dexterity (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_dex
    unless @dup_temp
      actor_dup_base_dex
    else
      return @actor.dex
    end
  end
  #-----------------------------------------------------------------------------
  # * Base Agility (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_agi
    unless @dup_temp
      actor_dup_base_agi
    else
      return @actor.agi
    end
  end
  #-----------------------------------------------------------------------------
  # * Base Intelligence (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_int
    unless @dup_temp
      actor_dup_base_int
    else
      return @actor.int
    end
  end
  #-----------------------------------------------------------------------------
  # * Base Attack (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_atk
    unless @dup_temp
      actor_dup_base_atk
    else
      return @actor.atk
    end
  end
  #-----------------------------------------------------------------------------
  # * Base P. Defense (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_pdef
    unless @dup_temp
      actor_dup_base_pdef
    else
      return @actor.pdef
    end
  end
  #-----------------------------------------------------------------------------
  # * Base M. Defense (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_mdef
    unless @dup_temp
      actor_dup_base_mdef
    else
      return @actor.mdef
    end
  end
  #-----------------------------------------------------------------------------
  # * Base Evade (*Aliased*)
  #-----------------------------------------------------------------------------
  def base_eva
    unless @dup_temp
      actor_dup_base_eva
    else
      return @actor.eva
    end
  end
end
 
Yeah, I shoulda said this was on XP.

Ok, I get what you mean, thanks, that answered the question. :) Another question - how do you reference the variables you use for eventing when you script?
 
I'm not sure, I haven't had time to test it... Try using this call script at the start of battle, and tell me if it works.

Code:
$game_enemy(4, 1, 3)

# Troop ID, Member Index, Actor to Imitate.

If there's more to do when I get home, I'll test everything and see what else needs to be done. This doesn't change the enemy's graphic, so the battler must use that actor's graphic by default.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top