RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Gameover -> Common Event

0 Members and 3 Guests are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Gameover -> Common Event
Version: 1.0
Author: modern algebra
Date: February 20th, 2008


Description


Requested by zzzdude, I figured I would post it in case anyone else wanted it. Instead of calling up the GameOver scene when you die in battle, it calls a common event you specify. This can be used for an epilogue, or any kind of evented Game Over cutscene. Bear in mind that you do have to call the Game Over screen at the end, or else arrange an alternate game over. You will need to set everything in the common event. The script does not do anything a regular Game Over scene does.

Paste it into it's own script page in the editor, just above main.

Features

  • Allows you to call a common event, instead of going straight to Scene_GameOver. This allows you to have an evented gameover or send to an inn or whatever.

Instructions

Just paste this code above main. Then, go down to line 6 and set @gameover_ce_id to the ID of the common event you want to use as the common event it calls when you hit gameover. This only works for game overs in battle. If you leave it as 0, then it will game over as default. If you ever want to change what common event is called during the game or to set it back to default, just use a call script like this:

$game_system.gameover_ce_id = <new common event ID>

Script


Code: [Select]
class Game_System
  attr_accessor :gameover_ce_id
  alias modalg_gameover_to_common_event_init initialize
  def initialize
    modalg_gameover_to_common_event_init
    @gameover_ce_id = 0 # Default Common Event ID
  end
end

class Scene_Battle
  alias modern_algebra_gameover_common_event_call call_gameover
  def call_gameover
    if $game_system.gameover_ce_id != 0
      $game_party.clear_actions
      $game_party.remove_states_battle
      $game_troop.clear
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call (2)
        $game_temp.battle_proc = nil
      end
      unless $BTEST
        $game_temp.map_bgm.play
        $game_temp.map_bgs.play
      end
      $scene = Scene_Map.new
      @message_window.clear
      Graphics.fadeout(30)
      $game_temp.common_event_id = $game_system.gameover_ce_id
      $scene = Scene_Map.new
    else
      modern_algebra_gameover_common_event_call
    end
  end
end



Credit


No credit is necessary for such a simple script, but it was written by me

Support


Please post your questions here if you run into problems

Author's Notes


This, when I made it for RMXP, was just released as a scriptlet. But, I figure I will test releasing them independently to see what happens. Once the VX database gets more scripts I will probably merge them all back into the Useful Scriptlets topic. It has a few changes from the XP version. Mainly it overwrites the call_gameover method and throws in a few safety features.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:44:46 PM by Modern Algebra »

**
Rep: +0/-0Level 86
What's with these people?!?
Is there a way to call script to set the ID to a different Comment Event? Otherwise I could just use Confitional Branches to call a seperate event... I know it seems like a stupid question to me...

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Here, try this I guess::

Code: [Select]
class Game_System
  attr_accessor :gameover_ce_id
  alias modalg_gameover_to_common_event_init initialize
  def initialize
    modalg_gameover_to_common_event_init
    @gameover_ce_id = 0 # Default Common Event ID
  end
end

class Scene_Battle
  alias modern_algebra_gameover_common_event_call call_gameover
  def call_gameover
    if $game_system.gameover_ce_id != 0
      $game_party.clear_actions
      $game_party.remove_states_battle
      $game_troop.clear
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call (2)
        $game_temp.battle_proc = nil
      end
      unless $BTEST
        $game_temp.map_bgm.play
        $game_temp.map_bgs.play
      end
      $scene = Scene_Map.new
      @message_window.clear
      Graphics.fadeout(30)
      $game_temp.common_event_id = $game_system.gameover_ce_id
      $scene = Scene_Map.new
    else
      modern_algebra_gameover_common_event_call
    end
  end
end


I just added some code. It ought to work but I might have made some kind of error. Just post if you encounter problems.

To change the ID, use the code:

Code: [Select]
$game_system.gameover_ce_id = value

**
Rep: +0/-0Level 86
What's with these people?!?
Okay, thanks!

****
Rep:
Level 90
This script did not work for me unfortunately I keep getting errors here:

    if $game_temp.common_event_id > 0
      setup($data_common_events[$game_temp.common_event_id].list)
      $game_temp.common_event_id = 0
      return
    end
community project for RPG Maker VX: http://rmrk.net/index.php/topic,33789.0.html

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Hmm, that's strange. What does the error say exactly? Also, have you set the line in this script:


Code: [Select]
   @gameover_ce_id = 0 # Default Common Event ID

to be some number greater than the maximum number of common events in your game? That would likely cause the problem.


