reformatted everything

This commit is contained in:
Pao
2023-01-22 04:09:03 +01:00
parent b6b010705a
commit 713c250af9
21 changed files with 325 additions and 348 deletions

View File

@@ -9,14 +9,13 @@ end
function CheckIfCanBeCut(part_name) function CheckIfCanBeCut(part_name)
local toc_data = getPlayer():getModData().TOC local toc_data = getPlayer():getModData().TOC
local check = (not toc_data.Limbs[part_name].is_cut) and (not CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name)) local check = (not toc_data.Limbs[part_name].is_cut) and
(not CheckIfProsthesisAlreadyInstalled(toc_data.Limbs, part_name))
return check return check
end end
function CheckIfCanBeOperated(part_name) function CheckIfCanBeOperated(part_name)
local part_data = getPlayer():getModData().TOC.Limbs local part_data = getPlayer():getModData().TOC.Limbs
@@ -51,6 +50,3 @@ function CheckIfProsthesisAlreadyInstalled(part_data, part_name)
end end

View File

@@ -9,7 +9,8 @@ Commands["ResponseCanAct"] = function(arg)
ui.responsePartName = arg["toSend"][1] ui.responsePartName = arg["toSend"][1]
ui.responseCan = arg["toSend"][3] ui.responseCan = arg["toSend"][3]
ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername() ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername()
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(ui.responsePartName)):bitten() ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(ui
.responsePartName)):bitten()
end end
@@ -61,7 +62,6 @@ function AskCanEquipProsthesis(player, part_name)
sendClientCommand("TOC", "SendServer", arg) sendClientCommand("TOC", "SendServer", arg)
end end
-- Patient (receive) -- Patient (receive)
Commands["CutLimb"] = function(arg) Commands["CutLimb"] = function(arg)
local arg = arg["toSend"] local arg = arg["toSend"]
@@ -162,7 +162,4 @@ local function OnTocServerCommand(module, command, args)
end end
end end
Events.OnServerCommand.Add(OnTocServerCommand) Events.OnServerCommand.Add(OnTocServerCommand)

View File

@@ -1,6 +1,8 @@
function GetBodyParts() function GetBodyParts()
local bodyparts = { "Right_Hand", "Right_LowerArm", "Right_UpperArm", local bodyparts = {
"Left_Hand", "Left_LowerArm", "Left_UpperArm"} "Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand",
"Left_LowerArm", "Left_UpperArm"
}
return bodyparts return bodyparts
end end
@@ -13,60 +15,75 @@ function TocFindAmputatedClothingFromPartName(part_name)
return "TOC.Amputation_" .. part_name return "TOC.Amputation_" .. part_name
end end
function GetLimbsBodyPartTypes() function GetLimbsBodyPartTypes()
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R, return {
BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L} BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R,
BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L
}
end end
function GetOtherBodyPartTypes() function GetOtherBodyPartTypes()
return {BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head, BodyPartType.Neck, return {
BodyPartType.Groin, BodyPartType.UpperLeg_L, BodyPartType.UpperLeg_R, BodyPartType.LowerLeg_L, BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head,
BodyPartType.LowerLeg_R, BodyPartType.Foot_L, BodyPartType.Foot_R, BodyPartType.Back} BodyPartType.Neck, BodyPartType.Groin, BodyPartType.UpperLeg_L,
BodyPartType.UpperLeg_R, BodyPartType.LowerLeg_L,
BodyPartType.LowerLeg_R, BodyPartType.Foot_L, BodyPartType.Foot_R,
BodyPartType.Back
}
end end
function GetAcceptingProsthesisBodyPartTypes() function GetAcceptingProsthesisBodyPartTypes()
return {
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.Hand_L,
BodyPartType.Hand_L, BodyPartType.ForeArm_L} BodyPartType.ForeArm_L
}
end end
-- TODO This is just convoluted. Do not use this -- TODO This is just convoluted. Do not use this
function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType) function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType)
if bodyPartType == BodyPartType.Hand_R then return toc_limbs_data.Right_Hand if bodyPartType == BodyPartType.Hand_R then
elseif bodyPartType == BodyPartType.ForeArm_R then return toc_limbs_data.Right_LowerArm return toc_limbs_data.Right_Hand
elseif bodyPartType == BodyPartType.UpperArm_R then return toc_limbs_data.Right_UpperArm elseif bodyPartType == BodyPartType.ForeArm_R then
elseif bodyPartType == BodyPartType.Hand_L then return toc_limbs_data.Left_Hand return toc_limbs_data.Right_LowerArm
elseif bodyPartType == BodyPartType.ForeArm_L then return toc_limbs_data.Left_LowerArm elseif bodyPartType == BodyPartType.UpperArm_R then
elseif bodyPartType == BodyPartType.UpperArm_L then return toc_limbs_data.Left_UpperArm return toc_limbs_data.Right_UpperArm
else return nil elseif bodyPartType == BodyPartType.Hand_L then
return toc_limbs_data.Left_Hand
elseif bodyPartType == BodyPartType.ForeArm_L then
return toc_limbs_data.Left_LowerArm
elseif bodyPartType == BodyPartType.UpperArm_L then
return toc_limbs_data.Left_UpperArm
else
return nil
end end
end end
function TocGetPartNameFromBodyPartType(body_part) function TocGetPartNameFromBodyPartType(body_part)
if body_part == BodyPartType.Hand_R then return "Right_Hand" if body_part == BodyPartType.Hand_R then
elseif body_part == BodyPartType.ForeArm_R then return "Right_LowerArm" return "Right_Hand"
elseif body_part == BodyPartType.UpperArm_R then return "Right_UpperArm" elseif body_part == BodyPartType.ForeArm_R then
elseif body_part == BodyPartType.Hand_L then return "Left_Hand" return "Right_LowerArm"
elseif body_part == BodyPartType.ForeArm_L then return "Left_LowerArm" elseif body_part == BodyPartType.UpperArm_R then
elseif body_part == BodyPartType.UpperArm_L then return "Left_UpperArm" return "Right_UpperArm"
else return nil elseif body_part == BodyPartType.Hand_L then
return "Left_Hand"
elseif body_part == BodyPartType.ForeArm_L then
return "Left_LowerArm"
elseif body_part == BodyPartType.UpperArm_L then
return "Left_UpperArm"
else
return nil
end end
end end
function TocGetBodyPartTypeFromPartName(part_name) function TocGetBodyPartTypeFromPartName(part_name)
if part_name == "Right_Hand" then return BodyPartType.Hand_R end if part_name == "Right_Hand" then return BodyPartType.Hand_R end
if part_name == "Right_LowerArm" then return BodyPartType.ForeArm_R end if part_name == "Right_LowerArm" then return BodyPartType.ForeArm_R end
@@ -76,7 +93,6 @@ function TocGetBodyPartTypeFromPartName(part_name)
if part_name == "Left_UpperArm" then return BodyPartType.UpperArm_L end if part_name == "Left_UpperArm" then return BodyPartType.UpperArm_L end
end end
function TocFindCorrectClothingProsthesis(item_name, part_name) function TocFindCorrectClothingProsthesis(item_name, part_name)
local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name
@@ -94,12 +110,9 @@ local function PartNameToBodyLocation(name)
if name == "Left_UpperArm" then return "ArmLeft_Prot" end if name == "Left_UpperArm" then return "ArmLeft_Prot" end
end end
function TocFindItemInProstBodyLocation(part_name, patient) function TocFindItemInProstBodyLocation(part_name, patient)
-- FIXME this can return even amputated limbs, and we're using it only for prosthetics. This is gonna break sooner or later -- FIXME this can return even amputated limbs, and we're using it only for prosthetics. This is gonna break sooner or later
local worn_items = patient:getWornItems() local worn_items = patient:getWornItems()
for i = 1, worn_items:size() - 1 do -- Maybe wornItems:size()-1 for i = 1, worn_items:size() - 1 do -- Maybe wornItems:size()-1

View File

@@ -10,8 +10,6 @@ function TocCheckCompatibilityWithOlderVersions(mod_data)
end end
function TocMapOldDataToNew(mod_data) function TocMapOldDataToNew(mod_data)
local map_names = { local map_names = {
@@ -25,7 +23,8 @@ function TocMapOldDataToNew(mod_data)
} }
local old_names_table = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm" } local old_names_table = { "RightHand", "RightForearm", "RightArm", "LeftHand", "LeftForearm", "LeftArm" }
local new_names_table = {"Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand", "Left_LowerArm", "Left_UpperArm"} local new_names_table = { "Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand", "Left_LowerArm",
"Left_UpperArm" }
print("TOC: Trying to backup old data") print("TOC: Trying to backup old data")
local backup_old_data = mod_data.TOC local backup_old_data = mod_data.TOC

View File

@@ -1,12 +1,7 @@
function TryToToResetEverythingOtherPlayer(_, patient, surgeon) function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() }) sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() })
end end
---------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------
TocContextMenus = {} TocContextMenus = {}
@@ -40,10 +35,12 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
local cut_menu = TocContextMenus.CreateNewMenu("Cut", context, root_menu) local cut_menu = TocContextMenus.CreateNewMenu("Cut", context, root_menu)
local operate_menu = TocContextMenus.CreateNewMenu("Operate", context, root_menu) local operate_menu = TocContextMenus.CreateNewMenu("Operate", context, root_menu)
local cheat_menu = TocContextMenus.CreateCheatMenu(context, root_menu, local_player, clicked_player) local cheat_menu = TocContextMenus.CreateCheatMenu(context, root_menu, local_player,
clicked_player)
context:addSubMenu(root_option, root_menu) context:addSubMenu(root_option, root_menu)
TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects, cut_menu, operate_menu) TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects,
cut_menu, operate_menu)
--TocContextMenus.FillCheatMenu(context, cheat_menu) --TocContextMenus.FillCheatMenu(context, cheat_menu)
break break
@@ -74,13 +71,15 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
--local props = v:getSprite() and v:getSprite():getProperties() or nil --local props = v:getSprite() and v:getSprite():getProperties() or nil
for _, v_stove in pairs(worldObjects) do 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 if instanceof(v_stove, "IsoStove") and
(player_obj:HasTrait("Brave") or player_obj:getPerkLevel(Perks.Strength) >= 6) then
-- Check temperature -- Check temperature
if v_stove:getCurrentTemperature() > 250 then if v_stove:getCurrentTemperature() > 250 then
for _, v_bodypart in ipairs(GetBodyParts()) do for _, v_bodypart in ipairs(GetBodyParts()) do
if part_data[v_bodypart].is_cut and part_data[v_bodypart].is_amputation_shown and not part_data[v_bodypart].is_operated then if part_data[v_bodypart].is_cut and part_data[v_bodypart].is_amputation_shown and
not part_data[v_bodypart].is_operated then
local subMenu = context:getNew(context); local subMenu = context:getNew(context);
if is_main_menu_already_created == false then if is_main_menu_already_created == false then
@@ -88,7 +87,8 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
context:addSubMenu(rootMenu, subMenu) context:addSubMenu(rootMenu, subMenu)
is_main_menu_already_created = true is_main_menu_already_created = true
end end
subMenu:addOption(getText('UI_ContextMenu_' .. v_bodypart), worldObjects, TocOperateLocal, getSpecificPlayer(player), getSpecificPlayer(player), v_bodypart, true) subMenu:addOption(getText('UI_ContextMenu_' .. v_bodypart), worldObjects, TocOperateLocal,
getSpecificPlayer(player), getSpecificPlayer(player), v_bodypart, true)
end end
end end
end end
@@ -135,13 +135,16 @@ TocContextMenus.FillCutAndOperateMenus = function(local_player, clicked_player,
cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Cut", local_player, local_player) cut_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Cut", local_player, local_player)
elseif CheckIfCanBeOperated(v) then elseif CheckIfCanBeOperated(v) then
operate_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Operate", local_player, local_player) operate_menu:addOption(getText('UI_ContextMenu_' .. v), _, TryTocAction, v, "Operate", local_player,
local_player)
end end
else -- Another player else -- Another player
-- TODO add way to prevent cutting already cut parts of another player -- TODO add way to prevent cutting already cut parts of another player
cut_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Cut", local_player, clicked_player) cut_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Cut", local_player,
operate_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Operate", local_player, clicked_player) clicked_player)
operate_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Operate",
local_player, clicked_player)
end end
@@ -161,7 +164,8 @@ TocContextMenus.CreateCheatMenu = function(context, root_menu, local_player, cli
cheat_menu:addOption("Reset TOC for me", _, TocResetEverything) cheat_menu:addOption("Reset TOC for me", _, TocResetEverything)
else else
cheat_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer, clicked_player, local_player) cheat_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer,
clicked_player, local_player)
end end

