User File #43727354848359221

Upload All User Files

#43727354848359221 - Wolf3D Map Script (encode version)

Wolf3d-scriptencodereg.lua
918 downloads
Uploaded 12/13/2017 6:09 AM by slamo (see all 61)
This is the version of the Wolf3D map script I used to make the map encodes. The regular map script requires a refresh command, but this one updates automatically. Only works on the registered version.
dofile("textrender.lua");

mouse_vx = 0;
mouse_vy = 0;
mouse_deadzone = 8192
mouse_ysensitivity = 70;
mouse_xsensitivity = 70;
last_x = 0;
last_y = 0;
last_d = 0;
last_f = 0;
dx = 0;
dy = 0;
dd = 0;
wolfmap = {};
for i=0,4095,1 do
	wolfmap[i] = 0;
end
htable = {};
for i=1,150,1 do
	htable[i] = 0;
end
hstring = "";
rndtable = {0,   8, 109, 220, 222, 241, 149, 107,  75, 248, 254, 140,  16,  66, 74,  21, 211,  47,  80, 242, 154,  27, 205, 128, 161,  89,  77,  36, 95, 110,  85,  48, 212, 140, 211, 249,  22,  79, 200,  50,  28, 188, 52, 140, 202, 120,  68, 145,  62,  70, 184, 190,  91, 197, 152, 224, 149, 104,  25, 178, 252, 182, 202, 182, 141, 197,   4,  81, 181, 242, 145,  42,  39, 227, 156, 198, 225, 193, 219,  93, 122, 175, 249,   0, 175, 143,  70, 239,  46, 246, 163,  53, 163, 109, 168, 135,   2, 235, 25,  92,  20, 145, 138,  77,  69, 166,  78, 176, 173, 212, 166, 113, 94, 161,  41,  50, 239,  49, 111, 164,  70,  60,   2,  37, 171,  75, 136, 156,  11,  56,  42, 146, 138, 229,  73, 146,  77,  61,  98, 196, 135, 106,  63, 197, 195,  86,  96, 203, 113, 101, 170, 247, 181, 113, 80, 250, 108,   7, 255, 237, 129, 226,  79, 107, 112, 166, 103, 241, 24, 223, 239, 120, 198,  58,  60,  82, 128,   3, 184,  66, 143, 224, 145, 224,  81, 206, 163,  45,  63,  90, 168, 114,  59,  33, 159,  95, 28, 139, 123,  98, 125, 196,  15,  70, 194, 253,  54,  14, 109, 226, 71,  17, 161,  93, 186,  87, 244, 138,  20,  52, 123, 251,  26,  36, 17,  46,  52, 231, 232,  76,  31, 221,  84,  37, 216, 165, 212, 106, 197, 242,  98,  43,  39, 175, 254, 145, 190,  84, 118, 222, 187, 136, 120, 163, 236, 249};

