first commit

This commit is contained in:
Pao
2023-01-09 22:01:35 +01:00
commit 55c338f976
129 changed files with 3103 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
local function healUpdatePart(partName, modData, player)
local modData_part = modData.TOC[partName];
local bodyDamage = player:getBodyDamage();
local bodyPart = bodyDamage:getBodyPart(TOC_getBodyPart(partName));
if not bodyPart then
print("TOC ERROR : Can't update health of " .. partName);
return fasle;
end
local isBand = false;
local bandLife = 0;
local bandType = "";
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
bodyPart:SetHealth(80);
elseif bodyPart:getHealth() > 40 then
bodyPart:SetHealth(40);
end
--Heal
if modData_part.IsCicatrized then
if bodyPart:deepWounded() then bodyPart:setDeepWounded(false) end
if bodyPart:bleeding() then bodyPart:setBleeding(false) end
end
if bodyPart:bitten() then
bodyPart:SetBitten(false);
if not modData.TOC.OtherBody_IsInfected and not isOtherArmInfect(modData, partName) then
bodyDamage:setInfected(false);
bodyDamage:setInfectionMortalityDuration(-1);
bodyDamage:setInfectionTime(-1);
bodyDamage:setInfectionLevel(0);
local bodyParts = bodyDamage:getBodyParts();
for i=bodyParts:size()-1, 0, -1 do
local bodyPart = bodyParts:get(i);
bodyPart:SetInfected(false);
end
end
end
if bodyPart:scratched() then bodyPart:setScratched(false, false) end
if bodyPart:haveGlass() then bodyPart:setHaveGlass(false) end
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:getFractureTime()>0 then bodyPart:setFractureTime(0) end
-- During healing
-- this will not happen every 10 sec or some shit like that.
-- We will allow stitching. Surgery is needed only to have a faster cicatrization
if modData_part.IsCut and not modData_part.IsCicatrized then
if modData_part.CicaTimeLeft < 0 then
player:Say(getText('UI_ContextMenu_My') .. partName .. getText('UI_ContextMenu_Now_cut')) -- dunno if this works.
modData_part.IsCicatrized = true;
player:getTraits():add("Brave")
player:getTraits():add("Insensitive")
bodyPart:setBleeding(false);
bodyPart:setDeepWounded(false);
bodyPart:setBleedingTime(0);
bodyPart:setDeepWoundTime(0);
player:transmitModData()
end
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));
end
end
if isBand then bodyPart:setBandaged(true, bandLife, false, bandType) end
end
local function isOtherArmInfect(modData, partName)
local names = {"RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"}
names[partName] = nil;
for i,v in pairs(names) do
if modData.TOC[v].IsInfected then return true end
end
return false
end
function UpdatePlayerHealth(player, modData)
local bodyDamage = player:getBodyDamage()
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
end
end

View File

@@ -0,0 +1,16 @@
function CheckIfInfect(player, modData)
local bd = player:getBodyDamage()
local Keys = {BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head, BodyPartType.Neck, BodyPartType.Groin, BodyPartType.UpperLeg_L, BodyPartType.UpperLeg_R, BodyPartType.LowerLeg_L, BodyPartType.LowerLeg_R, BodyPartType.Foot_L, BodyPartType.Foot_R, BodyPartType.Back}
if bd:getBodyPart(BodyPartType.Hand_R):bitten() and not modData.TOC.RightHand.IsCut then modData.TOC.RightHand.IsInfected = true; player:transmitModData()
elseif bd:getBodyPart(BodyPartType.ForeArm_R):bitten() and not modData.TOC.RightForearm.IsCut then modData.TOC.RightForearm.IsInfected = true; player:transmitModData()
elseif bd:getBodyPart(BodyPartType.UpperArm_R):bitten() and not modData.TOC.RightArm.IsCut then modData.TOC.RightArm.IsInfected = true; player:transmitModData()
elseif bd:getBodyPart(BodyPartType.Hand_L):bitten() and not modData.TOC.LeftHand.IsCut then modData.TOC.LeftHand.IsInfected = true; player:transmitModData()
elseif bd:getBodyPart(BodyPartType.ForeArm_L):bitten() and not modData.TOC.LeftForearm.IsCut then modData.TOC.LeftForearm.IsInfected = true; player:transmitModData()
elseif bd:getBodyPart(BodyPartType.UpperArm_L):bitten() and not modData.TOC.LeftArm.IsCut then modData.TOC.LeftArm.IsInfected = true; player:transmitModData()
else
for index, value in ipairs(Keys) do
if bd:getBodyPart(value):bitten() then modData.TOC.OtherBody_IsInfected = true; player:transmitModData() end
end
end
end

View File

@@ -0,0 +1,94 @@
--- A rly big thx to Fenris_Wolf and Chuck to help me with that. Love you guy
local Commands = {}
-- Surgeon (send)
function SendCutArm(player, partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount)
local arg = {};
arg["From"] = getPlayer():getOnlineID();
arg["To"] = player:getOnlineID();
arg["command"] = "CutArm";
arg["toSend"] = {partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount};
sendClientCommand("TOC", "SendServer", arg);
end
function SendOperateArm(player, partName, surgeonFact, useOven)
local arg = {};
arg["From"] = getPlayer():getOnlineID();
arg["To"] = player:getOnlineID();
arg["command"] = "OperateArm";
arg["toSend"] = {partName, surgeonFact, useOven};
sendClientCommand("TOC", "SendServer", arg);
end
function AskCanCutArm(player, partName)
GetConfirmUIMP().responseReceive = false;
local arg = {};
arg["From"] = getPlayer():getOnlineID();
arg["To"] = player:getOnlineID();
arg["command"] = "CanCutArm";
arg["toSend"] = partName;
sendClientCommand("TOC", "SendServer", arg);
end
function AskCanOperateArm(player, partName)
GetConfirmUIMP().responseReceive = false;
local arg = {};
arg["From"] = getPlayer():getOnlineID();
arg["To"] = player:getOnlineID();
arg["command"] = "CanOperateArm";
arg["toSend"] = partName;
sendClientCommand("TOC", "SendServer", arg);
end
Commands["responseCanArm"] = function(arg)
local ui = GetConfirmUIMP()
ui.responseReceive = true;
ui.responseAction = arg["toSend"][2];
ui.responsePartName = arg["toSend"][1];
ui.responseCan = arg["toSend"][3];
ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername();
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TOC_getBodyPart(ui.responsePartName)):bitten();
end
-- Patient (receive)
Commands["CutArm"] = function(arg)
local arg = arg["toSend"];
CutArm(arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]);
end
Commands["OperateArm"] = function(arg)
local arg = arg["toSend"];
OperateArm(arg[1], arg[2], arg[3]);
end
Commands["CanCutArm"] = function(arg)
local partName = arg["toSend"];
arg["To"] = arg["From"];
arg["From"] = getPlayer():getOnlineID();
arg["command"] = "responseCanArm";
arg["toSend"] = {partName, "Cut", CanBeCut(partName)};
sendClientCommand("TOC", "SendServer", arg);
end
Commands["CanOperateArm"] = function(arg)
local partName = arg["toSend"];
arg["To"] = arg["From"];
arg["From"] = getPlayer():getOnlineID();
arg["command"] = "responseCanArm";
arg["toSend"] = {partName, "Operate", CanBeOperate(partName)};
sendClientCommand("TOC", "SendServer", arg);
end
-- Event
local onServerCommand = function(module, command, args)
if module == "TOC" and Commands[command] then
args = args or {}
Commands[command](args)
end
end
Events.OnServerCommand.Add(onServerCommand)

