DECLARE SUB drawscores ()
DECLARE SUB drawchats ()
DECLARE SUB messages ()
DECLARE SUB center2 (y%, tekst$, kleur%)
DECLARE SUB drawwindow (breedte!)
DECLARE SUB addplayer (team%, cell%, action%)
DECLARE SUB DoPlayers ()
'$DYNAMIC
'$INCLUDE: 'declars.bas'
RANDOMIZE TIMER
'******************************************
'ELITE FORCES ENGINE - Programmed by Stefan Hendriks
'******************************************
initializegame

'Currently we are always Counter Terrorist, so we always have the same
'message at start
message$ = "Rescue the hostages!"
messagecounter = 15

DO
DQBclearLayer 1
IF DQBkey(1) THEN EXIT DO

IF MX < 0 THEN MX = 0
IF MX > 50 THEN MX = 50
IF MY < 0 THEN MY = 0
IF MY > 55 THEN MY = 55
IF MY > MaxMY THEN MY = MaxMY

PlayerOutside = FALSE   'Player is not outside
buy = 0
radio = 0
'All subs
drawscreen              'Draw 'terrain'
drawitems               'Draw ITEMS, but also blocking tiles
IF PlayerHealth > 0 THEN drawplayer              'Draw player and handle its actions
DoPlayers               'Handle PLAYERS and AI etc
drawbullets             'Draw all bullets
IF PlayerHealth > 0 THEN drawhud                 'Draw Power, bullets, armor
changetime              'Timer
doevents                'Do events
drawchats               'Draw chatlines
messages                'Draw messages
IF DQBkey(59) THEN drawscores 'draw scores
IF PlayerHealth > 0 THEN
IF DQBkey(15) AND radio = 0 THEN      'TAB Key pressed (BUY MENU)
handlebuy               'Buy objects
buy = 1
END IF
IF DQBkey(44) AND buy = 0 THEN      'Z, Radio Menu
radiomenu
radio = 1
END IF
END IF
'Show scores


DQBxPut 4, 297, 182, 313, 198, 1, DQBmouseX - 7, DQBmouseY - 7

IF DQBkey(88) THEN
t = DQBsaveImage(1, 0, 0, 319, 199, "screeny.bmp", pal, BMP)
END IF

dqbcopylayer 1, 0
LOOP
DQBremoveSB
DQBclose
dummy& = SETMEM(17000)
CLS
COLOR 15, 1: PRINT SPACE$(80)
LOCATE 1, 30: PRINT "Elite Forces V 1.00"
COLOR 7, 0: PRINT "Credits:"
PRINT
PRINT "Programmed by Stefan Hendriks"
PRINT "DirectQB by Angelo Mottola"
PRINT "Graphics from C&C: RA"
PRINT "Sounds from Half-Life / Half-Life: CounterStrike 6.1"
PRINT
PRINT "Elite Forces is a product of"
PRINT
PRINT "Future Software"
PRINT "www.qb45.com"
PRINT
PRINT "Mail Programmer:"
PRINT "stefanhendriks@zonnet.nl"
END

REM $STATIC
SUB addbullet (startx, starty, endx, endy, strength, owner, Speed)
FOR i = 0 TO 300
IF bulletd(i) = 0 THEN EXIT FOR
NEXT i
IF i > 300 THEN EXIT SUB
new = i

Angle! = DQBangle(startx, starty, endx, endy)
Angle! = Angle! - 65
Angle! = Angle! * (360 / 255)
multi! = 3.141593 / 180
ang! = Angle! * multi!

bulleta!(new) = ang!

bulleto(new) = owner
bulletd(new) = 1
afwijkingx = -2 + INT(RND * 5)
afwijkingy = -2 + INT(RND * 5)
bulletx!(new) = startx + 3 + (MX * 24) - PMX + afwijkingx
bullety!(new) = starty + 3 + (MY * 24) - PMY + afwijkingy
bulletdy!(new) = incy!
bulletdx!(new) = incx!
bullets(new) = strength + 1
bullets2(new) = Speed
END SUB

SUB addchatline (txt$)
'Latest will be chatline
FOR j = 0 TO 5
IF chatline$(j) = "" THEN chatline$(j) = txt$: EXIT SUB
NEXT j
'When all are full
'We move all to a new position -1
FOR j = 1 TO 5
chatline$(j - 1) = chatline$(j)
NEXT j
chatline$(5) = txt$     'and the latest is our txt$

END SUB

SUB addplayer (team, cell, action)
IF team = 0 THEN
FOR i = 1 TO 7
IF unitd(i) = 0 THEN new = i: EXIT FOR
NEXT i
IF i > 7 THEN EXIT SUB
END IF

IF team = 1 THEN
FOR i = 8 TO 15
IF unitd(i) = 0 THEN new = i: EXIT FOR
NEXT i
IF i > 15 THEN EXIT SUB
END IF

IF team = 2 THEN
FOR i = 16 TO 30
IF unitd(i) = 0 THEN new = i: EXIT FOR
NEXT i
IF i > 30 THEN EXIT SUB
END IF

IF new = 7 THEN unitl(new) = 1 ELSE unitl(new) = 0
unitam(new) = 0         ' no bullets/ammo
unitm(new) = 700        ' 700 Bucks at start
unitm(new) = 10000
unitd(new) = 1  'NOT DEAD!
unitc(new) = cell
unitac(new) = action
unitx(new) = 0
unity(new) = 0
unita(new) = 0
unith(new) = 100
unitf(new) = INT(RND * 8)
unitf2(new) = 0
unitmc(new) = unitc(new)
uniti1(new) = 0
uniti2(new) = 0
uniti3(new) = 0
uniti4(new) = 0
uniti5(new) = 0
uniti6(new) = 0
unitw(new) = 0  'No weapon at start
IF team < 2 THEN
OPEN "names.dat" FOR INPUT AS #3
DO WHILE NOT EOF(3)
INPUT #3, n$
totaal = totaal + 1
LOOP
CLOSE #3
a = INT(RND * 30)
name$ = "Unnamed"
OPEN "names.dat" FOR INPUT AS #3
wilt = INT(RND * totaal)
DO WHILE NOT EOF(3)
t = t + 1
INPUT #3, n$
IF wilt = t THEN name$ = n$
LOOP
CLOSE #3
END IF
IF team = 2 THEN name$ = "HOSTAGE"
unitname$(new) = name$
'PRINT "GAME: Player " + unitname$(new); " entered the game."
DQBwait 1
unitping(new) = 100 + INT(RND * 200)
END SUB

REM $DYNAMIC
SUB center (y, tekst$, kleur)
'tekst$ = UCASE$(tekst$)
l = LEN(tekst$)
l = l * 6 'Real size in pixels
xplaats = 100 - (l / 2)
y = y * 8
DQBprint 1, tekst$, xplaats, y, kleur
END SUB

REM $STATIC
SUB center2 (y, tekst$, kleur)
'tekst$ = UCASE$(tekst$)
l = LEN(tekst$)
l = l * 6 'Real size in pixels
xplaats = 160 - (l / 2)
y = y * 8
DQBprint 1, tekst$, xplaats, y, kleur
END SUB

REM $DYNAMIC
SUB changetime
'will give time units in seconds,

F$ = TIME$              'Put current time in f$
k$ = MID$(F$, 8, 8)     'Read the last figure (that is a second)

IF k$ = n$ THEN
'When this figure is the same figure as one
tijd = tijd + 1:  frame = frme: frme = 1: seconds = seconds + 1
roundtime = roundtime - 1
IF seconds > 59 THEN seconds = 0: minutes = minutes + 1
FOR i = 0 TO 15
unitping(i) = 100 + INT(RND * 200)
NEXT i
END IF

                                'second before, decrease time
k = VAL(k$)                     'last figure is now an integer
k = k + 1                       'increase it (so we can check the comming sec)
IF k > 9 THEN k = 0             'And a check... (cause you only have till 9)
e$ = STR$(k)                    'Now make it a string again
e$ = LTRIM$(e$)                 'Remove spaces at the left
e$ = RTRIM$(e$)                 'And at the right (just in case)
n$ = e$                         'And give n$ our e$ value to check like above
F$ = LEFT$(F$, LEN(F$) - 1)     'Delete the second at the current time
F$ = F$ + e$                    'And place the future second instead of it

END SUB

REM $STATIC
SUB doevents
'Do events, like Ok lets go voice or whatever
IF tijd = freezetime AND DQBinUse(1) = FALSE THEN
DQBplaySound 23 + INT(RND * 3), 1, 22050, 0
END IF


END SUB

SUB drawchats
FOR i = 0 TO 5
lengte = LEN(chatline$(i))
IF lengte > meestlang THEN meestlang = lengte
DQBprint 1, chatline$(i), 0, i * 8, 165
NEXT i
END SUB

SUB drawscores
'Oh shit man, we have to sort this out.
'We have 1 large score bar, after each name it says (T) for Terror
'or (CT) for counterterror, thereafter a ping (visual) and the scores
DIM tempname$(15), tempkills(15), tempdeaths(15)
FOR i = 0 TO 15
IF i > 0 THEN
tempname$(i) = unitname$(i)
tempkills(i) = unitki(i)
tempdeaths(i) = unitds(i)
ELSE
tempname$(i) = Playername$
tempkills(i) = PlayerKills
tempdeaths(i) = PlayerDeaths
END IF

NEXT i

center2 7, "Name (team)       KILLS / DEATHS    PING", 165

FOR i = 0 TO 15
IF tempname$(i) <> "" THEN
c = 168
IF tempname$(i) = Playername$ THEN c = 231
IF unith(i) <= 0 THEN c = 0
IF i <= 7 THEN tempname$(i) = tempname$(i) + "(CT)"
IF i > 7 THEN tempname$(i) = tempname$(i) + "(T)"
'center2 8 + (i - m), tempname$(i) + "   " + STR$(tempkills(i)) + "/" + STR$(tempdeaths(i)) + " " + STR$(unitping(i)), c
DQBprint 1, tempname$(i), 40, 64 + ((i - m) * 8), c
DQBprint 1, STR$(tempkills(i)), 134, 64 + ((i - m) * 8), c
DQBprint 1, "/", 160, 64 + ((i - m) * 8), c
DQBprint 1, STR$(tempdeaths(i)), 170, 64 + ((i - m) * 8), c
DQBprint 1, STR$(unitping(i)), 224, 64 + ((i - m) * 8), c
ELSE
m = m + 1
END IF
NEXT i

END SUB

SUB drawscreen
blocked = FALSE
FOR x = MX - 1 TO MX + 14
FOR y = MY - 1 TO MY + 9
cell = y * 64 + x
IF cell < 0 THEN cell = 0
IF cell > 4095 THEN cell = 4095
py = 0
t = maptile(cell)

r = INT(t / 12)    ' Rows
l = (t - (r * 12)) ' Lengths

px = l * 24 + l    ' Xpos
py = r * 24 + r    ' Ypos


DQBxPut 2, px, py, px + 23, py + 23, 1, (x - MX) * 24 + PMX, (y - MY) * 24 + PMY
IF t > 2 AND blocked = FALSE AND (t < 19 OR t > 32) THEN
blocked = DQBcollide(playerx, playery, VARSEG(plmask(0)), VARPTR(plmask(0)), (x - MX) * 24 + PMX, (y - MY) * 24 + PMY, VARSEG(plsprite(0)), VARPTR(plsprite(0)))
END IF
IF t >= 11 AND t <= 16 THEN
DQBsetVoiceVol 10, 40
IF DQBinUse(10) = FALSE THEN DQBplaySound 6, 10, 22050, 0
END IF

