Changeset - 33c86533769a
[Not reviewed]
default
0 5 0
Silverwing - 5 years ago 2019-04-27 10:06:57

Mouse-driven combat interface
5 files changed with 276 insertions and 5 deletions:
0 comments (0 inline, 0 general)
atlantis_dyp.lua
Show inline comments
 
@@ -2219,6 +2219,7 @@ dyp_crab_fight_win = cutscene("dyp_crab_fight_win", "Пещера", [[Отбившись от крабов, вы остаетесь одни в темном лабиринте пещер. ]], "dyp_crab_cave");
 

	
 
dyp_cmbt_learr = combatant {
 
    nam = "dyp_cmbt_learr";
 
    disp = "Леарр";
 
    disp2 = "Леарр";
 
    disp3 = "Леарр";
 
    x = 5;
 
@@ -2229,6 +2230,17 @@ dyp_cmbt_learr = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasSpear = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Она легко ранена. ";
 
        elseif s.hp > 3 then
 
            return "Она ранена. ";
 
        else
 
            return "Она тяжело ранена. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -2311,6 +2323,7 @@ dyp_cmbt_learr = combatant {
 

	
 
dyp_cmbt_wright = combatant {
 
    nam = "za_cmbt_wright";
 
    disp = "Райт";
 
    disp2 = "Райта";
 
    disp3 = "Райту";
 
    x = 5;
 
@@ -2321,6 +2334,17 @@ dyp_cmbt_wright = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Он легко ранен. ";
 
        elseif s.hp > 3 then
 
            return "Он ранен. ";
 
        else
 
            return "Он тяжело ранен. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -2415,8 +2439,9 @@ dyp_cmbt_wright = combatant {
 

	
 
dyp_cmbt_radcliffe = combatant {
 
    nam = "dyp_cmbt_radcliffe";
 
    disp2 = "Рэклиффа";
 
    disp3 = "Рэдклиффу";
 
    disp = "Уолтер";
 
    disp2 = "Уолтера";
 
    disp3 = "Уолтеру";
 
    x = 5;
 
    y = 7;
 
    pic = "images/walter.png";
 
@@ -2425,6 +2450,17 @@ dyp_cmbt_radcliffe = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Он легко ранен. ";
 
        elseif s.hp > 3 then
 
            return "Он ранен. ";
 
        else
 
            return "Он тяжело ранен. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -2519,6 +2555,7 @@ dyp_cmbt_radcliffe = combatant {
 

	
 
dyp_cmbt_anna = combatant {
 
    nam = "dyp_cmbt_anna";
 
    disp = "Анна";
 
    disp2 = "Анну";
 
    disp3 = "Анне";
 
    x = 5;
 
@@ -2529,6 +2566,17 @@ dyp_cmbt_anna = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = true;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Она легко ранена. ";
 
        elseif s.hp > 3 then
 
            return "Она ранена. ";
 
        else
 
            return "Она тяжело ранена. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -2626,6 +2674,7 @@ dyp_cmbt_anna = combatant {
 

	
 
dyp_king_crab = combatant {
 
    nam = "dyp_king_crab";
 
    disp = "краб";
 
    disp2 = "краба";
 
    disp3 = "крабу";
 
    x = 4;
 
@@ -2639,6 +2688,17 @@ dyp_king_crab = combatant {
 
    handKill = "Вы ударяет краба, убивая его. ";
 
    handFar = "Слишком далеко. ";
 
    enemy = true;
 
    state = function(s)
 
        if s.hp == 4 then
 
            return "";
 
        elseif s.hp == 3 then
 
            return "Он легко ранен. ";
 
        elseif s.hp == 2 then
 
            return "Он ранен. ";
 
        else
 
            return "Он тяжело ранен. ";
 
        end;
 
    end;
 
    dsc = function(s)
 
        if (s.hp > 0) then
 
            return "{Краб} готов к бою. ";
 
@@ -2699,6 +2759,7 @@ dyp_king_crab = combatant {
 
dyp_little_crab = function(nam, index, x, y) 
 
    return combatant {
 
        nam = nam;
 
        disp = "детеныш краба " .. tostring(index);
 
        disp2 = "детеныша краба " .. tostring(index);
 
        disp3 = "детенышу краба " .. tostring(index);
 
        x = x;
 
@@ -2712,6 +2773,12 @@ dyp_little_crab = function(nam, index, x
 
        handKill = "Вы ударяет детеныша краба, убивая его. ";
 
        handFar = "Слишком далеко. ";
 
        enemy = true;
 
        state = function(s)
 
            if s.hp == 1 then
 
                return "Он ранен. ";
 
            end;
 
            return "";
 
        end;
 
        dsc = function(s)
 
            if (s.hp > 0) then
 
                return "{Детеныш краба " .. tostring(index).. "} готов к бою. ";
battlefield.lua
Show inline comments
 
@@ -135,6 +135,104 @@ battlefield = function(tab)
 
    tab.nosave = true;
 
    tab.noautosave = true;
 
    tab.not_follow = true;
 

	
 
    tab.ui_state = nil;
 

	
 
    tab.click = function(s, x, y)
 
        local tx = math.floor(x / 32) + 1;
 
        local ty = math.floor(y / 32) + 1;
 
        if s.ui_state == nil then
 
            -- No tile selected
 
            if s.plX == tx and s.plY == ty then
 
                pr [[Это вы. ]];
 
                if pl.hp > 9 then
 
                    pr [[Вы не ранены. ]];
 
                elseif pl.hp > 7 then
 
                    pr [[Вы легко ранены. ]];
 
                elseif pl.hp > 3 then
 
                    pr [[Вы ранены. ]];
 
                else
 
                    pr [[Вы тяжело ранены. ]];
 
                end;
 
                pr [[Нажмите еще раз, чтобы ждать. ]];
 
                s.ui_state = 1;
 
                return;
 
            end;
 
            for i = 1, #s.obj do
 
                -- TODO hp state of other units
 
                if not disabled(s.obj[i]) and (s.obj[i].hp == nil or s.obj[i].hp > 0) then
 
                    if (s.obj[i].x == tx and s.obj[i].y == ty) then
 
                        pr('Это ' .. s.obj[i].disp);
 
                        if s.obj[i].enemy then
 
                            pr(', ваш противник. ');
 
                        elseif s.obj[i].ally then
 
                            pr(', ваш союзник. ');
 
                        else
 
                            pr('. ');
 
                        end;
 

	
 
                        pr(EngineUtils.getValue(s.obj[i].state, s.obj[i]));
 

	
 
                        if s.obj[i].enemy then
 
                            if s.obj[i]:canhit() or (s.obj[i]:canthrust() and have(item_harpoon)) then
 
                                s.ui_state = {tx, ty, 'hit', s.obj[i]};
 
                                pr('Нажмите еще раз, чтобы ударить. ');
 
                            elseif s:canShoot(s.plX, s.plY, tx, ty) and (have(item_colt) and not s.underwater) or (have(item_harpoon)) then
 
                                if have(item_colt) and not s.underwater and item_colt.bullets == 0 then
 
                                    pr [[Ваш револьвер не заряжен. ]];
 
                                elseif have(item_harpoon) and item_harpoon.charge == 0 then
 
                                    pr [[Ваше ружье не заряжено. ]];
 
                                else
 
                                    s.ui_state = {tx, ty, 'shoot', s.obj[i]};
 
                                    pr('Нажмите еще раз, чтобы выстрелить. ');
 
                                end;
 
                            end;
 
                        end;
 
                        return;
 
                    end;
 
                end;
 
            end;
 
            if math.abs(s.plX - tx) + math.abs(s.plY - ty) < 2 then
 
                s.ui_state = {tx, ty, 'walk'};
 
                pr('Нажмите еще раз, чтобы идти. ');
 
            end;
 
        elseif s.ui_state == 1 then
 
            -- tile selected. Click same tile to confirm action, or elsewhere to cancel
 
            s.ui_state = nil;
 
            if s.plX == tx and s.plY == ty then
 
                p("Вы ждете. ");
 
                here():make_turn();
 
            else
 
                pr [[Действие отменено. ]];
 
            end;
 
        else
 
            if tx == s.ui_state[1] and ty == s.ui_state[2] then
 
                if s.ui_state[3] == 'shoot' then
 
                    if have(item_colt) and not s.underwater and item_colt.bullets > 0 then
 
                        item_colt:use(s.ui_state[4]);
 
                    elseif have(item_harpoon) and item_harpoon.charge > 0 then
 
                        item_harpoon:use(s.ui_state[4]);
 
                    else
 
                        pr [[Если вы видите это сообщение -- это баг. ]];
 
                    end;
 
                elseif s.ui_state[3] == 'hit' then
 
                    if have(item_harpoon) then
 
                        pr(item_harpoon:use(s.ui_state[4]));
 
                    else
 
                        pr(s.ui_state[4]:act());
 
                    end;
 
                elseif s.ui_state[3] == 'walk' then
 
                    here().plX = s.ui_state[1];
 
                    here().plY = s.ui_state[2];
 
                    here():make_turn();
 
                end;
 
            else
 
                pr [[Действие отменено. ]];
 
            end;
 
            s.ui_state = nil;
 
        end;
 
    end;
 

	
 
    tab.isPassable = function(s, x, y)
 
        if (x < 1 or x > 7 or y < 1 or y > 7 or tab.map[y][x] > 0) then
 
            return false;
lse_confrontation.lua
Show inline comments
 
@@ -450,6 +450,7 @@ lse_prison_fight = battlefield {
 

	
 
lse_cmbt_learr = combatant {
 
    nam = "lse_cmbt_learr";
 
    disp = "Леарр";
 
    disp2 = "Леарр";
 
    disp3 = "Леарр";
 
    x = 7;
 
@@ -460,6 +461,17 @@ lse_cmbt_learr = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasSpear = false;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Она легко ранена. ";
 
        elseif s.hp > 3 then
 
            return "Она ранена. ";
 
        else
 
            return "Она тяжело ранена. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -541,6 +553,7 @@ lse_cmbt_learr = combatant {
 

	
 
lse_cmbt_phaetlarr = combatant {
 
    nam = "lse_cmbt_phaetlarr";
 
    disp = "Фаэтларр";
 
    disp2 = "Фаэтларра";
 
    disp3 = "Фаэтларру";
 
    x = 4;
 
@@ -551,6 +564,17 @@ lse_cmbt_phaetlarr = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasSpear = false;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Он легко ранен. ";
 
        elseif s.hp > 3 then
 
            return "Он ранен. ";
 
        else
 
            return "Он тяжело ранен. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -632,6 +656,7 @@ lse_cmbt_phaetlarr = combatant {
 

	
 
lse_cmbt_wright = combatant {
 
    nam = "lse_cmbt_wright";
 
    disp = "Джек";
 
    disp2 = "Джека";
 
    disp3 = "Джеку";
 
    x = 1;
 
@@ -642,6 +667,17 @@ lse_cmbt_wright = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = false;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Он легко ранен. ";
 
        elseif s.hp > 3 then
 
            return "Он ранен. ";
 
        else
 
            return "Он тяжело ранен. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -692,6 +728,7 @@ lse_cmbt_wright = combatant {
 

	
 
lse_cmbt_radcliffe = combatant {
 
    nam = "lse_cmbt_radcliffe";
 
    disp = "Уолтер";
 
    disp2 = "Уолтера";
 
    disp3 = "Уолтеру";
 
    x = 1;
 
@@ -702,6 +739,17 @@ lse_cmbt_radcliffe = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = false;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Он легко ранен. ";
 
        elseif s.hp > 3 then
 
            return "Он ранен. ";
 
        else
 
            return "Он тяжело ранен. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -752,6 +800,7 @@ lse_cmbt_radcliffe = combatant {
 

	
 
lse_cmbt_anna = combatant {
 
    nam = "lse_cmbt_anna";
 
    disp = "Анна";
 
    disp2 = "Анну";
 
    disp3 = "Анне";
 
    x = 7;
 
@@ -762,6 +811,17 @@ lse_cmbt_anna = combatant {
 
    noshoot = "Я не буду атаковать союзника.";
 
    hp = 10;
 
    hasHarpoon = false;
 
    state = function(s)
 
        if s.hp == 10 then
 
            return "";
 
        elseif s.hp > 7 then
 
            return "Она легко ранена. ";
 
        elseif s.hp > 3 then
 
            return "Она ранена. ";
 
        else
 
            return "Она тяжело ранена. ";
 
        end;
 
    end;
 
    make_turn = function(s)
 
        local enemies = {  };
 
        for item=1,#here().obj do
 
@@ -813,6 +873,7 @@ lse_cmbt_anna = combatant {
 
lse_cmbt_guard = function(nam, index, x, y, spear) 
 
    return combatant {
 
        nam = nam;
 
        disp = "стражник " .. tostring(index);
 
        disp2 = "стражника " .. tostring(index);
 
        disp3 = "стражнику " .. tostring(index);
 
        x = x;
 
@@ -827,6 +888,17 @@ lse_cmbt_guard = function(nam, index, x,
 
        handFar = "Слишком далеко. ";
 
        hasSpear = spear;
 
        enemy = true;
 
        state = function(s)
 
            if s.hp == 4 then
 
                return "";
 
            elseif s.hp == 3 then
 
                return "Он легко ранен. ";
 
            elseif s.hp == 2 then
 
                return "Он ранен. ";
 
            else
 
                return "Он тяжело ранен. ";
 
            end;
 
        end;
 
        dsc = function(s)
 
            if (s.hp > 0) then
 
                if (s.hasSpear) then
lse_final_battle.lua
Show inline comments
 
@@ -284,6 +284,13 @@ lse_generator = function(nam, x, y, inde
 
        y = y;
 
        hp = 2;
 
        broken = false;
 
        state = function(s)
 
            if s.hp == 2 then
 
                return "";
 
            elseif s.hp == 1 then
 
                return "Он поврежден, но работает. ";
 
            end;
 
        end;
 
        pic = function(s)
 
            layers = {
 
                'images/fb_generator' .. tostring(index) .. '.png'
 
@@ -306,6 +313,7 @@ lse_generator = function(nam, x, y, inde
 
            return layers;
 
        end;
 
        enemy = true;
 
        disp = "генератор " .. tostring(index);
 
        disp2 = "генератор " .. tostring(index);
 
        disp3 = "генератор " .. tostring(index);
 
        dsc = function(s)
 
@@ -399,6 +407,7 @@ lse_gen_10 = lse_generator("lse_gen_10",
 
lse_pylon = function(nam, x, y, index)
 
    return combatant {
 
        nam = nam;
 
        disp = "пилон " .. tostring(index);
 
        disp2 = "пилон " .. tostring(index);
 
        disp3 = "пилон " .. tostring(index);
 
        pic = "images/fb_pylon.png";
 
@@ -409,6 +418,7 @@ lse_pylon = function(nam, x, y, index)
 
        shootMiss = "Вы промахиваетесь мимо пилона, являющегося достаточно сложной целью. ";
 
        shootKill = "Каким-то чудом, вы попадаете в пилон и выводите его из строя. ";
 
        enemy = true;
 
        state = "";
 
        dsc = function(s)
 
            if (s.hp > 0) then
 
                return [[{Пилон ]] .. tostring(index) .. "} излучает слабое свечение. ";
 
@@ -453,13 +463,16 @@ lse_throne = combatant {
 
    hp = 1;
 
    pic = "images/fb_naethvjirr.png";
 
    obst = 1;
 
    disp = "трон";
 
    enemy = false;
 
    ally = false;
 
    state = "";
 
    dsc = [[В центре комнаты установлен металлический трон. Рядом с ним валяется выведенный из строя автоматон-навьяр. ]];
 
};
 

	
 
lse_naethvjirr = combatant {
 
    nam = "lse_naethvjirr";
 
    disp = "Наэтвьирр";
 
    disp2 = "Наэтвьирра";
 
    disp3 = "Наэтвьирру";
 
    x = 4;
 
@@ -479,7 +492,15 @@ lse_naethvjirr = combatant {
 
    handHit = "Вы попадаете в Наэтвьирра. ";
 
    handMiss = "Вы промахиваетесь мимо Наэтвьирра. ";
 
    handKill = "Вы попадаете в Наэтвьирра. Глаза автоматона гаснут и он с грохотом падает на пол. ";
 
    dsc =function(s)
 
    state = function(s)
 
        if s.hp == 2 then
 
            return "Он поврежден. ";
 
        elseif s.hp == 1 then
 
            return "Он сильно поврежден. ";
 
        end;
 
        return "";
 
    end;
 
    dsc = function(s)
 
        local p = [[В центре комнаты установлен металлический трон. Рядом с ним стоит {автоматон-навьяр}, готовый к бою. ]];
 
        
 
        if (lse_generators_chShield <= 0) then
 
@@ -599,6 +620,7 @@ lse_naethvjirr = combatant {
 

	
 
lse_drake = combatant {
 
    nam = "lse_drake";
 
    disp = "Уильям Дрейк";
 
    disp2 = "Уильяма Дрейка";
 
    disp3 = "Уильяму Дрейку";
 
    shootHit = "Вы стреляете в Уильяма и попадаете в него. ";
 
@@ -612,6 +634,7 @@ lse_drake = combatant {
 
    hp = 1;
 
    pic = "images/fb_drake.png";
 
    gun = 6;
 
    state = "";
 
    dsc = function(s)
 
        if s.hp > 0 then
 
            return [[{Уильям Дрейк} готов к бою. ]];
 
@@ -686,6 +709,7 @@ lse_aedhyarr = combatant {
 
    x = 5;
 
    y = 3;
 
    hp = 1;
 
    disp = "Аэдхиарр";
 
    disp2 = "Аэдхиарра";
 
    disp3 = "Аэдхиарру";
 
    pic = "images/aedhyarr.png";
 
@@ -696,6 +720,7 @@ lse_aedhyarr = combatant {
 
    handKill = "После вашего удара Аэдхиарр падает. ";
 
    handFar = "Слишком далеко. ";
 
    gun = 6;
 
    state = "";
 
    dsc = function(s)
 
        if s.hp > 0 then
 
            return [[{Аэдхиарр} готов к бою. ]];
startup.lua
Show inline comments
 
@@ -193,8 +193,17 @@ function init()
 
    ---game init
 
    pl.where = intro;
 
    ---debug
 
    --pl.where = atl_dom_main_near_adm;
 
    --take(item_naethvjirr_key);
 
    pl.party = {'wright', 'radcliffe', 'learr', 'phaetlarr'};
 
    char_learr:accompany(true);
 
    --char_radcliffe:accompany(true);
 
    --char_learr:accompany(true);
 
    --char_phaetlarr:accompany(true);
 
    pl.where = dyp_crab_fight_intro;
 
    -- pl.where = lse_prison_fight_intro;
 
    -- pl.where = lse_final_battle;
 

	
 
    take(item_colt);
 
    take(item_harpoon);
 
    --[[put(char_learr, 'aurora_borealis');
 
    atl_iyh_state = 7;
 
    ven_quest_status = 8;
0 comments (0 inline, 0 general)