Ekuipment Points XP
#1
Ekuipment Points XP

by Kyonides

Introduction

Limit the type of weapons or armor pieces your heroes will be able to equip!
If your heroes want to replace their equipment, they better earn enough EP first!
Another way to explain it would be to call it an equipment weight script.

The script lets you set the default and custom EP the actor will start with. The same is valid for weapons and pieces of armor.
Actors can also gain more EP by leveling up.

Inside the EkuipPoints module you can find the WEAPON_POINTS, ARMOR_POINTS, ACTOR_POINTS & the ACTOR_LEVEL_POINTS constants that will let you customize the EP earned by actors and the EP costs of their equipment.

You can also change the X & Y coordinates of windows or EP labels at will.

NOTE

To open the equipment window in battle, during the actor's command phase, press the RM's X button. Normally, it's linked to your A key on the keyboard.

Screenshots

The Script

Code:
# * Ekuipment Points XP * #
#  Not a Plug & Play Script
#  Scripter : Kyonides
#  v1.0.5 - 2025-11-05

# Limit the type of weapons or armor pieces your heroes will be able to equip!
# If heroes want to replace their equipment, they better earn enough EP first!

# * Optional Script Calls * #
# Block a given actor's change equipment feature, especially useful in battle:
#  boolean stands for true OR false only.
#  $game_actors[ActorID].block_equip_change = boolean
#  $game_party.actors[Index].block_equip_change = boolean

# Block the party's change equipment feature at once:
#  $game_party.block_equip_change = boolean

# Increase a given actor's equipment points:
#  $game_actors[ActorID].ep_plus += Number
#  $game_party.actors[Index].ep_plus += Number

module EkuipPoints
  module Colors
    EP_LABEL_COLOR  = [40, 242, 254] # [R,G,B]
    EP_GAUGE_COLOR1 = [0, 0, 0] # [R,G,B]
    EP_GAUGE_COLOR2 = [180, 255, 60] # [R,G,B]
  end

  module Battle
    EQUIP_WIN_X  = 136
    EQUIP_WIN_Y  = 320
    EQUIP_WIN_OPA = 255
    EQUIP_WIN_BACK_OPA = 255
  end
  EP = "EP"
  EP_COST_X = 220
  EP_MENU_XY_W    = [304, 0, 60]
  EP_STATS_XY_W  = [168, 0, 60]
  EP_HELP_XY_WH  = [0, 0, 104, 4]
  EP_STATUS_XY_WH = [320, 112, 120, 6]
  # Define Hashes
  WEAPON_POINTS = {}
  ARMOR_POINTS = {}
  ACTOR_POINTS = {}
  ACTOR_LEVEL_POINTS = {}
  # Set Default Values
  WEAPON_POINTS.default = 1
  ARMOR_POINTS.default = 1
  ACTOR_POINTS.default = 4
  ACTOR_LEVEL_POINTS.default = { :levels => 10, :ep => 1 }
  # [WeaponID] = Points
  WEAPON_POINTS[2] = 2
  WEAPON_POINTS[3] = 4
  WEAPON_POINTS[4] = 6
  # [ArmorID] = Points
  ARMOR_POINTS[2] = 2
  ARMOR_POINTS[3] = 4
  ARMOR_POINTS[4] = 6
  # [ActorID] = BasePoints
  ACTOR_POINTS[1] = 7
  ACTOR_POINTS[7] = 5
  # [ActorID] = { :levels => LevelsNeeded, :ep => ExtraPoints }
  ACTOR_LEVEL_POINTS[1] = { :levels => 8, :ep => 2 }
end

module RPG
  class Equipment
    def ep_cost
      0
    end
  end

  class Weapon
    def ep_cost
      @ep_cost ||= EkuipPoints::WEAPON_POINTS[@id]
    end
  end

  class Armor
    def ep_cost
      @ep_cost ||= EkuipPoints::ARMOR_POINTS[@id]
    end
  end
end

