This commit is contained in:
Pao
2023-01-10 20:32:54 +01:00
parent f9d2831158
commit eb72635b6d
4 changed files with 111 additions and 169 deletions

View File

@@ -47,7 +47,7 @@ local function healUpdatePart(partName, modData, player)
-- During healing -- During healing
if modData_part.is_cut and not modData_part.is_cicatrized then if modData_part.is_cut and not modData_part.is_cicatrized then
if modData_part.CicaTimeLeft < 0 then if modData_part.cicatrization_time < 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.is_cicatrized = true; modData_part.is_cicatrized = true;
player:getTraits():add("Brave") player:getTraits():add("Brave")
@@ -79,7 +79,7 @@ local function isOtherArmInfect(modData, partName)
names[partName] = nil; names[partName] = nil;
for i,v in pairs(names) do for i,v in pairs(names) do
if modData.TOC[v].IsInfected then return true end if modData.TOC[v].is_infected then return true end
end end
return false return false
end end

View File

@@ -1,4 +1,19 @@
local function cureInfection(bodyDamage)
local function CheckIfStillInfected(toc_data)
for k,v in pairs(Bodyparts) do
if toc_data[v].is_infected == true then
getPlayer().Say("I'm still infected...")
return true
end
end
return false
end
local function CureInfection(bodyDamage)
bodyDamage:setInfected(false); bodyDamage:setInfected(false);
bodyDamage:setInfectionMortalityDuration(-1); bodyDamage:setInfectionMortalityDuration(-1);
bodyDamage:setInfectionTime(-1); bodyDamage:setInfectionTime(-1);
@@ -8,14 +23,20 @@ local function cureInfection(bodyDamage)
local bodyPart = bodyParts:get(i); local bodyPart = bodyParts:get(i);
bodyPart:SetInfected(false); bodyPart:SetInfected(false);
end end
getPlayer().Say("I'm gonna be fine")
end end
function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount) function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount)
local player = getPlayer();
local modData = player:getModData().TOC;
local bodyPart = player:getBodyDamage():getBodyPart(TOC_getBodyPart(partName));
--Set dommage of bodypart & stress & endu
local player = getPlayer();
local toc_data = player:getModData().TOC;
local bodyPart = player:getBodyDamage():getBodyPart(TOC_getBodyPart(partName)); -- why the fuck do we we need this
--Set damage of body part & stress & endurance
local stats = player:getStats(); local stats = player:getStats();
bodyPart:AddDamage(100 - surgeonFact); bodyPart:AddDamage(100 - surgeonFact);
bodyPart:setAdditionalPain(100 - surgeonFact); bodyPart:setAdditionalPain(100 - surgeonFact);
@@ -27,113 +48,56 @@ function CutArm(partName, surgeonFact, useBandage, bandageAlcool, usePainkiller,
stats:setStress(100 - surgeonFact); stats:setStress(100 - surgeonFact);
-- Bandage -- Bandage
if useBandage and bandageAlcool then --if useBandage and bandageAlcool then
bodyPart:setBandaged(true, 10, true, bandage:getType()); -- bodyPart:setBandaged(true, 10, true, bandage:getType());
elseif useBandage and not bandageAlcool then --elseif useBandage and not bandageAlcool then
bodyPart:setBandaged(true, 10, false, bandage:getType()); -- bodyPart:setBandaged(true, 10, false, bandage:getType());
end --end
-- Painkiller -- Painkiller
if usePainkiller then --if usePainkiller then
for _ = 1,painkillerCount+1 do -- for _ = 1,painkillerCount+1 do
player:getBodyDamage():JustTookPill(painkiller); -- player:getBodyDamage():JustTookPill(painkiller);
end -- end
if painkillerCount < 10 then addSound(player, player:getX(), player:getY(), player:getZ(), 50-painkillerCount*5, 50-painkillerCount*5) end -- if painkillerCount < 10 then addSound(player, player:getX(), player:getY(), player:getZ(), 50-painkillerCount*5, 50-painkillerCount*5) end
else --else
addSound(player, player:getX(), player:getY(), player:getZ(), 50, 50) -- addSound(player, player:getX(), player:getY(), player:getZ(), 50, 50)
end --end
-- Change modData -- Change modData
if bodyPart:getType() == BodyPartType.Hand_R then
modData.RightHand.IsCut = true; local current_bodypart = bodyPart:getType()
modData.RightHand.ToDisplay = true; local body_damage = player:getBodyDamage()
modData.RightHand.CicaTimeLeft = 1700 - surgeonFact * 50;
elseif bodyPart:getType() == BodyPartType.ForeArm_R then for k,v in pairs(Bodyparts) do
modData.RightForearm.IsCut = true; modData.RightHand.IsCut = true;
modData.RightForearm.ToDisplay = true; modData.RightHand.ToDisplay = false; if v == partName then
modData.RightHand.is_cauterized = false; toc_data[v].is_cut = true
modData.RightForearm.CicaTimeLeft = 1800 - surgeonFact * 50; modData.RightHand.CicaTimeLeft = 1800 - surgeonFact * 50; toc_data[v].is_amputation_shown = true
elseif bodyPart:getType() == BodyPartType.UpperArm_R then toc_data[v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50
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.is_cauterized = false; modData.RightForearm.is_cauterized = false; -- Heal the infection here
modData.RightArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.RightHand.CicaTimeLeft = 2000 - surgeonFact * 50; if toc_data[v].is_infected and body_damage.getInfectionLevel() < 20 then
elseif bodyPart:getType() == BodyPartType.Hand_L then toc_data[v].is_infected = false
modData.LeftHand.IsCut = true; current_bodypart:SetBitten(false)
modData.LeftHand.ToDisplay = true;
modData.LeftHand.CicaTimeLeft = 1700 - surgeonFact * 50; -- Second check, let's see if there is any other infected limb.
elseif bodyPart:getType() == BodyPartType.ForeArm_L then if CheckIfStillInfected(toc_data) == false then
modData.LeftForearm.IsCut = true; modData.LeftHand.IsCut = true; CureInfection(body_damage)
modData.LeftForearm.ToDisplay = true; modData.LeftHand.ToDisplay = false; end
modData.LeftHand.is_cauterized = false;
modData.LeftForearm.CicaTimeLeft = 1800 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 1800 - surgeonFact * 50; end
elseif bodyPart:getType() == BodyPartType.UpperArm_L then
modData.LeftArm.IsCut = true; modData.LeftForearm.IsCut = true; modData.LeftHand.IsCut = true; for depended_k, depended_v in pairs(toc_data[v].depends_on) do
modData.LeftArm.ToDisplay = true; modData.LeftForearm.ToDisplay = false; modData.LeftHand.ToDisplay = false; toc_data[depended_v].is_cut = true
modData.LeftHand.is_cauterized = false; modData.LeftForearm.is_cauterized = false; toc_data[depended_v].is_amputation_shown = true
modData.LeftArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 2000 - surgeonFact * 50; toc_data[depended_v].cicatrization_time = toc_data[v].cicatrization_base_time - surgeonFact * 50
end
end
end end
--Heal the infection
-- dude what the fuck is this code
local bd = player:getBodyDamage()
if bodyPart:getType() == BodyPartType.Hand_R then
if bd:getInfectionLevel() < 20 and modData.RightHand.IsInfected and not (modData.RightForearm.IsInfected or modData.RightArm.IsInfected or modData.LeftArm.IsInfected or modData.LeftForearm.IsInfected or modData.LeftHand.IsInfected or modData.OtherBody_IsInfected) then
player:Say("I'm gonna be fine!");
bd:getBodyPart(BodyPartType.Hand_R):SetBitten(false);
cureInfection(bd);
else
player:Say("I did that for nothing...");
end
modData.RightHand.IsInfected = false;
elseif bodyPart:getType() == BodyPartType.ForeArm_R then
if bd:getInfectionLevel() < 20 and modData.RightForearm.IsInfected and not (modData.RightArm.IsInfected or modData.LeftArm.IsInfected or modData.LeftForearm.IsInfected or modData.LeftHand.IsInfected or modData.OtherBody_IsInfected) then
player:Say("I'm gonna be fine!");
bd:getBodyPart(BodyPartType.Hand_R):SetBitten(false); bd:getBodyPart(BodyPartType.ForeArm_R):SetBitten(false);
cureInfection(bd);
else
player:Say("I did that for nothing...");
end
modData.RightHand.IsInfected = false;
modData.RightForearm.IsInfected = false;
elseif bodyPart:getType() == BodyPartType.UpperArm_R then
if bd:getInfectionLevel() < 20 and modData.RightArm.IsInfected and not (modData.LeftArm.IsInfected or modData.LeftForearm.IsInfected or modData.LeftHand.IsInfected or modData.OtherBody_IsInfected) then
player:Say("I healed !");
bd:getBodyPart(BodyPartType.Hand_R):SetBitten(false); bd:getBodyPart(BodyPartType.ForeArm_R):SetBitten(false); bd:getBodyPart(BodyPartType.UpperArm_R):SetBitten(false);
cureInfection(bd);
else
player:Say("I did that for nothing...");
end
modData.RightHand.IsInfected = false; modData.RightForearm.IsInfected = false; modData.RightArm.IsInfected = false;
elseif bodyPart:getType() == BodyPartType.Hand_L then
if bd:getInfectionLevel() < 20 and modData.LeftHand.IsInfected and not (modData.RightForearm.IsInfected or modData.RightArm.IsInfected or modData.LeftArm.IsInfected or modData.LeftForearm.IsInfected or modData.RightHand.IsInfected or modData.OtherBody_IsInfected) then
player:Say("I'm gonna be fine!");
bd:getBodyPart(BodyPartType.Hand_L):SetBitten(false);
cureInfection(bd);
else
player:Say("I did that for nothing...");
end
modData.LeftHand.IsInfected = false;
elseif bodyPart:getType() == BodyPartType.ForeArm_L then
if bd:getInfectionLevel() < 20 and modData.LeftForearm.IsInfected and not (modData.RightForearm.IsInfected or modData.RightArm.IsInfected or modData.LeftArm.IsInfected or modData.RightHand.IsInfected or modData.OtherBody_IsInfected) then
player:Say("I'm gonna be fine!");
bd:getBodyPart(BodyPartType.Hand_L):SetBitten(false); bd:getBodyPart(BodyPartType.ForeArm_L):SetBitten(false);
cureInfection(bd);
else
player:Say("I did that for nothing...");
end
modData.LeftHand.IsInfected = false; modData.LeftForearm.IsInfected = false;
elseif bodyPart:getType() == BodyPartType.UpperArm_L then
if bd:getInfectionLevel() < 20 and modData.LeftArm.IsInfected and not (modData.RightForearm.IsInfected or modData.RightArm.IsInfected or modData.RightHand.IsInfected or modData.OtherBody_IsInfected) then
player:Say("I'm gonna be fine!");
bd:getBodyPart(BodyPartType.Hand_L):SetBitten(false); bd:getBodyPart(BodyPartType.ForeArm_L):SetBitten(false); bd:getBodyPart(BodyPartType.UpperArm_L):SetBitten(false);
cureInfection(bd);
else
player:Say("I did that for nothing...");
end
modData.LeftHand.IsInfected = false; modData.LeftForearm.IsInfected = false; modData.LeftArm.IsInfected = false;
end
--Equip cloth --Equip cloth
local cloth = player:getInventory():AddItem(find_clothName2_TOC(partName)); local cloth = player:getInventory():AddItem(find_clothName2_TOC(partName));
@@ -143,7 +107,7 @@ end
function OperateArm(partName, surgeonFact, useOven) function OperateArm(partName, surgeonFact, useOven)
local player = getPlayer(); local player = getPlayer();
local modData = player:getModData().TOC; local toc_data = player:getModData().TOC;
if useOven then if useOven then
local stats = player:getStats(); local stats = player:getStats();
@@ -151,58 +115,25 @@ function OperateArm(partName, surgeonFact, useOven)
stats:setStress(100); stats:setStress(100);
end end
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.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.is_cauterized = true;
modData.TOC.RightForearm.is_cauterized = true;
end
elseif partName == "RightArm" and not modData.RightArm.IsOperated then
modData.RightArm.IsOperated = true;
modData.RightForearm.IsOperated = true;
modData.RightHand.IsOperated = true;
modData.RightArm.CicaTimeLeft = modData.RightArm.CicaTimeLeft - (surgeonFact * 200);
modData.RightForearm.CicaTimeLeft = modData.RightForearm.CicaTimeLeft - (surgeonFact * 200);
modData.RightHand.CicaTimeLeft = modData.RightHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then
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.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.is_cauterized = true;
modData.LeftForearm.is_cauterized = true;
end
elseif partName == "LeftArm" and not modData.LeftArm.IsOperated then
modData.LeftArm.IsOperated = true;
modData.LeftForearm.IsOperated = true;
modData.LeftHand.IsOperated = true;
modData.LeftArm.CicaTimeLeft = modData.LeftArm.CicaTimeLeft - (surgeonFact * 200);
modData.LeftForearm.CicaTimeLeft = modData.LeftForearm.CicaTimeLeft - (surgeonFact * 200);
modData.LeftHand.CicaTimeLeft = modData.LeftHand.CicaTimeLeft - (surgeonFact * 200);
if useOven then
modData.LeftHand.is_cauterized = true;
modData.LeftForearm.is_cauterized = true;
modData.LeftArm.is_cauterized = true;
end
end
for k,v in pairs(Bodyparts) do
if not toc_data[v].is_operated then
toc_data[v].is_operated = true
toc_data[v].cicatrization_time = toc_data[v].cicatrization_time - (surgeonFact * 200)
if useOven then toc_data[v].is_cauterized = true end
for depended_k, depended_v in pairs(toc_data[v].depends_on) do
toc_data[depended_v].is_operated = true
toc_data[depended_v].cicatrization_time = toc_data[depended_v].cicatrization_time - (surgeonFact * 200)
if useOven then toc_data[depended_v].is_cauterized = true end
end
end
end
SetBodyPartsStatus(player, partName, useOven) SetBodyPartsStatus(player, partName, useOven)
player:transmitModData(); player:transmitModData();
end end
@@ -257,3 +188,4 @@ function SetBodyPartsStatus(player, partName, useOven)
end end
end end

View File

@@ -155,25 +155,25 @@ local function setDescUI(partName)
-- Cut but not healed -- Cut but not healed
elseif partData.is_cut and not partData.is_cicatrized 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.cicatrization_time > 1000 then
descUI["textEtat"]:setText("Still a long way to go") descUI["textEtat"]:setText("Still a long way to go")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2); descUI["textEtat"]:setColor(1, 0.8, 1, 0.2);
elseif partData.CicaTimeLeft > 500 then elseif partData.cicatrization_time > 500 then
descUI["textEtat"]:setText("Starting to get better") descUI["textEtat"]:setText("Starting to get better")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2) descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
elseif partData.CicaTimeLeft > 100 then elseif partData.cicatrization_time > 100 then
descUI["textEtat"]:setText("Almost cicatrized"); descUI["textEtat"]:setText("Almost cicatrized");
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2); descUI["textEtat"]:setColor(1, 0.8, 1, 0.2);
end end
else else
if partData.CicaTimeLeft > 1000 then if partData.cicatrization_time > 1000 then
descUI["textEtat"]:setText("It hurts so much...") descUI["textEtat"]:setText("It hurts so much...")
descUI["textEtat"]:setColor(1, 1, 0, 0) descUI["textEtat"]:setColor(1, 1, 0, 0)
elseif partData.CicaTimeLeft > 500 then elseif partData.cicatrization_time > 500 then
descUI["textEtat"]:setText("It still hurts a lot") descUI["textEtat"]:setText("It still hurts a lot")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2) descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
elseif partData.CicaTimeLeft > 500 then elseif partData.cicatrization_time > 500 then
descUI["textEtat"]:setText("I think it's almost over...") descUI["textEtat"]:setText("I think it's almost over...")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2) descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
end end

