Mostly refactoring this chaos

This commit is contained in:
Alessandro
2023-01-10 12:23:25 +01:00
parent 10fd6dc40f
commit f9d2831158
7 changed files with 160 additions and 183 deletions

View File

@@ -12,14 +12,14 @@ local function healUpdatePart(partName, modData, player)
if bodyPart:bandaged() then isBand = true; bandLife = bodyPart:getBandageLife(); bandType = bodyPart:getBandageType() end if bodyPart:bandaged() then isBand = true; bandLife = bodyPart:getBandageLife(); bandType = bodyPart:getBandageType() end
--Set max heal --Set max heal
if modData_part.IsCicatrized and bodyPart:getHealth() > 80 then if modData_part.is_cicatrized and bodyPart:getHealth() > 80 then
bodyPart:SetHealth(80); bodyPart:SetHealth(80);
elseif bodyPart:getHealth() > 40 then elseif bodyPart:getHealth() > 40 then
bodyPart:SetHealth(40); bodyPart:SetHealth(40);
end end
--Heal --Heal
if modData_part.IsCicatrized then if modData_part.is_cicatrized then
if bodyPart:deepWounded() then bodyPart:setDeepWounded(false) end if bodyPart:deepWounded() then bodyPart:setDeepWounded(false) end
if bodyPart:bleeding() then bodyPart:setBleeding(false) end if bodyPart:bleeding() then bodyPart:setBleeding(false) end
end end
@@ -42,14 +42,14 @@ local function healUpdatePart(partName, modData, player)
if bodyPart:haveBullet() then bodyPart:setHaveBullet(false, 0) end if bodyPart:haveBullet() then bodyPart:setHaveBullet(false, 0) end
if bodyPart:isInfectedWound() then bodyPart:setInfectedWound(false) end if bodyPart:isInfectedWound() then bodyPart:setInfectedWound(false) end
if bodyPart:isBurnt() then bodyPart:setBurnTime(0) end if bodyPart:isBurnt() then bodyPart:setBurnTime(0) end
if bodyPart:isCut() then bodyPart:setCut(false, false) end if bodyPart:isCut() then bodyPart:setCut(false, false) end --Lacerations?
if bodyPart:getFractureTime()>0 then bodyPart:setFractureTime(0) end if bodyPart:getFractureTime()>0 then bodyPart:setFractureTime(0) end
-- During healing -- During healing
if modData_part.IsCut and not modData_part.IsCicatrized then if modData_part.is_cut and not modData_part.is_cicatrized then
if modData_part.CicaTimeLeft < 0 then if modData_part.CicaTimeLeft < 0 then
player:Say(getText('UI_ContextMenu_My') .. partName .. getText('UI_ContextMenu_Now_cut')) player:Say(getText('UI_ContextMenu_My') .. partName .. getText('UI_ContextMenu_Now_cut'))
modData_part.IsCicatrized = true; modData_part.is_cicatrized = true;
player:getTraits():add("Brave") player:getTraits():add("Brave")
player:getTraits():add("Insensitive") player:getTraits():add("Insensitive")
bodyPart:setBleeding(false); bodyPart:setBleeding(false);
@@ -61,11 +61,15 @@ local function healUpdatePart(partName, modData, player)
end end
--Phantom pain --Phantom pain
if modData_part.ToDisplay then if modData_part.is_amputation_shown and ZombRand(1, 100) < 10 then
if ZombRand(1, 100) < 10 then
if modData_part.IsBurn then x = 60 else x = 30 end if modData_part.is_cauterized then
bodyPart:setAdditionalPain(ZombRand(1, x)); local added_pain = 60
else
local added_pain = 30
end end
bodyPart:setAdditionalPain(ZombRand(1,added_pain))
end end
if isBand then bodyPart:setBandaged(true, bandLife, false, bandType) end if isBand then bodyPart:setBandaged(true, bandLife, false, bandType) end
end end
@@ -82,11 +86,14 @@ end
function UpdatePlayerHealth(player, modData) function UpdatePlayerHealth(player, modData)
local bodyDamage = player:getBodyDamage() local bodyDamage = player:getBodyDamage()
local partNames = {"RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"} --local partNames = {"RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"}
if player:HasTrait("Insensitive") then bodyDamage:setPainReduction(49) end if player:HasTrait("Insensitive") then bodyDamage:setPainReduction(49) end
for i,name in pairs(partNames) do for i,name in pairs(Bodyparts) do
if modData.TOC[name].IsCut then healUpdatePart(name, modData, player) end if modData.TOC[name].is_cut then
healUpdatePart(name, modData, player)
end
end end
end end

View File

