User File #28795717603126010

Upload All User Files

#28795717603126010 - Wolfenstein 3D Minimap Script v1.3

Wolf3d-scriptv13.lua
Game: Wolfenstein 3D ( DOS, see all files )
850 downloads
Uploaded 2/9/2016 7:19 PM by slamo (see all 61)
Now works with the registered version of Wolf3D.
Commands:
refresh: Reloads the tiles on the minimap. Do this when the enemies pop up. move x y: Holds mouse movement at (x,y) indefinitely.
Minimap legend:
Orange: BJ Brown: Guard Pink: Dog Blue: SS Green: Mutant Gray: Officer Red: Boss or unknown
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};

--a28

while true do
	a, b = jpcrr.wait_event();
	if a == "lock" then
		jpcrr.hud.top_gap(3, 16);
		jpcrr.hud.right_gap(3, 512);
		jpcrr.hud.bottom_gap(3, 96);
        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);
		f = jpcrr.frame_number();
		spd = math.sqrt(dx * dx + dy * dy)
		render_text(3, 0, 0, string.format("(%7d,%7d) %3d [%+5d,%+5d](%f) %+3d", x, y, d, dx, dy, spd, dd), false, 0, 255, 0);
		render_text(3, 0, 432, string.format("Time: %5d",timer), false, 0, 255, 0);
		--render_text(3, 120, 432, string.format("Custom: %5d",custom), false, 0, 255, 0);
		render_text(3, 0, 448, "Index", false, 0, 255, 0);
		render_text(3, 88, 448, tostring(rngindex), false, 255, 255, 255);
		render_text(3, 0, 464, "Dist 0-1", false, 0, 255, 0);
		render_text(3, 0, 480, "Dist 2+", false, 0, 255, 0);
		render_text(3, 0, 496, "Max Dist", false, 0, 255, 0);
		for i=1,10,1 do
			nextind = rngindex+i+1;
			if nextind>256 then nextind = nextind - 256 end
			render_text(3, 144+48*(i-1), 448, tostring(nextind-1), false, 0, 255, 0);
			render_text(3, 144+48*(i-1), 464, tostring(math.floor((rndtable[nextind])/4)), false, 0, 255, 0);
			render_text(3, 144+48*(i-1), 480, tostring(math.floor((rndtable[nextind])/6)), false, 0, 255, 0);
			if i>1 then
				distind = nextind - 1;
				if distind<1 then distind=256 end
				maxdist = math.floor(rndtable[distind]/12);
				if maxdist<4 then maxdist = 3 end
				render_text(3, 144+48*(i-1), 496, tostring(maxdist), false, 0, 255, 0);
			end
		end
		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
		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
			if enemyh~=htable[i] then -- damage has been done
				hstring = string.format("Last damage dealt: %3d",(htable[i]-enemyh))
			end
			render_text(3, 0,416, hstring,false, 0, 255, 0);
			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)