View File

@@ -1,4 +0,0 @@

View File

@@ -1,7 +1,3 @@
-- CutLimb -- CutLimb
-- TODO if TheONlyCure. triggers an errors -- TODO if TheONlyCure. triggers an errors
function TocCheckIfStillInfected(part_data) function TocCheckIfStillInfected(part_data)
@@ -25,8 +21,6 @@ function TocCheckIfStillInfected(part_data)
return check return check
end end
function TocCureInfection(body_damage, part_data, part_name) function TocCureInfection(body_damage, part_data, part_name)
local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromPartName(part_name)) local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
@@ -64,7 +58,6 @@ function TocCureInfection(body_damage, part_data, part_name)
end end
function TocDeleteOtherAmputatedLimbs(side) function TocDeleteOtherAmputatedLimbs(side)
-- if left hand is cut and we cut left lowerarm, then delete hand -- if left hand is cut and we cut left lowerarm, then delete hand
@@ -83,16 +76,17 @@ end
function TocGetKitInInventory(surgeon) function TocGetKitInInventory(surgeon)
local playerInv = surgeon:getInventory(); local playerInv = surgeon:getInventory();
local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or playerInv:getItemFromType('TOC.Improvised_surgeon_kit') local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or
playerInv:getItemFromType('TOC.Improvised_surgeon_kit')
return item return item
end end
function TocGetSawInInventory(surgeon) function TocGetSawInInventory(surgeon)
local player_inv = surgeon:getInventory() local player_inv = surgeon:getInventory()
local item = player_inv:getItemFromType("Saw") or player_inv:getItemFromType("GardenSaw") or player_inv:getItemFromType("Chainsaw") local item = player_inv:getItemFromType("Saw") or player_inv:getItemFromType("GardenSaw") or
player_inv:getItemFromType("Chainsaw")
return item return item
end end
@@ -127,7 +121,6 @@ function FixSingleBodyPartType(body_part_type, use_oven)
end end
end end
------------------------------------- -------------------------------------
-- Override helper -- Override helper

View File

@@ -29,7 +29,8 @@ function TocEquipProsthesisLocal(_, patient, surgeon, part_name)
surgeon_inventory:getItemFromType('TOC.MetalHook') or surgeon_inventory:getItemFromType('TOC.MetalHook') or
surgeon_inventory:getItemFromType('TOC.WoodenHook') surgeon_inventory:getItemFromType('TOC.WoodenHook')
if prosthesis_to_equip then if prosthesis_to_equip then
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip,
patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
else else
surgeon:Say("I need a prosthesis") surgeon:Say("I need a prosthesis")
end end
@@ -37,5 +38,6 @@ end
function TocUnequipProsthesisLocal(_, patient, part_name) function TocUnequipProsthesisLocal(_, patient, part_name)
local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient) local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient)
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis,
patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end end

View File