View File

@@ -0,0 +1,103 @@
local function operateLocal(partName)
local player = getPlayer();
ISTimedActionQueue.add(ISOperateArm:new(player, player, _, partName, true));
end
local function otherPlayerLocal(_, partName, action, patient)
local ui = GetConfirmUIMP();
if not ui then
MakeConfirmUIMP();
ui = GetConfirmUIMP();
end
if action == "Cut" then
AskCanCutArm(patient, partName);
else
AskCanOperateArm(patient, partName);
end
ui.actionAct = action;
ui.partNameAct = partName;
ui.patient = patient;
SetConfirmUIMP("Wait server");
end
local function TOC_onFillWorldObjectContextMenu(playerId, context, worldobjects, _)
local player = getSpecificPlayer(playerId);
local clickedPlayer
local modData = player:getModData();
for _,object in ipairs(worldobjects) do
local square = object:getSquare()
if square then
for i=1,square:getObjects():size() do
local object2 = square:getObjects():get(i-1);
--For the oven operate part
if instanceof(object2, "IsoStove") and (player:HasTrait("Brave") or player:getPerkLevel(Perks.Strength) >= 6) then
if not object2:isMicrowave() and object2:getCurrentTemperature() > 250 then
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");
end
end
end
end
local movingObjects = square:getMovingObjects()
for i = 0, movingObjects:size() - 1 do
local o = movingObjects:get(i)
if instanceof(o, "IsoPlayer") then
clickedPlayer = o;
break
end
end
if clickedPlayer 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;
end
local rootOption = context:addOption("The Only Cure on " .. clickedPlayer:getUsername());
local rootMenu = context:getNew(context);
local cutOption = rootMenu:addOption("Cut");
local operateOption = rootMenu:addOption("Operate");
local cutMenu = context:getNew(context);
local operateMenu = context:getNew(context);
context:addSubMenu(rootOption, rootMenu);
context:addSubMenu(cutOption, cutMenu);
context:addSubMenu(operateOption, operateMenu);
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
Events.OnFillWorldObjectContextMenu.Add(TOC_onFillWorldObjectContextMenu);

View File

@@ -0,0 +1,262 @@
local function cureInfection(bodyDamage)
bodyDamage:setInfected(false);
bodyDamage:setInfectionMortalityDuration(-1);
bodyDamage:setInfectionTime(-1);
bodyDamage:setInfectionLevel(0);
local bodyParts = bodyDamage:getBodyParts();
for i=bodyParts:size()-1, 0, -1 do
local bodyPart = bodyParts:get(i);
bodyPart:SetInfected(false);
end
end
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 stats = player:getStats();
bodyPart:AddDamage(100 - surgeonFact);
bodyPart:setAdditionalPain(100 - surgeonFact);
bodyPart:setBleeding(true);
bodyPart:setBleedingTime(100 - surgeonFact);
bodyPart:setDeepWounded(true)
bodyPart:setDeepWoundTime(100 - surgeonFact);
stats:setEndurance(0 + surgeonFact);
stats:setStress(100 - surgeonFact);
--TODO this is broken
-- Bandage
--if useBandage and bandageAlcool then
-- bodyPart:setBandaged(true, 10, true, bandage:getType());
--elseif useBandage and not bandageAlcool then
-- bodyPart:setBandaged(true, 10, false, bandage:getType());
--end
-- Painkiller
if usePainkiller then
for _ = 1,painkillerCount+1 do
player:getBodyDamage():JustTookPill(painkiller);
end
if painkillerCount < 10 then addSound(player, player:getX(), player:getY(), player:getZ(), 50-painkillerCount*5, 50-painkillerCount*5) end
else
addSound(player, player:getX(), player:getY(), player:getZ(), 50, 50)
end
-- Change modData
if bodyPart:getType() == BodyPartType.Hand_R then
modData.RightHand.IsCut = true;
modData.RightHand.ToDisplay = true;
modData.RightHand.CicaTimeLeft = 1700 - surgeonFact * 50;
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.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.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;
modData.LeftHand.ToDisplay = true;
modData.LeftHand.CicaTimeLeft = 1700 - surgeonFact * 50;
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.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.LeftArm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftForearm.CicaTimeLeft = 2000 - surgeonFact * 50; modData.LeftHand.CicaTimeLeft = 2000 - surgeonFact * 50;
end
--Heal the infection
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 healed !");
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 healed !");
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 healed !");
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 healed !");
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 healed !");
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
local cloth = player:getInventory():AddItem(find_clothName2_TOC(partName));
player:setWornItem(cloth:getBodyLocation(), cloth);
-- Set the correct stats for the injury
bodyPart:setBleeding(true);
bodyPart:setDeepWounded(true);
bodyPart:setBleedingTime(100);
bodyPart:setDeepWoundTime(100);
player:transmitModData();
end
function OperateArm(partName, surgeonFact, useOven)
local player = getPlayer();
local modData = player:getModData().TOC;
if UseOven then
local stats = character:getStats();
bodyPart:AddDamage(100);
bodyPart:setAdditionalPain(100);
stats:setEndurance(0);
stats:setStress(100);
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.IsBurn = 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;
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.IsBurn = true;
modData.RightForearm.IsBurn = true;
modData.RightArm.IsBurn = 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
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;
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.IsBurn = true;
modData.LeftForearm.IsBurn = true;
modData.LeftArm.IsBurn = true;
end
end
FixDeepWound(partname)
player:transmitModData();
end
function FixDeepWound(partName)
a_rightArm = {"RightArm", "RightForearm", "RightHand"}
a_rightForearm = {"RightForearm", "RightHand"}
a_rightHand = {"RightHand"}
a_leftArm = {"LeftArm", "LeftForearm", "LeftHand"}
a_leftForearm = {"LeftForearm", "LeftHand"}
a_leftHand = {"LeftHand"}
if partName == "RightArm" then
chosen_array = a_rightArm
elseif partName == "RightForearm" then
chosen_array = a_rightForearm
elseif partName == "RightHand" then
chosen_array = a_rightHand
elseif partName == "LeftArm" then
chosen_array = a_leftArm
elseif partName == "LeftForearm" then
chosen_array = a_leftForearm
elseif partName == "LeftHand" then
chosen_array = a_leftHand
end
for k,v in pairs(chosen_array) do
local tmpBodyPart = bodyDamage:getBodyPart(TOC_getBodyPart(v));
tmpBodyPart:setDeepWounded(false); -- Basically like stictching
tmpBodyPart:setDeepWoundTime(0);
bodyPart:setBleeding(true);
bodyPart:setBleedingTime(10); -- Reset the bleeding
end
end

