Well, so far so good. I've got the basic code done , LUA specific, not ROM). Now I just need to take this and insert all the specific functions and actions for the bot to take advantage of it. I'll probably also add a function so that after round 5 if there are still barrels to check it will check them in order of highest score first.
In this test file, I set 3, 14, & 21 as the barrels with the kobolds inside. I'm also going to test some others as well. Here's a copy of what I've got so far. *** This is a .Lua file, not an xml waypoint file.
Code: Select all
--=== Setting up variables: ===--
local koboldsFound = 0
local numMoves = 0
local barrelTbl = {
[1]={ X=3010.98291 , Z=35.38862991, Score=5, Links={[1]={Num=2},[2]={Num=6},[3]={Num=7},}},
[2]={ X=3036.711914 , Z=49.38666916, Score=5, Links={[1]={Num=1},[2]={Num=3},[3]={Num=6},[4]={Num=8},[5]={Num=7},}},
[3]={ X=3061.070068 , Z=67.11927032, Score=5, Links={[1]={Num=2},[2]={Num=4},[3]={Num=7},[4]={Num=9},[5]={Num=8},}},
[4]={ X=3086.976074 , Z=80.69120026, Score=5, Links={[1]={Num=3},[2]={Num=5},[3]={Num=8},[4]={Num=10},[5]={Num=9},}},
[5]={ X=3113.544922 , Z=99.62309265, Score=5, Links={[1]={Num=4},[2]={Num=10},[3]={Num=9},}},
[6]={ X=3027.961914 , Z=8.74179554, Score=5, Links={[1]={Num=11},[2]={Num=1},[3]={Num=2},[4]={Num=12},[5]={Num=7},}},
[7]={ X=3053.081055 , Z=25.25625992, Score=5, Links={[1]={Num=1},[2]={Num=13},[3]={Num=3},[4]={Num=11},[5]={Num=6},[6]={Num=8},[7]={Num=2},[8]={Num=12},}},
[8]={ X=3077.891113 , Z=41.24858856, Score=5, Links={[1]={Num=12},[2]={Num=4},[3]={Num=2},[4]={Num=14},[5]={Num=7},[6]={Num=9},[7]={Num=13},[8]={Num=3},}},
[9]={ X=3103.554932 , Z=56.39542007, Score=5, Links={[1]={Num=5},[2]={Num=13},[3]={Num=15},[4]={Num=3},[5]={Num=8},[6]={Num=10},[7]={Num=4},[8]={Num=14},}},
[10]={ X=3129.545898 , Z=73.40276337, Score=5, Links={[1]={Num=5},[2]={Num=15},[3]={Num=14},[4]={Num=4},[5]={Num=9},}},
[11]={ X=3042.2229 , Z=-15.36034966, Score=5, Links={[1]={Num=16},[2]={Num=6},[3]={Num=7},[4]={Num=17},[5]={Num=12},}},
[12]={ X=3068.716064 , Z=-0.087428153, Score=5, Links={[1]={Num=16},[2]={Num=8},[3]={Num=18},[4]={Num=6},[5]={Num=13},[6]={Num=11},[7]={Num=7},[8]={Num=17},}},
[13]={ X=3094.581055 , Z=15.31999016, Score=5, Links={[1]={Num=7},[2]={Num=19},[3]={Num=9},[4]={Num=17},[5]={Num=14},[6]={Num=12},[7]={Num=18},[8]={Num=8},}},
[14]={ X=3119.471924 , Z=31.05658913, Score=5, Links={[1]={Num=10},[2]={Num=18},[3]={Num=8},[4]={Num=20},[5]={Num=15},[6]={Num=13},[7]={Num=9},[8]={Num=19},}},
[15]={ X=3145.129883 , Z=47.69260025, Score=5, Links={[1]={Num=10},[2]={Num=20},[3]={Num=19},[5]={Num=9},[6]={Num=14},}},
[16]={ X=3059.019043 , Z=-40.57423019, Score=5, Links={[1]={Num=21},[2]={Num=11},[3]={Num=12},[4]={Num=22},[5]={Num=17},}},
[17]={ X=3084.559082 , Z=-26.07653046, Score=5, Links={[1]={Num=13},[2]={Num=21},[3]={Num=11},[4]={Num=23},[5]={Num=16},[6]={Num=18},[7]={Num=12},[8]={Num=22},}},
[18]={ X=3108.978027 , Z=-11.35186005, Score=5, Links={[1]={Num=14},[2]={Num=22},[3]={Num=24},[5]={Num=12},[6]={Num=17},[7]={Num=19},[8]={Num=23},[9]={Num=13},}},
[19]={ X=3134.354004 , Z=4.835566044, Score=5, Links={[1]={Num=13},[2]={Num=25},[3]={Num=23},[4]={Num=15},[5]={Num=18},[6]={Num=20},[7]={Num=14},[8]={Num=24},}},
[20]={ X=3160.509033 , Z=20.60238075, Score=5, Links={[1]={Num=15},[2]={Num=25},[3]={Num=24},[4]={Num=14},[5]={Num=19},}},
[21]={ X=3073.481934 , Z=-66.05554962, Score=5, Links={[1]={Num=22},[2]={Num=16},[3]={Num=17},}},
[22]={ X=3098.574951 , Z=-51.81417084, Score=5, Links={[1]={Num=23},[2]={Num=21},[3]={Num=18},[4]={Num=16},[5]={Num=17},}},
[23]={ X=3125.886963 , Z=-36.31401062, Score=5, Links={[1]={Num=24},[2]={Num=22},[3]={Num=19},[4]={Num=17},[5]={Num=18},}},
[24]={ X=3150.272949 , Z=-18.85281944, Score=5, Links={[1]={Num=25},[2]={Num=23},[3]={Num=20},[4]={Num=18},[5]={Num=19},}},
[25]={ X=3175.987061 , Z=-3.51265502, Score=5, Links={[1]={Num=20},[2]={Num=24},[3]={Num=19},}},
}
local checkRound = {
[1]={4, 6, 13, 20, 22},
[2]={1, 5, 21, 25},
[3]={3, 11, 15, 23},
[4]={7, 9, 17, 19},
[5]={8, 12, 14, 18},
}
--=== testing data follows:
local koboldLocation = {3, 14, 21}
local koboldNearby = {2,4,7,8,9,10,13,15,16,17,18,19,20,22}
local noneFound = {1,5,6,11,12,23,24,25}
--=== functions ===--
local function getStatus(barrelnum)
for i,loc in pairs(koboldLocation) do
if koboldsFound == 3 then
break
end
if loc == barrelnum then
cprintf(cli.green,"\tKobold found in barrel "..barrelnum..". clicking barrel and marking it done.\n")
-- useExtraActionItem(2)
barrelTbl[barrelnum].Score = 0
koboldsFound = koboldsFound + 1
break
end
end
for i,loc in pairs(koboldNearby) do
if loc == barrelnum then
cprintf(cli.yellow,"\t\tKobolds are near barrel "..barrelnum..". Setting it's score to ZERO\n")
barrelTbl[barrelnum].Score = 0
cprintf(cli.yellow,"\t\t\tAnd updating score for surrounding barrels.\n")
for u,udbrl in ipairs(barrelTbl[barrelnum].Links) do
if barrelTbl[udbrl.Num].Score >0 then
print("\t\tAdding +1 to score for barrel "..udbrl.Num)
barrelTbl[udbrl.Num].Score = barrelTbl[udbrl.Num].Score + 1
print("\t\tCurrent barrel score is "..barrelTbl[udbrl.Num].Score)
else
print("\t\t"..udbrl.Num.." is already ZERO!!! Not updating it.")
end
end
break
end
end
for i,loc in pairs(noneFound) do
if loc == barrelnum then
cprintf(cli.red,"\tNo Kobolds are nearby "..barrelnum..". Setting this barrel Score to ZERO.\n")
barrelTbl[barrelnum].Score = 0
cprintf(cli.red,"\t\tand updating score for surrounding barrels to ZERO.\n")
for u,udbrl in ipairs(barrelTbl[barrelnum].Links) do
print("\t\tSetting score for barrel "..udbrl.Num.." to ZERO")
if barrelTbl[udbrl.Num].Score > 0 then
barrelTbl[udbrl.Num].Score = 0
print("\t\tCurrent barrel score is "..barrelTbl[udbrl.Num].Score)
else
print("\t\t"..udbrl.Num.." is already ZERO!!! Not updating it.")
end
end
break
end
end
end
function checkBarrels()
for i,round in ipairs(checkRound) do
--for each barrel during this round:
print("Beginning Round "..i)
for b, barrels in pairs(round) do
print("Current Barrel to be checked: "..barrels)
--if barrel not marked as empty then
if barrelTbl[barrels].Score == 0 then
cprintf(cli.red,"\tThis barrel has already been eliminated\n")
elseif barrelTbl[barrels].Score > 0 then
print("\tWe will now check this barrel")
numMoves = numMoves + 1
getStatus(barrels)
end
if koboldsFound == 3 then
break
end
end
if koboldsFound == 3 then
break
end
end
cprintf(cli.pink,"All kobolds found in "..numMoves.." moves!")
end
startMacro(checkBarrels,true);
I fixed a issue where i wasn't updating surrounding barrels properly. I fixed that and made my output a little better to read.