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
@@ -42,15 +41,12 @@ function CheckIfProsthesisAlreadyInstalled(part_data, part_name)
if string.find(part_name, r) then if string.find(part_name, r) then
return (part_data[r .. "_Hand"].is_prosthesis_equipped or part_data[r .. "_LowerArm"].is_prosthesis_equipped) return (part_data[r .. "_Hand"].is_prosthesis_equipped or part_data[r .. "_LowerArm"].is_prosthesis_equipped)
elseif string.find(part_name, l) then elseif string.find(part_name, l) then
return (part_data[l .. "_Hand"].is_prosthesis_equipped or part_data[l .. "_LowerArm"].is_prosthesis_equipped) return (part_data[l .. "_Hand"].is_prosthesis_equipped or part_data[l .. "_LowerArm"].is_prosthesis_equipped)
end end
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
@@ -18,7 +19,7 @@ function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkille
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["To"] = player:getOnlineID() arg["To"] = player:getOnlineID()
arg["command"] = "CutLimb" arg["command"] = "CutLimb"
arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table} arg["toSend"] = { part_name, surgeon_factor, bandage_table, painkiller_table }
sendClientCommand("TOC", "SendServer", arg) sendClientCommand("TOC", "SendServer", arg)
end end
@@ -27,7 +28,7 @@ function SendOperateLimb(player, part_name, surgeon_factor, use_oven)
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["To"] = player:getOnlineID() arg["To"] = player:getOnlineID()
arg["command"] = "OperateLimb" arg["command"] = "OperateLimb"
arg["toSend"] = {part_name, surgeon_factor, use_oven} arg["toSend"] = { part_name, surgeon_factor, use_oven }
sendClientCommand("TOC", "SendServer", arg) sendClientCommand("TOC", "SendServer", arg)
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"]
@@ -75,11 +75,11 @@ end
Commands["CanCutLimb"] = function(arg) Commands["CanCutLimb"] = function(arg)
local part_name = arg["toSend"] local part_name = arg["toSend"]
arg["To"] = arg["From"] arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct" arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Cut", CheckIfCanBeCut(part_name)} arg["toSend"] = { part_name, "Cut", CheckIfCanBeCut(part_name) }
sendClientCommand("TOC", "SendServer", arg) sendClientCommand("TOC", "SendServer", arg)
end end
@@ -89,7 +89,7 @@ Commands["CanOperateLimb"] = function(arg)
arg["To"] = arg["From"] arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct" arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Operate", CheckIfCanBeOperated(part_name)} arg["toSend"] = { part_name, "Operate", CheckIfCanBeOperated(part_name) }
sendClientCommand("TOC", "SendServer", arg) sendClientCommand("TOC", "SendServer", arg)
end end
@@ -99,18 +99,18 @@ Commands["CanEquipProsthesis"] = function(arg)
arg["To"] = arg["From"] arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct" arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Equip", CheckIfProsthesisCanBeEquipped(part_name)} arg["toSend"] = { part_name, "Equip", CheckIfProsthesisCanBeEquipped(part_name) }
end end
Commands["CanResetEverything"] = function(arg) Commands["CanResetEverything"] = function(arg)
local part_name = "RightHand" --useless local part_name = "RightHand" --useless
arg["To"] = arg["From"] arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID() arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct" arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Cut", true} arg["toSend"] = { part_name, "Cut", true }
sendClientCommand("TOC", "SendServer", arg) sendClientCommand("TOC", "SendServer", arg)
--TocResetEverything() --TocResetEverything()
end end
@@ -120,10 +120,10 @@ Commands["ResetEverything"] = function(arg)
TocResetEverything() TocResetEverything()
end end
-- Cheating stuff -- Cheating stuff
Commands["AcceptResetEverything"] = function(arg) Commands["AcceptResetEverything"] = function(arg)
local clicked_player = getPlayerByOnlineID(arg[1]) -- TODO delete this local clicked_player = getPlayerByOnlineID(arg[1]) -- TODO delete this
TocResetEverything() TocResetEverything()
end end
@@ -131,9 +131,9 @@ end
-- Base stuff -- Base stuff
Commands["GivePlayerData"] = function(arg) Commands["GivePlayerData"] = function(arg)
local surgeon_id = arg[1] local surgeon_id = arg[1]
local patient = getPlayerByOnlineID(arg[2]) local patient = getPlayerByOnlineID(arg[2])
local toc_data = patient:getModData().TOC local toc_data = patient:getModData().TOC
sendClientCommand(patient, "TOC", "SendPlayerData", {surgeon_id, toc_data}) sendClientCommand(patient, "TOC", "SendPlayerData", { surgeon_id, toc_data })
end end
Commands["SendTocData"] = function(arg) Commands["SendTocData"] = function(arg)
@@ -162,7 +162,4 @@ local function OnTocServerCommand(module, command, args)
end end
end end
Events.OnServerCommand.Add(OnTocServerCommand)
Events.OnServerCommand.Add(OnTocServerCommand)

View File

