Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Yanfly Engine RD - Custom Item Abilities
- # Last Date Updated: 2009.06.24
- # Level: Easy, Normal, Hard, Lunatic
- #
- # Usable items have generally been a very neglected part of many RPG Maker
- # games due to the complete and utter lack of flavour they deliver to the game.
- # This script allows you to give items a few more abilities than what they
- # originally had and restores a few of the lost RPG Maker 2000/2003 features.
- #
- # - Item charges. Use items a certain number of times before they're consumed.
- # - Variable and Switch adjustment. Rather than doing it with common events,
- # do it straight from the menu without kicking the player out of the menu.
- # - Unique item effects. Different actors and different classes can produce
- # different effects from the same item depending on who is using them.
- # - Some actors and classes are unable to use particular items. This is another
- # feature reclaimed from older RPG Makers.
- # - Some items will not have any effects on certain actors, classes, or enemies.
- #
- # - Custom effects for lunatic scripters. These effects can happen before the
- # item is used, consuming the item, or after the item is used.
- #
- #===============================================================================
- # Updates:
- # ----------------------------------------------------------------------------
- # o 2009.06.24 - Finished script.
- # o 2009.06.21 - Started script.
- #===============================================================================
- # Instructions
- #===============================================================================
- #
- # These tags go into item noteboxes within the database.
- #
- # <item charges x>
- # This will allow items to be used x times before they are consumed. This was
- # originally a feature that came from RPG Maker 2000 and RPG Maker 2003. The
- # default charge is 1. Use x to deliver charges higher than 1 to have an effect.
- #
- # ----------------------------------------------------------------------------
- #
- # <variable x +y> or <variable x -y>
- # This causes the item to change variable x by y amount when used. This can
- # will be activated both in battle and out of battle.
- #
- # <switch x on> or <switch x off> or <toggle switch x>
- # This will cause switch x to be turned on or off. If you use the toggle tag,
- # switch x will turn off if it was originally on and vice versa.
- #
- # ----------------------------------------------------------------------------
- #
- # The following will affect whether or not an item can be used by different
- # actors inside battle. This is a feature that was originally taken out of
- # RPG Maker 2000 and RPG Maker 2003.
- #
- # <pharmacology only>
- # Only actors with pharmacology will be able to use this item. If the actor
- # does not possess the pharmacology trait by either innate, class trait, or
- # from a status effect, the item cannot be used.
- #
- # <unusable actor x> or <unusable actor x,x>
- # <unusable class x> or <unusable class x,x>
- # This will cause the listed actors and classes to be unable to use the said
- # items. Items that cannot be used will not appear for them in battle when the
- # "item" command is selected.
- #
- # ----------------------------------------------------------------------------
- #
- # <null actor x> or <null actor x,x>
- # <null class x> or <null class x,x>
- # <null enemy x> or <null enemy x,x>
- # This will cause the item to have no effect on the specified actors, classes,
- # or enemies. The items will still be used, but nothing else will change on
- # that target and the game will go on as if nothing happened.
- #
- # ----------------------------------------------------------------------------
- #
- # The following will only occur in battle as it's calculated by individual use
- # rather than party-wide use. These effects will change the item's effects into
- # a skill's effects if conditions are met.
- #
- # <pharmacology effect x>
- # This will cause the item to cast a skill instead of using the typical item
- # effect. This will only trigger if the actor using the skill has the
- # pharmacology trait and this will override any of the below tags if they're
- # to be used together.
- #
- # <actor effect y> or <actor effect x:y>
- # This will cause the item to cast a skill instead of using the typical item
- # effect. The skill used will be y. If you use the second tag, it will cause
- # different actors to use different skills when using that particular item. x
- # will determine which actor will use skill y. If x is 0, that skill becomes
- # the universal skill for unlisted actors.
- #
- # <class effect y> or <class effect x:y>
- # This will cause the item to cast a skill instead of using the typical item
- # effect. The skill used will be y. If you use the second tag, it will cause
- # different classes to use different skills when using that particular item. x
- # will determine which class will use skill y. If x is 0, that skill becomes
- # the universal skill for unlisted classes.
- #
- #===============================================================================
- #
- # Compatibility
- # - Works With: Yanfly Custom Skill Effects, Scene Battle ReDux
- # - Works With: KGC's Usable Equipment
- # - Alias: Game_Battler: item_effective?
- # - Alias: Game_Party: consume_item
- # - Alias: Scene_Item: use_item_nontarget
- # - Alias: Window_Item: refresh
- # - Overwrites: Game_Party: item_can_use?
- # - Overwrites: Scene_Battle: execute_action_item
- # - Overwrites: Window_Item: draw_item
- #
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["CustomItemAbilities"] = true
- module YE
- module ITEM
- # This will change the way item text is displayed in battle.
- USE_ITEM = "%s uses %s!"
- # This is how the amount of an item is drawn in menus.
- DRAW_ITEM = "×%2d"
- # If this is set to true, it will name the item used along with the
- # name of the skill produced by the item if the item has a skill effect.
- SHOW_SKILL_EFFECT = true
- # This adjusts the size of the item charges displayed in the item window.
- # Items will only display this if they have the <item charge x> tag.
- CHARGE_SIZE = 14
- CHARGE_BOLD = true
- end # ITEM
- end # YE
- #===============================================================================
- # How to Use: Lunatic Mode
- #===============================================================================
- #
- # <usage effect x>
- # Usage effects will occur before the item is used. In a way, this is the
- # preparation step for items. Find "def effect_usage" to begin adding in your
- # own custom usage effects. "def common_usage" will have usage effects that
- # will occur for all items regardless of UIE tagging.
- #
- # <consume effect x>
- # Consume effects will only occur when the item is consumed. This means that if
- # an item has more than 1 charges left or the item isn't consumable, this will
- # not trigger. Find "def effect_consume" to begin adding in your own custom
- # consume effects. "def common_consume" will have consume effects that will
- # occur whenever an item is consumed regardless of CIE tagging.
- #
- # <finish effect x>
- # Finish effects will only occur when the item is finished being used. This will
- # pretty much at the end of the turn. Find "def effect_finish" to begin adding
- # in your own custom finish effects. "def common_finish" will have finish
- # effects that will occur whenever an item is finished being used regardless of
- # FIE tagging.
- #
- #===============================================================================
- class Scene_Battle < Scene_Base
- def effect_usage(item, usageitem)
- line_number = @message_window.line_number
- case usageitem
- #---------------------------------------------------------------------------
- # //////////////////////////////////////////////////////////////////////////
- # This is where you begin adding in your own item usage effects.
- #---------------------------------------------------------------------------
- when 1
- # Active Battler will recover MP equal to Active Battler's Level
- @active_battler.mp += @active_battler.level
- when 2
- # Active Battler will recover HP equal to Active Battler's Level
- @active_battler.hp += @active_battler.level
- when 3
- #---------------------------------------------------------------------------
- # This is the part you guys shouldn't touch afterwards.
- # //////////////////////////////////////////////////////////////////////////
- #---------------------------------------------------------------------------
- end
- end
- #-----------------------------------------------------------------------------
- #-----This is the common usage effect. It'll occur regardless of UIE tagging.
- def common_usage(item)
- end
- #-----------------------------------------------------------------------------
- def effect_consume(item, consumeitem)
- line_number = @message_window.line_number
- case consumeitem
- #---------------------------------------------------------------------------
- # //////////////////////////////////////////////////////////////////////////
- # This is where you begin adding in your own item finish effects.
- #---------------------------------------------------------------------------
- when 1
- # Party will recover to full health when the item is consumed
- for member in $game_party.existing_members
- member.hp = member.maxhp
- end
- when 2
- #---------------------------------------------------------------------------
- # This is the part you guys shouldn't touch afterwards.
- # //////////////////////////////////////////////////////////////////////////
- #---------------------------------------------------------------------------
- end
- end
- #-----------------------------------------------------------------------------
- #-----This is the common consume effect. It'll occur regardless of CIE tagging.
- def common_consume(item)
- end
- #-----------------------------------------------------------------------------
- def effect_finish(item, finishitem)
- line_number = @message_window.line_number
- case finishitem
- #---------------------------------------------------------------------------
- # //////////////////////////////////////////////////////////////////////////
- # This is where you begin adding in your own item finish effects.
- #---------------------------------------------------------------------------
- when 1
- # Active Battler will recover HP equal to Active Battler's Level
- @active_battler.hp += @active_battler.level
- when 2
- # Active Battler will recover MP equal to Active Battler's Level
- @active_battler.mp += @active_battler.level
- when 3
- #---------------------------------------------------------------------------
- # This is the part you guys shouldn't touch afterwards.
- # //////////////////////////////////////////////////////////////////////////
- #---------------------------------------------------------------------------
- end
- end
- #-----------------------------------------------------------------------------
- #-----This is the common finish effect. It'll occur regardless of FIE tagging.
- def common_finish(item)
- end
- #-----------------------------------------------------------------------------
- end # Scene_Battle
- #===============================================================================
- # Editting anything past this point may potentially result in causing computer
- # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
- # Therefore, edit at your own risk.
- #===============================================================================
- module YE
- module REGEXP
- module BASEITEM
- # Item Charges
- ITEM_CHARGES = /<(?:ITEM_CHARGES|item charges)[ ]*(\d+)>/i
- # Variable and Switch Changes
- CHANGE_VARIABLE = /<(?:CHANGE_VARIABLE|variable)[ ]*(\d+)[ ]([\+\-]\d+)>/i
- CHANGE_SWITCH = /<(?:CHANGE_SWITCH|switch)[ ]*(\d+)[ ](.*)>/i
- TOGGLE_SWITCH = /<(?:TOGGLE_SWITCH|toggle switch)[ ]*(\d+)>/i
- # Skill Effects for Items
- PHARMACOLOGY_EFFECT = /<(?:PHARMACOLOGY_EFFECT|pharmacology effect)[ ]*(\d+)>/i
- ACTOR_EFFECT = /<(?:ACTOR_EFFECT|actor effect)[ ]*(\d+)>/i
- ACTOR_EFFECT_MULTI = /<(?:ACTOR_EFFECT|actor effect)[ ]*(\d+):(\d+)>/i
- CLASS_EFFECT = /<(?:CLASS_EFFECT|class effect)[ ]*(\d+)>/i
- CLASS_EFFECT_MULTI = /<(?:CLASS_EFFECT|class effect)[ ]*(\d+):(\d+)>/i
- # Null Effects for Items
- NULL_ACTOR = /<(?:NULL_ACTOR|null actor)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- NULL_CLASS = /<(?:NULL_CLASS|null class)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- NULL_ENEMY = /<(?:NULL_ENEMY|null enemy)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- # Unusable Actors and Classes
- PHARMACOLOGY_ONLY = /<(?:PHARMACOLOGY_ONLY|pharmacology only)>/i
- UNUSABLE_ACTOR = /<(?:UNUSABLE_ACTOR|unusable actor)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- UNUSABLE_CLASS = /<(?:UNUSABLE_CLASS|unusable class)[ ]*(\d+(?:\s*,\s*\d+)*)>/i
- # Lunatic Effects
- USAGE_EFFECT = /<(?:USAGE_EFFECT|usage effect|effect usage)[ ]*(\d+)>/i
- CONSUME_EFFECT = /<(?:CONSUME_EFFECT|consume effect|effect consume)[ ]*(\d+)>/i
- FINISH_EFFECT = /<(?:FINISH_EFFECT|finish effect|effect finish)[ ]*(\d+)>/i
- end # BASEITEM
- end # REGEXP
- end # YE
- module Vocab
- UseItem = YE::ITEM::USE_ITEM
- end # Vocab
- #===============================================================================
- # RPG::BaseItem
- #===============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # Yanfly_Cache_BaseItem_CIA
- #--------------------------------------------------------------------------
- def yanfly_cache_baseitem_cia
- @uie = 0; @cie = 0; @fie = 0
- @change_var_id = 0; @change_var_amt = 0; @toggle_switch = 0
- @change_switch_id = 0; @change_switch_flag = false; @pharma_effect = 0
- @item_skill_effect = false; @unusable_actor = []; @unusuable_class = []
- @actor_effect = {}; @class_effect = {}; @pharma_only = false
- @item_charges = 1; @null_actor = []; @null_class = []; @null_enemy = []
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when YE::REGEXP::BASEITEM::USAGE_EFFECT
- @uie = $1.to_i
- when YE::REGEXP::BASEITEM::CONSUME_EFFECT
- @cie = $1.to_i
- when YE::REGEXP::BASEITEM::FINISH_EFFECT
- @fie = $1.to_i
- when YE::REGEXP::BASEITEM::ITEM_CHARGES
- @item_charges = $1.to_i
- when YE::REGEXP::BASEITEM::CHANGE_VARIABLE
- @change_var_id = $1.to_i
- @change_var_amt = $2.to_i
- when YE::REGEXP::BASEITEM::CHANGE_SWITCH
- @change_switch_id = $1.to_i
- case $2.to_s
- when "true", "TRUE", "True", "on", "ON", "On"
- @change_switch_flag = true
- else
- @change_switch_flag = false
- end
- when YE::REGEXP::BASEITEM::TOGGLE_SWITCH
- @toggle_switch = $1.to_i
- when YE::REGEXP::BASEITEM::NULL_ACTOR
- $1.scan(/\d+/).each { |num|
- if num.to_i > 0
- @null_actor.push(num.to_i)
- end }
- when YE::REGEXP::BASEITEM::NULL_CLASS
- $1.scan(/\d+/).each { |num|
- if num.to_i > 0
- @null_class.push(num.to_i)
- end }
- when YE::REGEXP::BASEITEM::NULL_ENEMY
- $1.scan(/\d+/).each { |num|
- if num.to_i > 0
- @null_enemy.push(num.to_i)
- end }
- when YE::REGEXP::BASEITEM::PHARMACOLOGY_ONLY
- @pharma_only = true
- when YE::REGEXP::BASEITEM::UNUSABLE_ACTOR
- $1.scan(/\d+/).each { |num|
- if num.to_i > 0
- @unusable_actor.push(num.to_i)
- end }
- when YE::REGEXP::BASEITEM::UNUSABLE_CLASS
- $1.scan(/\d+/).each { |num|
- if num.to_i > 0
- @unusuable_class.push(num.to_i)
- end }
- when YE::REGEXP::BASEITEM::PHARMACOLOGY_EFFECT
- @pharma_effect = $1.to_i
- @item_skill_effect = true
- when YE::REGEXP::BASEITEM::ACTOR_EFFECT
- @actor_effect[0] = $1.to_i
- @item_skill_effect = true
- when YE::REGEXP::BASEITEM::ACTOR_EFFECT_MULTI
- @actor_effect[0] = $2.to_i if @actor_effect[0] == nil
- @actor_effect[$1.to_i] = $2.to_i
- @item_skill_effect = true
- when YE::REGEXP::BASEITEM::CLASS_EFFECT
- @class_effect[0] = $1.to_i
- @item_skill_effect = true
- when YE::REGEXP::BASEITEM::CLASS_EFFECT_MULTI
- @class_effect[0] = $2.to_i if @class_effect[0] == nil
- @class_effect[$1.to_i] = $2.to_i
- @item_skill_effect = true
- end
- }
- end
- #--------------------------------------------------------------------------
- # definitions - misc
- #--------------------------------------------------------------------------
- def uie
- yanfly_cache_baseitem_cia if @uie == nil
- return @uie
- end
- def cie
- yanfly_cache_baseitem_cia if @cie == nil
- return @cie
- end
- def fie
- yanfly_cache_baseitem_cia if @fie == nil
- return @fie
- end
- def item_charges
- yanfly_cache_baseitem_cia if @item_charges == nil
- return @item_charges
- end
- #--------------------------------------------------------------------------
- # definitions - variables and switches
- #--------------------------------------------------------------------------
- def change_var_id
- yanfly_cache_baseitem_cia if @change_var_id == nil
- return @change_var_id
- end
- def change_var_amt
- yanfly_cache_baseitem_cia if @change_var_amt == nil
- return @change_var_amt
- end
- def change_switch_id
- yanfly_cache_baseitem_cia if @change_switch_id == nil
- return @change_switch_id
- end
- def change_switch_flag
- yanfly_cache_baseitem_cia if @change_switch_flag == nil
- return @change_switch_flag
- end
- def toggle_switch
- yanfly_cache_baseitem_cia if @toggle_switch == nil
- return @toggle_switch
- end
- #--------------------------------------------------------------------------
- # definitions - null/unusuable
- #--------------------------------------------------------------------------
- def null_actor
- yanfly_cache_baseitem_cia if @null_actor == nil
- return @null_actor
- end
- def null_class
- yanfly_cache_baseitem_cia if @null_class == nil
- return @null_class
- end
- def null_enemy
- yanfly_cache_baseitem_cia if @null_enemy == nil
- return @null_enemy
- end
- def pharma_only
- yanfly_cache_baseitem_cia if @pharma_only == nil
- return @pharma_only
- end
- def unusuable_actor
- yanfly_cache_baseitem_cia if @unusable_actor == nil
- return @unusable_actor
- end
- def unusuable_class
- yanfly_cache_baseitem_cia if @unusable_class == nil
- return @unusable_class
- end
- #--------------------------------------------------------------------------
- # definitions - item/skill effects
- #--------------------------------------------------------------------------
- def item_skill_effect
- yanfly_cache_baseitem_cia if @item_skill_effect == nil
- return @item_skill_effect
- end
- def pharma_effect
- yanfly_cache_baseitem_cia if @pharma_effect == nil
- return @pharma_effect
- end
- def actor_effect
- yanfly_cache_baseitem_cia if @actor_effect == nil
- return @actor_effect
- end
- def class_effect
- yanfly_cache_baseitem_cia if @class_effect == nil
- return @class_effect
- end
- end # RPG::BaseItem
- #==============================================================================
- # Game_Temp
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :refreshing_cia
- end # Game_Temp
- #===============================================================================
- # Game_Battler
- #===============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # alias item_effective?
- #--------------------------------------------------------------------------
- alias item_effective_cia item_effective?
- def item_effective?(user, item)
- return false if null_effect?(item)
- return item_effective_cia(user, item)
- end
- #--------------------------------------------------------------------------
- # null_effect?
- #--------------------------------------------------------------------------
- def null_effect?(item)
- if self.actor?
- return true if item.null_actor.include?(self.id)
- return true if item.null_class.include?(self.class_id)
- else
- return true if item.null_enemy.include?(self.enemy_id)
- end
- return false
- end
- end # Game_Battler
- #===============================================================================
- # Game_Party
- #===============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # overwrite item_can_use?
- #--------------------------------------------------------------------------
- def item_can_use?(item)
- return false if !item.is_a?(RPG::Item) and !$imported["UsableEquipment"]
- return false if item_number(item) == 0
- return false unless actor_can_use(item)
- return $game_temp.in_battle ? item.battle_ok? : item.menu_ok?
- end
- #--------------------------------------------------------------------------
- # actor_can_use
- #--------------------------------------------------------------------------
- def actor_can_use(item)
- return true unless $game_temp.in_battle
- return true if $game_temp.refreshing_cia
- if item.pharma_only
- return false unless $scene.active_battler.pharmacology
- end
- if item.unusuable_actor != []
- actor_id = $scene.active_battler.id
- return false if item.unusuable_actor.include?(actor_id)
- end
- if item.unusuable_class != []
- class_id = $scene.active_battler.class_id
- return false if item.unusuable_actor.include?(class_id)
- end
- return true
- end
- #--------------------------------------------------------------------------
- # alias consume_item
- #--------------------------------------------------------------------------
- alias consume_item_cia consume_item unless $@
- def consume_item(item)
- if item.is_a?(RPG::Item) and item.item_charges > 1 and item.consumable
- if self.item_charges[item.id] == nil
- self.item_charges[item.id] = item.item_charges
- end
- if self.item_charges[item.id] > 1
- self.item_charges[item.id] -= 1
- else
- self.item_charges[item.id] = item.item_charges
- consume_item_cia(item)
- end
- else
- consume_item_cia(item)
- end
- end
- #--------------------------------------------------------------------------
- # item_charges
- #--------------------------------------------------------------------------
- def item_charges
- @item_charges = {} if @item_charges == nil
- return @item_charges
- end
- end # Game_Party
- #===============================================================================
- # Scene_Battle
- #===============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # overwrite execute_action_item
- #--------------------------------------------------------------------------
- def execute_action_item
- item = @active_battler.action.item
- item_variable_and_switch_changes(item)
- if item.item_skill_effect == true
- perform_item_skill_effect(item)
- else
- use_the_item(item)
- end
- end
- #--------------------------------------------------------------------------
- # item_variable_and_switch_changes
- #--------------------------------------------------------------------------
- def item_variable_and_switch_changes(item)
- if item.change_var_id > 0
- $game_variables[item.change_var_id] += item.change_var_amt
- end
- if item.change_switch_id > 0
- $game_switches[item.change_switch_id] = item.change_switch_flag
- end
- if item.toggle_switch > 0
- if $game_switches[item.toggle_switch]
- $game_switches[item.toggle_switch] = false
- else
- $game_switches[item.toggle_switch] = true
- end
- end
- end
- #--------------------------------------------------------------------------
- # consume_item
- #--------------------------------------------------------------------------
- def consume_item(item)
- amount = $game_party.item_number(item)
- $game_party.consume_item(item)
- if $game_party.item_number(item) < amount
- effect_consume(item, item.cie) if item.uie > 0
- common_consume(item)
- end
- end
- #--------------------------------------------------------------------------
- # perform_item_skill_effect
- #--------------------------------------------------------------------------
- def perform_item_skill_effect(item)
- if item.pharma_effect > 0 and @active_battler.pharmacology
- skill_id = item.pharma_effect
- elsif item.actor_effect.include?(@active_battler.id)
- skill_id = item.actor_effect[@active_battler.id]
- elsif item.class_effect.include?(@active_battler.class_id)
- skill_id = item.class_effect[@active_battler.class_id]
- elsif item.actor_effect[0] != nil
- skill_id = item.actor_effect[0]
- elsif item.class_effect[0] != nil
- skill_id = item.class_effect[0]
- else
- use_the_item(item)
- return
- end
- if $imported["SceneBattleReDux"] and YE::REDUX::BATTLE::MSG_CURRENT_ACTION
- text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
- @message_window.add_instant_text(text) if YE::ITEM::SHOW_SKILL_EFFECT
- end
- effect_usage(item, item.uie) if item.uie > 0
- common_usage(item)
- consume_item(item)
- @active_battler.action.set_skill(skill_id)
- execute_action_skill
- effect_finish(item, item.fie) if item.fie > 0
- common_finish(item)
- $game_temp.common_event_id = item.common_event_id
- end
- #--------------------------------------------------------------------------
- # use_the_item
- #--------------------------------------------------------------------------
- def use_the_item(item)
- if $imported["SceneBattleReDux"] and YE::REDUX::BATTLE::MSG_CURRENT_ACTION
- text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
- @message_window.add_instant_text(text)
- end
- effect_usage(item, item.uie) if item.uie > 0
- common_usage(item)
- targets = @active_battler.action.make_targets
- if $imported["CustomSkillEffects"] and item.csa > 0
- custom_ani(targets, skill.csa)
- else
- display_animation(targets, item.animation_id)
- end
- consume_item(item)
- for target in targets
- target.item_effect(@active_battler, item)
- display_action_effects(target, item)
- end
- effect_finish(item, item.fie) if item.fie > 0
- common_finish(item)
- $game_temp.common_event_id = item.common_event_id
- end
- #--------------------------------------------------------------------------
- # return active battler
- #--------------------------------------------------------------------------
- def active_battler
- return @active_battler
- end
- end # Scene_Battle
- #===============================================================================
- # Scene_Item
- #===============================================================================
- class Scene_Item < Scene_Base
- #--------------------------------------------------------------------------
- # alias use_item_nontarget
- #--------------------------------------------------------------------------
- alias use_item_nontarget_cia use_item_nontarget unless $@
- def use_item_nontarget
- if @item.change_var_id > 0
- $game_variables[@item.change_var_id] += @item.change_var_amt
- end
- if @item.change_switch_id > 0
- $game_switches[@item.change_switch_id] = @item.change_switch_flag
- end
- if @item.toggle_switch > 0
- if $game_switches[@item.toggle_switch]
- $game_switches[@item.toggle_switch] = false
- else
- $game_switches[@item.toggle_switch] = true
- end
- end
- use_item_nontarget_cia
- end
- end # Scene_Item
- #===============================================================================
- # Window_Item
- #===============================================================================
- class Window_Item < Window_Selectable
- #--------------------------------------------------------------------------
- # alias refresh
- #--------------------------------------------------------------------------
- alias refresh_window_item_cia refresh unless $@
- def refresh
- $game_temp.refreshing_cia = true
- refresh_window_item_cia
- end
- #--------------------------------------------------------------------------
- # overwrite draw_item
- #--------------------------------------------------------------------------
- def draw_item(index)
- $game_temp.refreshing_cia = false
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- if item != nil
- number = $game_party.item_number(item)
- enabled = enable?(item)
- rect.width -= 4
- draw_item_name(item, rect.x, rect.y, enabled)
- draw_charges(item, rect, enabled)
- self.contents.draw_text(rect, sprintf(YE::ITEM::DRAW_ITEM, number), 2)
- end
- end
- #--------------------------------------------------------------------------
- # draw_charges
- #--------------------------------------------------------------------------
- def draw_charges(item, rect, enabled)
- return unless item.item_charges > 1
- return unless item.consumable
- return if $game_party.item_number(item) <= 0
- if $game_party.item_charges[item.id] == nil
- $game_party.item_charges[item.id] = item.item_charges
- end
- charges = $game_party.item_charges[item.id]
- dx = rect.x
- dy = rect.y + WLH * 1 / 3
- font_size = self.contents.font.size
- font_bold = self.contents.font.bold
- self.contents.font.size = YE::ITEM::CHARGE_SIZE
- self.contents.font.bold = YE::ITEM::CHARGE_BOLD
- self.contents.draw_text(dx, dy, 24, WLH * 2 / 3, charges, 2)
- self.contents.font.size = font_size
- self.contents.font.bold = font_bold
- end
- end # Window_Item
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement