i'm burning
This commit is contained in:
@@ -11,6 +11,19 @@ function SendCutArm(player, partName, surgeonFact, useBandage, bandageAlcool, us
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
|
||||
function TheOnlyCure.SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
local arg = {}
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["To"] = player:getOnlineID()
|
||||
arg["command"] = "CutLimb"
|
||||
arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table}
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function SendOperateArm(player, partName, surgeonFact, useOven)
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
@@ -52,11 +65,20 @@ end
|
||||
|
||||
|
||||
-- Patient (receive)
|
||||
Commands["CutLimb"] = function(arg)
|
||||
local arg = arg["toSend"]
|
||||
TheOnlyCure.CutLimb(arg[1], arg[2], arg[3], arg[4])
|
||||
end
|
||||
|
||||
|
||||
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]);
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
local function OnTocServerCommand(module, command, args)
|
||||
-- TODO Change name of the func
|
||||
|
||||
@@ -28,6 +32,7 @@ local function OnTocServerCommand(module, command, args)
|
||||
|
||||
-- ew a global var.... but dunno if there's a better way to do this
|
||||
MP_other_player_toc_data = args[2]
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
-- TODO OLD TO DELETE
|
||||
local function CheckIfStillInfected(toc_data)
|
||||
for k,v in pairs(GetBodyParts()) do
|
||||
if toc_data[v].is_infected == true then
|
||||
@@ -12,7 +12,7 @@ local function CheckIfStillInfected(toc_data)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- TODO OLD TO DELETE
|
||||
local function CureInfection(bodyDamage)
|
||||
bodyDamage:setInfected(false);
|
||||
bodyDamage:setInfectionMortalityDuration(-1);
|
||||
@@ -23,9 +23,6 @@ local function CureInfection(bodyDamage)
|
||||
local bodyPart = bodyParts:get(i);
|
||||
bodyPart:SetInfected(false);
|
||||
end
|
||||
|
||||
getPlayer().Say("I'm gonna be fine")
|
||||
|
||||
end
|
||||
|
||||
-- TODO change it to CutLimb or CutBodyPart
|
||||
@@ -133,7 +130,6 @@ function OperateArm(partName, surgeonFact, useOven)
|
||||
player:transmitModData();
|
||||
end
|
||||
|
||||
|
||||
function SetBodyPartsStatus(player, partName, useOven)
|
||||
-- TODO use GetBodyParts with depends_on
|
||||
|
||||
@@ -166,8 +162,12 @@ function SetBodyPartsStatus(player, partName, useOven)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for k,v in pairs(chosen_array) do
|
||||
local tmpBodyPart = player:getBodyDamage():getBodyPart(TOC_getBodyPart(v));
|
||||
local tmpBodyPart = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(v))
|
||||
|
||||
tmpBodyPart:setDeepWounded(false); -- Basically like stictching
|
||||
tmpBodyPart:setDeepWoundTime(0);
|
||||
if useOven then
|
||||
|
||||
65
media/lua/client/TOC_HelperFunctions.lua
Normal file
65
media/lua/client/TOC_HelperFunctions.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
-- CutLimb
|
||||
function TheOnlyCure.CheckIfStillInfected(toc_data)
|
||||
|
||||
-- Check ALL body part types to check if the player is still gonna die
|
||||
local check = false
|
||||
|
||||
for _, v in ipairs(GetBodyParts()) do
|
||||
if toc_data[v].is_infected then
|
||||
check = true
|
||||
end
|
||||
end
|
||||
|
||||
if toc_data.is_other_bodypart_infected then
|
||||
check = true
|
||||
end
|
||||
|
||||
return check
|
||||
end
|
||||
|
||||
|
||||
function TheOnlyCure.CureInfection(body_damage)
|
||||
body_damage:setInfected(false)
|
||||
body_damage:setInfectionMortalityDuration(-1)
|
||||
body_damage:setInfectionTime(-1)
|
||||
body_damage:setInfectionLevel(0)
|
||||
local body_part_types = body_damage:getBodyParts()
|
||||
for i=body_part_types:size()-1, 0, -1 do
|
||||
local bodyPart = body_part_types:get(i)
|
||||
bodyPart:SetInfected(false)
|
||||
end
|
||||
|
||||
getPlayer().Say("I'm gonna be fine")
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- OperateLimb
|
||||
function TheOnlyCure.SetBodyPartsStatusAfterOperation(player, toc_data, part_name, use_oven)
|
||||
--for _, v in ipairs(GetBodyParts()) do
|
||||
|
||||
|
||||
local body_part_type = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name))
|
||||
FixSingleBodyPartType(body_part_type, use_oven)
|
||||
|
||||
for _, v in ipairs(toc_data[part_name].depends_on) do
|
||||
local depended_body_part_type = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(v))
|
||||
FixSingleBodyPartType(depended_body_part_type, use_oven)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function FixSingleBodyPartType(body_part_type, use_oven)
|
||||
body_part_type:setDeepWounded(false) --Basically like stitching
|
||||
body_part_type:setDeepWoundTime(0)
|
||||
if use_oven then
|
||||
body_part_type:AddDamage(100)
|
||||
body_part_type:setAdditionalPain(100);
|
||||
body_part_type:setBleeding(false)
|
||||
body_part_type:setBleedingTime(0) -- no bleeding since it's been cauterized
|
||||
else
|
||||
body_part_type:setBleeding(true);
|
||||
body_part_type:setBleedingTime(ZombRand(1, 5)); -- Reset the bleeding, maybe make it random
|
||||
end
|
||||
end
|
||||
|
||||
@@ -340,7 +340,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(ISCutLimb:new(player, player, descUI.partNameAct));
|
||||
else
|
||||
getPlayer():Say("Never mind");
|
||||
end
|
||||
@@ -366,7 +366,7 @@ local function confirmPressMP(button, args)
|
||||
if confirmUIMP.actionAct == "Cut" then
|
||||
if args.option == "yes" then
|
||||
getPlayer():Say("Hold on, I believe in you!");
|
||||
ISTimedActionQueue.add(IsCutArm:new(confirmUIMP.patient, player, confirmUIMP.partNameAct));
|
||||
ISTimedActionQueue.add(ISCutLimb:new(confirmUIMP.patient, player, confirmUIMP.partNameAct));
|
||||
else
|
||||
getPlayer():Say("Alright...");
|
||||
end
|
||||
|
||||
@@ -119,5 +119,103 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
|
||||
-- TODO Check if this works in MP through MENU UI
|
||||
local player = getPlayer()
|
||||
local toc_data = player:getModDare().TOC
|
||||
local body_part_type = player:getBodyDamage():getBodyPart(TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name))
|
||||
local stats = player:getStats();
|
||||
|
||||
-- Set damage, stress, and low endurance after amputation
|
||||
body_part_type:AddDamage(100 - surgeon_factor)
|
||||
body_part_type:setAdditionalPain(100 - surgeon_factor)
|
||||
body_part_type:setBleeding(true)
|
||||
body_part_type:setBleedingTime(100 - surgeon_factor)
|
||||
body_part_type:setDeepWounded(true)
|
||||
body_part_type:setDeepWoundTime(100 - surgeon_factor)
|
||||
stats:setEndurance(surgeon_factor)
|
||||
stats:setStress(100 - surgeon_factor)
|
||||
|
||||
-- If bandages are available, use them
|
||||
body_part_type:setBandaged(bandage_table.use_bandage, 10, bandage_table.is_bandage_sterilized, bandage_table.bandage_type)
|
||||
|
||||
|
||||
|
||||
-- If painkillers are available, use them
|
||||
-- ...
|
||||
|
||||
if toc_data[part_name].is_cut == false then
|
||||
toc_data[part_name].is_cut = true
|
||||
toc_data[part_name].is_amputation_shown = true
|
||||
toc_data[part_name].cicatrization_time = toc_data[part_name].cicatrization_base_time - surgeon_factor * 50
|
||||
|
||||
-- Heal the infection here
|
||||
local body_damage = player:getBodyDamage()
|
||||
if toc_data[part_name].is_infected and body_damage.getInfectionLevel() < 20 then
|
||||
toc_data[part_name].is_infected = false
|
||||
body_part_type:SetBitten(false)
|
||||
|
||||
-- Second check, let's see if there is any other infected limb.
|
||||
if TheOnlyCure.CheckIfStillInfected(toc_data) == false then
|
||||
TheOnlyCure.CureInfection(body_damage)
|
||||
getPlayer():Say("I'm gonna be fine")
|
||||
else
|
||||
getPlayer():Say("I'm still gonna die...")
|
||||
end
|
||||
end
|
||||
|
||||
-- Cut the depended part
|
||||
for _, depended_v in pairs(toc_data[part_name].depends_on) do
|
||||
toc_data[depended_v].is_cut = true
|
||||
toc_data[depended_v].is_amputation_shown = true
|
||||
toc_data[depended_v].cicatrization_time = toc_data[part_name].cicatrization_base_time - surgeon_factor * 50
|
||||
end
|
||||
|
||||
--Equip model for amputation
|
||||
local cloth = player:getInventory():AddItem(find_clothName2_TOC(part_name))
|
||||
player:setWornItem(cloth:getBodyLocation(), cloth)
|
||||
player:transmitModData()
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
function TheOnlyCure.OperateLimb(part_name, surgeon_factor, use_oven)
|
||||
|
||||
local player = getPlayer()
|
||||
local toc_data = player:getModData().TOC
|
||||
|
||||
if use_oven then
|
||||
local stats = player:getStats()
|
||||
stats:setEndurance(100)
|
||||
stats:setStress(100)
|
||||
end
|
||||
|
||||
if toc_data[part_name].is_operated == false and toc_data[part_name].is_cut == true then
|
||||
toc_data[part_name].is_operated = true
|
||||
toc_data[part_name].cicatrization_time = toc_data[part_name].cicatrization_time - (surgeon_factor * 200)
|
||||
if use_oven then toc_data[part_name].is_cauterized = true end
|
||||
for _, depended_v in pairs(toc_data[part_name].depends_on) do
|
||||
toc_data[depended_v].is_operated = true
|
||||
toc_data[depended_v].cicatrization_time = toc_data[depended_v].cicatrization_time - (surgeon_factor * 200)
|
||||
if use_oven then toc_data[depended_v].is_cauterized = true end -- TODO does this make sense?
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
TheOnlyCure.SetBodyPartsStatusAfterOperation(player, toc_data, part_name, use_oven)
|
||||
player:transmitModData()
|
||||
end
|
||||
|
||||
|
||||
|
||||
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
|
||||
Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits)
|
||||
121
media/lua/client/TimedActions/NewOnCut2.lua
Normal file
121
media/lua/client/TimedActions/NewOnCut2.lua
Normal file
@@ -0,0 +1,121 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
ISCutLimb = ISBaseTimedAction:derive("ISCutLimb")
|
||||
|
||||
|
||||
function ISCutLimb:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY()
|
||||
end
|
||||
|
||||
function ISCutLimb:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function ISCutLimb:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
end
|
||||
|
||||
function ISCutLimb:start()
|
||||
if self.patient == self.surgeon then
|
||||
self:setActionAnim("WearClothing") -- TODO Change it to a better animation
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
else
|
||||
self:setActionAnim("Loot")
|
||||
self.patient:SetVariable("LootPosition", "Mid")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ISCutLimb:findArgs()
|
||||
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor)
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeon_factor = surgeon_factor + 15 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeon_factor = surgeon_factor + 9 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeon_factor = surgeon_factor + 4 end
|
||||
|
||||
local bandage_table = {
|
||||
use_bandage = false,
|
||||
bandage_type = nil,
|
||||
is_bandage_sterilized = nil}
|
||||
local painkiller_table = {}
|
||||
|
||||
|
||||
local bandage = self.surgeon:getInventory():FindAndReturn('Bandage')
|
||||
local sterilized_bandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage')
|
||||
|
||||
if sterilized_bandage then
|
||||
bandage_table.bandage_type = sterilized_bandage:getType()
|
||||
bandage_table.is_bandage_sterilized = true
|
||||
bandage_table.use_bandage = true
|
||||
self.surgeon:getInventory():Remove(sterilized_bandage)
|
||||
surgeon_factor = surgeon_factor + 4
|
||||
elseif bandage then
|
||||
bandage_table.bandage_type = bandage:getType()
|
||||
bandage_table.is_bandage_sterilized = false
|
||||
self.surgeon:getInventory():Remove(bandage)
|
||||
surgeon_factor = surgeon_factor + 2
|
||||
else
|
||||
bandage_table.bandage_type = ""
|
||||
bandage_table.use_bandage = false
|
||||
bandage_table.is_bandage_sterilized = false
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- local painkiller = self.surgeon:getInventory():FindAndReturn('Pills');
|
||||
-- if painkiller then
|
||||
-- usePainkiller = true;
|
||||
-- painkillerCount = painkiller:getRemainingUses();
|
||||
-- end
|
||||
|
||||
return surgeon_factor, bandage_table, painkiller_table
|
||||
end
|
||||
|
||||
|
||||
function ISCutLimb:perform()
|
||||
local surgeon_factor, bandage_table, painkiller_table = self:findArgs()
|
||||
|
||||
if self.patient ~= self.surgoen and isClient() then
|
||||
SendCutLimb()
|
||||
else
|
||||
TheOnlyCure.CutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
end
|
||||
|
||||
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 ISCutLimb:new(patient, surgeon, part_name)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
o.partName = part_name
|
||||
o.bodyPart = TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name)
|
||||
o.character = surgeon -- For anim
|
||||
|
||||
o.surgeon = surgeon; -- Surgeon or player that make the operation
|
||||
o.patient = patient; -- Player to amputate
|
||||
|
||||
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
|
||||
@@ -40,7 +40,21 @@ function getDisplayText_TOC(name)
|
||||
if name == "LeftArm" then return getText("UI_ContextMenu_LeftArm") end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TheOnlyCure.GetBodyPartTypeFromBodyPart(part_name)
|
||||
if part_name == "RightHand" then return BodyPartType.Hand_R end
|
||||
if part_name == "RightForearm" then return BodyPartType.ForeArm_R end
|
||||
if part_name == "RightArm" then return BodyPartType.UpperArm_R end
|
||||
if part_name == "LeftHand" then return BodyPartType.Hand_L end
|
||||
if part_name == "LeftForearm" then return BodyPartType.ForeArm_L end
|
||||
if part_name == "LeftArm" then return BodyPartType.UpperArm_L end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TOC_getBodyPart(name)
|
||||
--TODO Delete this
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user