@@ -22,12 +22,12 @@ end
local function CheckIfCanBeOperated(modData) local function CheckIfCanBeOperated(modData)
if modData.TOC.RightHand.IsCut and not modData.TOC.RightHand.IsOperated if modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.is_operated
or modData.TOC.RightForearm.IsCut and not modData.TOC.RightForearm.IsOperated or modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.is_operated
or modData.TOC.RightArm.IsCut and not modData.TOC.RightArm.IsOperated or modData.TOC.RightArm.is_cut and not modData.TOC.RightArm.is_operated
or modData.TOC.LeftHand.IsCut and not modData.TOC.LeftHand.IsOperated or modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.is_operated
or modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftForearm.IsOperated or modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.is_operated
or modData.TOC.LeftArm.IsCut and not modData.TOC.LeftArm.IsOperated then or modData.TOC.LeftArm.is_cut and not modData.TOC.LeftArm.is_operated then
return true return true
else else
return false return false
@@ -58,26 +58,18 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldobjects, nil); local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldobjects, nil);
local subMenu = context:getNew(context); local subMenu = context:getNew(context);
context:addSubMenu(rootMenu, subMenu) context:addSubMenu(rootMenu, subMenu)
if modData.TOC.RightHand.IsCut and not modData.TOC.RightForearm.IsCut and not modData.TOC.RightHand.IsOperated then
subMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, operateLocal, "RightHand"); for k, v in pairs(Bodyparts) do
end -- todo this is awful but it should work
if modData.TOC.LeftHand.IsCut and not modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftHand.IsOperated then if modData.TOC[v].is_cut and not modData.TOC[v].is_operated then
subMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, operateLocal, "LeftHand"); subMenu:addOption(getText('UI_ContextMenu_' .. v), worldobjects, operateLocal, v);
end
if modData.TOC.RightForearm.IsCut and not modData.TOC.RightArm.IsCut and not modData.TOC.RightForearm.IsOperated then end
subMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, operateLocal, "RightForearm");
end
if modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftArm.IsCut and not modData.TOC.LeftForearm.IsOperated then
subMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, operateLocal, "LeftForearm");
end
if modData.TOC.RightArm.IsCut and not modData.TOC.RightArm.IsOperated then
subMenu:addOption(getText('UI_ContextMenu_RightArm'), worldobjects, operateLocal, "RightArm");
end
if modData.TOC.LeftArm.IsCut and not modData.TOC.LeftArm.IsOperated then
subMenu:addOption(getText('UI_ContextMenu_LeftArm'), worldobjects, operateLocal, "LeftArm");
end end
break -- stop cycling like an idiot
end end
end end
end end
@@ -92,6 +84,7 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
end end
end end
if clickedPlayer then if clickedPlayer then
-- Pretty sure this check is kinda broken
if not ((-1 < clickedPlayer:getX() - player:getX() and clickedPlayer:getX() - player:getX() < 1) and (-1 < clickedPlayer:getY() - player:getY() and clickedPlayer:getY() - player:getY() < 1)) then if not ((-1 < clickedPlayer:getX() - player:getX() and clickedPlayer:getX() - player:getX() < 1) and (-1 < clickedPlayer:getY() - player:getY() and clickedPlayer:getY() - player:getY() < 1)) then
return false; return false;
end end
@@ -105,20 +98,14 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
context:addSubMenu(rootOption, rootMenu); context:addSubMenu(rootOption, rootMenu);
context:addSubMenu(cutOption, cutMenu); context:addSubMenu(cutOption, cutMenu);
context:addSubMenu(operateOption, operateMenu); context:addSubMenu(operateOption, operateMenu);
-- todo add checks so that we don't show these menus if a player has already beeen operated or amputated
for k, v in pairs(Bodyparts) do
cutMenu:addOption(getText('UI_ContextMenu_' .. v), worldobjects, otherPlayerLocal, v, "Cut", clickedPlayer)
operateMenu:addOption(getText('UI_ContextMenu_' .. v), worldobjects, otherPlayerLocal, v, "Operate", clickedPlayer);
end
cutMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, otherPlayerLocal, "RightHand", "Cut", clickedPlayer);
cutMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, otherPlayerLocal, "LeftHand", "Cut", clickedPlayer);
cutMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, otherPlayerLocal, "RightForearm", "Cut", clickedPlayer);
cutMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, otherPlayerLocal, "LeftForearm", "Cut", clickedPlayer);
cutMenu:addOption(getText('UI_ContextMenu_RightArm'), worldobjects, otherPlayerLocal, "RightArm", "Cut", clickedPlayer);
cutMenu:addOption(getText('UI_ContextMenu_LeftArm'), worldobjects, otherPlayerLocal, "LeftArm", "Cut", clickedPlayer);
operateMenu:addOption(getText('UI_ContextMenu_RightHand'), worldobjects, otherPlayerLocal, "RightHand", "Operate", clickedPlayer);
operateMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, otherPlayerLocal, "LeftHand", "Operate", clickedPlayer);
operateMenu:addOption(getText('UI_ContextMenu_RightForearm'), worldobjects, otherPlayerLocal, "RightForearm", "Operate", clickedPlayer);
operateMenu:addOption(getText('UI_ContextMenu_LeftForearm'), worldobjects, otherPlayerLocal, "LeftForearm", "Operate", clickedPlayer);
operateMenu:addOption(getText('UI_ContextMenu_RightArm'), worldobjects, otherPlayerLocal, "RightArm", "Operate", clickedPlayer);
operateMenu:addOption(getText('UI_ContextMenu_LeftArm'), worldobjects, otherPlayerLocal, "LeftArm", "Operate", clickedPlayer);
end end
end end
end end

View File