@@ -11,4 +11,4 @@ end
--Make a link --Make a link
TOC_Options = {} TOC_Options = {}
TOC_Options = options TOC_Options = options

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,70 +15,84 @@ 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
if part_name == "Right_UpperArm" then return BodyPartType.UpperArm_R end if part_name == "Right_UpperArm" then return BodyPartType.UpperArm_R end
if part_name == "Left_Hand" then return BodyPartType.Hand_L end if part_name == "Left_Hand" then return BodyPartType.Hand_L end
if part_name == "Left_LowerArm" then return BodyPartType.ForeArm_L end if part_name == "Left_LowerArm" then return BodyPartType.ForeArm_L end
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
@@ -86,27 +102,24 @@ end
local function PartNameToBodyLocation(name) local function PartNameToBodyLocation(name)
-- This is still correct but naming sucks -- This is still correct but naming sucks
if name == "Right_Hand" then return "ArmRight_Prot" end if name == "Right_Hand" then return "ArmRight_Prot" end
if name == "Right_LowerArm" then return "ArmRight_Prot" end if name == "Right_LowerArm" then return "ArmRight_Prot" end
if name == "Right_UpperArm" then return "ArmRight_Prot" end if name == "Right_UpperArm" then return "ArmRight_Prot" end
if name == "Left_Hand" then return "ArmLeft_Prot" end if name == "Left_Hand" then return "ArmLeft_Prot" end
if name == "Left_LowerArm" then return "ArmLeft_Prot" end if name == "Left_LowerArm" then return "ArmLeft_Prot" end
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
local item = worn_items:get(i):getItem() local item = worn_items:get(i):getItem()
if item:getBodyLocation() == PartNameToBodyLocation(part_name) then if item:getBodyLocation() == PartNameToBodyLocation(part_name) then
return item return item
end end
end end
end end

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 = {
@@ -24,8 +22,9 @@ function TocMapOldDataToNew(mod_data)
Left_UpperArm = "LeftArm" Left_UpperArm = "LeftArm"
} }
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
@@ -42,7 +41,7 @@ function TocMapOldDataToNew(mod_data)
TocResetEverything() TocResetEverything()
-- For some reasons pairs does not work here... -- For some reasons pairs does not work here...
-- TODO ask why -- TODO ask why
@@ -74,11 +73,11 @@ function TocMapOldDataToNew(mod_data)
-- mod_data.TOC.Limbs[new_name].is_amputation_shown = backup_old_data[old_name].is_amputation_shown -- mod_data.TOC.Limbs[new_name].is_amputation_shown = backup_old_data[old_name].is_amputation_shown
-- mod_data.TOC.Limbs[new_name].cicatrization_time = backup_old_data[old_name].cicatrization_time -- mod_data.TOC.Limbs[new_name].cicatrization_time = backup_old_data[old_name].cicatrization_time
-- end -- end
for i=1, #new_names_table do for i = 1, #new_names_table do
print("TOC: Looping " .. i) print("TOC: Looping " .. i)
print(backup_old_data[old_names_table[i]].is_cut) print(backup_old_data[old_names_table[i]].is_cut)
@@ -99,11 +98,11 @@ function TocMapOldDataToNew(mod_data)
mod_data.TOC.Limbs[new_name].is_cauterized = backup_old_data[old_name].is_cauterized mod_data.TOC.Limbs[new_name].is_cauterized = backup_old_data[old_name].is_cauterized
mod_data.TOC.Limbs[new_name].is_amputation_shown = backup_old_data[old_name].is_amputation_shown mod_data.TOC.Limbs[new_name].is_amputation_shown = backup_old_data[old_name].is_amputation_shown
mod_data.TOC.Limbs[new_name].cicatrization_time = backup_old_data[old_name].cicatrization_time mod_data.TOC.Limbs[new_name].cicatrization_time = backup_old_data[old_name].cicatrization_time
end end
getPlayer():transmitModData() getPlayer():transmitModData()
end end

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 = {}
@@ -17,15 +12,15 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
local clicked_player = nil local clicked_player = nil
local local_player = getSpecificPlayer(player) local local_player = getSpecificPlayer(player)
--local players = getOnlinePlayers() --local players = getOnlinePlayers()
for k,v in ipairs(worldObjects) do for k, v in ipairs(worldObjects) do
-- help detecting a player by checking nearby squares -- help detecting a player by checking nearby squares
for x=v:getSquare():getX()-1,v:getSquare():getX()+1 do for x = v:getSquare():getX() - 1, v:getSquare():getX() + 1 do
for y=v:getSquare():getY()-1,v:getSquare():getY()+1 do for y = v:getSquare():getY() - 1, v:getSquare():getY() + 1 do
local sq = getCell():getGridSquare(x,y,v:getSquare():getZ()) local sq = getCell():getGridSquare(x, y, v:getSquare():getZ())
if sq then if sq then
for i=0,sq:getMovingObjects():size()-1 do for i = 0, sq:getMovingObjects():size() - 1 do
local o = sq:getMovingObjects():get(i) local o = sq:getMovingObjects():get(i)
if instanceof(o, "IsoPlayer") then if instanceof(o, "IsoPlayer") then
clicked_player = o clicked_player = o
@@ -34,16 +29,18 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
-- FIXME this is to prevent context menu spamming. Find a better way -- FIXME this is to prevent context menu spamming. Find a better way
clicked_players_table[clicked_player:getUsername()] = true clicked_players_table[clicked_player:getUsername()] = true
local root_option = context:addOption("The Only Cure on " .. clicked_player:getUsername()) local root_option = context:addOption("The Only Cure on " .. clicked_player:getUsername())
local root_menu = context:getNew(context) local root_menu = context:getNew(context)
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
@@ -65,7 +62,7 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
-- TODO Add a way to move the player towards the oven -- TODO Add a way to move the player towards the oven
local part_data = player_obj:getModData().TOC.Limbs local part_data = player_obj:getModData().TOC.Limbs
local is_main_menu_already_created = false local is_main_menu_already_created = false
@@ -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,12 +87,13 @@ 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
break -- stop searching for stoves break -- stop searching for stoves
end end
@@ -130,18 +130,21 @@ TocContextMenus.FillCutAndOperateMenus = function(local_player, clicked_player,
for _, v in ipairs(GetBodyParts()) do for _, v in ipairs(GetBodyParts()) do
if local_player == clicked_player then -- Local player if local_player == clicked_player then -- Local player
if CheckIfCanBeCut(v) then if CheckIfCanBeCut(v) then
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
@@ -179,5 +183,5 @@ TocContextMenus.FillCheatMenus = function(context, cheat_menu)
end end
Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateOperateWithOvenMenu) -- this is probably too much Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateOperateWithOvenMenu) -- this is probably too much
Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateMenus) Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateMenus)

View File

