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)
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
end
function CheckIfCanBeOperated(part_name)
local part_data = getPlayer():getModData().TOC.Limbs
@@ -51,6 +50,3 @@ function CheckIfProsthesisAlreadyInstalled(part_data, part_name)
end

View File

@@ -9,7 +9,8 @@ Commands["ResponseCanAct"] = function(arg)
ui.responsePartName = arg["toSend"][1]
ui.responseCan = arg["toSend"][3]
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
@@ -18,7 +19,7 @@ function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkille
arg["From"] = getPlayer():getOnlineID()
arg["To"] = player:getOnlineID()
arg["command"] = "CutLimb"
arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table}
arg["toSend"] = { part_name, surgeon_factor, bandage_table, painkiller_table }
sendClientCommand("TOC", "SendServer", arg)
end
@@ -27,7 +28,7 @@ function SendOperateLimb(player, part_name, surgeon_factor, use_oven)
arg["From"] = getPlayer():getOnlineID()
arg["To"] = player:getOnlineID()
arg["command"] = "OperateLimb"
arg["toSend"] = {part_name, surgeon_factor, use_oven}
arg["toSend"] = { part_name, surgeon_factor, use_oven }
sendClientCommand("TOC", "SendServer", arg)
end
@@ -61,7 +62,6 @@ function AskCanEquipProsthesis(player, part_name)
sendClientCommand("TOC", "SendServer", arg)
end
-- Patient (receive)
Commands["CutLimb"] = function(arg)
local arg = arg["toSend"]
@@ -79,7 +79,7 @@ Commands["CanCutLimb"] = function(arg)
arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Cut", CheckIfCanBeCut(part_name)}
arg["toSend"] = { part_name, "Cut", CheckIfCanBeCut(part_name) }
sendClientCommand("TOC", "SendServer", arg)
end
@@ -89,7 +89,7 @@ Commands["CanOperateLimb"] = function(arg)
arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Operate", CheckIfCanBeOperated(part_name)}
arg["toSend"] = { part_name, "Operate", CheckIfCanBeOperated(part_name) }
sendClientCommand("TOC", "SendServer", arg)
end
@@ -99,7 +99,7 @@ Commands["CanEquipProsthesis"] = function(arg)
arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Equip", CheckIfProsthesisCanBeEquipped(part_name)}
arg["toSend"] = { part_name, "Equip", CheckIfProsthesisCanBeEquipped(part_name) }
end
@@ -110,7 +110,7 @@ Commands["CanResetEverything"] = function(arg)
arg["To"] = arg["From"]
arg["From"] = getPlayer():getOnlineID()
arg["command"] = "ResponseCanAct"
arg["toSend"] = {part_name, "Cut", true}
arg["toSend"] = { part_name, "Cut", true }
sendClientCommand("TOC", "SendServer", arg)
--TocResetEverything()
end
@@ -133,7 +133,7 @@ Commands["GivePlayerData"] = function(arg)
local surgeon_id = arg[1]
local patient = getPlayerByOnlineID(arg[2])
local toc_data = patient:getModData().TOC
sendClientCommand(patient, "TOC", "SendPlayerData", {surgeon_id, toc_data})
sendClientCommand(patient, "TOC", "SendPlayerData", { surgeon_id, toc_data })
end
Commands["SendTocData"] = function(arg)
@@ -162,7 +162,4 @@ local function OnTocServerCommand(module, command, args)
end
end
Events.OnServerCommand.Add(OnTocServerCommand)

View File

