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.

[VX] Battling party members? Enemys have weapons.

I was wondering if their was a script, or a way, to battle other party members.

For example Ralph is party member 1, later Jane is party member 2.

Before Jane joins the party Ralph has to battle Jane, and in battle her status in level 10 party member Jane.


Edit: What I am looking for is a script which allows enemies to have a certain weapon equip. I know since it is impossible to do this within the database it will have to be scripted.

Thanks for any help =)
 
Diedrupo":2a7u3cas said:
Just make an enemy battler named Jane, make her graphic like Jane's, and give her stats identical to Jane's level 10 stats.
I wasn’t sure if that worked, but I'll try it. xP. I should of done this originally. Thanks for the help Diedrupo. =)

Edit: Though this works, the weapons are different and the two sword style is lost. The enemy character does not have a weapon, which is what I mainly want.

In a side view battle system, this is a problem.
 

poccil

Sponsor

That's essentially a fundamental problem here.  In the default scripts, actors are treated equally to enemies in some respects (for example, they are both battlers and thus have HP, MP, and so on), but they are treated very differently in others (for example, enemies can't hold weapons and much less have stills than use them.)
 
poccil":2fxo0i3u said:
That's essentially a fundamental problem here.  In the default scripts, actors are treated equally to enemies in some respects (for example, they are both battlers and thus have HP, MP, and so on), but they are treated very differently in others (for example, enemies can't hold weapons and much less have stills than use them.)
Is there a script or some way which could allow enemies to have weapons?
 
Gando":p5a4v5b8 said:
Brewmeister made something like this a while ago. I don't know if it's what you're looking for, but you should check it out. Here is the link to the topic: http://www.rmxp.org/forums/index.php?topic=44182.0
Thank you for showing me this script, it seems really useful. Unfortunately I am more looking for a way to make the actual weapons from the party members work on battlers.

But thanks for showing me that Gando.
 
Well, the 'enemy' actor doesn't necisarilly HAVE to have equipment, right? Rather, you want the enemy version to be exactly like the actor that (was once) in your party, such as their HP, SP, normal stats and equipment buffs?

If thats the case, I might have to dust off my VX later tonight and see if I can try and write a script for you that can do that. Let me know if thats more in the ballpark of what you're looking for before I get started on it though, because I normally don't work with VX, this is just an excuse to use it because I've left it otherwise untouched. :crazy:
 
Kain Nobel":3m3v75mt said:
Well, the 'enemy' actor doesn't necisarilly HAVE to have equipment, right? Rather, you want the enemy version to be exactly like the actor that (was once) in your party, such as their HP, SP, normal stats and equipment buffs?

If thats the case, I might have to dust off my VX later tonight and see if I can try and write a script for you that can do that. Let me know if thats more in the ballpark of what you're looking for before I get started on it though, because I normally don't work with VX, this is just an excuse to use it because I've left it otherwise untouched. :crazy:
I would like the enemy to have the equipment which the actor had while the actor was in the party. So if Jane had a sword in the battle Jane would use the sword while attacking with the default "attack" command (no skills used). If it really is difficult to do, then the script you are willing to create will be the next best thing, as long as it can contain two swords or critical bonus and such. Thanks for all the help Kain.
 

poccil

Sponsor

Here's a script I made that simulates this.  It defines a class (Game_ActorEnemy) that derives from Game_Actor and describes enemies with the characteristics of actors.  The trick here is that when a new enemy is created, it actually returns a Game_ActorEnemy object, instead of a Game_Enemy object (look at the bottom of the script).  Thus, the enemy object would have the same methods that actors have (for example, "weapons", "equips", "skills", and so on.)

Put the script below all others in the Materials section of the script editor.  Look at the bottom of the script for ACTORENEMIES, where you can see how to customize it.

The code is below.  Please notify me if there are errors.