@@ -6,7 +6,7 @@ function TocResetEverything()
TheOnlyCure.InitTheOnlyCure(_, player) TheOnlyCure.InitTheOnlyCure(_, player)
-- 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(TocFindAmputatedClothingFromPartName(v)) local cloth = player:getInventory():FindAndReturn(TocFindAmputatedClothingFromPartName(v))
if cloth ~= nil then if cloth ~= nil then

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))
@@ -43,20 +37,20 @@ function TocCureInfection(body_damage, part_data, part_name)
local body_part_types = body_damage:getBodyParts() local body_part_types = body_damage:getBodyParts()
-- TODO I think this is enough... we should just cycle if with everything instead of that crap up there -- TODO I think this is enough... we should just cycle if with everything instead of that crap up there
for i=body_part_types:size()-1, 0, -1 do for i = body_part_types:size() - 1, 0, -1 do
local bodyPart = body_part_types:get(i); local bodyPart = body_part_types:get(i);
bodyPart:SetInfected(false); bodyPart:SetInfected(false);
end end
end end
if body_part_type:scratched() then body_part_type:setScratched(false, false) end if body_part_type:scratched() then body_part_type:setScratched(false, false) end
if body_part_type:haveGlass() then body_part_type:setHaveGlass(false) end if body_part_type:haveGlass() then body_part_type:setHaveGlass(false) end
if body_part_type:haveBullet() then body_part_type:setHaveBullet(false, 0) end if body_part_type:haveBullet() then body_part_type:setHaveBullet(false, 0) end
if body_part_type:isInfectedWound() then body_part_type:setInfectedWound(false) end if body_part_type:isInfectedWound() then body_part_type:setInfectedWound(false) end
if body_part_type:isBurnt() then body_part_type:setBurnTime(0) end if body_part_type:isBurnt() then body_part_type:setBurnTime(0) end
if body_part_type:isCut() then body_part_type:setCut(false, false) end --Lacerations if body_part_type:isCut() then body_part_type:setCut(false, false) end --Lacerations
if body_part_type:getFractureTime()>0 then body_part_type:setFractureTime(0) end if body_part_type:getFractureTime() > 0 then body_part_type:setFractureTime(0) end
@@ -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
@@ -76,23 +69,24 @@ function TocDeleteOtherAmputatedLimbs(side)
if amputated_limb then if amputated_limb then
getPlayer():getInventory():Remove(amputated_limb) getPlayer():getInventory():Remove(amputated_limb)
end end
end end
end 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
@@ -112,22 +106,21 @@ function SetBodyPartsStatusAfterOperation(player, part_data, part_name, use_oven
end end
function FixSingleBodyPartType(body_part_type, use_oven) function FixSingleBodyPartType(body_part_type, use_oven)
body_part_type:setDeepWounded(false) --Basically like stitching body_part_type:setDeepWounded(false) --Basically like stitching
body_part_type:setDeepWoundTime(0) body_part_type:setDeepWoundTime(0)
if use_oven then if use_oven then
body_part_type:AddDamage(100) body_part_type:AddDamage(100)
body_part_type:setAdditionalPain(100); body_part_type:setAdditionalPain(100);
body_part_type:setBleeding(false) body_part_type:setBleeding(false)
body_part_type:setBleedingTime(0) -- no bleeding since it's been cauterized body_part_type:setBleedingTime(0) -- no bleeding since it's been cauterized
else else
-- TODO Think a little better about this, do we want to trigger bleeding or not? -- TODO Think a little better about this, do we want to trigger bleeding or not?
body_part_type:setBleeding(false) body_part_type:setBleeding(false)
--body_part_type:setBleedingTime(ZombRand(1, 5)) -- Reset the bleeding, maybe make it random --body_part_type:setBleedingTime(ZombRand(1, 5)) -- Reset the bleeding, maybe make it random
end end
end end
------------------------------------- -------------------------------------
-- Override helper -- Override helper
@@ -146,7 +139,7 @@ function CheckIfItemIsAmputatedLimb(item)
end end
-- function CheckIfItemIsAmputatedLimb(item) -- function CheckIfItemIsAmputatedLimb(item)
-- local item_full_type = item:getFullType() -- local item_full_type = item:getFullType()
@@ -200,4 +193,4 @@ function CheckIfItemIsInstalledProsthesis(item)
return false return false
end end
end end

View File

@@ -22,14 +22,15 @@ function TocOperateLocal(_, patient, surgeon, part_name, use_oven)
end end
function TocEquipProsthesisLocal(_, patient, surgeon, part_name) function TocEquipProsthesisLocal(_, patient, surgeon, part_name)
-- TODO probably completely broken for MP -- TODO probably completely broken for MP
-- TODO this is really janky -- TODO this is really janky
local surgeon_inventory = surgeon:getInventory() local surgeon_inventory = surgeon:getInventory()
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
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,
end patient:getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name))))
end

View File

