home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fun Online 1997 April
/
FOL0497.iso
/
tvmlsa
/
apps
/
maze
/
mr.tvm
< prev
next >
Wrap
Text File
|
1997-06-26
|
161KB
|
6,421 lines
/**********************************************************************
*
* File : mazerun.tvm
*
* Abstract : TVML Maze runner
*
**********************************************************************
*
* This file is a product of TVML Ltd.
*
* This file is provided as is with no warranties of any kind and is
* provided without any obligation on TVML Ltd.
*
* TVML Ltd. will not, under any circumstances, be liable for any
* lost revenue or other damages arising from the use of this file.
*
************************************************************************/
local
/* Binary /text control flags */
const
int BadLuckMessage = 0, WellDoneMessage = 2, BonusMessage = 4, ScoreMessage = 6
int language = 1
var
// string MazeRemoteRoot = "http://194.80.180.23/web/tvml/apps/maze/"
// string MazeRemoteRoot = "http://www.tvml.co.uk/tvml/apps/maze/"
// string MazeRemoteRoot = "http://tvml.simplenet.com/tvml/apps/maze/"
string MazeRemoteRoot = "http://www.fol.de/tvml/apps/maze/"
string MazeLocalCDRoot = ""
filename MazeDir = `tvmlsa\apps\maze\`
// filename MazeDir = `apps\maze\`
filename TvmlDir
filename InstallDir
int start_text,end_text,del_text
const
string PlayerVersion = "0.89"
int FastScale = 2, SlowScale = 1
CLOSEST as float=0.1
NORTH as int=1
EAST as int=2
SOUTH as int=4
WEST as int=8
float PickUp = 0.25
int FastTimerTick = 75 //ms
int SlowTimerTick = 500 //ms
int bumprepeat = 1000 //ms
data Messages:2
"Bad luck! You didn't succeed this time. Better luck next time!",
"Schade! Pech gehabt - du hast es leider nicht geschafft.\n Versuch┤s doch nochmal!",
"Congratulations! You have completed the maze successfully!\n",
"Super! Herzlichen Glⁿckwunsch! Du hast es geschafft!\n",
"Your time bonus is %d\n",
"Dein Zeitbonus ist %d\n",
"Your final score is %d\n",
"Dein Endergebnis ist %d\n"
enddata
data ObjectsPerRoomData
// 1,2,3,4,5,6,7,8,9,10,11
2,3,4,4,1,4,4,2,3, 4, 2
enddata
data DoorsPerRoomData
// 1,2,3,4,5,6,7,8,9,10,11
2,3,4,4,1,4,4,2,3, 4, 2
enddata
data MinRoomSizeData
// 1,2,3,4,5,6,7,8,9,10,11
2,2,2,2,2,2,3,2,3, 3, 1
enddata
data RoomRotateData
1,0,0,0,
1,0,0,0,
1,0,0,0,
1,0,0,0
enddata
const
int MapEditMode=1,
RoomEditMode=2,
MazeEditMode=3,
ThreeDEditMode=4,
TextureEditMode=5
int StretchTexturesBoth=1, TileTexturesBoth=2, StretchAcrossTileDown=3, StretchDownTileAcross=4,
StretchAndSquareTile=5
const
int MINUNIT = 10, MAXUNIT = 100, UNITSTEP = 10, DEFAULTMAPUNIT = 30, DEFAULTROOMUNIT = 60
int DEFAULTPLAYERMAPUNIT=8
int DRAWNAMEUNIT = 40
int maxx = 100, maxy = 100
int MapGridX = 60, MapGridY = 180
int RoomGridX = 60, RoomGridY = 180
int NROTATES = high(RoomRotateData)+1
int MaxRoomSize = 10
int DefaultRoomW = 5, DefaultRoomD = 5, DefaultRoomHeight = 2, DefaultLinkHeight = 1
//basic room defs
const
float floor = -0.5
float roomsep = 0.000
float OBJECTHEIGHT = 0.1
int NROOMS = 7,
NLINKS = 4,
NMAPOBJS = NROOMS+NLINKS,
NOBJECTS = 11
int NITEMS=7
int MAXINVENTORY=10
int GreenKeyItem=0, BlueKeyItem=1, RedKeyItem=2
int MapItem=3, TimeBonusItem=4, FreezeTimeItem=5
int SpeedItem=6
int EndItem=10
int SPEEDTIMEPERIOD=20
int FREEZETIMEPERIOD=10
int TIMEBONUS=10
int MaxObjectsPerRoom = 5
int MaxObjectsPerLink = 2
int DefaultClipping=15
var
int FarClipping=DefaultClipping
string InitFile
int bigarray[maxy][maxx]
int walls[maxy][maxx]
int ObjectsPerRoom[1 to NMAPOBJS]
int DoorsPerRoom[1 to NMAPOBJS]
string MazeFilenames[0]
var
int XOriginObj, YOriginObj
//global maze data
string MazeTimeLimit
string MazeName
string MazeFilename
filename SaveFilename
boolean goodsav
string TextureDir
int RoomFloorTexture, RoomWallTexture, RoomCeilingTexture
int LinkFloorTexture, LinkWallTexture, LinkCeilingTexture
int RedDoorTexture, GreenDoorTexture, BlueDoorTexture
int SoundEffectFlags
string FinishSound, OooffSound, CollectSound
string BackgroundMIDI
string ObjectDir
string SoundDir
int NextCollectSlot
string Object3dList[0]
int Object3dUsage[0]
float Object3dScale[0]
// float Object3dXRot[0]
// float Object3dYRot[0]
// float Object3dZRot[0]
string TextureList[0]
int TextureUsage[0]
int NumberOfTextures
int RoomFloorTexturing, RoomWallTexturing, RoomCeilingTexturing
int ThisRoomTexturing=0
int ThisRoomFloorTexture
int ThisRoomWallTexture
int ThisRoomCeilingTexture
string LevelName[0]
int NextRoomAtLevel[0]
int NextLinkAtLevel[0]
int Adjacent[0] //list of adjacent cells for all rooms
RwClump *DoorClumps[0]//clump for each door in a room
RwClump DoorControlCLump[0]
int DoorControlCell[0]
int OverlapList[0] //list of overlapping cells for all rooms
int ObjectsList[0] //list of all objects in the maze
string ObjectsName[0]//special names of objects in a room
int ObjectsXYH[0] //position of objects in a room
// float ObjectsXRot[0], ObjectsYRot[0], ObjectsZRot[0]
RwClump *ObjectsClump[0]//clump for each object in a room
int roomtype[0] //type of room
int RoomNumber[0]
int roomid[0] //id of first object in room
int roomNameid[0] //id of name object for room if any
int roomx[0] //x pos of room
int roomy[0] //y pos
int roomw[0] //width
int roomd[0] //depth
int roomr[0] //rotation code
int RoomHeight[0] //height
int RoomLevel[0] //level of room
string RoomName[0] //name of room
int RoomDoors[0] //number of doors in room
int RoomAdjacent[0] //index in AdjacentList of first adjacent cell
int RoomObjectsCount[0] //number of objects in room
int RoomObjectsindex[0] //index in ObjectsXXXX of first object in room
int RoomTextureBits[0]
int RoomVisited[0] //true if room visited
RwClump *room_geometry[0]
RwScene *room_contents[0]
RwClump *PosStr
int TopDownSort[0]
int BottomUpSort[0]
int LeftToRightSort[0]
int RightToLeftSort[0]
int AdjacentRender[0]
int RoomsAtThisLevel[0]
int PlayerMapUnit=DEFAULTPLAYERMAPUNIT
int MapUnit
int RoomUnit
int CurrentPenWidth = 2
int unit
int door
int FirstObjectTag, LastObjectTag
int StartX, StartY, StartRoom, StartLevel
int EndX, EndY, EndRoom, EndLevel
int CheckError
int StartPosObj, EndPosObj
int GridObjectFirst, GridObjectLast
int DrawOriginX, DrawOriginY
int GridOriginX, GridOriginY
boolean RelativeDrawMode
int MapdrawX, MapDrawY
int EditMode = -1
int MapCreateMode = 1
// boolean AutoLinkMode
int ActionKey=0
int ActionType
int ActionRoom=-1, thesize=2
int ActionLevel=0
int ActionX, ActionY
// string ActionRoomName
string ActionLevelName
boolean EndReached, OutOfTime, quit
//stock object stuff
int ItemsList[NITEMS]
RwClump Inventory[NITEMS][1 to MAXINVENTORY]
int score
int MazeTime
int TimerTick
int ticks
int FrozenTime
int HighSpeedTime
int FirstScoreSprite=10, ScoreDigits=7
int FirstTimeSprite=17, TimeDigits=3
int TimeRingSprite=20
//stock object sprites are numbered 0-7
int digits=10
int MaggotSprite=255
int FirstTimeRingSprite=20
int TimeRingSprites=10
int WindowX, WindowY, WindowW, WindowH
int WindowRX, WindowRY
sub printrwerror( str as string )
print str, " ", RwStrError( RwGetError() ), "\n"
endsub
sub fast_ ShowScore( bonus as int )
local
int i, s, dv
int x=0,y=0
endlocal
score+=bonus
s=score
for i = FirstScoreSprite to FirstScoreSprite+ScoreDigits-1 loop
dv = s % 10
s/=10
CreateSprite i, x, y, oneshot, 0, 0, 1, [digits+dv]
if s = 0 then
loopexit
endif
end loop
end sub
sub fast_ ShowTime( adjust as int )
local
int i, t, dv
int x=0,y=0
boolean Leading0=true
int ring, lastring
int divby=int(pow(10,TimeDigits-1))
endlocal
if MazeTimeLimit = "-1" then
return
endif
if MazeTimeLimit = "0" then
//count up
MazeTime-=adjust
t = MazeTime
else
MazeTime+=adjust
t = MazeTime
if t <= 0 then
OutOfTime = true
t = 0
endif
ring = (MazeTime)/10
if ring <= 8 then
if ring <> lastring then
CreateSprite TimeRingSprite, 38*2, 23*2, oneshot, 0, 0, 1, [FirstTimeRingSprite+(8-ring)]
SetSpriteFlags TimeRingSprite, enabled|visible, unbound
lastring = ring
endif
else
ring = 10
if ring <> lastring then
CreateSprite TimeRingSprite, 38*2, 23*2, oneshot, 0, 0, 1, [FirstTimeRingSprite+8]
SetSpriteFlags TimeRingSprite, enabled|visible, unbound
lastring=ring
endif
endif
endif
for i = FirstTimeSprite+TimeDigits-1 to FirstTimeSprite step -1 loop
// dv = t % 10
// t/=10
dv = t/divby
t-=dv*divby
divby/=10
if dv <> 0 then
leading0 = false
endif
CreateSprite i, x, y, oneshot, 0, 0, 1, [digits+dv]
if leading0 then
SetSpriteFlags i, enabled, unbound
else
SetSpriteFlags i, enabled|visible, unbound
endif
end loop
end sub
function fast_ ValidRoom( n as int ) as boolean
if n < 0 or n > high(RoomType) then
return false
endif
if RoomType[n] = 0/* or RoomID[n] = 0*/ then
return false
endif
return true
end function
function fast_ RoomAtLevel( n as int level as int ) as boolean
return RoomLevel[n] = level
end function
function fast_ PointInRoom( n as int x as int y as int level as int ) as boolean
//return true if (x,y) is in room n
local
int r
int x1,y1,x2,y2
endlocal
if not ValidRoom(n) then
return false
endif
if not RoomAtLevel( n, level ) then
return false
endif
// print using "PointInRoom=%d type=%d (%d,%d)", n, RoomType[n], x, y
// print using "x=%d y=%d w=%d d=%d", roomx[n], roomy[n], roomw[n], roomd[n]
if x < roomx[n] or x >= (roomx[n]+roomw[n]) then
return false
endif
if y < roomy[n] or y >= (roomy[n]+roomd[n]) then
return false
endif
x1 = RoomX[n]
y1 = RoomY[n]
x2 = RoomW[n]+x1-1
y2 = RoomD[n]+y1-1
r = RoomR[n]
if RoomType[n] = NROOMS+1 then
//special cases for the link pieces because these are not rectangular
if r = 0 then
if x = x2 and y = y1 then
return false
endif
elsif r = 4 then
if x = x2 and y = y2 then
return false
endif
elsif r = 8 then
if x = x1 and y = y2 then
return false
endif
elsif r = 12 then
if x = x1 and y = y1 then
return false
endif
endif
elseif RoomType[n] = NROOMS+2 then
if r = 0 then
if (x = x1 and y = y2) or (x = x2 and y = y2) then
return false
endif
elsif r = 4 then
if (x = x1 and y = y1) or (x = x1 and y = y2) then
return false
endif
elsif r = 8 then
if (x = x1 and y = y1) or (x = x2 and y = y1) then
return false
endif
elsif r = 12 then
if (x = x2 and y = y1) or (x = x2 and y = y2) then
return false
endif
endif
elseif RoomType[n] = NROOMS+3 then
if (r % 4) = 0 then
if (x = x1 and y = y1) or (x = x2 and y = y1) or (x = x1 and y = y2) or (x = x2 and y = y2) then
return false
endif
endif
endif
return true
end function
function fast_ FindRoomAtXYL( x as int y as int level as int type inout int ) as int
//return the number of the room covering xy
//return 0 if none
local
int n=0
endlocal
while n <= high(RoomType) loop
if PointInRoom(n, x, y, level) then
type = RoomType[n]
return n
endif
n++
endloop
return -1
end function
function fast_ XYL( x as int y as int level as int ) as int
return (level*maxy+y)*maxx+x
end function
sub fast_ fromXYL( XYL as int x inout int y inout int level inout int )
XYL &= %x00ffffff
x = XYL % maxx
// XYL-=x
XYL/=maxx
y = XYL % maxy
// XYL-=y
level = XYL/maxy
end sub
// include `\tvml\apps\mazeedit\msgbox.tvm`
//msg box functions
const
int cancel=1, yes=2, no=3
int YESORNOBOX=1, OKBOX=2, YESNOCANCELBOX=3
function MsgBox( str1 as string str2 as string type as int ) as int
local
const
int h = 60*3, l = 400, t = 0
var
int id, id1, id2
int flag=0
int l1=len(str1)
int w=max([l1,len(str2)])*10
int bwidth, bleft, left
endlocal
for id = id1 to id2 loop
DeleteObject id
endfor
gsave()
id1 = GetNextObjectID()
if type = OKBOX then
bwidth = 120+30*2
elsif type = YESORNOBOX then
bwidth = 120*2+30*3
elsif type = YESNOCANCELBOX then
bwidth = 120*3+30*4
endif
w = max([bwidth, w])
left = max([(1280-w)/2,l])
bleft = (w-bwidth)/2+left+30
linestyle solid
pencolor 0,0,160
penwidth 2
SetColourFill 128,128,128
rectangle left, t+10, w, h-10
id = 200
label id, left, t+10, w, 100, centre, str1+'\n'+str2
if type = OKBOX then
button bleft, t+110, 120, 60, "OK", enabled, none, { flag = yes }
elsif type = YESORNOBOX then
button bleft, t+110, 120, 60, "YES", enabled, none, { flag = yes }
button bleft+150, t+110, 120, 60, "NO", enabled, none, { flag = no }
elsif type = YESNOCANCELBOX then
button bleft , t+110, 120, 60, "YES", enabled, none, { flag = yes }
button bleft+150, t+110, 120, 60, "NO", enabled, none, { flag = no }
button bleft+300, t+110, 120, 60, "CANCEL", enabled, none, { flag = cancel}
endif
grestore()
id2 = GetNextObjectID()-1
flag = 0
while not flag loop
hold
endloop
for id = id1 to id2 loop
DeleteObject id
endfor
id1 = 0
id2 = 0
return flag
end function
// include `\tvml\apps\mazeedit\mapstuff.tvm`
//Bug fix function
sub DelayedUpdate( p as boolean )
local
int r
endlocal
gsave()
SetDelayedUpdate p
if not p then
r = GetNextObjectID()
linestyle 0
SetNoFill
rectangle GridOriginX,GridOriginY,1280-GridOriginX,960-GridOriginY
DeleteObject r
endif
grestore()
end sub
sub SetRoomDefaults( num as int )
if num != -1 and RoomType[num] > NROOMS then
pencolor 255,0,255
else
pencolor 0,0,255
endif
if unit < 20 then
CurrentPenWidth = 1
else
CurrentPenWidth = 2
endif
penwidth CurrentPenWidth
linestyle solid
end sub
sub DrawDoors( num as int x1 as int y1 as int x2 as int y2 as int )
//draw room num doors
local
int rx1 = RoomX[num], ry1 = RoomY[num], rx2 = rx1+RoomW[num], ry2 = ry1+RoomD[num]
int aji = RoomAdjacent[num]
int nd = RoomDoors[num]
int i, dt, dx, dy, dl, dp
int o
endlocal
gsave()
linestyle solid
if CurrentPenWidth = 2 then
penwidth 3
o = 3
else
penwidth 1
o = 1
endif
for i = 0 to nd-1 loop
dt = Adjacent[aji+i] & %xff000000
if dt then
dt>>=24
if dt = 1 then
pencolor 128+63+32,0,0
elseif dt = 2 then
pencolor 0,128+63+32,0
elseif dt = 3 then
pencolor 0,0,128+63+32
endif
else
//draw thicker grey line to indicate doorway
pencolor 128+64+32,128+64+32,128+64+32
endif
fromXYL( Adjacent[aji+i], dx, dy, dl )
if dx = rx1-1 then
//left wall door
dp = (dy-ry1)*unit+y1
line [x1+o,dp, x1+o, dp+unit]
elseif dx = rx2 then
//right wall door
dp = (dy-ry1)*unit+y1
line [x2-o,dp, x2-o, dp+unit]
elseif dy = ry1-1 then
//top wall door
dp = (dx-rx1)*unit+x1
line [dp, y1+o, dp+unit, y1+o]
elseif dy = ry2 then
//bottom wall door
dp = (dx-rx1)*unit+x1
line [dp, y2-o, dp+unit, y2-o]
endif
endloop
grestore()
end sub
sub fast_ DrawObjectTags( num as int )
local
int max, ObjectIndex, first=RoomObjectsIndex[num]
int x,y,h, id, offset
string ObjectTags[1 to NOBJECTS], name
boolean InitDone
endlocal
if not InitDone then
ObjectTags[1] = "g"
ObjectTags[2] = "b"
ObjectTags[3] = "r"
ObjectTags[4] = "m"
ObjectTags[5] = "t"
ObjectTags[6] = "h"
ObjectTags[7] = "f"
ObjectTags[8] = "p"
ObjectTags[9] = "p"
ObjectTags[10] = "p"
ObjectTags[11] = "e"
InitDone = true
endif
gsave()
font "timesroman", unit/2, unit
if RoomType[num] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
for ObjectIndex = 0 to max-1 loop
id = ObjectsList[ObjectIndex+first]
if id != 0 then
fromXYL( ObjectsXYH [ObjectIndex+first], x, y, h )
x+=RoomX[num]
y+=RoomY[num]
if id = -11 then
print using "End in Room %d\n", num
endif
if id != -4 then offset = unit/4 else offset = 0 endif
if id < 0 then
//stock object
text (x+DrawOriginX)*unit+GridOriginX+offset, (y+DrawOriginY)*unit+GridOriginY, ObjectTags[-id]
else
//it's a user object
text (x+DrawOriginX)*unit+GridOriginX+offset, (y+DrawOriginY)*unit+GridOriginY, "u"
endif
endif
endfor
grestore()
end sub
sub fast_ DeleteAllObjectTags()
local
int id
endlocal
for id = FirstObjectTag to LastObjectTag loop
DeleteObject id
endfor
FirstObjectTag = 0
LastObjectTag = -1
endsub
sub fast_ DrawAllObjectTags()
local
int r
endlocal
DeleteAllObjectTags()
FirstObjectTag = GetNextObjectID()
for r = 0 to high(RoomType) loop
if RoomLevel[r] = ActionLevel then
DrawObjectTags( r )
endif
endfor
LastObjectTag = GetNextObjectID()-1
end sub
sub fast_ DrawRoom( num as int )
//draw room number num
local
int n = RoomType[num]
int x = RoomX[num], y = RoomY[num], w = RoomW[num], d = RoomD[num], r = RoomR[num]
int thisx = x, thisy = y
int x1, y1, x2, y2
int dw1, dw2, dw3, dw4, dh1, dh2, dh3, dh4
int id
endlocal
if ActionLevel != RoomLevel[num] then
return
endif
gsave()
SetRoomDefaults(num)
if EditMode = MapEditMode then
if num = ActionRoom then
pencolor 0,255,0
endif
endif
if RoomTextureBits[num] > 0 then
penwidth 1 //Windows 95 can't draw a broken line any thicker
linestyle dots
endif
if RelativeDrawMode then
thisx = 0
thisy = 0
endif
x1 = (thisx+DrawOriginX)*unit+GridOriginX y1 = (thisy+DrawOriginY)*unit+GridOriginY
if x1 < GridOriginX or y1 < GridOriginY then
grestore()
return
endif
x2 = (thisx+w+DrawOriginX)*unit+GridOriginX
y2 = (thisy+d+DrawOriginY)*unit+GridOriginY
if CurrentPenWidth = 2 then
x2-=CurrentPenWidth
y2-=CurrentPenWidth
endif
RoomID[num] = GetNextObjectID()
dw1 = ((w-1)/2)
dw2 = (w-1-dw1)
dw3 = (w-3)/2
dw4 = (w-3-dw3)
dh1 = ((d-1)/2)
dh2 = (d-1-dh1)
dh3 = (d-3)/2
dh4 = (d-3-dh3)
dw1*=unit dw2*=unit dw3*=unit dw4*=unit
dh1*=unit dh2*=unit dh3*=unit dh4*=unit
if n = 1 then
if r = 0 then
line [x1,y1,x2,y1,x2,y2] //top and right
line [x2-door,y2,x1,y2,x1,y1+door] //bottom and left
elsif r = 4 then
line [x2,y1,x2,y2,x1,y2]
line [x1,y2-door,x1,y1,x2-door,y1]
elsif r = 8 then
line [x2,y2,x1,y2,x1,y1]
line [x1+door,y1,x2,y1,x2,y2-door]
elsif r = 12 then
line [x1,y2,x1,y1,x2,y1]
line [x2,y1+door,x2,y2,x1+door,y2]
else
print "Illegal rotate code room %d %d ", n, r
endif
elseif n = 2 then
if r = 0 then
line [x2,y1,x2,y2]
line [x2-door,y2,x1,y2,x1,y2-dh2]
line [x1,y1+dh1,x1,y1,x2-door,y1]
elsif r = 4 then
line [x2,y2,x1,y2]
line [x1,y2-door,x1,y1,x1+dw2,y1]
line [x2-dw1,y1,x2,y1,x2,y2-door]
elsif r = 8 then
line [x1,y2,x1,y1]
line [x1+door,y1,x2,y1,x2,y1+dh1]
line [x2,y2-dh2,x2,y2,x1+door,y2]
elsif r = 12 then
line [x1,y1,x2,y1]
line [x2,y1+door,x2,y2,x2-dw2,y2]
line [x1+dw1,y2,x1,y2,x1,y1+door]
else
print "Illegal rotate code room %d %d ", n, r
endif
elseif n = 3 then
if (r = 0) or (r = 8) then
line [x1,y1+dh1,x1,y1,x2-door,y1]
line [x2,y1,x2,y1+dh2]
line [x2,y2-dh1,x2,y2,x1+door,y2]
line [x1,y2,x1,y2-dh2]
elsif (r = 4) or (r = 12) then
line [x1,y1,x1+dw2,y1]
line [x2-dw1,y1,x2,y1,x2,y2-door]
line [x2,y2,x2-dw2,y2]
line [x1+dw1,y2,x1,y2,x1,y1+door]
else
print "Illegal rotate code room %d %d ", n, r
endif
elseif n = 4 then
if r = 0 or r = 8 then
line [x1+door,y1,x2,y1,x2,y1+dh2]
line [x2,y2-dh1,x2,y2]
line [x2-door,y2,x1,y2,x1,y2-dh2]
line [x1,y1+dh1,x1,y1]
elsif r = 4 or r = 12 then
line [x1,y2-door,x1,y1,x1+dw2,y1]
line [x2-dw1,y1,x2,y1]
line [x2,y1+door,x2,y2,x2-dw2,y2]
line [x1+dw1,y2,x1,y2]
else
print "Illegal rotate code room %d %d ", n, r
endif
elsif n = 5 then
if r = 0 then
line [x1+dw1,y1, x1,y1,x1,y2,x2,y2,x2,y1,x2-dw2,y1]
elsif r = 4 then
line [x2,y1+dh1, x2,y1,x1,y1,x1,y2,x2,y2,x2,y2-dh2]
elsif r = 8 then
line [x2-dw1,y2, x2,y2,x2,y1,x1,y1,x1,y2,x1+dw2,y2]
elsif r = 12 then
line [x1,y2-dh1, x1,y2,x2,y2,x2,y1,x1,y1,x1,y1+dh2]
else
print "Illegal rotate code room %d %d ", n, r
endif
elsif n = 6 then
if (r % 4) = 0 then
line [x1,y1+dh1,x1,y1,x1+dw1,y1]
line [x2-dw2,y1,x2,y1,x2,y1+dh2]
line [x2,y2-dh1,x2,y2,x2-dw1,y2]
line [x1+dw2,y2,x1,y2,x1,y2-dh2]
else
print "Illegal rotate code room %d %d ", n, r
endif
elsif n = 7 then
if r = 0 then
line [x1+door,y1,x2,y1,x2,y1+dh1]
line [x2,y2-dh2,x2,y2,x2-dw3,y2]
line [x2-dw3-door,y2,x2-dw3-2*door,y2]
line [x1+dw4,y2,x1,y2,x1,y1]
elsif r = 4 then
line [x1,y1+dh4,x1,y1,x2,y1]
line [x2,y1+door,x2,y2,x2-dw1,y2]
line [x1+dw2,y2,x1,y2,x1,y2-dh3]
line [x1,y2-dh3-door,x1,y2-dh3-2*door]
elsif r = 8 then
line [x1,y1+dh2,x1,y1,x1+dw3,y1]
line [x1+dw3+door,y1,x1+dw3+2*door,y1]
line [x2-dw4,y1,x2,y1,x2,y2]
line [x2-door,y2,x1,y2,x1,y2-dh1]
elsif r = 12 then
line [x1,y2-door,x1,y1,x1+dw1,y1]
line [x2-dw2,y1,x2,y1,x2,y1+dh3]
line [x2,y1+dh3+door,x2,y1+dh3+2*door]
line [x2,y2-dh4,x2,y2,x1,y2]
else
print "Illegal rotate code room %d %d ", n, r
endif
elsif n = NROOMS+1 then
//links
if r = 0 then
line [x1,y1,x1,y2,x2,y2]
line [x2-unit,y1,x2-unit,y1+unit,x2,y1+unit]
elsif r = 4 then
line [x1,y2,x1,y1,x2,y1]
line [x2-unit,y2,x2-unit,y2-unit,x2,y2-unit]
elsif r = 8 then
line [x1,y1,x2,y1,x2,y2]
line [x1,y2-unit,x1+unit,y2-unit,x1+unit,y2]
elsif r = 12 then
line [x1,y1+unit,x1+unit,y1+unit,x1+unit,y1]
line [x1,y2,x2,y2,x2,y1]
endif
elsif n = NROOMS+2 then
if r = 0 then
line [x1,y1,x2,y1]
line [x1,y2-unit,x1+unit,y2-unit,x1+unit,y2]
line [x2,y2-unit,x2-unit,y2-unit,x2-unit,y2]
elsif r = 4 then
line [x2,y1,x2,y2]
line [x1+unit,y1,x1+unit,y1+unit,x1,y1+unit]
line [x1+unit,y2,x1+unit,y2-unit,x1,y2-unit]
elsif r = 8 then
line [x1,y2,x2,y2]
line [x1,y1+unit,x1+unit,y1+unit,x1+unit,y1]
line [x2,y1+unit,x2-unit,y1+unit,x2-unit,y1]
elsif r = 12 then
line [x1,y1,x1,y2]
line [x2-unit,y1,x2-unit,y1+unit,x2,y1+unit]
line [x2-unit,y2,x2-unit,y2-unit,x2,y2-unit]
endif
elsif n = NROOMS+3 then
if r = 0 or r = 4 or r = 8 or r = 12 then
line [x1,y1+unit,x1+unit,y1+unit,x1+unit,y1]
line [x2-unit,y1,x2-unit,y1+unit,x2,y1+unit]
line [x1,y2-unit,x1+unit,y2-unit,x1+unit,y2]
line [x2-unit,y2,x2-unit,y2-unit,x2,y2-unit]
endif
elsif n = NROOMS+4 then
if r = 0 or r = 8 then
line [x1,y1,x2,y1]
line [x1,y2,x2,y2]
elsif r = 4 or r = 12 then
line [x1,y1,x1,y2]
line [x2,y1,x2,y2]
endif
endif
DrawDoors( num, x1, y1, x2, y2 )
pencolor 0,0,255
if unit >= DRAWNAMEUNIT then
RoomNameID[num] = GetNextObjectID()
text x1+4, y1, RoomName[num]
else
RoomNameID[num] = 0
endif
grestore()
end sub
sub FindAdjacent( num as int )
//find the cells adjacent to the doors of room num
local
int n = RoomType[num]
// int thisx = x, thisy = y
int dw1, dw2, dw3, dw4, dh1, dh2, dh3, dh4
// int id
int l = RoomLevel[num]
int aji = RoomAdjacent[num]
int w = RoomW[num], d = RoomD[num], r = RoomR[num]
int x1 = Roomx[num], y1 = RoomY[num], x2 = x1+RoomW[num], y2=y1+RoomD[num]
int nd = RoomDoors[num]
endlocal
if not ValidRoom(num) then
return
endif
//preserve any door type info
for dw1 = 0 to nd-1 loop
Adjacent[aji+dw1] &= %xff000000
endloop
dw1 = ((w-1)/2)
dw2 = (w-1-dw1)
dw3 = (w-3)/2
dw4 = (w-3-dw3)
dh1 = ((d-1)/2)
dh2 = (d-1-dh1)
dh3 = (d-3)/2
dh4 = (d-3-dh3)
if n = 1 then
// print using "Room type 1 (%d,%d)-(%d,%d)", x1,y1,x2,y2
if r = 0 then
Adjacent[aji++] |= XYL(x1-1,y1,l)
Adjacent[aji++] |= XYL(x2-1,y2,l)
elsif r = 4 then
Adjacent[aji++] |= XYL(x1-1,y2-1,l)
Adjacent[aji++] |= XYL(x2-1,y1-1,l)
elsif r = 8 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y2-1,l)
elsif r = 12 then
Adjacent[aji++] |= XYL(x1,y2,l)
Adjacent[aji++] |= XYL(x2,y1,l)
endif
elsif n = 2 then
if r = 0 then
Adjacent[aji++] |= XYL(x2-1,y1-1,l)
Adjacent[aji++] |= XYL(x2-1,y2,l)
Adjacent[aji++] |= XYL(x1-1,y1+dh1,l)
elsif r = 4 then
Adjacent[aji++] |= XYL(x1-1,y2-1,l)
Adjacent[aji++] |= XYL(x2,y2-1,l)
Adjacent[aji++] |= XYL(x1+dw2,y1-1,l)
elsif r = 8 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x1,y2,l)
Adjacent[aji++] |= XYL(x2,y1+dh1,l)
elsif r = 12 then
Adjacent[aji++] |= XYL(x1-1,y1,l)
Adjacent[aji++] |= XYL(x2,y1,l)
Adjacent[aji++] |= XYL(x1+dw1,y2,l)
endif
elsif n = 3 then
if (r = 0) or (r = 8) then
Adjacent[aji++] |= XYL(x2-1,y1-1,l)
Adjacent[aji++] |= XYL(x1,y2,l)
Adjacent[aji++] |= XYL(x1-1,y1+dh1,l)
Adjacent[aji++] |= XYL(x2,y1+dh2,l)
elsif (r = 4) or (r = 12) then
Adjacent[aji++] |= XYL(x1-1,y1,l)
Adjacent[aji++] |= XYL(x1+dw2,y1-1,l)
Adjacent[aji++] |= XYL(x2,y2-1,l)
Adjacent[aji++] |= XYL(x1+dw1,y2,l)
endif
elsif n = 4 then
if r = 0 or r = 8 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y1+dh2,l)
Adjacent[aji++] |= XYL(x2-1,y2,l)
Adjacent[aji++] |= XYL(x1-1,y1+dh1,l)
elsif r = 4 or r = 12 then
Adjacent[aji++] |= XYL(x1-1,y2-1,l)
Adjacent[aji++] |= XYL(x1+dw2,y1-1,l)
Adjacent[aji++] |= XYL(x2,y1,l)
Adjacent[aji++] |= XYL(x1+dw1,y2,l)
endif
elsif n = 5 then
if r = 0 then
Adjacent[aji++] |= XYL(x1+dw1,y1-1,l)
elsif r = 4 then
Adjacent[aji++] |= XYL(x2,y1+dh1,l)
elsif r = 8 then
Adjacent[aji++] |= XYL(x1+dw2,y2,l)
elsif r = 12 then
Adjacent[aji++] |= XYL(x1-1,y1+dh2,l)
endif
elsif n = 6 then
if (r % 4) = 0 then
Adjacent[aji++] |= XYL(x1-1,y1+dh1,l)
Adjacent[aji++] |= XYL(x1+dw1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y1+dh2,l)
Adjacent[aji++] |= XYL(x1+dw2,y2,l)
endif
elsif n = 7 then
if r = 0 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y1+dh1,l)
Adjacent[aji++] |= XYL(x2-dw3-1,y2,l)
Adjacent[aji++] |= XYL(x1+dw4,y2,l)
elsif r = 4 then
Adjacent[aji++] |= XYL(x1-1,y1+dh4,l)
Adjacent[aji++] |= XYL(x2,y1,l)
Adjacent[aji++] |= XYL(x1+dw2,y2,l)
Adjacent[aji++] |= XYL(x1-1,y2-dh3-1,l)
elsif r = 8 then
Adjacent[aji++] |= XYL(x1-1,y1+dh2,l)
Adjacent[aji++] |= XYL(x1+dw3,y1-1,l)
Adjacent[aji++] |= XYL(x1+dw3+2,y1-1,l)
Adjacent[aji++] |= XYL(x2-1,y2,l)
elsif r = 12 then
Adjacent[aji++] |= XYL(x1-1,y2-1,l)
Adjacent[aji++] |= XYL(x1+dw1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y1+dh3,l)
Adjacent[aji++] |= XYL(x2,y1+dh3+2,l)
endif
elsif n = NROOMS+1 then
if r = 0 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y2-1,l)
elsif r = 4 then
Adjacent[aji++] |= XYL(x2,y1,l)
Adjacent[aji++] |= XYL(x1,y2,l)
elsif r = 8 then
Adjacent[aji++] |= XYL(x1-1,y1,l)
Adjacent[aji++] |= XYL(x2-1,y2,l)
elsif r = 12 then
Adjacent[aji++] |= XYL(x1-1,y2-1,l)
Adjacent[aji++] |= XYL(x2-1,y1-1,l)
endif
elsif n = NROOMS+2 then
if r = 0 then
Adjacent[aji++] |= XYL(x1-1,y1,l)
Adjacent[aji++] |= XYL(x2,y1,l)
Adjacent[aji++] |= XYL(x1+1,y2,l)
elsif r = 4 then
Adjacent[aji++] |= XYL(x2-1,y1-1,l)
Adjacent[aji++] |= XYL(x1-1,y1+1,l)
Adjacent[aji++] |= XYL(x2-1,y2,l)
elsif r = 8 then
Adjacent[aji++] |= XYL(x1-1,y2-1,l)
Adjacent[aji++] |= XYL(x1+1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y2-1,l)
elsif r = 12 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x2,y1+1,l)
Adjacent[aji++] |= XYL(x1,y2,l)
endif
elsif n = NROOMS+3 then
if (r % 4) = 0 then
Adjacent[aji++] |= XYL(x1+1,y1-1,l)
Adjacent[aji++] |= XYL(x1-1,y1+1,l)
Adjacent[aji++] |= XYL(x2,y1+1,l)
Adjacent[aji++] |= XYL(x1+1,y2,l)
endif
elsif n = NROOMS+4 then
if r = 0 or r = 8 then
Adjacent[aji++] |= XYL(x1-1,y1,l)
Adjacent[aji++] |= XYL(x2,y1,l)
elsif r = 4 or r = 12 then
Adjacent[aji++] |= XYL(x1,y1-1,l)
Adjacent[aji++] |= XYL(x1,y2,l)
endif
endif
end sub
function CreateLink( n as int x as int y as int r as int height as int name as string ) as int
//create a link of type n at(x,y) rotation r
//return the link number (0 based)
local
int num, w, d, i
int NameObject = 0
endlocal
num = NextLinkAtLevel[ActionLevel]++
if n = 1 then
w = 2
d = 2
elsif n = 2 then
if r = 0 or r = 8 then
w = 3
d = 2
else
w = 2
d = 3
endif
elsif n = 3 then
w = 3
d = 3
elsif n = 4 then
w = 1
d = 1
endif
AddElement roomx x
AddElement roomy y
AddElement roomw w
AddElement roomd d
AddElement roomr r
AddElement RoomHeight height
AddElement RoomType n+NROOMS
AddElement RoomID 0
AddElement RoomNameID 0
AddElement RoomDoors DoorsPerRoom[n+NROOMS]
AddElement RoomAdjacent high(Adjacent)+1
AddElement RoomObjectsCount 0
AddElement RoomObjectsIndex high(ObjectsList)+1
AddElement RoomTextureBits 0
for i = 1 to MaxObjectsPerLink loop
AddElement ObjectsList 0
AddElement ObjectsName ""
AddElement ObjectsXYH 0
endfor
for i = 1 to DoorsPerRoom[n+NROOMS] loop
AddElement Adjacent 0
endfor
if name == "" then
name = print( using "Link %d", Num )
endif
AddElement RoomNumber num
AddElement RoomName name
AddElement RoomLevel ActionLevel
FindAdjacent( high(RoomType) )
DrawRoom( high(RoomType) )
return high(RoomType)
endfunction
function fast_ CreateRoom( n as int x as int y as int w as int d as int r as int height as int name as string ) as int
//create a room of type n at(x,y) size(w,d) rotation r
//return the room number (0 based)
local
int num, i
endlocal
num = NextRoomAtLevel[ActionLevel]++
AddElement roomx x
AddElement roomy y
AddElement roomw w
AddElement roomd d
AddElement roomr r
AddElement RoomHeight height
AddElement RoomType n
AddElement RoomID 0
AddElement RoomNameID 0
AddElement RoomDoors DoorsPerRoom[n]
AddElement RoomAdjacent high(Adjacent)+1
AddElement RoomObjectsCount 0
AddElement RoomObjectsIndex high(ObjectsList)+1
AddElement RoomTextureBits 0
for i = 1 to MaxObjectsPerRoom loop
AddElement ObjectsList 0
AddElement ObjectsName ""
AddElement ObjectsXYH 0
endfor
for i = 1 to DoorsPerRoom[n] loop
AddElement Adjacent 0
endfor
if name == "" then
name = print( using "Room %d", num )
endif
AddElement RoomNumber num
AddElement RoomName name
AddElement RoomLevel ActionLevel
FindAdjacent( high(RoomType) )
DrawRoom( high(RoomType) )
return high(RoomType)
endfunction
sub fast_ DrawGrid()
local
int sx, sy, n
int w, d
endlocal
GridObjectFirst = GetNextObjectID()
gsave()
DelayedUpdate (true)
pencolor 128+64+32,128+64+32,128+64+32
penwidth 1
linestyle solid
SetNoFill
if EditMode = MapEditMode then
w = 100*unit-(GridOriginX-DrawOriginX*unit)
d = 100*unit-(GridOriginY-DrawOriginY*unit)
w=100*unit
d=100*unit
else
w = 12*unit-(GridOriginX-DrawOriginX*unit)
d = 12*unit-(GridOriginY-DrawOriginY*unit)
w = 12*unit
d = 12*unit
endif
if w > 1280-GridOriginX then
w = 1280-GridOriginX
endif
if d > 960-GridOriginY then
d = 960-GridOriginY
endif
rectangle GridOriginX, GridOriginY, w, d
n=0
for sx = GridOriginX to w+GridOriginX step unit loop
line [ sx,GridOriginY,sx,d+GridOriginY ]
if ++n >= 100 then
loopexit
endif
endloop
n=0
for sy = GridOriginY to d+GridOriginY step unit loop
line [ GridOriginX,sy,w+GridOriginX,sy ]
if ++n >= 100 then
loopexit
endif
endloop
GridObjectLast = GetNextObjectID()-1
DelayedUpdate (false)
grestore()
if XOriginObj then
SetStringProperty XOriginObj, "Text", itostr(-DrawOriginX)
endif
if YOriginObj then
SetStringProperty YOriginObj, "Text", itostr(-DrawOriginY)
endif
end sub
sub fast_ DeleteGrid()
local
int id
endlocal
DelayedUpdate (true)
for id = GridObjectFirst to GridObjectLast loop
DeleteObject id
endfor
GridObjectFirst = 0
GridObjectLast = 0
DelayedUpdate (false)
end sub
sub fast_ SetRoomLineColour( n as int r as rgbvalue g as rgbvalue b as rgbvalue )
// set the colour of the lines making this room
local
int i, id
endlocal
if not ValidRoom(n) then
return
endif
id = RoomId[n]
if id then
for i = 1 to ObjectsPerRoom[RoomType[n]] loop
SetRGBProperty id++, "PenColour", r,g,b
endfor
endif
end sub
sub fast_ ResetRoomLineColour( n as int )
// set the default colour of the lines making this room
local
int i, id
rgbvalue r=0,g=0,b=255
endlocal
if not ValidRoom(n) then
return
endif
if RoomType[n] > NROOMS then
r=255
endif
id = RoomId[n]
if id then
for i = 1 to ObjectsPerRoom[RoomType[n]] loop
SetRGBProperty id++, "PenColour", r,g,b
endfor
endif
end sub
sub DrawStartPos( relative as int )
local
int w, h
string name
endlocal
if StartPosObj then
DeleteObject StartPosObj
endif
if StartX >= DrawOriginX and StartY >= DrawOriginY and ActionLevel = StartLevel then
gsave()
pencolor 0,255/2,0
font "timesroman.bold", unit, unit
StartPosObj = GetNextObjectID()
if relative then
text (StartX-RoomX[StartRoom])*unit+GridOriginX,(StartY-RoomY[StartRoom])*unit+GridOriginY, "S"
else
text (StartX+DrawOriginX)*unit+GridOriginX,(StartY+DrawOriginY)*unit+GridOriginY, "S"
endif
grestore()
endif
end sub
sub fast_ DeleteRoom( n as int )
//delete room number n
local
int i, id, aji
endlocal
if not ValidRoom(n) then
return
endif
id = RoomId[n]
if id then
for i = 1 to ObjectsPerRoom[RoomType[n]] + DoorsPerRoom[RoomType[n]] loop
DeleteObject id++
endfor
RoomID[n] = 0
endif
aji = RoomAdjacent[n]
for i = 1 to DoorsPerRoom[RoomType[n]] loop
adjacent[aji++] = -1
endfor
if RoomNameID[n] then
DeleteObject RoomNameID[n]
RoomNameID[n] = 0
endif
if n = StartRoom then
StartX = -1
StartY = -1
StartRoom = -1
DrawStartPos(0)
endif
RoomType[n] = 0
end sub
sub fast_ HideRoom( n as int )
//delete objects for room number n but leave roomtype
local
int i, id
endlocal
if not ValidRoom(n) then
return
endif
id = RoomId[n]
if id then
for i = 1 to ObjectsPerRoom[RoomType[n]] + DoorsPerRoom[RoomType[n]] loop
DeleteObject id++
endfor
RoomID[n] = 0
endif
if RoomNameID[n] then
DeleteObject RoomNameID[n]
RoomNameID[n] = 0
endif
end sub
sub fast_ RedrawRoom( n as int )
//delete objects for room number n and then redraw it
local
int i, id
endlocal
if RoomType[n] = 0 then
return
endif
id = RoomId[n]
if id then
for i = 1 to ObjectsPerRoom[RoomType[n]] + DoorsPerRoom[RoomType[n]] loop
DeleteObject id++
endfor
endif
if RoomNameID[n] then
DeleteObject RoomNameID[n]
endif
DrawRoom( n )
end sub
sub fast_ HideAllRooms()
local
int i
endlocal
DelayedUpdate( true)
for i = 0 to high(RoomType) loop
HideRoom(i)
end for
DelayedUpdate( false)
end sub
sub fast_ RedrawAllRooms()
local
int i
endlocal
DelayedUpdate (true)
for i = 0 to high(RoomType) loop
RedrawRoom(i)
end for
DelayedUpdate (false)
end sub
//maze load code
sub fast_ ClearMaze()
Mazename = "NewMaze"
// MazeRemoteRoot = "no remote root"
// MazeLocalCDRoot = "no local CD root"
MazeTimeLimit= "60"
MazeFilename = ""
TextureDir = "textures"
SoundDir = "sounds"
ObjectDir = "objects"
RoomFloorTexture = 0
RoomWallTexture = 0
RoomCeilingTexture = 0
LinkFloorTexture = 0
LinkWallTexture = 0
LinkCeilingTexture = 0
RedDoorTexture = -1
GreenDoorTexture = -1
BlueDoorTexture = -1
DeleteElements LevelName, high(LevelName)+1
DeleteElements NextRoomAtLevel, high(NextRoomAtLevel)+1
DeleteElements NextLinkAtLevel, high(NextLinkAtLevel)+1
DeleteElements Adjacent, high(Adjacent)+1
DeleteElements OverlapList, high(OverlapList)+1
DeleteElements roomtype, high(roomtype)+1
DeleteElements RoomNumber, high(RoomNumber)+1
DeleteElements roomid , high(roomid)+1
DeleteElements roomx , high(roomx)+1
DeleteElements roomy , high(roomy)+1
DeleteElements roomw , high(roomw)+1
DeleteElements roomd , high(roomd)+1
DeleteElements roomr , high(roomr)+1
DeleteElements roomheight , high(roomheight)+1
DeleteElements roomlevel, high(roomlevel)+1
DeleteElements roomname, high(roomname)+1
DeleteElements roomdoors, high(roomdoors)+1
DeleteElements roomadjacent,high(roomadjacent)+1
DeleteElements RoomTextureBits, high(RoomTextureBits)+1
DeleteElements roomvisited, high(roomvisited)+1
DeleteElements RoomObjectsCount, high(RoomObjectsCount)+1
DeleteElements RoomObjectsIndex, high(RoomObjectsIndex)+1
DeleteElements Room_Contents, high(Room_Contents)+1
DeleteElements Room_geometry, high(Room_geometry)+1
DeleteElements object3dList,high(object3dList)+1
DeleteElements object3dScale,high(object3dScale)+1
DeleteElements Object3dUsage, high(Object3dUsage)+1
DeleteElements ObjectsList, high(ObjectsList)+1
DeleteElements ObjectsName, high(ObjectsName)+1
DeleteElements ObjectsClump, high(ObjectsClump)+1
DeleteElements DoorClumps, high(DoorClumps)+1
DeleteElements ObjectsXYH, high(ObjectsXYH)+1
DeleteElements TextureList, high(TextureList)+1
DeleteElements TextureUsage, high(TextureUsage)+1
end sub
function LoadDoors( f as int r as int ) as int
local
int i, nd
string str
endlocal
input #f, nd
RoomDoors[r] = nd
for i = 1 to nd loop
str = input$(8,#f)
AddElement Adjacent bstrtoi(str, 16)
AddElement DoorClumps null
input$(1,#f)
endloop
return 1
end function
function LoadObjects( f as int r as int index as int version as string) as int
local
int i, x, y, h, ONumber
string name
int ocount
endlocal
input #f, ocount
RoomObjectsCount[r] = ocount
for i = 1 to ocount loop
input #f, ONumber, x, y, h
ObjectsList[index] = ONumber
ObjectsXYH[index] = XYL( x, y, h )
ObjectsClump[index] = null
index++
endloop
name = ""
return 1
end function
function LoadRoom( f as int level as int version as string) as int
local
int d, doors, x, y, l, i, t
int r=high(RoomType)+1
int max
endlocal
AddElement roomx 0
AddElement roomy 0
AddElement roomw 0
AddElement roomd 0
AddElement roomr 0
AddElement RoomHeight 0
AddElement RoomType 0
AddElement RoomID 0
AddElement RoomNameID 0
AddElement RoomDoors 0
AddElement RoomAdjacent high(Adjacent)+1
AddElement RoomObjectsCount 0
AddElement RoomObjectsIndex high(ObjectsList)+1
AddElement Room_Contents null
AddElement Room_geometry null
AddElement RoomVisited 0
AddElement RoomNumber 0
AddElement RoomName ""
AddElement RoomLevel level
AddElement RoomTextureBits 0
AddElement RoomVisited 0
input #f, RoomNumber[r]
RoomName[r] = inputline$(#f)
input #f, RoomType[r], roomx[r], roomy[r], roomw[r], roomd[r], roomr[r], RoomHeight[r]
RoomDoors[r] = DoorsPerRoom[RoomType[r]]
if RoomType[r] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
for i = 1 to max loop
AddElement ObjectsList 0
AddElement ObjectsName ""
AddElement ObjectsXYH 0
AddElement ObjectsClump null
endfor
if version >= "0.81" then
RoomTextureBits[r] = bstrtoi( inputline$(#f), 16 )
endif
LoadObjects( f, r, RoomObjectsIndex[high(RoomObjectsIndex)], version )
if version >= "0.83" then
LoadDoors( f, r )
endif
return 1
end function
function fast_ LoadMaze( fname as string, mode as int ) as boolean
local
int bl //base level of maze we are loading
boolean status=false
filename thefile, thebakfile
string lfile
int index
string VersionStr, str
int levels, rooms, links
int l, r
int OriginalLevel
int f=1
int type
float scale
string objectname
int NumberOfObjects
string spare
boolean FoundStart=false, FoundEnd=false, FoundAction=false
endlocal
goodsav = false
thefile = filename(fname)
if !checkfile( thefile, readable ) then
thefile = InstallDir + thefile
if !checkfile( thefile, readable ) then
MsgBox( "Can't load", string(thefile), OKBOX )
return false
endif
endif
lfile = tidy$( string(thefile), lower )
index = instr( lfile, ".maz", 0 )
if index >=1 then
thebakfile = filename(left$( string(thefile), index )) + `.bak`
SaveFilename = filename(left$( string(thefile), index )) + `.sav`
goodsav = true
endif
if mode = 0 then
ClearMaze()
bl = 0
else
bl = high(LevelName)+1
endif
open thefile for read as #f
print using "Loading %s\n", thefile
VersionStr = inputline$(#f)
if PlayerVersion < VersionStr then
MsgBox( "Can't load", "Your editor is out of date!", OKBOX )
return false
endif
MazeName = inputline$(#f)
print using "Loading Maze %s\n", MazeName
if VersionStr >= "0.87" then
// MazeRemoteRoot = inputline$(#f)
// MazeLocalCDRoot = inputline$(#f)
spare = inputline$(#f)
spare = inputline$(#f)
endif
if VersionStr > "0.84" then
MazeTimeLimit = inputline$(#f)
else
MazeTimeLimit = "60"
endif
input #f, ActionRoom, ActionLevel
input #f, DrawOriginX, DrawOriginY, MapUnit, RoomUnit
input #f, CheckError
DrawOriginX = 0
DrawOriginY = 0
if VersionStr < "0.84" then
input #f, StartX, StartY, StartLevel, EndX, EndY, EndLevel
else
input #f, StartX, StartY, StartLevel
endif
if VersionStr >= "0.81" then
TextureDir = inputline$(#f)
input #f, NumberOfTextures
if NumberOfTextures then
for l = 1 to NumberOfTextures loop
AddElement TextureUsage 1
if VersionStr >= "0.89" then
input #f, TextureUsage[l-1]
endif
AddElement TextureList inputline$(#f)
endfor
else
AddElement TextureList "none"
endif
input #f, RoomFloorTexture, RoomWallTexture, RoomCeilingTexture
input #f, LinkFloorTexture, LinkWallTexture, LinkCeilingTexture
if VersionStr >= "0.84" then
input #f, RedDoorTexture, GreenDoorTexture, BlueDoorTexture
else
RedDoorTexture = -1
GreenDoorTexture = -1
BlueDoorTexture = -1
endif
input #f, RoomFloorTexturing, RoomWallTexturing, RoomCeilingTexturing
else
TextureDir = inputline$(#f)
AddElement TextureList inputline$(#f)
AddElement TextureList inputline$(#f)
AddElement TextureList inputline$(#f)
AddElement TextureList inputline$(#f)
AddElement TextureList inputline$(#f)
AddElement TextureList inputline$(#f)
RoomFloorTexture = 0
RoomWallTexture = 1
RoomCeilingTexture = 2
LinkFloorTexture = 3
LinkWallTexture = 4
LinkCeilingTexture = 5
RedDoorTexture = -1
GreenDoorTexture = -1
BlueDoorTexture = -1
input #f, RoomFloorTexturing
if RoomFloorTexturing = 0 then
RoomFloorTexturing = StretchTexturesBoth
else
RoomFloorTexturing = TileTexturesBoth
endif
RoomWallTexturing = RoomFloorTexturing
RoomCeilingTexturing = RoomFloorTexturing
endif
if versionStr >= "0.88" then
SoundDir = inputline$(#f)
endif
if versionStr >= "0.80" then
input #f, SoundEffectFlags
if SoundEffectFlags & 1 then
OooffSound = inputline$(#f)
endif
if SoundEffectFlags & 2 then
BackgroundMIDI = inputline$(#f)
endif
if SoundEffectFlags & 4 then
CollectSound = inputline$(#f)
endif
if SoundEffectFlags & 8 then
FinishSound = inputline$(#f)
endif
endif
if VersionStr >= "0.77" then
ObjectDir = inputline$(#f)
input #f, NumberOfObjects
for r = 1 to NumberOfObjects loop
AddElement Object3dUsage 1
if VersionStr >= "0.89" then
input #f, Object3dUsage[r-1]
endif
input #f, scale
AddElement Object3dScale scale
Objectname = inputline$(#f)
AddElement Object3dList objectname
endloop
endif
input #f, levels
print using "Loading %d levels\n", levels
for l = bl to bl+levels-1 loop
print using "Loading level %d\n", l
AddElement LevelName ""
AddElement NextRoomAtLevel 0
AddElement NextLinkAtLevel 0
input #f, OriginalLevel
LevelName[l] = inputline$(#f)
input #f, rooms, NextRoomAtLevel[l]
input #f, links, NextLinkAtLevel[l]
for r = 0 to rooms+links-1 loop
print using "Loading room %d\n", r
LoadRoom(f, l, VersionStr)
endloop
endloop
close #f
StartRoom = FindRoomAtXYL( StartX, StartY, StartLevel, type )
for r = 0 to high(RoomNumber) loop
if RoomNumber[r] = ActionRoom then
ActionRoom = r
loopexit
endif
endfor
status = true
return status
end function
sub fast_ LoadEditorData()
local
int i
string str
int f=1
endlocal
// load list of previous maze files
str=global_select
//only add files to list if they exist
if len(str) > 0 and checkfile( InstallDir + filename(str), readable ) then
AddElement MazeFilenames str
endif
end sub
sub BuildWalls( num as int )
//find the cells adjacent to the doors of room num
local
int n = RoomType[num]
int dw1, dw2, dw3, dw4, dh1, dh2, dh3, dh4
int l = RoomLevel[num]
int w = RoomW[num], d = RoomD[num], r = RoomR[num]
int x1 = Roomx[num], y1 = RoomY[num], x2 = x1+RoomW[num]-1, y2=y1+RoomD[num]-1
int x,y
endlocal
if not ValidRoom(num) then
return
endif
if n <= NROOMS then
//build complete walls for rooms
for x = x1 to x2 loop
walls[y1][x] |= NORTH
walls[y2][x] |= SOUTH
endloop
for y = y1 to y2 loop
walls[y][x1] |= WEST
walls[y][x2] |= EAST
endloop
endif
dw1 = ((w-1)/2)
dw2 = (w-1-dw1)
dw3 = (w-3)/2
dw4 = (w-3-dw3)
dh1 = ((d-1)/2)
dh2 = (d-1-dh1)
dh3 = (d-3)/2
dh4 = (d-3-dh3)
if n = 1 then
// print using "Room type 1 (%d,%d)-(%d,%d)", x1,y1,x2,y2
if r = 0 then
walls[y1][x1] &= ~WEST
walls[y2][x2] &= ~SOUTH
elsif r = 4 then
walls[y2][x1] &= ~WEST
walls[y1][x2] &= ~NORTH
elsif r = 8 then
walls[y1][x1] &= ~NORTH
walls[y2][x2] &= ~EAST
elsif r = 12 then
walls[y2][x1] &= ~SOUTH
walls[y1][x2] &= ~EAST
endif
elsif n = 2 then
if r = 0 then
walls[y1][x2] &= ~NORTH
walls[y2][x2] &= ~SOUTH
walls[y1+dh1][x1] &= ~WEST
elsif r = 4 then
walls[y2][x1] &= ~WEST
walls[y2][x2] &= ~EAST
walls[y1][x1+dw1] &= ~NORTH
elsif r = 8 then
walls[y1][x1] &= ~NORTH
walls[y2][x1] &= ~SOUTH
walls[y1+dh1][x2] &= ~EAST
elsif r = 12 then
walls[y1][x1] &= ~WEST
walls[y1][x2] &= ~EAST
walls[y2][x1+dw1] &= ~SOUTH
endif
elsif n = 3 then
if r = 0 or r = 8 then
walls[y1][x2] &= ~NORTH
walls[y2][x1] &= ~SOUTH
walls[y1+dh1][x1] &= ~WEST
walls[y1+dh2][x2] &= ~EAST
elsif r = 4 or r = 12 then
walls[y1][x1] &= ~WEST
walls[y1][x1+dw2] &= ~NORTH
walls[y2][x2] &= ~EAST
walls[y2][x1+dw1] &= ~SOUTH
endif
elsif n = 4 then
if r = 0 or r = 8 then
walls[y1][x1] &= ~NORTH
walls[y1+dh2][x2] &= ~EAST
walls[y2][x2] &= ~SOUTH
walls[y1+dh1][x1] &= ~WEST
elsif r = 4 or r = 12 then
walls[y2][x1] &= ~WEST
walls[y1][x1+dw2] &= ~NORTH
walls[y1][x2] &= ~EAST
walls[y2][x1+dw1] &= ~SOUTH
endif
elsif n = 5 then
if r = 0 then
walls[y1][x1+dw1] &= ~NORTH
elsif r = 4 then
walls[y1+dh1][x2] &= ~EAST
elsif r = 8 then
walls[y2][x1+dw2] &= ~SOUTH
elsif r = 12 then
walls[y1+dh2][x1] &= ~WEST
endif
elsif n = 6 then
if (r % 4) = 0 then
walls[y1+dh1][x1] &= ~WEST
walls[y1][x1+dw1] &= ~NORTH
walls[y1+dh2][x2] &= ~EAST
walls[y2][x1+dw2] &= ~SOUTH
endif
elsif n = 7 then
if r = 0 then
walls[y1][x1] &= ~NORTH
walls[y1+dh1][x2] &= ~EAST
walls[y2][x1+dw4] &= ~SOUTH
walls[y2][x1+dw4+2] &= ~SOUTH
elsif r = 4 then
walls[y1+dh4][x1] &= ~WEST
walls[y1][x2] &= ~EAST
walls[y2][x1+dw2] &= ~SOUTH
walls[y1+dh4+2][x1] &= ~WEST
elsif r = 8 then
walls[y1+dh2][x1] &= ~WEST
walls[y1][x1+dw3] &= ~NORTH
walls[y1][x1+dw3+2] &= ~NORTH
walls[y2][x2] &= ~SOUTH
elsif r = 12 then
walls[y2][x1] &= ~WEST
walls[y1][x1+dw1] &= ~NORTH
walls[y1+dh3][x2] &= ~EAST
walls[y1+dh3+2][x2] &= ~EAST
endif
elsif n = NROOMS+1 then
if r = 0 then
walls[y1][x1] |= EAST|WEST
walls[y2][x1] |= SOUTH|WEST
walls[y2][x2] |= NORTH|SOUTH
elsif r = 4 then
walls[y1][x1] |= WEST|NORTH
walls[y1][x2] |= NORTH|SOUTH
walls[y2][x1] |= EAST|WEST
elsif r = 8 then
walls[y1][x1] |= NORTH|SOUTH
walls[y1][x2] |= NORTH|EAST
walls[y2][x2] |= EAST|WEST
elsif r = 12 then
walls[y2][x1] |= NORTH|SOUTH
walls[y2][x2] |= SOUTH|EAST
walls[y1][x2] |= EAST|WEST
endif
elsif n = NROOMS+2 then
if r = 0 then
walls[y1][x1] |= NORTH|SOUTH
walls[y1][x1+1] |= NORTH
walls[y1][x2] |= NORTH|SOUTH
walls[y2][x1+1] |= EAST|WEST
elsif r = 4 then
walls[y1][x2] |= EAST|WEST
walls[y1+1][x1] |= NORTH|SOUTH
walls[y1+1][x2] |= EAST
walls[y2][x2] |= EAST|WEST
elsif r = 8 then
walls[y2][x1] |= NORTH|SOUTH
walls[y1][x1+1] |= EAST|WEST
walls[y2][x1+1] |= SOUTH
walls[y2][x2] |= NORTH|SOUTH
elsif r = 12 then
walls[y1][x1] |= EAST|WEST
walls[y1+1][x1] |= WEST
walls[y1+1][x2] |= NORTH|SOUTH
walls[y2][x1] |= EAST|WEST
endif
elsif n = NROOMS+3 then
if (r % 4) = 0 then
walls[y1][x1+1] |= EAST|WEST
walls[y1+1][x1] |= NORTH|SOUTH
walls[y1+1][x2] |= NORTH|SOUTH
walls[y2][x1+1] |= EAST|WEST
endif
elsif n = NROOMS+4 then
if r = 0 or r = 8 then
for x = x1 to x2 loop
walls[y1][x] |= NORTH
walls[y2][x] |= SOUTH
endfor
elsif r = 4 or r = 12 then
for y = y1 to y2 loop
walls[y][x1] |= WEST
walls[y][x2] |= EAST
endfor
endif
endif
end sub
function fast_ BuildRoom( num as int FTexturing as int WTexturing as int CTexturing as int ) as RwClump
//build room number num
local
int n = RoomType[num]
int x = RoomX[num], y = RoomY[num], r = RoomR[num]
int w = RoomW[num]
int d = RoomD[num]
int h = RoomHeight[num]
int thisx = x, thisy = y
float x1, y1, x2, y2
int dw1, dw2, dw3, dw4, dh1, dh2, dh3, dh4
int id
RwClump clump
int temp, temp2
rwClumpHints hint = rwHS
float twf,tdf
float tww,tdw,th
float twc,tdc
endlocal
if ActionLevel != RoomLevel[num] then
return null
endif
x1 = 0
y1 = 0
if r = 0 then
x2 = x1+w-roomsep
y2 = y1+d-roomsep
elsif r = 4 then
x2 = x1+d-roomsep
y2 = y1+w-roomsep
elsif r = 8 then
x2 = x1+w-roomsep
y2 = y1+d-roomsep
elsif r = 12 then
x2 = x1+d-roomsep
y2 = y1+w-roomsep
endif
dw1 = ((w-1)/2)
dw2 = (w-1-dw1)
dw3 = (w-3)/2
dw4 = (w-3-dw3)
dh1 = ((d-1)/2)
dh2 = (d-1-dh1)
dh3 = (d-3)/2
dh4 = (d-3-dh3)
dw1*=unit dw2*=unit dw3*=unit dw4*=unit
dh1*=unit dh2*=unit dh3*=unit dh4*=unit
if r = 0 then
null
elsif r = 4 then
temp = w
w = d
d = temp
elsif r = 8 then
null
elsif r = 12 then
temp = w
w = d
d = temp
endif
if FTexturing = TileTexturesBoth then
twf = 1 tdf = 1
elseif FTexturing = StretchTexturesBoth then
twf = w tdf = d
elseif FTexturing = StretchAcrossTileDown then
twf = w tdf = 1
elseif FTexturing = StretchDownTileAcross then
twf = 1 tdf = d
elseif FTexturing = StretchAndSquareTile then
twf = min([w,d]) tdf = min([w,d])
endif
if WTexturing = TileTexturesBoth then
tww = 1 tdw = 1 th = 1
elseif WTexturing = StretchTexturesBoth then
tww = w tdw = d th = h
elseif WTexturing = StretchAcrossTileDown then
tww = w tdw = d th = 1
elseif WTexturing = StretchDownTileAcross then
tww = 1 tdw = 1 th = h
elseif WTexturing = StretchAndSquareTile then
tww = h tdw = h th = h
endif
if CTexturing = TileTexturesBoth then
twc = 1 tdc = 1
elseif CTexturing = StretchTexturesBoth then
twc = w tdc = d
elseif CTexturing = StretchAcrossTileDown then
twc = w tdc = 1
elseif CTexturing = StretchDownTileAcross then
twc = 1 tdc = d
elseif CTexturing = StretchAndSquareTile then
twc = min([w,d]) tdc = min([w,d])
endif
RwModelBegin()
if n = 1 then
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
elsif r = 4 then
RwTranslateCTM( thisx+d, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+w)
RwRotateCTM( 0,1,0,90)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //5
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwQuad( 5 6 7 8 ) //ceiling
RwVertexUV( x1, floor, y2, 0, h/th )
RwVertexUV( x2-door, floor, y2, (w-door)/tww, h/th )
RwVertexUV( x2-door, floor+door, y2, (w-door)/tww, (h-door)/th )
RwVertexUV( x2, floor+door, y2, w/tww, (h-door)/th )
RwVertexUV( x2, floor+h, y2, w/tww, 0 )
RwVertexUV( x1, floor+h, y2, 0, 0 )
RwVertexUV( x1, floor, y2, 0, h/th )
RwVertexUV( x1, floor, y1+door, (d-door)/tdw, h/th )
RwVertexUV( x1, floor+door, y1+door, (d-door)/tdw, (h-door)/th )
RwVertexUV( x1, floor+door, y1, d/tdw, (h-door)/th )
RwVertexUV( x1, floor+h, y1, d/tdw, 0 )
RwVertexUV( x1, floor+h, y2, 0, 0 )
RwVertexUV( x2, floor, y2, 0, h/th )
RwVertexUV( x2, floor, y1, w/tww, h/th )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x2, floor+h, y2, 0, 0 )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x2, floor, y1, w/tww, h/th )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwPolygon( [14, 13, 12, 11, 10, 9] )
RwQuad( 24 23 22 21 )
RwPolygon( [15,16,17,18,19,20] )
RwQuad( 25 26 27 28 )
elseif n = 2 then
if r = 0 then
temp = dh1
elsif r = 4 then
temp = dw1
elsif r = 8 then
temp = dh2
elsif r = 12 then
temp = dw1
endif
RwProtoBegin("floor")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //5
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwQuad( 1 2 3 4 ) //ceiling
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x2-door, floor, y1, (w-door)/tww, h/th )
RwVertexUV( x2-door, floor+door, y1, (w-door)/tww, (h-door)/th )
RwVertexUV( x2, floor+door, y1, w/tww, (h-door)/th )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor, y1, 0, h/th )
RwVertexUV( x2, floor, y2, d/tdw, h/th )
RwVertexUV( x2, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor+h, y2, d/tdw, 0 )
RwVertexUV( x2-door, floor, y2, door/tww, h/th )
RwVertexUV( x1, floor, y2, w/tww, h/th )
RwVertexUV( x1, floor+h, y2, w/tww, 0 )
RwVertexUV( x2, floor+h, y2, 0, 0 )
RwVertexUV( x2, floor+door, y2, 0, (h-door)/th )
RwVertexUV( x2-door, floor+door, y2, door/tww, (h-door)/th )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1, floor, y1+temp, temp/tdw, h/th )
RwVertexUV( x1, floor+door, y1+temp, temp/tdw, (h-door)/th )
RwVertexUV( x1, floor+door, y1+temp+door, (temp+door)/tdw, (h-door)/th )
RwVertexUV( x1, floor, y1+temp+door, (temp+door)/tdw, h/th )
RwVertexUV( x1, floor, y2, d/tdw, h/th )
RwVertexUV( x1, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwPolygon( [1, 2, 3, 4, 5, 6] )
RwQuad( 7 8 10 9 )
RwPolygon( [11,12,13,14,15,16] )
RwPolygon( [24,23,22,21,20,19,18,17 ] )
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
elsif r = 4 then
RwTranslateCTM( thisx+d, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+w)
RwRotateCTM( 0,1,0,+90)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elseif n = 3 then
if r = 0 then
temp = dh1
elsif r = 4 then
temp = dw1
elsif r = 8 then
temp = dh1
elsif r = 12 then
temp = dw1
endif
RwProtoBegin("floor")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //5
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwQuad( 1 2 3 4 ) //ceiling
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x2-door, floor, y1, (w-door)/tww, h/th )
RwVertexUV( x2-door, floor+door, y1, (w-door)/tww, (h-door)/th )
RwVertexUV( x2, floor+door, y1, w/tww, (h-door)/th )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor, y2, 0, h/th )
RwVertexUV( x1+door, floor, y2, (w-door)/tww, h/th )
RwVertexUV( x1+door, floor+door, y2, (w-door)/tww, (h-door)/th )
RwVertexUV( x1, floor+door, y2, w/tww, (h-door)/th )
RwVertexUV( x1, floor+h, y2, w/tww, 0 )
RwVertexUV( x2, floor+h, y2, 0, 0 )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1, floor, y1+temp, temp/tdw, h/th )
RwVertexUV( x1, floor+door, y1+temp, temp/tdw, (h-door)/th )
RwVertexUV( x1, floor+door, y1+temp+door, (temp+door)/tdw, (h-door)/th )
RwVertexUV( x1, floor, y1+temp+door, (temp+door)/tdw, h/th )
RwVertexUV( x1, floor, y2, d/tdw, h/th )
RwVertexUV( x1, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor, y2, 0, h/th )
RwVertexUV( x2, floor, y2-temp, temp/tdw, h/th )
RwVertexUV( x2, floor+door, y2-temp, temp/tdw, (h-door)/th )
RwVertexUV( x2, floor+door, y2-temp-door, (temp+door)/tdw, (h-door)/th )
RwVertexUV( x2, floor, y2-temp-door, (temp+door)/tdw, h/th )
RwVertexUV( x2, floor, y1, d/tdw, h/th )
RwVertexUV( x2, floor+h, y1, d/tdw, 0 )
RwVertexUV( x2, floor+h, y2, 0, 0 )
RwPolygon( [1,2,3,4,5,6] )
RwPolygon( [7,8,9,10,11,12] )
RwPolygon( [20,19,18,17,16,15,14,13] )
RwPolygon( [28,27,26,25,24,23,22,21] )
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
elsif r = 4 then
RwTranslateCTM( thisx+d, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+w)
RwRotateCTM( 0,1,0,+90)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elseif n = 4 then
if r = 0 then
temp = dh1
elsif r = 4 then
temp = dw1
elsif r = 8 then
temp = dh1
elsif r = 12 then
temp = dw1
endif
RwProtoBegin("floor")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //5
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwQuad( 1 2 3 4 ) //ceiling
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( x1, floor+door, y1, 0, (h-door)/th )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x2, floor, y1, w/tww, h/th )
RwVertexUV( x1+door, floor, y1, door/tww, h/th )
RwVertexUV( x1+door, floor+door, y1, door/tww, (h-door)/th )
RwVertexUV( x1, floor, y2, 0, h/th )
RwVertexUV( x2-door, floor, y2, (w-door)/tww, h/th )
RwVertexUV( x2-door, floor+door, y2, (w-door)/tww, (h-door)/th )
RwVertexUV( x2, floor+door, y2, w/tww, (h-door)/th )
RwVertexUV( x2, floor+h, y2, w/tww, 0 )
RwVertexUV( x1, floor+h, y2, 0, 0 )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1, floor, y1+temp, temp/tdw, h/th )
RwVertexUV( x1, floor+door, y1+temp, temp/tdw, (h-door)/th )
RwVertexUV( x1, floor+door, y1+temp+door, (temp+door)/tdw, (h-door)/th )
RwVertexUV( x1, floor, y1+temp+door, (temp+door)/tdw, h/th )
RwVertexUV( x1, floor, y2, d/tdw, h/th )
RwVertexUV( x1, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor, y2, 0, h/th )
RwVertexUV( x2, floor, y2-temp, temp/tdw, h/th )
RwVertexUV( x2, floor+door, y2-temp, temp/tdw, (h-door)/th )
RwVertexUV( x2, floor+door, y2-temp-door, (temp+door)/tdw, (h-door)/th )
RwVertexUV( x2, floor, y2-temp-door, (temp+door)/tdw, h/th )
RwVertexUV( x2, floor, y1, d/tdw, h/th )
RwVertexUV( x2, floor+h, y1, d/tdw, 0 )
RwVertexUV( x2, floor+h, y2, 0, 0 )
RwPolygon( [6,5,4,3,2,1] )
RwPolygon( [12,11,10,9,8,7] )
RwPolygon( [20,19,18,17,16,15,14,13] )
RwPolygon( [28,27,26,25,24,23,22,21] )
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
elsif r = 4 then
RwTranslateCTM( thisx+d, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+w)
RwRotateCTM( 0,1,0,+90)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elsif n = 5 then
if r = 0 then
temp = dw1
elsif r = 4 then
temp = dh1
elsif r = 8 then
temp = dw1
elsif r = 12 then
temp = dh1
endif
RwProtoBegin("floor")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //5
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwQuad( 1 2 3 4 ) //ceiling
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( x2, floor, y1, 0, h/th )
RwVertexUV( x2, floor, y2, d/tdw, h/th )
RwVertexUV( x2, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1, floor, y2, d/tdw, h/th )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x1, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor, y2, 0, h/th )
RwVertexUV( x2, floor, y2, w/tww, h/th )
RwVertexUV( x1, floor+h, y2, 0, 0 )
RwVertexUV( x2, floor+h, y2, w/tww, 0 )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1+temp, floor, y1, temp/tww, h/th )
RwVertexUV( x1+temp, floor+door, y1, temp/tww, (h-door)/th )
RwVertexUV( x1+temp+door, floor+door, y1, (temp+door)/tww, (h-door)/th )
RwVertexUV( x1+temp+door, floor, y1, (temp+door)/tww, h/th )
RwVertexUV( x2, floor, y1, w/tww, h/th )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwQuad( 1 2 4 3)
RwQuad( 5 7 8 6)
RwQuad( 9 11 12 10)
RwPolygon( [13,14,15,16,17,18,19,20 ] )
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
elsif r = 4 then
RwTranslateCTM( thisx+d, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+w)
RwRotateCTM( 0,1,0,+90)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elsif n = 6 then
temp = dw1
temp2 = dh2
RwProtoBegin("floor")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //5
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwQuad( 1 2 3 4 ) //ceiling
RwProtoEnd()
RwProtoBegin( "walls")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1+temp, floor, y1, temp/tww, h/th )
RwVertexUV( x1+temp, floor+door, y1, temp/tww, (h-door)/th )
RwVertexUV( x1+temp+door, floor+door, y1, (temp+door)/tww, (h-door)/th )
RwVertexUV( x1+temp+door, floor, y1, (temp+door)/tww, h/th )
RwVertexUV( x2, floor, y1, w/tww, h/th )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x1, floor, y2, 0, h/th )
RwVertexUV( x2-temp-door, floor, y2, (w-temp-door)/tww, h/th )
RwVertexUV( x2-temp-door, floor+door, y2, (w-temp-door)/tww, (h-door)/th )
RwVertexUV( x2-temp, floor+door, y2, (w-temp)/tww, (h-door)/th )
RwVertexUV( x2-temp, floor, y2, (w-temp)/tww, h/th )
RwVertexUV( x2, floor, y2, w/tww, h/th )
RwVertexUV( x2, floor+h, y2, w/tww, 0 )
RwVertexUV( x1, floor+h, y2, 0, 0 )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1, floor, y2-temp2-door, (d-temp2-door)/tdw, h/th )
RwVertexUV( x1, floor+door, y2-temp2-door, (d-temp2-door)/tdw, (h-door)/th )
RwVertexUV( x1, floor+door, y2-temp2, (d-temp2)/tdw, (h-door)/th )
RwVertexUV( x1, floor, y2-temp2, (d-temp2)/tdw, h/th )
RwVertexUV( x1, floor, y2, d/tdw, h/th )
RwVertexUV( x1, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor, y1, 0, h/th )
RwVertexUV( x2, floor, y1+temp2, temp2/tdw, h/th )
RwVertexUV( x2, floor+door, y1+temp2, temp2/tdw, (h-door)/th )
RwVertexUV( x2, floor+door, y1+temp2+door, (temp2+door)/tdw, (h-door)/th )
RwVertexUV( x2, floor, y1+temp2+door, (temp2+door)/tdw, h/th )
RwVertexUV( x2, floor, y2, d/tdw, h/th )
RwVertexUV( x2, floor+h, y2, d/tdw, 0 )
RwVertexUV( x2, floor+h, y1, 0, 0 )
RwPolygon( [ 1,2,3,4,5,6,7,8] )
RwPolygon( [ 16,15,14,13,12,11,10,9] )
RwPolygon( [ 24,23,22,21,20,19,18,17] )
RwPolygon( [ 25,26,27,28,29,30,31,32] )
RwProtoEnd()
RwIdentityCTM()
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elsif n = 7 then
if r = 0 then
temp = dh1
temp2 = dw3
elsif r = 4 then
temp = dw1
temp2 = dh3
elsif r = 8 then
temp = dh1
temp2 = dw3
elsif r = 12 then
temp = dw1
temp2 = dh3
endif
RwProtoBegin("floor")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//floor points
RwVertexUV( x1,floor, y1, 0, 0 ) //1
RwVertexUV( x2,floor, y1, w/twf, 0 )
RwVertexUV( x2,floor, y2, w/twf, d/tdf )
RwVertexUV( x1,floor, y2, 0, d/tdf )
RwQuad( 4 3 2 1 ) //floor
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
//ceiling points
RwVertexUV( x1,floor+h,y1, 0, 0 ) //1
RwVertexUV( x2,floor+h,y1, w/twc, 0 )
RwVertexUV( x2,floor+h,y2, w/twc, d/tdc )
RwVertexUV( x1,floor+h,y2, 0, d/tdc )
RwQuad( 1 2 3 4 ) //ceiling
RwProtoEnd()
RwProtoBegin( "walls")
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( x1, floor+door, y1, 0, (h-door)/th )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor+h, y1, w/tww, 0 )
RwVertexUV( x2, floor, y1, w/tww, h/th )
RwVertexUV( x1+door, floor, y1, door/tww, h/th )
RwVertexUV( x1+door, floor+door, y1, door/tww, (h-door)/th )
RwVertexUV( x1, floor, y1, 0, h/th )
RwVertexUV( x1, floor, y2, d/tdw, h/th )
RwVertexUV( x1, floor+h, y2, d/tdw, 0 )
RwVertexUV( x1, floor+h, y1, 0, 0 )
RwVertexUV( x2, floor, y2, 0, h/th )
RwVertexUV( x2, floor, y1+temp+door, (d-temp-door)/tdw, h/th )
RwVertexUV( x2, floor+door, y1+temp+door, (d-temp-door)/tdw, (h-door)/th )
RwVertexUV( x2, floor+door, y1+temp, (d-temp)/tdw, (h-door)/th )
RwVertexUV( x2, floor, y1+temp, (d-temp)/tdw, h/th )
RwVertexUV( x2, floor, y1, d/tdw, h/th )
RwVertexUV( x2, floor+h, y1, d/tdw, 0 )
RwVertexUV( x2, floor+h, y2, 0, 0 )
RwVertexUV( x1, floor, y2, 0, h/th )
RwVertexUV( x1, floor+h, y2, 0, 0 )
RwVertexUV( x2, floor+h, y2, w/tww, 0 )
RwVertexUV( x2, floor, y2, w/tww, h/th)
RwVertexUV( x2-temp2, floor, y2, (w-temp2)/tww , h/th )
RwVertexUV( x2-temp2, floor+door, y2, (w-temp2)/tww , (h-door)/th )
RwVertexUV( x2-temp2-door, floor+door, y2, (w-temp2-door)/tww , (h-door)/th )
RwVertexUV( x2-temp2-door, floor, y2, (w-temp2-door)/tww , h/th )
RwVertexUV( x2-temp2-2*door, floor, y2, (w-temp2-2*door)/tww , h/th )
RwVertexUV( x2-temp2-2*door, floor+door, y2, (w-temp2-2*door)/tww , (h-door)/th )
RwVertexUV( x2-temp2-3*door, floor+door, y2, (w-temp2-3*door)/tww , (h-door)/th )
RwVertexUV( x2-temp2-3*door, floor, y2, (w-temp2-3*door)/tww , h/th )
RwPolygon( [6,5,4,3,2,1] )
RwPolygon( [10,9,8,7] )
RwPolygon( [18,17,16,15,14,13,12,11] )
RwPolygon( [19,20,21,22,23,24,25,26,27,28,29,30] )
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0 )
elsif r = 4 then
RwTranslateCTM( thisx+d, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+w)
RwRotateCTM( 0,1,0,+90)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elsif n = NROOMS+1 then
//corner
RwProtoBegin("floor1")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor,y2-1,1,0 )
RwVertexUV( x2-1,floor,y2-1,1,1 )
RwVertexUV( x1, floor,y2, 0,0 )
RwVertexUV( x2-1,floor,y2, 0,1 )
RwPolygon( [1,3,4,2] )
RwVertexUV( x2-1,floor,y1, 0,0 )
RwVertexUV( x2, floor,y1, 1,0 )
RwVertexUV( x2-1,floor,y2-1,0,1 )
RwVertexUV( x2, floor,y2-1,1,1 )
RwPolygon( [5,7,8,6] )
RwProtoEnd()
RwProtoBegin("floor2")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor,y1, 0,0 )
RwVertexUV( x2-1,floor,y1, 1,0 )
RwVertexUV( x1, floor,y2-1,0,1 )
RwVertexUV( x2-1,floor,y2-1,1,1 )
RwPolygon( [1,3,4,2] )
RwProtoEnd()
RwProtoBegin("ceiling1")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor+h,y2-1,1,0 )
RwVertexUV( x2-1,floor+h,y2-1,1,1 )
RwVertexUV( x1, floor+h,y2, 0,0 )
RwVertexUV( x2-1,floor+h,y2, 0,1 )
RwPolygon( [2,4,3,1] )
RwVertexUV( x2-1,floor+h,y1, 0,0 )
RwVertexUV( x2, floor+h,y1, 1,0 )
RwVertexUV( x2-1,floor+h,y2-1,0,1 )
RwVertexUV( x2, floor+h,y2-1,1,1 )
RwPolygon( [6,8,7,5] )
RwProtoEnd()
RwProtoBegin("ceiling2")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor+h,y1, 0,0 )
RwVertexUV( x2-1,floor+h,y1, 1,0 )
RwVertexUV( x1, floor+h,y2-1,0,1 )
RwVertexUV( x2-1,floor+h,y2-1,1,1 )
RwPolygon( [2,4,3,1] )
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor,y2, d,h )//1
RwVertexUV( x1, floor,y1, 0,h )
RwVertexUV( x2, floor,y1, w,h )
RwVertexUV( x2-1,floor,y2, 1,h )
RwVertexUV( x2-1,floor,y2-1,0,h )
RwVertexUV( x2, floor,y2-1,1,h )
RwVertexUV( x1, floor+h,y2, d,0 )//1
RwVertexUV( x1, floor+h,y1, 0,0 )
RwVertexUV( x2, floor+h,y1, w,0 )
RwVertexUV( x2-1,floor+h,y2, 1,0 )
RwVertexUV( x2-1,floor+h,y2-1,0,0 )
RwVertexUV( x2, floor+h,y2-1,1,0 )
RwQuad( 1 2 8 7 )
RwQuad( 2 3 9 8 )
RwQuad( 6 5 11 12)
RwQuad( 5 4 10 11)
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy+d)
RwRotateCTM( 0,1,0,90 )
elsif r = 4 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0)
elsif r = 8 then
RwTranslateCTM( thisx+w, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 12 then
RwTranslateCTM( thisx+w, 0, thisy+d)
RwRotateCTM( 0,1,0,180)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor1" )
RwProtoInstance( "floor2" )
RwProtoInstance( "ceiling1" )
RwProtoInstance( "ceiling2" )
RwProtoInstance( "walls" )
elsif n = NROOMS+2 then
// T junction
RwProtoBegin("walls")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor, y1, 0, h) //1
RwVertexUV( x2, floor, y1, w, h)
RwVertexUV( x1, floor, y1+door, 0, h)
RwVertexUV( x1+1, floor, y1+door, 1, h)
RwVertexUV( x1+1, floor, y2, 0, h)
RwVertexUV( x2-1, floor, y2, w-1, h)
RwVertexUV( x2-1, floor, y1+door, 0, h)
RwVertexUV( x2, floor, y1+door, w, h)
RwVertexUV( x1, floor+h, y1, 0, 0) //9
RwVertexUV( x2, floor+h, y1, w, 0)
RwVertexUV( x1, floor+h, y1+door, 0, 0)
RwVertexUV( x1+1, floor+h, y1+door, 1, 0)
RwVertexUV( x1+1, floor+h, y2, 0, 0)
RwVertexUV( x2-1, floor+h, y2, w-1, 0)
RwVertexUV( x2-1, floor+h, y1+door, 0, 0)
RwVertexUV( x2, floor+h, y1+door, w, 0)
RwQuad( 1 2 10 9 )
RwQuad( 4 3 11 12 )
RwQuad( 5 4 12 13 )
RwQuad( 7 6 14 15 )
RwQuad( 8 7 15 16 )
RwProtoEnd()
RwProtoBegin("floor1")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor, y1, 0, 0) //1
RwVertexUV( x1+1, floor, y1, 1, 0)
RwVertexUV( x1, floor, y1+door, 0, 1)
RwVertexUV( x1+1, floor, y1+door, 1, 1)
RwVertexUV( x2-1, floor, y1, 0, 0)
RwVertexUV( x2, floor, y1, 1, 0)
RwVertexUV( x2-1, floor, y1+door, 0, 1)
RwVertexUV( x2, floor, y1+door, 1, 1)
RwVertexUV( x1+1, floor, y1+door, 1, 0)
RwVertexUV( x1+1, floor, y2, 0, 0)
RwVertexUV( x2-1, floor, y2, 0, 1)
RwVertexUV( x2-1, floor, y1+door, 1, 1)
RwQuad( 1 3 4 2 )
RwQuad( 5 7 8 6 )
RwQuad( 9 10 11 12 )
RwProtoEnd()
RwProtoBegin("floor2")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1+1, floor, y1, 0, 0)
RwVertexUV( x2-1, floor, y1, 1, 0) //1
RwVertexUV( x2-1, floor, y1+door, 1, 1)
RwVertexUV( x1+1, floor, y1+door, 0, 1)
RwQuad( 4 3 2 1 )
RwProtoEnd()
RwProtoBegin("ceiling1")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor+h, y1, 0, 0) //1
RwVertexUV( x1+1, floor+h, y1, 1, 0)
RwVertexUV( x1, floor+h, y1+door, 0, 1)
RwVertexUV( x1+1, floor+h, y1+door, 1, 1)
RwVertexUV( x2-1, floor+h, y1, 0, 0)
RwVertexUV( x2, floor+h, y1, 1, 0)
RwVertexUV( x2-1, floor+h, y1+door, 0, 1)
RwVertexUV( x2, floor+h, y1+door, 1, 1)
RwVertexUV( x1+1, floor+h, y1+door, 1, 0)
RwVertexUV( x1+1, floor+h, y2, 0, 0)
RwVertexUV( x2-1, floor+h, y2, 0, 1)
RwVertexUV( x2-1, floor+h, y1+door, 1, 1)
RwQuad( 2 4 3 1 )
RwQuad( 6 8 7 5 )
RwQuad( 12 11 10 9 )
RwProtoEnd()
RwProtoBegin("ceiling2")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1+1, floor+h, y1, 0, 0)
RwVertexUV( x2-1, floor+h, y1, 1, 0) //1
RwVertexUV( x2-1, floor+h, y1+door, 1, 1)
RwVertexUV( x1+1, floor+h, y1+door, 0, 1)
RwQuad( 1 2 3 4 )
RwProtoEnd()
RwIdentityCTM()
if r = 0 then
RwTranslateCTM( thisx, 0, thisy)
RwRotateCTM( 0,1,0,0)
elsif r = 4 then
RwTranslateCTM( thisx+2, 0, thisy)
RwRotateCTM( 0,1,0,-90)
elsif r = 8 then
RwTranslateCTM( thisx+3, 0, thisy+2)
RwRotateCTM( 0,1,0,180)
elsif r = 12 then
RwTranslateCTM( thisx, 0, thisy+3)
RwRotateCTM( 0,1,0,90 )
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( rwHS )
RwProtoInstance( "floor1" )
RwProtoInstance( "floor2" )
RwProtoInstance( "walls" )
RwProtoInstance( "ceiling1" )
RwProtoInstance( "ceiling2" )
elsif n = NROOMS+3 then
if r = 0 or r = 4 or r = 8 or r = 12 then
// cross junction
RwProtoBegin("walls")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor, y1+door, 0, h)
RwVertexUV( x1+door, floor, y1+door, 1, h)
RwVertexUV( x1+door, floor, y1, 0, h)
RwVertexUV( x2-door, floor, y1, 0, h)
RwVertexUV( x2-door, floor, y1+door, 1, h)
RwVertexUV( x2, floor, y1+door, 0, h)
RwVertexUV( x1, floor, y2-door, 0, h) //7
RwVertexUV( x1+door, floor, y2-door, 1, h)
RwVertexUV( x1+door, floor, y2, 0, h)
RwVertexUV( x2-door, floor, y2, 0, h)
RwVertexUV( x2-door, floor, y2-door, 1, h)
RwVertexUV( x2, floor, y2-door, 0, h)
RwVertexUV( x1, floor+h, y1+door, 0, 0) //13
RwVertexUV( x1+door, floor+h, y1+door, 1, 0)
RwVertexUV( x1+door, floor+h, y1, 0, 0)
RwVertexUV( x2-door, floor+h, y1, 0, 0)
RwVertexUV( x2-door, floor+h, y1+door, 1, 0)
RwVertexUV( x2, floor+h, y1+door, 0, 0)
RwVertexUV( x1, floor+h, y2-door, 0, 0) //19
RwVertexUV( x1+door, floor+h, y2-door, 1, 0)
RwVertexUV( x1+door, floor+h, y2, 0, 0)
RwVertexUV( x2-door, floor+h, y2, 0, 0)
RwVertexUV( x2-door, floor+h, y2-door, 1, 0)
RwVertexUV( x2, floor+h, y2-door, 0, 0)
RwQuad( 1 2 14 13 )
RwQuad( 2 3 15 14 )
RwQuad( 4 5 17 16 )
RwQuad( 5 6 18 17 )
RwQuad( 8 7 19 20 )
RwQuad( 9 8 20 21 )
RwQuad( 11 10 22 23)
RwQuad( 12 11 23 24)
RwProtoEnd()
RwProtoBegin("floor1")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1+door, floor, y1+door, 0, 0)
RwVertexUV( x2-door, floor, y1+door, 0, 1)
RwVertexUV( x2-door, floor, y1, 1, 1)
RwVertexUV( x1+door, floor, y1, 1, 0)
RwVertexUV( x1+door, floor, y2, 0, 0)
RwVertexUV( x2-door, floor, y2, 0, 1)
RwVertexUV( x2-door, floor, y2-door, 1, 1)
RwVertexUV( x1+door, floor, y2-door, 1, 0)
RwQuad( 1 2 3 4 )
RwQuad( 5 6 7 8 )
RwVertexUV( x1, floor, y1+door, 0, 0 )
RwVertexUV( x1, floor, y2-door, 0, 1 )
RwVertexUV( x1+door, floor, y2-door, 1, 1 )
RwVertexUV( x1+door, floor, y1+door, 1, 0 )
RwVertexUV( x2, floor, y1+door, 0, 0 )
RwVertexUV( x2, floor, y2-door, 0, 1 )
RwVertexUV( x2-door, floor, y2-door, 1, 1 )
RwVertexUV( x2-door, floor, y1+door, 1, 0 )
RwQuad( 9 10 11 12 )
RwQuad( 16 15 14 13 )
RwProtoEnd()
RwProtoBegin("floor2")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1+door, floor, y1+door, 0, 0)
RwVertexUV( x1+door, floor, y2-door, 0, 1)
RwVertexUV( x2-door, floor, y2-door, 1, 1)
RwVertexUV( x2-door, floor, y1+door, 1, 0)
RwQuad( 1 2 3 4 )
RwProtoEnd()
RwProtoBegin("ceiling1")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1+door, floor+h, y1+door, 0, 0)
RwVertexUV( x2-door, floor+h, y1+door, 0, 1)
RwVertexUV( x2-door, floor+h, y1, 1, 1)
RwVertexUV( x1+door, floor+h, y1, 1, 0)
RwVertexUV( x1+door, floor+h, y2, 0, 0)
RwVertexUV( x2-door, floor+h, y2, 0, 1)
RwVertexUV( x2-door, floor+h, y2-door, 1, 1)
RwVertexUV( x1+door, floor+h, y2-door, 1, 0)
RwQuad( 4 3 2 1 )
RwQuad( 8 7 6 5 )
RwVertexUV( x1, floor+h, y1+door, 0, 0 )
RwVertexUV( x1, floor+h, y2-door, 0, 1 )
RwVertexUV( x1+door, floor+h, y2-door, 1, 1 )
RwVertexUV( x1+door, floor+h, y1+door, 1, 0 )
RwVertexUV( x2, floor+h, y1+door, 0, 0 )
RwVertexUV( x2, floor+h, y2-door, 0, 1 )
RwVertexUV( x2-door, floor+h, y2-door, 1, 1 )
RwVertexUV( x2-door, floor+h, y1+door, 1, 0 )
RwQuad( 12 11 10 9 )
RwQuad( 13 14 15 16 )
RwProtoEnd()
RwProtoBegin("ceiling2")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1+door, floor+h, y1+door, 0, 0)
RwVertexUV( x1+door, floor+h, y2-door, 0, 1)
RwVertexUV( x2-door, floor+h, y2-door, 1, 1)
RwVertexUV( x2-door, floor+h, y1+door, 1, 0)
RwQuad( 4 3 2 1 )
RwProtoEnd()
RwIdentityCTM()
if (r %4) = 0 then
RwTranslateCTM( thisx, 0, thisy)
else
print "Illegal rotate code room %d %d ", n, r
endif
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor1" )
RwProtoInstance( "floor2" )
RwProtoInstance( "walls" )
RwProtoInstance( "ceiling1" )
RwProtoInstance( "ceiling2" )
endif
elsif n = NROOMS+4 then
//straight corridor
if r = 0 or r = 8 then
RwProtoBegin("floor")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor,y1,0,0 )
RwVertexUV( x2, floor,y1,w,0 )
RwVertexUV( x1, floor,y2,0,d )
RwVertexUV( x2, floor,y2,w,d )
RwPolygon( [1,3,4,2] )
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor+h,y1,0,0 )
RwVertexUV( x2, floor+h,y1,w,0 )
RwVertexUV( x1, floor+h,y2,0,d )
RwVertexUV( x2, floor+h,y2,w,d )
RwPolygon( [1,2,4,3] )
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor, y1,0,h )//1
RwVertexUV( x2, floor, y1,w,h )
RwVertexUV( x1, floor+h,y1,0,0 )
RwVertexUV( x2, floor+h,y1,w,0 )
RwVertexUV( x1, floor, y2,0,h )//1
RwVertexUV( x2, floor, y2,w,h )
RwVertexUV( x1, floor+h,y2,0,0 )
RwVertexUV( x2, floor+h,y2,w,0 )
RwQuad( 1 2 4 3 )
RwQuad( 6 5 7 8 )
RwProtoEnd()
RwIdentityCTM()
RwTranslateCTM( thisx, 0, thisy)
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
elsif r = 4 or r = 12 then
//swap these back
temp = d
d = w
w = temp
x2 = x1+w-roomsep
y2 = y1+d-roomsep
RwProtoBegin("floor")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomFloorTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor,y1,d,0 )
RwVertexUV( x2, floor,y1,d,w )
RwVertexUV( x1, floor,y2,0,0 )
RwVertexUV( x2, floor,y2,0,w )
RwPolygon( [1,3,4,2] )
RwProtoEnd()
RwProtoBegin("ceiling")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomCeilingTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor+h,y1,d,0 )
RwVertexUV( x2, floor+h,y1,d,w )
RwVertexUV( x1, floor+h,y2,0,0 )
RwVertexUV( x2, floor+h,y2,0,w )
RwPolygon( [1,2,4,3] )
RwProtoEnd()
RwProtoBegin("walls")
RwSetSurface( 0.05, 0.65, 0.0)
RwSetSurfaceColor( 0.8, 0.5, 0.0 )
RwSetSurfaceTexture( TextureList[ThisRoomWallTexture] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwSetSurfaceLightSampling( rwVERTEX )
RwVertexUV( x1, floor, y1,0,h )//1
RwVertexUV( x1, floor, y2,d,h )
RwVertexUV( x1, floor+h,y1,0,0 )
RwVertexUV( x1, floor+h,y2,d,0 )
RwVertexUV( x2, floor, y1,0,h )//1
RwVertexUV( x2, floor, y2,d,h )
RwVertexUV( x2, floor+h,y1,0,0 )
RwVertexUV( x2, floor+h,y2,d,0 )
RwQuad( 1 3 4 2)
RwQuad( 5 6 8 7 )
RwProtoEnd()
RwIdentityCTM()
RwTranslateCTM( thisx, 0, thisy)
RwClumpBegin()
RwSetHints( hint )
RwProtoInstance( "floor" )
RwProtoInstance( "ceiling" )
RwProtoInstance( "walls" )
endif
endif
clump = RwRootClumpEnd( clump )
RwModelEnd()
return clump
end function
boolean TimerActive, destroyed
sub printmat( name as string, mat as RwMatrix4d )
local
int i
RwReal elem[4][4]
endlocal
RwGetMatrixElements( mat, elem )
print name, "\n"
for i = 0 to 3 loop
print using "(%s, %s, %s, %s)\n", ftostr( elem[i][0], "%f" ), ftostr( elem[i][1], "%f" ), ftostr( elem[i][2], "%f" ), ftostr( elem[i][3], "%f" )
endloop
endsub
function RANDOM_REAL (lmin as RwReal, lmax as RwReal ) as RwReal
return lmin + (float(RwRandom()&%x7fff) * 1.0/32768.0) * (lmax - lmin)
endfunction
function RANDOM_INT(lmin as int, lmax as int) as int
return (lmin + (16383 + (RwRandom() & %x7fff) * (lmax - lmin))) >> 15
endfunction
var
dfile as int=1
const
/* Default size of the viewer's window. */
DEFAULT_WINDOW_WIDTH as int=419//322
DEFAULT_WINDOW_HEIGHT as int=372//246
/* Maximum size of the viewer's window. */
MAXIMUM_WINDOW_WIDTH as int=419//640
MAXIMUM_WINDOW_HEIGHT as int=372//480
/* What kind of action to take on mouse events. */
int MMNoAction=0, MMPanAndZoomCamera =1, MMTiltCamera =2, MMRotateClump=3, MMMoveClump=4
var
boolean ThreeDInitialized
boolean Shrink
boolean Fast=false
int VScale = SlowScale
boolean MapOn= false
/* Global RenderWare object pointers. */
RwScene *Scene, *AdjacentRenderScene
RwCamera *Camera
RwLight *RoomLight1, *RoomLight2
RwClump *DragClump
RwClump *RedDoorClump, *GreenDoorClump, *BlueDoorClump
fforward as RwReal
pan as RwReal
MouseMoveMode as int = MMNoAction;
var
FirstX as int
FirstY as int
SX as int
SY as int
LastX as int
LastY as int
sub SetViewport( vscale as int )
local
int w, h
endlocal
WinGetClientRect w, h;
RwSetCameraViewport(Camera, 0, 0, w/vscale, h/vscale );
RwSetCameraBackdropViewportRect(Camera, 0, 0, w/vscale, h/vscale );
endsub
sub fast_ ClearMap( )
local
int x, y
endlocal
for x = 0 to maxx-1 loop
for y = 0 to maxy-1 loop
bigarray[y][x] = -1
walls[y][x] = 0
endfor
endfor
end sub
sub fast_ MakeMap( level as int )
local
int r, x, y
endlocal
for r = 0 to high(RoomType) loop
if RoomLevel[r] = level then
for x = roomx[r] to roomx[r]+roomw[r]-1 loop
for y = roomy[r] to roomy[r]+roomd[r]-1 loop
// bigarray[99-y][x] = r
bigarray[y][x] = r
endfor
endfor
endif
end for
end sub
function SetPolygonColour( poly as RwPolygon3d r as int g as int b as int ) as RwPolygon3d
RwSetPolygonColor( poly, r, g, b )
return poly
end function
function fast_ BuildRoomScene( r as int ) as RwScene
local
RwConvertOptions opts = optPROTOTYPE|optCOMMENTS|optCENTRE|optCOMBINE
int rx1 = RoomX[r], ry1 = RoomY[r], rx2 = rx1+RoomW[r], ry2 = ry1+RoomD[r]
int i, index=RoomObjectsIndex[r]
int aji = RoomAdjacent[r]
int onum, dt
int dx, dy, h
RwClump *clump
RwScene *scene
RwClump *DoorClump
float scale
endlocal
Set3dsConvertOptions opts|optNORMALIZE, optTEXTUREEXT|optTEXTURE|optFORESHORTEN, optHS, 1.0, 1.0, 0.3, 0.59, 0.11, 0.5
scene = RwCreateScene()
for i = 0 to RoomObjectsCount[r]-1 loop
onum = ObjectsList[index+i]
fromXYL( ObjectsXYH[index+i], dx, dy, h )
clump = null
if onum < 0 then
//stock object
clump = RwCreateSprite( RwGetNamedTexture("stock" + itostr(-onum-1) ) )
scale = 0.25
elseif onum > 0 and onum <= high(Object3dList)+1 then
clump = Rw3dsReadShape(InstallDir + filename(ObjectDir) + `/` + filename(Object3dList[onum-1]) +`.3ds`)
scale = Object3dScale[onum-1]
endif
RwScaleMatrix( RwScratchMatrix(), scale, scale, scale, rwREPLACE)
RwTranslateMatrix( RwScratchMatrix(), RoomX[r]+dx+0.5, floor+h+OBJECTHEIGHT+scale/2, RoomY[r]+dy+0.5, rwPOSTCONCAT )
if clump != null then
if onum > 0 then
RwSetClumpTag(clump, 2)
endif
ObjectsClump[index+i] = clump
RwTransformClump( clump, RwScratchMatrix(), rwREPLACE )
RwAddClumpToScene( scene, clump )
endif
endfor
for i = 0 to RoomDoors[r]-1 loop
dt = Adjacent[aji+i] & %xff000000
dt>>=24
if dt then
fromXYL( Adjacent[aji+i], dx, dy, h )
//get colour and change code to match ***KEY+1
if dt = 1 then
dt = 3
DoorClump = RedDoorClump
elseif dt = 2 then
dt = 1
DoorClump = GreenDoorClump
elseif dt = 3 then
dt = 2
DoorClump = BlueDoorClump
endif
clump = RwDuplicateClump( DoorClump )
if clump != null then
DoorClumps[aji+i] = clump
endif
RwIdentityMatrix( RwScratchMatrix() )
if dx = rx1-1 then
//left wall door
RwRotateMatrix( RwScratchMatrix(), 0,1,0, 90, rwPOSTCONCAT)
RwTranslateMatrix( RwScratchMatrix(), rx1, floor, dy+1, rwPOSTCONCAT )
walls[dy][rx1] |= (dt<<13)
walls[dy][rx1-1] |= (dt<<7)
AddElement DoorControlCell (dy*256+rx1)*4+dt-1
AddElement DoorControlCell (dy*256+(rx1-1))*4+dt-1
AddElement DoorControlClump clump
AddElement DoorControlClump clump
elseif dx = rx2 then
//right wall door
RwRotateMatrix( RwScratchMatrix(), 0,1,0, -90, rwPOSTCONCAT)
RwTranslateMatrix( RwScratchMatrix(), rx2, floor, dy, rwPOSTCONCAT )
walls[dy][rx2-1] |= (dt<<7)
walls[dy][rx2] |= (dt<<13)
AddElement DoorControlCell (dy*256+rx2)*4+dt-1
AddElement DoorControlCell (dy*256+(rx2-1))*4+dt-1
AddElement DoorControlClump clump
AddElement DoorControlClump clump
elseif dy = ry1-1 then
//top wall door
RwTranslateMatrix( RwScratchMatrix(), dx, floor, ry1, rwPOSTCONCAT )
walls[ry1][dx] |= (dt<<4)
walls[ry1-1][dx] |= (dt<<10)
AddElement DoorControlCell (ry1*256+dx)*4+dt-1
AddElement DoorControlCell ((ry1-1)*256+dx)*4+dt-1
AddElement DoorControlClump clump
AddElement DoorControlClump clump
elseif dy = ry2 then
//bottom wall door
RwRotateMatrix( RwScratchMatrix(), 0,1,0, 180, rwPOSTCONCAT)
RwTranslateMatrix( RwScratchMatrix(), dx+1, floor, ry2, rwPOSTCONCAT )
walls[ry2-1][dx] |= (dt<<10)
walls[ry2][dx] |= (dt<<4)
AddElement DoorControlCell ((ry2-1)*256+dx)*4+dt-1
AddElement DoorControlCell (ry2*256+dx)*4+dt-1
AddElement DoorControlClump clump
AddElement DoorControlClump clump
endif
if clump <> null then
RwTransformClump( clump, RwScratchMatrix(), rwREPLACE )
endif
endif
endfor
return scene
end function
sub fast_ BuildRooms( level as int )
local
int x, y, r, type
RwClump clump
int w, f, c, tf, tw, tc, index
endlocal
for r = 0 to high(RoomType) loop
if RoomLevel[r] = level then
AddElement RoomsAtThisLevel r
type = RoomType[r]
BuildWalls( r )
index = RoomTextureBits[r]
tc = index & 7
index>>=3
tw = index & 7
index>>=3
tf = index & 7
index>>=3
c = index & 127
index>>=7
w = index & 127
index>>=7
f = index & 127
if tf = 0 then
tf = RoomFloorTexturing
endif
if tw = 0 then
tw = RoomWallTexturing
endif
if tc = 0 then
tc = RoomCeilingTexturing
endif
// print using "tf=%d tw=%d tc=%d\n" , tf, tw, tc
if w = 0 then
if type <= NROOMS then
ThisRoomWallTexture = RoomWallTexture
else
ThisRoomWallTexture = LinkWallTexture
endif
else
ThisRoomWallTexture = w-1
endif
if f = 0 then
if type <= NROOMS then
ThisRoomFloorTexture = RoomFloorTexture
else
ThisRoomFloorTexture = LinkFloorTexture
endif
else
ThisRoomFloorTexture = f-1
endif
if c = 0 then
if type <= NROOMS then
ThisRoomCeilingTexture = RoomCeilingTexture
else
ThisRoomCeilingTexture = LinkCeilingTexture
endif
else
ThisRoomCeilingTexture = c-1
endif
clump = BuildRoom( r, tf, tw, tc )
room_geometry[r] = clump
room_contents[r] = BuildRoomScene( r )
if clump = null then
print "Room ", r, " failed\n"
else
if RoomType[r] > NROOMS then
RwAddClumpToScene( room_contents[r], clump )
endif
endif
endif
end for
end sub
function CreateDoorClump( type as int ) as RwClump
local
RwClump clump
float r=0,g=0,b=0
int texi
endlocal
if type = 0 then
r=1
texi = RedDoorTexture
elseif type = 1 then
g=1
texi = GreenDoorTexture
else
b=1
texi = BlueDoorTexture
endif
RwModelBegin()
RwClumpBegin()
RwSetSurface( 0.75, 0.65, 0.0)
RwSetSurfaceColor( r, g, b )
RwSetSurfaceMaterialModes( rwDOUBLE )
if texi <> -1 then
RwSetSurfaceTexture( TextureList[texi] )
RwSetSurfaceTextureModes( rwFORESHORTEN )
RwVertexUV( 0 0 0, 0 1 )
RwVertexUV( 1 0 0, 1 1 )
RwVertexUV( 1 1 0, 1 0 )
RwVertexUV( 0 1 0, 0 0 )
else
RwVertex( 0 0 0 )
RwVertex( 1 0 0 )
RwVertex( 1 1 0 )
RwVertex( 0 1 0 )
endif
RwQuad( 1 2 3 4 )
clump = RwRootClumpEnd( clump )
RwModelEnd()
return clump
end function
sub fast_ MakeObjectSpritesDragable( flag as boolean )
local
int id
SpriteFlagBits flags
endlocal
if flag then
flags = enabled|visible|dragable
else
flags = enabled|visible
endif
for id = GreenKeyItem to MapItem loop
if ItemsList[id] then
SetSpriteFlags id, flags, unbound
endif
end loop
end sub
sub fast_ HandleSpriteDrop( id as int x as int y as int )
local
int i, max, onum
int index=RoomObjectsIndex[ActionRoom]
boolean dropped=false
boolean DeleteReqd=false
at as RwReal[3]
endlocal
if x >= WindowRX and x < WindowRX+WindowW*2 and y >= WindowRY and y < WindowRY + WindowH*2 then
//drop it on the window
if RoomType[ActionRoom] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
for i = 0 to max-1 loop
onum = ObjectsList[index+i]
if onum = 0 then
//slot empty, can drop here
onum = -id-1
RwGetCameraPosition(Camera, at)
x = INT(at[0])
y = INT(at[2])
RwScaleMatrix( RwScratchMatrix(), 0.25,0.25,0.25, rwREPLACE)
RwTranslateMatrix( RwScratchMatrix(), x+0.5, floor+OBJECTHEIGHT, y+0.5, rwPOSTCONCAT )
ObjectsXYH [index+i] = XYL( x-RoomX[ActionRoom], y-RoomY[ActionRoom], 0 )
ObjectsClump[index+i] = Inventory[id][ItemsList[id]]
ObjectsList[index+i] = onum
RwTransformClump( ObjectsClump[index+i], RwScratchMatrix(), rwREPLACE )
RwAddClumpToScene( room_contents[ActionRoom], ObjectsClump[index+i] )
dropped = true
loopexit
endif
end for
endif
if dropped then
if --ItemsList[id] = 0 then
DeleteReqd = true
endif
endif
if DeleteReqd then
DeleteSprite id
else
//put it back in the interface correctly
MoveSpriteTo id, (id*54+36)*2, 422*2
endif
end sub
sub fast_ PrintArr( a inout int[] )
local
int i
endlocal
print "Array \n"
for i = 0 to high(a) loop
print a[i], '\n'
endfor
end sub
function fast_ InAdjacentRender( r as int ) as boolean
local
i as int
endlocal
for i = 0 to high(AdjacentRender) loop
if AdjacentRender[i] = r then
return true
endif
endfor
return false
end function
function fast_ Local3DInit ( rootpath as filename ) as boolean
local
clump as RwClump
cbclump as RwClump
cbreal as float
x as int
y as int
i as int
int id, dw, r, max, index
rectbottom as int
rectright as int
thiscell as string
CType as int
BOOL ok, err
string str
int depth
endlocal
/* set search path so we pick up textures */
RwSetShapePath(rootpath + filename(TextureDir), rwREPLACE)
RwSetShapePath(rootpath + filename(ObjectDir), rwPOSTCONCAT)
RwSetShapePath(`.`, rwPOSTCONCAT)
ActionX = StartX
ActionY = StartY
ActionLevel = StartLevel
unit = 1
door = unit
Scene = RwCreateScene()
if (Scene == NULL) then
print "Error creating the RenderWare scene\n"
return FALSE
endif
AdjacentRenderScene = RwCreateScene()
RoomLight1 = RwCreateLight(rwDIRECTIONAL, -0.5, -1.0, 0.5, 0.5)
RoomLight2 = RwCreateLight(rwDIRECTIONAL, -0.5, -1.0, 0.5, 0.5)
RedDoorClump = CreateDoorClump(0)
GreenDoorClump = CreateDoorClump(1)
BlueDoorClump = CreateDoorClump(2)
MakeMap(ActionLevel)
DeleteElements RoomsAtThisLevel, high(RoomsAtThisLevel)+1
BuildRooms( ActionLevel )
ActionRoom = bigarray[ActionY][ActionX]
RoomVisited[ActionRoom] = 1
unit=PlayerMapUnit
unit=1
DeleteElements AdjacentRender, high(AdjacentRender)+1
RwForAllClumpsInScene( AdjacentRenderScene, RwRemoveClumpFromScene(clump), clump )
dw = RoomAdjacent[ActionRoom]
for i = 1 to RoomDoors[ActionRoom] loop
fromXYL( adjacent[dw++] & %x00ffffff, x, y, id )
r = FindRoomAtXYL( x, y, ActionLevel, id )
AddElement AdjacentRender, r
if RoomType[r] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
if Room_Geometry[r] != null then
RwAddClumpToScene( AdjacentRenderScene Room_Geometry[r])
endif
index=RoomObjectsIndex[r]
for i = 1 to max loop
clump = ObjectsClump[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
index=RoomAdjacent[r]
for i = 1 to RoomDoors[r] loop
clump = DoorClumps[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
end for
//add the actionroom
if ActionRoom >= 0 and ActionRoom <= high(room_geometry) then
AddElement AdjacentRender, ActionRoom
if Room_Geometry[ActionRoom] != null then
RwAddClumpToScene( AdjacentRenderScene Room_Geometry[ActionRoom])
endif
if RoomType[ActionRoom] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
index=RoomObjectsIndex[ActionRoom]
for i = 1 to max loop
clump = ObjectsClump[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
index=RoomAdjacent[ActionRoom]
for i = 1 to RoomDoors[ActionRoom] loop
clump = DoorClumps[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
endif
RwAddLightToScene( AdjacentRenderScene, RoomLight1 )
for r = 0 to high(room_geometry) loop
if not InAdjacentRender(r) then
if room_geometry[r] != null then
if RoomType[r] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
RwAddClumpToScene( room_contents[r] Room_Geometry[r])
index=RoomObjectsIndex[r]
for i = 1 to max loop
clump = ObjectsClump[index++]
if clump <> null then
RwAddClumpToScene( room_contents[r] clump)
endif
endfor
index=RoomAdjacent[r]
for i = 1 to RoomDoors[r] loop
clump = DoorClumps[index++]
if clump <> null then
RwAddClumpToScene( room_contents[r] clump)
endif
endfor
endif
endif
endfor
SetConvertErrorLevel enabled, rwCONVERTWARN
Camera = RwCreateCamera( MAXIMUM_WINDOW_WIDTH, MAXIMUM_WINDOW_HEIGHT )
if Camera == NULL then
if RwGetError() == RwErrorCode'E_RW_NOMEM then
print "Insufficient memory to create the RenderWare camera\n"
else
print "Error creating the RenderWare camera\n"
endif
return FALSE
endif
RwSetCameraPosition(Camera, ActionX, 0, ActionY )
RwSetCameraBackColor(Camera, 0.0, 0.0, 0.0)
RwSetCameraBackdropOffset(Camera, 0,0)
RwSetCameraViewwindow(Camera, 1.0, 1.0)
WinGetClientRect rectright, rectbottom
RwDeviceControl(rwWINSETOUTPUTSIZE, Camera, rectright, rectbottom)
RwSetCameraViewport(Camera, 0, 0, rectright/VScale , rectbottom/VScale )
RwSetCameraBackdropViewportRect(Camera, 0, 0, rectright/VScale , rectbottom/VScale )
RwSetCameraFarClipping( Camera, FarClipping )
ThreeDInitialized = TRUE
return TRUE
endfunction
sub fast_ TidyUp3D()
local
int i
endlocal
for i = 0 to high(room_geometry) loop
if room_geometry[i] != null then
RwDestroyClump(room_geometry[i])
endif
endfor
for i = 0 to high(room_contents) loop
if room_contents[i] != null then
RwDestroyScene(room_contents[i] )
endif
endfor
RwDestroyCamera(Camera)
RwDestroyScene(Scene)
RwDestroyScene(AdjacentRenderScene)
RwClose
endsub
sub DoRender( drawlist inout int[] )
local
int r, i, max, index
RwClump clump
endlocal
RwBeginCameraUpdate(Camera)
for i = 0 to high(drawlist) loop
r = drawlist[i]
if not InAdjacentRender(r) then
if RoomType[r] <= NROOMS then
RwAddLightToScene( room_contents[r], RoomLight2 )
RwRenderClump( room_geometry[r] )
RwRenderScene( room_contents[r] )
else
RwAddLightToScene( room_contents[r], RoomLight2 )
RwRenderScene( room_contents[r] )
endif
endif
endfor
RwRenderScene(AdjacentRenderScene)
RwEndCameraUpdate(Camera)
RwShowCameraImage(Camera)
endsub
//sort stuff
const
int xAxis=0, zAxis=2
var
int FirstAxis, SecondAxis
function FMaxSMax(r1 as int r2 as int vec inout RwReal[3] ) as int
local
int nVal1, nVal2
endlocal
if FirstAxis = xAxis then
nVal1 = (RoomX[r2]) - (RoomX[r1]+RoomW[r1])
nVal2 = (RoomX[r2]+RoomW[r2]) - (RoomX[r1])
if nVal1 >= 0 then
return 1
elseif nVal2 <= 0 then
return -1
else
return ((RoomY[r2]) - (RoomY[r1]))
endif
else
nVal1 = (RoomY[r1]) - (RoomY[r2]+RoomD[r2])
nVal2 = (RoomY[r1]+RoomD[r1]) - (RoomY[r2])
if nVal1 >= 0 then
return -1
elseif nVal2 <= 0 then
return 1
else
return -((RoomX[r1]) - (RoomX[r2]))
endif
endif
end function
function FMinSMax(r1 as int r2 as int vec inout RwReal[3]) as int
local
int nVal1, nVal2
endlocal
if FirstAxis = xAxis then
nVal1 = (RoomX[r2]) - (RoomX[r1]+RoomW[r1])
nVal2 = (RoomX[r2]+RoomW[r2]) - (RoomX[r1])
if nVal1 >= 0 then
return -1
elseif nVal2 <= 0 then
return 1
else
return ((RoomY[r2]) - (RoomY[r1]))
endif
else
nVal1 = (RoomY[r1]) - (RoomY[r2]+RoomD[r2])
nVal2 = (RoomY[r1]+RoomD[r1]) - (RoomY[r2])
if nVal1 >= 0 then
return -1
elseif nVal2 <= 0 then
return 1
else
return ((RoomX[r1]+RoomW[r1]) - (RoomX[r2]+RoomW[r2]))
endif
endif
end function
function FMinSMin(r1 as int r2 as int vec inout RwReal[3]) as int
local
int nVal1, nVal2
endlocal
if FirstAxis = xAxis then
nVal1 = (RoomX[r2]) - (RoomX[r1]+RoomW[r1])
nVal2 = (RoomX[r2]+RoomW[r2]) - (RoomX[r1])
if nVal1 >= 0 then
return -1
elseif nVal2 <= 0 then
return 1
else
return -((RoomY[r2]+RoomD[r2]) - (RoomY[r1]+RoomD[r1]))
endif
else
nVal1 = (RoomY[r2]) - (RoomY[r1]+RoomD[r1])
nVal2 = (RoomY[r2]+RoomD[r2]) - (RoomY[r1])
if nVal1 >= 0 then
return -1
elseif nVal2 <= 0 then
return 1
else
return -((RoomX[r2]+RoomW[r2]) - (RoomX[r1]+RoomW[r2]))
endif
endif
end function
function FMaxSMin(r1 as int r2 as int vec inout RwReal[3]) as int
local
int nVal1,nVal2
endlocal
if FirstAxis = xAxis then
nVal1 = (RoomX[r2]) - (RoomX[r1]+RoomW[r1])
nVal2 = (RoomX[r2]+RoomW[r2]) - (RoomX[r1])
if nVal1 >= 0 then
return 1
elseif nVal2 <= 0 then
return -1
else
return ((RoomY[r1]+RoomD[r1]) - (RoomY[r2]+RoomD[r2]))
endif
else
nVal1 = (RoomY[r2]) - (RoomY[r1]+RoomD[r1])
nVal2 = (RoomY[r2]+RoomD[r2]) - (RoomY[r1])
if nVal1 >= 0 then
return -1
elseif nVal2 <= 0 then
return 1
else
return ((RoomX[r2]) - (RoomX[r1]))
endif
endif
end function
sub fast_ render()
local
pos as RwReal[3]
at as RwReal[3]
x as int
y as int
int r1, r2
RwClump cbclump
int r
endlocal
RwGetCameraPosition(Camera, pos)
x = INT(pos[0])
y = INT(pos[2])
ActionRoom = bigarray[y][x]
RwGetCameraLookAt(Camera, at)
if fabs(at[0]) > fabs(at[2]) then
FirstAxis = xAxis
SecondAxis = zAxis
else
FirstAxis = zAxis
SecondAxis = xAxis
endif
if at[0] < 0 then
if at[2] < 0 then
sortintuser RoomsAtThisLevel, r1, r2, FMinSMin(r1, r2, pos)
else
sortintuser RoomsAtThisLevel, r1, r2, FMinSMax(r1, r2, pos)
endif
else
if at[2] < 0 then
sortintuser RoomsAtThisLevel, r1, r2, FMaxSMin(r1, r2, pos)
else
sortintuser RoomsAtThisLevel, r1, r2, FMaxSMax(r1, r2, pos)
endif
endif
DoRender( RoomsAtThisLevel )
end sub
sub OpenDoors( x as int y as int )
local
int i, thiscell, dcell
RwClump *clump=null
endlocal
thiscell = (y*256+x)*4
for i = 0 to high(DoorControlCell) loop
dcell = DoorControlCell[i]
if (dcell & (~3)) = thiscell and ItemsList[(dcell & 3)] then
clump = DoorControlClump[i]
if clump != null then
RwSetClumpState( clump, rwOFF )
endif
endif
endfor
end sub
sub CloseDoors( x as int y as int )
local
int i, thiscell, dcell
RwClump *clump=null
endlocal
thiscell = (y*256+x)*4
for i = 0 to high(DoorControlCell) loop
dcell = DoorControlCell[i]
if (dcell & (~3)) = thiscell then
clump = DoorControlClump[i]
if clump != null then
RwSetClumpState( clump, rwON )
endif
endif
endfor
end sub
sub moveforward(fforward as RwReal)
local
pos1 as RwReal[3]
pos2 as RwReal[3]
at as RwReal[3]
x1 as int
y1 as int
x2 as int
y2 as int
dbounce as int
dbp as RwReal
boolean bump=false
int timesincebump
RwClump *clump
int oldroom, type
int i, index, count
int onum, max
int x, y, h, dcol, r
filename res
int dw, id, bonus
int CellWalls
string pos
float angle
endlocal
RwGetCameraPosition(Camera, pos1)
x1 = INT(pos1[0])
y1 = INT(pos1[2])
RwGetCameraLookAt(Camera, at)
oldroom = ActionRoom
//attempt to move
if (fforward != 0) then
RwWCMoveCamera(Camera, (at[0]*fforward), dbp, (at[2]*fforward))
endif
RwGetCameraPosition(Camera, pos2)
x2 = INT(pos2[0])
y2 = INT(pos2[2])
//check for doors present first
CellWalls = walls[y1][x1]
dw = CellWalls>>4
if dw then
//we have at least one door in this cell
count = 1
for i = 0 to 3 loop
dcol = dw & 7
if dcol-- then
//this is a door, 1=g,2=b,3=r
if not ItemsList[dcol] then
CellWalls |= count
endif
endif
dw>>=3
count<<=1
endfor
endif
// constrain movement based upon cell walls
if (INT(pos2[0] - CLOSEST) < x1 && (CellWalls/*walls[y1][x1]*/ & WEST)) then
pos2[0] = float(INT(pos1[0]))
pos2[0] += CLOSEST
bump = true
endif
if (INT(pos2[0] + CLOSEST) > x1 && (CellWalls/*walls[y1][x1]*/ & EAST)) then
pos2[0] = float(INT(pos1[0]) + 1)
pos2[0] -= CLOSEST
bump = true
endif
if (INT(pos2[2] - CLOSEST) < y1 && (CellWalls/*walls[y1][x1]*/ & NORTH)) then
pos2[2] = float(INT(pos1[2]))
pos2[2] += CLOSEST
bump = true
endif
if (INT(pos2[2] + CLOSEST) > y1 && (CellWalls/*walls[y1][x1]*/ & SOUTH)) then
pos2[2] = float(INT(pos1[2]) + 1)
pos2[2] -= CLOSEST
bump = true
endif
// special case diagonal move which causes problems
if ((x1 != x2) && (y1 != y2)) then
if (y2 > y1) then
if (walls[y2-1][x2] & SOUTH) then
pos2[2] = float(INT(pos1[2]) + 1)
pos2[2] -= CLOSEST
bump = true
endif
else
if (walls[y2+1][x2] & NORTH) then
pos2[2] = float(INT(pos1[2]))
pos2[2] += CLOSEST
bump = true
endif
endif
endif
timesincebump+=TimerTick
if bump and timesincebump > bumprepeat then
if SoundEffectFlags & 1 then
audio wav, filename(OooffSound)
endif
timesincebump = 0
endif
ifc ( pos2[0] < 0 )
pos2[0] = 0
ifc ( pos2[0] > maxx )
pos2[0] = maxx
ifc ( pos2[2] < 0 )
pos2[2] = 0
ifc ( pos2[2] > maxy )
pos2[2] = maxy
RwSetCameraPosition(Camera, pos2[0], pos2[1], pos2[2] )
x2 = INT(pos2[0])
y2 = INT(pos2[2])
ActionRoom = bigarray[y2][x2]
if x1 <> x2 or y1 <> y2 then
//new cell stuff
CloseDoors( x1, y1 )
OpenDoors( x2, y2 )
index=RoomObjectsIndex[ActionRoom]
if RoomType[ActionRoom] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
for i = 0 to max-1 loop
onum = ObjectsList[index+i]
if onum < 0 then
//can collect, so do special processing
onum = -onum-1
fromXYL( ObjectsXYH[index+i], x, y, h )
x+=RoomX[ActionRoom]
y+=RoomY[ActionRoom]
if x2 = x and y2 = y then
id = onum //+1 until we have a green key
if id = EndItem then
EndReached = true
elsif id > SpeedItem then
ObjectsList[index+i] = 0
RwSetClumpState( ObjectsClump[index+i], rwOFF )
// this is a score bonus
bonus = 10000
while id > SpeedItem loop
id--
bonus/=10
endwhile
ShowScore(bonus)
elseif id = TimeBonusItem then
ObjectsList[index+i] = 0
RwSetClumpState( ObjectsClump[index+i], rwOFF )
ShowTime( +TIMEBONUS )
else
if ++ItemsList[id] <= MAXINVENTORY then
Inventory[id][ItemsList[id]] = ObjectsClump[index+i]
ObjectsList[index+i] = 0
RwSetClumpState( ObjectsClump[index+i], rwOFF )
if ItemsList[id] = 1 then
CreateSprite id, (id*53+36)*2, 422*2, oneshot, 0, 0, 1, [onum]
if id <= MapItem then
SetSpriteFlags id, enabled|visible|dragable, unbound
else
SetSpriteFlags id, enabled|visible, unbound
endif
endif
else
--ItemsList[id]
endif
endif
if SoundEffectFlags & 4 and id <> EndItem then
mci ( `close trev`, res )
mci ( `open waveaudio!`+filename(CollectSound)+` alias trev wait`, res )
mci ( `play trev`, res )
endif
endif
endif
endfor
endif
if oldroom <> ActionRoom then
//new room
DeleteElements AdjacentRender, high(AdjacentRender)+1
RwForAllClumpsInScene( AdjacentRenderScene, RwRemoveClumpFromScene(clump), clump )
dw = RoomAdjacent[ActionRoom]
for i = 1 to RoomDoors[ActionRoom] loop
fromXYL( adjacent[dw++] & %x00ffffff, x, y, id )
r = FindRoomAtXYL( x, y, ActionLevel, id )
AddElement AdjacentRender, r
if RoomType[r] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
if Room_Geometry[r] != null then
RwAddClumpToScene( AdjacentRenderScene Room_Geometry[r])
endif
index=RoomObjectsIndex[r]
for i = 1 to max loop
clump = ObjectsClump[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
index=RoomAdjacent[r]
for i = 1 to RoomDoors[r] loop
clump = DoorClumps[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
end for
//add the actionroom
if ActionRoom >= 0 and ActionRoom <= high(room_geometry) then
AddElement AdjacentRender, ActionRoom
if Room_Geometry[ActionRoom] != null then
RwAddClumpToScene( AdjacentRenderScene Room_Geometry[ActionRoom])
endif
if RoomType[ActionRoom] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
endif
index=RoomObjectsIndex[ActionRoom]
for i = 1 to max loop
clump = ObjectsClump[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
index=RoomAdjacent[ActionRoom]
for i = 1 to RoomDoors[ActionRoom] loop
clump = DoorClumps[index++]
if clump <> null then
RwAddClumpToScene( AdjacentRenderScene clump)
endif
endfor
endif
RwAddLightToScene( AdjacentRenderScene, RoomLight1 )
for r = 0 to high(room_geometry) loop
if not InAdjacentRender(r) then
if room_geometry[r] != null then
if RoomType[r] <= NROOMS then
max = MaxObjectsPerRoom
else
max = MaxObjectsPerLink
RwAddClumpToScene( room_contents[r] Room_Geometry[r])
endif
index=RoomObjectsIndex[r]
for i = 1 to max loop
clump = ObjectsClump[index++]
if clump <> null then
RwAddClumpToScene( room_contents[r] clump)
endif
endfor
index=RoomAdjacent[r]
for i = 1 to RoomDoors[r] loop
clump = DoorClumps[index++]
if clump <> null then
RwAddClumpToScene( room_contents[r] clump)
endif
endfor
RwAddLightToScene( room_contents[r], RoomLight2 )
endif
endif
endfor
if not RoomVisited[ActionRoom] then
RoomVisited[ActionRoom] = 1
unit=PlayerMapUnit
unit=1
endif
ResetRoomLineColour(oldroom)
SetRoomLineColour( ActionRoom, 0, 255, 0 )
endif
endsub
sub fast_ DoHandleSize(width as int, height as int)
RwDeviceControl(rwWINSETOUTPUTSIZE, Camera, width, height)
RwSetCameraViewport(Camera, 0, 0, width/VScale, height/VScale)
RwSetCameraBackdropViewportRect(Camera, 0,0, width/VScale, height/VScale)
/* viewwindow aspect ratio of 1:1 regardless of viewport aspect ratio */
if ((width != 0) && (height != 0)) then
if (width >= height) then
RwSetCameraViewwindow(Camera, 1.0, 1.0*( float(height)/float(width) ) )
else
RwSetCameraViewwindow(Camera, 1.0*( float(width)/float(height) ), 1.0 )
endif
endif
WinInvalidateRect
endsub
function HandleLeftButtonDown(x as int, y as int , vKeys as int ) as BOOL
if not ThreeDInitialized then
return 1
endif
// print "LMOUSEDOWN\n"
if (vKeys & MK_DEFS'MK_SHIFT) then
MouseMoveMode = MMTiltCamera
else
MouseMoveMode = MMPanAndZoomCamera
fforward = 0.0
pan = 0.0
if !Fast then
Vscale = SlowScale
endif
endif
if (MouseMoveMode != MMNoAction) then
WinSetCapture
LastX = x
LastY = y
WinClientToScreen LastX, LastY
SX = x
SY = y
WinClientToScreen SX, SY
endif
return 0
endfunction
function HandleRightButtonDown2(x as int, y as int, vkeys as int) as BOOL
local
vx as int
vy as int
vw as int
vh as int
XDelta as RwReal
YDelta as RwReal
//pickrecord
picktype as RwPickObject
pickclump as RwClump
pickpolygon as RwPolygon3d
vindex as int
d2 as int
pickx as RwReal
picky as RwReal
pickz as RwReal
tag as int
RwScene Scene
endlocal
if not ThreeDInitialized then
return 1
endif
MouseMoveMode = MMNoAction
if room_contents[ActionRoom] != null then
Scene = room_contents[ActionRoom]
// if (Scene != NULL) then
RwGetCameraViewport(Camera, vx, vy, vw, vh)
x-=vx
y-=vy
if RwPickScene(Scene, x, y, Camera, picktype, pickclump, pickpolygon, vindex, d2, pickx, picky, pickz) != Scene then
return 0
endif
if (Picktype == RwPickObject'rwPICKCLUMP) then
// The objects in the scene which are manipulatable are tagged with 2.
tag = RwGetClumpTag(Pickclump)
if (tag) then
DragClump = Pickclump
if (tag = 1) then
MouseMoveMode = MMRotateClump
elseif tag = 2 then
MouseMoveMode = MMMoveClump
endif
endif
endif
endif
if (MouseMoveMode != MMNoAction) then
RwGetCameraViewport(Camera, vx, vy, vw, vh)
FirstX = vx + (vw >> 1)
FirstY = vy + (vh >> 1)
WinClientToScreen FirstX, FirstY
LastX = x+vx
LastY = y+vy
WinClientToScreen LastX, LastY
WinSetCapture
endif
return 0
endfunction
function HandleMouseMove(x as int, y as int) as BOOL
local
centrex as int
centrey as int
foffx as float
foffy as float
width as int
height as int
offx as int
offy as int
boolean DummyBool
at as RwReal[3]
RwReal hyp, cosangle
RwMatrix4d mat, matr
RwReal tlate[3]
int OldVScale = VScale
int dx, dy
string tag
endlocal
if not ThreeDInitialized then
return 1
endif
// print "MOUSEMOVE\n"
WinClientToScreen x, y
RwGetCameraViewport(Camera, DummyBool, DummyBool, width, height)
if MouseMoveMode == MMNoAction then
null
elsif MouseMoveMode == MMPanAndZoomCamera then
RwGetCameraPosition(Camera, at)
dx = INT(at[0])
dy = INT(at[2])
pan = float(Sx - x) / 20.0
fforward = float(Sy - y)/800.0
if fforward > WindowH/(1*800.0) then
fforward = WindowH/(1*800.0)
endif
if ItemsList[SpeedItem] > 0 then
fforward*=2
endif
elsif MouseMoveMode == MMTiltCamera then
RwRotateMatrix(RwScratchMatrix(), 0.0, 1.0, 0.0, float(LastX - x), rwREPLACE)
RwTransformCameraOrientation(Camera, RwScratchMatrix())
RwTiltCamera(Camera, float(y - LastY))
RwGetCameraBackdropOffset(Camera, offx, offy)
RwGetCameraPosition( Camera, at )
elsif MouseMoveMode == MMRotateClump then
foffx = float(x - LastX)/ float(width)
RwPushScratchMatrix()
RwRotateMatrix(RwScratchMatrix(), (0.0), (1.0), (0.0), foffx * (180.0), rwREPLACE)
RwTransformClumpJoint(DragClump, RwScratchMatrix(), rwPOSTCONCAT)
RwPopScratchMatrix()
elsif MouseMoveMode == MMMoveClump then
foffx = float(x - LastX)/ float(width)
foffy = float(y - LastY)/ float(height)
RwGetCameraLookAt( Camera, at )
hyp = sqrt( at[0]*at[0] + at[2]*at[2] )
cosangle = at[2]/hyp
if Shrink then
tlate[0] = -foffx*16
tlate[1] = 0
tlate[2] = -foffy*16
else
tlate[0] = -foffx*4
tlate[1] = 0
tlate[2] = -foffy*4
endif
RwPushScratchMatrix()
RwRotateMatrixCos( RwScratchMatrix(), 0,1,0, cosangle, at[0], rwREPLACE )
RwTransformVector( tlate, RwScratchMatrix() )
RwTranslateMatrix( RwScratchMatrix(), tlate[0], 0.0, tlate[2], rwREPLACE)
RwTransformClumpJoint(DragClump, RwScratchMatrix(), rwPOSTCONCAT)
RwPopScratchMatrix()
endif
LastX = x
LastY = y
return 0
endfunction
function HandleLeftButtonUp( ) as BOOL
if not ThreeDInitialized then
return 1
endif
if (MouseMoveMode != MMNoAction) then
MouseMoveMode = MMNoAction
fforward = 0.0
pan = 0.0
if !Fast then
Vscale = SlowScale
endif
WinReleaseCapture
endif
return 0
endfunction
function HandleRightButtonUp( ) as BOOL
if not ThreeDInitialized then
return 1
endif
RwSetCameraLookUp(Camera, 0.0, 1.0, 0.0);
if (MouseMoveMode != MMNoAction) then
MouseMoveMode = MMNoAction
fforward = 0.0
pan = 0.0
if !Fast then
Vscale = SlowScale
endif
WinReleaseCapture
endif
return 0
endfunction
function HandlePaint() as BOOL
local
int w, h
endlocal
if not ThreeDInitialized then
return 1
endif
WinGetClientRect w, h
DoHandleSize( w, h )
WinBeginPaint
RwInvalidateCameraViewport(Camera)
render()
WinEndPaint
return 0
endfunction
function fast_ HandleTimer() as BOOL
local
int dx =0, dy =0, tempx, tempy
at as RwReal[3]
cbclump as RwClump
cbtexture as RwTexture
int h,m,s,c
int sold
endlocal
if not ThreeDInitialized then
return 1
endif
gettime h,m,s,c
if s <> sold then
sold = s
if ItemsList[SpeedItem] then
if ++HighSpeedTime > SPEEDTIMEPERIOD then
HighSpeedTime = 0
if --ItemsList[SpeedItem] = 0 then
DeleteSprite SpeedItem
endif
endif
endif
if ItemsList[FreezeTimeItem] then
if ++FrozenTime > FREEZETIMEPERIOD then
FrozenTime = 0
if --ItemsList[FreezeTimeItem] = 0 then
DeleteSprite FreezeTimeItem
endif
endif
else
ShowTime( -1 )
endif
endif
RwGetCameraPosition(Camera, at)
dx = INT(at[0])
dy = INT(at[2])
/* Perform any "momentum" camera moves. */
if ( (pan != 0.0) || (fforward != 0.0) ) then
RwRotateMatrix(RwScratchMatrix(), 0.0, 1.0, 0.0, pan, rwREPLACE)
RwTransformCameraOrientation(Camera, RwScratchMatrix())
moveforward(fforward);
RwGetCameraBackdropOffset(Camera, dx, dy);
// artificially wrap dx to avoid overflow present in original program
if ( (dx > 16383) || (dx < -16384) ) then
dx = -dx
endif
RwSetCameraBackdropOffset(Camera, dx-INT(pan)*2, dy)
endif
render()
if MouseMoveMode = MMNoAction then
if TimerTick = FastTimerTick then
WinKillTimer 1
TimerTick = SlowTimerTick
WinSetTimer 1, TimerTick
endif
else
if TimerTick = SlowTimerTick then
WinKillTimer 1
TimerTick = FastTimerTick
WinSetTimer 1, TimerTick
endif
endif
return 0
endfunction
function HandleChar( char as int ) as BOOL
local
RwReal pos[3]
endlocal
if not ThreeDInitialized then
return 1
endif
break on
// print using "CHAR %s\n", chr$(char)
if(char == asc('s') || char == asc('S')) then
Shrink = !Shrink
RwGetCameraPosition(Camera, pos )
if Shrink then
pos[1]/=4
RwSetCameraViewWindow( Camera, 0.25, 0.25 )
else
pos[1]*=4
RwSetCameraViewWindow( Camera, 1.0, 1.0 )
endif
RwSetCameraPosition(Camera, pos[0], pos[1], pos[2] )
elsif(char == asc('f') || char == asc('F')) then
Fast = !Fast
if Fast then
VScale = FastScale
else
Vscale = SlowScale
endif
SetViewport( VScale )
endif
return 0
end function
function HandleSize( Reason as int NewSize as int ) as BOOL
local
NewWidth as int
NewHeight as int
end local
if not ThreeDInitialized then
return 1
endif
break on
// print "SIZE\n"
if (ThreeDInitialized) then
NewWidth = NewSize & %xffff
NewHeight = NewSize >> 16
if Reason = SIZE_REASON'SIZE_MINIMIZED then
if TimerActive then
WinKillTimer 1
TimerActive = false
endif
else
if !TimerActive then
WinSetTimer 1, TimerTick
TimerActive = true
endif
DoHandleSize( NewWidth, NewHeight)
endif
endif
end function
sub fast_ RemoveEventHandlers( )
OffWinEvent2 0, WM_CHAR
OffWinEvent2 0, WM_CREATE
OffWinEvent2 0, WM_SIZE
OffWinEvent2 0, WM_PAINT
OffWinEvent2 0, WM_TIMER
OffWinEvent2 0, WM_DESTROY
OffMouseEvent2 0, LBUTTONDOWN
OffMouseEvent2 0, RBUTTONDOWN
OffMouseEvent2 0, MOUSEMOVE
OffMouseEvent2 0, LBUTTONUP
OffMouseEvent2 0, RBUTTONUP
// off_event timer
endsub
function fast_ HandleCreate() as BOOL
break on
// print "CREATE\n"
return 0
end function
function fast_ HandleDestroy() as BOOL
break on
// print "DESTROY\n"
WinKillTimer 1
TimerActive = false
TidyUp3D()
DeinitRw()
RemoveEventHandlers()
destroyed = true
return 0
end function
sub fast_ SetupEventHandlers( )
local
int Mkey=77
int NewSize, Reason
MouseXPos as int
MouseYPos as int
keys as int
dummy as int = 0
timercount as int
char as int
RwReal pos[3]
endlocal
OnWinEvent2 0, WM_CHAR, char, dummy, HandleChar( char )
OnWinEvent2 0, WM_CREATE, dummy, dummy, HandleCreate()
OnWinEvent2 0, WM_SIZE, Reason, NewSize, HandleSize( Reason, NewSize )
OnWinEvent2 0, WM_PAINT, dummy, dummy, HandlePaint()
OnWinEvent2 0, WM_TIMER, dummy, dummy, HandleTimer()
OnWinEvent2 0, WM_DESTROY, dummy, dummy, HandleDestroy()
OnMouseEvent2 0, LBUTTONDOWN, MouseXPos, MouseYPos, keys, HandleLeftButtonDown(MouseXPos/VScale, MouseYPos/VScale, keys)
OnMouseEvent2 0, RBUTTONDOWN, MouseXPos, MouseYPos, keys, HandleRightButtonDown2(MouseXPos/VScale, MouseYPos/VScale, keys)
OnMouseEvent2 0, MOUSEMOVE, MouseXPos, MouseYPos, keys, HandleMouseMove(MouseXPos/VScale, MouseYPos/VScale)
OnMouseEvent2 0, LBUTTONUP, MouseXPos, MouseYPos, keys, HandleLeftButtonUp()
OnMouseEvent2 0, RBUTTONUP, MouseXPos, MouseYPos, keys, HandleRightButtonUp()
endsub
sub fast_ DefineScoreAndTimeSprites()
local
int i
int x=(36+8+(ScoreDigits-1)*16)*2
int w= 16*2
int y=332*2
int bx
int h
endlocal
//stock object sprites images
SpriteBank 1
transparentcolour 221,0,147,255
for bx = 0 to 5 loop
DefineSprite bx+1, bx*53*2,384*2,53*2,32*2
endfor
//green key is separate
bx=9
DefineSprite 0, bx*53*2,384*2,53*2,32*2
//digit sprites images
for i = 1 to 9 loop
DefineSprite digits+i, (8+20*(i-1))*2, 350*2, 16*2, (32-4)*2
endloop
DefineSprite digits+0, (8+20*i)*2, 350*2, 16*2, (32-4)*2
//score sprites
x= (38+(ScoreDigits-1)*16)*2
y= 334*2
w= 16*2
for i = FirstScoreSprite to FirstScoreSprite+ScoreDigits-1 loop
CreateSprite i, x, y, oneshot, 0, 0, 1, [digits+0]
SetSpriteFlags i, enabled|visible, unbound
x-=w
end loop
x=0*2
y=0*2
w=116*2
h=115*2
//time ring sprite images
for i = 0 to 3 loop
DefineSprite FirstTimeRingSprite+i, x, y, w, h
x+=w-1
endfor
y+=h
for i = 4 to 7 loop
x-=w-1
DefineSprite FirstTimeRingSprite+i, x, y, w, h
endfor
x = 4*w
y+=h
for i = 8 to 9 loop
x-=w
DefineSprite FirstTimeRingSprite+i, x, y, w, h
endfor
//time sprites
MazeTime = strtoi(MazeTimeLimit)
if MazeTime >= 0 then
CreateSprite TimeRingSprite, 39*2, 25*2, oneshot, 0, 0, 1, [FirstTimeRingSprite+8]
SetSpriteFlags TimeRingSprite, enabled|visible, unbound
endif
if MazeTime >= 0 then
x = (38 + (116/2))*2
y = (23 + (116/2)-(28/2))*2
w= 16*2
if MazeTime = 0 then
x+=2*w
endif
for i = FirstTimeSprite to FirstTimeSprite+TimeDigits-1 loop
CreateSprite i, x, y, oneshot, 0, 0, 1, [digits+0]
SetSpriteFlags i, enabled|visible, unbound
x-=w
end loop
endif
end sub
sub fast_ init()
local
int i, id, x, y
endlocal
PlayerMapUnit = DEFAULTPLAYERMAPUNIT
MapUnit = DEFAULTMAPUNIT
RoomUnit = DEFAULTROOMUNIT
unit = 1
door = unit
TimerTick = SlowTimerTick
GridOriginX = MapGridX
DrawOriginX = 0
GridOriginY = MapGridY
DrawOriginY = 0
StartX = -1 StartY = -1 StartRoom = -1 StartLevel = 0
for i = 1 to NMAPOBJS loop
input data ObjectsPerRoomData, ObjectsPerRoom[i]
input data DoorsPerRoomData, DoorsPerRoom[i]
endfor
on_sprite_drop id, x, y, { HandleSpriteDrop(id, x, y ) }
end sub
//maggot stuff
const
int v=50
int astep=100
int MaggotStart=1
const
int MaggotW=10
int MaggotL=40
int downup=-1, updown=-2, rightleft=-3, leftright=-4
int left=0, right=8, down=16, up=24
int leftup=32, leftdown=38,rightup=44,rightdown=50
int upright=56,upleft=62,downright=68,downleft=74
int MaggotBank=2
data MaggotLL
34,32,28,28,26,32,38,36
enddata
data MaggotOffsetL
0,36,34,28,28,26,34,38
enddata
data MaggotOffsetR
0,34,38,34,26,28,32,32
enddata
data MaggotRL
36,36,34,28,26,32,34,34
enddata
data MaggotOffsetD
0,34,40,34,26,28,32,32
enddata
data MaggotDL
36,38,34,28,28,32,30,36
enddata
data MaggotOffsetU
0,36,36,28,26,28,34,36
enddata
data MaggotUL
36,34,28,28,28,32,38,38
enddata
data MaggotXY:2
212,350,
212,364,
484,0,
508,0
enddata
data BBoxXY:6
14, 8, 38,290,down,downup, //A-Y
14, 8, 38,290,up,upright, //A-Y
14, 8,178, 20,right,rightdown,//A-q
166, 8,178,157,down,downleft, //B-L
99,150,178,164,left,leftright, //H-L
99,150,131,164,right,rightdown,//H-J
116,150,131,184,down,downleft, //I-
62,170,131,184,left,leftdown, //K-
62,170, 76,294,down,downright, //K-
62,282,134,296,right,rightup, //-U
120,218,134,296,up,updown, //V-U
120,218,134,296,down,downleft, //V-U
87,282,134,296,left,leftup, //S-U
87,194,105,296,up,upright, //R-T
87,194,156,208,right,rightdown,//R-P
142,194,156,320,down,downleft, //Q-W
38,306,156,320,left,leftup, //Y-W
38,150, 52,320,up,upright, //F-X
38,150, 86,164,right,rightleft,//F-G
38,150, 86,164,left,leftdown, //F-G
38,150, 52,320,down,downleft, //F-X
14,306, 52,320,left,leftdown, //z-X
14,306, 38,479,down,downright, //z-b
14,465,634,479,right,rightup,
620,438,634,479,up,updown,
620,438,634,479,down,downleft,
576,465,634,479,left,leftup,
576,450,594,479,up,upright,
576,450,608,464,right,rightup,
594,420,608,464,up,upleft,
576,420,608,434,left,leftup,
576,402,594,434,up,upright,
576,402,634,416,right,rightdown,
620,398,634,440,down,downup,
620, 8,634,440,up,upleft,
578, 8,634, 20,left,leftright,
578, 8,634, 20,right,rightdown,
620, 8,634,416,down,downleft,
139,402,634,416,left,leftright,
139,402,594,416,right,rightdown,
576,402,594,434,down,downright,
576,420,608,434,right,rightdown,
594,420,608,464,down,downleft,
576,450,608,464,left,leftdown,
576,450,594,479,down,downleft,
14,465,594,479,left,leftup,
14,402, 38,479,up,upright,
14,402,128,416,right,rightleft,
14,402,128,416,left,leftup,
14,378, 38,416,up,upright,
14,378, 61,392,right,rightleft,
14,378, 61,392,left,leftup,
14,306, 38,392,up,upright,
14,306,156,320,right,rightup,
142,250,156,320,up,upright,
142,250,178,266,right,rightdown,
166,250,178,392,down,downleft,
74,378,178,392,left,leftright,
74,378,178,392,right,rightup,
166,252,178,392,up,upleft,
142,252,178,266,left,leftup,
142,170,156,266,up,updown,
142,170,156,208,down,downleft,
87,194,156,208,left,leftdown,
87,194,105,296,down,downleft,
62,282,105,296,left,leftup,
62,170,105,296,up,upright,
62,170,131,184,right,rightup,
116,150,131,184,up,upright,
116,150,178,157,right,rightdown,
166,150,178,234,down,downup,
166, 8,178,234,up,upright,
166, 8,567, 20,right,rightleft,
14, 8,567, 20,left,leftdown
enddata
int mx, my, mw, mh, mvx, mvy, mx2, my2
int olddir, dir
int turndir
sub fast_ HandleCorner( turndir as int )
SetSpriteFlags MaggotSprite, enabled|visible, unbound
SpriteMechanics MaggotSprite,0,0,0,0,0
if turndir > 0 then
CreateSprite MaggotSprite, mx*2, my*2, oneshot, 0, astep, MaggotBank, [turndir+5,turndir+4,turndir+3,turndir+2,turndir+1,turndir+0]
elseif turndir = updown then
CreateSprite MaggotSprite, mx*2, my*2, oneshot, 0, astep, MaggotBank, [up+3,up+3,up+3]
elseif turndir = downup then
CreateSprite MaggotSprite, mx*2, my*2, oneshot, 0, astep, MaggotBank, [down,down,down]
elseif turndir = leftright then
CreateSprite MaggotSprite, mx*2, my*2, oneshot, 0, astep, MaggotBank, [left+3,left+3,left+3]
elseif turndir = rightleft then
CreateSprite MaggotSprite, mx*2, my*2, oneshot, 0, astep, MaggotBank, [right,right,right]
endif
if olddir=left and dir=down then
MoveSpriteTo MaggotSprite, mx*2, (my-4)*2
elsif olddir=left and dir=up then
MoveSpriteTo MaggotSprite, mx*2, (my2-29)*2
elsif olddir=right and dir=down then
MoveSpriteTo MaggotSprite, (mx2-25)*2, (my-4)*2
elsif olddir=right and dir=up then
MoveSpriteTo MaggotSprite, (mx2-25)*2, (my2-29)*2
elsif olddir=up and dir=right then
MoveSpriteTo MaggotSprite, mx*2, (my-4)*2
elsif olddir=up and dir=left then
MoveSpriteTo MaggotSprite, (mx2-25)*2, (my-4)*2
elsif olddir=down and dir=right then
MoveSpriteTo MaggotSprite, mx*2, (my2-29)*2
elsif olddir=down and dir=left then
MoveSpriteTo MaggotSprite, (mx2-25)*2, (my2-29)*2
endif
end sub
sub fast_ HandleDirChange( )
// print using "Bump LI=%d\n", ListIndex
CreateSprite MaggotSprite, mx*2, my*2, looped, 0, astep, MaggotBank, [dir+0,dir+1,dir+2,dir+3,dir+4,dir+5,dir+6,dir+7]
if olddir=left and dir=down then
MoveSpriteTo MaggotSprite, mx*2, my*2
elsif olddir=left and dir=up then
MoveSpriteTo MaggotSprite, mx*2, (my2-40)*2
elsif olddir=down and dir=up then
MoveSpriteTo MaggotSprite, mx*2, (my2-40)*2
elsif olddir=up and dir=down then
MoveSpriteTo MaggotSprite, mx*2, my*2
elsif olddir=right and dir=left then
MoveSpriteTo MaggotSprite, (mx2-40)*2, my*2
elsif olddir=left and dir=right then
MoveSpriteTo MaggotSprite, mx*2, my*2
elsif olddir=right and dir=down then
MoveSpriteTo MaggotSprite, mx*2, my*2
elsif olddir=right and dir=up then
MoveSpriteTo MaggotSprite, mx*2, (my2-40)*2
elsif olddir=up and dir=right then
MoveSpriteTo MaggotSprite, mx*2, my*2
elsif olddir=up and dir=left then
MoveSpriteTo MaggotSprite, (mx2-40)*2, my*2
elsif olddir=down and dir=right then
MoveSpriteTo MaggotSprite, mx*2, my*2
elsif olddir=down and dir=left then
MoveSpriteTo MaggotSprite, (mx2-40)*2, my*2
endif
SpriteBBox MaggotSprite, mx*2, my*2, (mx2-mx)*2, (my2-my)*2
SetSpriteFlags MaggotSprite, enabled|visible, bound
SpriteMechanics MaggotSprite,mvx,mvy,0,0,0
end sub
sub fast_ LoadMaggots()
local
int x, y, w, h, id, offset
endlocal
spritebank MaggotBank
transparentcolour 221,0,147,255
spritefile gif, InstallDir + `sprites.gif`
//left going maggot
input data MaggotXY, x, y
restoredata MaggotLL
restoredata MaggotOffsetL
h=MaggotW
for id = 0 to 7 loop
input data MaggotLL, w
input data MaggotOffsetL, offset
x+=offset
defsprite id+left, x*2, y*2, w*2, h*2
endfor
//right going maggot
input data MaggotXY, x, y
restoredata MaggotRL
restoredata MaggotOffsetR
h=MaggotW
for id = 0 to 7 loop
input data MaggotRL, w
input data MaggotOffsetR, offset
x+=offset
defsprite id+right, x*2, y*2, w*2, h*2
endfor
//down going maggot
input data MaggotXY, x, y
restoredata MaggotDL
restoredata MaggotOffsetD
w=MaggotW
for id = 0 to 7 loop
input data MaggotDL, h
input data MaggotOffsetD, offset
y+=offset
defsprite id+down, x*2, y*2, w*2, h*2
endfor
//up going maggot
input data MaggotXY, x, y
restoredata MaggotUL
restoredata MaggotOffsetU
w=MaggotW
for id = 0 to 7 loop
input data MaggotUL, h
input data MaggotOffsetU, offset
y+=offset
defsprite id+up, x*2, y*2, w*2, h*2
endfor
//leftup going maggot
offset=40
w=25
h=25
x=10+(5*offset)
y=416
for id = 0 to 5 loop
defsprite id+leftup, x*2, y*2, w*2, h*2
x-=offset
endfor
//leftdown going maggot
offset=40
w=25
h=25
x=10+(5*offset)
//x=290-offset
y=452
for id = 0 to 5 loop
defsprite id+leftdown, x*2, y*2, w*2, h*2
x-=offset
endfor
//rightup going maggot
offset=40
w=25
h=25
x=290-offset
y=416
for id = 0 to 5 loop
defsprite id+rightup, x*2, y*2, w*2, h*2
x+=offset
endfor
//rightdown going maggot
offset=40
w=25
h=25
x=290-offset
y=452
for id = 0 to 5 loop
defsprite id+rightdown, x*2, y*2, w*2, h*2
x+=offset
endfor
//upleft going maggot
offset=40
w=25
h=25
x=538
y=4+(5*offset)
for id = 0 to 5 loop
defsprite id+upleft, x*2, y*2, w*2, h*2
y-=offset
endfor
//upright going maggot
offset=40
w=25
h=25
x=538+42
y=4+(5*offset)
for id = 0 to 5 loop
defsprite id+upright, x*2, y*2, w*2, h*2
y-=offset
endfor
//downleft going maggot
offset=40
w=25
h=25
x=538
y=4+(6*offset)
for id = 0 to 5 loop
defsprite id+downleft, x*2, y*2, w*2, h*2
y+=offset
endfor
//downright going maggot
offset=40
w=25
h=25
x=538+offset
y=4+(6*offset)
for id = 0 to 5 loop
defsprite id+downright, x*2, y*2, w*2, h*2
y+=offset
endfor
end sub
sub fast_ HandleCollision( )
olddir = dir
input data BBoxXY, turndir
if endofdata( BBoxXY ) then
RestoreData BBoxXY
endif
input data BBoxXY, mx, my, mx2, my2, dir
if dir = left then
mvx = -v mvy = 0
elsif dir = right then
mvx = v mvy = 0
elsif dir = up then
mvx = 0 mvy = -v
elsif dir = down then
mvx = 0 mvy = v
endif
HandleCorner(turndir)
end sub
sub fast_ HandleStop()
if dir=left or dir=right then
if abs(mx-mx2) <= MaggotL then
olddir = dir
input data BBoxXY, turndir
if endofdata( BBoxXY ) then
RestoreData BBoxXY
endif
input data BBoxXY, mx, my, mx2, my2, dir
if dir = left then
mvx = -v mvy = 0
elsif dir = right then
mvx = v mvy = 0
elsif dir = up then
mvx = 0 mvy = -v
elsif dir = down then
mvx = 0 mvy = v
endif
HandleCorner(turndir)
else
HandleDirChange()
endif
elseif dir=up or dir=down then
if abs(my-my2) <= MaggotL then
olddir = dir
input data BBoxXY, turndir
if endofdata( BBoxXY ) then
RestoreData BBoxXY
endif
input data BBoxXY, mx, my, mx2, my2, dir
if dir = left then
mvx = -v mvy = 0
elsif dir = right then
mvx = v mvy = 0
elsif dir = up then
mvx = 0 mvy = -v
elsif dir = down then
mvx = 0 mvy = v
endif
HandleCorner(turndir)
else
HandleDirChange()
endif
endif
end sub
sub fast_ StartMaggots()
local
int id, id2
endlocal
restoredata BBoxXY
for id = 1 to MaggotStart loop
input data BBoxXY, mx, my, mx2, my2, dir
if id <> MaggotStart then
input data BBoxXY, turndir
endif
endfor
if dir = left then
mvx = -v mvy = 0
elsif dir = right then
mvx = v mvy = 0
elsif dir = up then
mvx = 0 mvy = -v
elsif dir = down then
mvx = 0 mvy = v
endif
Timeline_Timer 100,100
CreateSprite MaggotSprite, mx*2, my*2, looped, 0, astep, MaggotBank, [dir+0,dir+1,dir+2,dir+3,dir+4,dir+5,dir+6,dir+7]
SetSpriteFlags MaggotSprite, enabled|visible, bound
SpriteBBox MaggotSprite, mx*2, my*2, (mx2-mx)*2, (my2-my)*2
SpriteMechanics MaggotSprite, mvx,mvy,0,0,0
SpriteCollision MaggotSprite, 0, 0, [31], []
on_sprite_collision id, id2, { HandleCollision() }
on_sprite_animstop id, { HandleStop() }
endsub
int TextureLoadCount
sub GetTexture( f as filename )
local
int dummy
endlocal
print "GetTexture ", f, '\n'
if MazeRemoteRoot == "no remote root" then
TextureLoadCount++
else
saveimage 1280,960,0,0, jpg, filename(MazeRemoteRoot) + f + `.jpg`, InstallDir + f + `.bmp`, dummy, {
TextureLoadCount++
}
endif
end sub
function GetFile( f as filename ) as boolean
print "GetFile ", f, '\n'
if MazeRemoteRoot == "no remote root" then
return false
else
return FileCopy ( filename(MazeRemoteRoot) + f, InstallDir + f ) = 0
endif
end function
sub CheckAndLoadFiles()
local
int i, TextureNeedCount
filename f
string l
boolean b
filename sd
end local
TextureLoadCount=0
TextureNeedCount=0
//ensure sub-directories exist
sd = InstallDir + filename("/" + SoundDir)
mkdir( sd )
mkdir( InstallDir + filename("/" + TextureDir) )
mkdir( InstallDir + filename("/" + ObjectDir) )
//ensure sound sub-directories exist
mkdir( sd + `\circuit` )
mkdir( sd + `\iceage` )
mkdir( sd + `\medieval` )
mkdir( sd + `\metallic` )
mkdir( sd + `\organic` )
//ensure we have stock objects
for i = 0 to 10 loop
f = filename(ObjectDir + '/' + "stock" + itostr(i) )
if not checkfile ( InstallDir + f + `.bmp`, exists ) then
TextureNeedCount++
GetTexture( f )
else
print "Have ", f, '\n'
end if
end for
// get maze textures
for i = 0 to high(TextureList) loop
//chop off .bmp extension
TextureList[i] = left$(TextureList[i], len(TextureList[i])-4)
f = filename(TextureDir + '/' + TextureList[i])
if TextureUsage[i] then
if not checkfile ( InstallDir + f + `.bmp`, exists ) then
TextureNeedCount++
GetTexture( f )
else
print "Have texture ", f, '\n'
end if
endif
end for
//get maze objects and textures
for i = 0 to high(Object3dList) loop
if Object3dUsage[i] then
f = filename(ObjectDir + "/" + Object3dList[i] + ".txt")
if checkfile ( InstallDir + f, exists ) then
b = true
print "Have object texture list ", f, '\n'
else
b = GetFile( f )
end if
if b then
open InstallDir + f for read as #1
while not feof(#1) loop
l = inputline$(#1)
if len(l) > 2 then
if l <> "notextures" then
l = left$( l, len(l)-4 ) //lose the .bmp
f = filename(ObjectDir + "/" + l)
if not checkfile ( InstallDir + f + `.bmp`, exists ) then
TextureNeedCount++
GetTexture( f )
else
print "Have object texture ", f, '\n'
end if
end if
end if
end while
close #1
endif
f = filename(ObjectDir + "/" + Object3dList[i] + ".3ds")
if not checkfile ( InstallDir + f, exists ) then
GetFile( f )
else
print "Have object ", f, '\n'
end if
endif
end for
//get specific sounds
if SoundEffectFlags & 1 then
f = filename(SoundDir + "/" + OooffSound)
if not checkfile ( InstallDir + f, exists ) then
if not GetFile( f ) then
SoundEffectFlags &= ~1
endif
else
print "Have sound ", f, '\n'
endif
OooffSound = string(InstallDir + f)
endif
if SoundEffectFlags & 2 then
f = filename(SoundDir + '/' + BackgroundMIDI)
if not checkfile ( InstallDir + f, exists ) then
if not GetFile( f ) then
SoundEffectFlags &= ~2
endif
else
print "Have sound ", f, '\n'
endif
BackgroundMIDI = string(InstallDir + f)
endif
if SoundEffectFlags & 4 then
f = filename(SoundDir + '/' + CollectSound)
if not checkfile ( InstallDir + f, exists ) then
if not GetFile( f ) then
SoundEffectFlags &= ~4
endif
else
print "Have sound ", f, '\n'
endif
CollectSound = string(InstallDir + f)
endif
if SoundEffectFlags & 8 then
f = filename(SoundDir + '/' + FinishSound)
if not checkfile ( InstallDir + f, exists ) then
if not GetFile( f ) then
SoundEffectFlags &= ~8
endif
else
print "Have sound ", f, '\n'
endif
FinishSound = string(InstallDir + f)
endif
while TextureLoadCount <> TextureNeedCount loop
print TextureNeedCount - TextureLoadCount, '\n'
wait 100
endwhile
end sub
initcode as int
int dummy, flag
int SCX, SCY
int id
int bx
string bonusstr, message
string cddrives
endlocal
BrowserSetCursorBusy true
wait 100
ShowBrowserWindow FULLSCREEN
//TvmlDir = filename( GetInfo(InstallDir) )
//InstallDir = TvmlDir + MazeDir
//check for cd-rom drive
cddrives = GetInfo( CDROMS )
if len(cddrives) > 0 then
//check for more than 1 cd-rom drive
if len(cddrives) > 3 then
cddrives = left$(cddrives, 3)
endif
if MazeLocalCDRoot <> "no local CD root" then
// SetReadOnlyCache enabled, filename(cddrives+MazeLocalCDRoot), `/web/`
// SetReadOnlyCache enabled, filename(cddrives+MazeLocalCDRoot), `/`
SetReadOnlyCache disabled, ``, ``
else
SetReadOnlyCache disabled, ``, ``
end if
else
SetReadOnlyCache disabled, ``, ``
end if
//TvmlDir = filename( GetInfo(InstallDir) )
//InstallDir = TvmlDir + MazeDir
InstallDir = filename(cddrives) + MazeDir
init()
SCX = GetSystemMetrics(SM_CXSCREEN)
SCY = GetSystemMetrics(SM_CYSCREEN)
WindowX = ((SCX-640)/2 + 188)
WindowY = ((SCY-480)/2 + 22)
WindowW = (608-188)
WindowH = (393-22)
WindowRX = 188*2
WindowRY = 22*2
print "Maze start\n"
activepage 1
if not checkfile( InstallDir + `int2.jpg`, exists ) then
GetFile ( `int2.jpg` )
endif
loadimage 0,0,1280,960, jpg, InstallDir + `int2.jpg`
flag = 1
spritebank 1
if not checkfile( InstallDir + `sprites.gif`, exists ) then
GetFile ( `sprites.gif` )
endif
spritefile gif, InstallDir + `sprites.gif`
activepage 0
clearscreen 0,0,1280,960, standard, 1, 255
start_text = GetNextObjectID()
pencolor 0,0,0
text 640,380,"Bitte habt etwas Geduld!"
text 640,480,"Das Spiel wird geladen."
end_text = GetNextObjectID()
InitFile = GetInfo( CommandLine )
InitFile = tidy$(InitFile, ltrim|rtrim)
if len(InitFile) > 0 then
if not LoadMaze( InitFile, 0 ) then
print "Failed to load maze\n"
BrowserExit
endif
if CheckError != 0 then
print "Warning: Maze has errors\n"
// return false
endif
MazeFilename = InitFile
while flag = 0 loop
wait 50
end loop
elseif checkfile( InstallDir + `mazerun.ini`, readable ) then
open InstallDir + `mazerun.ini` for read as #1
InitFile = inputline$(#1)
close #1
InitFile = global_select
if InitFile = "" or not LoadMaze( InitFile, 0 ) then
while flag = 0 loop
wait 50
end loop
BrowserSetCursorBusy false
flag = 0
InitFile = ".maz"
id = GetNextObjectID()
editbox 0,0,400,60, enabled, InitFile, {
BrowserSetCursorBusy true
if LoadMaze( InitFile, 0 ) then flag = 1 endif
}
button 400,0,60,60,"Quit", enabled, none, { BrowserExit }
SetProperty id, "SetFocus"
while flag = 0 loop
hold
end loop
DeleteObject id
DeleteObject id+1
else
while flag = 0 loop
wait 50
end loop
endif
endif
CheckAndLoadFiles()
DefineScoreAndTimeSprites()
SetupEventHandlers()
LoadMaggots()
initcode = InitRw("My Window", WS_popup,
WindowX, WindowY, WindowW, WindowH, WindowW, WindowH )
GridOriginX = 190*2
GridOriginY = 22*2
if initcode > 0 then
print "InitRw() failure code ", initcode, "\n"
else
if initcode = -1 then
print "Display not running in a native RenderWare depth of 8 or 16 bits\n"
endif
LocalInitDoneRw
if ! Local3DInit( InstallDir ) then
print "Local3DInit() failed\n"
WinClose
else
BrowserSetCursorBusy false
WinSetTimer 1, TimerTick
TimerActive = true
if SoundEffectFlags & 2 then
audio mid, filename(BackgroundMIDI)
endif
hotspot 0,0,40,40,enabled, { quit = true }
hotspot 56,30,274,268,enabled, { quit = true }
StartMaggots()
/* That's it ! */
forc(del_text=start_text;del_text<end_text;del_text++)
deleteobject del_text
print "start the maze now"
EndReached = false
quit = false
OutOfTime = false
// Windows messages get lost without this
loop
if EndReached or OutOfTime or quit then
WinClose
endif
if TimerActive then
null
else
wait 100
endif
until destroyed
endif
endif
off_sprite_drop
pencolor 0 160 220
SetColourFill 0 160 220
rectangle WindowRX WindowRY WindowW*2 WindowH*2
if EndReached then
pencolor 0,0,0
if MazeTime > 0 then
input data Messages[BonusMessage+language], message
bonusstr = print ( using message, MazeTime*10 )
ShowScore( MazeTime*10 )
else
bonusstr = ""
endif
input data Messages[ScoreMessage+language], message
bonusstr += print ( using message, score )
input data Messages[WellDoneMessage+language], message
label 0, WindowRX, WindowH+WindowRY, WindowW*2, 300, center, message + bonusstr
if SoundEffectFlags & 8 then
audio wav, filename(FinishSound)
endif
wait 4000
elsif OutOfTime then
pencolor 0,0,0
input data Messages[BadLuckMessage+language], message
label 0, WindowRX, WindowH+WindowRY, WindowW*2, 300, center, message
wait 4000
endif
if not quit then
on_event keyup, scx, scy, { quit = true }
on_event mouseclick, scx, scy, { quit = true }
while not quit loop
hold
endwhile
endif
pencolor 0,0,0
script InstallDir + `frontend.tvm`