@@ -51,7 +51,8 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
-- Perk scaling -- Perk scaling
if part_name == "Right_Hand" or part_name == "Left_Hand" then if part_name == "Right_Hand" or part_name == "Left_Hand" then
modified_max_time = modified_max_time * (1 + (9 - self.character:getPerkLevel(Perks[part_name])) / 20 ) modified_max_time = modified_max_time *
(1 + (9 - self.character:getPerkLevel(Perks[part_name])) / 20)
end end
end end
@@ -70,9 +71,6 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
end end
------------------------------------------------- -------------------------------------------------
-- Block access to drag, picking, inspecting, etc to amputated limbs -- Block access to drag, picking, inspecting, etc to amputated limbs
local og_ISInventoryPaneOnMouseDoubleClick = ISInventoryPane.onMouseDoubleClick local og_ISInventoryPaneOnMouseDoubleClick = ISInventoryPane.onMouseDoubleClick
@@ -93,7 +91,6 @@ function ISInventoryPane:onMouseDoubleClick(x, y)
end end
local og_ISInventoryPaneGetActualItems = ISInventoryPane.getActualItems local og_ISInventoryPaneGetActualItems = ISInventoryPane.getActualItems
function ISInventoryPane.getActualItems(items) function ISInventoryPane.getActualItems(items)
@@ -112,7 +109,6 @@ function ISInventoryPane.getActualItems(items)
return ret return ret
end end
local og_ISInventoryPaneContextMenuOnInspectClothing = ISInventoryPaneContextMenu.onInspectClothing local og_ISInventoryPaneContextMenuOnInspectClothing = ISInventoryPaneContextMenu.onInspectClothing
ISInventoryPaneContextMenu.onInspectClothing = function(playerObj, clothing) ISInventoryPaneContextMenu.onInspectClothing = function(playerObj, clothing)
@@ -171,7 +167,6 @@ function ISEquipWeaponAction:perform()
end end
local og_ISInventoryPaneContextMenuUnequipItem = ISInventoryPaneContextMenu.unequipItem local og_ISInventoryPaneContextMenuUnequipItem = ISInventoryPaneContextMenu.unequipItem
function ISInventoryPaneContextMenu.unequipItem(item, player) function ISInventoryPaneContextMenu.unequipItem(item, player)
@@ -191,4 +186,3 @@ function ISInventoryPaneContextMenu.dropItem(item, player)
end end
end end

View File