while true do
	a, b = jpcrr.wait_event();
	if a == "lock" then
		jpcrr.hud.top_gap(3, 56);
		jpcrr.hud.right_gap(3, 512);
		jpcrr.hud.bottom_gap(3, 56);
		x = jpcrr.read_dword(0x0049256);
		y = jpcrr.read_dword(0x004925A);
		d = jpcrr.read_word(0x00049270);
		timer = jpcrr.read_word(0x47C06);
		rngindex = jpcrr.read_byte(0x27350);
		actors = jpcrr.read_byte(0x47302);
		custom = jpcrr.read_word(0x48886);
		drawtrigger = jpcrr.read_byte(0x3E005);
		f = jpcrr.frame_number();
		spd = math.sqrt(dx * dx + dy * dy)
		if f ~= last_f then
			dx = x - last_x;
			dy = y - last_y;
			dd = d - last_d;
			last_x = x;
			last_y = y;
			last_d = d;
			last_f = f;
		end
		if drawtrigger==1 then
			for i = 0,4095,1 do
				wolfmap[i] = jpcrr.read_byte(0x452C8+i);
			end
		end
		for i=0,4095,1 do
			tile = wolfmap[i];
			if tile>0x7F then 
				doornum = tile - 0x80;
				dooropen = jpcrr.read_byte(0x43037+doornum*2);
				if dooropen<0xFF then
					jpcrr.hud.box(3,640+math.floor(i/64)*8,(i%64)*8,math.floor(((0xFF-dooropen)/0xFF)*8),8,0,0,0,0,0,0,255,255,255);
				end
			elseif tile>0 then
				jpcrr.hud.box(3,640+math.floor(i/64)*8,(i%64)*8,8,8,0,0,0,0,0,255,255,255,255);
			end
		end
		jpcrr.hud.circle(3,math.floor(x/8192)+640,math.floor(y/8192),4,0,0,0,0,0,255,69,0,255);
		jpcrr.hud.circle(3,math.floor(x/8192)+640+math.cos(math.rad(d))*4,math.floor(y/8192)-math.sin(math.rad(d))*4,2,0,0,0,0,0,255,69,0,255);
		--4882F: enemy x
		for i=1,actors,1 do
			enemyt = jpcrr.read_word(0x4924A+60*i);
			enemyh = jpcrr.read_word_signed(0x49272+60*i);
			if enemyh>0 then -- it's alive, otherwise move on
				enemyx = jpcrr.read_word(0x49257+60*i);
				enemyy = jpcrr.read_word(0x4925B+60*i);
				enemyd = jpcrr.read_byte(0x49254+60*i);
				if enemyt==3 then -- guard
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640,math.floor(enemyy/32),4,0,0,0,0,0,205,133,63,255);
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4,2,0,0,0,0,0,205,133,63,255);
				elseif enemyt==4 then -- officer
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640,math.floor(enemyy/32),4,0,0,0,0,0,127,127,127,255);
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4,2,0,0,0,0,0,127,127,127,255);
				elseif enemyt==5 then -- SS
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640,math.floor(enemyy/32),4,0,0,0,0,0,0,0,255,255);
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4,2,0,0,0,0,0,0,0,255,255);
				elseif enemyt==6 then -- dog
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640,math.floor(enemyy/32),4,0,0,0,0,0,255,105,180,255);
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4,2,0,0,0,0,0,255,105,180,255);
				elseif enemyt==11 then -- mutant
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640,math.floor(enemyy/32),4,0,0,0,0,0,0,255,0,255);
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4,2,0,0,0,0,0,0,255,0,255);
				else -- boss or unknown
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640,math.floor(enemyy/32),4,0,0,0,0,0,255,0,0,255);
					jpcrr.hud.circle(3,math.floor(enemyx/32)+640+math.cos(math.rad(enemyd*45))*4,math.floor(enemyy/32)-math.sin(math.rad(enemyd*45))*4,2,0,0,0,0,0,255,0,0,255);
				end
			end
			htable[i]=enemyh;
		end
		jpcrr.release_vga();
	elseif a == "message" then
		c,d,e = string.match(b, "(.*) (.*) (.*)");
		if b == "refresh" then
			for i = 0,4095,1 do
				wolfmap[i] = jpcrr.read_byte(0x452C8+i);
			end
		end
		if e and c == "BUTTON" then
			if d == "304" and e == "1" then
				jpcrr.pc_start();
			end
			if d == "304" and e == "0" then
				jpcrr.pc_stop();
			end
			if d == "305" then
				jpcrr.sendevent("org.jpc.emulator.peripheral.Keyboard", "KEYEDGE", "157");
			end
			if d == "307" then
				jpcrr.sendevent("org.jpc.emulator.peripheral.Keyboard", "KEYEDGE", "57");
			end
			if d == "308" then
				jpcrr.sendevent("org.jpc.emulator.peripheral.Keyboard", "KEYEDGE", "184");
			end
		end
		if e and c == "move" then
			if string.match(d, "-?[0-9]+") and string.match(e, "-?[0-9]+") then
				print("Moved X "..tonumber(d).." and Y "..tonumber(e));
				jpcrr.hold_mouse_motion(tonumber(d), tonumber(e));
			end
		end
		--print(b);
	end
end




-- 0x4882E  U position (dword)
-- 0x48832  V position (dword)
-- 0x48848  Direction (word)