@@ -1,6 +1,8 @@
function GetBodyParts()
local bodyparts = { "Right_Hand", "Right_LowerArm", "Right_UpperArm",
"Left_Hand", "Left_LowerArm", "Left_UpperArm"}
local bodyparts = {
"Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand",
"Left_LowerArm", "Left_UpperArm"
}
return bodyparts
end
@@ -13,60 +15,75 @@ function TocFindAmputatedClothingFromPartName(part_name)
return "TOC.Amputation_" .. part_name
end
function GetLimbsBodyPartTypes()
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R,
BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L}
return {
BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R,
BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L
}
end
function GetOtherBodyPartTypes()
return {BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head, BodyPartType.Neck,
BodyPartType.Groin, BodyPartType.UpperLeg_L, BodyPartType.UpperLeg_R, BodyPartType.LowerLeg_L,
BodyPartType.LowerLeg_R, BodyPartType.Foot_L, BodyPartType.Foot_R, BodyPartType.Back}
return {
BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head,
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
function GetAcceptingProsthesisBodyPartTypes()
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R,
BodyPartType.Hand_L, BodyPartType.ForeArm_L}
return {
BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.Hand_L,
BodyPartType.ForeArm_L
}
end
-- TODO This is just convoluted. Do not use this
function FindTocDataPartNameFromBodyPartType(toc_limbs_data, bodyPartType)
if bodyPartType == BodyPartType.Hand_R then return toc_limbs_data.Right_Hand
elseif bodyPartType == BodyPartType.ForeArm_R then return toc_limbs_data.Right_LowerArm
elseif bodyPartType == BodyPartType.UpperArm_R then return toc_limbs_data.Right_UpperArm
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
if bodyPartType == BodyPartType.Hand_R then
return toc_limbs_data.Right_Hand
elseif bodyPartType == BodyPartType.ForeArm_R then
return toc_limbs_data.Right_LowerArm
elseif bodyPartType == BodyPartType.UpperArm_R then
return toc_limbs_data.Right_UpperArm
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
function TocGetPartNameFromBodyPartType(body_part)
if body_part == BodyPartType.Hand_R then return "Right_Hand"
elseif body_part == BodyPartType.ForeArm_R then return "Right_LowerArm"
elseif body_part == BodyPartType.UpperArm_R then return "Right_UpperArm"
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
if body_part == BodyPartType.Hand_R then
return "Right_Hand"
elseif body_part == BodyPartType.ForeArm_R then
return "Right_LowerArm"
elseif body_part == BodyPartType.UpperArm_R then
return "Right_UpperArm"
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
function TocGetBodyPartTypeFromPartName(part_name)
if part_name == "Right_Hand" then return BodyPartType.Hand_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
end
function TocFindCorrectClothingProsthesis(item_name, part_name)
local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name
@@ -94,15 +110,12 @@ local function PartNameToBodyLocation(name)
if name == "Left_UpperArm" then return "ArmLeft_Prot" end
end
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
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()
if item:getBodyLocation() == PartNameToBodyLocation(part_name) then
return item

View File

@@ -10,8 +10,6 @@ function TocCheckCompatibilityWithOlderVersions(mod_data)
end
function TocMapOldDataToNew(mod_data)
local map_names = {
@@ -24,8 +22,9 @@ function TocMapOldDataToNew(mod_data)
Left_UpperArm = "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 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" }
print("TOC: Trying to backup old data")
local backup_old_data = mod_data.TOC
@@ -78,7 +77,7 @@ function TocMapOldDataToNew(mod_data)
-- end
for i=1, #new_names_table do
for i = 1, #new_names_table do
print("TOC: Looping " .. i)
print(backup_old_data[old_names_table[i]].is_cut)

View File

