# HG changeset patch # User Silverwing # Date 2017-01-09 09:56:31 # Node ID 8ef575a5da381fa79a5ceb3350ed4eef99ee5db1 # Parent 5dfd4e336063a82623f76e5d8fa54e7ac5f682a4 Minor changes diff --git a/battlefield.lua b/battlefield.lua --- a/battlefield.lua +++ b/battlefield.lua @@ -431,12 +431,12 @@ bf_wait = obj { combatant = function(tab) tab.canshoot = function(s) local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY)); - return dist < 4 and not tab.ally; + return dist < 6 and not tab.ally; end; tab.onthrust = function(s) - local dist = here().getDistance(here().plX, here().plY, s.x, s.y); - if (rnd(4) > dist) then + local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY)); + if (rnd(4) > dist - 2) then tab.hp = tab.hp - 2; if (tab.hp > 0) then p(tab.thrustHit); @@ -450,7 +450,7 @@ combatant = function(tab) here():make_turn(); end; tab.onshoot = function(s) - local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY));--here().getDistance(here().plX, here().plY, s.x, s.y); + local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY)); if (rnd(4) > dist - 2) then if (dist == 0) then tab.hp = tab.hp - 2; diff --git a/journey_zayslanotrr.lua b/journey_zayslanotrr.lua --- a/journey_zayslanotrr.lua +++ b/journey_zayslanotrr.lua @@ -1213,16 +1213,16 @@ za_plaetlarr_fight = battlefield { --TODO prepend player associate - anna, learr, walter or jack if (char_learr.follow) then table.insert(s.obj, 2, za_cmbt_learr); - s.plX = 2; + s.plX = 3; elseif (char_anna.follow) then table.insert(s.obj, 2, za_cmbt_anna); - s.plX = 2; + s.plX = 3; elseif (char_wright.follow) then table.insert(s.obj, 2, za_cmbt_wright); - s.plX = 2; + s.plX = 3; elseif (char_radcliffe.follow) then table.insert(s.obj, 2, za_cmbt_radcliffe); - s.plX = 2; + s.plX = 3; end; end; obj = { @@ -1278,8 +1278,6 @@ za_cmbt_phaetlarr = combatant { -- If enemy close and enemy doesn't have spear - hit with claws if s.hasSpear then - here():canShoot(s.x, s.y, enemy.x, enemy.y); - if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then --50% if (rnd(2) > 1) then @@ -1288,6 +1286,7 @@ za_cmbt_phaetlarr = combatant { else pn("Фаэтларр бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; + return; elseif (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then --75% if (rnd(4) > 1) then @@ -1296,18 +1295,34 @@ za_cmbt_phaetlarr = combatant { else pn("Фаэтларр бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; - else + return; + elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or + s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then --100% enemy.hp = enemy.hp - 2; pn("Фаэтларр бьет " .. enemy.disp2 .. " копьем и попадает. "); + return; + else + local dist = math.sqrt((s.x - here().plX) * (s.x - here().plX) + (s.y - here().plY) * (s.y - here().plY));--here().getDistance(here().plX, here().plY, s.x, s.y); + if (rnd(4) > dist - 2) then + s.hasSpear = false; + enemy.hp = enemy.hp - 2; + pn("Фаэтларр бросает копье в " .. enemy.disp2 .. " и попадает. "); + else + pn("Фаэтларр бросает копье в " .. enemy.disp2 .. ", но промахивается. "); + end; end; - return; else if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then - enemy.hp = enemy.hp - 1; - pn("Фаэтларр бьет " .. enemy.disp2 .. " и попадает. "); - return; + if (enemy.hasSpear) then + enemy.hasSpear = false; + s.hasSpear = true; + pn("Фаэтларр забирает копье у " .. enemy.disp2 .. ". "); + else + enemy.hp = enemy.hp - 1; + pn("Фаэтларр бьет " .. enemy.disp2 .. " и попадает. "); + end; end; end; @@ -1744,68 +1759,88 @@ za_cmbt_guard = function(nam, index, x, for item=1,#here().obj do local obj = here().obj[item]; if (obj.ally and obj.hp > 0) then - table.insert(enemies, obj); + local p = here():getWalkDistance(s.x, s.y, obj.x, obj.y); + if (p) then + table.insert(enemies, { + o = obj, + p = p + }); + end; end; end; table.sort(enemies, function(a, b) - return (here().getDistance(s.x, s.y, b.x, b.y) > here().getDistance(s.x, s.y, a.x, a.y)); + return (a.p.l < b.p.l); end); + local enemy = enemies[1]; - local dist = 9000; - if (not enemy) then + local path = here():getWalkDistance(s.x, s.y, here().plX, here().plY); + if (not enemy or path and enemy.p.l > path.l ) then enemy = pl; - dist = here().getDistance(s.x, s.y, here().plX, here().plY); else - dist = here().getDistance(s.x, s.y, enemy.x, enemy.y); + path = enemy.p; + enemy = enemy.o; + end; + + if (not enemy or not path) then + pn("Стражник ".. tostring(index).. " ждет. "); + return; end; - if (dist > here().getDistance(s.x, s.y, here().plX, here().plY)) then - enemy = pl; - end; -- AI Order: - -- If has spear and enemy is far - throw spear -- If has spear and enemy is close - hit with spear - -- if spear is nearer than any enemy - walk towards spear -- walk towards nearest enemy - -- If enemy close and enemy has spear - take spear from enemy - -- If enemy close and enemy doesn't have spear - hit with claws + -- If enemy close - hit with claws - if (s.hasSpear and dist == 1) then - if (rnd(4) > 1) then - pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем и попадает. "); - enemy.hp = enemy.hp - 2; - else - pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем, но промахивается. "); + if (s.hasSpear) then + here():canShoot(s.x,s.y, enemy.x, enemy.y); + + if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then + if (math.abs(s.x - enemy.x) == 2 or math.abs(s.y - enemy.y) == 2) then + --50% + if (rnd(2) > 1) then + enemy.hp = enemy.hp - 2; + pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем и попадает. "); + else + pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем, но промахивается. "); + end; + return; + elseif (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then + --75% + if (rnd(4) > 1) then + enemy.hp = enemy.hp - 2; + pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем и попадает. "); + else + pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем, но промахивается. "); + end; + return; + elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or + s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then + --100% + enemy.hp = enemy.hp - 2; + pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем и попадает. "); + return; + end; end; - elseif (s.hasSpear and dist == 0) then - enemy.hp = enemy.hp - 2; - pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем и попадает. "); - elseif dist == 0 then - enemy.hp = enemy.hp - 1; - pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " и попадает. "); else - if (enemy.x > s.x) then - s.x = s.x + 1; - elseif (enemy.x < s.x) then - s.x = s.x - 1; + if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or + s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then + enemy.hp = enemy.hp - 1; + pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " и попадает. "); + return; end; - - if (enemy.y > s.y) then - s.y = s.y + 1; - elseif (enemy.y < s.y) then - s.y = s.y - 1; - end; - - pn("Стражник ".. tostring(index).. " идет к " .. enemy.disp3 .. ". "); end; + print("fug2",path); + s.x = path.p[2][1]; + s.y = path.p[2][2]; + pn("Стражник ".. tostring(index).. " идет к " .. enemy.disp3 .. ". "); end; }; end; -za_cmbt_guard1 = za_cmbt_guard("za_cmbt_guard1", 1, 1, 5, true); -za_cmbt_guard2 = za_cmbt_guard("za_cmbt_guard2", 2, 2, 5, false); -za_cmbt_guard3 = za_cmbt_guard("za_cmbt_guard3", 3, 4, 5, true); -za_cmbt_guard4 = za_cmbt_guard("za_cmbt_guard4", 4, 5, 5, true); +za_cmbt_guard1 = za_cmbt_guard("za_cmbt_guard1", 1, 3, 5, true); +za_cmbt_guard2 = za_cmbt_guard("za_cmbt_guard2", 2, 5, 5, false); +za_cmbt_guard3 = za_cmbt_guard("za_cmbt_guard3", 3, 3, 7, true); +za_cmbt_guard4 = za_cmbt_guard("za_cmbt_guard4", 4, 5, 7, true); za_phaetlarr_dlg = dlg { var { diff --git a/lseryanotrr_locations.lua b/lseryanotrr_locations.lua --- a/lseryanotrr_locations.lua +++ b/lseryanotrr_locations.lua @@ -645,8 +645,6 @@ lse_cmbt_learr = combatant { -- If enemy close and enemy doesn't have spear - hit with claws if s.hasSpear then - here():canShoot(s.x, s.y, enemy.x, enemy.y); - if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then --50% if (rnd(2) > 1) then @@ -655,6 +653,7 @@ lse_cmbt_learr = combatant { else pn("Леарр бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; + return; elseif (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then --75% if (rnd(4) > 1) then @@ -663,12 +662,14 @@ lse_cmbt_learr = combatant { else pn("Леарр бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; - else + return; + elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or + s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then --100% enemy.hp = enemy.hp - 2; pn("Леарр бьет " .. enemy.disp2 .. " копьем и попадает. "); + return; end; - return; else if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then @@ -735,8 +736,6 @@ lse_cmbt_phaetlarr = combatant { -- If enemy close and enemy doesn't have spear - hit with claws if s.hasSpear then - here():canShoot(s.x, s.y, enemy.x, enemy.y); - if (math.abs(s.x - enemy.x) + math.abs(s.y - enemy.y) <= 2 and here():canShoot(s.x,s.y, enemy.x, enemy.y)) then --50% if (rnd(2) > 1) then @@ -745,6 +744,7 @@ lse_cmbt_phaetlarr = combatant { else pn("Фаэтларр бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; + return; elseif (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then --75% if (rnd(4) > 1) then @@ -753,12 +753,14 @@ lse_cmbt_phaetlarr = combatant { else pn("Фаэтларр бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; - else + return; + elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or + s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then --100% enemy.hp = enemy.hp - 2; pn("Фаэтларр бьет " .. enemy.disp2 .. " копьем и попадает. "); + return; end; - return; else if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then @@ -1038,6 +1040,7 @@ lse_cmbt_guard = function(nam, index, x, else pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; + return; elseif (math.abs(s.x - enemy.x) == 1 and math.abs(s.y - enemy.y) == 1) then --75% if (rnd(4) > 1) then @@ -1046,12 +1049,14 @@ lse_cmbt_guard = function(nam, index, x, else pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем, но промахивается. "); end; - else + return; + elseif (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or + s.x == enemy.x and math.abs(s.y - enemy.y) == 1) then --100% enemy.hp = enemy.hp - 2; pn("Стражник ".. tostring(index).. " бьет " .. enemy.disp2 .. " копьем и попадает. "); + return; end; - return; end; else if (math.abs(s.x - enemy.x) == 1 and s.y == enemy.y or @@ -1120,10 +1125,10 @@ lse_hideout_intro_dlg = dlg { pr [[]]; end; if (ArrayUtils.indexOf(pl.party, 'anna') ~= 0) then - pr [[\]]; + pr [[]]; end; end, code [[ - + walk("lse_hideout_main_room"); ]]} }; }; \ No newline at end of file diff --git a/main.lua b/main.lua --- a/main.lua +++ b/main.lua @@ -246,7 +246,7 @@ function init() --pl.where = "za_plaetlarr_fight"; pl.where = "za_phaetlarr_fight_intro"; move(submarine_leviathan, "za_temple_back_entrance_foot"); - char_anna.follow = true; + --char_anna.follow = true; --pl.where = "ven_chest_look"; --move(ven_shark, "ven_temple_l1");