class Game_Actor
  alias :kyon_ekuip_points_gm_act_stp :setup
  alias :kyon_ekuip_points_gm_act_set_exp :exp=
  def setup(actor_id)
    kyon_ekuip_points_gm_act_stp(actor_id)
    @maxep_base = EkuipPoints::ACTOR_POINTS[actor_id]
    hash = EkuipPoints::ACTOR_LEVEL_POINTS[actor_id]
    @base_ep_levels = hash[:levels]
    @base_level_ep = hash[:ep]
    @ep_plus = 0
    calc_level_ep
  end

  def calc_level_ep
    @level_ep = @level / @base_ep_levels * @base_level_ep
  end

  def exp=(new_exp)
    kyon_ekuip_points_gm_act_set_exp(new_exp)
    calc_level_ep
  end

  def maxep
    @maxep_base + @level_ep + @ep_plus
  end

  def armor_ids
    [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
  end

  def equip_ids
    [@weapon_id] + armor_ids
  end

  def get_weapon
    $data_weapons[@weapon_id]
  end

  def get_armors
    armor_ids.map {|armor_id| $data_armors[armor_id] }
  end

  def equip_list
    [get_weapon] + get_armors
  end

  def ep_used
    equip_list.compact.inject(0) {|total, item| total + item.ep_cost }
  end

  def ep_left
    self.maxep - self.ep_used
  end

  def find_equipment(equip_type, equip_id)
    return RPG::Equipment.new if equip_id == 0
    equip_type == 0 ? $data_weapons[equip_id] : $data_armors[equip_id]
  end

  def enough_ep?(equip_type, item)
    return true unless item
    equip_id = equip_ids[equip_type]
    equipment = find_equipment(equip_type, equip_id)
    used = self.ep_used - equipment.ep_cost + item.ep_cost
    return false if used < 0
    self.maxep >= used
  end
  attr_accessor :ep_plus, :block_equip_change
end

class Game_Party
  def block_equip_change=(state)
    @actors.each {|actor| actor.block_equip_change = state }
  end
end

class Window_Base
  include EkuipPoints::Colors
  LH = 32
  def ep_color
    @ep_color ||= Color.new(*EP_LABEL_COLOR)
  end

  def ep_gauge_color1
    @ep_gauge_color1 ||= Color.new(*EP_GAUGE_COLOR1)
  end

  def ep_gauge_color2
    @ep_gauge_color2 ||= Color.new(*EP_GAUGE_COLOR2)
  end

  def draw_ep_left(actor, lx, ly, lw, lh=4, large=nil)
    left = actor.ep_left
    gw = lw * left / actor.maxep
    c = self.contents
    c.fill_rect(lx, ly + LH - lh - 2, lw, lh, ep_gauge_color1)
    c.fill_rect(lx, ly + LH - lh - 2, gw, lh, ep_gauge_color2)
    c.font.color = system_color
    label = EkuipPoints::EP
    c.draw_text(lx, ly, lw, LH, label)
    c.font.color = normal_color
    if large
      c.draw_text(lx, ly, lw / 2 + 12, LH, left.to_s, 2)
      c.draw_text(lx, ly, lw / 2 + 24, LH, "/", 2)
      c.draw_text(lx, ly, lw, LH, actor.maxep.to_s, 2)
    else
      c.draw_text(lx, ly, lw, LH, left.to_s, 2)
    end
  end
end

class Window_Help
  def set_ep(actor)
    self.contents.clear
    ex, ey, ew, eh = EkuipPoints::EP_HELP_XY_WH
    draw_ep_left(actor, ex, ey, ew, eh, true)
    self.visible = true
  end
end

class Window_MenuStatus
  alias :kyon_ekuip_points_win_mnst_refr :refresh
  def refresh
    kyon_ekuip_points_win_mnst_refr
    @actors = $game_party.actors
    total = @actors.size
    total.times {|n| draw_actor_ep_status(n) }
  end

  def draw_actor_ep_status(n)
    actor = @actors[n]
    ex, ey, ew = EkuipPoints::EP_MENU_XY_W
    ex += 64
    ey += n * 116
    draw_ep_left(actor, ex, ey, ew)
  end
end

class Window_EquipLeft
  alias :kyon_ekuip_points_win_eqlft_refr :refresh
  def refresh
    kyon_ekuip_points_win_eqlft_refr
    draw_ep_left(@actor, *EkuipPoints::EP_STATS_XY_W)
  end
end

class Window_EquipRight
  include EkuipPoints::Battle
  alias :kyon_ekuip_points_win_eqrgt_init :initialize
  alias :kyon_ekuip_points_win_eqrgt_refr :refresh
  def initialize(actor)
    if $game_temp.in_battle
      super(EQUIP_WIN_X, EQUIP_WIN_Y, 368, 160)
      setup_window(actor)
    else
      kyon_ekuip_points_win_eqrgt_init(actor)
    end
  end

  def setup_window(actor)
    self.z = 1000
    self.opacity = EQUIP_WIN_OPA
    self.back_opacity = EQUIP_WIN_BACK_OPA
    self.contents = Bitmap.new(width - 32, height)
    @actor = actor
    refresh
    self.index = 0
  end

  def refresh
    kyon_ekuip_points_win_eqrgt_refr
    @data.size.times {|n| draw_equip_ep(n) }
  end

  def draw_equip_ep(n)
    item = @data[n]
    return unless item
    self.contents.font.color = ep_color
    number = sprintf("%2d", item.ep_cost)
    self.contents.draw_text(0, n * LH, width - 32, LH, number, 2)
  end
end

class Window_EquipItem
  def set_battle_coord
    self.x = 0
    self.y = 64
    self.z = 1000
  end

  def reset_index
    self.index = 0 if @index < 0
  end

  def enable?(item)
    @actor.enough_ep?(@equip_type, item)
  end

  def equip_type=(type)
    @equip_type = type
    refresh
  end

  def draw_item(index)
    item = @data[index]
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    case item
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    enabled = enable?(item)
    color = enabled ? normal_color : disabled_color
    font = self.contents.font
    font.color = color
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
    font.color = ep_color
    font.color.alpha = 160 unless enabled
    rect = Rect.new(x + EkuipPoints::EP_COST_X, y, 16, 32)
    number = item.ep_cost
    self.contents.draw_text(rect, sprintf("%2d", number), 2)
    font.color.alpha = 255 unless enabled
  end
end

class Window_Status
  alias :kyon_ekuip_points_win_st_refr :refresh
  def refresh
    kyon_ekuip_points_win_st_refr
    ex, ey, ew, eh = EkuipPoints::EP_STATUS_XY_WH
    draw_ep_left(@actor, ex, ey, ew, eh, true)
  end
end

class Scene_Equip
  alias :kyon_ekuip_points_scn_eqp_up_item :update_item
  def item_windows
    [@item_window1, @item_window2, @item_window3, @item_window4, @item_window5]
  end

  def update_item
    if Input.trigger?(Input::C)
      item = @item_window.item
      if item and !@actor.enough_ep?(@right_window.index, item)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
    end
    kyon_ekuip_points_scn_eqp_up_item
    if Input.trigger?(Input::C)
      windows = item_windows
      windows.delete_at(@right_window.index)
      windows.each {|window| window.refresh }
    end
  end
end

class Scene_Battle
  alias :kyon_ekuip_points_scn_btl_up_ph3 :update_phase3
  alias :kyon_ekuip_points_scn_btl_up_ph3_bsc_cmd :update_phase3_basic_command
  def update_phase3
    kyon_ekuip_points_scn_btl_up_ph3
    return unless @equip_item
    update_phase3_equipment
  end

  def update_phase3_equipment
    case @equip_index
    when 0
      update_equip_type
    when 1
      update_equip_list
    end
  end

  def update_phase3_basic_command
    kyon_ekuip_points_scn_btl_up_ph3_bsc_cmd
    if Input.trigger?(Input::X)
      create_equipment_windows
    end
  end

  def create_equipment_windows
    if @active_battler.block_equip_change
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    $game_system.se_play($data_system.decision_se)
    @help_window.set_ep(@active_battler)
    @equip_window = Window_EquipRight.new(@active_battler)
    @equip_item_window = Window_EquipItem.new(@active_battler, 0)
    @equip_item_window.set_battle_coord
    @equip_windows = [@equip_window, @equip_item_window]
    @actor_command_window.active = false
    @equip_index = 0
    @equip_item = true
  end

  def dispose_equipment_windows
    $game_system.se_play($data_system.cancel_se)
    @equip_windows.each {|window| window.dispose }
    @actor_command_window.active = true
    @help_window.visible = false
    @equip_item = false
  end

  def refresh_equip_type
    @equip_item_window.equip_type = @equip_window.index
    @equip_item_window.index = 0
  end

  def update_equip_type
    @equip_window.update
    if Input.trigger?(Input::B)
      dispose_equipment_windows
      return
    elsif Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @equip_item_window.active = true
      @equip_window.active = false
      @equip_item_window.reset_index
      return @equip_index = 1
    elsif Input.trigger?(Input::DOWN)
      refresh_equip_type
      return
    elsif Input.trigger?(Input::UP)
      refresh_equip_type
    end
  end

  def back_to_main_equip
    @help_window.set_ep(@active_battler)
    @equip_item_window.active = false
    @equip_window.active = true
    @equip_index = 0
  end

  def update_equip_list
    @equip_item_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @equip_item_window.index = -1
      back_to_main_equip
      return
    elsif Input.trigger?(Input::C)
      pos = @equip_window.index
      item = @equip_item_window.item
      if item and !@active_battler.enough_ep?(pos, item)
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.equip_se)
      item_id = item ? item.id : 0
      @active_battler.equip(@equip_window.index, item_id)
      @equip_item_window.refresh
      @equip_window.refresh
      back_to_main_equip
    end
  end
end


Terms & Conditions

Free as in Beer beer for non-commercial use.
Include me in your game credits! Grinning
That's it! Tongue sticking out
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
   DerVV's Actor Stat Points Distributor DerVVulfman 0 2,307 07-16-2024, 04:46 AM
Last Post: DerVVulfman
   Advanced Battle Points Trickster 0 7,353 03-01-2008, 04:53 AM
Last Post: Trickster



Users browsing this thread: 1 Guest(s)