@@ -11,58 +11,59 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
-- TODO Make the malus for time a little less awful and add some other malus, like fitness and stuff -- TODO Make the malus for time a little less awful and add some other malus, like fitness and stuff
print("TOC: Input max time " .. tostring(maxTime)) print("TOC: Input max time " .. tostring(maxTime))
local original_max_time = og_ISEquipTimedActionAdjustMaxTime(self, maxTime) local original_max_time = og_ISEquipTimedActionAdjustMaxTime(self, maxTime)
print("TOC: Return original max time: " .. tostring(original_max_time)) print("TOC: Return original max time: " .. tostring(original_max_time))
if original_max_time ~= -1 then if original_max_time ~= -1 then
local modified_max_time = original_max_time
local part_data = getPlayer():getModData().TOC.Limbs local modified_max_time = original_max_time
local burn_factor = 1.3
local part_data = getPlayer():getModData().TOC.Limbs
local burn_factor = 1.3
-- if it's -1, it should be instant. -- if it's -1, it should be instant.
-- To make it faster, let's have everything already written in another func -- To make it faster, let's have everything already written in another func
local all_body_parts = GetBodyParts() local all_body_parts = GetBodyParts()
-- TODO this gets awfully slow really quick, doesn't even make much sense. -- TODO this gets awfully slow really quick, doesn't even make much sense.
for _, part_name in ipairs(all_body_parts) do for _, part_name in ipairs(all_body_parts) do
if part_data[part_name].is_cut then if part_data[part_name].is_cut then
if part_data[part_name].is_prosthesis_equipped then if part_data[part_name].is_prosthesis_equipped then
modified_max_time = modified_max_time * part_data[part_name].equipped_prosthesis.prosthesis_factor modified_max_time = modified_max_time * part_data[part_name].equipped_prosthesis.prosthesis_factor
else else
modified_max_time = modified_max_time * 1.5 -- TODO make this lower modified_max_time = modified_max_time * 1.5 -- TODO make this lower
end
if part_data[part_name].is_cauterized then
modified_max_time = modified_max_time * burn_factor
end
-- Perk scaling
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)
end
end end
if part_data[part_name].is_cauterized then
modified_max_time = modified_max_time * burn_factor
end
-- Perk scaling
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 )
end
end end
end
if modified_max_time > 10 * original_max_time then modified_max_time = 10 * original_max_time end if modified_max_time > 10 * original_max_time then modified_max_time = 10 * original_max_time end
print("TOC: Modified Max Time " .. modified_max_time) print("TOC: Modified Max Time " .. modified_max_time)
return modified_max_time return modified_max_time
else else
return original_max_time return original_max_time
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
@@ -81,11 +79,11 @@ function ISInventoryPane:onMouseDoubleClick(x, y)
local item_to_check = self.items[self.mouseOverOption] local item_to_check = self.items[self.mouseOverOption]
local player_inventory = getPlayerInventory(self.player).inventory local player_inventory = getPlayerInventory(self.player).inventory
if instanceof(item_to_check, "InventoryItem") then if instanceof(item_to_check, "InventoryItem") then
og_ISInventoryPaneOnMouseDoubleClick(self, x,y) og_ISInventoryPaneOnMouseDoubleClick(self, x, y)
elseif CheckIfItemIsAmputatedLimb(item_to_check.items[1]) or CheckIfItemIsProsthesis(item_to_check.items[1]) then elseif CheckIfItemIsAmputatedLimb(item_to_check.items[1]) or CheckIfItemIsProsthesis(item_to_check.items[1]) then
print("TOC: Can't double click this item") print("TOC: Can't double click this item")
else else
og_ISInventoryPaneOnMouseDoubleClick(self, x,y) og_ISInventoryPaneOnMouseDoubleClick(self, x, y)
end end
@@ -93,17 +91,16 @@ 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)
-- TODO add an exception for installed prosthesis, make them unequippable automatically from here and get the correct obj -- TODO add an exception for installed prosthesis, make them unequippable automatically from here and get the correct obj
local ret = og_ISInventoryPaneGetActualItems(items) local ret = og_ISInventoryPaneGetActualItems(items)
-- This is gonna be slower than just overriding the function but hey it's more compatible -- This is gonna be slower than just overriding the function but hey it's more compatible
for i=1, #ret do for i = 1, #ret do
local item_full_type = ret[i]:getFullType() local item_full_type = ret[i]:getFullType()
if string.find(item_full_type, "Amputation_") or string.find(item_full_type, "Prost_") then if string.find(item_full_type, "Amputation_") or string.find(item_full_type, "Prost_") then
table.remove(ret, i) table.remove(ret, i)
@@ -112,17 +109,16 @@ 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)
-- Inspect menu bypasses getActualItems, so we need to add that workaround here too -- Inspect menu bypasses getActualItems, so we need to add that workaround here too
local clothing_full_type = clothing:getFullType() local clothing_full_type = clothing:getFullType()
if not string.find(clothing_full_type, "Amputation_") then if not string.find(clothing_full_type, "Amputation_") then
og_ISInventoryPaneContextMenuOnInspectClothing(playerObj, clothing) og_ISInventoryPaneContextMenuOnInspectClothing(playerObj, clothing)
end end
end end
@@ -134,7 +130,7 @@ function ISEquipWeaponAction:perform()
local part_data = self.character:getModData().TOC.Limbs local part_data = self.character:getModData().TOC.Limbs
local can_be_held = {} local can_be_held = {}
for _, side in ipairs (TOC_sides) do for _, side in ipairs(TOC_sides) do
can_be_held[side] = true can_be_held[side] = true
if part_data[side .. "_Hand"].is_cut then if part_data[side .. "_Hand"].is_cut then
@@ -160,8 +156,8 @@ function ISEquipWeaponAction:perform()
end end
else else
if (can_be_held["Right"] and not can_be_held["Left"]) or if (can_be_held["Right"] and not can_be_held["Left"]) or
(not can_be_held["Right"] and can_be_held["Left"]) or (not can_be_held["Right"] and can_be_held["Left"]) or
(not can_be_held["Left"] and not can_be_held["Right"]) then (not can_be_held["Left"] and not can_be_held["Right"]) then
self.character:dropHandItems() self.character:dropHandItems()
end end
@@ -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

