Different item effects in and out of battle

I have an item that is supposed to heal a player, but mostly for in-battle purposes. What I had in mind was a pill-type item that restores HP in battle without asking any questions, but if it's used outside of battle a message will tell the player that using it too much becomes detrimental to the player's health (i.e. Max HP goes down), then asks if the player still wants to use it.

I have attempted using a conditional branch inside of a common event, but putting them in the effects box:

qKHKxBj.png


causes the heal to occur first, then the common event runs. If I do the HP heal inside the common event, I'll need to do a bunch of conditionals checking who's using the item, then applying the heal to that person.

So. Is there a way to have different item "effects" depending on whether or not the item user is currently fighting a horde of Orcs?
So. Is there a way to have different item "effects" depending on whether or not the item user is currently fighting a horde of Orcs?
What i can do is allow to use discreetly another item instead of the selected one in the item menu.

I don't know if it'll help. 

EDIT: Script removed.

Erh...wait, i forgot something x)
@Lecode That sounds good as well, it doesn't really matter if it's the same item or not, as long as it achieves the same effect :3

Thank you, I'll wait here for the edit ^_^
Try this ^^

Spoiler
#==============================================================================# 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#==============================================================================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 endclass 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 endclass 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) true_item.effects.each {|effect| item_global_effect_apply(effect) } end endclass RPG::UsableItem def outside_item_id self.note =~ /<when_outside:[ ]?(.+)>/ ? $1.to_i : 0 end end 
However, there may be some compatibility issues with the use_item method. Send me a PM if it's the case.
Tested, no error messages are popping up. It works, thank you!

Side question that you might be able to help me with:

Is there a way to set a variable to equal the actor id of the actor the item was used on?

For future reference:

In the item/skill damage formula, do this:

v[variable id]=a.id
Fixed Script Formatting.
Haven't tested.
Spoiler: Lecode - Outside Effects
Code:
#==============================================================================
# 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
#==============================================================================
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
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)
        true_item.effects.each {|effect| item_global_effect_apply(effect) }
    end
end

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

Original thread: https://forums.rpgmakerweb.com/threads/different-item-effects-in-and-out-of-battle.43837/