583
media/lua/client/TOC_UI.lua Normal file
View File

@@ -0,0 +1,583 @@
local mainUI, descUI, confirmUI, confirmUIMP
function GetConfirmUIMP()
return confirmUIMP;
end
-- Usefull
local function prerenderFuncMP()
local toSee = confirmUIMP;
if confirmUIMP.responseReceive then
if not confirmUIMP.responseCan then
getPlayer():Say("I can't do that !")
confirmUIMP.responseReceive = false;
confirmUIMP:close();
return false;
end
SetConfirmUIMP(confirmUIMP.responseAction, confirmUIMP.responseIsBitten, confirmUIMP.responseUserName, confirmUIMP.responsePartName);
end
end
local function isPlayerHaveSaw()
local playerInv = getPlayer():getInventory();
local item = playerInv:getItemFromType('Saw') or playerInv:getItemFromType('GardenSaw') or playerInv:getItemFromType('Chainsaw');
return item;
end
local function isPlayerHavePainkiller()
local playerInv = getPlayer():getInventory();
local item = playerInv:getItemFromType('Pills');
return item;
end
local function isPlayerHaveBandage()
local playerInv = getPlayer():getInventory();
local item = playerInv:getItemFromType('AlcoholBandage') or playerInv:getItemFromType('Bandage');
return item;
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 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
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
name = "media/ui/TOC/" .. partName .. "/Bleed.png";
elseif partData.IsCut and not partData.IsCicatrized 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)
name = "media/ui/TOC/Empty.png";
elseif not partData.IsCut 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
name = "media/ui/TOC/" .. partName .. "/Hook.png";
elseif partName == "LeftHand" and modData["LeftForearm"].IsEquiped then
name = "media/ui/TOC/" .. partName .. "/Hook.png";
end
return name;
end
local function partNameToBodyLoc(name)
if name == "RightHand" then return "ArmRight_Prot" end
if name == "RightForearm" then return "ArmRight_Prot" end
if name == "RightArm" then return "ArmRight_Prot" end
if name == "LeftHand" then return "ArmLeft_Prot" end
if name == "LeftForearm" then return "ArmLeft_Prot" end
if name == "LeftArm" then return "ArmLeft_Prot" end
end
function find_itemWorn_TOC(partName)
local wornItems = getPlayer():getWornItems();
for i=1,wornItems:size()-1 do -- Maybe wornItems:size()-1
local item = wornItems:get(i):getItem();
if item:getBodyLocation() == partNameToBodyLoc(partName) then
return item;
end
end
return false;
end
local function findMinMax(lv)
local min, max
if lv == 1 then
min = 0;
max = 75;
elseif lv == 2 then
min = 75;
max = 150 + 75;
elseif lv == 3 then
min = 150;
max = 300 + 75 + 150;
elseif lv == 4 then
min = 300;
max = 750 + 75 + 150 + 300;
elseif lv == 5 then
min = 750;
max = 1500 + 75 + 150 + 300 + 750;
elseif lv == 6 then
min = 1500;
max = 3000 + 75 + 150 + 300 + 750 + 1500;
elseif lv == 7 then
min = 3000;
max = 4500 + 75 + 150 + 300 + 750 + 1500 + 3000;
elseif lv == 8 then
min = 4500;
max = 6000 + 75 + 150 + 300 + 750 + 1500 + 3000 + 4500;
elseif lv == 9 then
min = 6000;
max = 7500 + 75 + 150 + 300 + 750 + 1500 + 3000 + 4500 + 6000;
elseif lv == 10 then
min = 7500;
max = 9000 + 75 + 150 + 300 + 750 + 1500 + 3000 + 4500 + 6000 + 7500;
end
return min, max;
end
-- end Usefull
-- Function to update text/button of UIs
local function setDescUI(partName)
local modData = getPlayer():getModData().TOC;
local partData = modData[partName];
descUI["textTitle"]:setText(getDisplayText_TOC(partName));
descUI.partNameAct = partName;
if partData.IsCut and partData.IsCicatrized and partData.IsEquiped then -- Cut and equip
descUI["textEtat"]:setText("Cut and healed");
descUI["textEtat"]:setColor(1, 0, 1, 0);
descUI["b1"]:setText("Unequip");
descUI["b1"]:addArg("option", "Unequip");
descUI["b1"]:setVisible(true);
elseif partData.IsCut and partData.IsCicatrized and not partData.IsEquiped and partData.ToDisplay then -- Cut and healed
descUI["textEtat"]:setText("Cut and healed");
descUI["textEtat"]:setColor(1, 0, 1, 0);
if partName == "RightArm" or partName == "LeftArm" then
descUI["b1"]:setVisible(false);
else
descUI["b1"]:setText("Equip");
descUI["b1"]:addArg("option", "Equip");
descUI["b1"]:setVisible(true);
end
elseif partData.IsCut and not partData.IsCicatrized and partData.ToDisplay then -- Cut not healed
if partData.IsOperated then:
if partData.CicaTimeLeft > 1000 then
descUI["textEtat"]:setText("Still a long way to go")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2);
elseif partData.CicaTimeLeft > 500 then
descUI["textEtat"]:setText("Starting to get better")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
elseif partData.CicaTime > 100
descUI["textEtat"]:setText("Almost cicatrized");
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2);
else
if partData.CicaTimeLeft > 1000 then
descUI["textEtat"]:setText("It hurts so much..." .. partData.CicaTimeLeft)
descUI["textEtat"]:setColor(1, 1, 0, 0)
elseif partData.CicaTimeLeft > 500 then
descUI["textEtat"]:setText("It still hurts a lot")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
elseif partData.CicaTimeLeft > 500 then
descUI["textEtat"]:setText("I think it's almost over...")
descUI["textEtat"]:setColor(1, 0.8, 1, 0.2)
if partData.IsOperated then
descUI["b1"]:setVisible(false)
else
descUI["b1"]:setText("Operate")
descUI["b1"]:addArg("option", "Operate")
descUI["b1"]:setVisible(true)
end
elseif partData.IsCut 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
descUI["textEtat"]:setText("Bitten...");
descUI["textEtat"]:setColor(1, 1, 0, 0);
if isPlayerHaveSaw() then
descUI["b1"]:setVisible(true);
descUI["b1"]:setText("Cut");
descUI["b1"]:addArg("option", "Cut");
else
descUI["b1"]:setVisible(false);
end
elseif not partData.IsCut then -- Not cut
descUI["textEtat"]:setText("Not cut");
descUI["textEtat"]:setColor(1, 1, 1, 1);
if isPlayerHaveSaw() then
descUI["b1"]:setVisible(true);
descUI["b1"]:setText("Cut");
descUI["b1"]:addArg("option", "Cut");
else
descUI["b1"]:setVisible(false);
end
end
-- Set text for level
local player = getPlayer();
if string.find(partName, "Right") then
local lv = player:getPerkLevel(Perks.RightHand) + 1;
descUI["textLV2"]:setText("Level: " .. lv .. " / 10");
local xp = player:getXp():getXP(Perks.RightHand);
local min, max = findMinMax(lv);
descUI["pbarNLV"]:setMinMax(min, max);
descUI["pbarNLV"]:setValue(xp);
else
local lv = player:getPerkLevel(Perks.LeftHand) + 1;
descUI["textLV2"]:setText("Level: " .. lv .. " / 10");
local xp = player:getXp():getXP(Perks.LeftHand);
local min, max = findMinMax(lv);
descUI["pbarNLV"]:setMinMax(min, max);
descUI["pbarNLV"]:setValue(xp);
end
end
local function setConfirmUI(action)
confirmUI.actionAct = action;
confirmUI:setInCenterOfScreen();
confirmUI:bringToTop();
confirmUI:open();
if action == "Cut" then
if isPlayerHaveBandage() and isPlayerHavePainkiller() then
confirmUI["text2"]:setText("You have bandage and painkiller");
confirmUI["text2"]:setColor(1, 0, 1, 0);
else
confirmUI["text2"]:setText("You miss bandage or painkiller");
confirmUI["text2"]:setColor(1, 1, 0, 0);
end
if isPlayerHaveSaw() and getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct)):bitten() then
confirmUI["text3"]:setText("You are well bitten and you have a saw... it's time");
confirmUI["text3"]:setColor(1, 0, 1, 0);
elseif isPlayerHaveSaw() and not getPlayer():getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct)):bitten() then
confirmUI["text3"]:setText("What are you doing? You're okay !");
confirmUI["text3"]:setColor(1, 1, 0, 0);
else
confirmUI["text3"]:setText("You miss a saw");
confirmUI["text3"]:setColor(1, 1, 0, 0);
end
elseif action == "Operate" then
confirmUI["text2"]:setText("");
confirmUI["text3"]:setText("You are going to operate " .. getDisplayText_TOC(descUI.partNameAct));
confirmUI["text3"]:setColor(1, 1, 1, 1);
end
end
function SetConfirmUIMP(action, isBitten, userName, partName)
confirmUIMP:setInCenterOfScreen();
confirmUIMP:bringToTop();
confirmUIMP:open();
if action == "Cut" then
confirmUIMP["text4"]:setText("You gonna " .. action .. " the " .. getDisplayText_TOC(partName) .. " of " .. userName);
if isPlayerHaveBandage() and isPlayerHavePainkiller() then
confirmUIMP["text2"]:setText("You have bandage and painkiller");
confirmUIMP["text2"]:setColor(1, 0, 1, 0);
else
confirmUIMP["text2"]:setText("You miss bandage or painkiller");
confirmUIMP["text2"]:setColor(1, 1, 0, 0);
end
if isPlayerHaveSaw() and isBitten then
confirmUIMP["text3"]:setText("You are well bitten and you have a saw... it's time");
confirmUIMP["text3"]:setColor(1, 0, 1, 0);
confirmUIMP["b1"]:setVisible(true);
confirmUIMP["b2"]:setVisible(true);
elseif isPlayerHaveSaw() and not isBitten then
confirmUIMP["text3"]:setText("What are you doing? You're okay !");
confirmUIMP["text3"]:setColor(1, 1, 0, 0);
confirmUIMP["b1"]:setVisible(true);
confirmUIMP["b2"]:setVisible(true);
else
confirmUIMP["text3"]:setText("You miss a saw");
confirmUIMP["text3"]:setColor(1, 1, 0, 0);
confirmUIMP["b1"]:setVisible(false);
confirmUIMP["b2"]:setVisible(true);
end
elseif action == "Operate" then
confirmUIMP["text4"]:setText("You gonna " .. action .. " the " .. getDisplayText_TOC(partName) .. " of " .. userName);
confirmUIMP["text2"]:setText("");
confirmUIMP["text3"]:setText("");
confirmUIMP["b1"]:setVisible(true);
confirmUIMP["b2"]:setVisible(true);
elseif action == "Wait server" then
confirmUIMP["text4"]:setText(action);
confirmUIMP["text3"]:setText("");
confirmUIMP["text2"]:setText("");
confirmUIMP["b1"]:setVisible(false);
confirmUIMP["b2"]:setVisible(false);
end
end
local function setImageMainUI()
local modData = getPlayer():getModData().TOC
mainUI["b11"]:setPath(getImageName("RightArm", modData));
mainUI["b12"]:setPath(getImageName("LeftArm", modData));
mainUI["b21"]:setPath(getImageName("RightForearm", modData));
mainUI["b22"]:setPath(getImageName("LeftForearm", modData));
mainUI["b31"]:setPath(getImageName("RightHand", modData));
mainUI["b32"]:setPath(getImageName("LeftHand", modData));
end
-- Functions for button of UIs
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));
else
getPlayer():Say("Never mind");
end
end
if confirmUI.actionAct == "Operate" then
if args.option == "yes" then
local playerInv = player:getInventory();
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit');
if item then
ISTimedActionQueue.add(ISOperateArm:new(player, player, item, descUI.partNameAct, false));
else
player:Say("I need a kit");
end
else
getPlayer():Say("Never mind");
end
end
mainUI:close();
end
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));
else
getPlayer():Say("Never mind");
end
end
if confirmUIMP.actionAct == "Operate" then
if args.option == "yes" then
local playerInv = player:getInventory();
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit');
if item then
getPlayer():Say("Not moving ! Ok ?");
ISTimedActionQueue.add(ISOperateArm:new(confirmUIMP.patient, player, item, confirmUIMP.partNameAct, false));
else
player:Say("I need a kit");
end
else
getPlayer():Say("Never mind");
end
end
confirmUIMP:close();
confirmUIMP.responseReceive = false;
end
local function mainPress(button, args)
descUI:open();
descUI:setPositionPixel(mainUI:getRight(), mainUI:getY());
setDescUI(args.part);
end
local function descPress(button, args)
local player = getPlayer();
local playerInv = player:getInventory();
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
player:Say("I need to remove my prothesis first");
mainUI:close();
return false;
end
setConfirmUI("Cut");
elseif args.option == "Operate" then
setConfirmUI("Operate");
elseif args.option == "Equip" then
local item = playerInv:getItemFromType('TOC.MetalHand') or playerInv:getItemFromType('TOC.MetalHook') or playerInv:getItemFromType('TOC.WoodenHook');
if item then
ISTimedActionQueue.add(ISInstallProthesis:new(player, item, player:getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct))))
else
player:Say("I need a prosthesis");
end
mainUI:close();
elseif args.option == "Unequip" then
ISTimedActionQueue.add(ISUninstallProthesis:new(player, find_itemWorn_TOC(descUI.partNameAct), player:getBodyDamage():getBodyPart(TOC_getBodyPart(descUI.partNameAct))));
mainUI:close();
end
end
-- Make the UIS
local function makeMainUI()
mainUI = NewUI();
mainUI:setTitle("The only cure main menu");
mainUI:setWidthPercent(0.1);
mainUI:addImageButton("b11", "", mainPress);
mainUI["b11"]:addArg("part", "RightArm");
mainUI:addImageButton("b12", "", mainPress);
mainUI["b12"]:addArg("part", "LeftArm");
mainUI:nextLine();
mainUI:addImageButton("b21", "", mainPress);
mainUI["b21"]:addArg("part", "RightForearm");
mainUI:addImageButton("b22", "", mainPress);
mainUI["b22"]:addArg("part", "LeftForearm");
mainUI:nextLine();
mainUI:addImageButton("b31", "", mainPress);
mainUI["b31"]:addArg("part", "RightHand");
mainUI:addImageButton("b32", "", mainPress);
mainUI["b32"]:addArg("part", "LeftHand");
mainUI:saveLayout();
end
local function makeDescUI()
descUI = NewUI();
descUI:setTitle("The only cure description");
descUI:isSubUIOf(mainUI);
descUI:setWidthPixel(250);
descUI:setColumnWidthPixel(1, 100);
descUI:addText("textTitle", "Right arm", "Large", "Center");
descUI:nextLine();
descUI:addText("textLV2", "Level 3/10", _, "Center");
descUI:nextLine();
descUI:addText("textLV", "Next LV:", _, "Right");
descUI:addProgressBar("pbarNLV", 39, 0, 100);
descUI["pbarNLV"]:setMarginPixel(10, 6);
descUI:nextLine();
descUI:addEmpty("border1");
descUI:setLineHeightPixel(1);
descUI["border1"]:setBorder(true);
descUI:nextLine();
descUI:addEmpty();
descUI:nextLine();
descUI:addText("textEtat", "Is Cut !", "Medium", "Center");
descUI["textEtat"]:setColor(1, 1, 0, 0);
descUI:nextLine();
descUI:addEmpty();
descUI:nextLine();
descUI:addButton("b1", "Operate", descPress);
descUI:saveLayout();
end
local function makeConfirmUI()
confirmUI = NewUI();
confirmUI:isSubUIOf(descUI);
confirmUI:addText("text1", "Are you sure ?", "Title", "Center");
confirmUI:setLineHeightPixel(getTextManager():getFontHeight(confirmUI.text1.font) + 10)
confirmUI:nextLine();
confirmUI:addText("text2", "", _, "Center");
confirmUI:nextLine();
confirmUI:addText("text3", "", _, "Center");
confirmUI:nextLine();
confirmUI:addEmpty();
confirmUI:nextLine();
confirmUI:addEmpty();
confirmUI:addButton("b1", "Yes", confirmPress);
confirmUI.b1:addArg("option", "yes");
confirmUI:addEmpty();
confirmUI:addButton("b2", "No", confirmPress);
confirmUI:addEmpty();
confirmUI:nextLine();
confirmUI:addEmpty();
confirmUI:saveLayout();
end
function MakeConfirmUIMP()
confirmUIMP = NewUI();
confirmUIMP.responseReceive = false;
confirmUIMP:addText("text1", "Are you sure ?", "Title", "Center");
confirmUIMP:setLineHeightPixel(getTextManager():getFontHeight(confirmUIMP.text1.font) + 10)
confirmUIMP:nextLine();
confirmUIMP:addText("text4", "", "Medium", "Center");
confirmUIMP:setLineHeightPixel(getTextManager():getFontHeight(confirmUIMP.text4.font) + 10)
confirmUIMP:nextLine();
confirmUIMP:addText("text2", "", _, "Center");
confirmUIMP:nextLine();
confirmUIMP:addText("text3", "", _, "Center");
confirmUIMP:nextLine();
confirmUIMP:addEmpty();
confirmUIMP:nextLine();
confirmUIMP:addEmpty();
confirmUIMP:addButton("b1", "Yes", confirmPressMP);
confirmUIMP.b1:addArg("option", "yes");
confirmUIMP:addEmpty();
confirmUIMP:addButton("b2", "No", confirmPressMP);
confirmUIMP:addEmpty();
confirmUIMP:nextLine();
confirmUIMP:addEmpty();
confirmUIMP:saveLayout();
confirmUIMP:addPrerenderFunction(prerenderFuncMP);
confirmUIMP:close();
end
local function onCreateUI()
makeMainUI();
makeDescUI();
makeConfirmUI();
if isClient() then MakeConfirmUIMP() end
mainUI:close();
end
Events.OnCreateUI.Add(onCreateUI)
-- Add button to health panel
function ISNewHealthPanel.onClick_TOC(button)
mainUI:toggle();
mainUI:setInCenterOfScreen();
setImageMainUI();
end
local ISHealthPanel_createChildren = ISHealthPanel.createChildren
function ISHealthPanel:createChildren()
ISHealthPanel_createChildren(self);
self.fitness:setWidth(self.fitness:getWidth()/1.5);
self.TOCButton = ISButton:new(self.fitness:getRight(), self.healthPanel.y, 20, 20, "", self, ISNewHealthPanel.onClick_TOC);
self.TOCButton:setImage(getTexture("media/ui/TOC/iconForMenu.png"));
self.TOCButton.anchorTop = false
self.TOCButton.anchorBottom = true
self.TOCButton:initialise();
self.TOCButton:instantiate();
self:addChild(self.TOCButton);
if getCore():getGameMode() == "Tutorial" then
self.TOCButton:setVisible(false);
end
end
local ISHealthPanel_render = ISHealthPanel.render
function ISHealthPanel:render()
ISHealthPanel_render(self);
self.TOCButton:setY(self.fitness:getY());
end

