RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Jet's Item Gauge

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 82
Item Gauge

By Jet


Introduction


Spoiler for:
This is my annoying to program item gauge script. I worked on and off on it because i always ran into something wrong. Now though, i have it basically done, and i'm liking it so far. Hope you enjoy it as much as i suffered for it ;)

Features

Spoiler for:
Fully functional Item gauge and limitation
Default looking gauge
Good customization
Easy to use
Cool all together

Script/Demo

Here is a demo demonstrating the features of the Item Gauge (Might be outdated)

Spoiler for:
Code: [Select]
#===============================================================================
# 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

Credit

Jet



********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
You just submitted a few really nice scripts. So you're currently on my favorite persons list. However, what exactly is an Item Gauge? The features don't really explain much as to what it does. :)

**
Rep:
Level 82
=( 2 days later and i barely notice a post.

Basically, it gives an "MP"-like cost to items. Like, it takes 20 points of the item gauge to use a potion. If the character it is used on doesn't have 20 points left, the potion cannot be used on them.



*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
That's a cool idea. Good way to make item use more strategic.
« Last Edit: April 15, 2010, 11:38:44 PM by modern algebra »

*
RMRK's dad
Rep:
Level 86
You know, I think its all gonna be okay.
For going the distance for a balanced breakfast.Project of the Month winner for June 2009For being a noted contributor to the RMRK Wiki2013 Best WriterSilver Writing ReviewerSecret Santa 2013 Participant
That's really cool, I see applications in all kinds of games from traditional RPs to more action-oriented ones. Well done.
:tinysmile:

***
Rep:
Level 77
RMRK Junior
Doesn't work with any Yanfly menu scripts, just so you know.