Different item effects in and out of battle

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
969
Reaction score
807
First Language
English
Primarily Uses
N/A
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:



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?
 
Last edited by a moderator:

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
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)
 
Last edited by a moderator:

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
969
Reaction score
807
First Language
English
Primarily Uses
N/A
@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 ^_^
 

Lecode

(─‿‿─)
Veteran
Joined
Dec 18, 2013
Messages
490
Reaction score
659
First Language
French
Primarily Uses
N/A
Try this ^^

#==============================================================================# 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.
 
Last edited by a moderator:

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
969
Reaction score
807
First Language
English
Primarily Uses
N/A
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
 
Last edited by a moderator:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,674
Reaction score
566
First Language
English
Primarily Uses
RMVXA
Fixed Script Formatting.
Haven't tested.
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top