Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --dx/dy collation logic for copykat moves
- if (data.reason == "copkat") then
- --new 'move ALL the way' logic:
- --1) Split the move into two parts - all the diagonal movement, then all the remaining orthogonal movement.
- --2) Put the second half in as a new move after this one.
- local diag_amt = math.min(math.abs(data.dx), math.abs(data.dy));
- local ortho_amt = math.max(math.abs(data.dx), math.abs(data.dy)) - diag_amt;
- if (diag_amt == 0 and ortho_amt == 0 or slippers[unit.id] ~= nil or hasProperty(unit, "slep")) then
- data.times = 0;
- elseif (diag_amt > 0 and ortho_amt == 0) or (ortho_amt > 0 and diag_amt == 0) then
- data.times = math.max(diag_amt, ortho_amt);
- local dir = dirs8_by_offset[sign(data.dx)][sign(data.dy)];
- data.dir = dir;
- data.reason = "copkat_result";
- else
- local newdir = dirs8_by_offset[sign(math.abs(data.dx)-diag_amt)][sign(math.abs(data.dy)-diag_amt)]
- table.insert(copykat.moves, 2, {reason = "copkat_result", dir = newdir, times = ortho_amt})
- data.times = diag_amt;
- local dir = dirs8_by_offset[sign(data.dx)][sign(data.dy)];
- data.dir = dir;
- data.reason = "copkat_result";
- end
- if (data.times == 0) then
- while #unit.moves > 0 and unit.moves[1].times <= 0 do
- table.remove(unit.moves, 1)
- end
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement