Seventh Shade, on 11 December 2010 - 11:53 AM, said:
Can I borrow that engine? My map starts out with no power until you manage to find a backup generator.
: "justentered"
load char set "ty-interior.chr"
load palette "ty-interior.pal"
loop start
set "BOARD_X" to "loopcount"
modulo "BOARD_X" by 80
set "BOARD_Y" to "loopcount"
divide "BOARD_Y" by 80
if "BOARD_CHAR" = 32 then "sk1"
put "('BOARD_CHAR'!=33*17)" '!' overlay to "BOARD_X" "BOARD_Y"
: "sk1"
loop for 1999
copy overlay block at 0 5 for 80 by 25 to "@light_temp.mzm" 1
: "l"
cycle 1
. "replace with playerx, playery. If using default player, uncomment next line:"
. "set pl_d (('playerfacedir'=3)*3+('playerfacedir'=0)*2+('playerfacedir'=2))"
if "(('pl_x'='local30')a('pl_y'='local31')a('pl_d'='local32'))" = 1 then "l"
set "local30" to "pl_x"
set "local31" to "pl_y"
set "local32" to "pl_d"
put "@light_temp.mzm" Image_file p01 at 0 5
. "flashlight"
set "C_DIVISIONS" to 120
set "local" to 6
set "local5" to "('C_DIVISIONS'/4*'local'-1)"
. "Pseudo code because the real code got obfuscated as fuck for performance"
. "ray goes for local distance and skips t=0"
. "1) set multiplier loopcount%local+1"
. "determine the starting angle of the light + increment for each ray"
. "2) set local2 (loopcount/local)+(pl_d*2+1/c_divisions/8)"
. "get x coordinate (x is flipped because Lancer made pl_d counterclockwise"
. "3) set board_x -cos(local2)+pl_x"
. "get y coordinate"
. "4) set board_y sin(local2)+pl_y"
. "5) collision checks"
. "make distance affect the intensity (the -4 is just tuning)"
. "6) set local3 board_color-multiplier-4"
. "7) put overlay, and then put above if it's a wall with a wall above it"
loop start
set "MULTIPLIER" to "loopcount"
modulo "MULTIPLIER" by "local"
inc "MULTIPLIER" by 1
set "local3" to "loopcount"
divide "local3" by "local"
set "local2" to "pl_d"
multiply "local2" by 2
inc "local2" by 1
multiply "local2" by "C_DIVISIONS"
divide "local2" by 8
inc "local2" by "local3"
set "BOARD_X" to "cos&local2&"
multiply "BOARD_X" by -1
inc "BOARD_X" by "pl_x"
set "BOARD_Y" to "sin&local2&"
inc "BOARD_Y" by "pl_y"
if "nearWall" = 1 then "checkForWall"
: "noWall"
if "BOARD_CHAR" = 32 then "fuck off"
if "BOARD_CHAR" = 33 then "#nearWall"
if "BOARD_ID" = 5 then "#nearWall"
if "BOARD_CHAR" = 33 then "sk3"
set "local3" to "BOARD_COLOR"
dec "MULTIPLIER" by 4
dec "local3" by "MULTIPLIER"
put "local3" "BOARD_CHAR" overlay to "BOARD_X" "BOARD_Y"
if "BOARD_ID" != 5 then "sk3"
dec "BOARD_Y" by 1
if "BOARD_CHAR" = 33 then "sk3"
put "local3" "BOARD_CHAR" overlay to "BOARD_X" "BOARD_Y"
: "sk3"
loop for "local5"
. "light surrounding player"
loop start
set "BOARD_Y" to "pl_y"
set "BOARD_X" to "pl_x"
if "(('loopcount'=6)a('BOARD_CHAR'=33))" = 1 then "stop surround"
set "BOARD_X" to "('loopcount'%3+'pl_x'-1)"
set "BOARD_Y" to "('loopcount'/3+'pl_y'-1)"
if "BOARD_CHAR" = 33 then "sk2"
put c?? ' ' overlay to "BOARD_X" "BOARD_Y"
: "sk2"
loop for 8
: "stop surround"
. "party members"
loop start
if "follow&loopcount&_i" = -1 then "sk4"
set "BOARD_X" to "follow&loopcount&_x"
set "BOARD_Y" to "follow&loopcount&_y"
if "BOARD_CHAR" = 33 then "sk4"
put c?? ' ' overlay to "BOARD_X" "BOARD_Y"
: "sk4"
loop for 2
. "27-28 13 -- this box ignores dynamic and is always yellow"
loop start
set "OVERLAY_X" to "('loopcount'+27)"
set "OVERLAY_Y" to 13
if "OVERLAY_COLOR" = 17 then "sk5"
put c?? ' ' overlay to "OVERLAY_X" "OVERLAY_Y"
: "sk5"
loop for 1
. "cleans up a lighting glitch"
change overlay c?a to c11
. "exit arrows"
write overlay c0f "" at 53 20
goto "l"
: "checkForWall"
dec "nearWall" by 1
if "BOARD_ID" != 5 then "noWall"
: "fuck off"
set "loopcount" to "('loopcount'/'local'+1*'local'-1)"
goto "sk3"
: "#nearWall"
set "nearWall" to 1
goto "#return"
The gradient occurs over colors 1-9. The spaces surrounding the player are displayed in their natural colors. You'll need to replace pl_x with playerx and pl_y with playery, and uncomment the line that translates playerfacedir to pl_d, if you're using it for your own game. Also, you'll probably have to change the overlay generating thing.