@@ -18,21 +18,17 @@ local function PrerenderFuncMP()
end end
-- Prerender basically hooks onto SendCommandToConfirmUI, dunno how but it does -- Prerender basically hooks onto SendCommandToConfirmUI, dunno how but it does
SendCommandToConfirmUIMP(confirm_ui_mp.responseAction, confirm_ui_mp.responseIsBitten, confirm_ui_mp.responseUserName, confirm_ui_mp.responsePartName); SendCommandToConfirmUIMP(confirm_ui_mp.responseAction, confirm_ui_mp.responseIsBitten,
confirm_ui_mp.responseUserName, confirm_ui_mp.responsePartName);
end end
end end
----------------------- -----------------------
-- Getters -- Getters
function GetConfirmUIMP() function GetConfirmUIMP()
return confirm_ui_mp; return confirm_ui_mp;
end end
------------------------------ ------------------------------
-- UI Visible stuff functions -- UI Visible stuff functions
local function GetImageName(part_name, toc_data) local function GetImageName(part_name, toc_data)
@@ -45,15 +41,18 @@ local function GetImageName(part_name, toc_data)
else else
name = "media/ui/TOC/" .. part_name .. "/Prothesis.png" name = "media/ui/TOC/" .. part_name .. "/Prothesis.png"
end end
elseif part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and part_data.is_amputation_shown then -- Cut and heal elseif part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and
part_data.is_amputation_shown then -- Cut and heal
name = "media/ui/TOC/" .. part_name .. "/Cut.png" name = "media/ui/TOC/" .. part_name .. "/Cut.png"
elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and not part_data.is_operated then -- Cut not heal elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and
not part_data.is_operated then -- Cut not heal
name = "media/ui/TOC/" .. part_name .. "/Bleed.png" name = "media/ui/TOC/" .. part_name .. "/Bleed.png"
elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and part_data.is_operated then -- Cut not heal elseif part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown and part_data.is_operated then -- Cut not heal
name = "media/ui/TOC/" .. part_name .. "/Operate.png" name = "media/ui/TOC/" .. part_name .. "/Operate.png"
elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut) 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" name = "media/ui/TOC/Empty.png"
elseif not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten() then -- Not cut but bitten elseif not part_data.is_cut and
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten() then -- Not cut but bitten
name = "media/ui/TOC/" .. part_name .. "/Bite.png" name = "media/ui/TOC/" .. part_name .. "/Bite.png"
else -- Not cut else -- Not cut
name = "media/ui/TOC/" .. part_name .. "/Base.png" name = "media/ui/TOC/" .. part_name .. "/Base.png"
@@ -68,10 +67,6 @@ local function GetImageName(part_name, toc_data)
return name return name
end end
------------------------------------------ ------------------------------------------
-- Check functions -- Check functions
@@ -81,7 +76,8 @@ end
local function CanProsthesisBeEquipped(part_data) local function CanProsthesisBeEquipped(part_data)
return part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and part_data.is_amputation_shown return part_data.is_cut and part_data.is_cicatrized and not part_data.is_prosthesis_equipped and
part_data.is_amputation_shown
end end
@@ -94,14 +90,11 @@ local function IsAmputatedLimbToBeVisible(part_data)
return part_data.is_cut and not part_data.is_amputation_shown return part_data.is_cut and not part_data.is_amputation_shown
end end
local function IsPartBitten(part_data, part_name) local function IsPartBitten(part_data, part_name)
return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten() return not part_data.is_cut and
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten()
end end
local function FindMinMax(lv) local function FindMinMax(lv)
local min, max local min, max
if lv == 1 then if lv == 1 then
@@ -138,11 +131,6 @@ local function FindMinMax(lv)
return min, max; return min, max;
end end
------------------------------------------------ ------------------------------------------------
-- On Click Functions -- On Click Functions
local function OnClickTocMainUI(button, args) local function OnClickTocMainUI(button, args)
@@ -181,16 +169,17 @@ local function OnClickTocDescUI(button, args)
end end
function OnClickTocConfirmUIMP(button, args) function OnClickTocConfirmUIMP(button, args)
local player = getPlayer() local player = getPlayer()
if confirm_ui_mp.actionAct == "Cut" and args.option == "yes" then if confirm_ui_mp.actionAct == "Cut" and args.option == "yes" then
ISTimedActionQueue.add(ISCutLimb:new(confirm_ui_mp.patient, player, confirm_ui_mp.partNameAct)) ISTimedActionQueue.add(ISCutLimb:new(confirm_ui_mp.patient, player, confirm_ui_mp.partNameAct))
elseif confirm_ui_mp.actionAct == "Operate" and args.option == "yes" then elseif confirm_ui_mp.actionAct == "Operate" and args.option == "yes" then
local playerInv = player:getInventory(); 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') local item = playerInv:getItemFromType('TOC.Real_surgeon_kit') or playerInv:getItemFromType('TOC.Surgeon_kit') or
playerInv:getItemFromType('TOC.Improvised_surgeon_kit')
if item then if item then
ISTimedActionQueue.add(ISOperateLimb:new(confirm_ui_mp.patient, player, item, confirm_ui_mp.partNameAct, false)) ISTimedActionQueue.add(ISOperateLimb:new(confirm_ui_mp.patient, player, item, confirm_ui_mp.partNameAct,
false))
else else
player:Say("I need a kit") player:Say("I need a kit")
end end
@@ -210,8 +199,6 @@ function OnClickTocConfirmUIMP(button, args)
end end
----------------------------------------------- -----------------------------------------------
-- CREATE UI SECTION -- CREATE UI SECTION
@@ -288,7 +275,6 @@ function CreateTocDescUI()
desc_ui:saveLayout() desc_ui:saveLayout()
end end
function CreateTocConfirmUIMP() function CreateTocConfirmUIMP()
confirm_ui_mp = NewUI() confirm_ui_mp = NewUI()
confirm_ui_mp.responseReceive = false confirm_ui_mp.responseReceive = false
@@ -336,7 +322,6 @@ function OnCreateTheOnlyCureUI()
main_ui:close() main_ui:close()
end end
----------------------------------------- -----------------------------------------
-- Setup stuff with variables and shit -- Setup stuff with variables and shit
@@ -493,7 +478,8 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
confirm_ui_mp:open() confirm_ui_mp:open()
if action == "Cut" or action == "Operate" then if action == "Cut" or action == "Operate" then
confirm_ui_mp["text4"]:setText("You're gonna " .. action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName) confirm_ui_mp["text4"]:setText("You're gonna " ..
action .. " the " .. getText("UI_ContextMenu_" .. partName) .. " of " .. userName)
confirm_ui_mp["text2"]:setText("Are you sure?") confirm_ui_mp["text2"]:setText("Are you sure?")
confirm_ui_mp["text2"]:setColor(1, 0, 0, 0) confirm_ui_mp["text2"]:setColor(1, 0, 0, 0)
confirm_ui_mp["b1"]:setVisible(true); confirm_ui_mp["b1"]:setVisible(true);
@@ -509,6 +495,7 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
end end
-------------------------------------------- --------------------------------------------
-- Add TOC element to Health Panel -- Add TOC element to Health Panel
local ISHealthPanel_createChildren = ISHealthPanel.createChildren local ISHealthPanel_createChildren = ISHealthPanel.createChildren
@@ -542,14 +529,14 @@ function ISNewHealthPanel.onClick_TOC(button)
end end
function ISHealthPanel:createChildren() function ISHealthPanel:createChildren()
ISHealthPanel_createChildren(self) ISHealthPanel_createChildren(self)
self.fitness:setWidth(self.fitness:getWidth() / 1.5) self.fitness:setWidth(self.fitness:getWidth() / 1.5)
--TODO make it bigger --TODO make it bigger
self.TOCButton = ISButton:new(self.fitness:getRight(), self.healthPanel.y, 20, 20, "", self, ISNewHealthPanel.onClick_TOC) 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:setImage(getTexture("media/ui/TOC/iconForMenu.png"))
self.TOCButton.anchorTop = false self.TOCButton.anchorTop = false
self.TOCButton.anchorBottom = true self.TOCButton.anchorBottom = true
@@ -566,8 +553,5 @@ function ISHealthPanel:render()
self.TOCButton:setY(self.fitness:getY()); self.TOCButton:setY(self.fitness:getY());
end end
-- EVENTS -- EVENTS
Events.OnCreateUI.Add(OnCreateTheOnlyCureUI) Events.OnCreateUI.Add(OnCreateTheOnlyCureUI)