@@ -51,12 +51,12 @@ function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller,
elseif bodyPart:getType() == BodyPartType.ForeArm_R then elseif bodyPart:getType() == BodyPartType.ForeArm_R then
modData.RightForearm.IsCut = true; modData.RightHand.IsCut = true; modData.RightForearm.IsCut = true; modData.RightHand.IsCut = true;
modData.RightForearm.ToDisplay = true; modData.RightHand.ToDisplay = false; modData.RightForearm.ToDisplay = true; modData.RightHand.ToDisplay = false;
modData.RightHand.IsBurn = false; modData.RightHand.is_cauterized = false;
modData.RightForearm.CicaTimeLeft = 1800 - surgeonFact * 50; modData.RightHand.CicaTimeLeft = 1800 - surgeonFact * 50; modData.RightForearm.CicaTimeLeft = 1800 - surgeonFact * 50; modData.RightHand.CicaTimeLeft = 1800 - surgeonFact * 50;
elseif bodyPart:getType() == BodyPartType.UpperArm_R then elseif bodyPart:getType() == BodyPartType.UpperArm_R then
modData.RightArm.IsCut = true; modData.RightForearm.IsCut = true; modData.RightHand.IsCut = true; modData.RightArm.IsCut = true; modData.RightForearm.IsCut = true; modData.RightHand.IsCut = true;
modData.RightArm.ToDisplay = true; modData.RightForearm.ToDisplay = false; modData.RightHand.ToDisplay = false; modData.RightArm.ToDisplay = true; modData.RightForearm.ToDisplay = false; modData.RightHand.ToDisplay = false;
modData.RightHand.IsBurn = false; modData.RightForearm.IsBurn = false; modData.RightHand.is_cauterized = false; modData.RightForearm.is_cauterized = false;
modData.RightArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightHand.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightHand.CicaTimeLeft = 2000 - surgeonFact * 50;
elseif bodyPart:getType() == BodyPartType.Hand_L then elseif bodyPart:getType() == BodyPartType.Hand_L then
modData.LeftHand.IsCut = true; modData.LeftHand.IsCut = true;
@@ -65,12 +65,12 @@ function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller,
elseif bodyPart:getType() == BodyPartType.ForeArm_L then elseif bodyPart:getType() == BodyPartType.ForeArm_L then
modData.LeftForearm.IsCut = true; modData.LeftHand.IsCut = true; modData.LeftForearm.IsCut = true; modData.LeftHand.IsCut = true;
modData.LeftForearm.ToDisplay = true; modData.LeftHand.ToDisplay = false; modData.LeftForearm.ToDisplay = true; modData.LeftHand.ToDisplay = false;
modData.LeftHand.IsBurn = false; modData.LeftHand.is_cauterized = false;
modData.LeftForearm.CicaTimeLeft = 1800 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 1800 - surgeonFact * 50; modData.LeftForearm.CicaTimeLeft = 1800 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 1800 - surgeonFact * 50;
elseif bodyPart:getType() == BodyPartType.UpperArm_L then elseif bodyPart:getType() == BodyPartType.UpperArm_L then
modData.LeftArm.IsCut = true; modData.LeftForearm.IsCut = true; modData.LeftHand.IsCut = true; modData.LeftArm.IsCut = true; modData.LeftForearm.IsCut = true; modData.LeftHand.IsCut = true;
modData.LeftArm.ToDisplay = true; modData.LeftForearm.ToDisplay = false; modData.LeftHand.ToDisplay = false; modData.LeftArm.ToDisplay = true; modData.LeftForearm.ToDisplay = false; modData.LeftHand.ToDisplay = false;
modData.LeftHand.IsBurn = false; modData.LeftForearm.IsBurn = false; modData.LeftHand.is_cauterized = false; modData.LeftForearm.is_cauterized = false;
modData.LeftArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 2000 - surgeonFact * 50;
end end
@@ -154,15 +154,15 @@ function OperateArm(partName, surgeonFact, useOven)
if partName == "RightHand" and not modData.RightHand.IsOperated then if partName == "RightHand" and not modData.RightHand.IsOperated then
modData.RightHand.IsOperated = true; modData.RightHand.IsOperated = true;
modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200); modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then modData.RightHand.IsBurn = true end if useOven then modData.RightHand.is_cauterized = true end
elseif partName == "RightForearm" and not modData.RightForearm.IsOperated then elseif partName == "RightForearm" and not modData.RightForearm.IsOperated then
modData.RightForearm.IsOperated = true; modData.RightForearm.IsOperated = true;
modData.RightHand.IsOperated = true; modData.RightHand.IsOperated = true;
modData.RightForearm.CicaTimeLeft = modData.RightForearm.CicaTimeLeft - (surgeonFact * 200); modData.RightForearm.CicaTimeLeft = modData.RightForearm.CicaTimeLeft - (surgeonFact * 200);
modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200); modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then if useOven then
modData.TOC.RightHand.IsBurn = true; modData.TOC.RightHand.is_cauterized = true;
modData.TOC.RightForearm.IsBurn = true; modData.TOC.RightForearm.is_cauterized = true;
end end
elseif partName == "RightArm" and not modData.RightArm.IsOperated then elseif partName == "RightArm" and not modData.RightArm.IsOperated then
modData.RightArm.IsOperated = true; modData.RightArm.IsOperated = true;
@@ -172,22 +172,22 @@ function OperateArm(partName, surgeonFact, useOven)
modData.RightForearm.CicaTimeLeft = modData.RightForearm.CicaTimeLeft - (surgeonFact * 200); modData.RightForearm.CicaTimeLeft = modData.RightForearm.CicaTimeLeft - (surgeonFact * 200);
modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200); modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then if useOven then
modData.RightHand.IsBurn = true; modData.RightHand.is_cauterized = true;
modData.RightForearm.IsBurn = true; modData.RightForearm.is_cauterized = true;
modData.RightArm.IsBurn = true; modData.RightArm.is_cauterized = true;
end end
elseif partName == "LeftHand" and not modData.LeftHand.IsOperated then elseif partName == "LeftHand" and not modData.LeftHand.IsOperated then
modData.LeftHand.IsOperated = true; modData.LeftHand.IsOperated = true;
modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200); modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then modData.LeftHand.IsBurn = true end if useOven then modData.LeftHand.is_cauterized = true end
elseif partName == "LeftForearm" and not modData.LeftForearm.IsOperated then elseif partName == "LeftForearm" and not modData.LeftForearm.IsOperated then
modData.LeftForearm.IsOperated = true; modData.LeftForearm.IsOperated = true;
modData.LeftHand.IsOperated = true; modData.LeftHand.IsOperated = true;
modData.LeftForearm.CicaTimeLeft = modData.LeftForearm.CicaTimeLeft - (surgeonFact * 200); modData.LeftForearm.CicaTimeLeft = modData.LeftForearm.CicaTimeLeft - (surgeonFact * 200);
modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200); modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then if useOven then
modData.LeftHand.IsBurn = true; modData.LeftHand.is_cauterized = true;
modData.LeftForearm.IsBurn = true; modData.LeftForearm.is_cauterized = true;
end end
elseif partName == "LeftArm" and not modData.LeftArm.IsOperated then elseif partName == "LeftArm" and not modData.LeftArm.IsOperated then
modData.LeftArm.IsOperated = true; modData.LeftArm.IsOperated = true;
@@ -197,9 +197,9 @@ function OperateArm(partName, surgeonFact, useOven)
modData.LeftForearm.CicaTimeLeft = modData.LeftForearm.CicaTimeLeft - (surgeonFact * 200); modData.LeftForearm.CicaTimeLeft = modData.LeftForearm.CicaTimeLeft - (surgeonFact * 200);
modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200); modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then if useOven then
modData.LeftHand.IsBurn = true; modData.LeftHand.is_cauterized = true;
modData.LeftForearm.IsBurn = true; modData.LeftForearm.is_cauterized = true;
modData.LeftArm.IsBurn = true; modData.LeftArm.is_cauterized = true;
end end
end end

