Thanks.
Here is the code for my old engine:
Rem Project: Realms Of Tutopia I
Rem Created: 21/10/2004 13:56:17
Rem Author: Andrew Neale
set display mode 640,480,32
autocam off
Rem ************************************************************
Rem ************************************************************
Rem *** Main Menu ***
Rem ************************************************************
Rem ************************************************************
sync on
sync rate 0
sync
load sound "song2.wav",1
loop sound 1
backdrop on
color backdrop rgb(0,0,0)
load image "border.bmp",1,1
MakeHudObject(1,1,640,480,0,0,0,0)
load image "1player.bmp",2
MakeHudObject(2,2,256,64,172,192,1,0)
1Player=2
load image "2player.bmp",3
MakeHudObject(3,3,256,64,172,264,1,0)
2Player=3
load image "quit.bmp",4
MakeHudObject(4,4,256,64,172,336,1,0)
Quit=4
set ambient light 50
sync off
sync on
sync rate 0
MainMenu:
do
OldSelected=Selected
Selected=pick object(mousex(),mousey(),2,65535)
if Selected>0
ghost object off Selected
endif
if OldSelected>0 and OldSelected<>Selected
ghost object on OldSelected
endif
if mouseclick()=1
exit
endif
sync
loop
if Selected=1Player
for o=1 to 65535
if object exist(o)=1
delete object o
endif
next o
for i=1 to 100
if image exist(i)=1
delete image i
endif
next i
goto 1Player
endif
if Selected=2Player then goto MainMenu
if Selected=Quit then end
1Player:
do
if mouseclick()=0 then exit
loop
load image "border.bmp",1,1
MakeHudObject(1,1,640,480,0,0,0,0)
load image "newgame.bmp",2
MakeHudObject(2,2,256,64,172,192,1,0)
NewGame=2
load image "loadgame.bmp",3
MakeHudObject(3,3,256,64,172,264,1,0)
LoadGame=3
set ambient light 50
sync off
sync on
sync rate 0
1PlayerMenu:
do
OldSelected=Selected
Selected=pick object(mousex(),mousey(),2,65535)
if Selected>0
ghost object off Selected
endif
if OldSelected>0 and OldSelected<>Selected
ghost object on OldSelected
endif
if mouseclick()=1
exit
endif
sync
loop
if Selected=NewGame
for o=1 to 65535
if object exist(o)=1
delete object o
endif
next o
for i=1 to 100
if image exist(i)=1
delete image i
endif
next i
delete sound 1
goto NewGame
endif
if Selected=LoadGame then goto 1PlayerMenu
NewGame:
global LevelName as string
Rem ************************************************************
Rem ************************************************************
Rem *** Level 1 - Tunnels Of Undergroundness ***
Rem ************************************************************
Rem ************************************************************
Rem ************************************************************
Rem *** Load Level ***
Rem ************************************************************
LevelName="level1"
gosub LoadGameScript
load sound "song3.wav",1
loop sound 1
Rem ************************************************************
Rem *** Level 1 Main Loop ***
Rem ************************************************************
do
gosub ControlPlayer
gosub ControlStats
gosub ControlAI
sync
loop
Rem ************************************************************
Rem ************************************************************
Rem *** Subroutines ***
Rem ************************************************************
Rem ************************************************************
Rem ************************************************************
Rem *** Control Player ***
Rem ************************************************************
ControlPlayer:
Character.OldPosX=Character.PosX
Character.OldPosY=Character.PosY
Character.OldPosZ=Character.PosZ
if Character.Status<Attack1 or object playing(Object.Player)=0
if spacekey()=1
play object Object.Player,Character.Attack6Start,Character.Attack6End
Character.Status=Attack6
set object speed Object.Player,Character.Attack6AnimSpeed
endif
if mouseclick()=1
if object frame(Object.Player)<Character.Attack1Start or object frame(Object.Player)>Character.Attack1End
Attack=rnd(4)
if Attack<1 then Attack=1
if Attack>4 then Attack=4
if Attack=1
play object Object.Player,Character.Attack1Start,Character.Attack1End
Character.Status=Attack1
set object speed Object.Player,Character.Attack1AnimSpeed
endif
if Attack=2
play object Object.Player,Character.Attack2Start,Character.Attack2End
Character.Status=Attack2
set object speed Object.Player,Character.Attack2AnimSpeed
endif
if Attack=3
play object Object.Player,Character.Attack3Start,Character.Attack3End
Character.Status=Attack3
set object speed Object.Player,Character.Attack3AnimSpeed
endif
if Attack=4
play object Object.Player,Character.Attack4Start,Character.Attack4End
Character.Status=Attack4
set object speed Object.Player,Character.Attack4AnimSpeed
endif
endif
endif
if mouseclick()=2
if object frame(Object.Player)<Character.Attack5Start or object frame(Object.Player)>Character.Attack5End
play object Object.Player,Character.Attack5Start,Character.Attack5End
Character.Status=Attack5
set object speed Object.Player,Character.Attack5AnimSpeed
endif
endif
endif
if shiftkey()=1
Character.WalkAnimSpeed=40
Character.WalkSpeed=0.40
else
Character.WalkAnimSpeed=22
Character.WalkSpeed=0.20
endif
if keystate(17)=1 and keystate(30)=0 and keystate(31)=0 and keystate(32)=0
Character.AngY=curveangle(camera angle y(),Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=1 and keystate(30)=1 and keystate(31)=0 and keystate(32)=0
Character.AngY=curveangle(camera angle y()-45,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=1 and keystate(30)=0 and keystate(31)=0 and keystate(32)=1
Character.AngY=curveangle(camera angle y()+45,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=0 and keystate(30)=1 and keystate(31)=0 and keystate(32)=0
Character.AngY=curveangle(camera angle y()-90,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=0 and keystate(30)=0 and keystate(31)=0 and keystate(32)=1
Character.AngY=curveangle(camera angle y()+90,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=0 and keystate(30)=0 and keystate(31)=1 and keystate(32)=0
Character.AngY=curveangle(camera angle y()+180,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=0 and keystate(30)=1 and keystate(31)=1 and keystate(32)=0
Character.AngY=curveangle(camera angle y()-135,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if keystate(17)=0 and keystate(30)=0 and keystate(31)=1 and keystate(32)=1
Character.AngY=curveangle(camera angle y()+135,Character.AngY,15)
if Character.Status=Idle or Character.Status=Walk
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
if Character.Status>Idle and object playing(Object.Player)=0
Character.Status=Walk
if object playing(Object.Player)=0 or object frame(Object.Player)>Character.WalkEnd
set object speed Object.Player,Character.WalkAnimSpeed
play object Object.Player,Character.WalkStart,Character.WalkEnd
endif
endif
endif
if scancode()=0 and object playing(Object.Player)=0
Character.Status=Idle
if object playing(Object.Player)=0
set object speed Object.Player,Character.IdleAnimSpeed
play object Object.Player,Character.IdleStart,Character.IdleEnd
endif
endif
if object playing(Object.Player)=1 and Character.Status=Walk
Character.PosX=newxvalue(Character.PosX,Character.AngY,Character.WalkSpeed)
Character.PosZ=newzvalue(Character.PosZ,Character.AngY,Character.WalkSpeed)
endif
position object Object.PlayerLevelCollision,Character.PosX+2,Character.PosY+4,Character.PosZ
yrotate object Object.PlayerLevelCollision,Character.AngY
if object collision(Object.PlayerLevelCollision,Object.Level)>0
Character.PosX=Character.OldPosX
Character.PosY=Character.OldPosY
Character.PosZ=Character.OldPosZ
endif
position object Object.Player,Character.PosX,Character.PosY,Character.PosZ
yrotate object Object.Player,Character.AngY
if Character.Status<>Hit
position particles Object.Player,Character.PosX,Character.PosY,Character.PosZ
endif
if Character.Status=Hit
set particle emissions Object.Player,10
else
set particle emissions Object.Player,0
endif
gosub Camera
`set camera to follow Character.PosX,Character.PosY,Character.PosZ,Character.AngY,35,35,3.5,0
`point camera Character.PosX,Character.PosY,Character.PosZ
gosub Target
return
Rem ************************************************************
Rem *** Control Stats ***
Rem ************************************************************
ControlStats:
set cursor 0,0
paste sprite Bob.HUD,0,352
ink rgb(200,200-(Character.HP*2),0),rgb(0,0,0)
box 152,406,152+(Character.HP*4.5),426
ink rgb(255,255,255),rgb(0,0,0)
set text font "Excalibur SF"
set text to bold
set text size 20
If Character.XP>=Character.TargetXP
Character.XP=Character.XP-Character.TargetXP
Character.Level=Character.Level+1
Character.TargetXP=Character.TargetXP+100
endif
text 154,373,"Level "+str$(Character.Level)+" Experience "+str$(Character.XP)+"/"+str$(Character.TargetXP)
return
Rem ************************************************************
Rem *** Load Level ***
Rem ************************************************************
LoadLevel:
load object "levels\"+LevelName+".x",Object.Level
set object ambient Object.Level,0
load object "levels\"+LevelName+"_lm.x",Object.LevelLightMap
ghost object on Object.LevelLightMap,1
set object ambient Object.LevelLightMap,0
Return
Rem ************************************************************
Rem *** Load Player ***
Rem ************************************************************
LoadPlayer:
load object "tauron/tauron8.x",Object.Player
scale object Object.Player,100,100,100
set object speed Object.Player,Character.IdleAnimSpeed
set object collision off Object.Player
make object box Object.PlayerLevelCollision,5,3,5
hide object Object.PlayerLevelCollision
load image "blood.bmp",Image.Blood
make particles Object.Player,Image.Blood,50,10
set particle emissions Object.Player,0
set particle speed Object.Player,0.01
set particle gravity Object.Player,5
return
Rem ************************************************************
Rem *** Setup Variables ***
Rem ************************************************************
SetupVariables:
type Object
Player as integer
Level as integer
LevelLightMap as integer
PlayerLevelCollision as integer
EnemyLevelCollision as integer
endtype
global Object as Object
Object.Player=1
Object.Level=2
Object.LevelLightMap=3
Object.PlayerLevelCollision=4
Object.EnemyLevelCollision=5
type Character
IdleStart as integer
IdleEnd as integer
WalkStart as integer
WalkEnd as integer
Attack1Start as integer
Attack1End as integer
Attack2Start as integer
Attack2End as integer
Attack3Start as integer
Attack3End as integer
Attack4Start as integer
Attack4End as integer
Attack5Start as integer
Attack5End as integer
Attack6Start as integer
Attack6End as integer
HitStart as integer
HitEnd as integer
Status as integer
PosX as float
PosY as float
PosZ as float
OldPosX as float
OldPosY as float
OldPosZ as float
AngY as float
WalkAnimSpeed as integer
IdleAnimSpeed as integer
Attack1AnimSpeed as integer
Attack2AnimSpeed as integer
Attack3AnimSpeed as integer
Attack4AnimSpeed as integer
Attack5AnimSpeed as integer
Attack6AnimSpeed as integer
HitAnimSpeed as integer
WalkSpeed as float
TurnSpeed as float
HP as integer
MP as integer
XP as integer
TargetXP as integer
Level as integer
endtype
global Character as Character
Character.IdleStart=13
Character.IdleEnd=18
Character.WalkStart=1
Character.WalkEnd=11
Character.Attack1Start=19
Character.Attack1End=25
Character.Attack2Start=39
Character.Attack2End=44
Character.Attack3Start=45
Character.Attack3End=50
Character.Attack4Start=51
Character.Attack4End=63
Character.Attack5Start=26
Character.Attack5End=38
Character.Attack6Start=64
Character.Attack6End=71
Character.HitStart=72
Character.HitEnd=76
Character.Status=Idle
Character.WalkAnimSpeed=22
Character.IdleAnimSpeed=5
Character.Attack1AnimSpeed=10
Character.Attack2AnimSpeed=10
Character.Attack3AnimSpeed=10
Character.Attack4AnimSpeed=10
Character.Attack5AnimSpeed=16
Character.Attack6AnimSpeed=8
Character.HitAnimSpeed=8
Character.WalkSpeed=0.20
Character.TurnSpeed=2.00
Character.HP=100
Character.MP=100
Character.TargetXP=100
Character.Level=1
global Idle as integer
Idle=1
global Walk as integer
Walk=2
global Attack1 as integer
Attack1=3
global Attack2 as integer
Attack2=4
global Attack3 as integer
Attack3=5
global Attack5 as integer
Attack5=7
global Attack6 as integer
Attack6=8
global Hit as integer
Hit=9
global FallOver as integer
FallOver=10
global Dead as integer
Dead=11
global LevelName as string
global Temporary as string
global FogBrightness as string
global FogDistance as string
global AmbientBrightness as string
global AmbientColor as string
type CameraPoint
LowXArea as float
HighXArea as float
LowZArea as float
HighZArea as float
PosX as float
PosY as float
PosZ as float
AngX as float
AngY as float
AngZ as float
endtype
dim CameraPoint(65535) as CameraPoint
global CurrentCamera as integer
global Camera as integer
Camera=1
type Image
HUD
Blood
endtype
global Image as Image
Image.HUD=1
Image.Blood=2
type Bob
HUD
endtype
global Bob as Bob
Bob.HUD=1
global EnemyObj as integer
EnemyObj=1000
type Target
LowXArea as float
HighXArea as float
LowZArea as float
HighZArea as float
endtype
global Target as Target
type Enemy
IdleStart as integer
IdleEnd as integer
WalkStart as integer
WalkEnd as integer
Attack1Start as integer
Attack1End as integer
Attack2Start as integer
Attack2End as integer
HitStart as integer
HitEnd as integer
FallOverStart as integer
FallOverEnd as integer
DeadStart as integer
DeadEnd as integer
Status as integer
PosX as float
PosY as float
PosZ as float
OldPosX as float
OldPosY as float
OldPosZ as float
AngY as float
OldAngY as float
WalkAnimSpeed as integer
IdleAnimSpeed as integer
Attack1AnimSpeed as integer
Attack2AnimSpeed as integer
HitAnimSpeed as integer
FallOverAnimSpeed as integer
DeadAnimSpeed as integer
WalkSpeed as float
TurnSpeed as float
HP as integer
endtype
dim Enemy(65535) as Enemy
return
Rem ************************************************************
Rem *** Setup Collision ***
Rem ************************************************************
SetupCollision:
set object collision on Object.Level
set object collision to polygons Object.Level
set object collision on Object.PlayerLevelCollision
set object collision to boxes Object.PlayerLevelCollision
make object box Object.EnemyLevelCollision,3,1,3
position object Object.EnemyLevelCollision,0,100,0
hide object Object.EnemyLevelCollision
set object collision on Object.EnemyLevelCollision
set object collision to boxes Object.EnemyLevelCollision
return
Rem ************************************************************
Rem *** Setup Lighting ***
Rem ************************************************************
SetupLighting:
set ambient light val(AmbientBrightness)
color ambient light rgb(val(AmbientColor),val(AmbientColor),val(AmbientColor))
backdrop on
color backdrop rgb(0,0,0)
return
Rem ************************************************************
Rem *** Setup Fog ***
Rem ************************************************************
SetupFog:
fog on
fog distance val(FogDistance)
fog color rgb(val(FogBrightness),val(FogBrightness),val(FogBrightness))
return
Rem ************************************************************
Rem *** Manual Synchronisation ***
Rem ************************************************************
ManualSynchronisation:
sync on
sync rate 200
return
Rem ************************************************************
Rem *** Optimise ***
Rem ************************************************************
Optimise:
for o=1 to 65535
if object exist(o)=1
set object cull o,1
endif
next o
return
Rem ************************************************************
Rem *** Load Game Script ***
Rem ************************************************************
LoadGameScript:
open to read 1,"levels\"+LevelName+".lgs"
ReadLoadGameScript:
read string 1,Temporary
if Temporary="Start()" then goto ReadLoadGameScript
if Temporary="Initialise Variables()" then gosub SetupVariables
if Temporary="Load Player()" then gosub LoadPlayer
if Temporary="Load Level"
read string 1,Temporary
read string 1,LevelName
read string 1,Temporary
gosub LoadLevel
goto ReadLoadGameScript
endif
if Temporary="Add Enemy" then gosub AddEnemy
if Temporary="Setup Collision()" then gosub SetupCollision
if Temporary="Setup Lighting"
read string 1,Temporary
read string 1,AmbientBrightness
read string 1,AmbientColor
read string 1,Temporary
gosub SetupLighting
goto ReadLoadGameScript
endif
if Temporary="Setup Fog"
read string 1,Temporary
read string 1,FogDistance
read string 1,FogBrightness
read string 1,Temporary
gosub SetupFog
goto ReadLoadGameScript
endif
if Temporary="Add Camera"
read string 1,Temporary
read string 1,Temporary
CameraPoint(Camera).LowXArea=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).HighXArea=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).LowZArea=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).HighZArea=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).PosX=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).PosY=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).PosZ=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).AngX=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).AngY=val(Temporary)
read string 1,Temporary
CameraPoint(Camera).AngZ=val(Temporary)
read string 1,Temporary
Camera=Camera+1
endif
if Temporary="Add Target"
read string 1,Temporary
read string 1,Temporary
Target.LowXArea=val(Temporary)
read string 1,Temporary
Target.HighXArea=val(Temporary)
read string 1,Temporary
Target.LowZArea=val(Temporary)
read string 1,Temporary
Target.HighZArea=val(Temporary)
read string 1,Temporary
endif
if Temporary="Optimise()" then gosub Optimise
if Temporary="Load HUD()" then gosub LoadHUD
if Temporary="Manual Synchronisation()" then gosub ManualSynchronisation
if Temporary="End()" then goto LoadGameScriptRead
goto ReadLoadGameScript
LoadGameScriptRead:
close file 1
return
Rem ************************************************************
Rem *** Load HUD ***
Rem ************************************************************
LoadHUD:
load image "hud3.bmp",Image.HUD,1
sprite Bob.HUD,-1000,-1000,Image.HUD
return
Rem ************************************************************
Rem *** Add Enemy ***
Rem ************************************************************
AddEnemy:
read string 1,Temporary
read string 1,Temporary
load object Temporary+"\"+Temporary+".x",EnemyObj
scale object EnemyObj,250,250,250
make particles EnemyObj,Image.Blood,50,10
set particle emissions EnemyObj,0
set particle speed EnemyObj,0.01
set particle gravity EnemyObj,5
if Temporary="enemy1"
Enemy(EnemyObj).HitStart=1
Enemy(EnemyObj).HitEnd=6
Enemy(EnemyObj).HitAnimSpeed=8
Enemy(EnemyObj).FallOverStart=7
Enemy(EnemyObj).FallOverEnd=25
Enemy(EnemyObj).FallOveranimSpeed=8
Enemy(EnemyObj).DeadStart=7
Enemy(EnemyObj).DeadEnd=10
Enemy(EnemyObj).DeadanimSpeed=8
Enemy(EnemyObj).IdleStart=26
Enemy(EnemyObj).IdleEnd=30
Enemy(EnemyObj).IdleAnimSpeed=4
Enemy(EnemyObj).WalkStart=31
Enemy(EnemyObj).WalkEnd=34
Enemy(EnemyObj).WalkAnimSpeed=8
Enemy(EnemyObj).WalkSpeed=0.075
Enemy(EnemyObj).Attack1Start=36
Enemy(EnemyObj).Attack1End=44
Enemy(EnemyObj).Attack1AnimSpeed=4
Enemy(EnemyObj).HP=100
endif
read string 1,Temporary
position object EnemyObj,val(Temporary),object position y(EnemyObj),object position z(EnemyObj)
read string 1,Temporary
position object EnemyObj,object position x(EnemyObj),val(Temporary),object position z(EnemyObj)
read string 1,Temporary
position object EnemyObj,object position x(EnemyObj),object position y(EnemyObj),val(Temporary)
Enemy(EnemyObj).PosX=object position x(EnemyObj)
Enemy(EnemyObj).PosY=object position y(EnemyObj)
Enemy(EnemyObj).PosZ=object position z(EnemyObj)
read string 1,Temporary
yrotate object EnemyObj,val(Temporary)
Enemy(EnemyObj).AngY=object angle y(EnemyObj)
EnemyObj=EnemyObj+1
read 1,Temporary
return
Rem ************************************************************
Rem *** Camera ***
Rem ************************************************************
Camera:
CurrentCamera=1
for C=1 to 1000
if Character.PosX>=CameraPoint(C).LowXArea
if Character.PosX=<CameraPoint(C).HighXArea
if Character.PosZ>=CameraPoint(C).LowZArea
if Character.PosZ=<CameraPoint(C).HighZArea
CurrentCamera=C
goto CameraChosen
endif
endif
endif
endif
next C
CameraChosen:
position camera curvevalue(CameraPoint(C).PosX,camera position x(),25),curvevalue(CameraPoint(C).PosY,camera position y(),25),curvevalue(CameraPoint(C).PosZ,camera position z(),25)
rotate camera curveangle(CameraPoint(C).AngX,camera angle x(),25),curveangle(CameraPoint(C).AngY,camera angle y(),25),curveangle(CameraPoint(C).AngZ,camera angle z(),25)
return
Rem ************************************************************
Rem *** Target ***
Rem ************************************************************
Target:
if Character.PosX>=Target.LowXArea
if Character.PosX=<Target.HighXArea
if Character.PosZ>=Target.LowZArea
if Character.PosZ=<Target.HighZArea
end
endif
endif
endif
endif
return
Rem ************************************************************
Rem *** Control AI ***
Rem ************************************************************
ControlAI:
for e=1000 to EnemyObj-1
if Enemy(e).HP>0
if distance(Object.Player,e)<50 and distance(Object.Player,e)>7
if Enemy(e).Status<>Hit and Enemy(e).Status<>FallOver
Enemy(e).OldAngY=Enemy(e).AngY
point object e,Character.PosX,Enemy(e).PosY,Character.PosZ
Enemy(e).AngY=object angle y(e)
yrotate object e,Enemy(e).OldAngY
Enemy(e).OldAngY=curveangle(Enemy(e).AngY,Enemy(e).OldAngY,15)
if Enemy(e).Status=Walk or Enemy(e).Status=Idle
if Enemy(e).Status<>Walk or object playing(e)=0
play object e,Enemy(e).WalkStart,Enemy(e).WalkEnd
set object speed e,Enemy(e).WalkAnimSpeed
Enemy(e).Status=Walk
endif
Enemy(e).OldPosX=Enemy(e).PosX
Enemy(e).OldPosZ=Enemy(e).PosZ
Enemy(e).PosX=newxvalue(Enemy(e).PosX,Enemy(e).OldAngY,Enemy(e).WalkSpeed)
Enemy(e).PosZ=newzvalue(Enemy(e).PosZ,Enemy(e).OldAngY,Enemy(e).WalkSpeed)
position object Object.EnemyLevelCollision,Enemy(e).PosX,Enemy(e).PosY+5,Enemy(e).PosZ
if object collision(Object.EnemyLevelCollision,Object.Level)>0
Enemy(e).PosX=Enemy(e).OldPosX
Enemy(e).PosZ=Enemy(e).OldPosZ
endif
position object e,Enemy(e).PosX,Enemy(e).PosY,Enemy(e).PosZ
if Enemy(e).Status<>Hit and Enemy(e).Status<>FallOver
position particles e,Enemy(e).PosX,Enemy(e).PosY,Enemy(e).PosZ
endif
endif
endif
endif
if Enemy(e).Status=Hit or Enemy(e).Status=FallOver
set particle emissions e,10
else
set particle emissions e,0
endif
if distance(Object.Player,e)<9
if Enemy(e).Status=Idle or Enemy(e).Status=Walk
Enemy(e).Status=Attack1
play object e,Enemy(e).Attack1Start,Enemy(e).Attack1End
set object speed e,Enemy(e).Attack1AnimSpeed
endif
endif
`
if Enemy(e).Status=Attack1
position object Object.EnemyLevelCollision,newxvalue(Enemy(e).PosX,Enemy(e).OldAngY,5.0),Enemy(e).PosY,newzvalue(Enemy(e).PosZ,Enemy(e).OldAngY,5.0)
if distance(Object.Player,Object.EnemyLevelCollision)<4 and facing(e,Object.Player)=1
if object frame(Object.Player)<Character.HitStart or object frame(e)>Character.HitEnd
set object frame Object.Player,Character.HitStart
endif
if Character.Status<>Hit
Character.HP=Character.HP-5
play object Object.Player,Character.HitStart,Character.HitEnd
set object speed Object.Player,Character.HitAnimSpeed
endif
Character.Status=Hit
Character.PosX=newxvalue(Character.PosX,Enemy(e).AngY,0.025)
Character.PosZ=newzvalue(Character.PosZ,Enemy(e).AngY,0.025)
endif
endif
`
if Character.Status=Attack1 or Character.Status=Attack2 or Character.Status=Attack3 or Character.Status=Attack4
if distance(Object.Player,e)<10 and facing(Object.Player,e)=1
Temp=rnd(5)
if Temp=1
if Enemy(e).Status<>FallOver and Enemy(e).Status<>Hit
Enemy(e).HP=Enemy(e).HP-(Character.Level*15)
Character.XP=Character.XP+5
set object frame e,Enemy(e).FallOverStart
play object e,Enemy(e).FallOverStart,Enemy(e).FallOverEnd
set object speed e,Enemy(e).FallOverAnimSpeed
Enemy(e).Status=FallOver
endif
endif
if Temp=2 or Temp=3 or Temp=4 or Temp=5
if Enemy(e).Status<>Hit and Enemy(e).Status<>FallOver
Enemy(e).HP=Enemy(e).HP-(Character.Level*10)
Character.XP=Character.XP+2
set object frame e,Enemy(e).HitStart
play object e,Enemy(e).HitStart,Enemy(e).HitEnd
set object speed e,Enemy(e).HitAnimSpeed
Enemy(e).Status=Hit
endif
endif
endif
endif
if Character.Status=Attack5
if distance(Object.Player,e)<10
if object frame(e)<Enemy(e).FallOverStart or object frame(e)>Enemy(e).FallOverEnd
set object frame e,Enemy(e).FallOverStart
endif
if object playing(e)=0
Enemy(e).HP=Enemy(e).HP-(Character.Level*5)
Character.XP=Character.XP+1
play object e,Enemy(e).FallOverStart,Enemy(e).FallOverEnd
set object speed e,Enemy(e).FallOverAnimSpeed
endif
Enemy(e).Status=FallOver
endif
endif
if Character.Status=Attack6
if distance(Object.Player,e)<10
if facing(Object.Player,e)=0
point object Object.Player,Enemy(e).PosX,Character.PosY,Enemy(e).PosZ
Character.AngY=object angle y(Object.Player)
endif
if facing(Object.Player,e)=1
if Enemy(e).Status=FallOver
Enemy(e).HP=0
endif
endif
endif
endif
if object playing(e)=0
Enemy(e).Status=Idle
endif
if Enemy(e).Status=Idle and object playing(e)=0
set object speed e,Enemy(e).IdleAnimSpeed
play object e,Enemy(e).IdleStart,Enemy(e).IdleEnd
endif
if Enemy(e).HP=0
set object frame e,Enemy(e).DeadStart
play object e,object frame(e),Enemy(e).DeadEnd
set object speed e,Enemy(e).DeadAnimSpeed
Enemy(e).Status=Dead
Character.XP=Character.XP+10
set particle emissions e,0
endif
else
if object playing(e)=0
move object down e,0.05
endif
endif
next e
return
Rem ************************************************************
Rem *** Distance Function ***
Rem ************************************************************
function distance(obj1,obj2)
dist=sqrt(((object position x(obj1)-object position x(obj2))*(object position x(obj1)-object position x(obj2)))+((object position z(obj1)-object position z(obj2))*(object position z(obj1)-object position z(obj2))))
endfunction dist
Rem ************************************************************
Rem *** Facing Function ***
Rem ************************************************************
function facing(obj1,obj2)
facing=0
oldtemp=object angle y(obj1)
point object obj1,object position x(obj2),object position y(obj1),object position z(obj2)
smalltemp=object angle y(obj1)-45
largetemp=object angle y(obj1)+45
yrotate object obj1,oldtemp
if object angle y(obj1)>smalltemp and object angle y(obj1)<largetemp
facing=1
endif
endfunction facing
I'll upload media soon.
The code is not fully commented or optimised so feel free to ask questions or improve it.
Instead of using my media you can change filenames appropriately and use your own. You still however need the scripts.
To make a script open notepad and use the following commands:
[b]Start()[/b]
Starts the current script
[b]Initialise Variables()[/b]
Starts off all game variables
[b]Load Player()[/b]
Loads player object and collision boxes
[b]Load Level
{
levelname.x
}[/b]
Loads the chosen level
[b]Add enemy
{
enemyname.x
xposition
yposition
zposition
yangle
}[/b]
Positions the chosen enemy at the chosen location
[b]Setup Collision()[/b]
Sets up all game collision
[b]Setup Lighting
{
Brightness
Color
}[/b]
Sets ambient light to selected levels
[b]Setup Fog
{
Distance
Brightness
}[/b]
Sets fog to selected values
[b]Add Camera
{
LowXArea
HighXArea
LowZArea
HighZArea
xposition
yposition
zposition
xangle
yangle
zangle
}[/b]
If the player's position is between lowxarea and highxarea and lowzarea and highzarea then the camera will curve to xposition,yposition,zposition and rotate to xangle,yangle,zangle
[b]Add Target
{
LowXArea
HighXArea
LowZArea
HighZArea
}[/b]
If the player's position is between LowXArea and HighXArea and LowZArea and HighZArea then the level is complete
[b]Optimise()[/b]
Optimises the game for speed
[b]Load HUD()[/b]
Loads the sprites for the HUD
[b]Manual Synchronisation()[/b]
Sets up the synchronisation levels for the game
[b]End()[/b]
Ends the script
Then save as a .lgs file.
I hope this helps some people.