@@ -12,27 +12,23 @@ local function PrerenderFuncMP()
if confirm_ui_mp.responseReceive then if confirm_ui_mp.responseReceive then
if not confirm_ui_mp.responseCan then if not confirm_ui_mp.responseCan then
getPlayer():Say("I can't do that !") getPlayer():Say("I can't do that !")
confirm_ui_mp.responseReceive = false confirm_ui_mp.responseReceive = false
confirm_ui_mp:close() confirm_ui_mp:close()
return false; return false;
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,17 +41,20 @@ 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"
end end
@@ -68,10 +67,6 @@ local function GetImageName(part_name, toc_data)
return name return name
end end
------------------------------------------ ------------------------------------------
-- Check functions -- Check functions
@@ -81,26 +76,24 @@ 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
local function IsAmputatedLimbHealed(part_data) local function IsAmputatedLimbHealed(part_data)
return part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown return part_data.is_cut and not part_data.is_cicatrized and part_data.is_amputation_shown
end end
local function IsAmputatedLimbToBeVisible(part_data) 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
local function IsPartBitten(part_data, part_name)
return not part_data.is_cut and getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten()
end end
local function IsPartBitten(part_data, part_name)
return not part_data.is_cut and
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten()
end
local function FindMinMax(lv) local function FindMinMax(lv)
local min, max local min, max
@@ -138,23 +131,18 @@ 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)
desc_ui:open() desc_ui:open()
desc_ui:setPositionPixel(main_ui:getRight(), main_ui:getY()) desc_ui:setPositionPixel(main_ui:getRight(), main_ui:getY())
SetupTocDescUI(main_ui.surgeon, main_ui.patient, args.toc_data, args.part_name) -- surgeon is generic. SetupTocDescUI(main_ui.surgeon, main_ui.patient, args.toc_data, args.part_name) -- surgeon is generic.
end end
local function OnClickTocDescUI(button, args) local function OnClickTocDescUI(button, args)
-- Gets every arg from main -- Gets every arg from main
local patient = desc_ui.patient local patient = desc_ui.patient
local surgeon = desc_ui.surgeon local surgeon = desc_ui.surgeon
@@ -168,29 +156,30 @@ local function OnClickTocDescUI(button, args)
elseif args.option == "Equip" then elseif args.option == "Equip" then
TryTocAction(_, desc_ui.part_name, "Equip", surgeon, patient) TryTocAction(_, desc_ui.part_name, "Equip", surgeon, patient)
-- TODO probably completely broken for MP -- TODO probably completely broken for MP
-- TODO this is really janky -- TODO this is really janky
elseif args.option == "Unequip" then elseif args.option == "Unequip" then
TryTocAction(_, desc_ui.part_name, "Unequip", surgeon, patient) TryTocAction(_, desc_ui.part_name, "Unequip", surgeon, patient)
elseif args.option == "Nothing" then elseif args.option == "Nothing" then
print("Just do nothing") -- TODO workaround print("Just do nothing") -- TODO workaround
end end
main_ui:close() main_ui:close()
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
@@ -198,7 +187,7 @@ function OnClickTocConfirmUIMP(button, args)
elseif confirm_ui_mp.actionAct == "Equip" and args.option == "yes" then elseif confirm_ui_mp.actionAct == "Equip" and args.option == "yes" then
print("Equip mp comp") print("Equip mp comp")
elseif confirm_ui_mp.actionAct == "Unequip" and args.option == "yes" then elseif confirm_ui_mp.actionAct == "Unequip" and args.option == "yes" then
print("Unequip mp comp") print("Unequip mp comp")
@@ -210,8 +199,6 @@ function OnClickTocConfirmUIMP(button, args)
end end
----------------------------------------------- -----------------------------------------------
-- CREATE UI SECTION -- CREATE UI SECTION
@@ -260,7 +247,7 @@ function CreateTocDescUI()
desc_ui:addText("textTitle", "Right arm", "Large", "Center") desc_ui:addText("textTitle", "Right arm", "Large", "Center")
desc_ui:nextLine() desc_ui:nextLine()
desc_ui:addText("textLV2", "Level 3/10", _, "Center") desc_ui:addText("textLV2", "Level 3/10", _, "Center")
desc_ui:nextLine() desc_ui:nextLine()
desc_ui:addText("textLV", "Next LV:", _, "Right") desc_ui:addText("textLV", "Next LV:", _, "Right")
@@ -283,12 +270,11 @@ function CreateTocDescUI()
desc_ui:addEmpty() desc_ui:addEmpty()
desc_ui:nextLine() desc_ui:nextLine()
desc_ui:addButton("b1", "Operate", OnClickTocDescUI) -- TODO this is just temporary desc_ui:addButton("b1", "Operate", OnClickTocDescUI) -- TODO this is just temporary
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
@@ -316,7 +302,7 @@ function CreateTocConfirmUIMP()
confirm_ui_mp:addEmpty(); confirm_ui_mp:addEmpty();
confirm_ui_mp:addButton("b2", "No", OnClickTocConfirmUIMP); confirm_ui_mp:addButton("b2", "No", OnClickTocConfirmUIMP);
confirm_ui_mp:addEmpty(); confirm_ui_mp:addEmpty();
confirm_ui_mp:nextLine(); confirm_ui_mp:nextLine();
confirm_ui_mp:addEmpty(); confirm_ui_mp:addEmpty();
@@ -336,16 +322,15 @@ function OnCreateTheOnlyCureUI()
main_ui:close() main_ui:close()
end end
----------------------------------------- -----------------------------------------
-- Setup stuff with variables and shit -- Setup stuff with variables and shit
function SetupTocMainUI(surgeon, patient, toc_data) function SetupTocMainUI(surgeon, patient, toc_data)
main_ui.surgeon = surgeon -- we shouldn't need an arg for this main_ui.surgeon = surgeon -- we shouldn't need an arg for this
main_ui.patient = patient main_ui.patient = patient
if toc_data then if toc_data then
main_ui["b11"]:addArg("toc_data", toc_data) main_ui["b11"]:addArg("toc_data", toc_data)
main_ui["b12"]:addArg("toc_data", toc_data) main_ui["b12"]:addArg("toc_data", toc_data)
main_ui["b21"]:addArg("toc_data", toc_data) main_ui["b21"]:addArg("toc_data", toc_data)
@@ -355,10 +340,10 @@ function SetupTocMainUI(surgeon, patient, toc_data)
main_ui["b11"]:setPath(GetImageName("Right_UpperArm", toc_data)) main_ui["b11"]:setPath(GetImageName("Right_UpperArm", toc_data))
main_ui["b12"]:setPath(GetImageName("Left_UpperArm", toc_data)) main_ui["b12"]:setPath(GetImageName("Left_UpperArm", toc_data))
main_ui["b21"]:setPath(GetImageName("Right_LowerArm", toc_data)) main_ui["b21"]:setPath(GetImageName("Right_LowerArm", toc_data))
main_ui["b22"]:setPath(GetImageName("Left_LowerArm", toc_data)) main_ui["b22"]:setPath(GetImageName("Left_LowerArm", toc_data))
main_ui["b31"]:setPath(GetImageName("Right_Hand", toc_data)) main_ui["b31"]:setPath(GetImageName("Right_Hand", toc_data))
main_ui["b32"]:setPath(GetImageName("Left_Hand", toc_data)) main_ui["b32"]:setPath(GetImageName("Left_Hand", toc_data))
@@ -394,12 +379,12 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name)
desc_ui["b1"]:addArg("option", "Equip") desc_ui["b1"]:addArg("option", "Equip")
desc_ui["b1"]:setVisible(true) desc_ui["b1"]:setVisible(true)
end end
-- Limb cut but still healing -- Limb cut but still healing
elseif IsAmputatedLimbHealed(part_data) then elseif IsAmputatedLimbHealed(part_data) then
-- Limb cut and healed, no prosthesis equipped -- Limb cut and healed, no prosthesis equipped
if part_data.is_operated then if part_data.is_operated then
desc_ui["b1"]:setVisible(false) -- no operate prompt desc_ui["b1"]:setVisible(false) -- no operate prompt
if part_data.cicatrization_time > 1000 then if part_data.cicatrization_time > 1000 then
desc_ui["status"]:setText("Still a long way to go") desc_ui["status"]:setText("Still a long way to go")
@@ -430,7 +415,7 @@ function SetupTocDescUI(surgeon, patient, toc_data, part_name)
end end
end end
elseif IsAmputatedLimbToBeVisible(part_data) then elseif IsAmputatedLimbToBeVisible(part_data) then
-- Limb cut and not visible (ex: hand after having amputated forearm) -- Limb cut and not visible (ex: hand after having amputated forearm)
desc_ui["status"]:setText("Nothing here") desc_ui["status"]:setText("Nothing here")
@@ -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
@@ -527,14 +514,14 @@ function ISNewHealthPanel.onClick_TOC(button)
--SetupTocConfirmUI(surgeon, surgeon) --SetupTocConfirmUI(surgeon, surgeon)
else else
-- MP stuff, try to get the other player data and display it on the surgeon display -- MP stuff, try to get the other player data and display it on the surgeon display
sendClientCommand(surgeon, "TOC", "GetPlayerData", {surgeon:getOnlineID(), patient:getOnlineID()}) sendClientCommand(surgeon, "TOC", "GetPlayerData", { surgeon:getOnlineID(), patient:getOnlineID() })
SetupTocMainUI(surgeon, patient, MP_other_player_toc_data) SetupTocMainUI(surgeon, patient, MP_other_player_toc_data)
--SetupTocConfirmUI(surgeon, patient) --SetupTocConfirmUI(surgeon, patient)
end end
else else
-- This is when surgeon doesnt exist for some reason. -- This is when surgeon doesnt exist for some reason.
SetupTocMainUI(patient, patient, patient:getModData().TOC) SetupTocMainUI(patient, patient, patient:getModData().TOC)
-- SetupTocConfirmUI(patient, patient) -- SetupTocConfirmUI(patient, patient)
end end
main_ui:toggle() main_ui:toggle()
@@ -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

