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,549
Reaction score
859
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,549
Reaction score
859
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 Posts

Latest Profile Posts

A woman gave me her number without me even asking for it. Then she left because she had other patients to see.
oh, hey, I forgot about all this!

my old project got abandoned after I started working too much on stuff I'd already worked on - plus, starting to hate the story I wrote for it. Then, well, a lot of serious life **** went down. I ended up moving across the country, cutting off some people, etc. - **** was rough.

So, uh, I guess I'm back for now? Funny how things work.
I'm glad I'm sticking to my guns on having fighting game mechanics in my game, from what I've read, it's not for everyone. but for the most part, I've made it so you don't have to use them motion inputs for attacks if you don't want to.
And my project's just entered the Lunar New Year Sale 2022... Let's see if it reaches it's goal of $ 7,77.
Ohmygoodness I played Dicey Dungeons for the first time last night. Gave me SO MANY IDEAS for how to fix Heidi.

Forum statistics

Threads
118,727
Messages
1,118,258
Members
155,876
Latest member
Mataku
Top