I can't seem to be able to select multiple units.
`BattleZone Game
`Real Time Strategy Game
`Starting Date June 3,2008
`SETUP GAME
SYNC ON
SYNC RATE 80
`LOAD DARK A.I.
AI START
`MAKE CAMERAS
BLOOMCAM=CMR MAKE CAMERA()
`LOAD SHADERS
LOAD CAMERA EFFECT "SHADERS\OBJECT\BLOOM.fx",1,0
`MAKE CAMERA OBJECT
CAMERA=B3D MAKE OBJECT SPHERE(10)
POINT CAMERA OBJECT POSITION X(CAMERA),OBJECT POSITION Y(CAMERA),OBJECT POSITION Z(CAMERA)
HIDE OBJECT CAMERA
`MAKE MOUSE POINTER
MOUSE=B3D MAKE OBJECT SPHERE(10)
HIDE OBJECT MOUSE
`LOAD TERRAIN
MAP1=B3D LOAD OBJECT("LEVELS\TUTORIAL\MAP1\MAP1.x")
POSITION OBJECT MAP1,0,0,0
SET SHADOW SHADING ON MAP1
`SETUP BLOOM SHADER EFFECT
`UNIT ACTIONS & PROPERTIES
TYPE BASICUNITACTIONS
ISSELECTED AS BOOLEAN
ENDTYPE
TYPE BASICUNITPROPERTIES
NAME AS STRING
MAXLIFE AS INTEGER
ENDTYPE
DIM CHARACTERTYPE(2) AS BASICUNITPROPERTIES
`UNIT TYPES
`UNITS
CHARACTERTYPE(GROUND).name = "SHADOW"
CHARACTERTYPE(GROUND).maxLife = 60
CHARACTERTYPE(FLIGHT).name = "STRIKER"
CHARACTERTYPE(FLIGHT).maxLife = 40
TYPE CHARACTER
OBJECT AS INTEGER
ACTION AS BASICUNITACTIONS
GROUP AS INTEGER
UNIT AS INTEGER
LIFE AS INTEGER
ENDTYPE
DIM CHARACTERS(0) AS CHARACTER
`MAKE ONE UNIT
UNITS=100
LOAD OBJECT "MODELS\BODY PARTS\GROUND\SHADOWBLUE.x",UNITS
POSITION OBJECT UNITS,250,5,348
SCALE OBJECT UNITS,3500,3500,3500
AI ADD FRIENDLY UNITS,1
AI SET ENTITY SPEED UNITS,95
ARRAY INSERT AT BOTTOM CHARACTERS(0)
INDEX=ARRAY COUNT(CHARACTERS(0))
CHARACTERS(INDEX).OBJECT=UNITS
CHARACTERS(INDEX).ACTION.ISSELECTED=0
CHARACTERS(INDEX).UNIT=GROUND
CHARACTERS(INDEX).LIFE=CHARACTERTYPE(GROUND).MAXLIFE
`GRID
squareSize#=40.0
mapX=68
mapZ=68
DIM map(mapX,mapZ)
terrainX#=mapX*squareSize#
terrainZ#=mapZ*squareSize#
MAKE MATRIX 1,terrainX#,terrainZ#,mapX,mapZ
`SETUP REAL TIME SKY SYSTEM
BACKDROP ON
CLEAR CAMERA VIEW 0,RGB(0,0,0)
SET CAMERA RANGE 1,110000
RTS SETUP SKYBOX "REAL-TIME SKY SYSTEM\RTS_DesertMountain",0
RTS FOG ON
RTS SET CLOCK 5,0,0.9
RTS SET WIND SPEED 0.00004,0.00004
RTS SET CLOUD DENSITY 25
RTS SET MIST DENSITY 25
RTS SHADOW SHADING ON
`BLOOM SETUP
SET CAMERA EFFECT BLOOMCAM,1,1
BLOOM=B3D MAKE OBJECT PLAIN(100,100)
QUAD=E3D LOAD EFFECT("SHADERS\OBJECT\QUAD.fx",0)
SET OBJECT EFFECT BLOOM,QUAD
NULL=MAKE VECTOR4(1)
SET EFFECT CONSTANT VECTOR QUAD,"InViewSize",1
`START MAIN LOOP
DO
`UNIT MOVING AND SELECTING
_mouse_click = MOUSECLICK()
IF _mouse_click = 1 AND selectionFlag = 0
selectionFlag = 1
bx = MOUSEX()
by = MOUSEY()
ENDIF
IF _mouse_click = 1 AND selectionFlag = 1
bx2 = MOUSEX()
by2 = MOUSEY()
ENDIF
IF _mouse_click <> 1 then selectionFlag = 0
IF selectionFlag = 1
rem sort the coordinates
IF bx < bx2
bx0 = bx
bx1 = bx2
ELSE
bx0 = bx2
bx1 = bx
ENDIF
IF by < by2
by0 = by
by1 = by2
ELSE
by0 = by2
by1 = by
ENDIF
rem draw a box
LINE bx0, by0, bx1, by0
LINE bx0, by1, bx1, by1
LINE bx0, by0, bx0, by1
LINE bx1, by0, bx1, by1
rem loop through all characters
FOR CHAR = 1 to ARRAY COUNT(CHARACTERS(0))
rem get object number of this character for future object related actions
OBJ = CHARACTERS(CHAR).OBJECT
rem get the character's 2D screen coordinates
CX=OBJECT SCREEN X(OBJ)
CY=OBJECT SCREEN Y(OBJ)
rem if character is within the selection box..
IF CX > bx0 AND CX < bx1 AND CY > by0 AND CY < by1
CHARACTERS(CHAR).ACTION.ISSELECTED = 1
ELSE
CHARACTERS(CHAR).ACTION.ISSELECTED = 0
ENDIF
NEXT CHAR
ENDIF
`SETUP CAMERA
`GET CAMERA POSITION & ANGLE
CAMX=OBJECT POSITION X(CAMERA)
CAMY=OBJECT POSITION Y(CAMERA)+350
CAMZ=OBJECT POSITION Z(CAMERA)
TEXT 0,0,"X: "+STR$(CAMX)
TEXT 0,10,"Z: "+STR$(CAMZ)
`MOVE CAMERA CONTROLS
IF UPKEY()=1 THEN MOVE OBJECT CAMERA,3
IF DOWNKEY()=1 THEN MOVE OBJECT CAMERA,-3
IF LEFTKEY()=1 THEN MOVE OBJECT LEFT CAMERA,3
IF RIGHTKEY()=1 THEN MOVE OBJECT RIGHT CAMERA,3
IF CONTROLKEY()=1 THEN MOVE OBJECT UP CAMERA,3
IF SHIFTKEY()=1 THEN MOVE OBJECT DOWN CAMERA,3
`ROTATE & POSITION CAMERA
POSITION CAMERA CAMX,CAMY,CAMZ
`MOUSE POINTER
`position mouse marker
null = pick object(mousex(), mousey(), object, object)
targetX# = camera position x() + get pick vector x()
targetY# = camera position y() + get pick vector y()
targetZ# = camera position z() + get pick vector z()
pick screen mousex(),mouseY(),1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = -camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
position object MOUSE,vx#,1,vz#
`Mouse Camera Movement
IF SPACEKEY()=1
Camy#=Camy#+MOUSEMOVEX()*.5
Camx#=Camx#+MOUSEMOVEY()*.5
IF Camx#>90 AND Camx#<135 THEN Camx#=90
IF Camx#>270 AND Camx#<225 THEN Camx#=90
YROTATE CAMERA Camy#
XROTATE CAMERA Camx#
ENDIF
`MOVING UNITS
IF characters(INDEX).action.ISSELECTED = 1
IF _mouse_click=2
AI ENTITY GO TO POSITION OBJ,OBJECT POSITION X(3),OBJECT POSITION Z(3)
ENDIF
ENDIF
`RENDER BLOOM
`END LOOP
RTS UPDATE SKYBOX
AI UPDATE
SYNC
LOOP