This script needs to be updated with recognition of other methods of automatic death.
« Last Edit: October 06, 2009, 09:35:07 PM by modern algebra »

*
Rep: +0/-0Level 82
Unfortunatly, your script doesn't work with Vampyr SBABS :( I tried it but I still go on the title screen when I die. I guess it's because SBABS script overwrite (or whatever it's called) the gameover script... Anyway, if there's a way to fix it, it would be very appreciated if you could help me. If not, it's not too bad, I'll find a way to avoid Game Over :P

Thank you :)

Raphie123

**
Rep:
Level 82
Guy!! You know me to impress!! Algebra!!

Look at this!!
i'm an idiot!!
« Last Edit: November 10, 2009, 05:12:43 PM by grafikal »

**
Rep: +0/-0Level 82
Hello again,
I did try this script on a totally new project that I only started to check if the script works, and yes, it worked.
That made me wonder, what's wrong with my game. Then I did copy all the scripts back from the clean project, I did copy the graphics and all from my project to the clean project, and it didn't work, I think it must be a switch that interferes with it. Now it gives me this error:
Script 'Game_Interpreter' line 77: NoMethodError occured.
undefined method '>' for nil:NilClass

What can I do that it will work?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
It might be another script that's interfering, particularly if that other script overwrites the initialize method of Game_System.

Have you tried putting this script below any other custom scripts you might be using, but still above Main?

**
Rep: +0/-0Level 82
Thank you,
all the scripts I've been changing were in Script editor and not custom scripts, thats why, to check it, I had to revert to originals by copying them from a clean new project, but it didn't change anything, that's why I think its a switch, or maybe a variable set in the game?
I did change battle backgrounds, main font and line spacing by fiddling with script editor, and graphics of course, but graphics are easier for me, and photoshop is very handy :)
Actually now thinking about it the only other custom script is the default font 2 lines in Materials. Still don't know how to change a font in a single event though, I have tried.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
It's definitely not a variable or switch.

Hmm, well in the script, try replacing:

Code: [Select]
  def initialize
    modalg_gameover_to_common_event_init
    @gameover_ce_id = 0 # Default Common Event ID
  end

with:

Code: [Select]
  def initialize
    @gameover_ce_id = 0 # Default Common Event ID
    modalg_gameover_to_common_event_init
  end


Also, what do you have @gameover_ce_id set to? It should be an ID of the common event you want to call, which means a positive integer.

**
Rep: +0/-0Level 82
It's definitely not a variable or switch.

Hmm, well in the script, try replacing:

Code: [Select]
  def initialize
    modalg_gameover_to_common_event_init
    @gameover_ce_id = 0 # Default Common Event ID
  end

with:

Code: [Select]
  def initialize
    @gameover_ce_id = 0 # Default Common Event ID
    modalg_gameover_to_common_event_init
  end


Also, what do you have @gameover_ce_id set to? It should be an ID of the common event you want to call, which means a positive integer.


My game always ignore this script... the only way I can see for it to work (I already tried) is changing the Scene_Gameover script....

the problem is that I don't know how to call your script, can you give me the line of code to force "scene_gameover" to call your script?

**
Rep: +0/-0Level 82
That's a good idea! Now I copied the following part into gameover scene so my player is dead and walking now when defeated, but yeah, if you could please tell us the line to call the event from scene gameover.
Code: [Select]
==============================================================================
# ** Scene_Gameover
#------------------------------------------------------------------------------
#  This class performs game over screen processing.
#==============================================================================

class Scene_Gameover < Scene_Base

  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    if $game_temp.common_event_id != 013
      $game_party.clear_actions
      $game_party.remove_states_battle
      $game_troop.clear
      if $game_temp.battle_proc != nil
        $game_temp.battle_proc.call (2)
        $game_temp.battle_proc = nil
      end
      unless $BTEST
        $game_temp.map_bgm.play
        $game_temp.map_bgs.play
      end
      $scene = Scene_Map.new
      Graphics.fadeout(30)
      $game_temp.common_event_id = 013
      $scene = Scene_Map.new
    end
  end
end

**
Rep: +0/-0Level 82
That's a good idea! Now I copied the following part into gameover scene so my player is dead and walking now when defeated, but yeah, if you could please tell us the line to call the event from scene gameover.

yeah... I was messing here with the game over scene and I could make the "gameover" process stop...

the problem is that it keep repeating itself, I can't find a way to stop the gameover script from running ;/

the result is a loop of my screen going black and back to the map, and then again, and again... and agaain...

