VX Battle Retry script by Woratana

posted on 05 Mar 2009 20:34 by boxsuke in Resources, ScriptsVX, WoraScripts

* สคริปต์นี้จะทำให้ตอนที่ต่อสู้แพ้แล้วไป Gameover เราสามารถเลือกที่จะกลับไปต่อสู้อีกครั้งในการต่อสู้เดิมได้ครับผม ^^/ สามารถเปิดปิดสคริปต์นี้ได้ด้วยสวิตช์ ทำให้อนุญาตการ Retry เฉพาะในบางการต่อสู้ที่โหด ๆ ก็ได้ฮะ เจอบั๊กแจ้งได้เลยครับผม สคริปต์ก็อปได้ด้านล่าง~

Battle Retry
Version 1.0
by Woratana
Release Date: 05/03/2009


Introduction
I saw this kind of script in Gamebaker before.
Now that site is temporarily close, so think it would be a good practice to write it myself.

What this script basically does is after player lose the battle and go to Gameover screen,
there will be a choice for player to choose whether to retry the battle again, or go to title screen.

This script can be enable/disable in game.
This way you can make player not be able to retry in specific battle.

You can also choose to record the party's HP/MP/state before battle.
Therefore, when player chose battle retry, party members will not have full HP/MP and have no bad status.

Enjoy~^^


Features
Version 1.0
- Set switch ID to enable/disable battle retry during the game
- Editable command's text, command's window width and Y-coordinate
- You can choose to record party actors stat (HP/MP/States) before battle


Screenshots



Script
I decided to keep script on my blog. So it will be easier to update. ^^
#===============================================================
# ● [VX] ◦ Battle Retry ◦ □
# * Enable player to retry the battle after losing *
# ** Note: Read the setup part before using this script **
#--------------------------------------------------------------
# ◦ by Woratana [woratana@hotmail.com]
# ◦ Thaiware RPG Maker Community
# ◦ Released on: 29/02/2009
# ◦ Version: 1.0
#--------------------------------------------------------------
# ◦ Update:
#--------------------------------------------------------------
# □ Version 1.0 (29/02/2009)
# - Set switch ID to enable/disable battle retry during the game
# - Editable command's text, command's window width and Y-coordinate
# - You can choose to record party actors stat (HP/MP/States) before battle
#
#--------------------------------------------------------------
# ◦ Compatibility:
#--------------------------------------------------------------
# □ This script will rewrite 0 method(s):
#
#
# □ This script will alias 5 method(s):
#     Scene_Gameover.perform_transition
#     Scene_Gameover.terminate
#     Scene_Gameover.update
#     Scene_Battle.battle_end
#     Game_Interpreter.command_301
#
# □ This script should work with most scripts, except for some modifications
# of Scene_Gameover
#
#--------------------------------------------------------------
# ◦ Installation:
#--------------------------------------------------------------
# 1) This script should be placed JUST BEFORE ▼ Main Process.
#
# □ Like this:
# ▼ Materials
# ...
# ...
# * Battle Retry
# ▼ Main Process
# Main
#
# 2) Setup this script in Setup Part below.
#
#--------------------------------------------------------------
# ◦ How to use:
#--------------------------------------------------------------
# □ Place this script and setup in the setup part.
#
#=================================================================

