Changeset - 5fa679544e59
[Not reviewed]
default
0 3 0
silverwing - 5 years ago 2019-10-09 19:27:31

[fix] Dypatreanotrr combat fixed
3 files changed with 172 insertions and 160 deletions:
0 comments (0 inline, 0 general)
atlantis_dyp.lua
Show inline comments
 
@@ -2530,14 +2530,16 @@ dyp_cmbt_learr = combatant {
 
    disp = "Леарр";
 
    disp2 = "Леарр";
 
    disp3 = "Леарр";
 
    x = 5;
 
    y = 7;
 
    var {
 
        x = 5;
 
        y = 7;
 
        hp = 10;
 
        hasSpear = true;
 
    };
 
    pic = "images/learr.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasSpear = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
@@ -2634,14 +2636,16 @@ dyp_cmbt_wright = combatant {
 
    disp = "Райт";
 
    disp2 = "Райта";
 
    disp3 = "Райту";
 
    x = 5;
 
    y = 7;
 
    pic = "images/jack.png";
 
    var {
 
        x = 5;
 
        y = 7;
 
        hp = 10;
 
        hasHarpoon = true;
 
    };
 
    pic = "images/ally.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
@@ -2677,12 +2681,13 @@ dyp_cmbt_wright = combatant {
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        
 
        if (s.x ~= 6 or s.y ~=3) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 3);
 
            if (ppath.l < path.l) then
 
        if (s.x ~= 6 or s.y ~= 7) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 7);
 
            if ppath and (ppath.l < path.l) then
 
                s.x = ppath.p[2][1];
 
                s.y = ppath.p[2][2];
 
                pr("Райт идет к укрытию");
 
                pr("Райт идет к укрытию. ");
 
                return
 
            end;
 
        end;
 
        
 
@@ -2690,48 +2695,47 @@ dyp_cmbt_wright = combatant {
 
        -- If has harpoon and enemy is far - shoot
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 
        
 
        if (s.hasHarpoon) then
 
            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
 
                    enemy.hp = enemy.hp - 2;
 
                    pr("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Райт бьет " .. 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;
 
                    pr("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Райт бьет " .. 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%
 

	
 
        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
 
                enemy.hp = enemy.hp - 2;
 
                pr("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Райт бьет " .. 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;
 
                pr("Райт бьет " .. 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;
 
                    pr("Райт стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Райт стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
                pr("Райт бьет " .. 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;
 
            pr("Райт бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            return;
 
        elseif s.hasHarpoon then
 
            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.hasHarpoon = false;
 
                enemy.hp = enemy.hp - 2;
 
                pr("Райт стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Райт стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
            end;
 
            return;
 
        else
 
            s.hasHarpoon = true;
 
            pr("Райт перезаряжает ружье. ");
 
            return
 
        end;
 
        
 

	
 
        s.x = path.p[2][1];
 
        s.y = path.p[2][2];
 
        pr("Райт идет к " .. enemy.disp3 .. ". ");
 
@@ -2750,13 +2754,15 @@ dyp_cmbt_radcliffe = combatant {
 
    disp = "Уолтер";
 
    disp2 = "Уолтера";
 
    disp3 = "Уолтеру";
 
    x = 5;
 
    y = 7;
 
    pic = "images/walter.png";
 
    var {
 
        x = 5;
 
        y = 7;
 
        hp = 10;
 
    };
 
    pic = "images/ally.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
@@ -2793,12 +2799,13 @@ dyp_cmbt_radcliffe = combatant {
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        
 
        if (s.x ~= 6 or s.y ~=3) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 3);
 
            if (ppath.l < path.l) then
 
        if (s.x ~= 6 or s.y ~=7) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 7);
 
            if ppath and (ppath.l < path.l) then
 
                s.x = ppath.p[2][1];
 
                s.y = ppath.p[2][2];
 
                pr("Рэдклифф идет к укрытию");
 
                pr("Рэдклифф идет к укрытию. ");
 
                return
 
            end;
 
        end;
 
        
 
@@ -2807,47 +2814,46 @@ dyp_cmbt_radcliffe = combatant {
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 
        
 
        if (s.hasHarpoon) then
 
            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
 
                    enemy.hp = enemy.hp - 2;
 
                    pr("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Рэдклифф бьет " .. 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;
 
                    pr("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Рэдклифф бьет " .. 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%
 
        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
 
                enemy.hp = enemy.hp - 2;
 
                pr("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Рэдклифф бьет " .. 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;
 
                pr("Рэдклифф бьет " .. 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;
 
                    pr("Рэдклифф стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Рэдклифф стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
                pr("Рэдклифф бьет " .. 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;
 
            pr("Рэдклифф бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            return;
 
        elseif s.hasHarpoon then
 
            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.hasHarpoon = false;
 
                enemy.hp = enemy.hp - 2;
 
                pr("Рэдклифф стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Рэдклифф стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
            end;
 
            return;
 
        else
 
            s.hasHarpoon = true;
 
            pr("Рэдклифф перезаряжает ружье. ");
 
            return;
 
        end;
 
        
 

	
 
        s.x = path.p[2][1];
 
        s.y = path.p[2][2];
 
        pr("Рэдклифф идет к " .. enemy.disp3 .. ". ");
 
@@ -2866,13 +2872,15 @@ dyp_cmbt_anna = combatant {
 
    disp = "Анна";
 
    disp2 = "Анну";
 
    disp3 = "Анне";
 
    x = 5;
 
    y = 7;
 
    pic = "images/anna.png";
 
    var {
 
        x = 5;
 
        y = 7;
 
        hp = 10;
 
    };
 
    pic = "images/ally.png";
 
    ally = "Я не буду атаковать союзника.";
 
    nohit = "Я не буду атаковать союзника.";
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
@@ -2909,66 +2917,57 @@ dyp_cmbt_anna = combatant {
 
        local enemy = enemies[1].o;
 
        local path = enemies[1].p;
 
        
 
        if (s.x ~= 6 or s.y ~=3) then
 
            local ppath = here():getWalkDistance(s.x, s.y, 6, 3);
 
            if (ppath.l < path.l) then
 
                s.x = ppath.p[2][1];
 
                s.y = ppath.p[2][2];
 
                pr("Анна идет к укрытию");
 
            end;
 
        end;
 
        
 
        -- AI Order:
 
        -- If has harpoon and enemy is far - shoot
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 
        
 
        if (s.hasHarpoon) then
 
            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
 
                    enemy.hp = enemy.hp - 2;
 
                    pr("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Анна бьет " .. 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;
 
                    pr("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Анна бьет " .. 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;
 
                pr("Анна бьет " .. 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;
 
                    pr("Анна стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
                else
 
                    pr("Анна стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
                end;
 
                return;
 
            end;
 
        else
 
            s.hasHarpoon = true;
 
            pr("Анна перезаряжает ружье. ");
 
        end;
 
        
 
        local plpath = here():getWalkDistance(s.x, s.y, pl.x, pl.y);
 
        if (plpath.l > 2) then
 
            s.x = plpath.p[2][1];
 
            s.y = plpath.p[2][2];
 
            pr("Анна идет к вам. ");
 
            return
 
        end;
 

	
 
        -- AI Order:
 
        -- If has harpoon and enemy is far - shoot
 
        -- If has harpoon and enemy is close - hit with harpoon
 
        -- walk towards nearest enemy
 

	
 
        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
 
                enemy.hp = enemy.hp - 2;
 
                pr("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Анна бьет " .. 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;
 
                pr("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Анна бьет " .. 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;
 
            pr("Анна бьет " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            return;
 
        elseif s.hasHarpoon then
 
            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.hasHarpoon = false;
 
                enemy.hp = enemy.hp - 2;
 
                pr("Анна стреляет в " .. enemy.disp2 .. " гарпуном и попадает. ");
 
            else
 
                pr("Анна стреляет в " .. enemy.disp2 .. " гарпуном, но промахивается. "); 
 
            end;
 
            return;
 
        else
 
            s.hasHarpoon = true;
 
            pr("Анна перезаряжает ружье. ");
 
            return
 
        end;
 
    end;
 
    dsc = function(s)
 
@@ -2985,9 +2984,11 @@ dyp_king_crab = combatant {
 
    disp = "краб";
 
    disp2 = "краба";
 
    disp3 = "крабу";
 
    x = 4;
 
    y = 1;
 
    hp = 4;
 
    var {
 
        x = 4;
 
        y = 1;
 
        hp = 4;
 
    };
 
    pic = "images/king_crab.png";
 
    shootHit = "Вы стреляете в краба и попадаете в него. ";
 
    shootMiss = "Вы стреляете в краба, но не попадаете в него. ";
 
@@ -3070,9 +3071,11 @@ dyp_little_crab = function(nam, index, x
 
        disp = "детеныш краба " .. tostring(index);
 
        disp2 = "детеныша краба " .. tostring(index);
 
        disp3 = "детенышу краба " .. tostring(index);
 
        x = x;
 
        y = y;
 
        hp = 2;
 
        var {
 
            x = x;
 
            y = y;
 
            hp = 2;
 
        };
 
        pic = "images/little_crab_".. index ..".png";
 
        shootHit = "Вы стреляете в детеныша краба и попадаете в него. ";
 
        shootMiss = "Вы стреляете в детеныша краба, но не попадаете в него. ";
 
@@ -3147,8 +3150,10 @@ end;
 

	
 
dyp_crab_fight = battlefield {
 
    nam = "Пещера";
 
    plX = 4;
 
    plY = 7;
 
    var {
 
        plX = 4;
 
        plY = 7;
 
    };
 
    map = {
 
        {2,0,0,0,0,0,2};
 
        {2,0,0,0,0,0,2};
 
@@ -3166,16 +3171,16 @@ dyp_crab_fight = battlefield {
 
    entered = function(s)
 
        --TODO prepend player associate - anna, learr, walter or jack
 
        if (char_learr.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_learr);
 
            placeto(dyp_cmbt_learr, s, 1);
 
            s.plX = 3;
 
        elseif (char_anna.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_anna);
 
            placeto(dyp_cmbt_anna, s, 1);
 
            s.plX = 3;
 
        elseif (char_wright.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_wright);
 
            placeto(dyp_cmbt_wright, s, 1);
 
            s.plX = 3;
 
        elseif (char_radcliffe.follow) then
 
            table.insert(s.obj, 1, dyp_cmbt_radcliffe);
 
            placeto(dyp_cmbt_radcliffe, s, 1);
 
            s.plX = 3;
 
        end;
 
    end;
images/ally.png
Show inline comments
 
binary diff not shown
Show images
startup.lua
Show inline comments
 
@@ -209,7 +209,7 @@ function init()
 
    else
 
        prefs.language = language;
 
    end;
 
    
 

	
 
    local nums = {1,2,3,4,5,6};
 
    if #dt_code == 0 then
 
        for i = 1, 4 do
 
@@ -226,6 +226,13 @@ function init()
 
    ---game init
 
    pl.where = intro;
 
    ---debug
 
    --pl.party = {'anna'};
 
    --char_anna:accompany(true);
 
    pl.party = {'radcliffe'};
 
    char_radcliffe:accompany(true);
 
    --pl.party = {'wright'};
 
    --char_wright:accompany(true);
 
    pl.where = 'dyp_crab_fight_intro';
 
end;
 

	
 
function start()
0 comments (0 inline, 0 general)