There are 18212 lines of code (all world information, dialogue, items, abilities, etc. are in notepad scripts). I'll post the first 800 lines of code here so you can see what it looks like. Terrain uses matrices, which is kind of a pain to code around. If anyone is interest in some extra lager lucre or liquor lolly, bourbon bucks, or slizzard spondoolies, contact me (but seriously, you could make a real income from this).
`Main game loop.
do
if newGame=1
newGame = 0
for i = 1 to 5000
objAITarget(i,map) = 0 `Reset all targets for a new game.
for i2 = 0 to 3
objDest#(i,i2,map) = -1 `Reset AI destinations also.
next i2
selectedObj = 0
sourceObj = 0
sourceObj2 = 0
lastObj = 0
next i
endif
if stopCombat=1 `Stop combat script command.
stopCombat = 0
for i = 1 to numObj
if objType(i,map)=4
objAITarget(i,map) = 0
objDest#(i,0,map) = -1
objDest#(i,1,map) = -1
objDest#(i,2,map) = -1
endif
next i
endif
if FRAMERATE$="smooth" `Function intervals on smooth framerate.
smooth = smooth+1
if smooth>1 then smooth = 0
else
smooth = 0
endif
for i = 1 to numObj `Object functions.
t = objType(i,map)
if object exist(i)=1 and debugMode=0 and (t<>1 or objName$(i,map)<>"")
if t>2 and objGravCheck(i)=0 then gravity(i)
if breakGameLoop=1 then goto STARTGAME
objectChecks(i) `Basic checks for all objects.
if breakGameLoop=1 then goto STARTGAME
if t=4 and isDead(i)=0
sentientChecks(i) `Sentient object checks.
if breakGameLoop=1 then goto STARTGAME
if i<>playerObj and smooth=0
if objAITarget(i,map)>0
tempSentTarg = tempSentTarg+1
if disableAI=0 then sentientAI(i)
else
`Crowded maps have shorter passive AI range.
if disableAI=0
maxDist = 4500 - (numSent*100) - (numSentTarg*200)
if maxDist<1200 then maxDist = 1200
AIDist = maxDist
pDist = getDistance(playerObj,i)
if pDist<maxDist
AIChance = 0
if numSent>=35 then AIChance = 1
if numSent>=40 then AIChance = 2
if numSent>=50 then AIChance = 3
if AIChance=0
sentientAI(i)
else
if rnd(AIChance)=1
sentientAI(i)
endif
endif
endif
endif
endif
if breakGameLoop=1 then goto STARTGAME
endif
endif
endif
next i
numSentTarg = tempSentTarg `Number of sentient objects with a target.
tempSentTarg = 0
mapChange = 0
if smooth=0 then raiseWater() `Smoothly raise/lower water level.
if breakGameLoop=1 then goto STARTGAME
if playerObj>0 then playerInput() `Check for player's input.
if breakGameLoop=1 then goto STARTGAME `Restart the game after gameover, etc.
updateScreen() `Draw HUD and update screen.
changeAmbience() `Switch between indoor/outdoor ambience.
if keyRelease>0 `Check for key release.
keyPress = 0
for i = 4 to 14
if keystate(GAMEKEYS(i))>0 then keyPress = 1
next i
if mouseclick()=0 and keyPress=0 then keyRelease = 0
endif
if smooth=0 then ticker = ticker+1
if ticker>=97 `Map script (about every 3 seconds).
ticker = 0
if debugMode=0 then script(0,mapScript$(map),1)
endif
if ticker=50 and debugMode=0 `Player checks script (3 seconds).
script(playerObj,"playerChecks",1)
endif
if breakGameLoop=1 then goto STARTGAME
if ticker=64 `Automatically regroup team.
if partyFollow=2 and objFall#(playerObj)=0
regroupParty(0)
endif
msg("") `Scroll game messages.
endif
DONEMAIN:
loop
function syncScreen():
`Sync the screen.
sync
endfunction
function loadSettings():
`Load settings from INI file.
open to read 1,"Settings.ini" `Load INI file settings.
read string 1,l1$ `Resolution (0 to 3).
read string 1,l2$ `Window Mode (0 to 2).
read string 1,l3$ `Texture Filter (0 or 1).
read string 1,l4$ `Editor Mode (0 or 1).
read string 1,l5$ `Framerate/Game Speed (0 to 3).
read string 1,l6$ `Menu Music Volume (0 to 3).
read string 1,l7$ `Menu Sound Volume (0 to 3).
close file 1
resolution = val(l1$)
windowed = val(l2$)
colorDepth = val(l3$)
worldEditor = val(l4$)
menuFramerate = val(l5$)
menuMusic = val(l6$)
menuSound = val(l7$)
if resolution<0 then resolution = 0
if resolution>6 then resolution = 6
if windowed<0 then windowed = 0
if windowed>2 then windowed = 2
if colorDepth<0 then colorDepth = 0
if colorDepth>1 then colorDepth = 1
if worldEditor<0 then worldEditor = 0
if worldEditor>1 then worldEditor = 1
if menuFramerate<0 then menuFramerate = 0
if menuFramerate>3 then menuFramerate = 3
if menuMusic<0 then menuMusic = 0
if menuMusic>3 then menuMusic = 3
if menuSound<0 then menuSound = 0
if menuSound>3 then menuSound = 3
if demoVersion>0
resolution = 0
windowed = 0
endif
if resolution=1 then set display mode 1280,960,32,0,0,0
if resolution=2 then set display mode 1280,1024,32,0,0,0
if resolution=3 then set display mode 1600,900,32,0,0,0
if resolution=4 then set display mode 1600,1200,32,0,0,0
if resolution=5 then set display mode 1920,1080,32,0,0,0
if resolution=6 then set display mode 1920,1200,32,0,0,0
if windowed=2 then set window off
if windowed=0
set window layout 0,0,0
set window size desktop width(),desktop height()
endif
set window title "Brigand Engine"
set window position 0,0
make memblock 1,10000
window to front
load dll "SC_Collision.dll",1
load dll "SteamPlugin.dll",2
load dll "Steam_api.dll",3
load dll "D3DFunc.dll",4
randomize timer()
disable escapekey
d3d_init
steam init
steam update
endfunction
function declarations():
`All system and variable declarations.
`System variables.
global breakGameLoop `If 1, game loop stops running and return to main menu.
global disableRegroup `If 1, party regroup is automatically disabled.
global smooth `If 1, some functions only happen every other tick.
global currentStory$ `Name of current story (not including file extension).
global scene$ `Name of background menu currently loaded.
global stopCombat `If 1, stop all AI targets and destinations.
global map `Currently active map (1-50).
global numImages `Number of currently loaded images.
global numObj `Number of objects on the currently-loaded map.
global numSent `Number of sentient objects on map.
global numSentTarg `Number of sentient objects on map with a target.
global numAnims `Number of 2D animations currently playing.
global numSkills `Number of skills (1=more than 7, enable 2nd window).
global AIDist `AI distance (based on number of sentients and combatants).
global playerObj `Object ID of player.
global selectedObj `Object ID centered in player's screen.
global selectedObjDebug `Object ID centered in screen in debug mode.
global groundObj `Object ID for the floor after onGround function.
global lastObj `Object ID of the previous selectedObj.
global triggerObj `Object ID that caused the script to start.
global sourceObj `Object ID that initiated currently-running script.
global sourceObj2 `Object ID for second source object for explosive barrels, etc.
global ladderObj `Object ID of ladder player is currently climbing (0=none).
global newGame `If 1, reset some variables for a new game.
global playerAcc `Player acceleration for smooth movemet.
global money `Money held by player.
global headShotBon `Headshot damage multiplier.
global ticker `Timer for running map scripts.
global debugMode `If 1, game is currently in World-Editor mode.
global mainMenu `If 1, game is in the very first menu scene.
global keyRelease `If 1, player must release selection key.
global hideHUD `If 1, HUD is temporarily hidden until main menu accessed again.
global rain `Amount of raindrops falling on screen (0 to 100).
global thruWood `Used in LOS function to lower damage through wood/animal objects.
global keyDelay `Key delay for player command intervals.
global infoScreen `0=Skills#1,1=Skills#2,2=Resistances.
global cUp `Is the screen currently in close-up mode (1=yes)?
global windowMsg$ `The help messages in the window screen.
global waterLvlDest# `Destination for water level (for gradual rising or draining).
global infrared `Keeps track of infrared vision for shading objects.
global lastInfra `Keeps track of last infrared setting for processing.
global lastRain `Keeps track of last rain setting for processing.
global lastWater `Keeps track of last underwater camera status for processing.
global lastOutside `Keeps track of last indoor/outdoor status for processing.
global lastTarget `Keeps track of player's last target for target window.
global chapter `Current chapter (determines loading screen).
global points `Skill points possessed by player.
global selectedAbility `Keep track of the last ability used (for cheesey players).
global curAnim `Last anim created (for script commands).
global zoom `If 1, player is currently zoomed in.
global distLOS# `Distance returned in line of sight function.
global selectedPlayer `Selected party member (0 to 3).
global partyFollow `0=Hold, 1=Defend, 2=Follow Player.
global partyTeleport `Temporary variable for party teleport.
global winClose1 `Message window in the middle of closing animation.
global winClose2 `Target window in the middle of closing animation.
global command$ `The next three globals are used in the script functions.
global response$ `Player response for window and inputwin commands (string).
global lastResp$ `Save previous entries in input windows for reentry.
global editorInfo `Info displayed in world editor at top left corner.
global val1$ `For the edit function.
global val2$ `For the edit function.
global value$ `For the edit function.
global headShot `Set in LOS function (1=damage multiplier, player only).
global reloading `Set in reload function for gun kickback delay (player only).
global recoilAngle `Set in shoot function to randomize Y angle (player only).
global minigameBonus `Bonus skill points in minesweeper minigame (3 per chapter).
global damagePlane `Colored plane, displayed when player is damaged.
global damagePlaneT `Type of damage of current damage plane.
global camShake `Camera shake from explosions, etc.
global camShakeLast `Last direction of cam shake to prevent repeat.
global camLanding `Bob camera down a bit after a big fall.
global targetGround `Set to 1 if currently-selected item is at player's feet.
global disableAI `Set to 1 if AI is disabled (by advanced world editor).
global storyReal$ `Real story name (for when it's temp set to "default").
global origVol1$ `For resetting the music volume after loading a game.
global origVol2$ `For resetting the ambience volume after loading a game.
global tip$ `For loading screen display.
dim variable(500) `Game variables for storyline scripts (-9999 to 9999).
dim collisionChk(5000) `Imperitive for sentient collision.
dim pausedObj(5000) `Keep track of object animations when paused for menus.
dim imageFile$(9999) `Currently loaded image filenames (no duplicates).
dim soundName$(500) `Names of all loaded sounds (500 sound effects max).
dim partyMembers(3) `Party members (0 thru 3, 0 is default player).
dim message$(3) `The messages displayed in screen.
dim choices$(6) `Choices for the window function (set with script commands).
dim choicePic$(6) `Picture that displays in bottom-right of message window.
dim lines$(6) `For dividing window text into smooth lines.
dim tracers(20) `For graphical bullet tracers (no gameplay effect, 20 max).
dim factReact(6) `Reaction of factions towards player.
dim ailmentTut(9) `Player has seen description of ailemtns.
dim distrib(13) `Character creation skill point distributions.
dim maxDist(13) `Maximum skill player can upgrade to (at a given trainer).
dim newAb(99) `New abilities for initial character creation.
dim newItem$(99) `Keep track of new item names to display info.
dim objectives(99) `List of current objectives (1=listed).
dim characters$(19) `Names of saved characters for restore menu (10 max).
dim story$(19) `Names of stories in the story folder (10 max).
dim editPos#(2) `Position of editor cam (0=X,1=Y,2=Z).
dim cUpPos#(3) `Position of current camera close up (0=X,1=Y,2=Z,3=Angle).
dim invObj(9) `Used for teleporting inventory to another map.
dim fogDest(3) `Used for smooth changes in fog color and distance.
dim lastFog(3) `Keeps track of last fog change to speed up processing.
`Map variables.
dim mapName$(30) `Name of map (must be set to save map).
dim mapObjNum(30) `Number of objects on map.
dim mapShading(30) `Natural shading of all objects on map (0-100).
dim mapMusic$(30) `Filename of map music (minus file extension).
dim mapAmb$(30) `Filename of map ambient sound.
dim mapAmbIn$(30) `Filename of map ambient sound while indoors.
dim mapScript$(30) `Filename of map script (runs every 3 seconds).
dim mapSky$(30) `Texture filename of map skybox (without final number).
dim mapGround$(30) `Texture filename of map ground matrix.
dim mapCliff$(30) `Texture filename of map cliff matrix (impassable).
dim mapWater$(30) `Water texture filename on map.
dim mapWaterFlow(30,1) `Flow of water (0-50), (2nd dim: 0=X,1=Z).
dim mapWaterLvl#(30) `Water level of map.
dim mapFog(30,3) `Fog on map (2nd dim: 0=visibility,1=red,2=green,3=blue).
dim mapLinks(30,3) `Link to map at edge of map (2nd dim: 0=N,1=S,2=E,3=W).
dim mapGElev(30,50,50) `Elevation of ground matrix.
dim mapCElev(30,50,50) `Elevation of cliff matrix (impassable).
dim mapGTile(30,50,50) `Tiles of ground matrix (1-16).
dim mapCTile(30,50,50) `Tiles of cliff matrix (1-4).
`Animation plane variables.
dim animPic$(200) `BMP texture of animation.
dim animRadius(200) `Radius of animation area (and scale of anim object).
dim animLife(200) `Amount of frames this animation lasts.
dim animFrame(200) `Current frame of animation (max: 4x4=16).
dim animDamage(200) `Damage delt by entering anim area.
dim animDType(200) `Damage type dealt by entering anim area.
dim animAil(200) `Ailment inflicted by entering anim area.
dim animAilVal(200) `Amount ailment changed (negative for cure and resist).
dim animSpeed(200) `Speed at which anim follows target.
dim animDest#(200,2) `Animation destination coordinants.
dim animPos#(200,2) `Animation
dim animScript$(200) `Script run on anybody inside the anim's radius.
dim animHoming(200) `Target that anim will slowly follow (according to speed).
dim animParent(200) `Object that initiated the anim.
dim animGlued(200,1) `Object to which anim automatically glues (2nd dim: close).
dim animTemp(200) `Does anim dissipitate as soon as it hits a target?
dim animAngleXFix(200) `Fixed X angle for 2d animation (-1=face camera, default).
dim animAngleYFix(200) `Fixed Y angle for 2d animation (-1=face camera, default).
dim animCheck(200) `Temporary array for anim checks every frame.
`Object variables.
dim objTag$(5000,30) `Tag for object (model, scripts, default skin, etc.).
dim objName$(5000,30) `Name of 3d object.
dim objDesc$(5000,30) `Description of object (for the examine function).
dim objType(5000,30) `0=Normal,1=Passable,2=Usable,3=Obtainable,4=Sentient.
dim objHE(5000,30) `Current health of object (maximum is skill 0).
dim objME(5000,30) `Current meta of object (maximum is skill 1).
dim objSkin$(5000,30) `Texture id of 3d object, map loading only.
dim objIcon$(5000,30) `Icon of object if it's in player's inventory.
dim objMat$(5000,30) `Material of object, for special effects and scripts.
dim objAnim$(5000,30) `Filename of 2d animation effect when item is used.
dim objAquatic(5000,30) `Object can swim (not yet implemented).
dim objGovSkill(5000,30) `Number of governing skill (min/max crosshair size).
dim objTargType(5000,30) `Possible targets on use (0=other,1=self,2=option,3=none).
dim objGripLimb(5000,30) `Which limb number is the equipment glued to?
dim objHeadLimb(5000,30) `Which limb number rotates w/ XAngle?
dim objHideLimb(5000,6,30) `List of hidden limbs (can hide a maximum of 7 limbs).
dim objColSize(5000,1,30) `Size of collision box for sentients (0=width,1=height).
dim objCorpseBack(5000,30) `Distance corpse is knocked back for collision detection.
dim objFaction(5000,30) `Faction of allegiance used in AI function (see constants).
dim objUnarmed(5000,30) `1=Object uses attack animation only with unarmed attacks.
dim objFlying(5000,30) `1=Unaffected by gravity (mainly for baddies).
dim objEquip(5000,30) `Equipped inventory slot of this object (0-6).
dim objResist(5000,6,30) `Damage type percent modified (0=Normal,see constants).
dim objResistB(5000,6,30) `Current modifier of resistance (slowly moves towards 0).
dim objAilment#(5000,9,30) `Ailments (negative for resistance, slowly move towards 0).
dim objInv(5000,9,30) `Inventory slots of the object (0-9).
dim objInvCnt(5000,9,30) `Inventory count (objects with <1 durability and charges).
dim objSkills(5000,13,30) `Object's skills (see constants below for the list).
dim objSkillB(5000,13,30) `Current modifier of skill (slowly moves towards 0).
dim objAbility(5000,99,30) `1=Object possesses ability.
dim objZoom(5000,30) `Zoom magnification for weapon objects (examine key).
dim objBreath(5000,30) `How long object has been holding its breath.
dim objPolygon(5000,30) `1=Object uses polygon collision, not box collision (slow).
dim objEquipPos(5000,2,30) `Position correction for object's equipment.
dim objCamOverlay(5000,30) `Camera overlay if object is the player (0-3).
dim objAITarget(5000,30) `Object targets object ID for combat.
dim objAIFlee(5000,30) `Object will flee once health reaches this level.
dim objAIFollow(5000,30) `Object will follow this object ID when nothing else to do.
dim objAIGuard(5000,30) `Object will not move unless specifically ordered by script.
dim objAIStopAdv(5000,30) `Object will stop advancing towards target at this distance.
dim objDest#(5000,3,30) `Current destination (0=X,1=Y,2=Z,3=YAngle).
dim objAngle#(5000,2,30) `Angle of object (0=X,1=Y,2=Z).
dim objPivot#(5000,2,30) `Fixed default angle of object (after "fixpivot" command).
dim objPos#(5000,2,30) `Coordinants of object for map loading only (0=X,1=Y,2=Z).
dim objScale(5000,2,30) `Percent size of 3d object for map loading only.
dim objTexScale(5000,1,30) `Scale of object's texture (0=X,1=Y).
dim objDrawPri(5000,30) `If 1, object has priority when one overlapping another.
dim objLOSRadius(5000,30) `If >0, increase radius of unarmed LOS checks (rockets, etc.).
dim objFrameE(5000,9,30) `Ending frames of below task animations.
dim objFrameS(5000,9,30) `Starting frames of below task animations.
dim objFrame(5000,30) `Current object frame for non-sentients (open doors, etc.).
`Temp object variables.
dim objCross(5000) `Current diameter of crosshair (0=Precise,4000=Max).
dim objDelay(5000) `Time until object can jump, shoot, or be used again.
dim objFall#(5000) `Current fall distance (for fall damage), negative is jump.
dim objWait(5000) `How long object has stood still (for Meta regen).
dim objParent(5000) `The holder of this object.
dim objTask(5000) `0=Idle,1=Hit,2=Move,3=Attack,4=Fall.
dim objThrown(5000) `If 1, object ID is currently being thrown.
dim objBonus(5000) `Countdown for temporary object skill bonuses and ailments.
dim objFloor(5000) `Object ID of floor that object is standing on.
dim objSound(5000) `Sound number playing at each object (1 per object).
dim objHeadAng#(5000,2) `Head angles for idle sentient objects (0=task,1=Y,2=Z).
dim objGravCheck(5000) `If 1, object has already been checked for gravity.
dim objLastGhost(5000) `Keeps track of last concealment status for processing.
`NOTE: objGovSkill is also the damage type for sentient unarmed attacks (type 4).
`NOTE: objEquip is also the required Strength skill to carry an obtainable (type 3).
`NOTE: objUnarmed also determines whether obtainables can be unloaded to get ammo.
`NOTE: objBreath also determines whether obtainables can be used underwater.
`NOTE: camOverlay also determines if falling items collide with another (plates+trays).
`Game constants.
dim GAMEKEYS(14) `Key scancodes for the game's input (see below).
dim SKILLNAME$(13) `Names of sentient object skills.
dim FACTIONNAME$(6) `Names of factions.
dim DAMAGENAME$(6) `Names of damage types.
dim AILMENTNAME$(9) `Names of ailments.
dim AILMENTDESC$(9) `Message recieved when first inflicted with ailment.
dim AILMENTDAM(9,1) `Ailment damage every 3 seconds (2nd Dim: damage type).
dim AILMENTDRAIN(9) `Ailment meta drain every 3 seconds.
dim AILMENTINFRA(9) `Does ailment give infrared vision (1=yes)?
dim AILMENTCONFUSE(9) `Does ailment distort player's vision (1=yes)?
dim AILMENTGHOST(9) `Does ailment conceal player (1=yes)?
dim AILMENTPEN(9) `Which skill does the ailment lower?
dim AILMENTCURE#(9) `Amount ailment cures every 3 seconds (can be negative).
dim AILMENTMAX(9) `Maximum (negative minimum) of ailment amount.
dim SKILLDESC$(13) `Descriptions of all 14 skills.
dim ABILITYNAME$(99) `Names of skill-based abilities (up to 99).
dim ABILITYDESC$(99) `Descriptions of above abilities.
dim ABILITYSCRIPT$(99) `Script filename that ability initiates when used.
dim ABILITYCOST(99) `Ability's meta cost.
dim ABILITYREQ(99) `Required skill id and amount to learn ability.
dim ABILITYRANGE(99) `Ability's range in units.
dim ABILITYTARGT(99) `Possible targets on use (0=other,1=self,2=option,3=none).
dim ABILITYICON$(99) `Alternate ability icon.
dim OBJECTIVE$(99,1) `Objectives (0=title,1=description).
dim TIPS$(99) `Random 99 tips, displayed on loading screen.
global HEALTHNAME$ `Name of basic health attribute.
global METANAME$ `Name of basic meta attribute.
global MONEYNAME$ `Name of currency.
global POINTSNAME$ `Name of skill points (i.e. experience).
global AILMENTWIN$ `Caption for the player's status effect window.
global EQUIPWIN$ `Caption for the player's equipment window.
global SKILLSWIN$ `Caption for the player skills window.
global RESISTWIN$ `Caption for the player resistances window.
global UPGRADEWIN$ `Caption for the upgrade window.
global ABILITYWIN$ `Caption for the abilities window.
global PARTYWIN$ `Caption for the party member window.
global MINIGAME1WIN$ `Window caption for the minesweeper minigame.
global MINIGAME2WIN$ `Window caption for the hangman minigame.
global MINIGAME3WIN$ `Window caption for the Chinese dice minigame.
global STORYNAME$ `Name of original story file when new game was started.
global COMPASS$ `Display compass in upper-right?
global VOLMUS$ `Music volume ("off","low","mid","high").
global VOLEFF$ `Effects volume ("off","low","mid","high").
global INVERTY$ `Mouse Y Axis inverted ("off" or "on").
global ITEMDESC$ `Auto-show item description on pickup ("auto" or "examine").
global FRAMERATE$ `Frame rate ("normal", "fast", "ultra", or "smooth").
global FONTSIZE$ `HUD font size ("tiny","small","mid","large").
global MOUSESPEED$ `Mouse sensitivity (1 to 10).
GAMEKEYS(0) = 17 `Default keybindings.
GAMEKEYS(1) = 31
GAMEKEYS(2) = 30
GAMEKEYS(3) = 32
GAMEKEYS(4) = 57
GAMEKEYS(5) = 33
GAMEKEYS(6) = 42
GAMEKEYS(7) = 29
GAMEKEYS(8) = 18
GAMEKEYS(9) = 16
GAMEKEYS(10) = 15
GAMEKEYS(11) = 19
GAMEKEYS(12) = 45
GAMEKEYS(13) = 47
GAMEKEYS(14) = 56
VOLMUS$ = "high" `Default game settings.
VOLEFF$ = "high"
INVERTY$ = "off"
MOUSESPEED$ = "5"
FONTSIZE$ = "small"
ITEMDESC$ = "auto"
FRAMERATE$ = "normal"
COMPASS$ = "off"
STORYNAME$ = "default"
for i = 0 to 9
AILMENTPEN(i) = -1
next i
for i = 0 to 99
ABILITYREQ(i) = -1
next i
playerObj = 0
savedPlayer = 0
partyFollow = 2
curDir$ = get dir$()
d3d_font 1,"Arial Bold",10,0,0,1
set dir curDir$
`Load world's globals from this file.
if file exist("assets\" + STORYNAME$ + "\scripts\globals.bsl")=1
open to read 1,"assets\" + STORYNAME$ + "\scripts\globals.bsl"
else
open to read 1,"assets\default\scripts\globals.bsl"
endif
while file end(1)=0
read string 1,full$
parser(full$)
edit(selectedObj,command$,val1$,val2$)
endwhile
close file 1
endfunction
function screenSetup(new):
`Reset the basic screen properties and erase all images/sounds/objects.
`If parameter is set to 1, use settings from ini file (initial setup).
for i = 1 to 9999
if image exist(i)=1 then delete image i
imageFile$(i) = ""
next i
load image "assets\blank.dds",1 `Load blank default image.
c$ = "assets\" + STORYNAME$ + "\images\hud\compass.bmp"
if file exist(c$)=0 then c$ = "assets\default\images\hud\compass.bmp"
if file exist(c$)=1
load image c$,2
sprite 1,screen width()-40,40,2
set sprite 1,0,1
offset sprite 1,40,40
endif
numImages = 2
for i = 1 to 5400 `Delete all objects.
if object exist(i)=1 then delete object i
next i
for i = 1 to 10 `Delete all matrices.
if matrix exist(i)=1 then delete matrix i
next i
for i = 1 to 500 `Delete all sounds.
if sound exist(i)=1 then delete sound i
soundName$(i) = ""
next i
if music exist(1)=1 then delete music 1
if music exist(2)=1 then delete music 2
for i = 5001 to 5200 `Make preset animation planes.
make object plain i,1,1
ghost object on i
scale object texture i,0.25,0.25
set object transparency i,5
set object fog i,0
hide object i
next i
for i = 5201 to 5206 `Make sky plane objects (sky box).
make object plain i,12000,12000,1
set object texture i,2,0
set object fog i,0
set object light i,0
set object cull i,1
next i
yrotate object 5202,90
yrotate object 5203,180
yrotate object 5204,270
xrotate object 5205,90
xrotate object 5206,270
make object box 5207,0.1,0.1,20 `Make bullet calc object.
hide object 5207
sc_setupobject 5207,0,2
make object plain 5208,15000,15000,1 `Make the water level plane.
position object 5208,7500,0,7500
xrotate object 5208,90
set object fog 5208,0
set object diffuse 5208,rgb(255,255,255)
set object emissive 5208,rgb(255,255,255)
set object transparency 5208,1
scale object texture 5208,50,50
enable object zbias 5208,1,0
make object box 5209,10,10,10 `Placeholder for player's gun.
make object plain 5210,80,80 `Colored screen damage plane.
color object 5210,rgb(255,255,255)
disable object zdepth 5210
hide object 5210
set object ambient 5210,0
set object emissive 5210,rgb(0,0,0)
set object diffuse 5210,rgb(0,0,0)
set object fog 5210,0
ghost object on 5210,4
for i = 5211 to 5214
make object plain i,5000,5000 `Make 4 flat planes for each corner of terrain.
rotate object i,90,90,0
scale object texture i,50,50
set object texture i,0,1
set object ambient i,0
next i
make object box 5220,25,64,25 `Make a character collision box.
sc_setupobject 5220,0,2
hide object 5220
make object sphere 5221,100 `Make an anim collision sphere.
sc_setupobject 5221,0,1
sc_allowobjectscaling 5221
hide object 5221
make object box 5222,0.3,25,0.3 `Make 100 raindrop objects.
`make object box 5222,0.5,2,0.5 `Snowflake dimensions.
for i = 5222 to 5321
if i>5222 then clone object i,5222
color object i,rgb(150,150,255)
set object emissive i,rgb(150,150,180)
set object ambient i,0
set object fog i,0
ghost object on i,4
hide object i
next i
make object box 5322,0.3,2000,0.3 `Make outdoors testing box (for player only).
sc_setupobject 5322,0,2
make object box 5323,0.3,50,0.3 `Make raindrop collision box.
sc_setupobject 5323,0,2
hide object 5323
make object box 5324,100,100,20 `Make second bullet object for radius change.
sc_setupobject 5324,0,2
sc_allowobjectscaling 5324
hide object 5324
make object box 5325,100,100,100 `Make second collision box for big characters.
sc_setupobject 5325,0,2
sc_allowobjectscaling 5325
hide object 5325
for i = 5326 to 5345
make object box i,0.2,0.2,100 `Make 20 bullet tracer objects (yellow).
color object i,rgb(255,255,0)
set object emissive i,rgb(255,255,0)
set object ambient i,0
set object fog i,0
ghost object on i,4
hide object i
sc_setupobject i,0,2
next i
make matrix 1,5000,5000,50,50 `Make ground matrices.
for i = 3 to 6
make matrix i,5000,5000,50,50
next i
make matrix 2,5000,5000,100,100 `Make cliff matrices (higher poly than ground).
for i = 7 to 10
make matrix i,5000,5000,100,100
next i
position matrix 3,0,0,5000
position matrix 4,0,0,-5000
position matrix 5,5000,0,0
position matrix 6,-5000,0,0
position matrix 7,0,0,5000
position matrix 8,0,0,-5000
position matrix 9,5000,0,0
position matrix 10,-5000,0,0
for i = 1 to 10
set matrix i,0,0,0,2,0,1,1
set matrix texture i,2,1
update matrix i
next i
`Load the 10 default sounds (first check story assets, then default assets).
p$ = "assets\" + STORYNAME$ + "\sounds\"
if file exist(p$ + "select1.wav")=1
load sound p$ + "select1.wav",1
else
load sound "assets\default\sounds\select1.wav",1
endif
if file exist(p$ + "select2.wav")=1
load sound p$ + "select2.wav",2
else
load sound "assets\default\sounds\select2.wav",2
endif
if file exist(p$ + "dam3.wav")=1
load sound p$ + "dam3.wav",3
else
load sound "assets\default\sounds\dam3.wav",3
endif
if file exist(p$ + "dam4.wav")=1
load sound p$ + "dam4.wav",4
else
load sound "assets\default\sounds\dam4.wav",4
endif
if file exist(p$ + "dam5.wav")=1
load sound p$ + "dam5.wav",5
else
load sound "assets\default\sounds\dam5.wav",5
endif
if file exist(p$ + "dam6.wav")=1
load sound p$ + "dam6.wav",6
else
load sound "assets\default\sounds\dam6.wav",6
endif
if file exist(p$ + "dam7.wav")=1
load sound p$ + "dam7.wav",7
else
load sound "assets\default\sounds\dam7.wav",7
endif
if file exist(p$ + "money.wav")=1
load sound p$ + "money.wav",8
else
load sound "assets\default\sounds\money.wav",8
endif
if file exist(p$ + "fail.wav")=1
load sound p$ + "fail.wav",9
else
load sound "assets\default\sounds\fail.wav",9
endif
if file exist(p$ + "bonus.wav")=1
load sound p$ + "bonus.wav",10
else
load sound "assets\default\sounds\bonus.wav",10
endif
scale listener 0.6
if new=1
if menuFramerate=0 then FRAMERATE$ = "normal"
if menuFramerate=1 then FRAMERATE$ = "fast"
if menuFramerate=2 then FRAMERATE$ = "ultra"
if menuFramerate=3 then FRAMERATE$ = "smooth"
if menuMusic=0 then VOLMUS$ = "off"
if menuMusic=1 then VOLMUS$ = "low"
if menuMusic=2 then VOLMUS$ = "mid"
if menuMusic=3 then VOLMUS$ = "high"
if menuSound=0 then VOLEFF$ = "off"
if menuSound=1 then VOLEFF$ = "low"
if menuSound=2 then VOLEFF$ = "mid"
if menuSound=3 then VOLEFF$ = "high"
endif
flush video memory
sync rate 34
sync on
adjustVolume()
set image colorkey 0,0,0
draw to front
set text font "Arial Bold",204
set text size 14
font = 10
if FONTSIZE$="large" then font = 11
if FONTSIZE$="small" then font = 9
if FONTSIZE$="tiny" then font = 8
d3d_font 1,"Arial Bold",font,0,0,1
set gamma 255,255,255
set camera range 1,10392
set camera fov 68
set ambient light 100
hide light 0
fog on
fog distance 2000
hide mouse
if FRAMERATE$="ultra" or FRAMERATE$="smooth"
sync rate 66
else
if FRAMERATE$="fast"
sync rate 46
else
sync rate 34
endif
endif
syncScreen()
endfunction
function loadImage(filename$):
`Load an image and return index number (no duplicates).
if numImages>9998
msg("ERROR: Cannot load more than 9999 images.")
a = 0
exitfunction a
endif
a = 1
if filename$="" then exitfunction a `Return blank image.
f$ = "assets\" + STORYNAME$ + "\" + filename$ `Look in story assets folder.
if file exist(f$)=0
f$ = "assets\default\" + filename$ `Look in default assets folder.
if file exist(f$)=0 then exitfunction a `Return blank image.
endif
for i = 3 to numImages+1
if lower$(imageFile$(i))=lower$(f$) then exitfunction i
if imageFile$(i)=""
if colorDepth=1 or colorDepth=3
load image f$,i,1
else
load image f$,i,0
endif
imageFile$(i) = f$
numImages = i
exitfunction i
endif
next i
endfunction a
laughingcoyote.net