class Scene_Gameover < Scene_Base

  #=================================================================
  # ++ Setup Part
  #-----------------------------------------------------------------
  BATRETRY_SWITCH_ID = 1
  # Enable Battle Retry if this switch ID is ON
  # Disable Battle Retry if this switch ID is OFF

  BATRETRY_COMMANDS = ['Retry Battle', 'Return to Title Screen']
  # Text on command window asking for Battle Retry
  # E.g. ['Go back to battle', 'Exit to title screen']

  BATRETRY_WINDOW_Y = 288
  # Command window's Y-coordinate (Top: 0, Bottom: 416)

  BATRETRY_WINDOW_WIDTH = 200
  # Command windows' width

  BATRETRY_RECORD_PARTY_STAT = true
  # Record party members' HP/MP/status before going to battle? (true/false)
  #
  # - If this set to true, if Ralph has HP 30 before battle and got poisoned.
  # When player retry the battle, Ralph will still has HP 30 and poisoned.
  #
  # - If this set to false, all the members will get full HP/MP and no bad status
  # after retry the battle.
  #=================================================================

  alias wora_batretry_scego_pertran perform_transition
  alias wora_batretry_scego_term terminate
  alias wora_batretry_scego_upd update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update(*args)
    if $game_temp.battle_retry?
      super
      @command_window.update
      if Input.trigger?(Input::C)
        case @command_window.index
        when 0 # Battle Retry
          # If recorded party stat, load recorded data
          unless $game_temp.last_troop_actor.nil?
            $game_temp.last_troop_actor.each_key do |id|
              data = $game_temp.last_troop_actor[id]
              $game_actors[id].hp = data[0]
              $game_actors[id].mp = data[1]
              $game_actors[id].real_states = data[2]
            end
          else # If not, recover party members
            $game_party.members.each {|actor| actor.recover_all }
          end
          # Setup battle
          last_troop = $game_temp.last_troop_id
          $game_troop.setup(last_troop[0])
          $game_troop.can_escape = last_troop[1]
          $game_troop.can_lose = false
          $game_temp.next_scene = "battle"
          $scene = Scene_Battle.new
        when 1 # Go to Title Screen
          $scene = Scene_Title.new
          Graphics.fadeout(120)
        end
      end
    else # Normal Gameover scene
      wora_batretry_scego_upd(*args)
    end
  end
  #--------------------------------------------------------------------------
  # * Execute Transition
  #--------------------------------------------------------------------------
  def perform_transition(*args)
    if $game_temp.battle_retry?
      # Add command window if need battle retry
      @command_window = Window_Command.new(BATRETRY_WINDOW_WIDTH, BATRETRY_COMMANDS)
      # Show battle retry window in the middle
      @command_window.x = (Graphics.width - @command_window.width) / 2
      @command_window.y = BATRETRY_WINDOW_Y
      @command_window.openness = 0
      @command_window.open
      # Perform transition
      wora_batretry_scego_pertran(*args)
      # Open command window
      until @command_window.openness == 255
        @command_window.update
        Graphics.update
      end
      @command_window.active = true
    else # Normal Gameover scene
      wora_batretry_scego_pertran(*args)
    end
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate(*args)
    @command_window.dispose unless @command_window.nil?
    wora_batretry_scego_term(*args)
  end
end

class Scene_Battle < Scene_Base
  alias wora_batretry_scebat_batend battle_end
  #--------------------------------------------------------------------------
  # * End Battle
  #--------------------------------------------------------------------------
  def battle_end(*args)
    unless (args[0] == 2 and !$game_troop.can_lose)
      # Remove last troop data if won battle
      $game_temp.last_troop_id = nil
      $game_temp.last_troop_actor = nil
    end
    wora_batretry_scebat_batend(*args)
  end

end

class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :last_troop_id, :last_troop_actor

  #--------------------------------------------------------------------------
  # * Check if battle can be retry
  #--------------------------------------------------------------------------
  def battle_retry?
    return ($game_switches[Scene_Gameover::BATRETRY_SWITCH_ID] and
  !@last_troop_id.nil?)
  end
end

class Game_Interpreter
  alias wora_batretry_gamint_com301 command_301
  #--------------------------------------------------------------------------
  # * Battle Processing
  #--------------------------------------------------------------------------
  def command_301(*args)
    # If enable to record party stat before battle..
    if Scene_Gameover::BATRETRY_RECORD_PARTY_STAT
      $game_temp.last_troop_actor = {}
      $game_party.members.each do |actor|
        $game_temp.last_troop_actor[actor.id] = [actor.hp, actor.mp, actor.real_states]
      end
    end
    # Store last troop ID in Game_System
    troop_id = @params[0] == 0 ? @params[1] : $game_variables[@params[1]]
    $game_temp.last_troop_id = [troop_id, @params[2]] unless $game_temp.in_battle
    wora_batretry_gamint_com301(*args)
  end
end

class Game_Battler
  #--------------------------------------------------------------------------
  # * Return real states
  #--------------------------------------------------------------------------
  def real_states
    return @states.clone
  end

  #--------------------------------------------------------------------------
  # * Set states with states ID array
  #--------------------------------------------------------------------------
  def real_states=(states_id_array)
    @states = states_id_array
  end
end



Instruction
- Setup script in the SETUP part
- The complete instruction is included in the script


Author's Notes
Free for use in your work if credit is included.
If you want to post it on any forum, please link to this topic.


Bug Report?
Please give me these informations:
QUOTE
- What is it says in error window?
- When is it get error? (Right after run game, when you choose something, etc.)
- What have you changed in setting part?
- Do you have any other scripts running in your game that may crash with this script?

 

 

 

 

Comment

Comment:

Tweet

