Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

End Battle Quick Question

Hello ppl. Without further introductions, I'd like someone to show me how to put a couple of lines of code to be executed everytime a battle ends. An aliased scriptlet should be fine.
Thank you in advance for your time.
 
You can use this if you want to make something happen at the end of battle:
Code:
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias definitions
  #--------------------------------------------------------------------------
  alias raven_battle_end battle_end
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:lose 2:escape)
  #--------------------------------------------------------------------------
    def battle_end(result)
    raven_battle_end(result)
    if result == 0
      $game_variables[25] += 1
    end
  end
end

First i aliased so that we don't overwrite the old code. Then i called the old code with this line :

Code:
raven_battle_end(result)

You can make something happen if the result at the end of the battle is either win, lose or escape.
Here is how you check the result:

Code:
#Win
if result == 0
  #do winning stuff
end

#Lose
if result == 1
  #do losing stuff
end

#Escape
if result == 2
  #do escaping stuff
end

and if you only want something to happen at the end of the battle in general, you just skip the if statements, like this:

Code:
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias definitions
  #--------------------------------------------------------------------------
  alias raven_battle_end battle_end
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:lose 2:escape)
  #--------------------------------------------------------------------------
    def battle_end(result)
    raven_battle_end(result)
    #do your stuff here
  end
end

Anyways, i hope that helped! :thumb:

Over and out - Gando
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top