View File

@@ -39,30 +39,30 @@ end
local function getImageName(partName, modData) local function getImageName(partName, modData)
local partData = modData[partName]; local partData = modData[partName];
local name = ""; local name = "";
if partData.IsCut and partData.IsCicatrized and partData.IsEquiped then -- Cut and equip if partData.is_cut and partData.is_cicatrized and partData.has_prothesis_equipped then -- Cut and equip
if partName == "RightHand" or partName == "LeftHand" then if partName == "RightHand" or partName == "LeftHand" then
name = "media/ui/TOC/" .. partName .. "/Hook.png"; name = "media/ui/TOC/" .. partName .. "/Hook.png";
else else
name = "media/ui/TOC/" .. partName .. "/Prothesis.png"; name = "media/ui/TOC/" .. partName .. "/Prothesis.png";
end end
elseif partData.IsCut and partData.IsCicatrized and not partData.IsEquiped and partData.ToDisplay then -- Cut and heal elseif partData.is_cut and partData.is_cicatrized and not partData.has_prothesis_equipped and partData.ToDisplay then -- Cut and heal
name = "media/ui/TOC/" .. partName .. "/Cut.png"; name = "media/ui/TOC/" .. partName .. "/Cut.png";
elseif partData.IsCut and not partData.IsCicatrized and partData.ToDisplay and not partData.IsOperated then -- Cut not heal elseif partData.is_cut and not partData.is_cicatrized and partData.ToDisplay and not partData.IsOperated then -- Cut not heal
name = "media/ui/TOC/" .. partName .. "/Bleed.png"; name = "media/ui/TOC/" .. partName .. "/Bleed.png";
elseif partData.IsCut and not partData.IsCicatrized and partData.ToDisplay and partData.IsOperated then -- Cut not heal elseif partData.is_cut and not partData.is_cicatrized and partData.ToDisplay and partData.IsOperated then -- Cut not heal
name = "media/ui/TOC/" .. partName .. "/Operate.png"; name = "media/ui/TOC/" .. partName .. "/Operate.png";
elseif partData.IsCut and not partData.ToDisplay then -- Empty (like hand if forearm cut) elseif partData.is_cut and not partData.ToDisplay then -- Empty (like hand if forearm cut)
name = "media/ui/TOC/Empty.png"; name = "media/ui/TOC/Empty.png";
elseif not partData.IsCut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(partName)):bitten() then -- Not cut but bitten elseif not partData.is_cut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(partName)):bitten() then -- Not cut but bitten
name = "media/ui/TOC/" .. partName .. "/Bite.png"; name = "media/ui/TOC/" .. partName .. "/Bite.png";
else -- Not cut else -- Not cut
name = "media/ui/TOC/" .. partName .. "/Base.png"; name = "media/ui/TOC/" .. partName .. "/Base.png";
end end
-- If foreaerm equip, change hand -- If foreaerm equip, change hand
if partName == "RightHand" and modData["RightForearm"].IsEquiped then if partName == "RightHand" and modData["RightForearm"].has_prothesis_equipped then
name = "media/ui/TOC/" .. partName .. "/Hook.png"; name = "media/ui/TOC/" .. partName .. "/Hook.png";
elseif partName == "LeftHand" and modData["LeftForearm"].IsEquiped then elseif partName == "LeftHand" and modData["LeftForearm"].has_prothesis_equipped then
name = "media/ui/TOC/" .. partName .. "/Hook.png"; name = "media/ui/TOC/" .. partName .. "/Hook.png";
end end
return name; return name;
@@ -133,7 +133,7 @@ local function setDescUI(partName)
descUI.partNameAct = partName; descUI.partNameAct = partName;
-- Cut and equip -- Cut and equip
if partData.IsCut and partData.IsCicatrized and partData.IsEquiped then if partData.is_cut and partData.is_cicatrized and partData.has_prothesis_equipped then
descUI["textEtat"]:setText("Cut and healed"); descUI["textEtat"]:setText("Cut and healed");
descUI["textEtat"]:setColor(1, 0, 1, 0); descUI["textEtat"]:setColor(1, 0, 1, 0);
descUI["b1"]:setText("Unequip"); descUI["b1"]:setText("Unequip");
@@ -141,7 +141,7 @@ local function setDescUI(partName)
descUI["b1"]:setVisible(true); descUI["b1"]:setVisible(true);
-- Cut and healed -- Cut and healed
elseif partData.IsCut and partData.IsCicatrized and not partData.IsEquiped and partData.ToDisplay then elseif partData.is_cut and partData.is_cicatrized and not partData.has_prothesis_equipped and partData.ToDisplay then
descUI["textEtat"]:setText("Cut and healed"); descUI["textEtat"]:setText("Cut and healed");
descUI["textEtat"]:setColor(1, 0, 1, 0); descUI["textEtat"]:setColor(1, 0, 1, 0);
if partName == "RightArm" or partName == "LeftArm" then if partName == "RightArm" or partName == "LeftArm" then
@@ -153,7 +153,7 @@ local function setDescUI(partName)
end end
-- Cut but not healed -- Cut but not healed
elseif partData.IsCut and not partData.IsCicatrized and partData.ToDisplay then elseif partData.is_cut and not partData.is_cicatrized and partData.ToDisplay then
if partData.IsOperated then if partData.IsOperated then
if partData.CicaTimeLeft > 1000 then if partData.CicaTimeLeft > 1000 then
descUI["textEtat"]:setText("Still a long way to go") descUI["textEtat"]:setText("Still a long way to go")
@@ -188,11 +188,11 @@ local function setDescUI(partName)
descUI["b1"]:addArg("option", "Operate"); descUI["b1"]:addArg("option", "Operate");
descUI["b1"]:setVisible(true); descUI["b1"]:setVisible(true);
end end
elseif partData.IsCut and not partData.ToDisplay then -- Empty (hand if forearm cut) elseif partData.is_cut and not partData.ToDisplay then -- Empty (hand if forearm cut)
descUI["textEtat"]:setText("Nothing here..."); descUI["textEtat"]:setText("Nothing here...");
descUI["textEtat"]:setColor(1, 1, 1, 1); descUI["textEtat"]:setColor(1, 1, 1, 1);
descUI["b1"]:setVisible(false); descUI["b1"]:setVisible(false);
elseif not partData.IsCut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(partName)):bitten() then elseif not partData.is_cut and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(partName)):bitten() then
descUI["textEtat"]:setText("Bitten..."); descUI["textEtat"]:setText("Bitten...");
descUI["textEtat"]:setColor(1, 1, 0, 0); descUI["textEtat"]:setColor(1, 1, 0, 0);
if isPlayerHaveSaw() then if isPlayerHaveSaw() then
@@ -202,7 +202,7 @@ local function setDescUI(partName)
else else
descUI["b1"]:setVisible(false); descUI["b1"]:setVisible(false);
end end
elseif not partData.IsCut then -- Not cut elseif not partData.is_cut then -- Not cut
descUI["textEtat"]:setText("Not cut"); descUI["textEtat"]:setText("Not cut");
descUI["textEtat"]:setColor(1, 1, 1, 1); descUI["textEtat"]:setColor(1, 1, 1, 1);
if isPlayerHaveSaw() then if isPlayerHaveSaw() then
@@ -328,7 +328,7 @@ local function confirmPress(button, args)
local player = getPlayer(); local player = getPlayer();
if confirmUI.actionAct == "Cut" then if confirmUI.actionAct == "Cut" then
if args.option == "yes" then if args.option == "yes" then
ISTimedActionQueue.add(IsCutArm:new(player, player, descUI.partNameAct)); ISTimedActionQueue.add(is_cutArm:new(player, player, descUI.partNameAct));
else else
getPlayer():Say("Never mind"); getPlayer():Say("Never mind");
end end
@@ -353,10 +353,10 @@ local function confirmPressMP(button, args)
local player = getPlayer(); local player = getPlayer();
if confirmUIMP.actionAct == "Cut" then if confirmUIMP.actionAct == "Cut" then
if args.option == "yes" then if args.option == "yes" then
getPlayer():Say("Ok let's begging, courage !"); getPlayer():Say("Hold on, I believe in you!");
ISTimedActionQueue.add(IsCutArm:new(confirmUIMP.patient, player, confirmUIMP.partNameAct)); ISTimedActionQueue.add(is_cutArm:new(confirmUIMP.patient, player, confirmUIMP.partNameAct));
else else
getPlayer():Say("Never mind"); getPlayer():Say("Alright...");
end end
end end
if confirmUIMP.actionAct == "Operate" then if confirmUIMP.actionAct == "Operate" then
@@ -389,8 +389,8 @@ local function descPress(button, args)
if args.option == "Cut" then if args.option == "Cut" then
local modData = player:getModData().TOC; local modData = player:getModData().TOC;
-- Do not cut if prothesis equip -- Do not cut if prothesis equip
if (string.find(descUI.partNameAct, "Right") and (modData["RightHand"].IsEquiped or modData["RightForearm"].IsEquiped)) if (string.find(descUI.partNameAct, "Right") and (modData["RightHand"].has_prothesis_equipped or modData["RightForearm"].has_prothesis_equipped))
or (string.find(descUI.partNameAct, "Left") and (modData["LeftHand"].IsEquiped or modData["LeftForearm"].IsEquiped)) then or (string.find(descUI.partNameAct, "Left") and (modData["LeftHand"].has_prothesis_equipped or modData["LeftForearm"].has_prothesis_equipped)) then
player:Say("I need to remove my prothesis first"); player:Say("I need to remove my prothesis first");
mainUI:close(); mainUI:close();
return false; return false;

