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
--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);
elseif bodyPart:getHealth() > 40 then
bodyPart:SetHealth(40);
end
--Heal
if modData_part.IsCicatrized then
if modData_part.is_cicatrized then
if bodyPart:deepWounded() then bodyPart:setDeepWounded(false) end
if bodyPart:bleeding() then bodyPart:setBleeding(false) end
end
@@ -42,14 +42,14 @@ local function healUpdatePart(partName, modData, player)
if bodyPart:haveBullet() then bodyPart:setHaveBullet(false, 0) end
if bodyPart:isInfectedWound() then bodyPart:setInfectedWound(false) 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
-- 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
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("Insensitive")
bodyPart:setBleeding(false);
@@ -61,11 +61,15 @@ local function healUpdatePart(partName, modData, player)
end
--Phantom pain
if modData_part.ToDisplay then
if ZombRand(1, 100) < 10 then
if modData_part.IsBurn then x = 60 else x = 30 end
bodyPart:setAdditionalPain(ZombRand(1, x));
if modData_part.is_amputation_shown and ZombRand(1, 100) < 10 then
if modData_part.is_cauterized then
local added_pain = 60
else
local added_pain = 30
end
bodyPart:setAdditionalPain(ZombRand(1,added_pain))
end
if isBand then bodyPart:setBandaged(true, bandLife, false, bandType) end
end
@@ -82,11 +86,14 @@ end
function UpdatePlayerHealth(player, modData)
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
for i,name in pairs(partNames) do
if modData.TOC[name].IsCut then healUpdatePart(name, modData, player) end
for i,name in pairs(Bodyparts) do
if modData.TOC[name].is_cut then
healUpdatePart(name, modData, player)
end
end
end

View File

@@ -22,12 +22,12 @@ end
local function CheckIfCanBeOperated(modData)
if modData.TOC.RightHand.IsCut and not modData.TOC.RightHand.IsOperated
or modData.TOC.RightForearm.IsCut and not modData.TOC.RightForearm.IsOperated
or modData.TOC.RightArm.IsCut and not modData.TOC.RightArm.IsOperated
or modData.TOC.LeftHand.IsCut and not modData.TOC.LeftHand.IsOperated
or modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftForearm.IsOperated
or modData.TOC.LeftArm.IsCut and not modData.TOC.LeftArm.IsOperated then
if modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.is_operated
or modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.is_operated
or modData.TOC.RightArm.is_cut and not modData.TOC.RightArm.is_operated
or modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.is_operated
or modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.is_operated
or modData.TOC.LeftArm.is_cut and not modData.TOC.LeftArm.is_operated then
return true
else
return false
@@ -58,26 +58,18 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldobjects, nil);
local subMenu = context:getNew(context);
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");
end
if modData.TOC.LeftHand.IsCut and not modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftHand.IsOperated then
subMenu:addOption(getText('UI_ContextMenu_LeftHand'), worldobjects, operateLocal, "LeftHand");
end
if modData.TOC.RightForearm.IsCut and not modData.TOC.RightArm.IsCut and not modData.TOC.RightForearm.IsOperated then
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");
for k, v in pairs(Bodyparts) do
-- todo this is awful but it should work
if modData.TOC[v].is_cut and not modData.TOC[v].is_operated then
subMenu:addOption(getText('UI_ContextMenu_' .. v), worldobjects, operateLocal, v);
end
break -- stop cycling like an idiot
end
end
end
end
@@ -92,6 +84,7 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
end
end
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
return false;
end
@@ -105,20 +98,14 @@ local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects,
context:addSubMenu(rootOption, rootMenu);
context:addSubMenu(cutOption, cutMenu);
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

View File

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

View File

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

View File