@@ -1,16 +1,17 @@
-- Helper for DropItem -- Helper for DropItem
function TheOnlyCure.CheckIfCanPickUpItem(toc_data, side, limb, secondary_limb) function TheOnlyCure.CheckIfCanPickUpItem(toc_data, side, limb, secondary_limb)
-- TODO we can use this when uninstall prost or when cutting -- TODO we can use this when uninstall prost or when cutting
local full_primary_limb = side .. limb local full_primary_limb = side .. 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
(toc_data[full_secondary_limb].is_cut and not toc_data[full_secondary_limb].is_prosthesis_equipped) 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)
end end
function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data) function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
@@ -27,13 +28,13 @@ function TheOnlyCure.CheckIfPlayerIsInfected(player, toc_data)
part_data.is_infected = true part_data.is_infected = true
player:transmitModData() player:transmitModData()
end end
end end
end end
for _, v in ipairs(GetOtherBodyPartTypes()) do for _, v in ipairs(GetOtherBodyPartTypes()) do
if body_damage:getBodyPart(v):bitten() then if body_damage:getBodyPart(v):bitten() then
toc_data.Limbs.is_other_bodypart_infected = true -- Even one is enough, stop cycling if we find it toc_data.Limbs.is_other_bodypart_infected = true -- Even one is enough, stop cycling if we find it
player:transmitModData() player:transmitModData()
break break
end end
@@ -50,7 +51,7 @@ function TheOnlyCure.UpdatePlayerHealth(player, part_data)
for i, part_name in pairs(GetBodyParts()) do for i, part_name in pairs(GetBodyParts()) do
if part_data[part_name].is_cut then if part_data[part_name].is_cut then
TheOnlyCure.SetHealthStatusForBodyPart(part_data, part_name, player) TheOnlyCure.SetHealthStatusForBodyPart(part_data, part_name, player)
end end
end end
@@ -78,7 +79,7 @@ function TheOnlyCure.SetHealthStatusForBodyPart(part_data, part_name, player)
-- TODO Bandages should have some disadvantage when not operated... Like getting drenched or something -- TODO Bandages should have some disadvantage when not operated... Like getting drenched or something
if body_part_type:bandaged() then if body_part_type:bandaged() then
is_bandaged = true -- this is useless is_bandaged = true -- this is useless
bandage_life = body_part_type:getBandageLife() bandage_life = body_part_type:getBandageLife()
bandage_type = body_part_type:getBandageType() bandage_type = body_part_type:getBandageType()
@@ -133,7 +134,7 @@ function TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name)
local body_parts = GetBodyParts() local body_parts = GetBodyParts()
body_parts[part_name] = nil body_parts[part_name] = nil
for _,v in pairs(body_parts) do for _, v in pairs(body_parts) do
if part_data[v].is_infected then if part_data[v].is_infected then
return true return true
end end
@@ -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()
@@ -182,15 +182,14 @@ function TheOnlyCure.UpdateEveryTenMinutes()
-- Updates the cicatrization time -- Updates the cicatrization time
for _, part_name in pairs(GetBodyParts()) do for _, part_name in pairs(GetBodyParts()) do
if part_data[part_name].is_cut and not part_data[part_name].is_cicatrized then if part_data[part_name].is_cut and not part_data[part_name].is_cicatrized then
part_data[part_name].cicatrization_time = part_data[part_name].cicatrization_time - 1 -- TODO Make it more "dynamic" part_data[part_name].cicatrization_time = part_data[part_name].cicatrization_time - 1 -- TODO Make it more "dynamic"
end end
end end
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

@@ -5,7 +5,7 @@ function TocSetCorrectTextureForAmputation(item, player)
local texture_string = human_visual:getSkinTexture() local texture_string = human_visual:getSkinTexture()
local matched_index = string.match(texture_string, "%d$") local matched_index = string.match(texture_string, "%d$")
print("TOC: Setting texture " .. matched_index) print("TOC: Setting texture " .. matched_index)
item:getVisual():setTextureChoice(tonumber(matched_index - 1)) -- TODO why is it correct with -1? item:getVisual():setTextureChoice(tonumber(matched_index - 1)) -- TODO why is it correct with -1?
end end
function TocSetBloodOnAmputation(player, body_part) function TocSetBloodOnAmputation(player, body_part)
@@ -13,14 +13,14 @@ function TocSetBloodOnAmputation(player, body_part)
local body_part_type = body_part:getType() local body_part_type = body_part:getType()
local blood_body_part_type local blood_body_part_type
if body_part_type == BodyPartType.Hand_R then if body_part_type == BodyPartType.Hand_R then
blood_body_part_type = BloodBodyPartType.ForeArm_R blood_body_part_type = BloodBodyPartType.ForeArm_R
elseif body_part_type == BodyPartType.Hand_L then elseif body_part_type == BodyPartType.Hand_L then
blood_body_part_type = BloodBodyPartType.ForeArm_L blood_body_part_type = BloodBodyPartType.ForeArm_L
elseif body_part_type == BodyPartType.Forearm_L or body_part_type == BodyPartType.UpperArm_L then elseif body_part_type == BodyPartType.Forearm_L or body_part_type == BodyPartType.UpperArm_L then
blood_body_part_type = BloodBodyPartType.UpperArm_L blood_body_part_type = BloodBodyPartType.UpperArm_L
elseif body_part_type == BodyPartType.Forearm_R or body_part_type == BodyPartType.UpperArm_R then elseif body_part_type == BodyPartType.Forearm_R or body_part_type == BodyPartType.UpperArm_R then
blood_body_part_type= BloodBodyPartType.UpperArm_R blood_body_part_type = BloodBodyPartType.UpperArm_R
end end
@@ -29,4 +29,4 @@ function TocSetBloodOnAmputation(player, body_part)
player:addBlood(blood_body_part_type, false, true, false) player:addBlood(blood_body_part_type, false, true, false)
player:addBlood(BloodBodyPartType.Torso_Lower, false, true, false) player:addBlood(BloodBodyPartType.Torso_Lower, false, true, false)
end end

View File

@@ -2,8 +2,8 @@ if not TheOnlyCure then
TheOnlyCure = {} TheOnlyCure = {}
end end
TOC_sides = {"Left", "Right"} TOC_sides = { "Left", "Right" }
TOC_limbs = {"Hand", "LowerArm", "UpperArm"} TOC_limbs = { "Hand", "LowerArm", "UpperArm" }
function TheOnlyCure.InitTheOnlyCure(_, player) function TheOnlyCure.InitTheOnlyCure(_, player)
@@ -13,7 +13,7 @@ function TheOnlyCure.InitTheOnlyCure(_, player)
TocSetInitData(mod_data, player) TocSetInitData(mod_data, player)
else else
TocCheckCompatibilityWithOlderVersions(mod_data) TocCheckCompatibilityWithOlderVersions(mod_data)
TocUpdateBaseData(mod_data) -- Since it's gonna be common to update stuff TocUpdateBaseData(mod_data) -- Since it's gonna be common to update stuff
end end
end end
@@ -22,7 +22,7 @@ function TocSetInitData(mod_data, player)
print("TOC: Creating mod_data.TOC") print("TOC: Creating mod_data.TOC")
mod_data.TOC = { mod_data.TOC = {
Limbs = { Limbs = {
Right_Hand = {}, Right_Hand = {},
@@ -35,7 +35,7 @@ function TocSetInitData(mod_data, player)
is_other_bodypart_infected = false is_other_bodypart_infected = false
}, },
Prosthesis = { Prosthesis = {
WoodenHook = { WoodenHook = {
Right_Hand = {}, Right_Hand = {},
Right_LowerArm = {}, Right_LowerArm = {},
Right_UpperArm = {}, Right_UpperArm = {},
@@ -98,10 +98,10 @@ function TocSetInitData(mod_data, player)
mod_data.TOC.Limbs[part_name].is_cicatrized = false mod_data.TOC.Limbs[part_name].is_cicatrized = false
mod_data.TOC.Limbs[part_name].is_cauterized = false mod_data.TOC.Limbs[part_name].is_cauterized = false
mod_data.TOC.Limbs[part_name].is_amputation_shown = false mod_data.TOC.Limbs[part_name].is_amputation_shown = false
mod_data.TOC.Limbs[part_name].cicatrization_time = 0 mod_data.TOC.Limbs[part_name].cicatrization_time = 0
mod_data.TOC.Limbs[part_name].is_prosthesis_equipped = false mod_data.TOC.Limbs[part_name].is_prosthesis_equipped = false
mod_data.TOC.Limbs[part_name].equipped_prosthesis = {} mod_data.TOC.Limbs[part_name].equipped_prosthesis = {}
@@ -153,13 +153,13 @@ end
function TocUpdateBaseData(mod_data) function TocUpdateBaseData(mod_data)
local prosthesis_list = {"WoodenHook", "MetalHook", "MetalHand"} local prosthesis_list = { "WoodenHook", "MetalHook", "MetalHand" }
local accepted_prosthesis_hand = {"WoodenHook", "MetalHook", "MetalHand"} local accepted_prosthesis_hand = { "WoodenHook", "MetalHook", "MetalHand" }
local accepted_prosthesis_lowerarm = {"WoodenHook", "MetalHook", "MetalHand"} local accepted_prosthesis_lowerarm = { "WoodenHook", "MetalHook", "MetalHand" }
local accepted_prosthesis_upperarm = {} -- For future stuff local accepted_prosthesis_upperarm = {} -- For future stuff
for _, side in ipairs(TOC_sides) do for _, side in ipairs(TOC_sides) do
for _, limb in ipairs(TOC_limbs) do for _, limb in ipairs(TOC_limbs) do
@@ -169,47 +169,51 @@ function TocUpdateBaseData(mod_data)
if limb == "Hand" then if limb == "Hand" then
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700 mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700
mod_data.TOC.Limbs[part_name].depends_on = {} mod_data.TOC.Limbs[part_name].depends_on = {}
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_hand mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_hand
mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.3 mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.3
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.2 mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.2
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1 mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1
elseif limb == "LowerArm" then elseif limb == "LowerArm" then
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800 mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1800
mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand",} mod_data.TOC.Limbs[part_name].depends_on = { side .. "_Hand", }
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_lowerarm mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_lowerarm
mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.35 mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.35
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.25 mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.25
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.15 mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.15
elseif limb == "UpperArm" then elseif limb == "UpperArm" then
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000 mod_data.TOC.Limbs[part_name].cicatrization_base_time = 2000
mod_data.TOC.Limbs[part_name].depends_on = {side .. "_Hand", side .. "_LowerArm",} mod_data.TOC.Limbs[part_name].depends_on = { side .. "_Hand", side .. "_LowerArm", }
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_upperarm mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_upperarm
end end
end end
end end
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")
@@ -261,7 +265,7 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
part_data[part_name].is_cut = true part_data[part_name].is_cut = true
part_data[part_name].is_amputation_shown = true part_data[part_name].is_amputation_shown = true
part_data[part_name].cicatrization_time = part_data[part_name].cicatrization_base_time - surgeon_factor * 50 part_data[part_name].cicatrization_time = part_data[part_name].cicatrization_base_time - surgeon_factor * 50
-- Heal the infection here -- Heal the infection here
local body_damage = player:getBodyDamage() local body_damage = player:getBodyDamage()
if part_data[part_name].is_infected and body_damage:getInfectionLevel() < 20 then if part_data[part_name].is_infected and body_damage:getInfectionLevel() < 20 then
@@ -327,7 +331,7 @@ function TheOnlyCure.OperateLimb(part_name, surgeon_factor, use_oven)
for _, depended_v in pairs(part_data[part_name].depends_on) do for _, depended_v in pairs(part_data[part_name].depends_on) do
part_data[depended_v].is_operated = true part_data[depended_v].is_operated = true
part_data[depended_v].cicatrization_time = part_data[depended_v].cicatrization_time - (surgeon_factor * 200) part_data[depended_v].cicatrization_time = part_data[depended_v].cicatrization_time - (surgeon_factor * 200)
if use_oven then part_data[depended_v].is_cauterized = true end -- TODO does this make sense? if use_oven then part_data[depended_v].is_cauterized = true end -- TODO does this make sense?
end end
@@ -343,7 +347,7 @@ function TryTocAction(_, part_name, action, surgeon, patient)
-- Check if SinglePlayer -- Check if SinglePlayer
if not isServer() and not isClient() then if not isServer() and not isClient() then
if action == "Cut" then if action == "Cut" then
TocCutLocal(_, surgeon, surgeon, part_name) TocCutLocal(_, surgeon, surgeon, part_name)
elseif action == "Operate" then elseif action == "Operate" then
@@ -376,11 +380,12 @@ function TryTocAction(_, part_name, action, surgeon, patient)
AskCanOperateLimb(patient, part_name) AskCanOperateLimb(patient, part_name)
elseif action == "Equip" then elseif action == "Equip" then
local surgeon_inventory = surgeon:getInventory() local surgeon_inventory = surgeon:getInventory()
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
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

@@ -51,13 +51,12 @@ function ISCutLimb:start()
body_damage_part:setBleeding(true) body_damage_part:setBleeding(true)
body_damage_part:setCut(true) body_damage_part:setCut(true)
body_damage_part:setBleedingTime(ZombRand(10,20)) body_damage_part:setBleedingTime(ZombRand(10, 20))
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,10 +66,11 @@ 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 = {}
local bandage = self.surgeon:getInventory():FindAndReturn('Bandage') local bandage = self.surgeon:getInventory():FindAndReturn('Bandage')
local sterilized_bandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage') local sterilized_bandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage')
@@ -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)
@@ -146,4 +144,4 @@ function ISCutLimb:new(patient, surgeon, part_name)
o.fromHotbar = true o.fromHotbar = true
if o.patient:isTimedActionInstant() then o.maxTime = 1 end if o.patient:isTimedActionInstant() then o.maxTime = 1 end
return o return o
end end

View File

@@ -47,9 +47,9 @@ function ISInstallProsthesis:perform()
if part_name then if part_name then
toc_data.Limbs[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm? toc_data.Limbs[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm?
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name] toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name]
self.character:getInventory():Remove(self.item) self.character:getInventory():Remove(self.item)
self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth) self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth)
end end

View File

@@ -44,7 +44,7 @@ function ISOperateLimb:findArgs()
surgeon_factor = surgeon_factor + 6 surgeon_factor = surgeon_factor + 6
end end
end end
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeon_factor = surgeon_factor + 10 end if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeon_factor = surgeon_factor + 10 end
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeon_factor = surgeon_factor + 5 end if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeon_factor = surgeon_factor + 5 end
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeon_factor = surgeon_factor + 2 end if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeon_factor = surgeon_factor + 2 end
@@ -88,16 +88,16 @@ function ISOperateLimb:new(patient, surgeon, kit, part_name, use_oven)
--o.use_oven = use_oven; --o.use_oven = use_oven;
if use_oven then if use_oven then
o.maxTime = 30 o.maxTime = 30
else else
o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10) o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10)
end end
o.stopOnWalk = true o.stopOnWalk = true
o.stopOnRun = true o.stopOnRun = true
o.ignoreHandsWounds = false o.ignoreHandsWounds = false
o.fromHotbar = true o.fromHotbar = true
if o.patient:isTimedActionInstant()then if o.patient:isTimedActionInstant() then
o.maxTime = 1 o.maxTime = 1
end end
return o return o
end end