**
Rep: +0/-0Level 82
You could put a "break loop" in but I don't know yet how to do it in script :(

**
Rep: +0/-0Level 82
it's just "break"

the problem is that it's not a loop... it's like a hidden witch is activated and everytime the game_over script stops, it check the "hidden" switch and launch again

searched everywhere for this process the only thing I found was this

Code: [Select]
  def command_353
    $game_temp.next_scene = "gameover"
    return false
  end

on game_interpreter...

I tried to put $game_temp.next_scene = ""

but it didn't work xD

**
Rep: +0/-0Level 82
try to change false to true? But I don't know, I just try to mess with the script and some of it occasionally works. :S ::)

****
Rep:
Level 83
h3llh0und, the only reason I can see that happening is through another script. Go through and comment out each script one at a time to see what is interfering.

*
Rep: +0/-0Level 76
RMRK Junior
Hey, sorry for the necropost. but i really like this script. However it doesnt work with ABS battle systems or any other overworld fighting. :-[ Is there anyway you can make a fix for this plz?


 :lol: :lol:

*
Rep: +0/-0Level 55
RMRK Junior
Necro, but I second that request. I've tried to modify the script to work with ABS, but it's resulting in really strange results.

The reason why this doesn't work with ABS is because ABS systems (I believe) don't go into Scene_Battle, which is what this script modifies. So I tried to modify Scene_Map.

I added the code below to the script. Note that I've kept it simple for debugging reasons. That's also why it's an override.
Code: [Select]
class Scene_Map
 
  def call_gameover
      #Graphics.fadeout(120) #Uncommenting confirms this code block DOES get called

      $game_temp.common_event_id = $game_system.gameover_ce_id

  end
 
end

Result: it only calls the common event after I open/close the menu. So it only works after a scene change, I think? However, it's clear that block of code IS being executed, as the fadeout line does work immediately (when you remove the comment).

Anyway, I am really confused what the problem is. modern algebra (or anyone else), if you have any insights, it'd be appreciated.



(Here are additional details that complicate things (and might be a separate issue), but I include them in case they actually provide insight into anything.)
Spoiler for:
Minor note: In testing, I found if I used an event (e.g. event w/ fire graphic that caused damage) to reduce my HP to 0, my character would freeze up. If I let an evented enemy deliver the finishing blow, then it doesn't... but I get the problem outlined above.

I'm using Vampyr SBABS 12. Initially I tried to see what it was doing due to the difference in behavior noted above (evented enemy damage vs. event damage). However, considering even evented enemy damage has issues, I stopped focusing on trying ot figure out how Vampyr executed game over.

Edit: Mistyped. Meant Scene_ classes, not Game_ classes. Fixed
« Last Edit: October 02, 2012, 05:36:24 PM by ShinUon »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
I haven't looked at whatever ABS script you're using, but my assumption would be that the GameOver screen is being called before the method which calls the common event. You would need to delete the $scene = Scene_GameOver.new line (or whatever; I haven't looked at this script in forever, nor am I all that familiar with VX anymore.)

*
*crack*
Rep:
Level 64
2012 Best Newbie2012 Most Unsung MemberFor frequently finding and reporting spam and spam bots
Hello again,
I did try this script on a totally new project that I only started to check if the script works, and yes, it worked.
That made me wonder, what's wrong with my game. Then I did copy all the scripts back from the clean project, I did copy the graphics and all from my project to the clean project, and it didn't work, I think it must be a switch that interferes with it. Now it gives me this error:
Script 'Game_Interpreter' line 77: NoMethodError occured.
undefined method '>' for nil:NilClass

What can I do that it will work?
Since it was never answered, I'd just like to let people know that you get that error because you're trying to compare nothing against a number.
You fix it be starting a new game rather than reloading from an old one.
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

*
Rep: +0/-0Level 55
RMRK Junior
I haven't looked at whatever ABS script you're using, but my assumption would be that the GameOver screen is being called before the method which calls the common event. You would need to delete the $scene = Scene_GameOver.new line (or whatever; I haven't looked at this script in forever, nor am I all that familiar with VX anymore.)

?? Are you responding to me? I think there's some confusion because that's not the issue. I don't get sent to the game over screen. The problem is nothing happens (e.g. common event) until I open/close the menu.

And regarding what the script (Vampyr SBABS 12) is doing, it sets $game_temp.next_scene = "gameover". That gets processed in Scene_Map in a case switch block, which goes to call_gameover. So shouldn't be any problems there.