'DQBprint 1, STR$(blocked), (x - MX) * 24 + PMX, (y - MY) * 24 + PMY, 15
NEXT y
NEXT x

END SUB

SUB handlebuy
IF PlayerMoney < 100 THEN
DQBprint 1, "- To Gain Money -", 0, 150, 229 + fade
DQBprint 1, "Kill the opponent or Rescue All hostages", 0, 160, 229 + fade
EXIT SUB
END IF

drawwindow 200
dqbcopylayer 1, 7
DO
dqbcopylayer 7, 1
DQBprint 1, "[Buy Menu]", 70, 20, 164
FOR j = 0 TO 5
nr$ = LTRIM$(RTRIM$(STR$(j)))
pr$ = LTRIM$(RTRIM$(STR$(itemp(j))))
DQBprint 1, nr$ + "]", 80, 30 + (j * 9), 161
DQBprint 1, item$(j), 100, 30 + (j * 9), 164

DQBprint 1, "$" + pr$, 200, 30 + (j * 9), 164

NEXT j

DQBprint 1, "Money $" + LTRIM$(STR$(PlayerMoney)), 70, 140, 165

IF gekochtteller > 0 THEN
DQBprint 1, "- $" + LTRIM$(RTRIM$(STR$(prijsaf))), 150, 140, 175 - gekochtteller
subt = subt + 1
IF subt > 15 THEN gekochtteller = gekochtteller - 1: subt = 0
END IF

DQBprint 1, "Ammo " + STR$(PlayerAmmo) + " of" + STR$(PlayerMaxAmmo), 70, 150, 165
DQBprint 1, "Cardrige " + STR$(PlayerUsedCardrige) + " of" + STR$(PlayerMaxCardrige), 165, 150, 165
s$ = "None"
IF PlayerWeapon = -1 THEN s$ = "Mini Gun"
IF PlayerWeapon = 0 THEN s$ = "MP5 Navy Machine Gun"
IF PlayerWeapon = 1 THEN s$ = "Sniper Gun"
IF PlayerWeapon = 2 THEN s$ = "ShotGun"
DQBprint 1, "Weapon " + s$, 70, 160, 165
DQBprint 1, "Armor " + STR$(PlayerArmor) + " of 100", 70, 170, 165

dqbcopylayer 1, 0

key$ = DQBinkey$

'Minigun
IF key$ = "0" AND PlayerMoney - 500 >= 0 AND PlayerWeapon <> -1 THEN
DQBplaySound 12, 8, 22050, 0
prijsaf = 500: gekochtteller = 15
PlayerMaxCardrige = 15
PlayerUsedCardrige = 15
PlayerMaxAmmo = 150
PlayerWeaponDelay = 20
PlayerWeaponCount = 0
PlayerWeapon = -1
PlayerMoney = PlayerMoney - 500
DQBwait 10
END IF

'Rifle
IF key$ = "1" AND PlayerMoney - 1500 >= 0 AND PlayerWeapon <> 0 THEN
DQBplaySound 12, 8, 22050, 0
prijsaf = 1500: gekochtteller = 15
PlayerMaxCardrige = 50
PlayerUsedCardrige = 50
PlayerMaxAmmo = 500
PlayerWeaponDelay = 2
PlayerWeaponCount = 0
PlayerWeapon = 0
PlayerMoney = PlayerMoney - 1500
DQBwait 10
END IF

'Sniper Gun
IF key$ = "2" AND PlayerMoney - 3200 >= 0 AND PlayerWeapon <> 1 THEN
DQBplaySound 12, 8, 22050, 0
prijsaf = 3200: gekochtteller = 15
PlayerMaxCardrige = 25
PlayerUsedCardrige = 25
PlayerMaxAmmo = 100
PlayerWeaponDelay = 50
PlayerWeaponCount = 0
PlayerWeapon = 1
PlayerMoney = PlayerMoney - 3200
DQBwait 10
END IF