View File

@@ -47,6 +47,7 @@ local function initVariable(_, player)
-- https://stackoverflow.com/questions/20915164/lua-loop-for-creating-variables-in-table -- https://stackoverflow.com/questions/20915164/lua-loop-for-creating-variables-in-table
local rightHand = "RightHand" local rightHand = "RightHand"
local rightForearm = "RightForearm" local rightForearm = "RightForearm"
local rightArm = "RightArm" local rightArm = "RightArm"
@@ -86,16 +87,25 @@ local function initVariable(_, player)
end end
-- Manual stuff -- Manual stuff, just a temporary fix since this is kinda awful
modData.TOC[rightHand].depends_on = {}
modData.TOC[rightForearm].depends_on = {rightHand} modData.TOC[rightForearm].depends_on = {rightHand}
modData.TOC[rightArm].depends_on = { rightHand, rightForearm } modData.TOC[rightArm].depends_on = { rightHand, rightForearm }
modData.TOC[leftHand].depends_on = {}
modData.TOC[leftForearm].depends_on = { leftHand } modData.TOC[leftForearm].depends_on = { leftHand }
modData.TOC[leftArm].depends_on = { leftHand, leftForearm } modData.TOC[leftArm].depends_on = { leftHand, leftForearm }
-- Setup cicatrization times
modData.TOC[rightHand].cicatrization_base_time = 1700
modData.TOC[leftHand].cicatrization_base_time = 1700
modData.TOC[rightForearm].cicatrization_base_time = 1800
modData.TOC[leftForearm].cicatrization_base_time = 1800
modData.TOC[rightArm].cicatrization_base_time = 2000
modData.TOC[leftArm].cicatrization_base_time = 2000
if player:HasTrait("amputee1") then if player:HasTrait("amputee1") then