View File

@@ -46,7 +46,7 @@ function ISUninstallProsthesis:perform()
local accepting_body_parts = GetAcceptingProsthesisBodyPartTypes() local accepting_body_parts = GetAcceptingProsthesisBodyPartTypes()
if accepting_body_parts == nil then if accepting_body_parts == nil then
return -- should never happen return -- should never happen
end end
for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do
@@ -54,7 +54,7 @@ function ISUninstallProsthesis:perform()
local part_name = TocGetPartNameFromBodyPartType(v) local part_name = TocGetPartNameFromBodyPartType(v)
print("Found prost in " .. part_name) print("Found prost in " .. part_name)
if part_name then if part_name then
toc_data.Limbs[part_name].is_prosthesis_equipped = false toc_data.Limbs[part_name].is_prosthesis_equipped = false
local item_full_type = self.item:getFullType() local item_full_type = self.item:getFullType()
print("Searching for " .. item_full_type) print("Searching for " .. item_full_type)
@@ -67,10 +67,10 @@ function ISUninstallProsthesis:perform()
self.character:setWornItem(self.item:getBodyLocation(), nil) self.character:setWornItem(self.item:getBodyLocation(), nil)
self.character:getInventory():Remove(self.item) self.character:getInventory():Remove(self.item)
self.character:transmitModData() self.character:transmitModData()
-- needed to remove from queue / start next. -- needed to remove from queue / start next.
ISBaseTimedAction.perform(self) ISBaseTimedAction.perform(self)
end end
end end
@@ -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

@@ -18,25 +18,25 @@ Commands["GetPlayerData"] = function(_, arg)
local surgeon_id = arg[1] local surgeon_id = arg[1]
local patient_id = arg[2] local patient_id = arg[2]
local patient = getPlayerByOnlineID(arg[2]) local patient = getPlayerByOnlineID(arg[2])
sendServerCommand(patient, "TOC", "GivePlayerData", {surgeon_id, patient_id}) sendServerCommand(patient, "TOC", "GivePlayerData", { surgeon_id, patient_id })
end end
Commands["SendPlayerData"] = function(_, arg) Commands["SendPlayerData"] = function(_, arg)
local surgeon = getPlayerByOnlineID(arg[1]) local surgeon = getPlayerByOnlineID(arg[1])
local surgeon_id = arg[1] local surgeon_id = arg[1]
local toc_data = arg[2] local toc_data = arg[2]
sendServerCommand(surgeon, "TOC", "SendTocData", {surgeon_id, toc_data}) sendServerCommand(surgeon, "TOC", "SendTocData", { surgeon_id, toc_data })
end end
-- CHEATING STUFF -- CHEATING STUFF
Commands["AskToResetEverything"] = function (_, arg) Commands["AskToResetEverything"] = function(_, arg)
local clicked_player = getPlayerByOnlineID(arg[1]) local clicked_player = getPlayerByOnlineID(arg[1])
local clicked_player_id = arg[1] local clicked_player_id = arg[1]
sendServerCommand(clicked_player, "TOC", "AcceptResetEverything", {clicked_player_id}) sendServerCommand(clicked_player, "TOC", "AcceptResetEverything", { clicked_player_id })
end end
@@ -52,4 +52,3 @@ local function OnTocClientCommand(module, command, player, args)
end end
Events.OnClientCommand.Add(OnTocClientCommand) Events.OnClientCommand.Add(OnTocClientCommand)

View File

@@ -6,4 +6,4 @@ Events.OnGameStart.Add(function()
print("checkbox1 = ", options.box1) print("checkbox1 = ", options.box1)
print("checkbox2 = ", options.box2) print("checkbox2 = ", options.box2)
end end
end) end)