'Shotgun
IF key$ = "3" AND PlayerMoney - 2000 >= 0 AND PlayerWeapon <> 2 THEN
DQBplaySound 12, 8, 22050, 0
prijsaf = 2000: gekochtteller = 15
PlayerMaxCardrige = 30
PlayerUsedCardrige = 30
PlayerMaxAmmo = 300
PlayerWeaponDelay = 40
PlayerWeaponCount = 0
PlayerWeapon = 2
PlayerMoney = PlayerMoney - 2000
DQBwait 10
END IF


IF key$ = "4" AND PlayerArmor < 100 AND PlayerMoney - 700 >= 0 THEN
'Buy Armor
DQBplaySound 13, 15, 22050, 0
prijsaf = 700: gekochtteller = 15
PlayerMoney = PlayerMoney - 700
PlayerArmor = PlayerArmor + 100
IF PlayerArmor > 100 THEN PlayerArmor = 100
DQBwait 10
END IF

IF key$ = "5" AND PlayerAmmo < PlayerMaxAmmo AND PlayerMoney - 100 >= 0 THEN
'Buy Ammo
PlayerMoney = PlayerMoney - 100
prijsaf = 100: gekochtteller = 15
DQBplaySound 1, 15, 22050, 0
er = 50
IF PlayerUsedCardrige < PlayerMaxCardrige THEN
verschil = PlayerMaxCardrige - PlayerUsedCardrige
er = er - verschil
PlayerUsedCardrige = PlayerMaxCardrige
END IF
PlayerAmmo = PlayerAmmo + er
DQBwait 10
END IF

IF PlayerAmmo > PlayerMaxAmmo THEN PlayerAmmo = PlayerMaxAmmo
IF key$ = CHR$(27) THEN EXIT DO
LOOP

END SUB

SUB initializegame
t = DQBinit(7, 45, 0)   '45 sounds!
CLS
COLOR 15, 1: PRINT SPACE$(80)
LOCATE 1, 30: PRINT "Elite Forces V 1.00"
COLOR 7, 0
PRINT "INIT: DirectQB"
IF t <> 0 THEN
PRINT "Failed :";
PRINT DQBerror$
DQBclose
END
END IF

INPUT "Enter your Name:", Playername$
PRINT "INIT: Keyboard"
DQBinstallKeyboard
PRINT "INIT: Memory for Soundcard"
dummy& = SETMEM(-17000) 'Soundcard mem

PRINT "INIT: Soundcard"
IF DQBinstallSB(64, 16, 22050, AUTO, AUTO, AUTO) THEN
PRINT "Failed :";
PRINT DQBerror$
DQBclose
END
END IF

PRINT "LOAD: Font"
t = DQBloadFont("DATA\SMALL.FNT")
IF t <> 0 THEN PRINT "ERROR: Could not Load DATA\SMALL.FNT": DQBclose: END



PRINT "LOAD: Graphics"
SLEEP 1

t = DQBloadImage(3, 0, 0, "DATA\GFX\SET2.PCX", pal, 320, 200)
IF t <> 0 THEN PRINT "ERROR: Could not load DATA\GFX\SET2.PCX": DQBclose: END
t = DQBloadImage(4, 0, 0, "DATA\GFX\CT.PCX", pal, 320, 200)
IF t <> 0 THEN PRINT "ERROR: Could not load DATA\GFX\CT.PCX": DQBclose: END
t = DQBloadImage(5, 0, 0, "DATA\GFX\T.PCX", pal, 320, 200)
IF t <> 0 THEN PRINT "ERROR: Could not load DATA\GFX\T.PCX": DQBclose: END
t = DQBloadImage(6, 0, 0, "DATA\GFX\H.PCX", pal, 320, 200)
IF t <> 0 THEN PRINT "ERROR: Could not load DATA\GFX\H.PCX": DQBclose: END
t = DQBloadImage(2, 0, 0, "DATA\GFX\SET1.PCX", pal, 320, 200)
IF t <> 0 THEN PRINT "ERROR: Could not load DATA\GFX\SET1.PCX": DQBclose: END