View File

@@ -7,7 +7,8 @@ function TheOnlyCure.CheckIfCanPickUpItem(toc_data, side, limb, secondary_limb)
local full_secondary_limb = side .. secondary_limb local full_secondary_limb = side .. secondary_limb
return toc_data[full_primary_limb].is_cut and not (toc_data[full_primary_limb].is_prosthesis_equipped or toc_data[full_secondary_limb]) or return toc_data[full_primary_limb].is_cut and
not (toc_data[full_primary_limb].is_prosthesis_equipped or toc_data[full_secondary_limb]) or
(toc_data[full_secondary_limb].is_cut and not toc_data[full_secondary_limb].is_prosthesis_equipped) (toc_data[full_secondary_limb].is_cut and not toc_data[full_secondary_limb].is_prosthesis_equipped)
@@ -141,7 +142,6 @@ function TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name)
return false return false
end end
-- MAIN UPDATE FUNCTIONS -- MAIN UPDATE FUNCTIONS
function TheOnlyCure.UpdateEveryOneMinute() function TheOnlyCure.UpdateEveryOneMinute()
@@ -191,6 +191,5 @@ function TheOnlyCure.UpdateEveryTenMinutes()
player:transmitModData() player:transmitModData()
end end
Events.EveryTenMinutes.Add(TheOnlyCure.UpdateEveryTenMinutes) Events.EveryTenMinutes.Add(TheOnlyCure.UpdateEveryTenMinutes)
Events.EveryOneMinute.Add(TheOnlyCure.UpdateEveryOneMinute) Events.EveryOneMinute.Add(TheOnlyCure.UpdateEveryOneMinute)

View File