View File

@@ -0,0 +1,178 @@
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 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 player:getSecondaryHandItem() ~= nil then
if player:getSecondaryHandItem():getName() ~= "Bare Hands" then player:dropHandItems() end
end
end
end
local function everyOneMinute()
local player = getPlayer();
local modData = player:getModData();
if modData.TOC ~= nil then
dropItem(player, modData);
CheckIfInfect(player, modData);
UpdatePlayerHealth(player, modData);
end
end
local function everyTenMinutes()
local player = getPlayer()
local modData = player:getModData()
if modData.TOC ~= nil then
local names = {"RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm"}
--Augmente l'xp si equip
if modData.TOC.RightHand.IsEquiped or modData.TOC.RightForearm.IsEquiped then player:getXp():AddXP(Perks.RightHand, 4) end
if modData.TOC.LeftHand.IsEquiped or modData.TOC.LeftForearm.IsEquiped then player:getXp():AddXP(Perks.LeftHand, 4) end
--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
if modData.TOC[name].IsOperated then
modData.TOC[name].CicaTimeLeft = modData.TOC[name].CicaTimeLeft - 1;
else
modData.TOC[name].CicaTimeLeft = modData.TOC[name].CicaTimeLeft - 10;
player:transmitModData()
end
end
end
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;
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;
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;
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;
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.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;
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;
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;
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;
player:getInventory():AddItem("TOC.MetalHook");
end
player:transmitModData()
end
end
local function initTOCTraits()
local amp1 = TraitFactory.addTrait("amputee1", getText("UI_trait_Amputee1"), -8, getText("UI_trait_Amputee1desc"), false, false);
amp1:addXPBoost(Perks.LeftHand, 4);
local amp2 = TraitFactory.addTrait("amputee2", getText("UI_trait_Amputee2"), -10, getText("UI_trait_Amputee2desc"), false, false);
amp2:addXPBoost(Perks.LeftHand, 4);
local amp3 = TraitFactory.addTrait("amputee3", getText("UI_trait_Amputee3"), -20, getText("UI_trait_Amputee3desc"), false, false);
amp3:addXPBoost(Perks.LeftHand, 4);
TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitivedesc"), false, false);
TraitFactory.setMutualExclusive("amputee1", "amputee2");
TraitFactory.setMutualExclusive("amputee1", "amputee3");
TraitFactory.setMutualExclusive("amputee2", "amputee3");
end
Events.EveryHours.Add(everyHours);
Events.EveryTenMinutes.Add(everyTenMinutes);
Events.EveryOneMinute.Add(everyOneMinute);
Events.OnCreatePlayer.Add(initVariable);
Events.OnGameBoot.Add(initTOCTraits);

