User File #46695978680246991

Upload All User Files

#46695978680246991 - Advance Wars: Dual Strike TAS bot resources file

resources.lua
824 downloads
Uploaded 4/25/2018 10:46 PM by ALAKTORN (see all 34)
local CONames = {
	[0] = 'None',
	[1] = 'Nell',
	[2] = 'Andy',
	[3] = 'Max',
	[4] = 'Olaf',
	[5] = 'Sami',
	[6] = 'Grit',
	[7] = 'Kanbei',
	[8] = 'Sonja',
	[9] = 'Eagle',
	[10] = 'Drake',
	[11] = 'Von Bolt',
	[12] = 'Jugger',
	[13] = 'Lash',
	[14] = 'Koal',
	[15] = 'Hawke',
	[16] = 'Hachi',
	[17] = 'Colin',
	[18] = 'Jess',
	[19] = 'Sensei',
	[20] = 'Jake',
	[21] = 'Rachel',
	[22] = 'Sasha',
	[23] = 'Javier',
	[24] = 'Grimm',
	[25] = 'Kindle',
	[26] = 'Flak',
	[27] = 'Adder'
}
function getCOName(id)
	return CONames[id]
end

local COPCosts = {
	[1] = 3,
	[2] = 3,
	[3] = 3,
	[4] = 3,
	[5] = 3,
	[6] = 3,
	[7] = 4,
	[8] = 3,
	[9] = 3,
	[10] = 4,
	[11] = -1,
	[12] = 3,
	[13] = 4,
	[14] = 3,
	[15] = 5,
	[16] = 3,
	[17] = 2,
	[18] = 3,
	[19] = 2,
	[20] = 3,
	[21] = 3,
	[22] = 2,
	[23] = 3,
	[24] = 3,
	[25] = 3,
	[26] = 3,
	[27] = 2
}
function getCOPCost(id)
	return COPCosts[id]
end

local SCOPCosts = {
	[1] = 6,
	[2] = 6,
	[3] = 6,
	[4] = 7,
	[5] = 8,
	[6] = 6,
	[7] = 7,
	[8] = 5,
	[9] = 9,
	[10] = 7,
	[11] = 10,
	[12] = 7,
	[13] = 7,
	[14] = 5,
	[15] = 9,
	[16] = 5,
	[17] = 6,
	[18] = 6,
	[19] = 6,
	[20] = 6,
	[21] = 6,
	[22] = 6,
	[23] = 6,
	[24] = 6,
	[25] = 6,
	[26] = 6,
	[27] = 5
}
function getSCOPCost(id)
	return SCOPCosts[id]
end

local UnitNames = {
	[0] = 'None',
	[1] = 'Inf',
	[2] = 'Mech',
	[3] = 'MD',
	[4] = 'Mega',
	[5] = 'Tank',
	[6] = 'Recon',
	[7] = 'APC',
	[8] = 'Neo',
	[9] = 'Piperunner',
	[10] = 'Art',
	[11] = 'Rockets',
	[12] = 'Stealth',
	[13] = 'Black Bomb',
	[14] = 'AA',
	[15] = 'Missiles',
	[16] = 'Fighter',
	[17] = 'Bomber',
	[18] = 'BB',
	[19] = 'B-Cop',
	[20] = 'T-Cop',
	[21] = 'BS',
	[22] = 'Cruiser',
	[23] = 'Lander',
	[24] = 'Sub',
	[25] = 'Carrier',
	[26] = 'Oozium'
}
local function getUnitName(id)
	return UnitNames[id]
end

--[[
-- COs
-- P1 CO1 0x218936C
-- P1 CO2 0x2189370
-- P2 CO1 0x2189404
-- P2 CO2 0x2189408

-- CO ID			+0
-- PowersInfo		+1 Bit 1-6
-- TimesPowersUsed	+1 Bit 7-8 and +2 Bit 1-2
-- Stars			+2 Bit 3-8 and +3


-- Unit 1
-- P1 0x2188472
-- P2 0x21887F2
-- P3 0x2188A72
-- P4 0x2188D72

-- Type			+0
-- Status*		+1
-- X			+2
-- Y			+3
-- LoadedUnit1	+4
-- LoadedUnit2	+5
-- HP			+6 Bit 1-7
-- Ammo			+6 Bit 8 and +7 Bit 1-3
-- Capture		+7 Bit 4-8
-- Fuel			+8 Bit 1-7
-- Next unit at + 14

*Status bitfield:
0x1: Wait
0x2: Unit Transported?
0x4: Unit Unselectable
0x8:
0x10: Transporting
0x20: Dived
0x40: Stunned
0x80
]]

function printMapStatus()
	for Army = 1, 2 do
		if Army == 1 then
			COBaseAddr = 0x218936C
			UnitBaseAddr = 0x2188472
		else
			COBaseAddr = 0x2189404
			UnitBaseAddr = 0x21887F2
		end
		
		-- CO Info
		for iCO = 1, 2 do
			local COAddr = COBaseAddr + (iCO - 1) * 4
			local COID = memory.readbyte(COAddr)
			if COID ~= 0 then
				local COStars = memory.readword(COAddr + 2)
				print(getCOName(COID) .. ' (' .. (COStars / 1600) .. ')')
			end
		end
		-- Unit Info
		for iUnit = 1, 50 do
			local UnitAddr = UnitBaseAddr + (iUnit - 1) * 14
			local UnitType = memory.readbyte(UnitAddr)
			if UnitType ~= 0 then
				local UnitX = memory.readbyte(UnitAddr + 2)
				local UnitY = memory.readbyte(UnitAddr + 3)
				local UnitHP = memory.readbyte(UnitAddr + 6) % 128
				print('#' .. iUnit .. ' ' .. getUnitName(UnitType) .. ' (' .. UnitX .. ',' .. UnitY .. ') ' .. UnitHP)
			end
		end
		print()
	end
end