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

From OHRRPGCE-Wiki
Jump to: navigation, search

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

Note that it is also very easy to make it active outside battle and make the player able to pause your game WHENEVER he/she wants! 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; whe the player presses pause, we store time datas in global variable and prevent everybody player and players. When the player presses pause again the time data we stored overwrite the one in Custom and players and NPCs are not suspended anylonger.

Contents

[edit] to get start

Here we go. The first 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. The only ones you cannot change are the "read general" ones.



define script (45, my keyispressed script, none)

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

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

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

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

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

#if (check tag (tag:battle started)==on=) then, begin 
# optionnal 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
# optionnal only if you have made your own battle system

end #end for the script 
#---------------------------------------------------------------------------
script,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 
savetime:= read general (54) #ToDo: make an official seconds of play command 
pauseisactive:=true 
wait(1)

end #end of the plotscript
#---------------------------------------------------------------------------
script, 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

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 assusme that you have created your own battle system and that you want the player to be able to use the pause key

 set tag (tag : battle started, on)

You also need to modify your script

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

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

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
# optionnal 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 ennemies 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 cutom games) may want going to toilet or may need to answer your phone not only during battle times ^_^


[edit] big text box that covers all the screen

You may have noticed that it is not a single text box with pause writting 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 ther 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!

[edit] Conclusion:

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 puase outside battle may not be easy for beginners and even intermediary level game makers, so don't hesistate to ask questions on the forum if you need any help for implementing!

 #reset time 

 write general(51,0) # days 
 write general(52,0) # hours  
 write general(53,0) # minutes
 write general(54,0) # seconds 

[edit] See Also

Personal tools