First stuff for prosthesis rewrite
This commit is contained in:
@@ -6,111 +6,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function TryTocAction(_, part_name, action, surgeon, patient)
|
|
||||||
-- TODO add checks so that we don't show these menus if a player has already beeen operated or amputated
|
|
||||||
-- TODO at this point surgeon doesnt do anything. We'll fix this later
|
|
||||||
|
|
||||||
-- Check if SinglePlayer
|
|
||||||
if not isServer() and not isClient() then
|
|
||||||
|
|
||||||
if action == "Cut" then
|
|
||||||
TocCutLocal(_, surgeon, surgeon, part_name)
|
|
||||||
elseif action == "Operate" then
|
|
||||||
TocOperateLocal(_, surgeon, surgeon, part_name, false)
|
|
||||||
elseif action == "Equip" then
|
|
||||||
-- TODO finish this
|
|
||||||
local item
|
|
||||||
TocEquipProsthesisLocal(_, surgeon, surgeon, part_name)
|
|
||||||
elseif action == "Unequip" then
|
|
||||||
-- TODO finish this
|
|
||||||
local item
|
|
||||||
TocUnequipProsthesisLocal(_, surgeon, part_name)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
|
|
||||||
local ui = GetConfirmUIMP()
|
|
||||||
if not ui then
|
|
||||||
CreateTocConfirmUIMP()
|
|
||||||
ui = GetConfirmUIMP()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if patient == nil then
|
|
||||||
patient = surgeon
|
|
||||||
end
|
|
||||||
|
|
||||||
if action == "Cut" then
|
|
||||||
AskCanCutLimb(patient, part_name)
|
|
||||||
elseif action == "Operate" then
|
|
||||||
AskCanOperateLimb(patient, part_name)
|
|
||||||
elseif action == "Equip" then
|
|
||||||
local surgeon_inventory = surgeon:getInventory()
|
|
||||||
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
|
|
||||||
surgeon_inventory:getItemFromType('TOC.MetalHook') or
|
|
||||||
surgeon_inventory:getItemFromType('TOC.WoodenHook')
|
|
||||||
if prosthesis_to_equip then
|
|
||||||
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name))))
|
|
||||||
else
|
|
||||||
surgeon:Say("I need a prosthesis")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--AskCanEquipProsthesis(patient, part_name, item)
|
|
||||||
|
|
||||||
elseif action == "Unequip" then
|
|
||||||
--AskCanUnequipProsthesis(patient, part_name)
|
|
||||||
local equipped_prosthesis = FindTocItemWorn(part_name, patient)
|
|
||||||
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name))))
|
|
||||||
end
|
|
||||||
ui.actionAct = action
|
|
||||||
ui.partNameAct = part_name
|
|
||||||
ui.patient = patient
|
|
||||||
|
|
||||||
--TODO just a workaround for now
|
|
||||||
if action ~= "Equip" and action ~= "Unequip" then
|
|
||||||
SendCommandToConfirmUIMP("Wait server")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- function TryTocActionOnAnotherPlayer(_, part_name, action, surgeon, patient)
|
|
||||||
|
|
||||||
|
|
||||||
-- if action == "Cut" then
|
|
||||||
-- AskCanCutLimb(patient, part_name)
|
|
||||||
|
|
||||||
-- elseif action == "Operate" then
|
|
||||||
-- AskCanOperateLimb(patient, part_name)
|
|
||||||
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local function CheckIfCanBeOperated(modData)
|
|
||||||
-- if modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.is_operated
|
|
||||||
-- or modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.is_operated
|
|
||||||
-- or modData.TOC.RightArm.is_cut and not modData.TOC.RightArm.is_operated
|
|
||||||
-- or modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.is_operated
|
|
||||||
-- or modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.is_operated
|
|
||||||
-- or modData.TOC.LeftArm.is_cut and not modData.TOC.LeftArm.is_operated then
|
|
||||||
-- return true
|
|
||||||
-- else
|
|
||||||
-- return false
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local function CloseAllMenus(player_index)
|
|
||||||
local contextMenu = getPlayerContextMenu(player_index)
|
|
||||||
if contextMenu:isVisible() then
|
|
||||||
|
|
||||||
contextMenu:closeAll()
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function ResetEverything()
|
|||||||
-- Destroy the amputation model
|
-- Destroy the amputation model
|
||||||
|
|
||||||
for _,v in ipairs(GetBodyParts()) do
|
for _,v in ipairs(GetBodyParts()) do
|
||||||
local cloth = player:getInventory():FindAndReturn(find_clothName2_TOC(v))
|
local cloth = player:getInventory():FindAndReturn(TocFindAmputatedClothingFromPartName(v))
|
||||||
|
|
||||||
if cloth ~= nil then
|
if cloth ~= nil then
|
||||||
print("Resetting " .. cloth:getName())
|
print("Resetting " .. cloth:getName())
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
local leftForearm = "LeftForearm"
|
local leftForearm = "LeftForearm"
|
||||||
local leftArm = "LeftArm"
|
local leftArm = "LeftArm"
|
||||||
|
|
||||||
|
|
||||||
|
local prothesis_list = {"WoodenHook", "MetalHook", "MetalHand"}
|
||||||
|
|
||||||
mod_data.TOC = {
|
mod_data.TOC = {
|
||||||
RightHand = {},
|
RightHand = {},
|
||||||
RightForearm = {},
|
RightForearm = {},
|
||||||
@@ -77,6 +80,20 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
|||||||
mod_data.TOC[leftArm].cicatrization_base_time = 2000
|
mod_data.TOC[leftArm].cicatrization_base_time = 2000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Setup a table with all the acceptable prosthesis
|
||||||
|
mod_data.TOC.prosthesis_table = {}
|
||||||
|
|
||||||
|
for _, v in ipairs(prothesis_list) do
|
||||||
|
mod_data.TOC.prosthesis_table[v] = {
|
||||||
|
material_id = 1,
|
||||||
|
something = "Something"
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Traits setup
|
-- Traits setup
|
||||||
if player:HasTrait("amputee1") then
|
if player:HasTrait("amputee1") then
|
||||||
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noHand")
|
local cloth = player:getInventory():AddItem("TOC.ArmLeft_noHand")
|
||||||
@@ -177,7 +194,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Equip model for amputation
|
--Equip model for amputation
|
||||||
local cloth = player:getInventory():AddItem(find_clothName2_TOC(part_name))
|
local cloth = player:getInventory():AddItem(TocFindAmputatedClothingFromPartName(part_name))
|
||||||
player:setWornItem(cloth:getBodyLocation(), cloth)
|
player:setWornItem(cloth:getBodyLocation(), cloth)
|
||||||
player:transmitModData()
|
player:transmitModData()
|
||||||
|
|
||||||
@@ -216,6 +233,73 @@ function TheOnlyCure.OperateLimb(part_name, surgeon_factor, use_oven)
|
|||||||
player:transmitModData()
|
player:transmitModData()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TryTocAction(_, part_name, action, surgeon, patient)
|
||||||
|
-- TODO add checks so that we don't show these menus if a player has already beeen operated or amputated
|
||||||
|
-- TODO at this point surgeon doesnt do anything. We'll fix this later
|
||||||
|
|
||||||
|
-- Check if SinglePlayer
|
||||||
|
if not isServer() and not isClient() then
|
||||||
|
|
||||||
|
if action == "Cut" then
|
||||||
|
TocCutLocal(_, surgeon, surgeon, part_name)
|
||||||
|
elseif action == "Operate" then
|
||||||
|
TocOperateLocal(_, surgeon, surgeon, part_name, false)
|
||||||
|
elseif action == "Equip" then
|
||||||
|
-- TODO finish this
|
||||||
|
local item
|
||||||
|
TocEquipProsthesisLocal(_, surgeon, surgeon, part_name)
|
||||||
|
elseif action == "Unequip" then
|
||||||
|
-- TODO finish this
|
||||||
|
local item
|
||||||
|
TocUnequipProsthesisLocal(_, surgeon, part_name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
|
||||||
|
local ui = GetConfirmUIMP()
|
||||||
|
if not ui then
|
||||||
|
CreateTocConfirmUIMP()
|
||||||
|
ui = GetConfirmUIMP()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if patient == nil then
|
||||||
|
patient = surgeon
|
||||||
|
end
|
||||||
|
|
||||||
|
if action == "Cut" then
|
||||||
|
AskCanCutLimb(patient, part_name)
|
||||||
|
elseif action == "Operate" then
|
||||||
|
AskCanOperateLimb(patient, part_name)
|
||||||
|
elseif action == "Equip" then
|
||||||
|
local surgeon_inventory = surgeon:getInventory()
|
||||||
|
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
|
||||||
|
surgeon_inventory:getItemFromType('TOC.MetalHook') or
|
||||||
|
surgeon_inventory:getItemFromType('TOC.WoodenHook')
|
||||||
|
if prosthesis_to_equip then
|
||||||
|
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name))))
|
||||||
|
else
|
||||||
|
surgeon:Say("I need a prosthesis")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--AskCanEquipProsthesis(patient, part_name, item)
|
||||||
|
|
||||||
|
elseif action == "Unequip" then
|
||||||
|
--AskCanUnequipProsthesis(patient, part_name)
|
||||||
|
local equipped_prosthesis = FindTocItemWorn(part_name, patient)
|
||||||
|
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromBodyPart(part_name))))
|
||||||
|
end
|
||||||
|
ui.actionAct = action
|
||||||
|
ui.partNameAct = part_name
|
||||||
|
ui.patient = patient
|
||||||
|
|
||||||
|
--TODO just a workaround for now
|
||||||
|
if action ~= "Equip" and action ~= "Unequip" then
|
||||||
|
SendCommandToConfirmUIMP("Wait server")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
|
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ require "TimedActions/ISBaseTimedAction"
|
|||||||
|
|
||||||
ISCutLimb = ISBaseTimedAction:derive("ISCutLimb")
|
ISCutLimb = ISBaseTimedAction:derive("ISCutLimb")
|
||||||
|
|
||||||
|
-- TODO Add a check so you can't cut your arm if you don't have hands or if you only have one arm and want to cut that same arm.
|
||||||
|
|
||||||
function ISCutLimb:isValid()
|
function ISCutLimb:isValid()
|
||||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY()
|
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY()
|
||||||
@@ -43,6 +44,9 @@ function ISCutLimb:start()
|
|||||||
body_damage_part:setCut(true)
|
body_damage_part:setCut(true)
|
||||||
body_damage_part:setBleedingTime(ZombRand(10,20))
|
body_damage_part:setBleedingTime(ZombRand(10,20))
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO Make the object currently on the hand return to the inventory
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,33 +51,6 @@ function ISInstallProsthesis:perform()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- print(self.item)
|
|
||||||
|
|
||||||
|
|
||||||
-- TODO there is something wrong with how I'm managing prosthesis. they don't apply
|
|
||||||
-- TODO cheatMenu are fucked up, admin access is wrong
|
|
||||||
|
|
||||||
-- TODO make a parser or something I dont care
|
|
||||||
-- Check Item before doing any of this shit maybe
|
|
||||||
-- Assemble the correct name for the object
|
|
||||||
--local prosthesis_name = self.item:getname() .. "_" .. Right .. "_" .. Forearm
|
|
||||||
-- for _, v in ipairs(GetLimbsBodyPartTypes()) do
|
|
||||||
-- if v ~= BodyPartType.UpperArm_L or v ~= BodyPartType.UpperArm_R then
|
|
||||||
|
|
||||||
-- if self.bodyPart:getType() == v then
|
|
||||||
-- --local item_name = "TOC."
|
|
||||||
-- --local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10
|
|
||||||
|
|
||||||
|
|
||||||
-- TODO why do we need this?
|
|
||||||
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if self.bodyPart:getType() == BodyPartType.Hand_R then lor = 1; foh = 1
|
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.ForeArm_R then lor = 1; foh = 2
|
||||||
elseif self.bodyPart:getType() == BodyPartType.Hand_L then lor = 0; foh = 1
|
elseif self.bodyPart:getType() == BodyPartType.Hand_L then lor = 0; foh = 1
|
||||||
|
|||||||
@@ -49,12 +49,6 @@ function ISUninstallProsthesis:perform()
|
|||||||
return -- should never happen
|
return -- should never happen
|
||||||
end
|
end
|
||||||
|
|
||||||
--if accepting_body_parts[body_part_type] then
|
|
||||||
-- toc_data[TOC_getBodyPart(body_part_type)]
|
|
||||||
--end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for _, v in ipairs(GetAcceptingProsthesisBodyParts()) do
|
for _, v in ipairs(GetAcceptingProsthesisBodyParts()) do
|
||||||
if self.bodyPart:getType() == v then
|
if self.bodyPart:getType() == v then
|
||||||
local part_name = FindTocBodyPartNameFromBodyPartType(v)
|
local part_name = FindTocBodyPartNameFromBodyPartType(v)
|
||||||
@@ -96,6 +90,8 @@ function ISUninstallProsthesis:perform()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO Make the object currently on the hand return to the inventory
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ISUninstallProsthesis:new(character, item, bodyPart)
|
function ISUninstallProsthesis:new(character, item, bodyPart)
|
||||||
|
|||||||
@@ -96,15 +96,17 @@ function TocGetBodyPartTypeFromBodyPart(part_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function find_clothName2_TOC(name)
|
function TocFindAmputatedClothingFromPartName(part_name)
|
||||||
if name == "RightHand" then return "TOC.ArmRight_noHand" end
|
if part_name == "RightHand" then return "TOC.ArmRight_noHand" end
|
||||||
if name == "RightForearm" then return "TOC.ArmRight_noForearm" end
|
if part_name == "RightForearm" then return "TOC.ArmRight_noForearm" end
|
||||||
if name == "RightArm" then return "TOC.ArmRight_noArm" end
|
if part_name == "RightArm" then return "TOC.ArmRight_noArm" end
|
||||||
if name == "LeftHand" then return "TOC.ArmLeft_noHand" end
|
if part_name == "LeftHand" then return "TOC.ArmLeft_noHand" end
|
||||||
if name == "LeftForearm" then return "TOC.ArmLeft_noForearm" end
|
if part_name == "LeftForearm" then return "TOC.ArmLeft_noForearm" end
|
||||||
if name == "LeftArm" then return "TOC.ArmLeft_noArm" end
|
if part_name == "LeftArm" then return "TOC.ArmLeft_noArm" end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function find_protheseID_TOC(item)
|
function find_protheseID_TOC(item)
|
||||||
local itemType = item:getType()
|
local itemType = item:getType()
|
||||||
if string.find(itemType, "WoodenHook") then return 1
|
if string.find(itemType, "WoodenHook") then return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user