Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
58
Reaction score
2
First Language
English
Primarily Uses
RMVXA
I have a basic healing item that restores all MP, but it's outclassed by the tier directly before it as a result of MP never getting high enough to require the 100% restore. As a result, I decided to make it so that said item also buffs MP, increasing it temporarily. This sounded nice until I remembered the dreaded item overuse quirk. Using a healing item in the overworld with a secondary effect causes it to be used even after the stat it heals being full due to the secondary effect, which is horribly annoying. My solution was to attempt to find a script to fix it, and I almost found the perfect one here. The only issue is that it only added alternate effects OUTSIDE of battle. I tried to make a modification to the script that makes it do the opposite, but can't quite seem to make it work, so now I'm here.

I need pretty much the opposite of that script. An item/skill using another item/skill's effect when used in-battle. If anyone can help me, I'd be greatly beyond appreciative.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,530
Reaction score
852
First Language
English
Primarily Uses
RMVXA
In that script you linked to if you put a ! in front of the $game_party.in_battle
does it work for you? That would be the opposite for in battle
 

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
58
Reaction score
2
First Language
English
Primarily Uses
RMVXA
In that script you linked to if you put a ! in front of the $game_party.in_battle
does it work for you? That would be the opposite for in battle
That was my assumption, too. It was my first instinct and I was shocked to find the effect didn't trigger at all. Both out of battle and in-battle, the script simply didn't do anything with this modification.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,530
Reaction score
852
First Language
English
Primarily Uses
RMVXA
I missed that it does not work in battle because scene_battle uses a different use_item method.

Updated with when_inside note tag. Works both ways now. A skill can have both note tags, but then it will never use it's own features.
Happy gaming
Ruby:
#==============================================================================
# Different effects outside the battle
# By Lecode
#----------------------
# Use <when_outside: x> on skills and items notetags.
# When the party is outside, the effects of the skill/item with
# the ID x w'll be used instead of the selected skill/item's effects
# Added <when_inside: x> - Roninator2
#==============================================================================
module Lecode_ItemOutside
  def self.get_outside_item(item)
    return item if $game_party.in_battle
    other_id = item.outside_item_id
    if other_id > 0
      if item.is_a?(RPG::Skill)
        return $data_skills[other_id]
      elsif item.is_a?(RPG::Item)
        return $data_items[other_id]
      end
    end
    return item
  end
  def self.get_inside_item(item)
    return item if !$game_party.in_battle
    other_id = item.inside_item_id
    if other_id > 0
      if item.is_a?(RPG::Skill)
        return $data_skills[other_id]
      elsif item.is_a?(RPG::Item)
        return $data_items[other_id]
      end
    end
    return item
  end
end

class Scene_ItemBase
  def use_item_to_actors
    true_item = Lecode_ItemOutside.get_outside_item(item)
    item_target_actors.each do |target|
      true_item.repeats.times { target.item_apply(user, true_item) }
    end
  end
end

class Game_Battler
  def use_item(item)
    pay_skill_cost(item) if item.is_a?(RPG::Skill)
    consume_item(item) if item.is_a?(RPG::Item)
    true_item = Lecode_ItemOutside.get_outside_item(item)
    if true_item.nil?
      item.effects.each {|effect| item_global_effect_apply(effect) }
    else
      true_item.effects.each {|effect| item_global_effect_apply(effect) }
    end
  end
end

class RPG::UsableItem
  def outside_item_id
    self.note =~ /<when_outside:[ ]?(.+)>/ ? $1.to_i : 0
  end
  def inside_item_id
    self.note =~ /<when_inside:[ ]?(.+)>/ ? $1.to_i : 0
  end
end

class Scene_Battle < Scene_Base
  def use_item
    item = @subject.current_action.item
    true_item = Lecode_ItemOutside.get_inside_item(item)
    @log_window.display_use_item(@subject, true_item)
    @subject.use_item(true_item)
    refresh_status
    targets = @subject.current_action.make_targets.compact
    show_animation(targets, true_item.animation_id)
    targets.each {|target| true_item.repeats.times { invoke_item(target, true_item) } }
  end
end
 

Kricketot

The
Veteran
Joined
Apr 19, 2015
Messages
58
Reaction score
2
First Language
English
Primarily Uses
RMVXA
I missed that it does not work in battle because scene_battle uses a different use_item method.

Updated with when_inside note tag. Works both ways now. A skill can have both note tags, but then it will never use it's own features.
Happy gaming
Ruby:
#==============================================================================
# Different effects outside the battle
# By Lecode
#----------------------
# Use <when_outside: x> on skills and items notetags.
# When the party is outside, the effects of the skill/item with
# the ID x w'll be used instead of the selected skill/item's effects
# Added <when_inside: x> - Roninator2
#==============================================================================
module Lecode_ItemOutside
  def self.get_outside_item(item)
    return item if $game_party.in_battle
    other_id = item.outside_item_id
    if other_id > 0
      if item.is_a?(RPG::Skill)
        return $data_skills[other_id]
      elsif item.is_a?(RPG::Item)
        return $data_items[other_id]
      end
    end
    return item
  end
  def self.get_inside_item(item)
    return item if !$game_party.in_battle
    other_id = item.inside_item_id
    if other_id > 0
      if item.is_a?(RPG::Skill)
        return $data_skills[other_id]
      elsif item.is_a?(RPG::Item)
        return $data_items[other_id]
      end
    end
    return item
  end
end

class Scene_ItemBase
  def use_item_to_actors
    true_item = Lecode_ItemOutside.get_outside_item(item)
    item_target_actors.each do |target|
      true_item.repeats.times { target.item_apply(user, true_item) }
    end
  end
end

class Game_Battler
  def use_item(item)
    pay_skill_cost(item) if item.is_a?(RPG::Skill)
    consume_item(item) if item.is_a?(RPG::Item)
    true_item = Lecode_ItemOutside.get_outside_item(item)
    if true_item.nil?
      item.effects.each {|effect| item_global_effect_apply(effect) }
    else
      true_item.effects.each {|effect| item_global_effect_apply(effect) }
    end
  end
end

class RPG::UsableItem
  def outside_item_id
    self.note =~ /<when_outside:[ ]?(.+)>/ ? $1.to_i : 0
  end
  def inside_item_id
    self.note =~ /<when_inside:[ ]?(.+)>/ ? $1.to_i : 0
  end
end

class Scene_Battle < Scene_Base
  def use_item
    item = @subject.current_action.item
    true_item = Lecode_ItemOutside.get_inside_item(item)
    @log_window.display_use_item(@subject, true_item)
    @subject.use_item(true_item)
    refresh_status
    targets = @subject.current_action.make_targets.compact
    show_animation(targets, true_item.animation_id)
    targets.each {|target| true_item.repeats.times { invoke_item(target, true_item) } }
  end
end
I can't thank you enough for this!
 

Latest Threads

Latest Profile Posts

ScreenShot_1_3_2022_1_32_12.png
I feel QSprite for MV is underrated. I basically am able to use my chibi sideview battlers I drew on the maps and have all the motions available. this'll help a lot with cutscenes.
I've figured out how to reasonably tall-ify chibi sprites on my editor. I like that making tall sprites gives me control on expressing how tall characters seem on the field relative to each other as well as better differentiate adult sprites from child sprites.
doing some wacky experimental stuff in MV right now :kaoluv: I cannot wait to drop what I've been working on
Doing RPG Maker News for this week. (January 14th - 20th, 2022)

My brother keeps saying," Women in his story act crazy because women are crazy." That's one way to make sure that the only woman in his life will be the retirement caregiver nurse that has to change his bedpan.

Forum statistics

Threads
118,552
Messages
1,116,916
Members
155,592
Latest member
Demure_Hero
Top