Merge branch 'master' into modular_prosthetics
This commit is contained in:
@@ -98,6 +98,20 @@ function TocDamagePlayerDuringAmputation(patient, part_name)
|
||||
body_damage_part:setBleedingTime(ZombRand(10, 20))
|
||||
end
|
||||
|
||||
local function FindTourniquetInWornItems(patient, side)
|
||||
local worn_items = patient:getWornItems()
|
||||
|
||||
for i = 1, worn_items:size() - 1 do -- Maybe wornItems:size()-1
|
||||
local item = worn_items:get(i):getItem()
|
||||
local item_full_type = item:getFullType()
|
||||
if string.find(item_full_type, "Test_Tourniquet_" .. side) then
|
||||
return item
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
|
||||
end
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
--- Main function for cutting a limb
|
||||
@@ -116,13 +130,9 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
local limbs_data = toc_data.Limbs
|
||||
|
||||
|
||||
|
||||
-- TODO Stop for a bit,
|
||||
|
||||
-- Cut Hand -> Damage in forearm
|
||||
-- Cut Forearm -> Damage in Upperarm
|
||||
-- Cut UpperArm -> Damage to torso
|
||||
|
||||
local body_damage = player:getBodyDamage()
|
||||
local body_part = body_damage:getBodyPart(TocGetBodyPartFromPartName(part_name))
|
||||
local adiacent_body_part = player:getBodyDamage():getBodyPart(TocGetAdiacentBodyPartFromPartName(part_name))
|
||||
@@ -135,18 +145,33 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
-- The bit will be checked later since we're not sure if the player is not infected from another wound
|
||||
TocSetParametersForMissingLimb(body_part, false)
|
||||
|
||||
-- Use a tourniquet if available
|
||||
local tourniquet_item = FindTourniquetInWornItems(player, TocGetSideFromPartName(part_name))
|
||||
|
||||
local base_damage_value = 100
|
||||
|
||||
if tourniquet_item ~= nil then
|
||||
base_damage_value = 50
|
||||
|
||||
if part_name == "Left_UpperArm" or part_name == "Right_UpperArm" then
|
||||
player:removeWornItem(tourniquet_item)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Set damage, stress, and low endurance after amputation
|
||||
adiacent_body_part:AddDamage(100 - surgeon_factor)
|
||||
adiacent_body_part:setAdditionalPain(100 - surgeon_factor)
|
||||
adiacent_body_part:AddDamage(base_damage_value - surgeon_factor)
|
||||
adiacent_body_part:setAdditionalPain(base_damage_value - surgeon_factor)
|
||||
adiacent_body_part:setBleeding(true)
|
||||
adiacent_body_part:setBleedingTime(100 - surgeon_factor)
|
||||
adiacent_body_part:setBleedingTime(base_damage_value - surgeon_factor)
|
||||
adiacent_body_part:setDeepWounded(true)
|
||||
adiacent_body_part:setDeepWoundTime(100 - surgeon_factor)
|
||||
adiacent_body_part:setDeepWoundTime(base_damage_value - surgeon_factor)
|
||||
stats:setEndurance(surgeon_factor)
|
||||
stats:setStress(100 - surgeon_factor)
|
||||
stats:setStress(base_damage_value - surgeon_factor)
|
||||
|
||||
|
||||
-- Set malus for strength and fitness
|
||||
-- TODO Make it more "random" with just some XP scaling down instead of a whole level, depending on the limb that we're cutting
|
||||
player:LoseLevel(Perks.Fitness)
|
||||
player:LoseLevel(Perks.Strength)
|
||||
|
||||
@@ -161,8 +186,9 @@ function TocCutLimb(part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
-- If painkillers are available, use them
|
||||
-- TODO add painkiller support
|
||||
|
||||
-- Use a tourniquet if available
|
||||
-- TODO add tourniquet
|
||||
|
||||
|
||||
-- A check for is_cut shouldn't be necessary here since if we've got here we've already checked it out enough
|
||||
|
||||
if limbs_data[part_name].is_cut == false then
|
||||
limbs_data[part_name].is_cut = true
|
||||
@@ -1,3 +1,10 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
------------- LOCAL ACTIONS --------------
|
||||
|
||||
|
||||
|
||||
function TocCutLocal(_, player, part_name)
|
||||
if TocGetSawInInventory(player) ~= nil then
|
||||
ISTimedActionQueue.add(ISCutLimb:new(player, player, part_name))
|
||||
@@ -7,12 +14,10 @@ function TocCutLocal(_, player, part_name)
|
||||
end
|
||||
|
||||
function TocOperateLocal(_, player, part_name, use_oven)
|
||||
--local player = getPlayer();
|
||||
-- todo add a check if the player has already been amputated or somethin
|
||||
if use_oven then
|
||||
ISTimedActionQueue.add(ISOperateLimb:new(player, player, _, part_name, use_oven));
|
||||
else
|
||||
local kit = TocGetKitInInventory(player) -- TODO Why is it here and only for local?
|
||||
local kit = TocGetKitInInventory(player)
|
||||
if kit ~= nil then
|
||||
ISTimedActionQueue.add(ISOperateLimb:new(player, player, kit, part_name, false))
|
||||
else
|
||||
63
media/lua/client/ActionsMethods/TOC_ProsthesisMethods.lua
Normal file
63
media/lua/client/ActionsMethods/TOC_ProsthesisMethods.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
---------- PROSTHESIS FUNCTIONS ----------
|
||||
|
||||
|
||||
---Equip a prosthesis transforming a normal item into a clothing item
|
||||
---@param part_name string
|
||||
---@param prosthesis_base_name string
|
||||
function TocEquipProsthesis(part_name, prosthesis_base_name)
|
||||
local player = getPlayer()
|
||||
|
||||
local toc_data = player:getModData().TOC
|
||||
|
||||
local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
|
||||
local added_prosthesis = player:getInventory():AddItem(prosthesis_name)
|
||||
|
||||
if part_name ~= nil then
|
||||
|
||||
if added_prosthesis ~= nil then
|
||||
toc_data.Limbs[part_name].is_prosthesis_equipped = true
|
||||
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name]
|
||||
|
||||
if player:isFemale() then
|
||||
added_prosthesis:getVisual():setTextureChoice(1)
|
||||
else
|
||||
added_prosthesis:getVisual():setTextureChoice(0)
|
||||
end
|
||||
player:setWornItem(added_prosthesis:getBodyLocation(), added_prosthesis)
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---Unequip a prosthesis clothing item and returns it to the inventory as a normal item
|
||||
---@param part_name string
|
||||
function TocUnequipProsthesis(patient, part_name, equipped_prosthesis)
|
||||
|
||||
|
||||
local toc_data = patient:getModData().TOC
|
||||
toc_data.Limbs[part_name].is_prosthesis_equipped = false
|
||||
|
||||
|
||||
local equipped_prosthesis_full_type = equipped_prosthesis:getFullType()
|
||||
|
||||
|
||||
for _, prost_v in ipairs(GetProsthesisList()) do
|
||||
local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v)
|
||||
if prosthesis_name then
|
||||
patient:getInventory():AddItem("TOC." .. prosthesis_name)
|
||||
patient:setWornItem(equipped_prosthesis:getBodyLocation(), nil)
|
||||
patient:getInventory():Remove(equipped_prosthesis)
|
||||
toc_data.Limbs[part_name].equipped_prosthesis = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- TODO this should be moved
|
||||
|
||||
function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
|
||||
local function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
|
||||
sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() })
|
||||
end
|
||||
|
||||
@@ -67,19 +67,11 @@ end
|
||||
|
||||
TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjects, test)
|
||||
local player_obj = getSpecificPlayer(player)
|
||||
--local clickedPlayer
|
||||
|
||||
|
||||
-- TODO Add a way to move the player towards the oven
|
||||
|
||||
-- TODO Let the player move towards the oven
|
||||
|
||||
local part_data = player_obj:getModData().TOC.Limbs
|
||||
|
||||
local is_main_menu_already_created = false
|
||||
|
||||
|
||||
--local props = v:getSprite() and v:getSprite():getProperties() or nil
|
||||
|
||||
for _, v_stove in pairs(worldObjects) do
|
||||
if instanceof(v_stove, "IsoStove") and
|
||||
(player_obj:HasTrait("Brave") or player_obj:getPerkLevel(Perks.Strength) >= 6) then
|
||||
@@ -53,7 +53,7 @@ local function GetImageName(part_name, limbs_data)
|
||||
elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut)
|
||||
name = "media/ui/TOC/Empty.png"
|
||||
elseif not part_data.is_cut and
|
||||
-- TODO This doesn't work in MP on another player since we're trying to retrieve bodyDamage from another player
|
||||
-- FIXME This doesn't work in MP on another player since we're trying to retrieve bodyDamage from another player
|
||||
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(part_name)):bitten() then -- Not cut but bitten
|
||||
name = "media/ui/TOC/" .. part_name .. "/Bite.png"
|
||||
else -- Not cut
|
||||
@@ -288,6 +288,54 @@ local function OnClickTocMainUI(button, args)
|
||||
|
||||
end
|
||||
|
||||
-- Generic TOC action, used in OnClickTocDescUI
|
||||
local function TryTocAction(_, part_name, action, surgeon, patient)
|
||||
-- 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, part_name)
|
||||
elseif action == "Operate" then
|
||||
TocOperateLocal(_, surgeon, part_name, false)
|
||||
elseif action == "Equip" then
|
||||
TocEquipProsthesisLocal(_, surgeon, part_name)
|
||||
elseif action == "Unequip" then
|
||||
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
|
||||
AskCanEquipProsthesis(patient, part_name)
|
||||
elseif action == "Unequip" then
|
||||
AskCanUnequipProsthesis(patient, part_name)
|
||||
end
|
||||
|
||||
ui.actionAct = action
|
||||
ui.partNameAct = part_name
|
||||
ui.patient = patient
|
||||
|
||||
SendCommandToConfirmUIMP("Wait server")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function OnClickTocDescUI(button, args)
|
||||
|
||||
-- Gets every arg from main
|
||||
@@ -335,9 +383,7 @@ local function OnClickTocConfirmUIMP(button, args)
|
||||
-- We can't check if the player has a prosthesis right now, we need to do it later
|
||||
|
||||
-- TODO should check if player has a prosthesis equipped before doing it
|
||||
|
||||
-- TODO Player is surgeon, but we don't have a confirm_ui_mp.surgeon... awful awful awful
|
||||
|
||||
-- TODO Workaround for now, we'd need to send data from patient before doing it since we can't access his inventory from the surgeon
|
||||
if confirm_ui_mp.patient == player then
|
||||
ISTimedActionQueue.add(ISUninstallProsthesis:new(player, confirm_ui_mp.patient, confirm_ui_mp.partNameAct))
|
||||
@@ -394,8 +440,8 @@ local function CreateTocMainUI()
|
||||
|
||||
end
|
||||
|
||||
-- Create a temporary desc UI with fake data (for now)
|
||||
local function CreateTocDescUI()
|
||||
-- TODO most of this stuff is just temporary. We can probably wipe this off the face of the earth
|
||||
desc_ui = NewUI()
|
||||
desc_ui:setTitle("The only cure description");
|
||||
desc_ui:isSubUIOf(main_ui)
|
||||
@@ -428,7 +474,7 @@ local function CreateTocDescUI()
|
||||
desc_ui:addEmpty()
|
||||
desc_ui:nextLine()
|
||||
|
||||
desc_ui:addButton("b1", "Operate", OnClickTocDescUI) -- TODO this is just temporary
|
||||
desc_ui:addButton("b1", "Operate", OnClickTocDescUI)
|
||||
|
||||
desc_ui:saveLayout()
|
||||
end
|
||||
@@ -540,6 +586,24 @@ function ISNewHealthPanel.onClick_TOC(button)
|
||||
Events.OnTick.Add(TocRefreshPlayerMenu)
|
||||
end
|
||||
|
||||
|
||||
-- Set the correct main title
|
||||
-- TODO sizes of the menu are strange in MP, they're not consistent with SP
|
||||
local separated_username = {}
|
||||
|
||||
for v in string.gmatch(patient:getUsername(), "%u%l+") do
|
||||
table.insert(separated_username, v)
|
||||
end
|
||||
|
||||
local main_title
|
||||
if separated_username[1] == nil then
|
||||
main_title = patient:getUsername() .. " - TOC"
|
||||
else
|
||||
main_title = separated_username[1] .. " " .. separated_username[2] .. " - TOC"
|
||||
end
|
||||
|
||||
main_ui:setTitle(main_title)
|
||||
|
||||
main_ui:toggle()
|
||||
main_ui:setInCenterOfScreen()
|
||||
|
||||
@@ -45,16 +45,16 @@ end
|
||||
-----------------------------------------
|
||||
|
||||
function CheckIfItemIsAmputatedLimb(item)
|
||||
-- TODO Benchmark if this is faster
|
||||
local item_full_type = item:getFullType()
|
||||
|
||||
local check
|
||||
|
||||
if string.find(item_full_type, "TOC.Amputation_") then
|
||||
return true
|
||||
check = true
|
||||
else
|
||||
return false
|
||||
check = false
|
||||
end
|
||||
|
||||
return check
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,13 @@ function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkille
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["To"] = player:getOnlineID()
|
||||
arg["command"] = "CutLimb"
|
||||
arg["toSend"] = { part_name, surgeon_factor, bandage_table, painkiller_table }
|
||||
|
||||
|
||||
-- TODO Hotfix for sound, fix this later
|
||||
arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table, getPlayer():getOnlineID()}
|
||||
|
||||
|
||||
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
@@ -100,6 +106,13 @@ end
|
||||
-- Patient (receive)
|
||||
Commands["CutLimb"] = function(arg)
|
||||
local arg = arg["toSend"]
|
||||
local surgeon_id = arg[5]
|
||||
|
||||
-- Disable the sound coming from the surgeon
|
||||
getPlayerByOnlineID(surgeon_id):getEmitter():stopSoundByName("Amputation_Sound")
|
||||
|
||||
|
||||
|
||||
TocCutLimb(arg[1], arg[2], arg[3], arg[4])
|
||||
end
|
||||
|
||||
@@ -126,7 +139,7 @@ Commands["UnequipProsthesis"] = function(arg)
|
||||
|
||||
local arg = arg["toSend"]
|
||||
|
||||
TheOnlyCure.UnequipProsthesis(arg[1], arg[2])
|
||||
TheOnlyCure.TocUnequipProsthesis(arg[1], arg[2])
|
||||
|
||||
end
|
||||
|
||||
@@ -109,3 +109,13 @@ function TocGetSawInInventory(surgeon)
|
||||
player_inv:getItemFromType("Chainsaw")
|
||||
return item
|
||||
end
|
||||
|
||||
function TocGetSideFromPartName(part_name)
|
||||
|
||||
if string.find(part_name, "Left") then
|
||||
return "Left"
|
||||
else
|
||||
return "Right"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -22,9 +22,8 @@ local function TocReapplyAmputationClothingItem(mod_data)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Gets the old status and turns it into the new.
|
||||
function TocCheckCompatibilityWithOlderVersions(mod_data)
|
||||
-- Gets the old status and turns it into the new.
|
||||
|
||||
if mod_data.TOC.Limbs == nil then
|
||||
print("TOC: Limbs is nil, setting new mod_data")
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
------------ DEBUG FUNCTIONS -------------
|
||||
|
||||
|
||||
-- Side functions
|
||||
local function TocGetAmputationFullTypeFromInventory(player, side, limb)
|
||||
@@ -105,9 +110,15 @@ function TocResetClothingItemBodyLocation(player, side, limb)
|
||||
prosthesis_item = nil -- reset it
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
------ TEST FUNCTIONS, DON'T USE THESE!!! ---------------
|
||||
|
||||
function TocTestBodyLocations()
|
||||
|
||||
local group = BodyLocations.getGroup("Human")
|
||||
|
||||
@@ -9,7 +9,7 @@ end
|
||||
|
||||
-- Unequip Prosthesis
|
||||
|
||||
function PartNameToBodyLocationProsthesis(name)
|
||||
local function PartNameToBodyLocationProsthesis(name)
|
||||
if name == "Right_Hand" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Right_LowerArm" then return "TOC_ArmRightProsthesis" end
|
||||
if name == "Right_UpperArm" then return "TOC_ArmRightProsthesis" end
|
||||
@@ -18,7 +18,7 @@ function PartNameToBodyLocationProsthesis(name)
|
||||
if name == "Left_UpperArm" then return "TOC_ArmLeftProsthesis" end
|
||||
end
|
||||
|
||||
function PartNameToBodyLocationAmputation(name)
|
||||
local function PartNameToBodyLocationAmputation(name)
|
||||
if name == "Right_Hand" then return "TOC_ArmRight" end
|
||||
if name == "Right_LowerArm" then return "TOC_ArmRight" end
|
||||
if name == "Right_UpperArm" then return "TOC_ArmRight" end
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
------------- INIT FUNCTIONS -------------
|
||||
|
||||
if not TheOnlyCure then
|
||||
TheOnlyCure = {}
|
||||
end
|
||||
@@ -22,8 +27,6 @@ local function TocCutLimbForTrait(player, limbs_data, part_name)
|
||||
limbs_data[v].is_cicatrized = true
|
||||
end
|
||||
end
|
||||
|
||||
-- Sub function of TocSetInitData
|
||||
local function TocUpdateBaseData(mod_data)
|
||||
|
||||
-- TODO The prosthetic knife needs to be a weapon first and foremost, so other than a
|
||||
@@ -197,8 +200,6 @@ local function TocSetInitData(mod_data, player)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function TheOnlyCure.InitTheOnlyCure(_, player)
|
||||
|
||||
local mod_data = player:getModData()
|
||||
@@ -211,8 +212,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TheOnlyCure.DeclareTraits()
|
||||
local function TocDeclareTraits()
|
||||
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8,
|
||||
getText("UI_trait_Amputee_Hand_desc"), false, false)
|
||||
amp1:addXPBoost(Perks.Left_Hand, 4)
|
||||
@@ -232,52 +232,6 @@ function TheOnlyCure.DeclareTraits()
|
||||
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
|
||||
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, part_name)
|
||||
elseif action == "Operate" then
|
||||
TocOperateLocal(_, surgeon, part_name, false)
|
||||
elseif action == "Equip" then
|
||||
TocEquipProsthesisLocal(_, surgeon, part_name)
|
||||
elseif action == "Unequip" then
|
||||
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
|
||||
AskCanEquipProsthesis(patient, part_name)
|
||||
elseif action == "Unequip" then
|
||||
AskCanUnequipProsthesis(patient, part_name)
|
||||
end
|
||||
|
||||
ui.actionAct = action
|
||||
ui.partNameAct = part_name
|
||||
ui.patient = patient
|
||||
|
||||
SendCommandToConfirmUIMP("Wait server")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
|
||||
Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits)
|
||||
Events.OnGameBoot.Add(TocDeclareTraits)
|
||||
|
||||
@@ -26,15 +26,8 @@ local function SetCompatibilityFancyHandwork()
|
||||
local limbs_data = getPlayer():getModData().TOC.Limbs
|
||||
local can_be_held = {}
|
||||
|
||||
-- TODO not totally realiable
|
||||
TocPopulateCanBeHeldTable(can_be_held, limbs_data)
|
||||
|
||||
|
||||
-- for _, test in pairs(can_be_held) do
|
||||
-- print(test)
|
||||
-- end
|
||||
--ISInventoryPaneContextMenu.transferIfNeeded(self.chr, item)
|
||||
|
||||
-- If we already have the item equipped
|
||||
if (primary and primary == item) or (secondary and secondary == item) then
|
||||
ISTimedActionQueue.add(ISUnequipAction:new(self.chr, item, 20))
|
||||
@@ -83,7 +76,6 @@ local function SetCompatibilityFancyHandwork()
|
||||
|
||||
local og_FHSwapHandsAction = FHSwapHandsAction.start
|
||||
|
||||
|
||||
function FHSwapHandsAction:isValid()
|
||||
local limbs_data = getPlayer():getModData().TOC.Limbs
|
||||
local can_be_held = {}
|
||||
|
||||
@@ -17,11 +17,8 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
-- MOD SUPPORT ACTIONS
|
||||
----------------------
|
||||
-- LIR
|
||||
|
||||
if TOC_ModTable.LeftIsRight then
|
||||
|
||||
if mod_data.LIR.is_attacking then
|
||||
-- TODO we need to check if we're doing that specific action
|
||||
return original_max_time
|
||||
end
|
||||
end
|
||||
@@ -196,3 +193,30 @@ function ISInventoryPaneContextMenu.dropItem(item, player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Make the player unable to equip a tourniquet on an already fully amputated limb
|
||||
local og_ISWearClothingIsValid = ISWearClothing.isValid
|
||||
function ISWearClothing:isValid()
|
||||
local base_check = og_ISWearClothingIsValid(self)
|
||||
--return self.character:getInventory():contains(self.item);
|
||||
|
||||
local item_full_type = self.item:getFullType()
|
||||
|
||||
-- TODO Sides
|
||||
local limbs_data = self.character:getModData().TOC.Limbs
|
||||
|
||||
for _, side in pairs(TOC_sides) do
|
||||
if string.find(item_full_type, "Test_Tourniquet_" .. side) then
|
||||
if limbs_data[side .. "_UpperArm"].is_cut then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return base_check
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
------------------------------------------
|
||||
-------- THE ONLY CURE BUT BETTER --------
|
||||
------------------------------------------
|
||||
---------- PROSTHESIS FUNCTIONS ----------
|
||||
|
||||
|
||||
---Equip a prosthesis transforming a normal item into a clothing item
|
||||
---@param part_name string
|
||||
---@param prosthesis_base_name string
|
||||
function TocEquipProsthesis(part_name, prosthesis_base_name)
|
||||
local player = getPlayer()
|
||||
|
||||
local toc_data = player:getModData().TOC
|
||||
|
||||
local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
|
||||
local added_prosthesis = player:getInventory():AddItem(prosthesis_name)
|
||||
|
||||
if part_name ~= nil then
|
||||
|
||||
if added_prosthesis ~= nil then
|
||||
toc_data.Limbs[part_name].is_prosthesis_equipped = true
|
||||
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name]
|
||||
|
||||
if player:isFemale() then
|
||||
added_prosthesis:getVisual():setTextureChoice(1)
|
||||
else
|
||||
added_prosthesis:getVisual():setTextureChoice(0)
|
||||
end
|
||||
player:setWornItem(added_prosthesis:getBodyLocation(), added_prosthesis)
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---Unequip a prosthesis clothing item and returns it to the inventory as a normal item
|
||||
---@param part_name string
|
||||
function TheOnlyCure.UnequipProsthesis(patient, part_name, equipped_prosthesis)
|
||||
|
||||
|
||||
local toc_data = patient:getModData().TOC
|
||||
toc_data.Limbs[part_name].is_prosthesis_equipped = false
|
||||
|
||||
|
||||
local equipped_prosthesis_full_type = equipped_prosthesis:getFullType()
|
||||
|
||||
|
||||
for _, prost_v in ipairs(GetProsthesisList()) do
|
||||
local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v)
|
||||
if prosthesis_name then
|
||||
patient:getInventory():AddItem("TOC." .. prosthesis_name)
|
||||
patient:setWornItem(equipped_prosthesis:getBodyLocation(), nil)
|
||||
patient:getInventory():Remove(equipped_prosthesis)
|
||||
toc_data.Limbs[part_name].equipped_prosthesis = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------------------------------
|
||||
-- TEST MODULAR SYSTEM
|
||||
---------------------------------------------------------------------------------------------
|
||||
|
||||
function TocModular()
|
||||
|
||||
|
||||
-- Should affect comfort, so mobility (equal speed of actions)
|
||||
local prost_straps = {
|
||||
"leather_strap", -
|
||||
"sheet_strap"
|
||||
}
|
||||
|
||||
-- A better base has a better resistance. During use it's gonna break sooner or later so a leather base is the best inbetween
|
||||
local prost_base_forearm = {
|
||||
"leather_base_forearm", -- Good resistance and speed
|
||||
"wood_base_forearm", -- Shitty resistance and low speed
|
||||
"metal_base_forearm" -- Really high resistance and very low speed
|
||||
}
|
||||
|
||||
local prost_base_hand = {
|
||||
"wood_base_hand",
|
||||
"metal_base_hand"
|
||||
}
|
||||
|
||||
|
||||
|
||||
local prost_top = {
|
||||
"metal_hook", -- Decent action speed (around 0.75), good durability, restores hand
|
||||
"metal_knife", -- Doesn't count as an hand, but substitute the primary attack... Gonna need a way to disable it to make LIR work (retractable)
|
||||
"wooden_hook", -- Shitty action speed (around 0.3), bad durability, restores hand
|
||||
"metal_hand" -- Good action speed, amazing durability, restores hand
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
local TOC_straps = {
|
||||
leather_strap = {
|
||||
time_modifier = 1,
|
||||
durability = 1,
|
||||
},
|
||||
sheet_strap = {
|
||||
time_modifier = 0.3,
|
||||
durability = 0.4
|
||||
}
|
||||
}
|
||||
|
||||
local TOC_base_lowerarm = {
|
||||
leather_base = {
|
||||
durability = 1,
|
||||
time_modifier = 1
|
||||
},
|
||||
wood_base = {
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
},
|
||||
metal_base = {
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
local TOC_base_hand = {
|
||||
wood_base = {
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
},
|
||||
metal_base = {
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local TOC_top = {
|
||||
metal_hook = {
|
||||
type = "Normal", -- restores functioning hand
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
},
|
||||
wooden_hook = {
|
||||
type = "Normal",
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
},
|
||||
|
||||
metal_hand = {
|
||||
type = "Normal",
|
||||
durability = 1,
|
||||
time_modifier = 1,
|
||||
},
|
||||
|
||||
metal_knife = {
|
||||
type = "Attack"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
-- We need A LOT of recipes... or use another menu from the toc one
|
||||
|
||||
-- RECIPES FOR FOREARM = 24 RECIPES in total
|
||||
-- Would be 48 items in TOC_items since we need them for both sides
|
||||
|
||||
|
||||
-- RECIPES FOR HAND = 8 RECIPES in total
|
||||
-- Would be in total 16 items
|
||||
|
||||
|
||||
|
||||
-- TOTAL = 64 ITEMS and 32 RECIPES
|
||||
|
||||
-- Leather strap + leather base forearm + metal hook
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Base Item that can be crafted\found
|
||||
|
||||
-- Different type of hooks
|
||||
|
||||
-- Addons that can be added to the base item
|
||||
|
||||
|
||||
-- Equip and unequip pretty much the same
|
||||
|
||||
end
|
||||
@@ -49,9 +49,6 @@ local function TocManagePhantomPain(player, toc_data)
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO Add phantom pain to depended parts
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -85,9 +82,9 @@ local function SetHealthStatusForBodyPart(part_data, part_name, player)
|
||||
|
||||
|
||||
-- Check for stitching
|
||||
local is_stitched = false
|
||||
local is_stitched = false -- TODO Implement this
|
||||
|
||||
|
||||
-- TODO Implement this
|
||||
|
||||
if part_data[part_name].is_cut then
|
||||
--print("TOC: Check update for " .. part_name)
|
||||
@@ -162,8 +159,6 @@ end
|
||||
local function UpdatePlayerHealth(player, part_data)
|
||||
local body_damage = player:getBodyDamage()
|
||||
|
||||
|
||||
|
||||
if player:HasTrait("Insensitive") then body_damage:setPainReduction(49) end
|
||||
|
||||
for _, part_name in pairs(GetBodyParts()) do
|
||||
@@ -253,7 +248,7 @@ local function TocUpdateEveryOneMinute()
|
||||
-- Updates toc data in a global way, basically player:transmitModData but it works
|
||||
-- Sends only Limbs since the other stuff is mostly static
|
||||
if toc_data ~= nil then
|
||||
-- TODO make it so that we dont send it constantly
|
||||
-- FIXME Send little packets instead of the whole thing?
|
||||
sendClientCommand(player, 'TOC', 'ChangePlayerState', { toc_data.Limbs } )
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
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()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY()
|
||||
@@ -24,7 +23,7 @@ end
|
||||
|
||||
function ISCutLimb:stop()
|
||||
|
||||
self.character:getEmitter():stopSoundByName("Amputation_Sound")
|
||||
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
|
||||
|
||||
|
||||
end
|
||||
@@ -33,10 +32,11 @@ end
|
||||
|
||||
|
||||
function ISCutLimb:start()
|
||||
-- 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.
|
||||
|
||||
self:setActionAnim("SawLog")
|
||||
local saw_item = TocGetSawInInventory(self.surgeon)
|
||||
self.sound = self.character:getEmitter():playSound("Amputation_Sound")
|
||||
self.surgeon:getEmitter():playSound("Amputation_Sound")
|
||||
|
||||
-- Return whatever object we've got in the inventory
|
||||
if self.surgeon:getPrimaryHandItem() then
|
||||
@@ -119,7 +119,7 @@ function ISCutLimb:perform()
|
||||
TocCutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
end
|
||||
|
||||
self.character:getEmitter():stopSoundByName("Amputation_Sound")
|
||||
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
ISBaseTimedAction.perform(self)
|
||||
|
||||
@@ -131,7 +131,7 @@ function ISCutLimb:new(patient, surgeon, part_name)
|
||||
|
||||
|
||||
local o = {}
|
||||
setmetatable(o, self) -- TODO what's this crap?
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
o.part_name = part_name
|
||||
o.character = surgeon -- For anim
|
||||
|
||||
@@ -23,7 +23,7 @@ end
|
||||
function ISOperateLimb:start()
|
||||
self:setActionAnim("MedicalCheck")
|
||||
if self.use_oven then
|
||||
self.sound = self.patient:getEmitter():playSound("Burn_sound") -- TODO currently broken, but maybe that's good
|
||||
self.sound = self.patient:getEmitter():playSound("Burn_sound")
|
||||
self:forceComplete()
|
||||
end
|
||||
end
|
||||
@@ -63,7 +63,6 @@ function ISOperateLimb:perform()
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
|
||||
-- FIXME Add a check for kit to prevent errors
|
||||
if self.kit and not use_oven then
|
||||
self.surgeon:getInventory():Remove(self.kit)
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ function ISUninstallProsthesis:perform()
|
||||
|
||||
SendUnequipProsthesis(self.patient, self.part_name, self.item)
|
||||
else
|
||||
TheOnlyCure.UnequipProsthesis(self.patient, self.part_name, self.item)
|
||||
TheOnlyCure.TocUnequipProsthesis(self.patient, self.part_name, self.item)
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
|
||||
@@ -4,7 +4,7 @@ local function addBodyLocationBefore(new_location, move_to_location)
|
||||
group:getOrCreateLocation(new_location)
|
||||
local new_item = list:get(list:size()-1)
|
||||
print("TOC: Created new body location" .. new_item:getId())
|
||||
list:remove(new_item)
|
||||
list:remove(new_item) -- We can't use the Index, it works if we pass the item though!
|
||||
local i = group:indexOf(move_to_location)
|
||||
list:add(i, new_item)
|
||||
end
|
||||
@@ -20,4 +20,4 @@ addBodyLocationBefore("TOC_ArmRightProsthesis", "Shoes")
|
||||
addBodyLocationBefore("TOC_ArmLeftProsthesis", "Shoes")
|
||||
|
||||
addBodyLocationBefore("TOC_LegRightProsthesis", "Shoes")
|
||||
addBodyLocationBefore("TOC_LegLeftProsthesis", "Shoes")
|
||||
addBodyLocationBefore("TOC_LegLeftProsthesis", "Shoes")
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
ContextMenu_EN = {
|
||||
|
||||
ContextMenu_Cut_Arm = "Cut arm",
|
||||
ContextMenu_Operate_Arm = "Operate arm",
|
||||
|
||||
ContextMenu_TourniquetRightSwitch = "Tourniquet on Right Arm",
|
||||
ContextMenu_TourniquetLeftSwitch = "Tourniquet on Left Arm",
|
||||
}
|
||||
|
||||
@@ -6,4 +6,9 @@ Sandbox_EN = {
|
||||
|
||||
Sandbox_TOC_CicatrizationSpeedMultiplier = "Cicatrization speed multiplier",
|
||||
Sandbox_TOC_CicatrizationSpeedMultiplier_tooltip = "Customize this to make the cicatrization process faster",
|
||||
|
||||
Sandbox_TOC_AmputationTimeMultiplier = "Amputation Time Scaler",
|
||||
Sandbox_TOC_AmputationTimeMultiplier_tooltip = "Scales the amount of time multplying added after amputation"
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user