じ☆ve冰风 发表于 2026-7-24 18:16:37

Battle Item Count XP

Battle Item Count XP

by Kyonides​

Introduction

Do you need to update the number of potions or elixirs currently available for the next couple of actors during battle?
Or were you in need of canceling your previous actor's action to change the item the actor is going to consume next?
Then this scriptlet is for you!


                Ruby:       
# * Battle Item Count XP * #
#   Plug & Play Script
#   Scripter : Kyonides Arkanthes
#   v1.0.4 - 2024-02-03

# The scriptlet updates the number of available items every single time you pick
# one or go back to the prior actor in battle.

# Warning: Overwritten Method Window_Item#draw_item

class Game_Party
def clear_battle_items
    @actors.each {|m| m.current_action.clear }
end

def actors_battle_items
    @actors.map {|m| m.current_action.item_id }
end

def battle_item_number(item_id)
    return item_number(item_id) unless $game_temp.in_battle
    battle_items = actors_battle_items.select {|bit_id| item_id == bit_id }
    item_number(item_id) - battle_items.size
end
end

class Window_Item
alias :kyon_btl_itm_cnt_win_itm_ref :refresh
def refresh
    @battle_items = {}
    @battle_items.default = 99
    kyon_btl_itm_cnt_win_itm_ref
end

def find_number(item_id)
    case item
    when RPG::Item
      $game_party.battle_item_number(item_id)
    when RPG::Weapon
      $game_party.weapon_number(item_id)
    when RPG::Armor
      $game_party.armor_number(item_id)
    end
end

def enable?(item)
    return unless item.is_a?(RPG::Item)
    $game_party.item_can_use?(item.id) and @battle_items > 0
end

def draw_item(index)
    item = @data
    number = find_number(item.id)
    @battle_items = number
    enabled = enable?(item)
    self.contents.font.color = enabled ? normal_color : disabled_color
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = enabled ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    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)
end

def battle_item_none?
    @battle_items == 0
end
end

class Scene_Battle
alias :kyon_btl_itm_cnt_scn_btl_ph3_prr_act :phase3_prior_actor
alias :kyon_btl_itm_cnt_scn_btl_up_ph3_itm_sel :update_phase3_item_select
def turn_decrease_item_count
    @active_battler.current_action.clear if @active_battler
end

def phase3_prior_actor
    turn_decrease_item_count
    kyon_btl_itm_cnt_scn_btl_ph3_prr_act
    turn_decrease_item_count
end

def update_phase3_item_select
    if Input.trigger?(Input::C) and @item_window.battle_item_none?
      return $game_system.se_play($data_system.buzzer_se)
    end
    kyon_btl_itm_cnt_scn_btl_up_ph3_itm_sel
end
end


Terms & Conditions

Free for use in ANY game.
Due credit is mandatory.
That's it!



本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/battle-item-count-xp.165436/
页: [1]
查看完整版本: Battle Item Count XP