sadly I can't get this to work. never shows up at the gameover screen and when I try to change the Switch ID where it says "1" to anything else besides one it crashes either when i run the game or after i die.

#86 By Chance (103.7.57.18|65.191.245.124) on 2013-03-25 03:37

<a href="http://md-wh.com/buy-clomid-usa.html">buy clomid</a> [url=http://md-wh.com/buy-clomid-usa.html]buy clomid[/url] [link=http://md-wh.com/buy-clomid-usa.html]buy clomid[/link]

#85 By none (109.251.105.123) on 2011-05-18 05:37

I'm just wondering if you've fixed the bug of the BGM that I've read in the comments. (and omg so many spam comments :/)
Other than that, I gotta compliment you on your nice RGSS2 skills :D

#84 By Kat (142.167.98.56) on 2011-05-02 07:49

<a href="http://rx-board.com/amoxicillin.php">amoxicillin rash</a> [url=http://rx-board.com/amoxicillin.php]amoxicillin rash[/url] [link=http://rx-board.com/amoxicillin.php]amoxicillin rash[/link]

#83 By none (148.122.38.198) on 2011-04-16 08:47

Thank you for sharing this information. The information was very helpful and saved a lot of my time.

#82 By Interesting essay Topics (116.71.43.207) on 2011-01-11 16:39

I reading your blog today It was very interesting and informative.

#81 By Creative Logos Gallery (110.37.54.238) on 2010-11-02 20:34

Very nice site!

#80 By uppieror (123.127.66.13) on 2010-10-10 05:11

Very nice site! cheap cialis http://oixypea.com/qxqaq/4.html

#79 By ypytoypi (195.35.223.10) on 2010-10-10 05:10

Very nice site! [url=http://oixypea.com/qxqaq/2.html]cheap cialis[/url]

#78 By rueowurw (85.183.135.74) on 2010-10-10 05:10

Very nice site! <a href="http://oixypea.com/qxqaq/1.html">cheap viagra</a>

#77 By piryteir (201.210.83.14) on 2010-10-10 05:10

Hello! geddeck interesting geddeck site!

#76 By tereueti (201.159.96.82) on 2010-10-10 05:10

Very nice site!

#75 By pwyopoor (91.121.209.25) on 2010-10-09 16:01

Very nice site! cheap cialis http://oixypea.com/qxqaq/4.html

#74 By wttuiuio (213.222.6.50) on 2010-10-09 16:00

Very nice site! [url=http://oixypea.com/qxqaq/2.html]cheap cialis[/url]

#73 By ryoriiyr (125.215.207.44) on 2010-10-09 16:00

Very nice site! <a href="http://oixypea.com/qxqaq/1.html">cheap viagra</a>

#72 By wiyytiew (82.160.202.14) on 2010-10-09 15:59

Hello! egggeac interesting egggeac site!

#71 By eptprwrw (212.200.250.26) on 2010-10-09 15:59

Very nice site!

#70 By pyprpoti (74.121.148.3) on 2010-10-07 08:52

Very nice site! cheap cialis http://oieapxy.com/tyrsst/4.html

#69 By twpituro (81.73.123.91) on 2010-10-07 08:52

Very nice site! [url=http://oieapxy.com/tyrsst/2.html]cheap cialis[/url]

#68 By euyrrwet (202.125.145.75) on 2010-10-07 08:52

Very nice site! <a href="http://oieapxy.com/tyrsst/1.html">cheap viagra</a>

#67 By tiiiorwi (118.99.67.191) on 2010-10-07 08:52

Hello! cdbfgab interesting cdbfgab site!

#66 By uyiwptoy (193.85.232.58) on 2010-10-07 08:51

Aloha! <a href="http://www.nws.noaa.gov">stabilization nations</a> [url=http://journals.ametsoc.org]mitigating began global 1979[/url] http://www.androidguys.com

#65 By timesstate (213.229.70.10) on 2010-09-28 01:34

comment6, camel cigarettes advertis, natural herbal tea remedies, doxycycline late missed period, cialis|cialis köp|handla cialis|köp cialis|köpa cialis|levitra|levitra köp|handla levitra|köp levitra|köpa levitra|viagra|viagra köp|handla viagra|köp viagra|köpa viagra,, cialis|cialis köp|handla cialis|köp cialis|köpa cialis|levitra|levitra köp|handla levitra|köp levitra|köpa levitra|viagra|viagra köp|handla viagra|köp viagra|köpa viagra,, rimonabant online prices, acomplia diet drug purephentermine, ultram|ultram köp|handla ultram|köp ultram|köpa ultram,, Predicort-50, auto insurance, viagra|viagra köp|handla viagra|köp viagra|köpa viagra,, online viagra consultation, free adelaide sex dating, discount cigarettes, female viagra, monaslim, auto insurance, clomid and ovulation test kit,

#64 By swiss replica watches (195.226.254.210) on 2010-09-22 04:01

comment1, camel cigarettes, levitra|levitra köp|handla levitra|köp levitra|köpa levitra,, prozac|prozac köp|handla prozac|köp prozac|köpa prozac,, replica graham watches, propranolol, replica automatic watches, lasix, prednisone, soma|soma köp|handla soma|köp soma|köpa soma,,

#63 By diabetes life insurance (219.137.58.132) on 2010-09-21 21:19

comment2, celebrex online, Xanax, zoloft plus wellbutrin, levitra buy, order clomid, accutane birth defect,

#62 By Vibra-Tabs (66.152.227.168) on 2010-09-21 18:09

comment4, zithromax tablet 250 mg 500 mg, lipitor cramps, Xanax, celebrex info, order cialis, neurontin excretion, cialis levitra, nexium, cialis levitra viagra, baclofen side effects, cialis, clomid directions, acomplia.com, generic phentermine cheap, order viagra, Viagra, accutane roaccutane, viagra and online, levitra fda, rimonabant, levaquin online qoclick, valtrex, Adipex,

#61 By comparison levitra viagra (184.72.14.70) on 2010-09-21 08:08

comment5, generic viagra overnight delivery, baclofen pump implant, buy phentermine, levitra, valtrex,

#60 By absolute cheapest cialis (87.247.99.93) on 2010-09-21 02:17

comment4, azithromycin 5 day dose pack, viagra prices, 2b 2b description doxycycline hyclate picture, cialis online, clomid for man, Acomplia, valtrex.com, Zithromax,

#59 By Zithromax (180.241.125.134) on 2010-09-20 23:38

comment4, Cialis, zithromax, viagra 25mg, lipitor off patent, xanax online overnight, zoloft stories, Valium, buy neurontin, buy nexium, clomid, phentermine, viagra and hypertension, order levitra, rimonabant, adipex-p ion amine,

#58 By rimonabant in diabetes (81.246.69.108) on 2010-09-20 20:16

comment3, viagra for women, overdose zoloft, appetite suppressant adipex, clomid progesterone, Rimonabant, order levaquin, rx pharmacy zithromax,

#57 By accutane 30 pills (85.254.213.163) on 2010-09-20 11:14

comment3, Cialis, zithromax as treatment for chlamydia, viagra super active 120 pills, lipitor, 3 mg xanax, celebrex online, cheap zoloft, valium without prescription, order cialis, appetite suppressant adipex, neurontin antibiotics, by cialis comment powered uri wordpress, bph caused doxycycline, nexium.com, cialis 20 mg, baclofen 30 pills, cialis levitra viagra vs, clomid discount pharmacy purchase, acomplia mexico, cheap phentermine, cheap viagra, viagra oder online, cialis viagra, accutane recall, cialis comparison levitra viagra, rimonabant price usa, levaquin.com, dosage zithromax,

#56 By Phentermine (207.96.159.7) on 2010-09-19 23:32

comment5, Cialis, lipitor, cheap celebrex online, order xanax online pharmacy, valium jokes, cialis on line, purchase adipex-p, buy cialis, cialis, clomid, viagra, rimonabant diet pill, valtrex,

#55 By neurontin benefits (61.115.229.74) on 2010-09-19 14:25

comment4, cialis professional 20mg, zithromax, viagra online miscellaneous, cheap lipitor, drug celebrex, zoloft, cialis, neurontin, acomplia, cialis, cheap nexium, cheap cialis, baclofen medication, levitra link, clomid, Acomplia, Phentermine, viagra online, kaiser and viagra, Levitra, levaquin, cheap adipex-p, zithromax info,

#54 By xanax sr (61.160.95.68) on 2010-09-19 11:52

comment3, stopping neurontin, doxycycline.com, Cialis, buy cialis without, noroxin, zithromax no prescription,

#53 By levitra vardenafil (84.124.53.74) on 2010-09-18 18:36

comment1, zithromax and infants, Viagra, zoloft, cialis online online, acomplia and serenade, cialis cheap price, effects of nexium, baclofen, clomid, phentermine without rx forum, georgia accutane law suits,

#52 By accutane mass tort (80.69.162.158) on 2010-09-18 15:25

comment1, zithromax and infants, Viagra, zoloft, cialis online online, acomplia and serenade, cialis cheap price, effects of nexium, baclofen, clomid, phentermine without rx forum, georgia accutane law suits,

#51 By accutane mass tort (85.254.213.163) on 2010-09-18 15:24

comment4, buy viagra, lipitor and muscle pain, cialis com, baclofen, phentermine, viagra pill splitter, accutane 5mg, viagra, adipex.com,

#50 By lipitor history (94.23.27.55) on 2010-09-18 12:54

comment3, cialis online pharmacy, testimonies for cialis, levitra, order cialis, uk viagra body building from sports supplement, levitra vs viagra, levitra 20 pills, levitra online, cheap cialis.jnsk.com link, Viagra, find viagra,

#49 By cialis discount online (212.98.208.66) on 2010-09-11 10:58

comment2, cialis, cialis, levitra online, Cialis, discount viagra, viagra online rx, levitra professional 60 pills, levitra online, by cialis comment powered uri wordpress, herbal viagra, viagra,

#48 By Viagra (62.103.30.184) on 2010-09-11 03:02

comment2, cialis order, cialis order, levitra, Cialis, viagra.com, viagra, compare levitra viagra, order levitra online, order cialis, viagra.com, viagra uses elderly,

#47 By cialis discount (119.247.129.59) on 2010-09-10 14:59

comment4, cheap cialis, buy cialis, levitra 4 pills, cialis, order viagra, viagra 120 pills, cialis levitra, levitra 180 pills, cialis cialis.asp zebrahaifa.com, Viagra, viagra wholesale,

#46 By cialis (209.12.101.150) on 2010-09-09 06:50

comment3, Adipex, interaction retin a and seborrhea, Antabuse, nh health insurance, buy allegra, buy acomplia, Amoxil, accutane.com, cialis.com,

#45 By Prozac (96.53.44.210) on 2010-09-07 13:18

comment3, Zolpidem, baclofen use, bactrim ds effects side, ultram, dealing with oxycontin withdrawals soma, accutane discussion, cheap accutane, klonopin, Tetracycline,

#44 By levitra lady (200.43.192.195) on 2010-09-07 09:32

comment6, Levitra, tramadol next day delivery, buy adipex, allopurinol increased salivation, aig auto insurance, Cialis, Xanax, Metformin, doxycycline 100mg, erythromycin, t-d life insurance, order acomplia, accutane generic, aspirin pregnant, buy diflucan, cialis levitra vs,

#43 By prednisone online (219.166.99.138) on 2010-09-07 05:50

WCNEXQ <a href="http://snagkmjcwyxh.com/">snagkmjcwyxh</a>, [url=http://qyajatchboke.com/]qyajatchboke[/url], [link=http://ifqudmivewpl.com/]ifqudmivewpl[/link], http://kbwnluadezkq.com/

#42 By LZwydyPLOzXh (94.102.49.89) on 2010-09-05 08:07

comment6, Propecia, acomplia, Tamiflu, bantningspiller, levitra, sluta röka, prozac, cialis, viagra, tramadol, xenical,,

#41 By tamiflu (122.154.106.84) on 2010-09-02 10:05

comment5, doxycycline online, zimulti 60 pills, ltc insurance quote, health insurance carriers, cheap propecia tramadol, car insurance, cialis kaufen.pagina.de link,

#40 By instant health insurance (85.254.213.163) on 2010-09-02 06:39

comment5, baclofen effects side, adipex online without a prescription, discount auto insurance, samba health insurance, us pharmacy no prescription valium, cialis sample, acomplia loss weight, viagra online, Viagra, antabuse liver, Phentermine, prozac used for, acomplia, cytotec induction labor, propecia cialis cialis,

#39 By allopurinol (93.63.174.85) on 2010-09-02 00:18

comment5, baclofen effects side, adipex online without a prescription, discount auto insurance, samba health insurance, us pharmacy no prescription valium, cialis sample, acomplia loss weight, viagra online, Viagra, antabuse liver, Phentermine, prozac used for, acomplia, cytotec induction labor, propecia cialis cialis,

#38 By allopurinol (59.106.172.146) on 2010-09-02 00:18

comment3, reductil uk, Tramadol, NutriDox, cialis soft tab, called drug female new viagra, is valtrex a acetaminophen, rimonabant.com, aspirin,

#37 By antabuse no online prescription (74.92.20.195) on 2010-09-01 14:40