View File

@@ -0,0 +1,163 @@
require "TimedActions/ISBaseTimedAction"
require "TimedActions/ISEquipWeaponAction"
local burnFact = 1.3
function ISBaseTimedAction:adjustMaxTime(maxTime)
if maxTime ~= -1 then
local maxTime_org = maxTime
-- add a slight maxtime if the character is unhappy
maxTime = maxTime + ((self.character:getMoodles():getMoodleLevel(MoodleType.Unhappy)) * 10)
-- add more time if the character have his hands wounded
if not self.ignoreHandsWounds then
for i=BodyPartType.ToIndex(BodyPartType.Hand_L), BodyPartType.ToIndex(BodyPartType.ForeArm_R) do
local part = self.character:getBodyDamage():getBodyPart(BodyPartType.FromIndex(i));
maxTime = maxTime + part:getPain();
end
end
-- Apply a multiplier based on body temperature.
maxTime = maxTime * self.character:getTimedActionTimeModifier();
if self.noAfectByCut then return maxTime; end
--Added if cut
local modData = getPlayer():getModData()
local protPartNames = {"RightHand", "RightForearm", "LeftHand", "LeftForearm"}
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;
else
maxTime = maxTime * 2;
end
if modData.TOC[name].IsBurn then maxTime = maxTime * burnFact end
end
end
for i,name in ipairs(otherPartNames) do
if modData.TOC[name].IsCut then
maxTime = maxTime * 2
if modData.TOC[name].IsBurn 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 maxTime > 10 * maxTime_org then maxTime = 10 * maxTime_org end
end
return maxTime;
end
function ISEquipWeaponAction:perform()
if self.sound then
self.character:getEmitter():stopSound(self.sound)
end
self.item:setJobDelta(0.0);
if self:isAlreadyEquipped(self.item) then
ISBaseTimedAction.perform(self);
return
end
if self.character:isEquippedClothing(self.item) then
self.character:removeWornItem(self.item)
triggerEvent("OnClothingUpdated", self.character)
end
self.item:getContainer():setDrawDirty(true);
forceDropHeavyItems(self.character)
if self.fromHotbar then
local hotbar = getPlayerHotbar(self.character:getPlayerNum());
hotbar.chr:removeAttachedItem(self.item);
self:setOverrideHandModels(self.item, nil)
end
if not self.twoHands then
-- equip primary weapon
if(self.primary) then
-- if the previous weapon need to be equipped in both hands, we then remove it
if self.character:getSecondaryHandItem() and self.character:getSecondaryHandItem():isRequiresEquippedBothHands() then
self.character:setSecondaryHandItem(nil);
end
-- if this weapon is already equiped in the 2nd hand, we remove it
if(self.character:getSecondaryHandItem() == self.item or self.character:getSecondaryHandItem() == self.character:getPrimaryHandItem()) then
self.character:setSecondaryHandItem(nil);
end
if not self.character:getPrimaryHandItem() or self.character:getPrimaryHandItem() ~= self.item then
self.character:setPrimaryHandItem(nil);
self.character:setPrimaryHandItem(self.item);
end
else -- second hand weapon
-- if the previous weapon need to be equipped in both hands, we then remove it
if self.character:getPrimaryHandItem() and self.character:getPrimaryHandItem():isRequiresEquippedBothHands() then
self.character:setPrimaryHandItem(nil);
end
-- if this weapon is already equiped in the 1st hand, we remove it
if(self.character:getPrimaryHandItem() == self.item or self.character:getSecondaryHandItem() == self.character:getPrimaryHandItem()) then
self.character:setPrimaryHandItem(nil);
end
if not self.character:getSecondaryHandItem() or self.character:getSecondaryHandItem() ~= self.item then
self.character:setSecondaryHandItem(nil);
self.character:setSecondaryHandItem(self.item);
end
end
else
self.character:setPrimaryHandItem(nil);
self.character:setSecondaryHandItem(nil);
self.character:setPrimaryHandItem(self.item);
self.character:setSecondaryHandItem(self.item);
end
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
self.character:setPrimaryHandItem(nil);
self.character:setSecondaryHandItem(self.item);
end
else
if not modData.TOC.RightHand.IsEquiped 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
self.character:setPrimaryHandItem(self.item);
self.character:setSecondaryHandItem(nil);
end
else
if not modData.TOC.LeftHand.IsEquiped 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
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
self.character:dropHandItems();
end
--if self.item:canBeActivated() and ((instanceof("Drainable", self.item) and self.item:getUsedDelta() > 0) or not instanceof("Drainable", self.item)) then
if self.item:canBeActivated() then
self.item:setActivated(true);
end
getPlayerInventory(self.character:getPlayerNum()):refreshBackpacks();
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self);
end

