Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Battle Item Count VX
#1
Battle Item Count VX

by Kyonides

Introduction

Thinking Do you need to update the number of potions or elixirs currently available for the next couple of actors during battle?
Confused 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! Grinning

The Script

Code:
# * Battle Item Count VX * #
#   Plug & Play Script
#   Scripter : Kyonides Arkanthes
#   2023-11-17

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

class Game_Temp
  alias :kyon_btl_itm_cnt_gm_tmp_init :initialize
  def initialize
    kyon_btl_itm_cnt_gm_tmp_init
    @item_count = {}
    @item_count.default = 0
  end

  def clear_item_count
    @item_count.clear
  end

  def add_item_count(item)
    @item_count[item.id] += 1
  end

  def reduce_item_count(item)
    item_id = item.id
    @item_count[item_id] -= 1 if @item_count[item_id] > 0
  end
  attr_reader :item_count
end

class Game_Party
  alias :kyon_btl_itm_cnt_itm_nmbr :item_number
  def item_number(item)
    n = kyon_btl_itm_cnt_itm_nmbr(item) - $game_temp.item_count[item.id]
    [n, 0].max
  end
end

class Scene_Battle
  alias :kyon_btl_itm_cnt_scn_btl_term :terminate
  alias :kyon_btl_itm_cnt_scn_btl_st_pty_cmd_sel :start_party_command_selection
  alias :kyon_btl_itm_cnt_scn_btl_prr_act :prior_actor
  def terminate
    kyon_btl_itm_cnt_scn_btl_term
    $game_temp.clear_item_count
  end

  def start_party_command_selection
    kyon_btl_itm_cnt_scn_btl_st_pty_cmd_sel
    $game_temp.clear_item_count
  end

  def temp_decrease_item_count
    return unless @active_battler
    action = @active_battler.action
    return unless action and action.item?
    item = $data_items[action.item_id]
    $game_temp.reduce_item_count(item) if item
  end

  def temp_increase_item_count
    $game_temp.add_item_count(@item) if @item
  end

  def prior_actor
    kyon_btl_itm_cnt_scn_btl_prr_act
    temp_decrease_item_count
  end

  def update_item_selection
    @item_window.active = true
    @item_window.update
    @help_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      temp_decrease_item_count
      end_item_selection
    elsif Input.trigger?(Input::C)
      @item = @item_window.item
      $game_party.last_item_id = @item.id if @item
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        temp_increase_item_count
        determine_item
      else
        Sound.play_buzzer
      end
    end
  end
end

Terms & Conditions

Free for use in ANY game. Gamer
Due credit is mandatory. Serious
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
   Fast Item Grouping DerVVulfman 1 2,032 06-12-2023, 05:28 PM
Last Post: DerVVulfman
   Dalissa's Battle Cry DerVVulfman 2 5,925 05-09-2023, 03:07 AM
Last Post: DerVVulfman
   Zenith Tactical Battle System Plus (ZTBS+) DerVVulfman 0 1,498 05-10-2022, 10:42 PM
Last Post: DerVVulfman
   DoubleX RMMZ Skill Item Cooldown DoubleX 4 4,548 02-07-2021, 04:11 PM
Last Post: DoubleX
   DoubleX RMMZ Skill Item Triggers DoubleX 3 4,123 12-26-2020, 04:00 PM
Last Post: DoubleX
   Actor Battle Items DerVVulfman 4 4,264 11-08-2020, 12:36 PM
Last Post: Melana
   Centi-Second Wait Count DerVVulfman 5 4,983 09-12-2020, 04:07 AM
Last Post: DerVVulfman
   Battle Report Raziel 1 5,879 05-29-2020, 02:27 AM
Last Post: Whisper
   ZLSL's Battle Portraits DerVVulfman 4 5,792 11-12-2019, 04:10 AM
Last Post: DerVVulfman
   DoubleX RMMV Unison Item Compatibility DoubleX 0 2,585 09-09-2019, 11:45 AM
Last Post: DoubleX



Users browsing this thread: