Rodrick1234

Warper
Member
Joined
Dec 15, 2020
Messages
4
Reaction score
0
First Language
Português - BR
Primarily Uses
RMVXA
In my game, I created an item called "Medicinal Herbs", which would have the function of preventing a Game Over caused in battle, in case your life reached 0. To facilitate what point I would like to reach, here is the function I would like to have the item had: if during a battle the player was defeated and he had a Medicinal Herb, instead of causing a Game Over, something like "Actor used Medicinal Herbs, X amount of HP was restored" would appear, and the player would continue the battle . If he does not have this herb, the Game Over screen would appear.
Now that you know the function of the item, I would like to know if it is possible to put this in my game. I've tried using the encounter battle event commands themselves, but it looks like Game Over takes precedence. Will it be possible to place these events, to possibly skip Game Over?
(Some words may be misspelled, I had to use the Translator.)
 

Testtubebaby

Wizard of the woods
Veteran
Joined
Oct 31, 2020
Messages
49
Reaction score
32
First Language
English
Primarily Uses
RMVXA
The only way I can see this working is if you use a script to override the game over sequence when specific conditions are met.

Have you tested to see if you can get this to work if the actor with medicinal herbs falls in battle while you still have other living party members? Or only with a party size of 1?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,930
Reaction score
1,023
First Language
English
Primarily Uses
RMVXA
if during a battle the player was defeated
Does your game only have one actor or several actors?

if the actor with medicinal herbs falls in battle while you still have other living party members?
That would certainly work as the battle does not end when one member falls.

A script would have to be used to override the end of battle when all members are defeated.

Try this
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Herb Recover After Defeat    ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║ Battle Manager                      ╠════════════════════╣
# ║ Adjust process defeat               ║    16 Dec 2020     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Simple script to adjust the proces defeat                ║
# ║ Party will recover when the party has the item indicated ║
# ║ If not then normal defeat is processed                   ║
# ║ Only for when the party is able to lose                  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module Herb_Recover

  SWITCH_ID = 1   # Change to your desired switch
    HERB_ITEM = 7        # item that will recovery party.
    HEAL = 500            # specify value to recover health
  
end

module Vocab
    Herb = "Party used Medicinal Herbs, #{Herb_Recover::HEAL} HP was restored to the party"
end

module BattleManager

  class << self
    alias_method :process_herb, :process_defeat
  end     


  def self.process_defeat
    if $game_switches[Herb_Recover::SWITCH_ID] && !@can_lose
            if $game_party.has_item?($data_items[Herb_Recover::HERB_ITEM], false)
                $game_message.add(sprintf(Vocab::Herb, $game_party.name))
                wait_for_message
                revive_battle_members
                $game_party.battle_members.each do |actor|
                    actor.hp += Herb_Recover::HEAL
                end
                $game_party.lose_item($data_items[Herb_Recover::HERB_ITEM], 1, false)
                return false
            else
                process_herb
            end
    else
            process_herb
        end
  end

end
 
Last edited:

Testtubebaby

Wizard of the woods
Veteran
Joined
Oct 31, 2020
Messages
49
Reaction score
32
First Language
English
Primarily Uses
RMVXA

I hope you don't mind me injecting my thoughts here, but I believe the OP is looking for a script just like this that checks for an applied state rather than a held item. If the script simply checks for an item within the player's inventory, then they won't have to use the item in order to receive its effects.

I believe the OP is looking for something that handles like an auto-raise while a state is applied, so they are automatically revived upon death/downed (Think Reraise from the Final Fantasy series). Mind you, this is going off of the assumption that this is what the OP wants, since it was stated that the item would have been used prior to being downed.
 

Binder28

Veteran
Veteran
Joined
Sep 15, 2020
Messages
106
Reaction score
30
First Language
Portuguese
Primarily Uses
RMVXA
I didn't understand very well...but if you want to cancel the game over AFTER you die in battle and the battle is over you can use "yanfly's" death common event script...you just need to create the event that will happen after the battle is over...but the battle will not continue of course...

.

If you want something to happenin battle after your characters life has reached 0 HP...you can use Hime's post battle events...these events will trigger at the end of battle but BEFORE the game leaves the battle screen...just create an events that triggers after the battle ends that checks if the character has the item and if it does make the event heals the character...I am not sure if the battle will continue tough as I've never used this scrip for this purpose...but it's worth a try I guess...


 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,930
Reaction score
1,023
First Language
English
Primarily Uses
RMVXA
checks for an applied state rather than a held item
Definitely an item. The OP says " Medicinal Herb " not Medicinal status or state. And " Actor used Medicinal Herbs " You can't use a state.

an auto-raise while a state is applied
The script I wrote will work only for the entire party. If it is to be one actor then that's a completely different function.
Of course the OP does say before the game over, so one could assume that it for when the party is defeated.
 
Last edited:

Rodrick1234

Warper
Member
Joined
Dec 15, 2020
Messages
4
Reaction score
0
First Language
Português - BR
Primarily Uses
RMVXA
Does your game only have one actor or several actors?


That would certainly work as the battle does not end when one member falls.

A script would have to be used to override the end of battle when all members are defeated.

Try this
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Herb Recover After Defeat    ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║ Battle Manager                      ╠════════════════════╣
# ║ Adjust process defeat               ║    16 Dec 2020     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Simple script to adjust the proces defeat                ║
# ║ Party will recover when the party has the item indicated ║
# ║ If not then normal defeat is processed                   ║
# ║ Only for when the party is able to lose                  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module Herb_Recover

  SWITCH_ID = 1   # Change to your desired switch
    HERB_ITEM = 7        # item that will recovery party.
    HEAL = 500            # specify value to recover health
 
end

module Vocab
    Herb = "Party used Medicinal Herbs, #{Herb_Recover::HEAL} HP was restored to the party"
end

module BattleManager

  class << self
    alias_method :process_herb, :process_defeat
  end    


  def self.process_defeat
    if $game_switches[Herb_Recover::SWITCH_ID] && !@can_lose
            if $game_party.has_item?($data_items[Herb_Recover::HERB_ITEM], false)
                $game_message.add(sprintf(Vocab::Herb, $game_party.name))
                wait_for_message
                revive_battle_members
                $game_party.battle_members.each do |actor|
                    actor.hp += Herb_Recover::HEAL
                end
                $game_party.lose_item($data_items[Herb_Recover::HERB_ITEM], 1, false)
                return false
            else
                process_herb
            end
    else
            process_herb
        end
  end

end
Yes, only one actor in the entire game. I'll try this script.

I didn't understand very well...but if you want to cancel the game over AFTER you die in battle and the battle is over you can use "yanfly's" death common event script...you just need to create the event that will happen after the battle is over...but the battle will not continue of course...

.

If you want something to happenin battle after your characters life has reached 0 HP...you can use Hime's post battle events...these events will trigger at the end of battle but BEFORE the game leaves the battle screen...just create an events that triggers after the battle ends that checks if the character has the item and if it does make the event heals the character...I am not sure if the battle will continue tough as I've never used this scrip for this purpose...but it's worth a try I guess...


Yes, I would like that if my character reached 0 HP, it would be possible to check if the Herb is in inventory, so that the character can recover amount X of HP and continues the battle. The second script verified if the Herb was in inventory and displayed the messages, and I believe it recovered the HP, but the battle didn't continue.

Does your game only have one actor or several actors?


That would certainly work as the battle does not end when one member falls.

A script would have to be used to override the end of battle when all members are defeated.

Try this
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Herb Recover After Defeat    ║  Version: 1.00     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║ Battle Manager                      ╠════════════════════╣
# ║ Adjust process defeat               ║    16 Dec 2020     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Simple script to adjust the proces defeat                ║
# ║ Party will recover when the party has the item indicated ║
# ║ If not then normal defeat is processed                   ║
# ║ Only for when the party is able to lose                  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module Herb_Recover

  SWITCH_ID = 1   # Change to your desired switch
    HERB_ITEM = 7        # item that will recovery party.
    HEAL = 500            # specify value to recover health
 
end

module Vocab
    Herb = "Party used Medicinal Herbs, #{Herb_Recover::HEAL} HP was restored to the party"
end

module BattleManager

  class << self
    alias_method :process_herb, :process_defeat
  end    


  def self.process_defeat
    if $game_switches[Herb_Recover::SWITCH_ID] && !@can_lose
            if $game_party.has_item?($data_items[Herb_Recover::HERB_ITEM], false)
                $game_message.add(sprintf(Vocab::Herb, $game_party.name))
                wait_for_message
                revive_battle_members
                $game_party.battle_members.each do |actor|
                    actor.hp += Herb_Recover::HEAL
                end
                $game_party.lose_item($data_items[Herb_Recover::HERB_ITEM], 1, false)
                return false
            else
                process_herb
            end
    else
            process_herb
        end
  end

end
It worked exactly as I would like! I'm really glad. But just so that I can make it a little more complete, would it be possible for the restored HP to be an amount equivalent to X% of the Actor's Maximum HP? And that the name Party be replaced by the name of the actor (that name changes during progression)?
 

Attachments

  • script.PNG
    script.PNG
    7.7 KB · Views: 2

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,930
Reaction score
1,023
First Language
English
Primarily Uses
RMVXA
the name Party be replaced by the name of the actor (that name changes during progression)?
To have the name change throughout the game the message needs to be in the process_defeat method.
Be sure to carefully change this if you want to change the message.
X% of the Actor's Maximum HP
Try this...
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Herb Recover After Defeat    ║  Version: 1.02     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║ Battle Manager                      ╠════════════════════╣
# ║ Adjust process defeat               ║    16 Dec 2020     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Simple script to adjust the proces defeat                ║
# ║ Party will recover when the party has the item indicated ║
# ║ If not then normal defeat is processed                   ║
# ║ Only for when the party is able to lose                  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module Herb_Recover

    SWITCH_ID = 1        # Change to your desired switch
    HERB_ITEM = 7        # item that will recovery party.
    HEAL = 50              # specify value to recover health. % value
end

module BattleManager

  class << self
    alias_method :process_herb, :process_defeat
  end   

  def self.process_defeat
    @herb = "#{$game_party.leader.name} used Medicinal Herbs, \n#{Herb_Recover::HEAL}%% HP was restored"
    if $game_switches[Herb_Recover::SWITCH_ID] && !@can_lose
            if $game_party.has_item?($data_items[Herb_Recover::HERB_ITEM], false)
                $game_message.add(sprintf(@herb, $game_party.name))
                wait_for_message
                revive_battle_members
                $game_party.battle_members.each do |actor|
                    actor.hp += [(actor.mhp * Herb_Recover::HEAL).to_i / 100 - 1, actor.mhp].min
                end
                $game_party.lose_item($data_items[Herb_Recover::HERB_ITEM], 1, false)
                return false
            else
                process_herb
            end
        else
            process_herb
        end
    end
end
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
14,185
Reaction score
15,251
First Language
English
Primarily Uses
RMVXA
If you have random battles it can only be done with a script.

Moved to RGSSx Script Requests

 

Latest Threads

Latest Posts

Latest Profile Posts

Realized I haven't posted in a while, so here's pics of two locations in my game. My current focus is to finish the visuals for the "base town" before I slap more events in, as well as put up a thread. :kaothx:

(The characters in the pictures are half-spider, heads up if you don't want to see spider parts.)
bar screencap.pngarcade screencap.png

definitely nice that I can make my own music for the game. this is one of theme's for one of the main protagonists.
Anime ninja man update: Slightly different trousers:
TestChara-22a.gif
A WIP of a 'hidden' cave. Supposed to be behind a waterfall--but I've settled for a "hidden adjacent to a waterfall" cave. lol
Toying around with some customization stuff...
customiz.PNG

Forum statistics

Threads
121,537
Messages
1,142,371
Members
159,705
Latest member
JackX101
Top