#===============================================================================
# Item Gauge
# By Jet10985 (Jet)
#===============================================================================
# This snippet will add an item gauge to your game. Item gauge, meaning that
# items can drain the item gauge, and if players do not have enough energy
# left in the gauge, they cannot use the item.
# This script has: 10 customization options.
#===============================================================================
=begin
How to use:
To increase the max stamina level, you can use this event "Script..." command:
increase_max_item_gauge(actor, amount)
actor = The actor id that you want to raise the item gauge for.
Actor id's start at 0.
amount = the amount you want to increase max item gauge by.
heal_item_gauge(actor, amount)
actor = whos item gauge you want to heal. If you want to heal the entire
party's item gauge, input "all" instead of a number.
amount = how much you want to heal it by. If you want to heal all of it, just put
in a really high number.
=end
module Actor_Item_Gauge
ACTOR_ITEM_GAUGE = [] # Don't touch.
# Below is the specific item gauge level up configuration for each actor.
# You can add 1 for each actor you have. Just follow the format
# shown in each configuration, or look at the comment next to the defaults.
ACTOR_ITEM_GAUGE[0] = [10, 42, 86, 8431] # ACTOR_ITEM_GAUGE[actor_id] = [level 1 amount, level 2 amount, level 3 amount, etc.]
ACTOR_ITEM_GAUGE[1] = [345, 753, 876] # ACTOR_ITEM_GAUGE[actor_id] = [level 1 amount, level 2 amount, level 3 amount, etc.]
ACTOR_ITEM_GAUGE[2] = [435, 535, 765] # ACTOR_ITEM_GAUGE[actor_id] = [level 1 amount, level 2 amount, level 3 amount, etc.]
ACTOR_ITEM_GAUGE[3] = [2093, 7645, 10000, 56382]
# Any unplaced level values will have the last level value
# increased by this number during level up.
BASE_RAISE = 10
# These are what colors the gauge is. Green by default
ITEM_GAUGE_COLOR1 = Color.new(34, 139, 34)
ITEM_GAUGE_COLOR2 = Color.new(0, 128, 0)
# This is the letter that will be shown with the item gauge.
ITEM_ABBREVIATION = "I"
# Will the item gauge be lowered when an item is used from the menu?
LOWER_ITEM_GAUGE_MENU = true
# Recharged everyones item gauge after battle?
REPLENISH_AFTER_BATTLE = false
end
#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
module Jet
def self.check_tag_number(obj, tag)
obj.note.split(/[\r\n]+/).each { |notetag|
case notetag
when tag
@result = $1.to_i
end }
return @result
end
end
module RPG
class BaseItem
def item_cost
if @item_price.nil?
txt = Jet.check_tag_number(self, /<(?:item price)[ ]*(\d+)>/i)
@item_price = txt.nil? ? :unpriced : txt.to_i
end
return @item_price
end
end
end
class Scene_Item
include Actor_Item_Gauge
def determine_target
used = false
if @item.for_all?
for target in $game_party.members
target.item_effect(target, @item)
target.item_gauge_damage += @item.item_cost / $game_party.members.size unless target.skipped || !LOWER_ITEM_GAUGE_MENU || @item.item_cost == :unpriced
used = true unless target.skipped
end
else
$game_party.last_target_index = @target_window.index
target = $game_party.members[@target_window.index]
target.item_effect(target, @item)
target.item_gauge_damage += @item.item_cost unless target.skipped || !LOWER_ITEM_GAUGE_MENU || @item.item_cost == :unpriced
used = true unless target.skipped
end
if used
use_item_nontarget
else
Sound.play_buzzer
end
end
end
class Game_Actor
include Actor_Item_Gauge
attr_accessor :item_gauge_damage
attr_accessor :max_item_gauge_plus
alias jet2891_initialize initialize unless $@
def initialize(*args)
@item_gauge_damage = 0
@max_item_gauge_plus = 0
jet2891_initialize(*args)
end
def item_gauge
return (self.max_item_gauge - self.item_gauge_damage)
end
def max_item_gauge
if self.level >= ACTOR_ITEM_GAUGE[self.id - 1].size
return ACTOR_ITEM_GAUGE[self.id - 1].max + ((self.level - 1 - ACTOR_ITEM_GAUGE[self.id - 1].size) * BASE_RAISE) + @max_item_gauge_plus
end
return ACTOR_ITEM_GAUGE[self.id - 1][self.level - 1] + self.max_item_gauge_plus unless ACTOR_ITEM_GAUGE[self.id - 1].size < self.level
return (self.level * BASE_RAISE)
end
end
class Window_Base
include Actor_Item_Gauge
def item_color(actor)
return crisis_color if actor.item_gauge < actor.max_item_gauge / 4
return normal_color
end
def draw_actor_item(actor, x, y, width = 120)
draw_actor_item_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, WLH, ITEM_ABBREVIATION)
self.contents.font.color = item_color(actor)
last_font_size = self.contents.font.size
xr = x + width
if width < 120
self.contents.draw_text(xr - 44, y, 44, WLH, actor.item_gauge, 2)
else
self.contents.draw_text(xr - 99, y, 44, WLH, actor.item_gauge, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
self.contents.draw_text(xr - 44, y, 44, WLH, actor.max_item_gauge, 2)
end
end
def draw_actor_item_gauge(actor, x, y, width = 120)
gw = width * actor.item_gauge / actor.max_item_gauge
gc1 = ITEM_GAUGE_COLOR1
gc2 = ITEM_GAUGE_COLOR2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
end
class Game_Battler
alias jet6904_item_effect item_effect unless $@
def item_effect(user, item)
unless item.item_cost == :unpriced
if user.item_gauge < item.item_cost
@skipped = true
return
end
end
jet6904_item_effect(user, item)
end
end
class Game_BattleAction
alias jet5367_valid? valid? unless $@
def valid?
return false if item? && item.item_cost != :unpriced && battler.item_gauge < item.item_cost
jet5367_valid?
end
end
class Scene_Battle
include Actor_Item_Gauge
alias jet5932_execute_action_item execute_action_item unless $@
def execute_action_item
item = @active_battler.action.item
@active_battler.item_gauge_damage += item.item_cost unless item.item_cost == :unpriced
jet5932_execute_action_item
end
alias jet7854_terminate terminate unless $@
def terminate
jet7854_terminate
if REPLENISH_AFTER_BATTLE
for i in 0...$game_party.members.size
$game_party.members[i].item_gauge_damage = 0
end
end
end
def update_item_selection
@item_window.active = true
@item_window.update
@help_window.update
if Input.trigger?(Input::B)
Sound.play_cancel
end_item_selection
elsif Input.trigger?(Input::C)
@item = @item_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
if @item.item_cost > @active_battler.item_gauge
Sound.play_buzzer
return
end
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
end
end
end
class Window_MenuStatus
alias jet5902_refresh refresh unless $@
def refresh
jet5902_refresh
for actor in $game_party.members
y = actor.index * 96 + WLH / 2
draw_actor_item(actor, 98, y + WLH * 2)
end
end
end
class Game_Interpreter
def increase_max_item_gauge(actor, amount)
$game_party.members[actor].max_item_gauge_plus += amount
end
def heal_item_gauge(actor, amount)
if actor == "all"
for i in 0...$game_party.members.size
$game_party.members[i].item_gauge_damage -= amount
if $game_party.members[i].item_gauge_damage < 0
$game_party.members[i].item_gauge_damage = 0
end
end
else
$game_party.members[actor].item_gauge_damage -= amount
if $game_party.members[actor].item_gauge_damage < 0
$game_party.members[actor].item_gauge_damage = 0
end
end
end
end
unless $engine_scripts.nil?
JetEngine.active("Item Gauge", "v1")
end