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,536
Reaction score
854
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,536
Reaction score
854
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

SF_People3_5 added!
index.php

Marketing seems to be about reducing dependence on luck to sell a product, as well as expanding the number of avenues in which luck can play a role in selling a product.
So, I've been wanting to do this randomized logic puzzle in my game for years now. I finally figured out how to do it by using arrays and a few small script calls. It's based on the Einstein Fish Puzzle! :D Though, I have no idea how to actually have the player put in answers.... might start a thread about it.

The projectiles shown in this video are as follows:
1, Basic Triple
2, 30-Degree Arc
3, Randomized Blast Wave
4, 8-way
5, 8-way Double
6, 8-way Slowness
7, 120-Degree Arc Repetitive
8, Projective Triple
9, Split 8-way
10, 2-way Split Randomized Arc
11, HP-MP Split Arc
12, Split Laser
13, Shock
14, Cosine
Drop shadows and water reflections tests in RPG Maker VX Ace


BgI3F80.png

Forum statistics

Threads
118,630
Messages
1,117,430
Members
155,719
Latest member
ElRuby
Top