View File

@@ -0,0 +1,96 @@
require "TimedActions/ISBaseTimedAction"
IsCutArm = ISBaseTimedAction:derive("IsCutArm");
function IsCutArm:isValid()
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
end
function IsCutArm:waitToStart()
if self.patient == self.surgeon then
return false
end
self.surgeon:faceThisObject(self.patient)
return self.surgeon:shouldBeTurning()
end
function IsCutArm:update()
if self.patient ~= self.surgeon then
self.surgeon:faceThisObject(self.patient)
end
end
function IsCutArm:start()
if self.patient == self.surgeon then
self:setActionAnim("WearClothing");
self:setAnimVariable("WearClothingLocation", "Jacket")
else
self:setActionAnim("Loot")
self.patient:SetVariable("LootPosition", "Mid")
end
end
function IsCutArm:findArgs()
local useBandage, bandageAlcool, usePainkiller, painkillerCount
local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 15 end
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 9 end
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 4 end
local bandage = self.surgeon:getInventory():FindAndReturn('Bandage');
local albandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage');
if albandage then
useBandage = true;
bandageAlcool = true;
self.patient:getInventory():Remove(albandage);
surgeonFact = surgeonFact + 4
elseif bandage then
useBandage = true;
self.patient:getInventory():Remove(bandage);
surgeonFact = surgeonFact + 2
end
local painkiller = self.surgeon:getInventory():FindAndReturn('Pills');
if painkiller then
usePainkiller = true;
painkillerCount = painkiller:getRemainingUses();
end
return surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount;
end
function IsCutArm:perform()
local surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount = self:findArgs();
if self.patient ~= self.surgeon and isClient() then
SendCutArm(self.patient, self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
else
CutArm(self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
end
self.surgeon:getXp():AddXP(Perks.Doctor, 400);
ISBaseTimedAction.perform(self);
end
function IsCutArm:new(patient, surgeon, partName)
local o = {}
setmetatable(o, self)
self.__index = self
o.partName = partName;
o.bodyPart = TOC_getBodyPart(partName);
o.character = surgeon; -- For anim
o.surgeon = surgeon; -- Surgeon or player that make the operation
o.patient = patient; -- Player to cut
o.patientX = patient:getX();
o.patientY = patient:getY();
o.maxTime = 1000 - (surgeon:getPerkLevel(Perks.Doctor) * 50);
o.stopOnWalk = true;
o.stopOnRun = true;
o.ignoreHandsWounds = false;
o.fromHotbar = true;
if o.patient:isTimedActionInstant() then o.maxTime = 1; end
return o;
end

View File

@@ -0,0 +1,89 @@
require "TimedActions/ISBaseTimedAction"
ISOperateArm = ISBaseTimedAction:derive("ISOperateArm");
function ISOperateArm:isValid()
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
end
function ISOperateArm:waitToStart()
if self.patient == self.surgeon then
return false
end
self.surgeon:faceThisObject(self.patient)
return self.surgeon:shouldBeTurning()
end
function ISOperateArm:update()
if self.patient ~= self.surgeon then
self.surgeon:faceThisObject(self.patient)
end
end
function ISOperateArm:start()
self:setActionAnim("MedicalCheck");
if self.UseOven then
self.sound = self.patient:getEmitter():playSound("Burn_sound")
self:forceComplete();
end
end
function ISOperateArm:findArgs()
local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
if self.UseOven then
surgeonFact = surgeonFact + 100;
else
if self.kit then
local weight = math.floor(self.kit:getWeight() * 10 + 0.5)
if weight == 1 then
surgeonFact = surgeonFact + 2;
elseif weight == surgeonFact2 then
surgeonFact = surgeonFact + 4;
elseif weight == 3 then
surgeonFact = surgeonFact + 6;
end
end
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 10 end
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 5 end
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 2 end
end
return surgeonFact, self.useOven;
end
function ISOperateArm:perform()
local surgeonFact, useOven = self:findArgs();
if self.patient ~= self.surgeon and isClient() then
SendOperateArm(self.patient, self.partName, surgeonFact, useOven);
else
OperateArm(self.partName, surgeonFact, useOven);
end
self.surgeon:getXp():AddXP(Perks.Doctor, 400);
if self.kit then
self.surgeon:getInventory():Remove(self.kit);
end
ISBaseTimedAction.perform(self);
end
function ISOperateArm:new(patient, surgeon, kit, partName, UseOven)
local o = ISBaseTimedAction.new(self, patient);
o.partName = partName;
o.patient = patient;
o.character = surgeon; -- For anim
o.patientX = patient:getX();
o.patientY = patient:getY();
o.surgeon = surgeon;
o.kit = kit;
o.UseOven = UseOven;
if UseOven then o.maxTime = 30 else o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10) end
o.stopOnWalk = true;
o.stopOnRun = true;
o.ignoreHandsWounds = false;
o.fromHotbar = true;
if o.patient:isTimedActionInstant() then o.maxTime = 1; end
return o;
end

View File

@@ -0,0 +1,133 @@
require "TimedActions/ISBaseTimedAction"
ISInstallProthesis = ISBaseTimedAction:derive("ISInstallProthesis");
function ISInstallProthesis:isValid()
return true;
end
function ISInstallProthesis:update()
self.item:setJobDelta(self:getJobDelta());
end
function ISInstallProthesis:start()
self.item:setJobType("Install prothesis");
self.item:setJobDelta(0.0);
self:setActionAnim("WearClothing");
self:setAnimVariable("WearClothingLocation", "Jacket");
end
function ISInstallProthesis:stop()
ISBaseTimedAction.stop(self);
self.item:setJobDelta(0.0);
end
function ISInstallProthesis:perform()
self.item:setJobDelta(0.0);
local modData = self.character:getModData();
local lor = 0
local foh = 0
if self.bodyPart:getType() == BodyPartType.Hand_R then lor = 1; foh = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then lor = 1; foh = 2
elseif self.bodyPart:getType() == BodyPartType.Hand_L then lor = 0; foh = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then lor = 0; foh = 2
end
local mat_id = 0
local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10
if weight == 1 and foh == 1 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_right_noHand");
mat_id = 1;
else
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_left_noHand");
mat_id = 1;
end
elseif weight == 0.5 and foh == 1 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_right_noHand");
mat_id = 2;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_left_noHand");
mat_id = 2;
end
elseif weight == 0.3 and foh == 1 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_right_noHand");
mat_id = 3;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_left_noHand");
mat_id = 3;
end
elseif weight == 1 and foh == 2 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_right_noForearm");
mat_id = 1;
else
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_left_noForearm");
mat_id = 1;
end
elseif weight == 0.5 and foh == 2 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_right_noForearm");
mat_id = 2;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_left_noForearm");
mat_id = 2;
end
elseif weight == 0.3 and foh == 2 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_right_noForearm");
mat_id = 3;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_left_noForearm");
mat_id = 3;
end
end
if self.cloth ~= nil then
if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.IsEquiped = true;
modData.TOC.RightHand.Equip_mat_id = mat_id;
modData.TOC.RightHand.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.IsEquiped = true;
modData.TOC.RightForearm.Equip_mat_id = mat_id;
modData.TOC.RightForearm.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.IsEquiped = true;
modData.TOC.LeftHand.Equip_mat_id = mat_id;
modData.TOC.LeftHand.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.IsEquiped = true;
modData.TOC.LeftForearm.Equip_mat_id = mat_id;
modData.TOC.LeftForearm.EquipFact = find_protheseFact_TOC(self.cloth);
end
self.character:getInventory():Remove(self.item);
self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth);
end
self.character:transmitModData()
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self);
end
function ISInstallProthesis:new(character, item, bodyPart)
local o = ISBaseTimedAction.new(self, character);
o.item = item;
o.bodyPart = bodyPart;
o.maxTime = 100;
o.stopOnWalk = true;
o.stopOnRun = true;
o.cloth = nil;
o.ignoreHandsWounds = false;
o.fromHotbar = true; -- just to disable hotbar:update() during the wearing
if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o;
end