@@ -1,10 +1,10 @@
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():getName() ~= "Bare Hands" then player:dropHandItems() 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():getName() ~= "Bare Hands" then player:dropHandItems() end
end
@@ -33,8 +33,8 @@ local function everyTenMinutes()
--Reduit le temps de cicatri restant
for i,name in pairs(names) do
if modData.TOC[name].IsCut and not modData.TOC[name].IsCicatrized then
modData.TOC[name].CicaTimeLeft = modData.TOC[name].CicaTimeLeft - 1;
if modData.TOC[name].is_cut and not modData.TOC[name].is_cicatrized then
modData.TOC[name].cicatrization_time = modData.TOC[name].cicatrization_time - 1;
player:transmitModData()
end
end
@@ -44,106 +44,79 @@ end
local function initVariable(_, player)
local modData = player:getModData()
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;
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;
-- https://stackoverflow.com/questions/20915164/lua-loop-for-creating-variables-in-table
modData.TOC.RightHand.IsInfected = false;
modData.TOC.RightForearm.IsInfected = false;
modData.TOC.RightArm.IsInfected = false;
modData.TOC.LeftHand.IsInfected = false;
modData.TOC.LeftForearm.IsInfected = false;
modData.TOC.LeftArm.IsInfected = false;
local rightHand = "RightHand"
local rightForearm = "RightForearm"
local rightArm = "RightArm"
modData.TOC.RightHand.IsOperated = false;
modData.TOC.RightForearm.IsOperated = false;
modData.TOC.RightArm.IsOperated = false;
modData.TOC.LeftHand.IsOperated = false;
modData.TOC.LeftForearm.IsOperated = false;
modData.TOC.LeftArm.IsOperated = false;
local leftHand = "LeftHand"
local leftForearm = "LeftForearm"
local leftArm = "LeftArm"
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;
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;
Bodyparts = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"}
modData.TOC.RightHand.EquipFact = 1.0;
modData.TOC.RightForearm.EquipFact = 1.0;
modData.TOC.RightArm.EquipFact = 1.0;
modData.TOC.LeftHand.EquipFact = 1.0;
modData.TOC.LeftForearm.EquipFact = 1.0;
modData.TOC.LeftArm.EquipFact = 1.0;
modData.TOC = {
RightHand = {},
RightForearm = {},
RightArm = {},
modData.TOC.RightHand.Equip_mat_id = nil;
modData.TOC.RightForearm.Equip_mat_id = nil;
modData.TOC.RightArm.Equip_mat_id = nil;
modData.TOC.LeftHand.Equip_mat_id = nil;
modData.TOC.LeftForearm.Equip_mat_id = nil;
modData.TOC.LeftArm.Equip_mat_id = nil;
LeftHand = {},
LeftForearm = {},
LeftArm = {}
}
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
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noHand");
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");
end
if player:HasTrait("amputee2") then
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noForearm");
player:setWornItem(cloth:getBodyLocation(), cloth);
modData.TOC.LeftHand.IsCut=true; modData.TOC.LeftHand.IsOperated=true;
modData.TOC.LeftForearm.IsCut=true; modData.TOC.LeftForearm.IsOperated=true; modData.TOC.LeftForearm.ToDisplay=true; modData.TOC.LeftForearm.IsCicatrized=true;
modData.TOC.LeftHand.is_cut=true; modData.TOC.LeftHand.is_operated=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");
end
if player:HasTrait("amputee3") then
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noArm");
player:setWornItem(cloth:getBodyLocation(), cloth);
modData.TOC.LeftHand.IsCut=true; modData.TOC.LeftHand.IsOperated=true;
modData.TOC.LeftForearm.IsCut=true; modData.TOC.LeftForearm.IsOperated=true;
modData.TOC.LeftArm.IsCut=true; modData.TOC.LeftArm.IsOperated=true; modData.TOC.LeftArm.ToDisplay=true; modData.TOC.LeftArm.IsCicatrized=true;
modData.TOC.LeftHand.is_cut=true; modData.TOC.LeftHand.is_operated=true;
modData.TOC.LeftForearm.is_cut=true; modData.TOC.LeftForearm.is_operated=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");
end

View File

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

View File

@@ -27,6 +27,16 @@ UI_EN = {
UI_ContextMenu_My = "My ",
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..."
}