mirror of
https://github.com/LDDestroier/CC/
synced 2025-02-07 14:40:03 +00:00
Made damage separate from panels
This commit is contained in:
parent
eadcae3482
commit
f8dec59229
47
ccbn.lua
47
ccbn.lua
@ -1,6 +1,3 @@
|
|||||||
-- slowly, I'll get rid of NFTE as a dependency by copying over specific functions from it
|
|
||||||
-- local nfte = dofile("nfte.lua")
|
|
||||||
|
|
||||||
local scr_x, scr_y = term.getSize()
|
local scr_x, scr_y = term.getSize()
|
||||||
local keysDown, miceDown = {}, {}
|
local keysDown, miceDown = {}, {}
|
||||||
|
|
||||||
@ -12,6 +9,7 @@ local FRAME = 0
|
|||||||
|
|
||||||
local stage = {
|
local stage = {
|
||||||
panels = {},
|
panels = {},
|
||||||
|
damage = {},
|
||||||
panelWidth = 6,
|
panelWidth = 6,
|
||||||
panelHeight = 2,
|
panelHeight = 2,
|
||||||
scrollX = 0,
|
scrollX = 0,
|
||||||
@ -177,7 +175,6 @@ act.stage.newPanel = function(x, y, panelType, owner)
|
|||||||
reserved = false,
|
reserved = false,
|
||||||
crackedLevel = 0, -- 0 is okay, 1 is cracked, 2 is broken
|
crackedLevel = 0, -- 0 is okay, 1 is cracked, 2 is broken
|
||||||
owner = owner or (x > 3 and 2 or 1),
|
owner = owner or (x > 3 and 2 or 1),
|
||||||
damage = {},
|
|
||||||
cooldown = {
|
cooldown = {
|
||||||
owner = 0,
|
owner = 0,
|
||||||
broken = 0,
|
broken = 0,
|
||||||
@ -193,26 +190,26 @@ act.stage.checkExist = function(x, y)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
act.stage.setDamage = function(x, y, damage, owner, time)
|
act.stage.setDamage = function(x, y, damage, owner, time)
|
||||||
if act.stage.checkExist(x, y) then
|
stage.damage[y] = stage.damage[y] or {}
|
||||||
stage.panels[y][x].damage[owner] = {
|
stage.damage[y][x] = stage.damage[y][x] or {}
|
||||||
owner = owner,
|
stage.damage[y][x][owner] = {
|
||||||
time = time,
|
owner = owner,
|
||||||
damage = damage,
|
time = time,
|
||||||
}
|
damage = damage,
|
||||||
end
|
}
|
||||||
end
|
end
|
||||||
act.stage.getDamage = function(x, y, owner)
|
act.stage.getDamage = function(x, y, owner)
|
||||||
if act.stage.checkExist(x, y) then
|
local totalDamage = 0
|
||||||
local totalDamage = 0
|
if stage.damage[y] then
|
||||||
for k,v in pairs(stage.panels[y][x].damage) do
|
if stage.damage[y][x] then
|
||||||
if k ~= owner then
|
for k,v in pairs(stage.damage[y][x]) do
|
||||||
totalDamage = totalDamage + v.damage
|
if k ~= owner then
|
||||||
|
totalDamage = totalDamage + v.damage
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return totalDamage
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
end
|
end
|
||||||
|
return totalDamage
|
||||||
end
|
end
|
||||||
|
|
||||||
act.player.newPlayer = function(x, y, owner)
|
act.player.newPlayer = function(x, y, owner)
|
||||||
@ -375,16 +372,14 @@ local reduceCooldowns = function()
|
|||||||
players[i].cooldown[k] = math.max(0, v - 1)
|
players[i].cooldown[k] = math.max(0, v - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for y = 1, #stage.panels do
|
for y, row in pairs(stage.damage) do
|
||||||
for x = 1, #stage.panels[y] do
|
for x, panel in pairs(row) do
|
||||||
|
for owner, damageData in pairs(panel) do
|
||||||
for owner, damageData in pairs(stage.panels[y][x].damage) do
|
stage.damage[y][x][owner].time = math.max(0, damageData.time - 1)
|
||||||
stage.panels[y][x].damage[owner].time = math.max(0, damageData.time - 1)
|
|
||||||
if damageData.time == 0 then
|
if damageData.time == 0 then
|
||||||
stage.panels[y][x].damage[owner] = nil
|
stage.damage[y][x][owner] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user