View File

@@ -1,10 +1,10 @@
local function dropItem(player, modData) local function dropItem(player, modData)
if (modData.TOC.RightHand.IsCut and not (modData.TOC.RightHand.IsEquiped or modData.TOC.RightForearm.IsEquiped)) or (modData.TOC.RightForearm.IsCut and not modData.TOC.RightForearm.IsEquiped) then if (modData.TOC.RightHand.is_cut and not (modData.TOC.RightHand.IsEquiped or modData.TOC.RightForearm.IsEquiped)) or (modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.IsEquiped) then
if player:getPrimaryHandItem() ~= nil then if player:getPrimaryHandItem() ~= nil then
if player:getPrimaryHandItem():getName() ~= "Bare Hands" then player:dropHandItems() end if player:getPrimaryHandItem():getName() ~= "Bare Hands" then player:dropHandItems() end
end end
end end
if (modData.TOC.LeftHand.IsCut and not (modData.TOC.LeftHand.IsEquiped or modData.TOC.LeftForearm.IsEquiped)) or (modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftForearm.IsEquiped) then if (modData.TOC.LeftHand.is_cut and not (modData.TOC.LeftHand.IsEquiped or modData.TOC.LeftForearm.IsEquiped)) or (modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.IsEquiped) then
if player:getSecondaryHandItem() ~= nil then if player:getSecondaryHandItem() ~= nil then
if player:getSecondaryHandItem():getName() ~= "Bare Hands" then player:dropHandItems() end if player:getSecondaryHandItem():getName() ~= "Bare Hands" then player:dropHandItems() end
end end
@@ -33,8 +33,8 @@ local function everyTenMinutes()
--Reduit le temps de cicatri restant --Reduit le temps de cicatri restant
for i,name in pairs(names) do for i,name in pairs(names) do
if modData.TOC[name].IsCut and not modData.TOC[name].IsCicatrized then if modData.TOC[name].is_cut and not modData.TOC[name].is_cicatrized then
modData.TOC[name].CicaTimeLeft = modData.TOC[name].CicaTimeLeft - 1; modData.TOC[name].cicatrization_time = modData.TOC[name].cicatrization_time - 1;
player:transmitModData() player:transmitModData()
end end
end end
@@ -44,106 +44,79 @@ end
local function initVariable(_, player) local function initVariable(_, player)
local modData = player:getModData() local modData = player:getModData()
if modData.TOC == nil then if modData.TOC == nil then
modData.TOC = {};
modData.TOC.RightHand = {};
modData.TOC.RightForearm = {};
modData.TOC.RightArm = {};
modData.TOC.LeftHand = {};
modData.TOC.LeftForearm = {};
modData.TOC.LeftArm = {};
modData.TOC.RightHand.IsCut = false; -- https://stackoverflow.com/questions/20915164/lua-loop-for-creating-variables-in-table
modData.TOC.RightForearm.IsCut = false;
modData.TOC.RightArm.IsCut = false;
modData.TOC.LeftHand.IsCut = false;
modData.TOC.LeftForearm.IsCut = false;
modData.TOC.LeftArm.IsCut = false;
modData.TOC.RightHand.IsInfected = false; local rightHand = "RightHand"
modData.TOC.RightForearm.IsInfected = false; local rightForearm = "RightForearm"
modData.TOC.RightArm.IsInfected = false; local rightArm = "RightArm"
modData.TOC.LeftHand.IsInfected = false;
modData.TOC.LeftForearm.IsInfected = false;
modData.TOC.LeftArm.IsInfected = false;
modData.TOC.RightHand.IsOperated = false; local leftHand = "LeftHand"
modData.TOC.RightForearm.IsOperated = false; local leftForearm = "LeftForearm"
modData.TOC.RightArm.IsOperated = false; local leftArm = "LeftArm"
modData.TOC.LeftHand.IsOperated = false;
modData.TOC.LeftForearm.IsOperated = false;
modData.TOC.LeftArm.IsOperated = false;
modData.TOC.RightHand.IsCicatrized = false;
modData.TOC.RightForearm.IsCicatrized = false;
modData.TOC.RightArm.IsCicatrized = false;
modData.TOC.LeftHand.IsCicatrized = false;
modData.TOC.LeftForearm.IsCicatrized = false;
modData.TOC.LeftArm.IsCicatrized = false;
modData.TOC.RightHand.IsEquiped = false;
modData.TOC.RightForearm.IsEquiped = false;
modData.TOC.RightArm.IsEquiped = false;
modData.TOC.LeftHand.IsEquiped = false;
modData.TOC.LeftForearm.IsEquiped = false;
modData.TOC.LeftArm.IsEquiped = false;
modData.TOC.RightHand.IsBurn = false; Bodyparts = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"}
modData.TOC.RightForearm.IsBurn = false;
modData.TOC.RightArm.IsBurn = false;
modData.TOC.LeftHand.IsBurn = false;
modData.TOC.LeftForearm.IsBurn = false;
modData.TOC.LeftArm.IsBurn = false;
modData.TOC.RightHand.EquipFact = 1.0; modData.TOC = {
modData.TOC.RightForearm.EquipFact = 1.0; RightHand = {},
modData.TOC.RightArm.EquipFact = 1.0; RightForearm = {},
modData.TOC.LeftHand.EquipFact = 1.0; RightArm = {},
modData.TOC.LeftForearm.EquipFact = 1.0;
modData.TOC.LeftArm.EquipFact = 1.0;
modData.TOC.RightHand.Equip_mat_id = nil; LeftHand = {},
modData.TOC.RightForearm.Equip_mat_id = nil; LeftForearm = {},
modData.TOC.RightArm.Equip_mat_id = nil; LeftArm = {}
modData.TOC.LeftHand.Equip_mat_id = nil; }
modData.TOC.LeftForearm.Equip_mat_id = nil;
modData.TOC.LeftArm.Equip_mat_id = nil; for k,v in pairs(Bodyparts) do
modData.TOC[v].is_cut = false
modData.TOC[v].is_infected = false
modData.TOC[v].is_operated = false
modData.TOC[v].is_cicatrized = false
modData.TOC[v].is_cauterized = false
modData.TOC[v].is_amputation_shown = false
modData.TOC[v].cicatrization_time = 0
modData.TOC[v].has_prothesis_equipped = false
modData.TOC[v].prothesis_factor = 1.0 -- Every prothesis has the same... does this even make sense here?
modData.TOC[v].prothesis_material_id = nil
end
-- Manual stuff
modData.TOC[rightForearm].depends_on = {rightHand}
modData.TOC[rightArm].depends_on = { rightHand, rightForearm }
modData.TOC[leftForearm].depends_on = { leftHand }
modData.TOC[leftArm].depends_on = { leftHand, leftForearm }
modData.TOC.RightHand.CicaTimeLeft = 0;
modData.TOC.RightForearm.CicaTimeLeft = 0;
modData.TOC.RightArm.CicaTimeLeft = 0;
modData.TOC.LeftHand.CicaTimeLeft = 0;
modData.TOC.LeftForearm.CicaTimeLeft = 0;
modData.TOC.LeftArm.CicaTimeLeft = 0;
modData.TOC.RightHand.ToDisplay = false;
modData.TOC.RightForearm.ToDisplay = false;
modData.TOC.RightArm.ToDisplay = false;
modData.TOC.LeftHand.ToDisplay = false;
modData.TOC.LeftForearm.ToDisplay = false;
modData.TOC.LeftArm.ToDisplay = false;
modData.TOC.InitDone = true;
modData.TOC.OtherBody_IsInfected = false;
if player:HasTrait("amputee1") then if player:HasTrait("amputee1") then
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noHand"); local cloth = player:getInventory():AddItem("TOC.ArmLeft_noHand");
player:setWornItem(cloth:getBodyLocation(), cloth); player:setWornItem(cloth:getBodyLocation(), cloth);
modData.TOC.LeftHand.IsCut=true; modData.TOC.LeftHand.IsOperated=true; modData.TOC.LeftHand.ToDisplay=true; modData.TOC.LeftHand.IsCicatrized=true; modData.TOC.LeftHand.is_cut=true; modData.TOC.LeftHand.is_operated=true; modData.TOC.LeftHand.is_amputation_shown=true; modData.TOC.LeftHand.is_cicatrized=true;
player:getInventory():AddItem("TOC.MetalHook"); player:getInventory():AddItem("TOC.MetalHook");
end end
if player:HasTrait("amputee2") then if player:HasTrait("amputee2") then
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noForearm"); local cloth = player:getInventory():AddItem("TOC.ArmLeft_noForearm");
player:setWornItem(cloth:getBodyLocation(), cloth); player:setWornItem(cloth:getBodyLocation(), cloth);
modData.TOC.LeftHand.IsCut=true; modData.TOC.LeftHand.IsOperated=true; modData.TOC.LeftHand.is_cut=true; modData.TOC.LeftHand.is_operated=true;
modData.TOC.LeftForearm.IsCut=true; modData.TOC.LeftForearm.IsOperated=true; modData.TOC.LeftForearm.ToDisplay=true; modData.TOC.LeftForearm.IsCicatrized=true; modData.TOC.LeftForearm.is_cut=true; modData.TOC.LeftForearm.is_operated=true; modData.TOC.LeftForearm.is_amputation_shown=true; modData.TOC.LeftForearm.is_cicatrized=true;
player:getInventory():AddItem("TOC.MetalHook"); player:getInventory():AddItem("TOC.MetalHook");
end end
if player:HasTrait("amputee3") then if player:HasTrait("amputee3") then
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noArm"); local cloth = player:getInventory():AddItem("TOC.ArmLeft_noArm");
player:setWornItem(cloth:getBodyLocation(), cloth); player:setWornItem(cloth:getBodyLocation(), cloth);
modData.TOC.LeftHand.IsCut=true; modData.TOC.LeftHand.IsOperated=true; modData.TOC.LeftHand.is_cut=true; modData.TOC.LeftHand.is_operated=true;
modData.TOC.LeftForearm.IsCut=true; modData.TOC.LeftForearm.IsOperated=true; modData.TOC.LeftForearm.is_cut=true; modData.TOC.LeftForearm.is_operated=true;
modData.TOC.LeftArm.IsCut=true; modData.TOC.LeftArm.IsOperated=true; modData.TOC.LeftArm.ToDisplay=true; modData.TOC.LeftArm.IsCicatrized=true; modData.TOC.LeftArm.is_cut=true; modData.TOC.LeftArm.is_operated=true; modData.TOC.LeftArm.is_amputation_shown=true; modData.TOC.LeftArm.is_cicatrized=true;
player:getInventory():AddItem("TOC.MetalHook"); player:getInventory():AddItem("TOC.MetalHook");
end end