Code:
class Game_ActorEnemy < Game_Actor
  attr_reader   :index                    # index in troop
  attr_reader   :enemy_id                 # enemy ID
  attr_reader   :original_name            # original name
  attr_accessor :letter                   # letters to be attached to the name
  attr_accessor :plural                   # multiple appearance flag
  attr_accessor :screen_x                 # battle screen X coordinate
  attr_accessor :screen_y                 # battle screen Y coordinate
  def is_a?(cls)
    return true if cls==Game_ActorEnemy
    return true if cls==Game_Enemy
    return super.is_a?(cls)
  end
  def kind_of?(cls)
    return true if cls==Game_ActorEnemy
    return true if cls==Game_Enemy
    return super.kind_of?(cls)
  end
  def actor?; return false; end
  def name
    if @plural
      return @original_name + letter
    else
      return @original_name
    end
  end
  def initialize(index, enemy_id, actor_id)
    super(actor_id)
    @enemy_id=enemy_id
    @index=index
    enemy = $data_enemies[@enemy_id]
    @original_name = enemy.name
    @letter = ''
    @plural = false
    @screen_x = 0
    @screen_y = 0
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hp = maxhp
    @mp = maxmp
  end
  def enemy
    return $data_enemies[@enemy_id]
  end
  def exp
    return enemy.exp
  end
  def gold
    return enemy.gold
  end
  def drop_item1
    return enemy.drop_item1
  end
  def drop_item2
    return enemy.drop_item2
  end
  def use_sprite?
    return true
  end
  def screen_z
    return 100
  end
  def perform_collapse
    if $game_temp.in_battle and dead?
      @collapse = true
      Sound.play_enemy_collapse
    end
  end
  def escape
    @hidden = true
    @action.clear
  end
  def transform(enemy_id)
    @enemy_id = enemy_id
    if enemy.name != @original_name
      @original_name = enemy.name
      @letter = ''
      @plural = false
    end
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    make_action
  end
  def conditions_met?(action)
    case action.condition_type
    when 1  # Number of turns
      n = $game_troop.turn_count
      a = action.condition_param1
      b = action.condition_param2
      return false if (b == 0 and n != a)
      return false if (b > 0 and (n < 1 or n < a or n % b != a % b))
    when 2  # HP
      hp_rate = hp * 100.0 / maxhp
      return false if hp_rate < action.condition_param1
      return false if hp_rate > action.condition_param2
    when 3  # MP
      mp_rate = mp * 100.0 / maxmp
      return false if mp_rate < action.condition_param1
      return false if mp_rate > action.condition_param2
    when 4  # State
      return false unless state?(action.condition_param1)
    when 5  # Party level
      return false if $game_party.max_level < action.condition_param1
    when 6  # Switch
      switch_id = action.condition_param1
      return false if $game_switches[switch_id] == false
    end
    return true
  end
  def make_action
    @action.clear
    return unless movable?
    available_actions = []
    rating_max = 0
    for action in enemy.actions
      next unless conditions_met?(action)
      if action.kind == 1
        next unless skill_can_use?($data_skills[action.skill_id])
      end
      available_actions.push(action)
      rating_max = [rating_max, action.rating].max
    end
    for skill in skills
      next unless $game_troop.turn_count>=3
      next unless skill_can_use?(skill)
      available_actions.push(action)
      action=RPG::Enemy::Action.new
      action.kind=1
      action.skill_id=skill.id
      action.rating=1
      rating_max = [rating_max, action.rating].max
    end
    ratings_total = 0
    rating_zero = rating_max - 3
    for action in available_actions
      next if action.rating <= rating_zero
      ratings_total += action.rating - rating_zero
    end
    return if ratings_total == 0
    value = rand(ratings_total)
    for action in available_actions
      next if action.rating <= rating_zero
      if value < action.rating - rating_zero
        @action.kind = action.kind
        @action.basic = action.basic
        @action.skill_id = action.skill_id
        @action.decide_random_target
        return
      else
        value -= action.rating - rating_zero
      end
    end
  end
end

class Game_Enemy
########################
  ACTORENEMIES={
    # Enemy ID => Actor ID
    20=>1,
    21=>2,
    22=>3
  }
#########################
  class << self
   alias petero_actorenemy_Game_Enemy_new new
   def new(index, enemy_id)
     if ACTORENEMIES[enemy_id]
      return Game_ActorEnemy.new(index,enemy_id,ACTORENEMIES[enemy_id])
     end
     return petero_actorenemy_Game_Enemy_new(index,enemy_id)
   end
  end
end
 
poccil":o8ymbf2w said:
Here's a script I made that simulates this.  It defines a class (Game_ActorEnemy) that derives from Game_Actor and describes enemies with the characteristics of actors.  The trick here is that when a new enemy is created, it actually returns a Game_ActorEnemy object, instead of a Game_Enemy object (look at the bottom of the script).  Thus, the enemy object would have the same methods that actors have (for example, "weapons", "equips", "skills", and so on.)

Put the script below all others in the Materials section of the script editor.  Look at the bottom of the script for ACTORENEMIES, where you can see how to customize it.

The code is below.  Please notify me if there are errors.