@@ -1,12 +1,7 @@
function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
sendClientCommand(surgeon, "TOC", "AskToResetEverything", {patient:getOnlineID()})
sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() })
end
----------------------------------------------------------------------------------------------------------
TocContextMenus = {}
@@ -19,13 +14,13 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
local local_player = getSpecificPlayer(player)
--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
for x=v:getSquare():getX()-1,v:getSquare():getX()+1 do
for y=v:getSquare():getY()-1,v:getSquare():getY()+1 do
local sq = getCell():getGridSquare(x,y,v:getSquare():getZ())
for x = v:getSquare():getX() - 1, v:getSquare():getX() + 1 do
for y = v:getSquare():getY() - 1, v:getSquare():getY() + 1 do
local sq = getCell():getGridSquare(x, y, v:getSquare():getZ())
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)
if instanceof(o, "IsoPlayer") then
clicked_player = o
@@ -40,10 +35,12 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
local cut_menu = TocContextMenus.CreateNewMenu("Cut", 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)
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)
break
@@ -74,13 +71,15 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
--local props = v:getSprite() and v:getSprite():getProperties() or nil
for _, v_stove in pairs(worldObjects) do
if instanceof(v_stove, "IsoStove") and (player_obj:HasTrait("Brave") or player_obj:getPerkLevel(Perks.Strength) >= 6) then
if instanceof(v_stove, "IsoStove") and
(player_obj:HasTrait("Brave") or player_obj:getPerkLevel(Perks.Strength) >= 6) then
-- Check temperature
if v_stove:getCurrentTemperature() > 250 then
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);
if is_main_menu_already_created == false then
@@ -88,7 +87,8 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
context:addSubMenu(rootMenu, subMenu)
is_main_menu_already_created = true
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
@@ -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)
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
else -- 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)
operate_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Operate", local_player, clicked_player)
cut_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Cut", local_player,
clicked_player)
operate_menu:addOption(getText('UI_ContextMenu_' .. v), world_objects, TryTocAction, v, "Operate",
local_player, clicked_player)
end
@@ -161,7 +164,8 @@ TocContextMenus.CreateCheatMenu = function(context, root_menu, local_player, cli
cheat_menu:addOption("Reset TOC for me", _, TocResetEverything)
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

View File

@@ -6,7 +6,7 @@ function TocResetEverything()
TheOnlyCure.InitTheOnlyCure(_, player)
-- Destroy the amputation model
for _,v in ipairs(GetBodyParts()) do
for _, v in ipairs(GetBodyParts()) do
local cloth = player:getInventory():FindAndReturn(TocFindAmputatedClothingFromPartName(v))
if cloth ~= nil then

View File

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

View File

@@ -1,7 +1,3 @@
-- CutLimb
-- TODO if TheONlyCure. triggers an errors
function TocCheckIfStillInfected(part_data)
@@ -25,8 +21,6 @@ function TocCheckIfStillInfected(part_data)
return check
end
function TocCureInfection(body_damage, part_data, part_name)
local body_part_type = body_damage:getBodyPart(TocGetBodyPartTypeFromPartName(part_name))
@@ -43,7 +37,7 @@ function TocCureInfection(body_damage, part_data, part_name)
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
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);
bodyPart:SetInfected(false);
end
@@ -56,7 +50,7 @@ function TocCureInfection(body_damage, part_data, part_name)
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: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
function TocDeleteOtherAmputatedLimbs(side)
-- if left hand is cut and we cut left lowerarm, then delete hand
@@ -83,16 +76,17 @@ end
function TocGetKitInInventory(surgeon)
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
end
function TocGetSawInInventory(surgeon)
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
end
@@ -127,7 +121,6 @@ function FixSingleBodyPartType(body_part_type, use_oven)
end
end
-------------------------------------
-- Override helper

View File

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

View File

@@ -51,7 +51,8 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
-- 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 )
modified_max_time = modified_max_time *
(1 + (9 - self.character:getPerkLevel(Perks[part_name])) / 20)
end
end
@@ -70,9 +71,6 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
end
-------------------------------------------------
-- Block access to drag, picking, inspecting, etc to amputated limbs
local og_ISInventoryPaneOnMouseDoubleClick = ISInventoryPane.onMouseDoubleClick
@@ -81,11 +79,11 @@ function ISInventoryPane:onMouseDoubleClick(x, y)
local item_to_check = self.items[self.mouseOverOption]
local player_inventory = getPlayerInventory(self.player).inventory
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
print("TOC: Can't double click this item")
else
og_ISInventoryPaneOnMouseDoubleClick(self, x,y)
og_ISInventoryPaneOnMouseDoubleClick(self, x, y)
end
@@ -93,7 +91,6 @@ function ISInventoryPane:onMouseDoubleClick(x, y)
end
local og_ISInventoryPaneGetActualItems = ISInventoryPane.getActualItems
function ISInventoryPane.getActualItems(items)
@@ -103,7 +100,7 @@ function ISInventoryPane.getActualItems(items)
-- 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()
if string.find(item_full_type, "Amputation_") or string.find(item_full_type, "Prost_") then
table.remove(ret, i)
@@ -112,7 +109,6 @@ function ISInventoryPane.getActualItems(items)
return ret
end
local og_ISInventoryPaneContextMenuOnInspectClothing = ISInventoryPaneContextMenu.onInspectClothing
ISInventoryPaneContextMenu.onInspectClothing = function(playerObj, clothing)
@@ -134,7 +130,7 @@ function ISEquipWeaponAction:perform()
local part_data = self.character:getModData().TOC.Limbs
local can_be_held = {}
for _, side in ipairs (TOC_sides) do
for _, side in ipairs(TOC_sides) do
can_be_held[side] = true
if part_data[side .. "_Hand"].is_cut then
@@ -171,7 +167,6 @@ function ISEquipWeaponAction:perform()
end
local og_ISInventoryPaneContextMenuUnequipItem = ISInventoryPaneContextMenu.unequipItem
function ISInventoryPaneContextMenu.unequipItem(item, player)
@@ -191,4 +186,3 @@ function ISInventoryPaneContextMenu.dropItem(item, player)
end
end

