How do I implement pause outside battles/ in my battle system?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

If you are interested in implementing a pause system outside battle, well it's perfectly possible to do so.

You may wonder? But I'm making my game and I can already make it pause! Well it's true that Pause outside had been implemented oustide battle but as a part of the debugging key.

The debugging key as the name state is a feature developed as a special bitset and give you access to various tools. Pause is one of them. The heck is that it make a game terribly easy for the player.

So the best things to do is to turn off the bitset and reimplement pause. Don't worry it is very easy to reimplement it. Adding pause outside battle and make the player able to pause your game WHENEVER he/she wants may really implement the quality of your game!! You may also indeed reuse the script when your add your own battle system!


So what are you waiting for? Let's go! To adapt your script so that it pauses games inside battle, you will need to use a tag which will be turned on when battle starts. So how does this work? Well; when the player presses pause, we store time datas in global variable and prevent the value of the variable from changing. When the player presses pause again the time data we stored overwrites. (see also how do I reset time for more details) This give you an acute idea of how long you've been playing/ testing your game as the save data take only into account the time outside pause, with is gameplay lengh.


Getting started[edit]

Here we go. As we said in the intro, the debugging key bistet may interfere with you script so edit the general dat of your game and check that the bitset is turned off.

The next thing to do is to edit your hss file and copy and paste the following code and adapt it to your hss file. You can choose for example Global variable (22, minute) instead of 12 like in the example above. You need also to adapt you keypress value and your text box value.



define script (45, my keyispressed script, none)

#---------------------------------------------------------------------------

  Global variable (10, day)  
  Global variable (11, hour)
  Global variable (12, minute)
  Global variable (13, second)
  Global variable (14, pauseisactive)

#---------------------------------------------------------------------------

define script (autonumber,my keyboard pause,none)
define script (autonumber,my keyboard unpaused,none)

#---------------------------------------------------------------------------
plotscript, my keyispressed script, begin

#if (check tag (tag:battle started)==on=) then, begin 
# optional only if you have made your own battle system

if (keyval(key: pause)>>1) then, begin 
# pause attn is pressed to put the game in pause just like custom battle system does
if (pauseisactive==false) then, begin 
my keyboard pause 
end, else, begin 

#thus, pauseisactive must be true 
my keyboard unpaused
end #end of the first if
end 

#end #end for the if check tag
# optional only if you have made your own battle system

end #end for the script 
#---------------------------------------------------------------------------
plotscript,my keyboard pause, begin 

set on keypress script (92)
suspend player 
suspend npcs 

show text box (334) #pause 
suspend box advance 

day:= days of play 
hour:= hours of play 
minute:= minutes of play 
second:= seconds of play #ToDo: make an official seconds of play command 
pauseisactive:=true 
wait(1)

end #end of the plotscript
#---------------------------------------------------------------------------
plotscript, mykeyboard unpaused, begin

while (pauseisactive) do, begin 
wait (1) 
advance text box 

write general(51, day) #ToDo: Make official set days of play, etc. commands 
write general(52, hour) 
write general(53, minute) 
write general(54, savetime) 

resume box advance
resume player 
resume npcs 

pauseisactive:=false
wait (1)

end #end of the while pause is active 

end #end of plotscript
#---------------------------------------------------------------------------

Save your hss file but don't compile it. Now go under custom.exe and pick up a free text box. Write pause in it. Go back under windows and check that the number of the text boxes correspond to the one you have in the script (show text box (the txt boxe you've just pick). Save the changes under custom but don't leave the game. Now you can compile your game. Feel free to test it! Even if you don't press pause for several minutes you'll see (when you save your game) that no time has passed!

If you want to use your pause script ONLY in battle, you'll need to pick up a free tag and add in your battle script. As pause is already implemented in custom's battle system we assume that you have created your own battle system and that you want the player to be able to use the pause key in your own battle system.

 set tag (tag : battle started, on)


If you choose to use the battle system that comes with Custom, then you may want the tag to do the contrary : desactivate your pause key so that it does not interfere with the one of the battle system.


You also need to modify your script

#---------------------------------------------------------------------------
plotscript, my keyispressed script, begin

#if (check tag (tag:battle started)==on) then, begin 
# optional only if you have made your own battle system
wait (1)
end, else, begin

if (keyval(key: pause)>>1, and, (check tag (tag: battle started)) then, begin 
# pause attn is pressed to put the game in pause just like custom battle system does
if (pauseisactive==false) then, begin 
my keyboard pause 
end, else, begin 

#thus, pauseisactive must be true 
my keyboard unpaused
end #end of the first if
end 

#end #end for the if check tag
# optional only if you have made your own battle system

end #end for the script 
#---------------------------------------------------------------------------

Note that you now need tow conditions : the key needs to be pressed AND the tag needs to be turned. It means that when you're not fighting enemies you cannot put into pause.

Remember that it is more nice for the player to let him/her presses pause and stop playing whenever he/she wants. Remember that the player (just like you when you play custom games) may want going to toilet or may need to answer your phone not only during battle times ^_^


Put a big text box that covers all the screen[edit]

You may have noticed that it is not a single text box with pause writing in it which have been implemented. When you press Pause and use the pause function implemented for battles, a big text box that covers all the screen. You can fake that if you want.

First go under custom and edit their text box. Edit the one you've made before. Edit its appearance and make sure that you read

  show box: no  

Then edit the text and make sure that Pause is written in capital letters and that it is in the center of the text box. We assume that you text box is text box number 6. So how are we going to make this big text box? Well that's simple : we're going to use the slice : create rectangle!


Modify your script : my keyboard pause and those lines before you make your text box appear on screen.


variable (handle)
handle:= find menu ID (0)
#menu 0 is the menu you uses when you have not created your own
if (handle) then, (close menu (handle)) #menu closes if it is opened
set tag (tag: menu previously op, on)

variable (pause box)
pause box := create rect (320,200,0)
set rect trans (pause box, true)
set rect border (pause box, border: none)
show text box (6) #pause 

Modify your script : my keyboard unpause delete the line "advance textbox" and copy and paste the following lines


variable (handle)
handle:= find menu ID (0)
if (handle == false, and, (check tag (tag: menu previously op)==on)) then (open menu (handle)) 
#if the menu is closed and was previously opened then open it

advance text box 
variable (pause box)
free slice (pause box)
resume box advance

Save you hss file and export it into you game. Feel free to test it as many times as you need if you want to change the colors of the size of the text box! As you can see it is rather easy when you're good at plotscripting! Feel free to ask questions on the forum!

Conclusion:[edit]

Thanks to this system the game quality should improve slightly so I strongly remember to implement it even if you're using custom battle system and even if you think you game doesn't it need because you have not used advanced plotscripting!

Note that you can also use this system to reset time. You don't need to create new variables or anything but only to enter the lines above in your script. That may be useful if you game intro lasts several scripts and about 10 minutes. Original gameplay implies giving explications to the player so that he fully understand how to get thought your rpg.

Implementing pause outside battle may not be easy for beginners and even intermediary level game makers, so don't hesistate to ask questions on the discord or on slime salad forum if you need any help for implementation!


See Also[edit]