Changeset - f7ea55cc58f4
[Not reviewed]
default
0 2 0
Silverwing - 5 years ago 2019-05-12 11:45:54

Mouse-driven combat interface updates
2 files changed with 12 insertions and 8 deletions:
0 comments (0 inline, 0 general)
battlefield.lua
Show inline comments
 
@@ -21,8 +21,6 @@
 
                return item;
 
            end;
 
            table.insert(closed, node);
 
            --print("closed", #closed);
 
            --print("open", #open);
 

	
 
            local pos = 1;
 
            while (#open >= pos and open[pos].l <= item.l) do
 
@@ -159,7 +157,6 @@ battlefield = function(tab)
 
                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);
 
@@ -176,7 +173,11 @@ battlefield = function(tab)
 
                        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('Нажмите еще раз, чтобы ударить. ');
 
                                if have(item_harpoon) then
 
                                    pr('Нажмите еще раз, чтобы ударить гарпуном. ');
 
                                else
 
                                    pr('Нажмите еще раз, чтобы ударить. ');
 
                                end;
 
                            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 [[Ваш револьвер не заряжен. ]];
 
@@ -193,6 +194,9 @@ battlefield = function(tab)
 
                end;
 
            end;
 
            if math.abs(s.plX - tx) + math.abs(s.plY - ty) < 2 then
 
                if not s:isPassable(tx, ty) then
 
                    return
 
                end;
 
                s.ui_state = {tx, ty, 'walk'};
 
                pr('Нажмите еще раз, чтобы идти. ');
 
            end;
items.lua
Show inline comments
 
@@ -210,10 +210,6 @@ item_harpoon = obj {
 
    dsc = [[К стене прислонено {гарпунное ружье}. ]];
 
    tak = "Вы забираете ружье. ";
 
    use = function(s, o)
 
        if (s.charge == 0) then
 
            return "Ружье не заряжено. ";
 
        end;
 
        
 
        local canshoot = false;
 
        if (type(o.canshoot) == "function") then
 
            canshoot = o:canshoot();
 
@@ -236,6 +232,10 @@ item_harpoon = obj {
 
                return "";
 
            end;
 
        elseif (canshoot) then
 
			if (s.charge == 0) then
 
				return "Ружье не заряжено. ";
 
			end;
 
 
            s.charge = s.charge - 1;
 
            p("Вы стреляете в "..o.disp2 .. ". ");
 
            if (o.onshoot) then
0 comments (0 inline, 0 general)