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.

Battle features and level reqs

Hey people!  I need some help making three different scripts.  They are totally sperate and have nothing to do with each other. 

Script One:
--must display enemy HP and SP
--must automatically update HP and SP after each attack

Script Two:
--must allow me to make an enemy with more health than 99999(the normal maximum HP)
--must allow me to make an enemy with greater SP(same idea as above)

Script Three:
--must allow me to add a level limit to each type of weapon and armor(for example, to use a mithril rod you must be level 10)

If any of these have already been covered, that means that I have searched but did not find them.  Please notify me if I am asking for something that has already been answered, and I will go search again.

Also, I it has already been answered, it may have had bugs, and that is why I did not use it.

Anyhow, thanks a lot for the help!
 
Level Requirements
You could use this script for the level thingy, I do not know who made this.

Author:
Please notify if your the creator of this script.

Use:
1. Don't credit me for this script.
2. I think the script is pretty explaining from itself in my eyes, although I could understand it if you would need help. Just respond :rolleyes:.
3. Add this above 'Main' but below the other default scripts.
Code:
module RPG
  
  class Weapon
    
    attr_reader   :str_needed
    attr_reader   :dex_needed
    attr_reader   :int_needed
    attr_reader   :agi_needed
    attr_reader   :lvl_needed
    attr_reader   :style_needed
    
    def setup_requirements
      @str_needed = 0
      @dex_needed = 0
      @int_needed = 0
      @agi_needed = 0
      @lvl_needed = 0
      @style_needed = ''
      
      case @id
      when 1
        @lvl_needed = 0
      when 2
        @lvl_needed = 0
      when 3
        @lvl_needed = 0
      when 4
        @lvl_needed = 0
      when 5
        @lvl_needed = 0
        @str_needed = 20
      when 6 
        @lvl_needed = 0
      when 7
        @lvl_needed = 0
      when 8
        @lvl_needed = 0
      when 9
        @lvl_needed = 0
      when 10
        @lvl_needed = 0
      when 11
        @lvl_needed = 0
      when 12
        @lvl_needed = 0
      when 13
        @lvl_needed = 0
      when 14
        @lvl_needed = 8
      when 15
        @lvl_needed = 8
      when 16
        @lvl_needed = 0
      when 17
        @lvl_needed = 0
      when 18
        @lvl_needed = 0
      when 19
        @lvl_needed = 0
      when 20
        @lvl_needed = 0
      when 21
        @lvl_needed = 0
      when 22
        @lvl_needed = 0
      when 23
        @lvl_needed = 0
      when 24
        @lvl_needed = 0
      when 25
        @lvl_needed = 0
      when 26
        @lvl_needed = 0
      when 27
        @lvl_needed = 0
      when 28
        @lvl_needed = 0
      when 29
        @lvl_needed = 0
      when 30
        @lvl_needed = 0
      when 31
        @lvl_needed = 0
      when 32
        @lvl_needed = 0
      when 33
        @lvl_needed = 0
      when 34
        @lvl_needed = 0
      when 35
        @lvl_needed = 0
      when 36
        @lvl_needed = 0
          
        
    end
      
    end
    
  end
  
  class Armor
    
    attr_reader   :str_needed
    attr_reader   :dex_needed
    attr_reader   :int_needed
    attr_reader   :agi_needed
    attr_reader   :lvl_needed
    attr_reader   :style_needed
    
    def setup_requirements
      @str_needed = 0
      @dex_needed = 0
      @int_needed = 0
      @agi_needed = 0
      @lvl_needed = 0
      @style_needed = ''
      
      case @id
      when 1
        @lvl_needed = 0
      when 2
        @lvl_needed = 0
      when 3
        @lvl_needed = 0
      when 4
        @lvl_needed = 0
      when 5
        @lvl_needed = 0
        @str_needed = 0
      when 6 
        @lvl_needed = 0
      when 7
        @lvl_needed = 0
      when 8
        @lvl_needed = 0
      when 9
        @lvl_needed = 0
      when 10
        @lvl_needed = 0
      when 11
        @lvl_needed = 0
      when 12
        @lvl_needed = 0
      when 13
        @lvl_needed = 0
      when 14
        @lvl_needed = 0
      when 15
        @lvl_needed = 0
      when 16
        @lvl_needed = 0
      when 17
        @lvl_needed = 0
      when 18
        @lvl_needed = 0
      when 19
        @lvl_needed = 0
      when 20
        @lvl_needed = 0
      when 21
        @lvl_needed = 0
      when 22
        @lvl_needed = 0
      when 23
        @lvl_needed = 0
      when 24
        @lvl_needed = 0
      when 25
        @lvl_needed = 0
      when 26
        @lvl_needed = 0
      when 27
        @lvl_needed = 0
      when 28
        @lvl_needed = 0
      when 29
        @lvl_needed = 0
      when 30
        @lvl_needed = 0
      when 31
        @lvl_needed = 0
      when 32
        @lvl_needed = 0
      when 33
        @lvl_needed = 0
      when 34
        @lvl_needed = 0
      when 35
        @lvl_needed = 0
      when 36
        @lvl_needed = 0
      end
      
    end
    
  end
  
end

class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add equippable weapons
    if @equip_type == 0
      weapon_set = $data_classes[@actor.class_id].weapon_set
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
          if @actor.meets_requirements?($data_weapons[i])
            @data.push($data_weapons[i])
          end
        end
      end
    end
    # Add equippable armor
    if @equip_type != 0
      armor_set = $data_classes[@actor.class_id].armor_set
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 and armor_set.include?(i)
          if $data_armors[i].kind == @equip_type-1
            if @actor.meets_requirements?($data_armors[i])
              @data.push($data_armors[i])
            end
          end
        end
      end
    end
    # Add blank page
    @data.push(nil)
    # Make a bit map and draw all items
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    for i in 0...@item_max-1
      draw_item(i)
    end
  end
end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :styles
  #--------------------------------------------------------------------------
  # * Setup
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  alias styles_setup setup
  def setup(actor_id)
    styles_setup(actor_id)
    @styles = []
    if actor_id == 19
      @styles.push('')
    end
    if actor_id == 20
      @styles.push('')
    end
  end
  
  def meets_requirements?(item)
    if item.str_needed > self.str
      return false
    end
    if item.dex_needed > self.dex
      return false
    end
    if item.int_needed > self.int
      return false
    end
    if item.agi_needed > self.agi
      return false
    end
    if item.lvl_needed > self.level
      return false
    end
    if item.style_needed != ''
      if self.styles == []
        return false
      end
      return self.styles.include?(item.style_needed)
    end
    return true
  end
  
end

class Game_Temp
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias setup initialize
  def initialize
    setup
    for weapon in $data_weapons
      next unless weapon
      weapon.setup_requirements
    end
    for armour in $data_armors
      next unless armour
      armour.setup_requirements
    end
    
  end
  
end

Enemy HP & SP Higher

Use:
1. Credits go to Bearcat for these in my opinion, he tought me 'how-to'.
2. Where "1 => 15000," is, 1 is the EnemyID from the database and 15000 is it's MaxHP/MaxSP. You can leave out the monsters that you define in the database. And, just copy the '2 => 100,' press enter, paste it, make the 2 a 3 to define the monster 3 from the database, etc.
3. Add these two scripts above 'Main' but below the default scripts.

Code:
module Marcel_MaxHP
  MaxHP = {
  1 => 15000,
  2 => 100,
  }
  
end

module RPG
  class Enemy
    alias_method :marcel_maxhp, :maxhp
    def maxhp
      return  Marcel_MaxHP::MaxHP[id] != nil ?
      Marcel_MaxHP::MaxHP[id] : marcel_maxhp
    end
  end
end

Code:
module Marcel_MaxSP
  MaxSP = {
  1 => 15000,
  2 => 100,
  }
  
end

module RPG
  class Enemy
    alias_method :marcel_maxsp, :maxsp
    def maxsp
      return  Marcel_MaxSP::MaxSP[id] != nil ?
      Marcel_MaxSP::MaxSP[id] : marcel_maxsp
    end
  end
end

Cheers~
 
For the last script, (script #1), it's not that hard either. But could you please be more specific? Like; Would you like to display numbers under, above, left or right of the enemy... or would you like to display HP/SP Bars under, above, left or right of the enemy? Or both?
 
HP & SP Bars

Use:
1. I only made a few minor edits for your needs, credits go to SephirothSpawn and Raziel. (Please correct me if I'm wrong, someone.)
2. If you use the default Battle Troops, I think you should move the battlers up in the database. Else it'll screw up in my opinion...
3. Add this script above 'Main' but below the default scripts.

Code:
class Window_Base < Window  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 300, height = 6, 
    bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end


class Window_EnemyHP < Window_Base
  
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    refresh
  end
  
  def refresh
    self.contents.clear
    for i in 0...$game_troop.enemies.size
      @enemy = $game_troop.enemies[i]
      unless @enemy.hidden or @enemy.immortal == true or @enemy.hp == 0
      draw_slant_bar(@enemy.screen_x - 65, @enemy.screen_y - 10, @enemy.hp, @enemy.maxhp, width = 75, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
      draw_slant_bar(@enemy.screen_x - 65, @enemy.screen_y - -5, @enemy.sp, @enemy.maxsp, width = 75, height = 6, bar_color = Color.new(150, 155, 255, 155), end_color = Color.new(130, 120, 255, 100))
    end
  end
end
end

class Scene_Battle
  
  alias raz_update update
  alias raz_update_phase5 update_phase5
  alias raz_update_phase4_step1 update_phase4_step1
  alias raz_update_phase4_step5 update_phase4_step5
  alias raz_enemy_hp_main main
  
   def main
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)       
    @enemy_window = Window_EnemyHP.new
    @enemy_window.z = 95
    raz_enemy_hp_main
    @enemy_window.dispose
  end

  
  def update
    @enemy_window.update
    raz_update
  end

  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        @enemy_window.visible = false
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_window.refresh
      end
      return
    end
   raz_update_phase5
 end

def update_phase4_step1
  raz_update_phase4_step1
  @enemy_window.refresh
end

  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    @enemy_window.refresh
    raz_update_phase4_step5 
  end
end
 

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