Ok heres everything in the main file.
load()
//createUI()
Function main()
setGadgetText console, "Game Started."
Load Image "mediaimagessmile.png", 22
Make Object sphere 999, 30
Texture Object enemy, 22
MAKE OBJECT SPHERE 9999,600
MAKE MESH FROM OBJECT 1,9999
DELETE OBJECT 9999
ADD LIMB 1,1,1
OFFSET LIMB 1,1,0,0,10000
DELETE MESH 1
Scale Limb 1, 1, 600, 600, 600
Hide Limb 1, 1
MAKE OBJECT SPHERE 9998,30
MAKE MESH FROM OBJECT 2,9998
DELETE OBJECT 9998
ADD LIMB enemy,1,2
OFFSET LIMB enemy,1,0,0,1000
DELETE MESH 2
Hide Limb enemy, 1
Position Object 1, Camera Position X(), Camera Position Y(), Camera Position Z()
//Position Object enemy, Camera Position X(), Camera Position Y(), Camera Position Z()
remstart
------------------
START AI
------------------ remend
AI Start
AI Set Radius 70
AI Add Container 1
AI Add Player 1
AI Add Enemy 999
AI Set Entity Speed enemy, 200
AI Set Entity Aggressive enemy
AI Set Entity View Arc enemy,90,180
AI Set Entity View Range enemy,1000
AI Set Entity Hearing Range enemy,1000
AI Make Path 1
AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750):AI Path Add Point 1, Rnd(750), Rnd(750)
AI Entity Assign Patrol Path enemy,1
Hide Mouse
remstart
----------------
START PHYSICS
--------------- remend
Phy Start
Make Object Box 10, 1000, 1, 1000
Position Object 10, Camera Position X(), Camera Position Y() - 15, Camera Position Z()
Phy Make Rigid Body static Box 10
Phy Make Rigid Body Dynamic Sphere enemy
Phy Make Box Character Controller 1, Object Position X(1), Object Position Y(1), Object Position Z(1), 10, 10, 10, 1, 5, 20
phy set rigid body position 10, Camera Position X(), Camera Position Y(), Camera Position Z()
Do
Position Object 20, Object Position X(enemy) - 30, Object Position Y(enemy) - 15, Object Position Z(enemy)
Scale Object 20, 20, 20, 20
Rotate Object 20, Object Angle X(enemy), Object Angle Y(enemy) - 80, Object Angle Z(enemy)
Lock Object On 20
Position Mouse Screen Width() / 2, Screen Height()/ 2
reloadtime = reloadtime + gunreload
AI Path Add Point 1, Rnd(750), Rnd(750)
reloadtime2 = reloadtime2 + 20
if reloadtime2 >= 300 then enemshoot()
If hp <= 0 Then Text 0, 100, "YOU LOSE!"
Text 0, 0, "Health: " + Str$(hp)
if enemyhp <= 0 then Delete Object enemy : AI Kill Entity enemy : Text 0, 100, "YOU WIN!"
controlsinput()
Text 10, 10, STR$(Camera Position X()) + " " + STR$(Camera Position Y())
Text 20, 20, STR$(Screen FPS())
Text 30, 30, STR$(reloadtime)
if mouseclick() = 1 and reloadtime >= 100 and shotsfired < ammomax Then
shoot()
imgrld = imgrld + 20
if hp < 50 and hpplayed = 0 then Set Sound Volume gunfire, 75 : Play Sound 2 : hpplayed = 1 : imgrld = 0
if hp < 50 and imgrld >= 100 then Show Sprite 2
if hp < 50 and imgrld >= 300 then hide sprite 2 : imgrld = 0
if hp > 50 then Hide Sprite 2
if hpplayed = 1 and imgrld >= 250 then Set Sound Volume gunfire, 100
Text 975, 375, STR$(ammomax - shotsfired) + "/" + STR$(ammomax)
IF Ai Entity Exist(enemy) =1
IF INTERSECT OBJECT (999, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0
Text Screen Width() / 2 - 40, Screen Width() / 2 - 45, "Enemy HP: " + STR$(enemyhp)
Endif
Endif
AI Update
Phy Update
Sync
Loop
EndFunction
Function shoot()
rand= Rnd(100)
IF OBJECT EXIST(999)=1
IF INTERSECT OBJECT (999, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0 and rand <= 75
enemyhp = enemyhp - Rnd(25)
ENDIF
ENDIF
shotsfired = shotsfired + 1
Play Sound gunfire
reloadtime = 0
AI Create Sound object position x(1),object position z(1),0,1
bulletexists = bulletexists + 1
EndFunction
Function enemshoot()
rand= Rnd(100)
if ai entity exist(enemy) = 1
if INTERSECT OBJECT (1, LIMB POSITION X(enemy,1), LIMB POSITION Y(enemy,1), LIMB POSITION Z(enemy,1), OBJECT POSITION X(enemy),OBJECT POSITION Y(enemy), OBJECT POSITION Z(enemy))>0 and rand <= 50
hp = hp - Rnd(17)
if hp >= 0 then Stretch Sprite 4, hp, 50
If hp <= 75 then Set Sprite Diffuse 4, 225, 198, 0
if hp <= 50 then set sprite diffuse 4, 225, 102, 0
if hp <= 25 then set sprite diffuse 4, 255, 0, 0
Play Sound gunfire
ENDIF
endif
reloadtime2 = 0
EndFunction
Function controlsinput()
If KEYSTATE(29) and KeyState(59) then consolecmd()
if KEYSTATE(1) then Show Mouse : menu()
if upkey() or KeyState(17) then move camera 0, 2 : Position Object 1, Camera Position X(), Camera Position Y(), Camera Position Z()
if downkey() or KeyState(31) then move camera 0, -1 : Position Object 1, Camera Position X(), Camera Position Y(), Camera Position Z()
if leftkey() or KeyState(30) then yrotate camera 0, wrapvalue(camera angle y(0)-.09)
if rightkey() or KeyState(32) then yrotate camera 0, wrapvalue(camera angle y(0)+.09)
if spacekey() then position camera 0, Camera Position X() , Camera Position Y() + 10, Camera Position Z()
cx#=camera angle x(0) : cy#=camera angle y(0)
rotate camera camera angle x(0)+(mousemovey()/2.0),camera angle y(0)+(mousemovex()/2.0),0 : Rotate Object 1, Camera Angle X(), Camera Angle Y(), Camera Angle Z()
if wrapvalue(camera angle x(0))>40 and wrapvalue(camera angle x(0))<180 then xrotate camera 0,40
if wrapvalue(camera angle x(0))>180 and wrapvalue(camera angle x(0))<280 then xrotate camera 0,280
EndFunction
function load()
Sync On : CLS 0 : Sync Rate 60 : Autocam Off
backdrop on
Print "Loading Game Assests, please wait..."
Load Image "mediamodelsweaponsak47.png", 1
gun = 2 : Load Object "mediamodelsweaponsak47.3ds", gun : Texture Object gun, 1 : Scale Object gun, 10, 10, 10 : Position Object gun, x# + 10, y# - 17, z# + 15 : Rotate Object gun, 0, Object Angle Y(gun) - 95, 0 : Lock Object On gun
Global gunfire = 1 : Load Sound "mediasoundsgunfire2.ogg", gunfire
Load Sound "mediasoundshpcrit.ogg", 2
Load Image "mediaimageshpcrit.png", 5
instance object 20, gun
global shotsfired as integer
global ammomax as Integer
global reloadtime as Integer
global reloadtime2 as integer
global enemyhp = 100
global imgrld = 100
global start as integer = 1000
global enemyhp as integer : enemyhp = 250
global enemy as integer : enemy = 999
global hp as integer : hp = 100
global gunreload as integer : gunreload = 20
global hpplayed as integer : hpplayed = 0
srverjoin=0 : shotsfired = 0 : ammomax = 60 : reloadtime = 100 : reloadtime2 = 100
Set Camera range 0, 1000
Load Image "mediaimageschair.png", 4
SPRITE 1, screen width()/2 - 40, screen height()/2 - 45, 4
Size Sprite 1, 75, 75
Sprite 2, 0, 0, 5
Size Sprite 2, Screen width(), screen height()
Hide Sprite 2
Set Sprite Alpha 2, 75
Load Image "mediaimageshud.png", 6
Sprite 3, 0, 0, 6
Size Sprite 3, Screen Width(), Screen Height()
Set Sprite 3, 0, 1
Draw Sprites Last
Load Image "mediaimageshp.png", 7
Sprite 4, Screen Width() / 2 - 250, 10, 7
Stretch Sprite 4, 100, 50
set Sprite Diffuse 4, 0, 255, 0
plyr = 1: Make Object Cube plyr, 10
main()
Endfunction
EDIT: Took off the // before autocam