Code:
class Game_ActorEnemy < Game_Actor
  attr_reader   :index                    # index in troop
  attr_reader   :enemy_id                 # enemy ID
  attr_reader   :original_name            # original name
  attr_accessor :letter                   # letters to be attached to the name
  attr_accessor :plural                   # multiple appearance flag
  attr_accessor :screen_x                 # battle screen X coordinate
  attr_accessor :screen_y                 # battle screen Y coordinate
  def is_a?(cls)
    return true if cls==Game_ActorEnemy
    return true if cls==Game_Enemy
    return super.is_a?(cls)
  end
  def kind_of?(cls)
    return true if cls==Game_ActorEnemy
    return true if cls==Game_Enemy
    return super.kind_of?(cls)
  end
  def actor?; return false; end
  def name
    if @plural
      return @original_name + letter
    else
      return @original_name
    end
  end
  def initialize(index, enemy_id, actor_id)
    super(actor_id)
    @enemy_id=enemy_id
    @index=index
    enemy = $data_enemies[@enemy_id]
    @original_name = enemy.name
    @letter = ''
    @plural = false
    @screen_x = 0
    @screen_y = 0
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hp = maxhp
    @mp = maxmp
  end
  def enemy
    return $data_enemies[@enemy_id]
  end
  def exp
    return enemy.exp
  end
  def gold
    return enemy.gold
  end
  def drop_item1
    return enemy.drop_item1
  end
  def drop_item2
    return enemy.drop_item2
  end
  def use_sprite?
    return true
  end
  def screen_z
    return 100
  end
  def perform_collapse
    if $game_temp.in_battle and dead?
      @collapse = true
      Sound.play_enemy_collapse
    end
  end
  def escape
    @hidden = true
    @action.clear
  end
  def transform(enemy_id)
    @enemy_id = enemy_id
    if enemy.name != @original_name
      @original_name = enemy.name
      @letter = ''
      @plural = false
    end
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    make_action
  end
  def conditions_met?(action)
    case action.condition_type
    when 1  # Number of turns
      n = $game_troop.turn_count
      a = action.condition_param1
      b = action.condition_param2
      return false if (b == 0 and n != a)
      return false if (b > 0 and (n < 1 or n < a or n % b != a % b))
    when 2  # HP
      hp_rate = hp * 100.0 / maxhp
      return false if hp_rate < action.condition_param1
      return false if hp_rate > action.condition_param2
    when 3  # MP
      mp_rate = mp * 100.0 / maxmp
      return false if mp_rate < action.condition_param1
      return false if mp_rate > action.condition_param2
    when 4  # State
      return false unless state?(action.condition_param1)
    when 5  # Party level
      return false if $game_party.max_level < action.condition_param1
    when 6  # Switch
      switch_id = action.condition_param1
      return false if $game_switches[switch_id] == false
    end
    return true
  end
  def make_action
    @action.clear
    return unless movable?
    available_actions = []
    rating_max = 0
    for action in enemy.actions
      next unless conditions_met?(action)
      if action.kind == 1
        next unless skill_can_use?($data_skills[action.skill_id])
      end
      available_actions.push(action)
      rating_max = [rating_max, action.rating].max
    end
    for skill in skills
      next unless $game_troop.turn_count>=3
      next unless skill_can_use?(skill)
      available_actions.push(action)
      action=RPG::Enemy::Action.new
      action.kind=1
      action.skill_id=skill.id
      action.rating=1
      rating_max = [rating_max, action.rating].max
    end
    ratings_total = 0
    rating_zero = rating_max - 3
    for action in available_actions
      next if action.rating <= rating_zero
      ratings_total += action.rating - rating_zero
    end
    return if ratings_total == 0
    value = rand(ratings_total)
    for action in available_actions
      next if action.rating <= rating_zero
      if value < action.rating - rating_zero
        @action.kind = action.kind
        @action.basic = action.basic
        @action.skill_id = action.skill_id
        @action.decide_random_target
        return
      else
        value -= action.rating - rating_zero
      end
    end
  end
end

class Game_Enemy
########################
  ACTORENEMIES={
    # Enemy ID => Actor ID
    20=>1,
    21=>2,
    22=>3
  }
#########################
  class << self
   alias petero_actorenemy_Game_Enemy_new new
   def new(index, enemy_id)
     if ACTORENEMIES[enemy_id]
      return Game_ActorEnemy.new(index,enemy_id,ACTORENEMIES[enemy_id])
     end
     return petero_actorenemy_Game_Enemy_new(index,enemy_id)
   end
  end
end
That seems to work nicely. Thanks Poccil.

Edit: Is there any way to make it capable with a side view system script?
 

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