View File

@@ -18,21 +18,17 @@ local function PrerenderFuncMP()
end
-- 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
-----------------------
-- Getters
function GetConfirmUIMP()
return confirm_ui_mp;
end
------------------------------
-- UI Visible stuff functions
local function GetImageName(part_name, toc_data)
@@ -45,15 +41,18 @@ local function GetImageName(part_name, toc_data)
else
name = "media/ui/TOC/" .. part_name .. "/Prothesis.png"
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"
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"
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"
elseif part_data.is_cut and not part_data.is_amputation_shown then -- Empty (like hand if forearm cut)
name = "media/ui/TOC/Empty.png"
elseif not part_data.is_cut and 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"
else -- Not cut
name = "media/ui/TOC/" .. part_name .. "/Base.png"
@@ -68,10 +67,6 @@ local function GetImageName(part_name, toc_data)
return name
end
------------------------------------------
-- Check functions
@@ -81,7 +76,8 @@ end
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
@@ -94,14 +90,11 @@ local function IsAmputatedLimbToBeVisible(part_data)
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()
return not part_data.is_cut and
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartTypeFromPartName(part_name)):bitten()
end
local function FindMinMax(lv)
local min, max
if lv == 1 then
@@ -138,11 +131,6 @@ local function FindMinMax(lv)
return min, max;
end
------------------------------------------------
-- On Click Functions
local function OnClickTocMainUI(button, args)
@@ -181,16 +169,17 @@ local function OnClickTocDescUI(button, args)
end
function OnClickTocConfirmUIMP(button, args)
local player = getPlayer()
if confirm_ui_mp.actionAct == "Cut" and args.option == "yes" then
ISTimedActionQueue.add(ISCutLimb:new(confirm_ui_mp.patient, player, confirm_ui_mp.partNameAct))
elseif confirm_ui_mp.actionAct == "Operate" and args.option == "yes" then
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
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
player:Say("I need a kit")
end
@@ -210,8 +199,6 @@ function OnClickTocConfirmUIMP(button, args)
end
-----------------------------------------------
-- CREATE UI SECTION
@@ -288,7 +275,6 @@ function CreateTocDescUI()
desc_ui:saveLayout()
end
function CreateTocConfirmUIMP()
confirm_ui_mp = NewUI()
confirm_ui_mp.responseReceive = false
@@ -336,7 +322,6 @@ function OnCreateTheOnlyCureUI()
main_ui:close()
end
-----------------------------------------
-- Setup stuff with variables and shit
@@ -493,7 +478,8 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
confirm_ui_mp:open()
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"]:setColor(1, 0, 0, 0)
confirm_ui_mp["b1"]:setVisible(true);
@@ -509,6 +495,7 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
end
--------------------------------------------
-- Add TOC element to Health Panel
local ISHealthPanel_createChildren = ISHealthPanel.createChildren
@@ -527,7 +514,7 @@ function ISNewHealthPanel.onClick_TOC(button)
--SetupTocConfirmUI(surgeon, surgeon)
else
-- 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)
--SetupTocConfirmUI(surgeon, patient)
end
@@ -542,14 +529,14 @@ function ISNewHealthPanel.onClick_TOC(button)
end
function ISHealthPanel:createChildren()
ISHealthPanel_createChildren(self)
self.fitness:setWidth(self.fitness:getWidth()/1.5)
self.fitness:setWidth(self.fitness:getWidth() / 1.5)
--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.anchorTop = false
self.TOCButton.anchorBottom = true
@@ -566,8 +553,5 @@ function ISHealthPanel:render()
self.TOCButton:setY(self.fitness:getY());
end
-- EVENTS
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
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)
@@ -133,7 +134,7 @@ function TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name)
local body_parts = GetBodyParts()
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
return true
end
@@ -141,7 +142,6 @@ function TheOnlyCure.CheckIfOtherLimbsAreInfected(part_data, part_name)
return false
end
-- MAIN UPDATE FUNCTIONS
function TheOnlyCure.UpdateEveryOneMinute()
@@ -191,6 +191,5 @@ function TheOnlyCure.UpdateEveryTenMinutes()
player:transmitModData()
end
Events.EveryTenMinutes.Add(TheOnlyCure.UpdateEveryTenMinutes)
Events.EveryOneMinute.Add(TheOnlyCure.UpdateEveryOneMinute)