DQBget 2, 0, 0, 23, 23, VARSEG(plsprite(0)), VARPTR(plsprite(0))
DQBget 4, 0, 0, 7, 11, VARSEG(plmask(0)), VARPTR(plmask(0))

PRINT "LOAD: Sound Effects "
SLEEP 1
'Load sounds
'Slot 1 = Buy Ammo
t = DQBloadSound(1, "DATA\SOUNDS\WEAPONS\RELOAD\SRELOAD.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading SRELOAD.WAV, please reinstall...": DQBclose: END
'Slot 2 = MiniGun Shot
t = DQBloadSound(2, "DATA\SOUNDS\WEAPONS\SHOTS\MINIG.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading MINIG.WAV, please reinstall...": DQBclose: END
'Slot 3 = Rifle Shot
t = DQBloadSound(3, "DATA\SOUNDS\WEAPONS\SHOTS\RIFLE.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading RIFLE.WAV, please reinstall...": DQBclose: END
'Slot 4 = Rifle Shot 2
t = DQBloadSound(4, "DATA\SOUNDS\WEAPONS\SHOTS\RIFLE2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading RIFLE2.WAV, please reinstall...": DQBclose: END
'Slot 5 = Shot Gun
t = DQBloadSound(5, "DATA\SOUNDS\WEAPONS\SHOTS\SHOTG.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading SHOTG.WAV, please reinstall...": DQBclose: END
'Slot 6 = Drone
t = DQBloadSound(6, "DATA\SOUNDS\AMBIENCE\DRONE2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading DRONE2.WAV, please reinstall...": DQBclose: END
'Slot 7 = STEP 1
t = DQBloadSound(7, "DATA\SOUNDS\PLAYER\PL_STEP1.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PL_STEP1.WAV, please reinstall...": DQBclose: END
'Slot 8 = STEP 2
t = DQBloadSound(8, "DATA\SOUNDS\PLAYER\PL_STEP2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PL_STEP2.WAV, please reinstall...": DQBclose: END
'Slot 9 = STEP 3
t = DQBloadSound(9, "DATA\SOUNDS\PLAYER\PL_STEP3.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PL_STEP3.WAV, please reinstall...": DQBclose: END
'Slot 10 = Sniper Blast
t = DQBloadSound(10, "DATA\SOUNDS\WEAPONS\SHOTS\SNIPE2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading SNIPE2.WAV, please reinstall...": DQBclose: END
'Slot 11 = Click... ehhh aut of ammo
t = DQBloadSound(11, "DATA\SOUNDS\WEAPONS\RELOAD\RELOAD1.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading RELOAD1.WAV, please reinstall...": DQBclose: END
'Slot 12 = Reload sound
t = DQBloadSound(12, "DATA\SOUNDS\WEAPONS\RELOAD\GRELOAD.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading GRELOAD.WAV, please reinstall...": DQBclose: END
'Slot 13 = Bought Vest/Armor
t = DQBloadSound(13, "DATA\SOUNDS\ITEMS\VEST.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading VEST.WAV, please reinstall...": DQBclose: END
'Slot 14 = Step 4
t = DQBloadSound(14, "DATA\SOUNDS\PLAYER\PLSTEP21.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PLSTEP21.WAV, please reinstall...": DQBclose: END
'Slot 15 = Step 5
t = DQBloadSound(15, "DATA\SOUNDS\PLAYER\PLSTEP22.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PLSTEP22.WAV, please reinstall...": DQBclose: END
'Slot 16 = Step 6
t = DQBloadSound(16, "DATA\SOUNDS\PLAYER\PLSTEP23.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PLSTEP23.WAV, please reinstall...": DQBclose: END
'Slot 17 = MIS 1
t = DQBloadSound(17, "DATA\SOUNDS\WEAPONS\SHOTS\RIC1.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading RIC1.WAV, please reinstall...": DQBclose: END
'Slot 18 = MIS 2
t = DQBloadSound(18, "DATA\SOUNDS\WEAPONS\SHOTS\RIC2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading RIC2.WAV, please reinstall...": DQBclose: END
'Slot 19 = MIS 3
t = DQBloadSound(19, "DATA\SOUNDS\WEAPONS\SHOTS\RIC3.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading RIC3.WAV, please reinstall...": DQBclose: END
'Slot 20 = Snow Step 1
t = DQBloadSound(20, "DATA\SOUNDS\PLAYER\SNOW1.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading SNOW1.WAV, please reinstall...": DQBclose: END
'Slot 21 = Snow Step 2
t = DQBloadSound(21, "DATA\SOUNDS\PLAYER\SNOW2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading SNOW2.WAV, please reinstall...": DQBclose: END
'Slot 22 = Snow Step 3
t = DQBloadSound(22, "DATA\SOUNDS\PLAYER\SNOW3.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading SNOW3.WAV, please reinstall...": DQBclose: END
'Slot 23 = RADIO : Ok lets go
t = DQBloadSound(23, "DATA\SOUNDS\RADIO\LETSGO.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading LETSGO.WAV, please reinstall...": DQBclose: END
'Slot 24 = RADIO : Lock'n Load
t = DQBloadSound(24, "DATA\SOUNDS\RADIO\LCKNLOAD.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading LCKNLOAD.WAV, please reinstall...": DQBclose: END
'Slot 25 = RADIO : Alright, lets move out
t = DQBloadSound(25, "DATA\SOUNDS\RADIO\MOVEOUT.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading MOVEOUT.WAV, please reinstall...": DQBclose: END
'Slot 26 = RADIO : Go Go GO
t = DQBloadSound(26, "DATA\SOUNDS\RADIO\GOGOGO.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading GOGOGO.WAV, please reinstall...": DQBclose: END
'Slot 27 = RADIO : Cover Me
t = DQBloadSound(27, "DATA\SOUNDS\RADIO\CVRME.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading CVRME.WAV, please reinstall...": DQBclose: END
'Slot 28 = RADIO : Follow Me
t = DQBloadSound(28, "DATA\SOUNDS\RADIO\FLWME.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading FLWME.WAV, please reinstall...": DQBclose: END
'Slot 29 = RADIO : I'm Hit!
t = DQBloadSound(29, "DATA\SOUNDS\RADIO\IMHIT.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading IMHIT.WAV, please reinstall...": DQBclose: END
'Slot 30 = RADIO : Taking Fire Need assistance!
t = DQBloadSound(30, "DATA\SOUNDS\RADIO\FRASS.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading FRASS.WAV, please reinstall...": DQBclose: END
'Slot 31 = RADIO : Ouch! - PAIN 1
t = DQBloadSound(31, "DATA\SOUNDS\PLAYER\PAIN1.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PAIN1.WAV, please reinstall...": DQBclose: END
'Slot 32 = RADIO : Ouch! - PAIN 2
t = DQBloadSound(32, "DATA\SOUNDS\PLAYER\PAIN2.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PAIN2.WAV, please reinstall...": DQBclose: END
'Slot 33 = RADIO : Ouch! - PAIN 3
t = DQBloadSound(33, "DATA\SOUNDS\PLAYER\PAIN3.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading PAIN3.WAV, please reinstall...": DQBclose: END
t = DQBloadSound(34, "DATA\SOUNDS\RADIO\MATEDOWN.WAV")
IF t <> 0 THEN PRINT "ERROR: Error loading MATEDOWN.WAV, please reinstall...": DQBclose: END
PRINT "GAME: Setting Variables"
resetall
PRINT "GAME: Loading Demo Map"
loadmap "test", 0
PRINT "GAME: Loading Item Data"
OPEN "item.dat" FOR INPUT AS #1
DO WHILE NOT EOF(1)
INPUT #1, item$(t), itemp(t)
t = t + 1
IF t > 9 THEN EXIT DO   'For now
LOOP
CLOSE #1
PRINT "GAME: Ready"
PRINT
PRINT "Press a key..."
WHILE DQBinkey$ = "": WEND
DQBfadeTo 0, 0, 0

DQBinitVGA
DQBsetPal pal
END SUB

SUB loadmap (file$, comment)
OPEN file$ + ".MAP" FOR INPUT AS #1
IF comment = 0 THEN PRINT "MAP : Terrain"
FOR i = 0 TO 4095
INPUT #1, maptile(i)
INPUT #1, mapitems(i)
IF maptile(i) > 2 AND maptile(i) < 19 THEN mapcol(i) = 1
IF mapitems(i) >= 0 THEN mapcol(i) = 1
NEXT i
INPUT #1, MaxMY
INPUT #1, playerx, playery, MX, MY
IF comment = 0 THEN PRINT "MAP : Players"
DO WHILE NOT EOF(1)
INPUT #1, index, cell
IF index <= 7 AND index > 0 THEN addplayer 0, cell, 0
IF index > 7 AND index <= 15 THEN addplayer 1, cell, 0
IF index > 15 THEN addplayer 2, cell, 0
IF index < 0 THEN EXIT DO
LOOP
IF comment = 0 THEN PRINT "MAP : Routes / Waypoints"
DO WHILE NOT EOF(1)
INPUT #1, i, j, rway(i, j)
IF rway(i, j) > 0 THEN
mapways(rway(i, j)) = i 'Save route nr on mapways
END IF

LOOP
CLOSE #1
END SUB

SUB messages
IF messagecounter > 0 THEN
center2 11, message$, 223 - messagecounter
messubt = messubt + 1
IF messubt > 5 THEN messagecounter = messagecounter - 1: messubt = 0
END IF
END SUB

SUB radiomenu

center 4, "- Radio Menu -", 234
center 6, "0. Go Go Go   ", 234
center 7, "1. Cover Me   ", 234
center 8, "2. Follow Me  ", 234
center 10, "3. Need Backup", 234

IF DQBkey(11) AND DQBinUse(15) = FALSE THEN
'Give command when we are done with giving our previous command
DQBplaySound 26, 15, 22050, 0
END IF

IF DQBkey(2) AND DQBinUse(15) = FALSE THEN
'Give command when we are done with giving our previous command
DQBplaySound 27, 15, 22050, 0
END IF

IF DQBkey(3) AND DQBinUse(15) = FALSE THEN
'Give command when we are done with giving our previous command
DQBplaySound 28, 15, 22050, 0
END IF

END SUB

SUB resetall
FOR i = 0 TO 4095
maptile(i) = INT(RND * 2)
mapitems(i) = -1
mapcol(i) = 0
mapplayers(i) = -1
mapways(i) = -1
NEXT i
FOR i = 0 TO 15
unitd(i) = 0
unitr(i) = -1
unitrw(i) = -1
NEXT i
FOR i = 0 TO 40
FOR j = 0 TO 40
rway(i, j) = -1
NEXT j
NEXT i
seconds = 0
minutes = 0
tijd = 0
PlayerReload = FALSE
PlayerMoney = 7000
PlayerScore = 0
PlayerAmmo = 0
PlayerHealth = 100
PlayerArmor = 0
PlayerSaved = 0
PlayerKills = 0
PlayerDeaths = 0
PlayerWeapon = -2
PlayerMaxAmmo = 0
playerx = 160
playery = 100
freezetime = 5
roundtime = 300 + freezetime
unitd(0) = 1    'WE LIVE! MUHAHAHAHAHAHAHAHAHA

END SUB

