This is a Rpg 3d battle system I got off the net and I was wondering if someone could explain it.
rem **********************************
rem RPG COMBAT SYSTEM - Traci Lane
REM THIS CODE WILL NOT COMPILE. I HAVE NOT INCLUDED THE CAMERA CODE WRITTEN BY ROB CUMMINGS
REM THIS IS THE GAME CODE ONLY. IT HAS NOT BEEN OPTIMISED. I WAS GOING TO CONVERT ALL THE GOSUBS
REM TO FUNCTIONS AND TIDY IT UP A LITTLE, BUT NEVER HAD THE TIME. HOWEVER AS SO MANY PEOPLE REQUESTED
REM THE CODE I HAVE RELEASED IT AS IS AND HOPE YOU WILL FIND SOME OF IT USEFUL :)
rem **********************************
rem include matrix handler
#include "handlemtx.dba"
#include "functions.dba"
backdrop off
`snow variables these are just particles initialized randomly in a cube and moved downward. When they hit the ground they are moved back to the top
`of the cube
num_particles =150
dim p#(num_particles+100, 7)
rem setup
autocam off
sync on
`the framerate is set to 40, this allows some of the timing to be done with the framerate
`this was going to be changed to a proper timer but I never got round to it.
sync rate 40
hide mouse
set camera range 10, 4000
planeset = 0
`general game variables to control the menu, timers etc.
over = 0
gamestate = 0
pos = 360
defc = 0
magic = 5
item = 7
critical = 9
magicmenu = 6
itemmenu =8
critmenu = 10
magicmenuj = 12
itemmenuj = 14
critmenuj = 16
ret = 0
magmen = 0
itmen = 0
critmen = 0
monsthp = 200
montmax = 150
chartmax = 200
timing = 0
fighttimechar = chartmax
fighttimemon = montmax
load bitmap "title.bmp" : sync
objid = 20
percount = 0
randomize timer()
`character status varibles
dim hp(1)
dim maxhp(1)
dim mp(1)
dim maxmp(1)
dim tp(1)
dim td(1)
dim itemno(1)
`
`hp(1) = 350
`maxhp(1) = 350
`mp(1) = 15
`maxmp(1) = 15
`tp(1) = 0
`td(1) = 0
`itemno(1) = 5
do
`set up the world
gosub _set_up_world
loop music 1
gosub _global_sweep
rem main game loop
do
rem timer stuff
if fighttimechar = 0 then fighttimechar = chartmax : gamestate = 1
if fighttimemon < 0 then fighttimemon = montmax
rem scroll sky
scroll object texture 1, 0, 0.0005
rem goto the subroutine for the fight menu
if gamestate = 1 then gosub _set_fight_menu
rem implement the command pointed to by the cursor on the menu
if gamestate = 2
if pos = 360 then gosub _attack
if pos = 384 then gosub _defend
`if monster dead, initiate dead anim.
if monsthp < 0 or monsthp = 0
play sound 4
gosub fadechar
stop sound 4
stop music 1
play sound 11
set object speed 10, 18 :`18
play object 10, victorystart, victoryend
do
if timing < 200
gosub _updatecam
gosub _do_particles
rem menu
center text 320, 2, "You win!"
inc timing
else
exit
endif
sync
loop
set object speed 10, 18
do
if object playing(10) = 0 then exit
gosub _do_particles
rem menu
sync
loop
exit
endif
endif
if gamestate = critical
gosub _critical
if monsthp < 0 or monsthp = 0
play sound 4
gosub fadechar
stop sound 4
stop music 1
play sound 11
set object speed 10, 18
play object 10, victorystart, victoryend
do
if timing < 200
position camera 90,90,90
gosub _updatecam
gosub _do_particles
rem menu center text 320, 2, "You win!"
inc timing
else
exit
endif
sync
loop
do
if object playing(10) = 0 then exit
gosub _do_particles
rem menu
sync
loop
exit
endif
endif
`if magic selected on menu
if gamestate = magic
gosub _magic
gosub _storm
`if monster dead after magic
if monsthp < 0 or monsthp = 0
play sound 4
gosub fadechar
stop sound 4
stop music 1
play sound 11
set object speed 10, 18
play object 10, victorystart, victoryend
do
if timing < 200
position camera 90,90,90
gosub _updatecam
gosub _do_particles
center text 320, 2, "You win!"
inc timing
else
exit
endif
sync
loop
do
if object playing(10) = 0 then exit
gosub _do_particles
sync
loop
exit
endif
`gosub _monster_attack
endif
`if using item
if gamestate = item
gosub _item
gosub _cure
if monsthp < 0 or monsthp = 0
play sound 4
gosub fadechar
stop sound 4
stop music 1
play sound 11
set object speed 10, 18
play object 10, victorystart, victoryend
do
if timing < 200
position camera 90,90,90
gosub _updatecam
gosub _do_particles
inc timing
else
exit
endif
sync
loop
do
if object playing(10) = 0 then exit
gosub _do_particles
sync
loop
exit
endif
endif
rem monster attack when timer says
if fighttimemon = 0
gosub _monster_attack
if over = 1 then exit
endif
rem update menu and other environmental factors
gosub _do_particles
set text size 24
rem ****************************************************
rem timing code
if percount = 0
if gamestate = critical
else
dec fighttimechar
percent = fighttimechar/2
endif
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
dec fighttimemon
ink rgb(127, 127, 127), 0
if gamestate = 0 then center text 320, 2, "Wait!"
if defc = 1 then center text 320, 2, "Defend!"
endif
if joystick fire b() = 1 then finishgame = 1 :gosub _delete_world : end
rem *********************************************************
sync
loop
if over = 1
`game over bitmap
load bitmap "over.bmp" : sync
else
`loading bitmap
load bitmap "load.bmp" : sync
endif
`delete the world ready to restart it again when game loop is recalled
gosub _delete_world
loop
end
rem see menu code tutorial if you need further explanaition of the menu system.
rem gosub routines
_set_fight_menu:
set = 0
magpos = 360
magmen = 0
magmenj = 0
itpos = 360
itmen = 0
itmenj = 0
critpos = 360
critmen = 0
critmenj = 0
ret = 0
retj = 0
xpos = 0
scost$ = "5"
itno$ = "4"
level$ = "1"
pos = 360
ret = 0
play = 0
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
do
`if backspace is pressed then the submenu disappears and calls the fight menu again.
if keystate(14) = 1
gamestate = 1
magpos = 360
magmen = 0
magmenj = 0
itpos = 360
itmen = 0
itmenj = 0
critpos = 360
critmen = 0
critmenj = 0
ret = 0
retj = 0
xpos = 0
scost$ = "5"
itno$ = "4"
level$ = "1"
`pos = 360
set = 0
if sound playing(8) = 0 and play = 0
play sound 8
play = 1
endif
endif
if keystate(14) = 0 then play = 0
gosub _do_particles
center text 320, 2, "select!"
paste image 38, 80 ,336
if gamestate <> magicmenu and gamestate <> itemmenu and gamestate <> critmenu and gamestate <> magicmenuj and gamestate <> itemmenuj and gamestate <> critmenuj
paste image 39, 68, pos, 0
endif
if set = 0
if downkey()=1 and down=0
if pos < 456 then pos = pos + 24
play sound 9
down=1
endif
if joystick down() = 1 and downj = 0
if pos < 456 then pos = pos + 24
play sound 9
downj=1
endif
if downkey()=0 and down=1 then down=0
if joystick down() = 0 and downj = 1 then downj = 0
if upkey()=1 and up=0
if pos > 360 then pos = pos - 24
play sound 9
up=1
endif
if joystick up() = 1 and upj = 0
if pos >360 then pos = pos - 24
play sound 9
upj=1
endif
if upkey()=0 and up=1 then up=0
if joystick up() = 0 and upj = 1 then upj = 0
endif
ink rgb(127, 127, 127), 0
center text 144, 356, "Attack"
center text 144, 380, "Defend"
center text 144, 404, "Special"
center text 144, 428, "Magic"
center text 144, 452, "Item"
if pos = 360 then ink 0, 0 : center text 146, 358,"Attack" : ink rgb(255, 255, 255),0 : center text 144, 356, "Attack"
if pos = 384 then ink 0, 0 : center text 146, 382,"Defend" : ink rgb(255, 255, 255),0 : center text 144, 380, "Defend"
if pos = 408 then ink 0, 0: center text 146, 406,"Special" : ink rgb(255, 255, 255),0 : center text 144, 404, "Special"
if pos = 432 then ink 0, 0 : center text 146, 430,"Magic" : ink rgb(255, 255, 255),0 : center text 144, 428, "Magic"
if pos = 456 then ink 0, 0: center text 146, 454,"Item" : ink rgb(255, 255, 255),0 : center text 144, 452, "Item"
ink rgb(127, 127, 127), 0
if pos <> 432 and pos <> 456 and pos <> 408
if returnkey() = 1 or joystick fire a() = 1 then gamestate = 2 : play sound 8
endif
if pos = 432
if returnkey() = 1 and ret = 0
gamestate = magicmenu
ret = 1
magmen = 1
endif
if joystick fire a() = 1 and retj = 0
gamestate = magicmenuj
retj = 1
magmenj = 1
endif
if returnkey() = 0 and magmen = 1 then magmen = 0 : play sound 8
if joystick fire a() = 0 and magmenj = 1 then magmenj = 0: play sound 8
endif
if pos = 456
if returnkey() = 1 and ret = 0
gamestate = itemmenu
ret = 1
itmen = 1
endif
if joystick fire a() = 1 and retj = 0
gamestate = itemmenuj
retj = 1
itmenj = 1
endif
if returnkey() = 0 and itmen = 1 then itmen = 0 : play sound 8
if joystick fire a() = 0 and itmenj = 1 then itmenj = 0 : play sound 8
endif
if pos = 408
if returnkey() = 1 and ret = 0
gamestate = critmenu
ret = 1
critmen = 1
endif
if joystick fire a() = 1 and retj = 0
gamestate = critmenuj
retj = 1
critmenj = 1
endif
if returnkey() = 0 and critmen = 1 then critmen = 0 : play sound 8
if joystick fire a() = 0 and critmenj = 1 then critmenj = 0 : play sound 8
endif
if gamestate = magicmenu and magmen = 0
paste image 41, 208, 336
paste image 39, 185 ,magpos, 0
if mp < 5
ink rgb(100, 100, 100), 0
text 223, 355, "Storm"
else
ink rgb(127, 127, 127), 0
text 223, 355, "Storm"
endif
set text size 15
`set text to bold
numlen = len(scost$)
if numlen = 1 then xpos = 16
if numlen = 2 then xpos = 8
if numlen = 3 then xpos = 0
text (398 + xpos), 363, scost$
set text size 24
if magpos = 360 and mp(1) >4
ink 0, 0
text 225,357, "Storm"
ink rgb(255, 255, 255),0
text 223, 355, "Storm"
set text size 15
ink 0, 0
text (400 + xpos),365, scost$
ink rgb(255, 255, 255),0
text (398 + xpos), 363, scost$
set text size 24
endif
ink rgb(127, 127, 127), 0
set = 1
if set = 1
if downkey()=1 and down=0
if magpos < 456 then magpos = magpos + 24
play sound 9
down=1
endif
if joystick down() = 1 and downj = 0
if magpos < 456 then magpos = magpos + 24
play sound 9
downj=1
endif
if downkey()=0 and down=1 then down=0
if joystick down() = 0 and downj = 1 then downj = 0
if upkey()=1 and up=0
if magpos > 360 then magpos = magpos - 24
play sound 9
up=1
endif
if joystick up() = 1 and upj = 0
if magpos > 360 then magpos = magpos - 24
play sound 9
upj=1
endif
if upkey()=0 and up=1 then up=0
if joystick up() = 0 and upj = 1 then upj = 0
endif
if returnkey() = 1 or joystick fire a() = 1 and magpos = 360
if mp(1) > 4
play sound 8
gamestate = magic
else
`play error sound
play sound 16
endif
endif
endif
if gamestate = magicmenuj and magmenj = 0
paste image 41, 208, 336
paste image 39, 185 ,magpos, 0
if mp < 5
ink rgb(100, 100, 100), 0
text 223, 355, "Storm"
else
ink rgb(127, 127, 127), 0
text 223, 355, "Storm"
endif
set text size 15
numlen = len(scost$)
if numlen = 1 then xpos = 16
if numlen = 2 then xpos = 8
if numlen = 3 then xpos = 0
text (398 + xpos), 363, scost$
set text size 24
if magpos = 360 and mp(1) >4
ink 0, 0
text 225,357, "Storm"
ink rgb(255, 255, 255),0
text 223, 355, "Storm"
set text size 15
ink 0, 0
text (400 + xpos),365, scost$
ink rgb(255, 255, 255),0
text (398 + xpos), 363, scost$
set text size 24
endif
ink rgb(127, 127, 127), 0
set = 1
if set = 1
if downkey()=1 and down=0
if magpos < 456 then magpos = magpos + 24
play sound 9
down=1
endif
if joystick down() = 1 and downj = 0
if magpos < 456 then magpos = magpos + 24
play sound 9
downj=1
endif
if downkey()=0 and down=1 then down=0
if joystick down() = 0 and downj = 1 then downj = 0
if upkey()=1 and up=0
if magpos > 360 then magpos = magpos - 24
play sound 9
up=1
endif
if joystick up() = 1 and upj = 0
if magpos > 360 then magpos = magpos - 24
play sound 9
upj=1
endif
if upkey()=0 and up=1 then up=0
if joystick up() = 0 and upj = 1 then upj = 0
endif
if returnkey() = 1 or joystick fire a() = 1 and magpos = 360
if mp(1) > 4
play sound 8
gamestate = magic
else
`play error sound
play sound 16
endif
endif
endif
if gamestate = critmenu and critmen = 0
paste image 45, 208, 336
paste image 39, 185 ,critpos, 0
ink rgb(127, 127, 127), 0
text 223, 355, "Killer Slice"
set text size 15
numlen = len(level$)
if numlen = 1 then xpos = 16
if numlen = 2 then xpos = 8
if numlen = 3 then xpos = 0
text (405), 363, level$
set text size 24
if critpos = 360
ink 0, 0
text 225,357, "Killer Slice"
ink rgb(255, 255, 255),0
text 223, 355, "Killer Slice"
set text size 15
ink 0, 0
text (407),365, level$
ink rgb(255, 255, 255),0
text (405), 363, level$
set text size 24
endif
ink rgb(127, 127, 127), 0
set = 1
if set = 1
if downkey()=1 or joystick down() = 1 and down=0
if magpos < 456 then critpos = critpos + 24
play sound 9
down=1
endif
if downkey()=0 or joystick down() = 0 and down=1 then down=0
if upkey()=1 or joystick up() = 1 and up=0
if critpos > 360 then critpos = critpos - 24
play sound 9
up=1
endif
if upkey()=0 or joystick up() = 0 and up=1 then up=0
endif
if returnkey() = 1 or joystick fire a() = 1 and critpos = 360
play sound 8
gamestate = critical
endif
endif
if gamestate = critmenuj and critmenj = 0
paste image 45, 208, 336
paste image 39, 185 ,critpos, 0
ink rgb(127, 127, 127), 0
text 223, 355, "Killer Slice"
set text size 15
numlen = len(level$)
if numlen = 1 then xpos = 16
if numlen = 2 then xpos = 8
if numlen = 3 then xpos = 0
text (405), 363, level$
set text size 24
if critpos = 360
ink 0, 0
text 225,357, "Killer Slice"
ink rgb(255, 255, 255),0
text 223, 355, "Killer Slice"
set text size 15
ink 0, 0
text (407),365, level$
ink rgb(255, 255, 255),0
text (405), 363, level$
set text size 24
endif
ink rgb(127, 127, 127), 0
set = 1
if set = 1
if downkey()=1 or joystick down() = 1 and down=0
if magpos < 456 then critpos = critpos + 24
play sound 9
down=1
endif
if downkey()=0 or joystick down() = 0 and down=1 then down=0
if upkey()=1 or joystick up() = 1 and up=0
if critpos > 360 then critpos = critpos - 24
play sound 9
up=1
endif
if upkey()=0 or joystick up() = 0 and up=1 then up=0
endif
if returnkey() = 1 or joystick fire a() = 1 and critpos = 360
play sound 8
gamestate = critical
endif
endif
if gamestate = itemmenu and itmen = 0
paste image 44, 208, 336
paste image 39, 185 ,itpos, 0
if itemno(1) < 1
ink rgb(100, 100, 100), 0
text 223, 355, "Potion"
else
ink rgb(127, 127, 127), 0
text 223, 355, "Potion"
endif
set text size 15
numlen = len(itno$)
if numlen = 1 then xpos = 16
if numlen = 2 then xpos = 8
if numlen = 3 then xpos = 0
text (398 + xpos), 363, str$(itemno(1))
set text size 24
if itpos = 360 and itemno(1) >0
ink 0, 0
text 225,357, "Potion"
ink rgb(255, 255, 255),0
text 223, 355, "Potion"
set text size 15
ink 0, 0
text (400 + xpos),365, str$(itemno(1))
ink rgb(255, 255, 255),0
text (398 + xpos), 363, str$(itemno(1))
set text size 24
endif
ink rgb(127, 127, 127), 0
set = 1
if set = 1
if downkey()=1 or joystick down() = 1 and down=0
if itpos < 456 then itpos = itpos + 24
play sound 9
down=1
endif
if downkey()=0 or joystick down() = 0 and down=1 then down=0
if upkey()=1 or joystick up() = 1 and up=0
if itpos > 360 then itpos = itpos - 24
play sound 9
up=1
endif
if upkey()=0 or joystick up() = 0 and up=1 then up=0
endif
if returnkey() = 1 or joystick fire a() = 1 and itpos = 360
if itemno(1) > 0
play sound 8
gamestate = item
else
`play error sound
play sound 16
endif
endif
endif
if gamestate = itemmenuj and itmenj = 0
paste image 44, 208, 336
paste image 39, 185 ,itpos, 0
if itemno(1) < 1
ink rgb(100, 100, 100), 0
text 223, 355, "Potion"
else
ink rgb(127, 127, 127), 0
text 223, 355, "Potion"
endif
set text size 15
numlen = len(itno$)
if numlen = 1 then xpos = 16
if numlen = 2 then xpos = 8
if numlen = 3 then xpos = 0
text (398 + xpos), 363, str$(itemno(1))
set text size 24
if itpos = 360 and itemno(1) >0
ink 0, 0
text 225,357, "Potion"
ink rgb(255, 255, 255),0
text 223, 355, "Potion"
set text size 15
ink 0, 0
text (400 + xpos),365, str$(itemno(1))
ink rgb(255, 255, 255),0
text (398 + xpos), 363, str$(itemno(1))
set text size 24
endif
ink rgb(127, 127, 127), 0
set = 1
if set = 1
if downkey()=1 or joystick down() = 1 and down=0
if itpos < 456 then itpos = itpos + 24
play sound 9
down=1
endif
if downkey()=0 or joystick down() = 0 and down=1 then down=0
if upkey()=1 or joystick up() = 1 and up=0
if itpos > 360 then itpos = itpos - 24
play sound 9
up=1
endif
if upkey()=0 or joystick up() = 0 and up=1 then up=0
endif
if returnkey() = 1 or joystick fire a() = 1 and itpos = 360
if itemno(1) > 0
play sound 8
gamestate = item
else
`play error sound
play sound 16
endif
endif
endif
if gamestate = 2 then exit
if gamestate = magic then exit
if gamestate = item then exit
if gamestate = critical then exit
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
return
rem gosub for setting up world
_set_up_world:
rem load in the bitmaps for the menu
load image "menu\console.bmp", 32
load image "menu\prompt.bmp", 33
load image "menu\timebar.bmp", 36
`load image "menu\consobar.bmp", 37
load image "menu\commenu.bmp", 38
load image "menu\cursor.bmp", 39
`load image "menu\commnbar.bmp", 40
load image "menu\submens.bmp", 41
`load image "menu\submnbri.bmp", 42
`load image "menu\submnbrs.bmp", 43
load image "menu\submeni.bmp", 44
load image "menu\submena.bmp", 45
load image "effects\grnstar2.bmp", 500
load image "effects\snoflake.bmp", 100
load image "load.bmp", 50
load image "over.bmp", 51
load sound "sounds\sword.wav", 1
load sound "sounds\growl.wav", 2
load sound "sounds\thunder.wav",3
load sound "sounds\draw.wav", 4
load sound "sounds\sword1.wav", 5
load sound "sounds\hit.wav", 6
load sound "sounds\stab.wav", 7
load sound "sounds\menu.wav", 8
load sound "sounds\menu2.wav", 9
load sound "sounds\whoosh.wav", 10
load sound "sounds\stab.wav", 12
load sound "sounds\cure.wav", 15
load sound "sounds\error.wav", 16
load sound "music\peg.wav", 11
load sound "music\dead.wav", 14
load music "music\fight.mid", 1
rem load matrix textures
load image "plains9.bmp", 1
load image "rock1.bmp", 2
rem load in effects
load object "effects\draw1.x", 40
set object 40, 1, 0, 0
ghost object on 40
hide object 40
load object "effects\flash1.x", 41
load object "effects\flash1.x", 42
load object "effects\bolt1.x", 43
load object "effects\bolt1.x", 44
load object "effects\drwstar1.x", 45
load object "effects\drwstar2.x", 46
`set effects
set object 41, 1, 0, 0
set object 42, 1, 0, 0
set object 43, 1, 0, 0
set object 44, 1, 0, 0
set object 45, 1, 0, 0
set object 46, 1, 0, 0
scale object 41, 90, 90, 90
scale object 42, 90, 90, 90
scale object 43, 120, 120, 120
scale object 44, 120, 120, 120
scale object 45, 50, 50, 50
scale object 46, 50,50, 50
ghost object on 41
ghost object on 42
ghost object on 43
ghost object on 44
ghost object on 45
ghost object on 46
hide object 41
hide object 42
hide object 43
hide object 44
hide object 45
hide object 46
`set text font
set text transparent
set text font "Lucida sans unicode"
rem load matrix
Make matrix 1,100,100,10,10
make matrix 1,1000,1000,50,50
position matrix 2, 0, -40, 0
update matrix 2
update matrix 1
rem load sky set to backface and position
load object "models\backgrounds\sky.3ds", 1
set object 1, 1, 1, 0
scale object 1, 2000, 1500, 2000
position object 1, 2500, -1700, 2500
rem load shiro start anim and apped others
swordstart = 0
load object "models\characters\shiro\shir1dr2.x", 10 :swordend = total object frames(10)
idlestart = total object frames(10) + 1
append object "models\characters\shiro\shir1cm0.x", 10, idlestart: idleend = total object frames(10)
attackstart = total object frames(10) +1
append object "models\characters\shiro\shir1ca1.x", 10, attackstart : attackend = total object frames(10)
magstart = total object frames(10) + 1
append object "models\characters\shiro\shir1sc1.x", 10, magstart : magend = total object frames(10)
hitstart = total object frames(10) + 1
append object "models\characters\shiro\shir1hit.x", 10, hitstart : hitend = total object frames(10)
defstart = total object frames(10) + 1
append object "models\characters\shiro\shir1def.x", 10, defstart : defend = total object frames(10)
smstart = total object frames(10) + 1
append object "models\characters\shiro\shir1sm1.x", 10, smstart : smend = total object frames(10)
victorystart = total object frames(10) + 1
append object "models\characters\shiro\shir1vic.x", 10, victorystart : victoryend = total object frames(10)
itemstart = total object frames(10) + 1
append object "models\characters\shiro\shir1itm.x", 10, itemstart : itemend = total Object frames(10)
deadstart = total object frames(10) + 1
append object "models\characters\shiro\shir1ded.x", 10, deadstart : deadend = total object frames(10)
`get shiro info
shirgnd = get ground height(1, 2500, 2000)
yrotate object 10, 180
fix object pivot 10
rem set animation speed
set object speed 10, 3
play object 10, idlestart, idleend
loop object 10, idlestart, idleend
rem position shiro on the grid
position object 10, 2500, shirgnd+ 7, 2040
set object 10, 1, 1, 1, 1, 0, 1
rem load ogre
idlestart1 = 0
load object "models\monsters\ogre\ogre1std.x", 20 :idleend1 = total object frames(20)
attackstart1 = total object frames(20) + 1
append object "models\monsters\ogre\ogre1atk.x", 20, attackstart1: attackend1 = total object frames(20)
hitstart1 = total object frames(20) +1
append object "models\monsters\ogre\ogre1hit.x", 20, hitstart1 : hitend1 = total object frames(20)
monstgnd# = get ground height(1, 2700, 2000)
rem set animation speed
set object speed 20, 3
play object 20, idlestart1, idleend1
loop object 20, idlestart1, idleend1
rem position monster on the grid
position object 20, 2500,monstgnd , 2700
set object 10, 1,1,1,1,1,1
set object 20,1,1,1,1,1,1
position camera 1927, 402, 2307
point camera 2500, 50, 2450
`set fog
fog on : fog distance 9000 : fog color rgb(240,240,255)
`make a light
make light 1
set spot light 1, 50,60
`set light to object position 1, 10
position light 1, 2500, shirgnd, 2040
color light 1, rgb(0, 255,0)
point light 1, 2500, 100, 2040
hide light 1
rem variables
gamestate = 0
pos = 360
defc = 0
magic = 5
magicmenu = 6
critmenu = 10
critical = 9
critmen = 0
ret = 0
magmen = 0
monsthp = rnd(100) + 150
timing = 0
over = 0
fighttimechar = chartmax
fighttimemon = montmax
cx# = 1927
cy# = 402
cz# = 2307
maxhp(1) = rnd(150) + 200
hp(1) = maxhp(1)
mp(1) = 15
maxmp(1) = 15
tp(1) = 0
td(1) = 0
itemno(1) = 3
Tcx# = 2500
Tcy# = 50
Tcz# = 2450
timer2 = 0
`initiate snow
for i = 100 to num_particles+100
make object plain i, 14, 14
texture object i, 100
`set object i, 1, 0, 0
ghost object on i
next i
for i = 100 to num_particles+100
p#(i, 2) = 500 - rnd(500)
p#(i, 1) = rnd(2000) + 1500
p#(i, 3) = rnd(2000) + 1500
position object i, p#(i, 1),p#(i, 2), p#(i, 3)
next i
return
rem subroutine that controls the character attack
_attack:
`set variables etc
percount = 0
set object speed 10, 10
play object 10, attackstart, attackend
turn = 0
hitm = 0
count = 0
attack = 0
hit = 0
dam = rnd(20) + 10
size = 180
monsthp = monsthp - dam
x = object screen x(20)
y = object screen y(20)
counter = 0
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
do
`move character to monster
if object position z(10)< 2580 and turn = 0 then move object 10, 16
frame = object frame(10)
if object playing(10) = 0
position object 10, 2500, shirgnd, 2040
set object speed 10 , 3
loop object 10, idlestart, idleend
turn = 1
endif
if frame = 30 then play sound 1
if frame = 35
set object speed 20, 9
play object 20, hitstart1, hitend1
hitm = 1
endif
if hitm = 1
if count < 10
if count < 3 then ghost object on 20
if count > 3 then ghost object off 20
inc count
endif
`do
`if counter > 30 then exit
ink RGB(251,165,4), 0
dam$ = str$(dam)
text x, y - size , dam$
ink rgb(127, 127, 127), 0
inc counter
`menu()
` sync
`loop
endif
if object playing(20) = 0 then exit
scroll object texture 1, 0, 0.0005
ink rgb(36, 35, 24), 0
gosub _do_particles
center text 320, 2, "Slice!"
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
gamestate = 0
set object interpolation 20, 5
set object speed 20, 3
loop object 20, idlestart1, idleend1
return
_monster_attack:
swing = rnd(2)
dam = rnd(30) + 30
damdef = dam/2
if swing = 2
angle = 270
leave = 1
else
angle = 189
leave = 0
endif
timer = 0
timer2 = 0
`the swing variable controls the camera, however the camera code has been removed.
if swing = 2
do
if timer < 60
position camera 90,90,90
gosub _updatecam
inc timer
else
exit
endif
gosub _do_particles
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
endif
set object speed 20, 8
play object 20, attackstart1, attackend1
play sound 2
hitc = 0
countc = 0
monmov = 0
sound = 0
movesm = 0
do
if object playing(20)= 0
monmov = 1
position object 20, 2500, monstgnd, 2700
set object speed 20, 3
loop object 20, idlestart1, idleend1
endif
framema = object frame(20)
if framema = attackstart1 + 11 then movesm = 1
if movesm = 1
if object position z(20) > 2400 and monmov = 0 then move object 20, -11
endif
if framema = 26 then play sound 6: sound = 1
if defc = 1 then set sound volume 7, 50
if defc = 0 then set sound volume 7, 100
if sound playing(6) = 0 and sound = 1 then play sound 7 : sound = 0
if defc = 1
if hp(1) - damdef > 0
if framema = 28
set object speed 10, 15
play object 10, defstart, defend
endif
endif
if framema = 32
if hp(1) - damdef > 0
play sound 5
hitc = 1
else
play sound 12
hp(1) = 0
stop music 1
play sound 14
` play sound 11 play dead music
position object 20, 2500, monstgnd, 2700
set object speed 10, 10
play object 10, deadstart, deadend
do
position camera 90,90,90
gosub _updatecam
gosub _do_particles
center text 320, 2, "Game Over!"
if leave = 0
if angle = 188 then exit
else
if angle = 269 then exit
endif
sync
loop
over = 1
exit
endif
endif
endif
if framema = 32 and defc = 0
if hp(1) - dam > 0
set object speed 10, 10
play object 10, hitstart, hitend
hitc = 1
else
stop music 1
play sound 14
hp(1) = 0
position object 20, 2500, monstgnd, 2700
set object speed 10, 10
play object 10, deadstart, deadend
do
position camera 90,90,90
gosub _updatecam
gosub _do_particles
center text 320, 2, "Game Over!"
if leave = 0
if angle = 188 then exit
else
if angle = 269 then exit
endif
sync
loop
over = 1
exit
endif
endif
x = object screen x(10)
y = object screen y(10)
if framema > 32
if swing = 2
ink RGB(251,165,4), 0
if defc = 1
damdef$ = str$(damdef)
text x, y - 180 , damdef$
ink rgb(127, 127, 127), 0
else
dam$ = str$(dam)
text x, y - 180 , dam$
ink rgb(127, 127, 127), 0
endif
else
ink RGB(251,165,4), 0
if defc = 1
damdef$ = str$(damdef)
text x, y - 180 , damdef$
ink rgb(127, 127, 127), 0
else
dam$ = str$(dam)
text x, y - 180 , dam$
ink rgb(127, 127, 127), 0
endif
endif
endif
if hitc = 1
if countc < 10
if countc < 3 then ghost object on 10
if countc > 3 then ghost object off 10
inc countc
endif
endif
if object playing(10) = 0 then exit
scroll object texture 1, 0, 0.0005
gosub _do_particles
center text 320, 2, "Big Slap!"
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
if over = 0
position object 20, 2500, monstgnd, 2700
set object speed 20, 3
loop object 20, idlestart1, idleend1
set object speed 10, 3
loop object 10, idlestart, idleend
gamestate = 0
turn = 0
gosub _do_particles
endif
if defc = 0
if swing = 2 and hp(1) - dam > 0
do
if timer2 < 40
position camera 90,90,90
gosub _updatecam
inc timer2
else
exit
endif
gosub _do_particles
position camera 90,90,90
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
endif
endif
if defc = 1
if swing = 2 and hp(1) - damdef > 0
do
if timer2 < 40
position camera 90,90,90
gosub _updatecam
inc timer2
else
exit
endif
gosub _do_particles
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
endif
endif
if defc = 1
hp(1) = hp(1) - 25
else
hp(1) = hp(1) - 50
endif
defc = 0
return
_magic:
percount = 0
rot# = 0
dummy = 100
drawpos = -100
show object 40
show object 45
show object 46
angy# = camera angle y()
show light 1
play object 10, magstart, magend
point camera 2500, 50, 2040
play sound 4
plane1pos = 0
plane2pos = 0
lightness = 50
flag = 0
show light 1
do
if drawpos < 0
move camera 4
set ambient light lightness
inc drawpos, 1
inc rot#, 5
if flag = 4
dec lightness
flag = 0
endif
inc flag
rot# = wrapvalue(rot#)
yrotate object 40, rot#
angy# = curveangle(115, angy#, 20)
yrotate camera angy#
endif
if drawpos = 0 then effect = 1
if drawpos > -100 and effect = 1
angy# = curveangle(78, angy#, 30)
yrotate camera angy#
move camera -60
dec drawpos, 10
inc rot#, 5
yrotate object 40, wrapvalue(rot#)
dec dummy, 10
if dummy = 0
hide object 40
hide object 45
hide object 46
exit
endif
endif
position object 40, 2500, drawpos, 2060
position object 45, 2550, plane1pos, 2050
position object 46, 2460, plane2pos, 2080
y# = camera angle y()
yrotate object 46, y#
yrotate object 45, y#
scroll object texture 1, 0, 0.0005
inc plane1pos, 2.9
inc plane2pos, 2.8
gosub _do_particles
center text 320, 2, "Draw!"
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
sync
loop
loop object 10, idlestart, idleend
position camera 1927, 402, 2307
point camera 2500, 50, 2450
hide light 1
set ambient light 50
return
_defend:
percount = 0
defc = 1
return
_global_sweep:
j = 0
v=0
cx = 2500
cy = 2350
play object 10, swordstart, swordstart
do
ox = cos(v)*600
oy = sin(v)*600
v = v+5
position camera cx+ox, 402, cy+oy
point camera 2500, 50, 2450
if oy = 0
j = j + 1
endif
if ox = 0 and j = 1 then play sound 1
if j =2 then exit
gosub _do_particles
sync
loop
timing = 0
position camera 1927, 402, 2307
point camera 2500, 50, 2450
set object speed 10,12
set object interpolation 10, 1
play object 10, swordstart, swordend
do
if object frame(10) = swordend then exit
scroll object texture 1, 0, 0.0005
gosub _do_particles
sync
loop
set object frame 10, idlestart
loop object 10, idlestart, idleend
set object speed 10, 3
gosub _do_particles
gamestate = 0
return
_storm:
effect = 0
time = 0
flash# = 0
flash2#= 0
atk = 0
var = 0
counter = 0
dam = rnd(30) + 30
monsthp = monsthp - dam
size = 190
mp(1) = mp(1) - 5
count = 0
angy# = camera angle y()
do
angy# = curvevalue(54, angy#, 1)
yrotate camera angy#
if angy# < 55 then exit
scroll object texture 1, 0, 0.0005
gosub _do_particles
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
x = object screen x(20)
y = object screen y(20)
do
if time = 0
show object 43
show object 44
show object 41
show object 42
position object 43, 2500, monstgnd, 2700
position object 44, 2500, monstgnd, 2700
position object 41, 2500, monstgnd , 2700
position object 42, 2500, monstgnd-5, 2700
yrotate object 43, 90
yrotate object 44, 90
play sound 3
endif
time = 1
scroll object texture 43, 0.0, -0.04
scroll object texture 44, 0.0, 0.02
inc flash#, 10
flash# = wrapvalue(flash#)
yrotate object 42, flash#
dec flash2#
flash2# = wrapvalue(flash2#)
yrotate object 41, flash2#
if counter > 5 then ghost object on 20 : set matrix 1,1,1,1,1,1,1,1 : set matrix 2,1,1,1,1,1,1,1
if counter < 5 then ghost object off 20 : set matrix 1,1,1,1,1,1,1,0 : set matrix 2,1,1,1,1,1,1,0
inc counter
if counter = 10 then counter = 0
set object speed 20, 12
if atk = 0
play object 20, hitstart1, hitend1
atk = 1
endif
if var = 0 and object frame(20) = hitend1
play object 20, hitstart1, hitend1
var = 1
endif
ink RGB(251,165,4), 0
dam$ = str$(dam)
text x, y - size , dam$
ink rgb(127, 127, 127), 0
inc count
if object playing(20) = 0
exit
endif
gosub _do_particles
scroll object texture 1, 0, 0.0005
gosub _do_particles
center text 320, 2, "Storm!"
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
sync
loop
hide object 43
hide object 44
hide object 42
hide object 41
ghost object off 20
set object speed 20, 3
set matrix 1,1,1,1,1,1,1,1
set matrix 2,1,1,1,1,1,1,1
loop object 20, idlestart1, idleend1
position camera 1927, 402, 2307
do
angy# = curvevalue(78, angy#, 30)
yrotate camera angy#
if angy# > 77 then exit
scroll object texture 1, 0, 0.0005
gosub _do_particles
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
sync
loop
pos = 360
gamestate = 0
set object speed 20, 3
return
_critical:
percount = 0
set object speed 10, 15
set object speed 20, 6
play object 10, smstart, smend
hitmsm = 0
countsm = 0
attacksm = 0
turnsm = 0
dam = rnd(20) + 20
monsthp = monsthp - dam
size = 180
x = object screen x(20)
y = object screen y(20)
count = 0
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
do
framesm = object frame(10)
if framesm > smstart + 17
if object position z(10)< 2580 and turnsm = 0 then move object 10, 35
endif
if object playing(10) = 0
position object 10, 2500, shirgnd, 2040
set object speed 10 , 3
loop object 10, idlestart, idleend
turnsm = 1
endif
if framesm = smstart + 31
play sound 10
play sound 7
play object 20, hitstart1, hitend1
hitmsm = 1
endif
if framesm = smstart + 40
play sound 10
play sound 7
endif
if framesm = smstart + 40 then countsm = 0
if hitmsm = 1
if countsm < 10
if countsm < 3 then ghost object on 20
if countsm > 3 then ghost object off 20
inc countsm
endif
ink RGB(251,165,4), 0
dam$ = str$(dam)
text x, y - size , dam$
ink rgb(127, 127, 127), 0
endif
if object playing(20) = 0 then exit
scroll object texture 1, 0, 0.0005
gosub _do_particles
center text 320, 2, "Killer Slice"
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
sync
loop
set object speed 20, 3
pos = 360
gamestate = 0
criticalstate = 0
set object interpolation 20, 5
set object speed 20, 3
loop object 20, idlestart1, idleend1
return
_Item:
percount = 0
timer = 0
set object speed 10, 9
play object 10, itemstart, itemend
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
do
if object playing(10) = 0
exit
endif
do
if timer < 130
position camera 90,90,90
gosub _updatecam
inc timer
else
exit
endif
gosub _do_particles
center text 320, 2, "item"
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
gosub _do_particles
center text 320, 2, "item"
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
sync
loop
set object speed 10, 3
loop object 10, idlestart, idleend
pos = 360
gamestate = 0
return
_delete_world:
rem delete all objects, images etc
delete image 32
delete image 33
`load image "menu\magic.bmp", 34
delete image 36
`load image "menu\highlight2.bmp", 35
`delete image 37
delete image 38
delete image 39
`delete image 40
delete image 41
`delete image 42
delete image 100
`delete image 43
delete image 44
delete sound 1
delete sound 2
delete sound 3
delete sound 4
delete sound 5
delete sound 6
delete sound 7
delete sound 8
delete sound 9
delete sound 10
rem load matrix texture
delete image 1
delete image 2
rem load in effects
delete object 40
delete object 41
delete object 42
delete object 43
delete object 44
delete object 45
delete object 46
delete matrix 2
delete matrix 1
rem delete sky set to backface and position
delete object 1
rem delete shiro
delete object 10
rem delete ogre
`delete object 20
delete light 1
for i = 100 to num_particles+100
delete object i
next i
return
`---------------------------------------
_do_particles:
for i = 100 to num_particles+100
if p#(i, 2) < 0 then p#(i, 2) = 500
cameraposy# = camera angle y()
cameraposx# = camera angle x()
cameraposz# = camera angle z()
set object rotation zyx i
rotate object i, camerapsox#, cameraposy#, cameraposz#
position object i, p#(i, 1), p#(i, 2), p#(i,3)
p#(i, 2) = p#(i, 2) - 3:`- (rnd(6)+3)
next i
return
`fade monster to red and then to black with ghosting to make invisible when monster dead
fadechar:
color object objid, RGB(255, 0, 0)
ghost object on objid
x = 255
repeat
color object objid, rgb(x, 0, 0)
dec x, 6
gosub _do_particles
position object objid, object position x(objid), object position y(objid), object position z(objid)
sync
until x <0
delete object objid
return
_cure:
timer = 0
timer2 = 0
plane1pos = 400
plane2pos = 400
make object cube 5000, 4
position object 5000, 2500,50, 2450
hide object 5000
x = object screen x(10)
y = object screen y(10)
show object 45
show object 46
position object 45, 2500, plane1pos, 2110
position object 46, 2500, plane2pos, 2000
play sound 15
do
if plane1pos > 0
y# = camera angle y()
yrotate object 45, y#
yrotate object 46, y#
dec plane1pos, 5.9
dec plane2pos, 5.8
position object 45, 2500, plane1pos, 2120
position object 46, 2500, plane2pos, 2000
ink rgb(0, 255, 0), 0
text x - 30, y-200, "100"
scroll object texture 1, 0, 0.0005
gosub _do_particles
center text 320, 2, "Cure!"
ink rgb(36, 35, 24), 0
box 615 - percent , 392, 615, 399
else
exit
endif
sync
loop
do
if timer2 < 50
position camera 90,90,90
gosub _updatecam
inc timer2
else
exit
endif
gosub _do_particles
ink rgb(36, 35, 24), 0
box 615 - percent, 392, 615, 399
sync
loop
delete object 5000
hp(1) = hp(1) + 100
if hp(1) > maxhp(1) then hp(1) = maxhp(1)
itemno(1) = itemno(1) - 1
return
_updatecam:
position camera 90,90,90
return
Dont worry and keep a cool head.