View File

@@ -0,0 +1,92 @@
require "TimedActions/ISBaseTimedAction"
ISUninstallProthesis = ISBaseTimedAction:derive("ISUninstallProthesis");
function ISUninstallProthesis:isValid()
return true;
end
function ISUninstallProthesis:update()
self.item:setJobDelta(self:getJobDelta());
end
function ISUninstallProthesis:start()
self.item:setJobType("Uninstall prothesis");
self.item:setJobDelta(0.0);
self:setActionAnim("WearClothing");
if self.item:IsClothing() then
self:setAnimVariable("WearClothingLocation", "Jacket")
elseif self.item:IsInventoryContainer() and self.item:canBeEquipped() ~= "" then
self:setAnimVariable("WearClothingLocation", "Jacket")
end
end
function ISUninstallProthesis:stop()
ISBaseTimedAction.stop(self);
self.item:setJobDelta(0.0);
end
function ISUninstallProthesis:perform()
self.item:getContainer():setDrawDirty(true);
self.item:setJobDelta(0.0);
if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() ~= "" then
self.character:removeFromHands(self.item);
self.character:setWornItem(self.item:canBeEquipped(), self.item);
getPlayerInventory(self.character:getPlayerNum()):refreshBackpacks();
elseif self.item:getCategory() == "Clothing" then
if self.item:getBodyLocation() ~= "" then
self.character:setWornItem(self.item:getBodyLocation(), self.item);
end
end
local modData = self.character:getModData()
if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.IsEquiped = false;
modData.TOC.RightHand.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.IsEquiped = false;
modData.TOC.RightForearm.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.IsEquiped = false;
modData.TOC.LeftHand.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.IsEquiped = false;
modData.TOC.LeftForearm.EquipFact = 1;
end
local weight = math.floor(self.item:getWeight() * 10 + 0.5)
if weight == 10 then
self.character:getInventory():AddItem("TOC.WoodenHook")
elseif weight == 5 then
self.character:getInventory():AddItem("TOC.MetalHook")
elseif weight == 3 then
self.character:getInventory():AddItem("TOC.MetalHand")
elseif weight == 20 then
self.character:getInventory():AddItem("TOC.WoodenHook")
elseif weight == 15 then
self.character:getInventory():AddItem("TOC.MetalHook")
elseif weight == 12 then
self.character:getInventory():AddItem("TOC.MetalHand")
end
self.character:setWornItem(self.item:getBodyLocation(), nil);
self.character:getInventory():Remove(self.item);
self.character:transmitModData();
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self);
end
function ISUninstallProthesis:new(character, item, bodyPart)
local o = ISBaseTimedAction.new(self, character);
o.item = item;
o.character = character;
o.bodyPart = bodyPart;
o.maxTime = 100;
o.stopOnWalk = true;
o.stopOnRun = true;
o.ignoreHandsWounds = false;
o.fromHotbar = true; -- just to disable hotbar:update() during the wearing
if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o;
end

