#====================================# # 8-Bit Contest 2008 Plotscript File # # Written by Aethereal & Wiz # # (Mostly Aethereal) # #====================================# include, plotscr.hsd include, jailbreak.hsi include, scancode.hsi define script( # Script definitions, in the old style out of habit and for organization 2, check_movement, none 3, shoot_gun, none 4, check_bullet_collision, none 5, check_gun, none 6, process_collision, 1, 0 7, update_ammo_lives_display, none 8, check_movement_type, none 9, check_menu, none 10, check_paths, none 11, process_caught, none 12, check_walls, 3, 0, 0, 0 13, item_pickup, none 14, cleanup_gun, none 15, box_processing, none 16, cleanup_movetype, none 17, cleanup_box, none 18, check_for_key, none 19, force_crawl, none 20, inventory_processing, none 21, intro, none 22, check_lasers, none 23, laser_switch_processing, none 24, pivot_processing, none 1000, main, none ) global variable( # Global variable definitions 1, check 2, ammo 3, lives 4, movetype 5, counter 6, counter_action 7, counter_on 8, forced_crawl 9, init 10, set_music 11, pivoting ) define constant( # Constant definitions -1, nil # I bet this will make at least one person groan or make them puzzled. I did this because I do most of my scripting nowadays in 0, walking # RGSS (RPG Maker XP), which is the Ruby programming language with a ton of libraries built in, and in Ruby "nothing" is 0, walk_shot # represented by "nil" (i.e. if variable == nil then (do stuff) for an undefined variable). So, this just makes my life easier. 1, crawling 1, crawl_shot 2, change_movetype 3, box_debug 4, move_box ) #=========================================== script, main, ( suspendplayer suspendobstruction # Suspend obstruction is needed for the engine, suspend player is so the player can't interfere too much if(init == false) then( # This if-then sets up lives, ammo, etc. at the beginning of the game. ammo := 6 lives := 5 getitem(0) counter_action := nil movetype := walking set debug keys disable (on) init := true ) while(true) do( # Main game loop wait(1) # Need this for it to not crash and burn if(counter_on) then( # The counter is used for several things to prevent the game from getting out of control increment(counter) ) if(counter == 1 && counter_action == move_box) then( # Squashes a bug if you held space/enter and entered a door that caused all the NPCs to stay counter_on := false # suspended forever! counter_action := nil counter := 0 resumenpcs ) if(counter == 2 && counter_action == change_movetype) then( # This squashes a bug involving walking while pressing Z cleanup_movetype # cleanup_movetype just turns the counter off ) if(counter == 2 && counter_action == box_debug) then( # Squashes a bug involved with holding space to move a box cleanup_box # Turns the counter off, sets walls up around the box (remember, obstruction is suspended) ) if(counter == 3) then( # Prevents wonky movement/crouching while shooting gun bugs. cleanup_gun # Sets the sprite back to normal, turns counter off, destroys gun sprite ) if(counter_on == false) then( # Sometimes the gun sprite wouldn't vanish; this ensures it does. destroynpc(2) ) if(currentmap <> 32 || currentmap <> 6) then( # Inside vent passageways, you can only crawl; the next two if-then blocks make this happen. forced_crawl := false ) if(currentmap == 32 || currentmap == 6) then( forced_crawl := true ) box_processing # The method that handles pushing boxes around check_movement # The method that moves the player when they hit a direction check_paths # The pathfinding method for the guards if(checktag(6) == false) then( # Sometimes the bullet sprite wouldn't get set back to the right tile; this ensures it does. setnpcposition(1, 0, 0) # Tag 6 is a tag that is on when the gun is being fired. This basically prevents rapid-fire. check_gun # The method that handles firing the gun. ) if(checktag(6) == true) then( check_bullet_collision # This checks to see if the bullet ran into something; enemy, wall, whatever. ) check_movement_type # Checks whether the player is walking or crawling. update_ammo_lives_display # Updates the display on-screen. check_menu # The method that does the menu. item_pickup # Initially intended for just ammo/item pickups, this really is run if you walk on any sort of important check_for_key # tile. check_lasers laser_switch_processing # These last three are just more checks. pivot_processing if(checktag(11) && currentmap == 1 && set_music == false) then( setambientmusic(song:blowuptricycleedited) set_music := true # Sets escape music used at the end game. ) ) ) #=========================================== script, check_paths, ( variable(npcid) check := false if(checktag(5)) then( # Prevents this from being run over and over and over if you get spotted. wait(1) exitreturning(0) ) for(npcid, 30, 35, 1) do( # NPCs 30-35 are designated for the guards on each map. This, therefore, loops through all those NPCs. if(npcdirection(npcid) == down) then( # We have to run a check based on the direction the guard is facing, and then check six tiles in the direction if(heroy(me) -- npcy(npcid) <= 6) then( # he is facing. if(herox(me) == npcx(npcid)) then( check := check_walls(npcid, npcdirection(npcid), heroy(me) -- npcy(npcid)) # check_walls sees if there's a wall or box blocking the guard's view. ) # If there isn't, then check gets set to true, if not, it gets set to false. ) ) if(npcdirection(npcid) == up) then( if(npcy(npcid) -- heroy(me) <= 6) then( if(herox(me) == npcx(npcid)) then( check := check_walls(npcid, npcdirection(npcid), npcy(npcid) -- heroy(me)) ) ) ) if(npcdirection(npcid) == left) then( if(npcx(npcid) -- herox(me) <= 6) then( if(heroy(me) == npcy(npcid)) then( check := check_walls(npcid, npcdirection(npcid), npcx(npcid) -- herox(me)) ) ) ) if(npcdirection(npcid) == right) then( if(herox(me) -- npcx(npcid) <= 6) then( if(heroy(me) == npcy(npcid)) then( check := check_walls(npcid, npcdirection(npcid), herox(me) -- npcx(npcid)) ) ) ) ) if(check) then( # If you got seen, then do all the stuff that happens when you get caught. settag(5, true) process_caught exitreturning(0) # I'm not sure if the exitreturning() is necessary here, but I put it in anyway. ) ) #=========================================== script, check_walls, npc, direction, distance, ( # This script is passed the NPC ID of the guard that may or may not have seen you, the direction he's facing, and how far it is (in tiles) from the player to the guard. # The for(tile, 1, distance, 1) do() blocks all check, in a direction, if any of the tiles between the guard and the player are walls that are also *not* marked with an A # vehicle tile. The A tile is used for walls that you can duck behind to avoid being seen with Z. If any of the tiles are walls, the method returns false. Otherwise, it checks # to see if there are any movable crates between the player and the guard with the for(i, 0, npccopycount(3)) do() block. If there are, it returns false. Next, it checks to # see if there are walled tiles that are also marked with A tiles. If so, it checks how the player is moving (walking or crawling). If crawling, it returns false, if walking, # it returns true (they were caught). Finally, if it sees no walls, it returns true. This is repeated for each direction. variable(tile) variable(i) variable(crawl_check) crawl_check := north wall + south wall + east wall + west wall + vehicle A if(direction == left) then( for(tile, 1, distance, 1) do( if(readpassblock(npcx(npc) -- tile, npcy(npc)) >> 0 && readpassblock(npcx(npc) -- tile, npcy(npc)) <> crawl_check) then( exitreturning(false) ) for(i, 0, npccopycount(3)) do( if(npcatspot(npcx(npc) -- tile, npcy(npc), get count) >> 0) then( exitreturning(false) ) ) if(readpassblock(npcx(npc) -- tile, npcy(npc)) == crawl_check) then( if(movetype == crawling) then( exitreturning(false) ) if(movetype == walking) then( return(true) ) ) if(readpassblock(npcx(npc) -- tile, npcy(npc)) == 0) then( return(true) ) ) ) if(direction == right) then( for(tile, 1, distance, 1) do( if(readpassblock(npcx(npc) + tile, npcy(npc)) >> 0 && readpassblock(npcx(npc) + tile, npcy(npc)) <> crawl_check) then( exitreturning(false) ) for(i, 0, npccopycount(3)) do( if(npcatspot(npcx(npc) + tile, npcy(npc), get count) >> 0) then( exitreturning(false) ) ) if(readpassblock(npcx(npc) + tile, npcy(npc)) == crawl_check) then( if(movetype == crawling) then( exitreturning(false) ) if(movetype == walking) then( return(true) ) ) if(readpassblock(npcx(npc) + tile, npcy(npc)) == 0) then( return(true) ) ) ) if(direction == up) then( for(tile, 1, distance, 1) do( if(readpassblock(npcx(npc), npcy(npc) -- tile) >> 0 && readpassblock(npcx(npc), npcy(npc) -- tile) <> crawl_check) then( exitreturning(false) ) for(i, 0, npccopycount(3)) do( if(npcatspot(npcx(npc), npcy(npc) -- tile, get count) >> 0) then( exitreturning(false) ) ) if(readpassblock(npcx(npc), npcy(npc) -- tile) == crawl_check) then( if(movetype == crawling) then( exitreturning(false) ) if(movetype == walking) then( return(true) ) ) if(readpassblock(npcx(npc), npcy(npc) -- tile) == 0) then( return(true) ) ) ) if(direction == down) then( for(tile, 1, distance, 1) do( if(readpassblock(npcx(npc), npcy(npc) + tile) >> 0 && readpassblock(npcx(npc), npcy(npc) + tile) <> crawl_check) then( exitreturning(false) ) for(i, 0, npccopycount(3)) do( if(npcatspot(npcx(npc), npcy(npc) + tile, get count) >> 0) then( exitreturning(false) ) ) if(readpassblock(npcx(npc), npcy(npc) + tile) == crawl_check) then( if(movetype == crawling) then( exitreturning(false) ) if(movetype == walking) then( return(true) ) ) if(readpassblock(npcx(npc), npcy(npc) + tile) == 0) then( return(true) ) ) ) ) #=========================================== script, check_movement, ( # A simple script that moves the player if you press a direction. I think this one is self explanatory. if(counter_on) then( # If you're shooting, changing movement type, etc. then you can't be walking also! exitreturning(0) ) if(keyispressed(key:DOWN) && heroiswalking(me) == false) then( if(pivoting == false) then( # The player can pivot by holding A. This makes sure they're not pivoting before moving them. walkhero(me, down, 1) ) if(pivoting == true) then( # If the player is pivoting, this pivots the sprite instead of moving them. setherodirection(me, down) ) ) if(keyispressed(key:UP) && heroiswalking(me) == false) then( if(pivoting == false) then( walkhero(me, up, 1) ) if(pivoting == true) then( setherodirection(me, up) ) ) if(keyispressed(key:LEFT) && heroiswalking(me) == false) then( if(pivoting == false) then( walkhero(me, left, 1) ) if(pivoting == true) then( setherodirection(me, left) ) ) if(keyispressed(key:RIGHT) && heroiswalking(me) == false) then( if(pivoting == false) then( walkhero(me, right, 1) ) if(pivoting == true) then( setherodirection(me, right) ) ) ) #=========================================== script, check_gun, ( # The gun is mapped to the X key on the keyboard. First, the game sees if you have any ammo; if not, the method exits. Next, the game checks to see if you're walking. If you # are, the method exits. Finally, the game checks if you're in forced crawling mode (inside a vent). If you are, the method exits; we don't want players accidentally wasting # shots in the vents. The game has to check the movetype because different sprites are used for shooting while walking and shooting while crawling. Finally, the game gets the # player's direction and sets up the bullet sprite one tile forward of the player, and places a gun sprite in the player's hands (NPC ID 2). Finally, the game subtracts one # bullet from your ammo total and sets on tag 6. if(keyispressed(key:X)) then( if(ammo == 0) then( exitreturning(0) ) if(heroiswalking(me)) then( exitreturning(0) ) if(forced_crawl) then( exitreturning(0) ) counter := 0 counter_on := true if(movetype == walking) then( counter_action := walk_shot ) if(movetype == crawling) then( counter_action := crawl_shot ) if(soundisplaying(sfx:gunshot)) then(stopsound(sfx:gunshot)) playsound(sfx:gunshot) if(herodirection(me) == down) then( setnpcposition(1, herox(me), heroy(me) + 1) setnpcdirection(1, down) setheropicture(me, 4) createnpc(2, herox(me), heroy(me), down) alternpc(2, npcstat:picture, 6) if(movetype == crawling) then( alternpc(2, npcstat:picture, 7) setheropicture(me, 5) ) ) if(herodirection(me) == up) then( setnpcposition(1, herox(me), heroy(me) -- 1) setnpcdirection(1, up) setheropicture(me, 4) createnpc(2, herox(me), heroy(me), up) alternpc(2, npcstat:picture, 6) if(movetype == crawling) then( alternpc(2, npcstat:picture, 7) setheropicture(me, 5) ) ) if(herodirection(me) == left) then( setnpcposition(1, herox(me) -- 1, heroy(me)) setnpcdirection(1, left) setheropicture(me, 4) createnpc(2, herox(me), heroy(me), left) alternpc(2, npcstat:picture, 6) if(movetype == crawling) then( alternpc(2, npcstat:picture, 7) setheropicture(me, 5) ) ) if(herodirection(me) == right) then( setnpcposition(1, herox(me) + 1, heroy(me)) setnpcdirection(1, right) setheropicture(me, 4) createnpc(2, herox(me), heroy(me), right) alternpc(2, npcstat:picture, 6) if(movetype == crawling) then( alternpc(2, npcstat:picture, 7) setheropicture(me, 5) ) ) ammo -= 1 setnpcspeed(1, 20) settag(6, true) ) ) #=========================================== script, check_bullet_collision, ( # This checks to see if a bullet hits a wall, box, guard, etc. First, we loop through all the guards with the for(npcid, 30, 35, 1) do() block. It then checks to see # if the bullet (NPC ID 1) is on the same tile as the guard. If so, it sets collided to true and processes the collision. Next, it checks the collided variable. If # it's false, the bullet is first moved one tile in the direction it's being fired. Then the game checks to see if there's a wall in the way, and if there is, the # bullet vanishes. wait(1) variable(npcid) variable(collided) collided := false for(npcid, 30, 35, 1) do( if(npcx(npcid) == npcx(1)) then( if(npcy(npcid) == npcy(1)) then( process_collision(npcid) collided := true ) ) ) if(collided == false) then( walknpc(1, npcdirection(1), 1) if(checknpcwall(1, npcdirection(1))) then( set tag(6, false) setnpcposition(1, 0, 0) ) ) ) #=========================================== script, process_collision, npcid, ( # This script is passed the ID of the NPC that got hit by the bullet. That NPC is first destroyed. Next, the bullet (NPC ID 1) is moved off-screen. Finally, the game # decides if an ammo boost is dropped or not by random chance. The npccopycount(0) == 0 check ensures that only one ammo boost can be on screen at once; otherwise, some # funky stuff will start to happen. In retrospect it wasn't necessary to have only one ammo boost appear at once, but I didn't want to run out of NPCs and I didn't have # time to change it later. variable(dropchance) variable(x) variable(y) x := npcx(npcid) y := npcy(npcid) settag(6, false) destroynpc(npcid) if(soundisplaying(sfx:enemydeath)) then(stopsound(sfx:enemydeath)) playsound(sfx:enemydeath) setnpcposition(1, 0, 0) dropchance := random(0, 9) if(dropchance <= 4) then( if(npccopycount(0) == 0) then( createnpc(0, x, y) ) ) ) #=========================================== script, update_ammo_lives_display, ( # This just shows a few strings to display ammo, lives, and inventory. Should be fairly self-explanatory. $1 = "Ammo: " $2 = "Lives: " $3 = "Inventory: " variable(i) for(i, 1, ammo) do( appendascii(1, 174) ) stringcolor(1, 1) stringcolor(2, 1) showstringat(1, 0, 0) appendnumber(2, lives) showstringat(2, 250, 0) appendascii(3, 175) if(checktag(8)) then( appendascii(3, 176) ) if(checktag(9)) then( appendascii(3, 177) ) if(checktag(10)) then( appendascii(3, 178) ) stringcolor(3, 1) showstringat(3, 0, 190) ) #=========================================== script, check_movement_type, ( # This handles the changing of movement type. There are two movement types: walking and crawling. When you're crawling, you move half as fast as you do when walking, # but you have to crawl under some walls to avoid being seen. The Z key toggles walking type. First, we run some checks: key Z is pressed, the counter is not on, the player # is not walking, and they're not in forced crawl mode. Then the game checks the movetype and switches the player to the other movetype by adjusting the movetype variable, # the player's speed, and the player's sprite. if(keyispressed(key:Z) && counter_on == false && heroiswalking(me) == false && forced_crawl == false) then( counter := 0 counter_on := true counter_action := change_movetype if(movetype == walking) then( movetype := crawling if(soundisplaying(sfx:standcrawl)) then(stopsound(sfx:standcrawl)) playsound(sfx:standcrawl) setherospeed(me, 2) setheropicture(me, 1) exitreturning(0) ) if(movetype == crawling) then( movetype := walking if(soundisplaying(sfx:standcrawl)) then(stopsound(sfx:standcrawl)) playsound(sfx:standcrawl) setherospeed(me, 4) setheropicture(me, 0) exitreturning(0) ) ) ) #=========================================== script, cleanup_movetype, ( # A clean-up script to shut off the counter after changing move type. counter := nil counter_on := false counter_action := nil ) #=========================================== script, check_menu, ( # This just loads up the main menu if you press ALT. if(keyispressed(key:ALT)) then( mainmenu ) ) #=========================================== script, item_pickup, ( # This script used to be much shorter, but in the interest of time I cluttered it up with any sort of thing that involves moving onto a specific tile to cause something to # happen. Therefore, it's used for a lot of things. The first if-then block is used for picking up ammo boosts that guards sometimes drop. NPC 0 is the ammo boost NPC. # The second and third ones are used for picking up two key items on the floor (the key and the crowbar). The final one is used to run the endgame scenes when you move # onto the correct tile at the end of the game. if(npcx(0) == herox(me) && npcy(0) == heroy(me)) then( playsound(sfx:itemget) ammo += 2 if(ammo >= 6) then( ammo := 6 ) destroynpc(0) ) if(npcx(11) == herox(me) && npcy(11) == heroy(me)) then( playsound(sfx:itemget) lives += 1 destroynpc(11) ) if(npcx(10) == herox(me) && npcy(10) == heroy(me) && currentmap == 27) then( playsound(sfx:itemget) showtextbox(11) waitfortextbox getitem(2, 1) settag(9, true) ) if(npcx(10) == herox(me) && npcy(10) == heroy(me) && currentmap == 20) then( playsound(sfx:itemget) showtextbox(10) waitfortextbox getitem(1, 1) settag(8, true) ) if(herox(me) == 17 && heroy(me) == 17 && checktag(11) && currentmap == 1) then( showbackdrop(0) hidestring(1) hidestring(2) hidestring(3) showtextbox(19) waitfortextbox showtextbox(20) waitfortextbox showtextbox(21) waitfortextbox showtextbox(22) waitfortextbox showtextbox(23) waitfortextbox showtextbox(24) waitfortextbox showtextbox(25) waitfortextbox showtextbox(26) waitfortextbox gameover ) ) #=========================================== script, cleanup_gun, ( # This cleans up the gun by destroying the gun sprite, fixing the player's sprite so it is back to walking/crawling, and turns off the counter. destroynpc(2) if(counter_action == walk_shot) then( setheropicture(me, 0) ) if(counter_action == crawl_shot) then( setheropicture(me, 1) ) counter := 0 counter_action := nil counter_on := false ) #=========================================== script, box_processing, ( # This is an extremely complicated script that handles box pushing. The reason this is needed is due to obstruction being off; you can just walk through boxes. Therefore, # in the editor, every box NPC is surrounded on all sides by walls and the walls are turned off and adjusted accordingly. Since this one is very complex, I'll comment it # as I go along instead of writing a big paragraph. # Again, in the interest of time, anything involving pressing ENTER/SPACE has been lumped into this script, including picking up items off tables, using the crowbar, and # triggering the alarm system. Those are later. variable(npc) variable(wall) variable(i) wall := northwall + southwall + eastwall + westwall # This is just for convenience's sake. if(keyispressed(key:ENTER) || keyispressed(key:SPACE)) then( if(npciswalking(3)) then( # Prevents holding of the key to move a box a very long way. exitreturning(0) ) if(npciswalking(1)) then( # No moving boxes while shooting the gun! exitreturning(0) ) counter_on := true counter := 1 counter_action := move_box suspendnpcs # Without this, it was very easy to move a box onto a guard and trap the guard # inside it forever. He could still see you, too, making it all the worse. for(i, 30, 35) do( # I didn't want to do it this way, but due to time constraints I had no choice. waitfornpc(i) ) if(herodirection(me) == up) then( if(getnpcid(npcatspot(herox(me), heroy(me) -- 1)) == 3) then( # This checks to see if there's a box (NPC 3) one tile above the player. npc := npcatspot(herox(me), heroy(me) -- 1) writepassblock(npcx(npc), npcy(npc), 0) # This kills the walls around the box. if(checknpcwall(npc, up) == false && npcatspot(npcx(npc), npcy(npc) -- 1, get count) == 0 && readpassblock(npcx(npc), npcy(npc) -- 1) <> vehicle B) then( # This long line checks to see if there is no NPC already on the tile the box is about to move to, # there's no wall in the way, and the tile to move to is not a B tile. B tiles are used to prevent walknpc(npc, up, 1) # the player from blocking up exits with boxes and getting stuck. if(soundisplaying(sfx:pushbox)) then(stopsound(sfx:pushbox)) playsound(sfx:pushbox) waitfornpc(3) ) if(npcatspot(npcx(npc), npcy(npc), get count) >> 1) then( counter_on := true counter := 0 counter_action := box_debug # More debugging for the box to keep a guy from being trapped on it. ) if(npcatspot(npcx(npc), npcy(npc), get count) == 1) then( writepassblock(npcx(npc), npcy(npc), wall) # Puts walls back around the box. ) ) ) if(herodirection(me) == down) then( # Repeat of the above, but for a different direction. if(getnpcid(npcatspot(herox(me), heroy(me) + 1)) == 3) then( npc := npcatspot(herox(me), heroy(me) + 1) writepassblock(npcx(npc), npcy(npc), 0) if(checknpcwall(npc, down) == false && npcatspot(npcx(npc), npcy(npc) + 1, get count) == 0 && readpassblock(npcx(npc), npcy(npc) + 1) <> vehicle B) then( walknpc(npc, down, 1) if(soundisplaying(sfx:pushbox)) then(stopsound(sfx:pushbox)) playsound(sfx:pushbox) waitfornpc(npc) ) if(npcatspot(npcx(npc), npcy(npc), get count) >> 1) then( counter_on := true counter := 0 counter_action := box_debug ) if(npcatspot(npcx(npc), npcy(npc), get count) == 1) then( writepassblock(npcx(npc), npcy(npc), wall) ) ) ) if(herodirection(me) == left) then( if(getnpcid(npcatspot(herox(me) -- 1, heroy(me))) == 3) then( npc := npcatspot(herox(me) -- 1, heroy(me)) writepassblock(npcx(npc), npcy(npc), 0) if(checknpcwall(npc, left) == false && npcatspot(npcx(npc) -- 1, npcy(npc), get count) == 0 && readpassblock(npcx(npc) -- 1, npcy(npc)) <> vehicle B) then( walknpc(npc, left, 1) if(soundisplaying(sfx:pushbox)) then(stopsound(sfx:pushbox)) playsound(sfx:pushbox) waitfornpc(npc) ) if(npcatspot(npcx(npc), npcy(npc), get count) >> 1) then( counter_on := true counter := 0 counter_action := box_debug ) if(npcatspot(npcx(npc), npcy(npc), get count) == 1) then( writepassblock(npcx(npc), npcy(npc), wall) ) ) ) if(herodirection(me) == right) then( if(getnpcid(npcatspot(herox(me) + 1, heroy(me))) == 3) then( npc := npcatspot(herox(me) + 1, heroy(me)) writepassblock(npcx(npc), npcy(npc), 0) if(checknpcwall(npc, right) == false && npcatspot(npcx(npc) + 1, npcy(npc), get count) == 0 && readpassblock(npcx(npc) + 1, npcy(npc)) <> vehicle B) then( walknpc(npc, right, 1) if(soundisplaying(sfx:pushbox)) then(stopsound(sfx:pushbox)) playsound(sfx:pushbox) waitfornpc(npc) ) if(npcatspot(npcx(npc), npcy(npc), get count) >> 1) then( counter_on := true counter := 0 counter_action := box_debug ) if(npcatspot(npcx(npc), npcy(npc), get count) == 1) then( writepassblock(npcx(npc), npcy(npc), wall) ) ) ) if(checktag(8) && currentmap == 24 && herox(me) == 5 && heroy(me) == 4 && herodirection(me) == up) then( # If the player's standing at the blocked vent, and they playsound(sfx:ventbreak) # press ENTER/SPACE with the crowbar, they break the settag(12, true) # vent. ) if(checktag(8) == false && currentmap == 24 && herox(me) == 5 && heroy(me) == 4 && herodirection(me) == up) then( # Indicates the need for a crowbar showtextbox(9) waitfortextbox ) if(npcx(10) == herox(me) && npcy(10) + 1 == heroy(me) && currentmap == 12) then( # This is for picking the keycard up off the desk on the first floor. playsound(sfx:itemget) showtextbox(12) waitfortextbox getitem(3, 1) settag(10, true) ) if(herox(me) == 25 && heroy(me) == 14 && herodirection(me) == up && checktag(10)) then( # This is for triggering the alarm system near the end of the game. settag(11, true) setambientmusic() showtextbox(18) waitfortextbox playsound(sfx:switchhit) wait(40) playsound(sfx:alert) showtextbox(17) suspendboxadvance wait(20) advancetextbox resumeboxadvance setherospeed(me,10) walkhero(me, down, 3) waitforhero(me) usedoor(4) ) if(herox(me) == 25 && heroy(me) == 14 && herodirection(me) == up && checktag(10) == false) then( showtextbox(14) waitfortextbox ) resumenpcs ) ) #=========================================== script, cleanup_box, ( # Just a script that cleans up the boxes, ensures they all have walls around them, turns off the counter...you've seen this before. variable(i) variable(wall) variable(npc) wall := northwall + southwall + eastwall + westwall for(i, 0, npccopycount(3)) do( npc := npcreference(3, i) writepassblock(npcx(npc), npcy(npc), wall) ) counter_on := false counter := 0 counter_action := nil ) #=========================================== script, process_caught, ( # This is what gets run when you're spotted by a guard, or you trip a laser. Most of this is self-explanatory, I think. suspendnpcs playsound(sfx:alert) suspendboxadvance showtextbox(1) wait(20) advancetextbox resumeboxadvance resumenpcs settag(5, false) if(lives <> 0) then( fadescreenout setherodirection(me,down) lives -= 1 if(ammo << 4) then( ammo := 4 ) movetype := walking setherospeed(me,4) setheropicture(me,0) counter := 0 counter_on := true counter_action := change_movetype wait(20) usedoor(0) exitreturning(0) ) if(lives == 0) then( if(soundisplaying(sfx:alert))then(stopsound(sfx:alert)) hidestring(1) hidestring(2) hidestring(3) suspendnpcs stopsong showbackdrop(0) $10 ="GAME OVER" stringcolor(10, 1) centerstringat(10,160,95) playsound(sfx:gameover) wait(100) hidestring(10) resumenpcs gameover ) ) #=========================================== script, check_for_key, ( # Unlike the other items, you don't press ENTER/SPACE to use the key; once you get it, all locked doors automatically open. This edits the tiles and walls on the # maps that have locked doors. if(checktag(9) && currentmap == 9) then( writemapblock(6, 7, 0, 1) writepassblock(6, 7, 0) ) if(checktag(9) && currentmap == 12) then( writemapblock(9, 5, 0, 1) writepassblock(9, 5, 0) ) if(checktag(9) && currentmap == 23) then( writemapblock(12, 12, 0, 1) writepassblock(12, 12, ) ) if(checktag(12) && currentmap == 24) then( writemapblock(5, 3, 133, 1) writepassblock(5, 3, 0) ) ) #=========================================== script, force_crawl, ( # In vents, the player is forced to crawl; after all, it is kind of hard to walk through those things. This forces the player to crawl by setting a variable true so that # they cannot change back to walking by pressing Z. forced_crawl := true counter := 0 counter_on := true counter_action := change_movetype movetype := crawling setherospeed(me, 2) setheropicture(me, 1) exitreturning(0) ) #=========================================== script, check_lasers, ( # The first floor has some trip lasers that sound an alarm if you move over one. They are assigned NPC IDs 26-29. This checks to see if you are on the same tile as a trip # laser, and if you are, you get caught. variable(npc) for(npc, 26, 29) do( if(herox(me) == npcx(npc) && heroy(me) == npcy(npc)) then( settag(5, true) process_caught ) ) ) #=========================================== script, laser_switch_processing, ( # The trip lasers can be turned off by pressing switches; this checks to see if you've moved over a switch. If you have, then the lasers get turned off. if(herox(me) == npcx(25) && heroy(me) == npcy(25)) then( if(checktag(15) == false) then( if(currentmap == 13) then( playsound(sfx:switch) settag(15, true) ) ) if(checktag(13) == false) then( if(currentmap == 15) then( playsound(sfx:switch) settag(13, true) showtextbox(15) waitfortextbox ) ) if(checktag(16) == false) then( if(currentmap == 16) then( playsound(sfx:switch) settag(16, true) ) ) if(checktag(14) == false) then( if(currentmap == 18) then( playsound(sfx:switch) settag(14, true) ) ) ) ) #=========================================== script, pivot_processing, ( # Pivoting is done by holding A and pressing the direction to pivot in. If the counter is on or the player is walking, you can't pivot. # If the game lets you pivot, then it just sets your speed to 0 and turns the pivoting variable on, which is used in the movement # script (it clears up a bug that caused the player sprite to walk in place while pivoting). If A is released, it re-sets the movement # speed back to normal based on the movement type. if(heroiswalking(me)) then( exitreturning(0) ) if(counter_on) then( exitreturning(0) ) if(keyispressed(key:A)) then( setherospeed(me, 0) pivoting := true ) if(keyispressed(key:A) == false) then( if(movetype == walking) then( setherospeed(me, 4) ) if(movetype == crawling) then( setherospeed(me, 2) ) pivoting := false ) ) #=========================================== script, intro, ( # Wiz wrote this. It just does the intro. suspendplayer walk npc(4,up,3) walk hero(me,up,3) walk npc(5,up,3) waitfornpc(4) waitforhero(me) waitfornpc(5) setnpcdirection(4,west) setherodirection(me,west) setnpcdirection(5,west) showtextbox(2) waitfortextbox showtextbox(3) waitfortextbox walknpc(6,8,9) waitfornpc(6) destroynpc(6) fadescreenout puthero(me,100,40) setherodirection(me,south) setnpcposition(4,10,2) setnpcdirection(4,east) setnpcposition(5,11,2) setnpcdirection(5,west) setnpcspeed(1,20) wait(5) fadescreenin showtextbox(4) waitfortextbox walknpc(4, left, 4) waitfornpc(4) showtextbox(5) waitfortextbox setherodirection(me,east) setheropicture(me,4) puthero(me,103,40) wait(1) puthero(me,106,40) wait(1) puthero(me,109,40) wait(2) playsound(sfx:falconpunch) wait(1) puthero(me,106,40) wait(1) puthero(me,103,40) wait(1) puthero(me,100,40) wait(1) createnpc(2, herox(me), heroy(me), right) wait(1) playsound(sfx:gunshot) destroynpc(4) wait(2) playsound(sfx:enemydeath) wait(20) if(soundisplaying(sfx:gunshot)) then(stopsound(sfx:gunshot)) playsound(sfx:gunshot) setnpcposition(1, herox(me) + 1, heroy(me)) wait(5) walknpc(5,left,1) walknpc(1,right,5) waitforall destroynpc(5) setnpcposition(1,0,0) if(soundisplaying(sfx:enemydeath)) then(stopsound(sfx:enemydeath)) playsound(sfx:enemydeath) wait(5) setnpcposition(2,0,0) wait(5) setheropicture(me,0) showtextbox(6) waitfortextbox showtextbox(13) playsound(sfx:itemget) waitfortextbox walkhero(me,right,3) waitforhero walkhero(me,down,7) waitforhero resumeplayer settag(17, true) usedoor(0) )