View File

@@ -20,7 +20,7 @@ function TocSetBloodOnAmputation(player, body_part)
elseif body_part_type == BodyPartType.Forearm_L or body_part_type == BodyPartType.UpperArm_L then
blood_body_part_type = BloodBodyPartType.UpperArm_L
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

View File

@@ -2,8 +2,8 @@ if not TheOnlyCure then
TheOnlyCure = {}
end
TOC_sides = {"Left", "Right"}
TOC_limbs = {"Hand", "LowerArm", "UpperArm"}
TOC_sides = { "Left", "Right" }
TOC_limbs = { "Hand", "LowerArm", "UpperArm" }
function TheOnlyCure.InitTheOnlyCure(_, player)
@@ -153,12 +153,12 @@ end
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_lowerarm = {"WoodenHook", "MetalHook", "MetalHand"}
local accepted_prosthesis_hand = { "WoodenHook", "MetalHook", "MetalHand" }
local accepted_prosthesis_lowerarm = { "WoodenHook", "MetalHook", "MetalHand" }
local accepted_prosthesis_upperarm = {} -- For future stuff
for _, side in ipairs(TOC_sides) do
@@ -179,7 +179,7 @@ function TocUpdateBaseData(mod_data)
elseif limb == "LowerArm" then
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["WoodenHook"][part_name].prosthesis_factor = 1.35
@@ -187,7 +187,7 @@ function TocUpdateBaseData(mod_data)
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.15
elseif limb == "UpperArm" then
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
end
@@ -200,16 +200,20 @@ function TocUpdateBaseData(mod_data)
end
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)
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)
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)
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_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.WoodenHook')
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
surgeon:Say("I need a prosthesis")
end
@@ -392,7 +397,8 @@ function TryTocAction(_, part_name, action, surgeon, patient)
elseif action == "Unequip" then
--AskCanUnequipProsthesis(patient, part_name)
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
ui.actionAct = action
ui.partNameAct = part_name
@@ -405,6 +411,5 @@ function TryTocAction(_, part_name, action, surgeon, patient)
end
end
Events.OnCreatePlayer.Add(TheOnlyCure.InitTheOnlyCure)
Events.OnGameBoot.Add(TheOnlyCure.DeclareTraits)

View File

@@ -51,13 +51,12 @@ function ISCutLimb:start()
body_damage_part:setBleeding(true)
body_damage_part:setCut(true)
body_damage_part:setBleedingTime(ZombRand(10,20))
body_damage_part:setBleedingTime(ZombRand(10, 20))
end
function ISCutLimb:findArgs()
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor)
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeon_factor = surgeon_factor + 15 end
@@ -67,7 +66,8 @@ function ISCutLimb:findArgs()
local bandage_table = {
use_bandage = false,
bandage_type = nil,
is_bandage_sterilized = nil}
is_bandage_sterilized = nil
}
local painkiller_table = {}
@@ -102,7 +102,6 @@ function ISCutLimb:findArgs()
return surgeon_factor, bandage_table, painkiller_table
end
function ISCutLimb:perform()
local surgeon_factor, bandage_table, painkiller_table = self:findArgs()
@@ -125,7 +124,6 @@ function ISCutLimb:perform()
end
function ISCutLimb:new(patient, surgeon, part_name)
local o = {}
setmetatable(o, self)

View File

@@ -95,7 +95,7 @@ function ISOperateLimb:new(patient, surgeon, kit, part_name, use_oven)
o.stopOnRun = true
o.ignoreHandsWounds = false
o.fromHotbar = true
if o.patient:isTimedActionInstant()then
if o.patient:isTimedActionInstant() then
o.maxTime = 1
end

View File

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

View File

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