View File

@@ -26,26 +26,26 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
local otherPartNames = {"RightArm", "LeftArm"} local otherPartNames = {"RightArm", "LeftArm"}
for i,name in ipairs(protPartNames) do for i,name in ipairs(protPartNames) do
if modData.TOC[name].IsCut then if modData.TOC[name].is_cut then
if modData.TOC[name].IsEquiped then if modData.TOC[name].has_prothesis_equipped then
maxTime = maxTime * modData.TOC[name].EquipFact; maxTime = maxTime * modData.TOC[name].EquipFact --todo this is dumb
else else
maxTime = maxTime * 2; maxTime = maxTime * 2;
end end
if modData.TOC[name].IsBurn then maxTime = maxTime * burnFact end if modData.TOC[name].is_cauterized then maxTime = maxTime * burnFact end
end end
end end
for i,name in ipairs(otherPartNames) do for i,name in ipairs(otherPartNames) do
if modData.TOC[name].IsCut then if modData.TOC[name].is_cut then
maxTime = maxTime * 2 maxTime = maxTime * 2
if modData.TOC[name].IsBurn then maxTime = maxTime * burnFact end if modData.TOC[name].is_cauterized then maxTime = maxTime * burnFact end
end end
end end
-- Protheses perks stuff -- Protheses perks stuff
if modData.TOC.RightHand.IsCut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.RightHand)) / 20) end if modData.TOC.RightHand.is_cut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.RightHand)) / 20) end
if modData.TOC.LeftHand.IsCut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.LeftHand)) / 20) end if modData.TOC.LeftHand.is_cut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.LeftHand)) / 20) end
if maxTime > 10 * maxTime_org then maxTime = 10 * maxTime_org end if maxTime > 10 * maxTime_org then maxTime = 10 * maxTime_org end
end end
@@ -117,38 +117,38 @@ function ISEquipWeaponAction:perform()
local modData = self.character:getModData() local modData = self.character:getModData()
if not self.item:isRequiresEquippedBothHands() then if not self.item:isRequiresEquippedBothHands() then
if modData.TOC.RightHand.IsCut then if modData.TOC.RightHand.is_cut then
if modData.TOC.RightForearm.IsCut then if modData.TOC.RightForearm.is_cut then
if not modData.TOC.RightForearm.IsEquiped then if not modData.TOC.RightForearm.has_prothesis_equipped then
self.character:setPrimaryHandItem(nil); self.character:setPrimaryHandItem(nil);
self.character:setSecondaryHandItem(self.item); self.character:setSecondaryHandItem(self.item);
end end
else else
if not modData.TOC.RightHand.IsEquiped then if not modData.TOC.RightHand.has_prothesis_equipped then
self.character:setPrimaryHandItem(nil); self.character:setPrimaryHandItem(nil);
self.character:setSecondaryHandItem(self.item); self.character:setSecondaryHandItem(self.item);
end end
end end
end end
if modData.TOC.LeftHand.IsCut then if modData.TOC.LeftHand.is_cut then
if modData.TOC.LeftForearm.IsCut then if modData.TOC.LeftForearm.is_cut then
if not modData.TOC.LeftForearm.IsEquiped then if not modData.TOC.LeftForearm.has_prothesis_equipped then
self.character:setPrimaryHandItem(self.item); self.character:setPrimaryHandItem(self.item);
self.character:setSecondaryHandItem(nil); self.character:setSecondaryHandItem(nil);
end end
else else
if not modData.TOC.LeftHand.IsEquiped then if not modData.TOC.LeftHand.has_prothesis_equipped then
self.character:setPrimaryHandItem(self.item); self.character:setPrimaryHandItem(self.item);
self.character:setSecondaryHandItem(nil); self.character:setSecondaryHandItem(nil);
end end
end end
end end
if (modData.TOC.RightHand.IsCut and not (modData.TOC.RightHand.IsEquiped or modData.TOC.RightForearm.IsEquiped)) and (modData.TOC.LeftHand.IsCut and not (modData.TOC.LeftHand.IsEquiped or modData.TOC.LeftForearm.IsEquiped)) then if (modData.TOC.RightHand.is_cut and not (modData.TOC.RightHand.has_prothesis_equipped or modData.TOC.RightForearm.has_prothesis_equipped)) and (modData.TOC.LeftHand.is_cut and not (modData.TOC.LeftHand.has_prothesis_equipped or modData.TOC.LeftForearm.has_prothesis_equipped)) then
self.character:dropHandItems(); self.character:dropHandItems();
end end
end end
if self.item:isRequiresEquippedBothHands() and ((modData.TOC.RightHand.IsCut and not modData.TOC.RightHand.IsEquiped) or (modData.TOC.RightForearm.IsCut and not modData.TOC.RightForearm.IsEquiped) or (modData.TOC.LeftHand.IsCut and not modData.TOC.LeftHand.IsEquiped) or (modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftForearm.IsEquiped)) then if self.item:isRequiresEquippedBothHands() and ((modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.has_prothesis_equipped) or (modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.has_prothesis_equipped) or (modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.has_prothesis_equipped) or (modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.has_prothesis_equipped)) then
self.character:dropHandItems(); self.character:dropHandItems();
end end

View File

@@ -27,6 +27,16 @@ UI_EN = {
UI_ContextMenu_My = "My ", UI_ContextMenu_My = "My ",
UI_ContextMenu_Now_cut = " is now healed!", UI_ContextMenu_Now_cut = " is now healed!",
UI_ContextMenu_Heal_from_zomb = "I heal from zombification !", UI_ContextMenu_Heal_from_zomb = "I think I'm gonna be fine!",
UI_ContextMenu_Cut_for_nothing = "I did it for nothing..." UI_ContextMenu_Cut_for_nothing = "I did it for nothing..."
} }