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.

Die -> return to checkpoint

Aran

Member

Hello, all. After trying to create this script myself with a lack of success, I have concluded that I need the script anyway--even if I don't create it. But, basically, it's striaghtforward: when you die, instead of starting over again, you return to the last checkpoint you visited with nothing lost but the distance you've covered (i.e. with dungeons).

The way I did was, I made a hash called saves (first in scene_title and then in game_map). Then, when you activate a save point (an event, of course) it will push/replace the saves hash with the new contents. The saves hash was set up like this: {map_id => event_id}. By replacing, of course, you will never have more than one check point.

Anyways... in scene_gameover, it'll transport you to map_id and the character coordinates will be the same as the event_id's x and y coord's.

But as I said, I tried and failed. perhaps it's not so simple... or maybe I overdid it? And no. I don't want to do it with events.

The bottom line: can someone create this for me? I really need it.
script objective: die -> no gameover -> restart from checkpoint. got it? ;)
 
You can make it with events... :D
I made a script like this some weeks ago. I have updated it for you and i'm working on a version using a hash.

Code:
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]# ** Checkpoint script[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]# Written by: Dargor[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]# Date: 14/02/07[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]# Version 1.0[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]# ** Checkpoint[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#------------------------------------------------------------------------------[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]# This class handles checkpoints.[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#000000] Checkpoint[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Public Instance Variables[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2] attr_accessor [/SIZE][/FONT][SIZE=2][COLOR=#4169e1]:[/COLOR][/SIZE][/FONT][SIZE=2]current_checkpoint [/SIZE][/FONT][SIZE=2][COLOR=#008000]# ID of the checkpoint[/COLOR][/SIZE][/FONT]
[SIZE=2] attr_accessor [/SIZE][/FONT][SIZE=2][COLOR=#4169e1]:[/COLOR][/SIZE][/FONT][SIZE=2]coordinates [/SIZE][/FONT][SIZE=2][COLOR=#008000]# Coordinates associated to current_checkpoint[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Object Initialization[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] def[/COLOR][/SIZE][/FONT][SIZE=2] initialize[/SIZE][/FONT]
[SIZE=2]   @current_checkpoint [/FONT][/SIZE][SIZE=2][COLOR=#4169e1]= [/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT]
[SIZE=2]   @coordinates [/SIZE][/FONT][SIZE=2][COLOR=#4169e1]= [/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]1[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]][/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Checkpoints: Returns informations on a checkpoint (id)[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] def[/COLOR][/SIZE][/FONT][SIZE=2] checkpoints[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]([/COLOR][/SIZE][/FONT][SIZE=2]id[/SIZE][/FONT][SIZE=2][COLOR=#4169e1])[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # EDIT HERE[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # when checkpoint_id[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # return [map_id,x,y][/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # ...[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   case[/COLOR][/SIZE][/FONT][SIZE=2] id[/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   when [/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]     return[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]1[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]][/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   when [/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]1[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]     return[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]2[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]10[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]10[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]][/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   else[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]     return[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]1[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]5[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1],[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]5[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]][/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Save: Store informations on a checkpoint[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] def[/COLOR][/SIZE][/FONT][SIZE=2] save[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]([/COLOR][/SIZE][/FONT][SIZE=2]id[/SIZE][/FONT][SIZE=2][COLOR=#4169e1])[/COLOR][/SIZE][/FONT]
[SIZE=2]   @current_checkpoint [/SIZE][/FONT][SIZE=2][COLOR=#4169e1]=[/COLOR][/SIZE][/FONT][SIZE=2] id[/SIZE][/FONT]
[SIZE=2]   @coordinates [/FONT][/SIZE][SIZE=2][COLOR=#4169e1]=[/COLOR][/SIZE][/FONT][SIZE=2] checkpoints[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]([/COLOR][/SIZE][/FONT][SIZE=2]id[/SIZE][/FONT][SIZE=2][COLOR=#4169e1])[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Restart: Bring the player back to a checkpoint[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] def[/COLOR][/SIZE][/FONT][SIZE=2] restart[/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # Set up initial map position[/COLOR][/SIZE][/FONT]
[SIZE=2]   $game_map[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]setup[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]([/COLOR][/SIZE][/FONT][SIZE=2]@coordinates[/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]0[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]])[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # Move player to initial position[/COLOR][/SIZE][/FONT]
[SIZE=2]   $game_player[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]moveto[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]([/COLOR][/SIZE][/FONT][SIZE=2]@coordinates[/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]1[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]],[/COLOR][/SIZE][/FONT][SIZE=2] @coordinates[/SIZE][/FONT][SIZE=2][COLOR=#4169e1][[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#8b0000]2[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#4169e1]])[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # Refresh player[/COLOR][/SIZE][/FONT]
[SIZE=2]   $game_player[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]refresh[/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # Run automatic change for BGM and BGS set with map[/COLOR][/SIZE][/FONT]
[SIZE=2]   $game_map[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]autoplay[/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # Update map (run parallel process event)[/COLOR][/SIZE][/FONT]
[SIZE=2]   $game_map[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]update[/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # Switch to map screen[/COLOR][/SIZE][/FONT]
[SIZE=2]   $scene [/SIZE][/FONT][SIZE=2][COLOR=#4169e1]=[/COLOR][/SIZE][/FONT][SIZE=2] Scene_Map[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]new[/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]end[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]# ** Scene_Title[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#------------------------------------------------------------------------------[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]# This class performs title screen processing.[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#000000] Scene_Title[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Alias listing[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] alias[/COLOR][/SIZE][/FONT][SIZE=2] checkpoint_command_new_game command_new_game[/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Command: New Game[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] def[/COLOR][/SIZE][/FONT][SIZE=2] command_new_game[/SIZE][/FONT]
[SIZE=2]   $checkpoint [/FONT][/SIZE][SIZE=2][COLOR=#4169e1]=[/COLOR][/SIZE][/FONT][SIZE=2] Checkpoint[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]new[/SIZE][/FONT]
[SIZE=2]   checkpoint_command_new_game[/FONT][/SIZE]
[SIZE=2][COLOR=#0000ff] end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]end[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]# ** Scene_Gameover[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#------------------------------------------------------------------------------[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]# This class performs game over screen processing.[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#008000]#==============================================================================[/COLOR][/FONT][/SIZE]
[SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][SIZE=2][COLOR=#000000] Scene_Gameover[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] # * Frame Update[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000] #--------------------------------------------------------------------------[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] def[/COLOR][/SIZE][/FONT][SIZE=2] update[/SIZE][/FONT]
[SIZE=2][COLOR=#008000]   # If C button was pressed[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   if[/COLOR][/SIZE][/FONT][SIZE=2] Input[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]trigger[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]?([/COLOR][/SIZE][/FONT][SIZE=2]Input[/SIZE][/FONT][SIZE=2][COLOR=#4169e1]::[/COLOR][/SIZE][/FONT][SIZE=2]C[/SIZE][/FONT][SIZE=2][COLOR=#4169e1])[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#008000]     # Switch to a checkpoint[/COLOR][/SIZE][/FONT]
[SIZE=2]     $checkpoint[/SIZE][/FONT][SIZE=2][COLOR=#4169e1].[/COLOR][/SIZE][/FONT][SIZE=2]restart[/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]   end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff] end[/COLOR][/SIZE][/FONT]
[SIZE=2][COLOR=#0000ff]end[/COLOR][/FONT][/SIZE]

I'm not sure if the coding is ok, I'm at school right now and can't test it but it should be fine. You just have to modify Scene_Gameover a little bit. Read the comments in the script to know how to use it. I'll post the version with an hash later.

EDIT: You don't need to modify scene_gameover, I changed it. When you press C in Scene_Gameover, it brings you at a checkpoint.

EDIT2: How to use:
In your checkpoint event, call a script: $checkpoint.save(checkpoint_id)
That's all!

- Dargor
 
Dargor, Maybe its just me but there is a problem. When i get a game over i return to the check point. But when i apear there it waits about 3 seconds and it says game over again. It repeats the process.
 
Hey guys, I used Dargor's script and it works great, but i'm having a problem.
I have a portal system in my game that lets the player choose what map to teleport to, and i also use the ABS fighting system. My problem is this, once the player has died and respawned, i teleport to the map again and the monsters events do not activate. as in they will not attack me or react to me at all. thanks in advance for the help.
 
I stink at scripting, but it sounds like your problem might be that you need to have the script turn on the ABS system once the player returns to the checkpoint. It sounds like the ABS is being turned off somehow, and when that happens, of course, everything in the programmed enemy AI stops working until it is turned back on. Of course, I'm probably wrong about this, but you could give it a try. Unfortunately, I'm not sure how to put event commands into RGSS form.
 

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