View File

@@ -0,0 +1,77 @@
function find_clothName_TOC(bodyPart)
if bodyPart:getType() == BodyPartType.Hand_R then return "TOC.ArmRight_noHand"
elseif bodyPart:getType() == BodyPartType.ForeArm_R then return "TOC.ArmRight_noForearm"
elseif bodyPart:getType() == BodyPartType.UpperArm_R then return "TOC.ArmRight_noArm"
elseif bodyPart:getType() == BodyPartType.Hand_L then return "TOC.ArmLeft_noHand"
elseif bodyPart:getType() == BodyPartType.ForeArm_L then return "TOC.ArmLeft_noForearm"
elseif bodyPart:getType() == BodyPartType.UpperArm_L then return "TOC.ArmLeft_noArm"
else return nil
end
end
function getDisplayText_TOC(name)
if name == "RightHand" then return getText("UI_ContextMenu_RightHand") end
if name == "RightForearm" then return getText("UI_ContextMenu_RightForearm") end
if name == "RightArm" then return getText("UI_ContextMenu_RightArm") end
if name == "LeftHand" then return getText("UI_ContextMenu_LeftHand") end
if name == "LeftForearm" then return getText("UI_ContextMenu_LeftForearm") end
if name == "LeftArm" then return getText("UI_ContextMenu_LeftArm") end
end
function TOC_getBodyPart(name)
if name == "RightHand" then return BodyPartType.Hand_R end
if name == "RightForearm" then return BodyPartType.ForeArm_R end
if name == "RightArm" then return BodyPartType.UpperArm_R end
if name == "LeftHand" then return BodyPartType.Hand_L end
if name == "LeftForearm" then return BodyPartType.ForeArm_L end
if name == "LeftArm" then return BodyPartType.UpperArm_L end
end
function find_clothName2_TOC(name)
if name == "RightHand" then return "TOC.ArmRight_noHand" end
if name == "RightForearm" then return "TOC.ArmRight_noForearm" end
if name == "RightArm" then return "TOC.ArmRight_noArm" end
if name == "LeftHand" then return "TOC.ArmLeft_noHand" end
if name == "LeftForearm" then return "TOC.ArmLeft_noForearm" end
if name == "LeftArm" then return "TOC.ArmLeft_noArm" end
end
function find_bodyPart_TOC(modData, bodyPart)
if modData.RightHand == nil then modData = modData.TOC end
if bodyPart:getType() == BodyPartType.Hand_R then return modData.RightHand
elseif bodyPart:getType() == BodyPartType.ForeArm_R then return modData.RightForearm
elseif bodyPart:getType() == BodyPartType.UpperArm_R then return modData.RightArm
elseif bodyPart:getType() == BodyPartType.Hand_L then return modData.LeftHand
elseif bodyPart:getType() == BodyPartType.ForeArm_L then return modData.LeftForearm
elseif bodyPart:getType() == BodyPartType.UpperArm_L then return modData.LeftArm
else return nil
end
end
function find_protheseID_TOC(item)
local itemType = item:getType()
if string.find(itemType, "WoodenHook") then return 1
elseif string.find(itemType, "MetalHook") then return 2
elseif string.find(itemType, "MetalHand") then return 3
else return 0
end
end
function find_protheseFact_TOC(item)
local itemType = item:getType()
if string.find(itemType, "WoodenHook") and string.find(itemType, "noHand") then return 1.5
elseif string.find(itemType, "WoodenHook") and string.find(itemType, "noForearm") then return 1.65
elseif string.find(itemType, "MetalHook") and string.find(itemType, "noHand") then return 1.3
elseif string.find(itemType, "MetalHook") and string.find(itemType, "noForearm") then return 1.45
elseif string.find(itemType, "MetalHand") and string.find(itemType, "noHand") then return 1.1
elseif string.find(itemType, "MetalHand") and string.find(itemType, "noForearm") then return 1.25
end
end
function CanBeCut(partName)
return not getPlayer():getModData().TOC[partName].IsCut
end
function CanBeOperate(partName)
return getPlayer():getModData().TOC[partName].IsCut and not getPlayer():getModData().TOC[partName].IsOperated and not getPlayer():getModData().TOC[partName].IsCicatrized
end