@@ -200,16 +200,20 @@ function TocUpdateBaseData(mod_data)
end end
function TheOnlyCure.DeclareTraits() function TheOnlyCure.DeclareTraits()
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8, getText("UI_trait_Amputee_Hand_desc"), false, false) 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) amp1:addXPBoost(Perks.Left_Hand, 4)
local amp2 = TraitFactory.addTrait("Amputee_LowerArm", getText("UI_trait_Amputee_LowerArm"), -10, getText("UI_trait_Amputee_LowerArm_desc"), false, false) local amp2 = TraitFactory.addTrait("Amputee_LowerArm", getText("UI_trait_Amputee_LowerArm"), -10,
getText("UI_trait_Amputee_LowerArm_desc"), false, false)
amp2:addXPBoost(Perks.Left_Hand, 4) amp2:addXPBoost(Perks.Left_Hand, 4)
local amp3 = TraitFactory.addTrait("Amputee_UpperArm", getText("UI_trait_Amputee_UpperArm"), -20, getText("UI_trait_Amputee_UpperArm_desc"), false, false) local amp3 = TraitFactory.addTrait("Amputee_UpperArm", getText("UI_trait_Amputee_UpperArm"), -20,
getText("UI_trait_Amputee_UpperArm_desc"), false, false)
amp3:addXPBoost(Perks.Left_Hand, 4) amp3:addXPBoost(Perks.Left_Hand, 4)
TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitivedesc"), false, false) TraitFactory.addTrait("Insensitive", getText("UI_trait_Insensitive"), 6, getText("UI_trait_Insensitivedesc"), false,
false)
TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_LowerArm") TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_LowerArm")
TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_UpperArm") TraitFactory.setMutualExclusive("Amputee_Hand", "Amputee_UpperArm")
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm") TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
@@ -380,7 +384,8 @@ function TryTocAction(_, part_name, action, surgeon, patient)
surgeon_inventory:getItemFromType('TOC.MetalHook') or surgeon_inventory:getItemFromType('TOC.MetalHook') or
surgeon_inventory:getItemFromType('TOC.WoodenHook') surgeon_inventory:getItemFromType('TOC.WoodenHook')
if prosthesis_to_equip then if prosthesis_to_equip then
ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) ISTimedActionQueue.add(ISInstallProsthesis:new(patient, prosthesis_to_equip,
patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
else else
surgeon:Say("I need a prosthesis") surgeon:Say("I need a prosthesis")
end end
@@ -392,7 +397,8 @@ function TryTocAction(_, part_name, action, surgeon, patient)
elseif action == "Unequip" then elseif action == "Unequip" then
--AskCanUnequipProsthesis(patient, part_name) --AskCanUnequipProsthesis(patient, part_name)
local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient) local equipped_prosthesis = TocFindItemInProstBodyLocation(part_name, patient)
ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis, patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)))) ISTimedActionQueue.add(ISUninstallProsthesis:new(patient, equipped_prosthesis,
patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end end
ui.actionAct = action ui.actionAct = action
ui.partNameAct = part_name ui.partNameAct = part_name
@@ -405,6 +411,5 @@ function TryTocAction(_, part_name, action, surgeon, patient)
end end
end end
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure) Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits) Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits)

View File

@@ -57,7 +57,6 @@ function ISCutLimb:start()
end end
function ISCutLimb:findArgs() function ISCutLimb:findArgs()
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor) 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() == "surgeon" then surgeon_factor = surgeon_factor + 15 end
@@ -67,7 +66,8 @@ function ISCutLimb:findArgs()
local bandage_table = { local bandage_table = {
use_bandage = false, use_bandage = false,
bandage_type = nil, bandage_type = nil,
is_bandage_sterilized = nil} is_bandage_sterilized = nil
}
local painkiller_table = {} local painkiller_table = {}
@@ -102,7 +102,6 @@ function ISCutLimb:findArgs()
return surgeon_factor, bandage_table, painkiller_table return surgeon_factor, bandage_table, painkiller_table
end end
function ISCutLimb:perform() function ISCutLimb:perform()
local surgeon_factor, bandage_table, painkiller_table = self:findArgs() local surgeon_factor, bandage_table, painkiller_table = self:findArgs()
@@ -125,7 +124,6 @@ function ISCutLimb:perform()
end end
function ISCutLimb:new(patient, surgeon, part_name) function ISCutLimb:new(patient, surgeon, part_name)
local o = {} local o = {}
setmetatable(o, self) setmetatable(o, self)

View File

@@ -104,5 +104,3 @@ function ISUninstallProsthesis:new(character, item, bodyPart)
if o.character:isTimedActionInstant() then o.maxTime = 1; end if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o; return o;
end end

View File

@@ -52,4 +52,3 @@ local function OnTocClientCommand(module, command, player, args)
end end
Events.OnClientCommand.Add(OnTocClientCommand) Events.OnClientCommand.Add(OnTocClientCommand)