Even more renaming

This commit is contained in:
Pao
2023-02-28 02:18:25 +01:00
parent 15dea9f57a
commit 672a6c9aac
66 changed files with 189 additions and 247 deletions

View File

@@ -10,12 +10,8 @@ end
local function TocCheckIfStillInfected(limbs_data)
if limbs_data == nil then
local function CheckIfStillInfected(limbsData)
if limbsData == nil then
return
end
-- Check ALL body part types to check if the player is still gonna die
@@ -23,54 +19,51 @@ local function TocCheckIfStillInfected(limbs_data)
for _, v in pairs(JCIO_Common.GetPartNames()) do
if limbs_data[v].is_infected then
if limbsData[v].isInfected then
check = true
end
end
if limbs_data.is_other_bodypart_infected then
if limbsData.isOtherBodypartInfected then
check = true
end
return check
end
local function TocCureInfection(body_damage, part_name)
local function CureInfection(bodyDamage, partName)
local body_part_type = body_damage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(part_name))
local bodyPartType = bodyDamage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName))
body_damage:setInfected(false)
body_part_type:SetInfected(false)
body_damage:setInfectionMortalityDuration(-1)
body_damage:setInfectionTime(-1)
body_damage:setInfectionLevel(0)
local body_part_types = body_damage:getBodyParts()
bodyDamage:setInfected(false)
bodyPartType:SetInfected(false)
bodyDamage:setInfectionMortalityDuration(-1)
bodyDamage:setInfectionTime(-1)
bodyDamage:setInfectionLevel(0)
local bodypartTypesTable = bodyDamage: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
local bodyPart = body_part_types:get(i)
for i = bodypartTypesTable:size() - 1, 0, -1 do
local bodyPart = bodypartTypesTable:get(i)
bodyPart:SetInfected(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: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: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 bodyPartType:scratched() then bodyPartType:setScratched(false, false) end
if bodyPartType:haveGlass() then bodyPartType:setHaveGlass(false) end
if bodyPartType:haveBullet() then bodyPartType:setHaveBullet(false, 0) end
if bodyPartType:isInfectedWound() then bodyPartType:setInfectedWound(false) end
if bodyPartType:isBurnt() then bodyPartType:setBurnTime(0) end
if bodyPartType:isCut() then bodyPartType:setCut(false, false) end --Lacerations
if bodyPartType:getFractureTime() > 0 then bodyPartType:setFractureTime(0) end
end
local function TocDeleteOtherAmputatedLimbs(side)
local function DeleteOtherAmputatedLimbs(side)
-- if left hand is cut and we cut left lowerarm, then delete hand
for _, limb in pairs(JCIO.limbNames) do
local part_name = "TOC.Amputation_" .. side .. "_" .. limb
local amputated_limb = getPlayer():getInventory():FindAndReturn(part_name)
if amputated_limb then
getPlayer():getInventory():Remove(amputated_limb)
local partName = "JCIO.Amputation_" .. side .. "_" .. limb
local amputatedLimbItem = getPlayer():getInventory():FindAndReturn(partName)
if amputatedLimbItem then
getPlayer():getInventory():Remove(amputatedLimbItem)
end
end
@@ -81,43 +74,43 @@ end
---@param perk any The perk to scale down
local function LosePerkLevel(player, perk)
player:LoseLevel(perk)
local actual_level = player:getPerkLevel(perk)
local perk_xp = player:getXp()
perk_xp:setXPToLevel(perk, actual_level)
local actualLevel = player:getPerkLevel(perk)
local perkXp = player:getXp()
perkXp:setXPToLevel(perk, actualLevel)
SyncXp(player)
end
---@param heal_bite boolean
local function TocSetParametersForMissingLimb(body_part, heal_bite)
body_part:setBleeding(false)
body_part:setBleedingTime(0)
body_part:setDeepWounded(false)
body_part:setDeepWoundTime(0)
body_part:setScratched(false, false) -- why the fuck are there 2 booleans TIS?
body_part:setScratchTime(0)
body_part:setCut(false)
body_part:setCutTime(0)
---@param isHealingBite boolean
local function SetParametersForMissingLimb(bodyPart, isHealingBite)
bodyPart:setBleeding(false)
bodyPart:setBleedingTime(0)
bodyPart:setDeepWounded(false)
bodyPart:setDeepWoundTime(0)
bodyPart:setScratched(false, false) -- why the fuck are there 2 booleans TIS?
bodyPart:setScratchTime(0)
bodyPart:setCut(false)
bodyPart:setCutTime(0)
if heal_bite then
body_part:SetBitten(false)
body_part:setBiteTime(0)
if isHealingBite then
bodyPart:SetBitten(false)
bodyPart:setBiteTime(0)
end
end
function TocDamagePlayerDuringAmputation(patient, part_name)
function JCIO.DamagePlayerDuringAmputation(patient, partName)
-- Since we're cutting that specific part, it only makes sense that the bleeding starts from there.
-- Then, we just delete the bleeding somewhere else before applying the other damage to to upper part of the limb
local body_part_type = JCIO_Common.GetBodyPartFromPartName(part_name)
local body_damage = patient:getBodyDamage()
local body_damage_part = body_damage:getBodyPart(body_part_type)
local bodyPartType = JCIO_Common.GetBodyPartFromPartName(partName)
local bodyDamage = patient:getBodyDamage()
local bodyDamagePart = bodyDamage:getBodyPart(bodyPartType)
body_damage_part:setBleeding(true)
body_damage_part:setCut(true)
body_damage_part:setBleedingTime(ZombRand(10, 20))
bodyDamagePart:setBleeding(true)
bodyDamagePart:setCut(true)
bodyDamagePart:setBleedingTime(ZombRand(10, 20))
end
local function FindTourniquetInWornItems(patient, side)
@@ -171,7 +164,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
-- Reset the status of the first body part, since we just cut it off it shouldn't be bleeding anymore
-- The bit will be checked later since we're not sure if the player is not infected from another wound
TocSetParametersForMissingLimb(bodyPart, false)
SetParametersForMissingLimb(bodyPart, false)
-- Use a tourniquet if available
local tourniquetItem = FindTourniquetInWornItems(player, JCIO_Common.GetSideFromPartName(partName))
@@ -232,7 +225,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
local canHealDependedV = limbsData[depended_v].isInfected and
bodyDamage:getInfectionLevel() < 20
local depended_body_part = bodyDamage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(depended_v))
TocSetParametersForMissingLimb(depended_body_part, canHealDependedV)
SetParametersForMissingLimb(depended_body_part, canHealDependedV)
if canHealDependedV then
limbsData[depended_v].isInfected = false
@@ -253,8 +246,8 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
bodyPart:setBiteTime(0)
-- Second check, let's see if there is any other infected limb.
if TocCheckIfStillInfected(limbsData) == false then
TocCureInfection(body_damage, partName)
if CheckIfStillInfected(limbsData) == false then
CureInfection(body_damage, partName)
getPlayer():Say("I'm gonna be fine...") -- TODO Make it visible to other players, check True Actions as reference
else
getPlayer():Say("I'm still gonna die...")
@@ -265,19 +258,19 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
-- Check for older amputation models and deletes them from player's inventory
local side = string.match(partName, '(%w+)_')
TocDeleteOtherAmputatedLimbs(side)
DeleteOtherAmputatedLimbs(side)
--Equip new model for amputation
local amputation_clothing_item_name = JCIO_Common.FindAmputatedClothingName(partName)
print(amputation_clothing_item_name)
local amputation_clothing_item = player:getInventory():AddItem(amputation_clothing_item_name)
TocSetCorrectTextureForAmputation(amputation_clothing_item, player, false)
JCIO_Visuals.SetTextureForAmputation(amputation_clothing_item, player, false)
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
-- Set blood on the amputated limb
TocSetBloodOnAmputation(getPlayer(), adjacentBodyPart)
JCIO_Visuals.SetBloodOnAmputation(getPlayer(), adjacentBodyPart)
if partName == "Left_Foot" or partName == "Right_Foot" then
JCIO_Anims.SetMissingFootAnimation(true)

View File

@@ -23,7 +23,7 @@ function JCIO_LocalActions.Operate(_, player, partName, useOven)
if useOven then
ISTimedActionQueue.add(JCIO_OperateLimbAction:new(player, player, _, partName, useOven));
else
local kit = TocGetKitInInventory(player)
local kit = JCIO_Common.GetKitInInventory(player)
if kit ~= nil then
ISTimedActionQueue.add(JCIO_OperateLimbAction:new(player, player, kit, partName, false))
else
@@ -32,6 +32,7 @@ function JCIO_LocalActions.Operate(_, player, partName, useOven)
end
end
-- TODO This is gonna get deleted
function JCIO_LocalActions.EquipProsthesis(_, player, partName)
local surgeonInv = player:getInventory()
local prosthesisToEquip = surgeonInv:getItemFromType('TOC.MetalHand') or

View File

@@ -13,6 +13,7 @@ local mainUI, descUI, confirmUI, confirmUIMP
-------------------------
-- MP stuff
-- TODO Strip out all this crap and redo it
local function PrerenderFuncMP()
local toSee = confirmUIMP
if confirmUIMP.responseReceive then
@@ -40,37 +41,37 @@ end
local function GetImageName(partName, limbsData)
local name = ""
local part_data = limbsData[partName]
local partData = limbsData[partName]
if part_data.isCut and part_data.isCicatrized and part_data.isProsthesisEquipped then -- Cut and equip
if partData.isCut and partData.isCicatrized and partData.isProsthesisEquipped then -- Cut and equip
if partName == "Right_Hand" or partName == "Left_Hand" then
name = "media/ui/TOC/" .. partName .. "/Hook.png"
name = "media/ui/JCIO/" .. partName .. "/Hook.png"
else
name = "media/ui/TOC/" .. partName .. "/Prothesis.png"
name = "media/ui/JCIO/" .. partName .. "/Prothesis.png"
end
elseif part_data.isCut and part_data.isCicatrized and not part_data.isProsthesisEquipped and
part_data.isAmputationShown then -- Cut and heal
name = "media/ui/TOC/" .. partName .. "/Cut.png"
elseif part_data.isCut and not part_data.isCicatrized and part_data.isAmputationShown and
not part_data.isOperated then -- Cut not heal
name = "media/ui/TOC/" .. partName .. "/Bleed.png"
elseif part_data.isCut and not part_data.isCicatrized and part_data.isAmputationShown and part_data.isOperated then -- Cut not heal
name = "media/ui/TOC/" .. partName .. "/Operate.png"
elseif part_data.isCut and not part_data.isAmputationShown then -- Empty (like hand if forearm cut)
name = "media/ui/TOC/Empty.png"
elseif not part_data.isCut and
elseif partData.isCut and partData.isCicatrized and not partData.isProsthesisEquipped and
partData.isAmputationShown then -- Cut and heal
name = "media/ui/JCIO/" .. partName .. "/Cut.png"
elseif partData.isCut and not partData.isCicatrized and partData.isAmputationShown and
not partData.isOperated then -- Cut but not healead
name = "media/ui/JCIO/" .. partName .. "/Bleed.png"
elseif partData.isCut and not partData.isCicatrized and partData.isAmputationShown and partData.isOperated then -- Cut but not healed and operated
name = "media/ui/JCIO/" .. partName .. "/Operate.png"
elseif partData.isCut and not partData.isAmputationShown then -- Empty (like hand if forearm cut)
name = "media/ui/JCIO/Empty.png"
elseif not partData.isCut and
-- FIXME This doesn't work in MP on another player since we're trying to retrieve bodyDamage from another player
getPlayer():getBodyDamage():getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName)):bitten() then -- Not cut but bitten
name = "media/ui/TOC/" .. partName .. "/Bite.png"
name = "media/ui/JCIO/" .. partName .. "/Bite.png"
else -- Not cut
name = "media/ui/TOC/" .. partName .. "/Base.png"
name = "media/ui/JCIO/" .. partName .. "/Base.png"
end
-- If foreaerm equip, change hand
if partName == "Right_Hand" and limbsData["Right_LowerArm"].isProsthesisEquipped then
name = "media/ui/TOC/" .. partName .. "/Hook.png"
name = "media/ui/JCIO/" .. partName .. "/Hook.png"
elseif partName == "Left_Hand" and limbsData["Left_LowerArm"].isProsthesisEquipped then
name = "media/ui/TOC/" .. partName .. "/Hook.png"
name = "media/ui/JCIO/" .. partName .. "/Hook.png"
end
return name
end
@@ -149,7 +150,7 @@ JCIO_UI.SetupMainUI = function(surgeon, patient, limbsData)
if limbsData then
mainUI.limbs_data = limbsData
mainUI.limbsData = limbsData
mainUI["b11"]:setPath(GetImageName("Right_UpperArm", limbsData))
mainUI["b12"]:setPath(GetImageName("Left_UpperArm", limbsData))
@@ -170,7 +171,7 @@ end
JCIO_UI.SetupDescUI = function(surgeon, patient, limbsData, partName)
descUI["textTitle"]:setText(getText("UI_ContextMenu_" .. partName))
descUI.part_name = partName
descUI.partName = partName
descUI.surgeon = surgeon
descUI.patient = patient
@@ -289,34 +290,34 @@ end
------------------------------------------------
-- On Click Functions
local function OnClickTocMainUI(button, args)
local function OnClickMainUI(button, args)
descUI:open()
descUI:setPositionPixel(mainUI:getRight(), mainUI:getY())
JCIO_UI.SetupDescUI(mainUI.surgeon, mainUI.patient, mainUI.limbs_data, args.part_name) -- surgeon is generic.
JCIO_UI.SetupDescUI(mainUI.surgeon, mainUI.patient, mainUI.limbsData, args.part_name) -- surgeon is generic.
end
-- Generic TOC action, used in OnClickTocDescUI
local function TryTocAction(_, part_name, action, surgeon, patient)
-- Generic JCIO action, used in OnClickDescUI
local function TryJcioAction(_, partName, action, surgeon, patient)
-- TODO at this point surgeon doesnt do anything. We'll fix this later
-- Check if SinglePlayer
if not isServer() and not isClient() then
if action == "Cut" then
JCIO_LocalActions.Cut(_, surgeon, part_name)
JCIO_LocalActions.Cut(_, surgeon, partName)
elseif action == "Operate" then
JCIO_LocalActions.Operate(_, surgeon, part_name, false)
JCIO_LocalActions.Operate(_, surgeon, partName, false)
elseif action == "Equip" then
JCIO_LocalActions.EquipProsthesis(_, surgeon, part_name)
JCIO_LocalActions.EquipProsthesis(_, surgeon, partName)
elseif action == "Unequip" then
JCIO_LocalActions.UnequipProsthesis(_, surgeon, part_name)
JCIO_LocalActions.UnequipProsthesis(_, surgeon, partName)
end
else
local ui = GetConfirmUIMP()
if not ui then
CreateTocConfirmUIMP()
CreateConfirmUIMP()
ui = GetConfirmUIMP()
end
@@ -326,17 +327,17 @@ local function TryTocAction(_, part_name, action, surgeon, patient)
if action == "Cut" then
AskCanCutLimb(patient, part_name)
AskCanCutLimb(patient, partName)
elseif action == "Operate" then
AskCanOperateLimb(patient, part_name)
AskCanOperateLimb(patient, partName)
elseif action == "Equip" then
AskCanEquipProsthesis(patient, part_name)
AskCanEquipProsthesis(patient, partName)
elseif action == "Unequip" then
AskCanUnequipProsthesis(patient, part_name)
AskCanUnequipProsthesis(patient, partName)
end
ui.actionAct = action
ui.partNameAct = part_name
ui.partNameAct = partName
ui.patient = patient
SendCommandToConfirmUIMP("Wait server")
@@ -345,35 +346,36 @@ local function TryTocAction(_, part_name, action, surgeon, patient)
end
local function OnClickTocDescUI(button, args)
local function OnClickDescUI(button, args)
-- Gets every arg from main
local patient = descUI.patient
local surgeon = descUI.surgeon
if args.option ~= "Nothing" then
TryTocAction(_, descUI.part_name, args.option, surgeon, patient)
TryJcioAction(_, descUI.partName, args.option, surgeon, patient)
end
mainUI:close()
end
local function OnClickTocConfirmUIMP(button, args)
local function OnClickConfirmUIMP(button, args)
local player = getPlayer()
if confirmUIMP.actionAct == "Cut" and args.option == "yes" then
ISTimedActionQueue.add(JCIO_CutLimbAction:new(confirmUIMP.patient, player, confirmUIMP.partNameAct))
elseif confirmUIMP.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')
if item then
ISTimedActionQueue.add(JCIO_OperateLimbAction:new(confirmUIMP.patient, player, item, confirmUIMP.partNameAct,
local kit = JCIO_Common.GetKitInInventory(player)
if kit then
ISTimedActionQueue.add(JCIO_OperateLimbAction:new(confirmUIMP.patient, player, kit, confirmUIMP.partNameAct,
false))
else
player:Say("I need a kit")
end
elseif confirmUIMP.actionAct == "Equip" and args.option == "yes" then
-- TODO Gonna be broken soon!
local surgeon_inventory = player:getInventory()
local prosthesis_to_equip = surgeon_inventory:getItemFromType('TOC.MetalHand') or
@@ -415,42 +417,42 @@ end
-----------------------------------------------
-- CREATE UI SECTION
local function CreateTocMainUI()
local function CreateMainUI()
mainUI = NewUI()
mainUI:setTitle("The Only Cure Menu")
mainUI:setWidthPercent(0.1)
mainUI:addImageButton("b11", "", OnClickTocMainUI)
mainUI:addImageButton("b11", "", OnClickMainUI)
mainUI["b11"]:addArg("part_name", "Right_UpperArm")
mainUI:addImageButton("b12", "", OnClickTocMainUI)
mainUI:addImageButton("b12", "", OnClickMainUI)
mainUI["b12"]:addArg("part_name", "Left_UpperArm")
mainUI:nextLine()
mainUI:addImageButton("b21", "", OnClickTocMainUI)
mainUI:addImageButton("b21", "", OnClickMainUI)
mainUI["b21"]:addArg("part_name", "Right_LowerArm")
mainUI:addImageButton("b22", "", OnClickTocMainUI)
mainUI:addImageButton("b22", "", OnClickMainUI)
mainUI["b22"]:addArg("part_name", "Left_LowerArm")
mainUI:nextLine()
mainUI:addImageButton("b31", "", OnClickTocMainUI)
mainUI:addImageButton("b31", "", OnClickMainUI)
mainUI["b31"]:addArg("part_name", "Right_Hand")
mainUI:addImageButton("b32", "", OnClickTocMainUI)
mainUI:addImageButton("b32", "", OnClickMainUI)
mainUI["b32"]:addArg("part_name", "Left_Hand")
mainUI:nextLine()
mainUI:addImageButton("b41", "", OnClickTocMainUI)
mainUI:addImageButton("b41", "", OnClickMainUI)
mainUI["b41"]:addArg("part_name", "Right_Foot")
mainUI:addImageButton("b42", "", OnClickTocMainUI)
mainUI:addImageButton("b42", "", OnClickMainUI)
mainUI["b42"]:addArg("part_name", "Left_Foot")
mainUI:saveLayout()
@@ -459,7 +461,7 @@ local function CreateTocMainUI()
end
-- Create a temporary desc UI with fake data (for now)
local function CreateTocDescUI()
local function CreateDescUI()
descUI = NewUI()
descUI:setTitle("The only cure description");
descUI:isSubUIOf(mainUI)
@@ -492,12 +494,12 @@ local function CreateTocDescUI()
descUI:addEmpty()
descUI:nextLine()
descUI:addButton("b1", "Operate", OnClickTocDescUI)
descUI:addButton("b1", "Operate", OnClickDescUI)
descUI:saveLayout()
end
function CreateTocConfirmUIMP()
function CreateConfirmUIMP()
confirmUIMP = NewUI()
confirmUIMP.responseReceive = false
@@ -519,10 +521,10 @@ function CreateTocConfirmUIMP()
confirmUIMP:nextLine();
confirmUIMP:addEmpty();
confirmUIMP:addButton("b1", "Yes", OnClickTocConfirmUIMP);
confirmUIMP:addButton("b1", "Yes", OnClickConfirmUIMP);
confirmUIMP.b1:addArg("option", "yes");
confirmUIMP:addEmpty();
confirmUIMP:addButton("b2", "No", OnClickTocConfirmUIMP);
confirmUIMP:addButton("b2", "No", OnClickConfirmUIMP);
confirmUIMP:addEmpty();
confirmUIMP:nextLine();
@@ -537,11 +539,11 @@ end
-- We create everything from here
JCIO_UI.OnCreate = function()
CreateTocMainUI()
CreateTocDescUI()
CreateTocConfirmUIMP()
CreateMainUI()
CreateDescUI()
CreateConfirmUIMP()
if isClient() then CreateTocConfirmUIMP() end
if isClient() then CreateConfirmUIMP() end
mainUI:close()
end
@@ -578,7 +580,7 @@ function SendCommandToConfirmUIMP(action, isBitten, userName, partName)
end
--------------------------------------------
-- Add TOC element to Health Panel
-- Add JCIO element to Health Panel
@@ -676,22 +678,22 @@ function ISHealthPanel:createChildren()
self.fitness:setWidth(self.fitness:getWidth() / 1.4)
self.TOCButton = ISButton:new(self.fitness:getRight() + 10, self.healthPanel.y, 60, 20, "", self,
self.JCIOButton = ISButton:new(self.fitness:getRight() + 10, self.healthPanel.y, 60, 20, "", self,
ISNewHealthPanel.onClickJCIO)
self.TOCButton:setImage(getTexture("media/ui/TOC/iconForMenu.png"))
self.TOCButton.anchorTop = false
self.TOCButton.anchorBottom = true
self.TOCButton:initialise()
self.TOCButton:instantiate()
self:addChild(self.TOCButton)
self.JCIOButton:setImage(getTexture("media/ui/JCIO/iconForMenu.png"))
self.JCIOButton.anchorTop = false
self.JCIOButton.anchorBottom = true
self.JCIOButton:initialise()
self.JCIOButton:instantiate()
self:addChild(self.JCIOButton)
if getCore():getGameMode() == "Tutorial" then
self.TOCButton:setVisible(false)
self.JCIOButton:setVisible(false)
end
end
function ISHealthPanel:render()
ISHealthPanel_render(self);
self.TOCButton:setY(self.fitness:getY());
self.JCIOButton:setY(self.fitness:getY());
end
-- EVENTS

View File

@@ -27,8 +27,8 @@ JCIO_Cheat.ResetEverything = function()
-- Destroy the amputation or prosthesis item
for _, partName in pairs(JCIO_Common.GetPartNames()) do
local amputationItemName = TocFindAmputationOrProsthesisName(partName, player, "Amputation")
local prostItemName = TocFindAmputationOrProsthesisName(partName, player, "Prosthesis")
local amputationItemName = JCIO_Common.FindAmputationOrProsthesisName(partName, player, "Amputation")
local prostItemName = JCIO_Common.FindAmputationOrProsthesisName(partName, player, "Prosthesis")
if amputationItemName ~= nil then
local amputationItem = playerInv:FindAndReturn(amputationItemName)
if amputationItem ~= nil then

View File

@@ -73,11 +73,11 @@ function GetProsthesisList()
end
function JCIO_Common.FindAmputatedClothingName(partName)
JCIO_Common.FindAmputatedClothingName = function(partName)
return "JCIO.Amputation_" .. partName
end
function JCIO_Common.GetPartNameFromBodyPartType(bodyPartType)
JCIO_Common.GetPartNameFromBodyPartType = function(bodyPartType)
if bodyPartType == BodyPartType.Hand_R then
return "Right_Hand"
@@ -99,7 +99,7 @@ end
-- 1:1 map of part_name to BodyPartType
function JCIO_Common.GetBodyPartFromPartName(partName)
JCIO_Common.GetBodyPartFromPartName = function(partName)
if partName == "Right_Hand" then return BodyPartType.Hand_R end
if partName == "Right_LowerArm" then return BodyPartType.ForeArm_R end
if partName == "Right_UpperArm" then return BodyPartType.UpperArm_R end
@@ -114,7 +114,7 @@ function JCIO_Common.GetBodyPartFromPartName(partName)
end
-- Custom mapping to make more sense when cutting a limb
function JCIO_Common.GetAdjacentBodyPartFromPartName(partName)
JCIO_Common.GetAdjacentBodyPartFromPartName = function(partName)
if partName == "Right_Hand" then return BodyPartType.ForeArm_R end
if partName == "Right_LowerArm" then return BodyPartType.UpperArm_R end
@@ -139,12 +139,12 @@ end
JCIO_Common.GetAmputationItemInInventory = function(player, partName)
local playerInv = player:getInventory()
local amputationItemName = TocFindAmputationOrProsthesisName(partName, player, "Amputation")
local amputationItemName = JCIO_Common.FindAmputationOrProsthesisName(partName, player, "Amputation")
local amputationItem = playerInv:FindAndReturn(amputationItemName)
return amputationItem
end
function JCIO_Common.GetSawInInventory(surgeon)
JCIO_Common.GetSawInInventory = function(surgeon)
local playerInv = surgeon:getInventory()
local item = playerInv:getItemFromType("Saw") or playerInv:getItemFromType("GardenSaw") or
@@ -160,7 +160,7 @@ end
-----------------------------------------
-- MP HANDLING CHECKS
function JCIO_Common.CheckIfCanBeCut(partName, limbsData)
JCIO_Common.CheckIfCanBeCut = function(partName, limbsData)
if limbsData == nil then
limbsData = getPlayer():getModData().JCIO.limbs
@@ -173,7 +173,7 @@ function JCIO_Common.CheckIfCanBeCut(partName, limbsData)
end
function JCIO_Common.CheckIfCanBeOperated(partName, limbsData)
JCIO_Common.CheckIfCanBeOperated = function(partName, limbsData)
if limbsData == nil then
limbsData = getPlayer():getModData().JCIO.limbs
@@ -183,13 +183,13 @@ function JCIO_Common.CheckIfCanBeOperated(partName, limbsData)
end
function JCIO_Common.CheckIfProsthesisCanBeEquipped(partName)
JCIO_Common.CheckIfProsthesisCanBeEquipped = function(partName)
local limbs_data = getPlayer():getModData().JCIO.limbs
return limbs_data[partName].isCauterized or limbs_data[partName].isCicatrized
-- check if prosthesis is in the surgeon inventory... we need to get it before
end
function JCIO_Common.CheckIfProsthesisCanBeUnequipped(partName)
JCIO_Common.CheckIfProsthesisCanBeUnequipped = function(partName)
-- TODO we should get item here to be sure that we can do this action instead of relying on some later checks
return true
@@ -201,7 +201,7 @@ end
-- Various checks
-----------------------------------------
function JCIO_Common.CheckIfItemIsAmputatedLimb(item)
JCIO_Common.CheckIfItemIsAmputatedLimb = function(item)
local itemFullType = item:getFullType()
local check
@@ -232,7 +232,7 @@ function CheckIfItemIsProsthesis(item)
end
function JCIO_Common.CheckIfItemIsInstalledProsthesis(item)
JCIO_Common.CheckIfItemIsInstalledProsthesis = function(item)
local itemFullType = item:getFullType()
if string.find(itemFullType, "TOC.Prost_") then
return true
@@ -242,7 +242,7 @@ function JCIO_Common.CheckIfItemIsInstalledProsthesis(item)
end
function JCIO_Common.CheckIfProsthesisAlreadyInstalled(limbsData, partName)
JCIO_Common.CheckIfProsthesisAlreadyInstalled = function(limbsData, partName)
for _, side in pairs(JCIO.sideNames) do
if string.find(partName, side) then
@@ -252,8 +252,7 @@ function JCIO_Common.CheckIfProsthesisAlreadyInstalled(limbsData, partName)
end
function JCIO_Common.GetCanBeHeldTable(limbs_data)
JCIO_Common.GetCanBeHeldTable = function(limbs_data)
local canBeHeld = {}

View File

@@ -1,8 +1,8 @@
-- TODO this needs to be moved away
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')
function JCIO_Common.GetKitInInventory(surgeon)
local playerInv = surgeon:getInventory()
local item = playerInv:getItemFromType('JCIO.Real_surgeon_kit') or playerInv:getItemFromType('JCIO.Surgeon_kit') or
playerInv:getItemFromType('JCIO.Improvised_surgeon_kit')
return item
end
@@ -30,12 +30,13 @@ local function PartNameToBodyLocationAmputation(name)
if name == "Right_Foot" then return "JCIO_LegRight" end
end
function TocFindItemInProstBodyLocation(partName, patient)
function JCIO_Common.FindItemInProstBodyLocation(partName, patient)
-- Can't be used for online purposes, since we can't get the online inventory of another player
local worn_items = patient:getWornItems()
local wornItems = patient:getWornItems()
for i = 1, worn_items:size() - 1 do -- Maybe wornItems:size()-1
local item = worn_items:get(i):getItem()
-- Particular case where i= 1 and size - 1 I guess?
for i = 1, wornItems:size() - 1 do
local item = wornItems:get(i):getItem()
if item:getBodyLocation() == PartNameToBodyLocationProsthesis(partName) then
return item
end
@@ -44,10 +45,10 @@ function TocFindItemInProstBodyLocation(partName, patient)
end
-- Debug cheat and update every minute for cicatrization
function TocFindAmputationOrProsthesisName(partName, player, choice)
local worn_items = player:getWornItems()
for i = 1, worn_items:size() - 1 do
local item = worn_items:get(i):getItem()
function JCIO_Common.FindAmputationOrProsthesisName(partName, player, choice)
local wornItems = player:getWornItems()
for i = 1, wornItems:size() - 1 do
local item = wornItems:get(i):getItem()
if choice == "Amputation" then

View File

@@ -73,7 +73,7 @@ JCIO.InitPart = function(limbs_data, part_name)
end
JCIO.SetInitData = function(modData, player)
print("JCIO: Creating mod_data.TOC")
print("JCIO: Creating mod_data.JCIO")
--------
-- NEW NAMING SCHEME

View File

@@ -70,9 +70,9 @@ function GenerateEquippedProsthesis(prosthesis_item, inventory, limb)
-- Check the item mod data if the values are different than the default values
if item_mod_data.TOC ~= nil then
durability_base = item_mod_data.base_durability
durability_top = item_mod_data.top_durability
if item_mod_data.JCIO ~= nil then
durability_base = item_mod_data.baseDurability
durability_top = item_mod_data.topDurability
-- else
-- durability_base, speed_base = GetProsthesisStats(base_table, prosthesis_name)
-- durability_top, speed_top = GetProsthesisStats(top_table, prosthesis_name)
@@ -127,45 +127,45 @@ function ProsthesisRecipes.OnCreateProsthesis(items, result, player, selectedIte
result:setCondition(condition) -- Should be the sum?
result:getModData().TOC = {
base_durability = 100,
top_durability = 100, -- Stores it here too so we can re-reference it for later
result:getModData().JCIO = {
baseDurability = 100,
topDurability = 100, -- Stores it here too so we can re-reference it for later
}
end
-- Reassign the correct condition to each item
function ProsthesisRecipes.OnDisassembleProsthesis(item, result_items, player, selectedItem)
function ProsthesisRecipes.OnDisassembleProsthesis(item, resultItems, player, selectedItem)
-- Check durability of original item
local item_mod_data = item.getModData().TOC
local itemModData = item.getModData().JCIO
local durability_top = item_mod_data.top.durability
local durability_base = item_mod_data.base.durability
local durabilityTop = itemModData.top.durability
local durabilityBase = itemModData.base.durability
-- TODO do we actually need to store speed again?
local speed_top = item_mod_data.top.speed
local speed_base = item_mod_data.base.speed
local speedTop = itemModData.top.speed
local speedBase = itemModData.base.speed
-- Check name of the item
local prosthesis_item_name = item:getFullType()
local prosthesisItemName = item:getFullType()
local base_name = GetProsthesisPartName(base_table, prosthesis_item_name)
local top_name = GetProsthesisPartName(top_table, prosthesis_item_name)
local baseName = GetProsthesisPartName(base_table, prosthesisItemName)
local topName = GetProsthesisPartName(top_table, prosthesisItemName)
print("JCIO: " .. base_name .. " and " .. top_name)
print("JCIO: " .. baseName .. " and " .. topName)
local player_inv = player:getInventory()
local playerInv = player:getInventory()
local part_base = player_inv:AddItem("JCIO.ProstPart" .. base_name)
part_base:setCondition(durability_base)
local partBase = playerInv:AddItem("JCIO.ProstPart" .. baseName)
partBase:setCondition(durabilityBase)
local part_top = player_inv:AddItem("JCIO.ProstPart" .. top_name)
part_top:setCondition(durability_top)
local partTop = playerInv:AddItem("JCIO.ProstPart" .. topName)
partTop:setCondition(durabilityTop)
-- TODO Add Screws from the item back with a chance of them breaking

View File

@@ -129,7 +129,7 @@ end
ServerCommands.AcceptDamageOtherPlayer = function(arg)
local patient = getPlayerByOnlineID(arg[1])
local part_name = arg[2]
TocDamagePlayerDuringAmputation(patient, part_name)
JCIO.DamagePlayerDuringAmputation(patient, part_name)
end
-- Used to propagate animation changes after amputating a foot

View File

@@ -78,10 +78,10 @@ function TocTestBodyLocations()
end
end
function TocTestItem()
function JCIOTestItem()
local player = getPlayer()
local player_inventory = player:getInventory()
local item_name = "TOC.Amputation_" .. "Right" .. "_" .. "Hand"
local item_name = "JCIO.Amputation_" .. "Right" .. "_" .. "Hand"
local found_item = player_inventory:FindAndReturn(item_name)
print(found_item:getID())

View File

@@ -128,7 +128,7 @@ local function SetHealthStatusForBodyPart(partData, partName, player)
if partData[partName].cicatrizationTime < 0 then
partData[partName].isCicatrized = true
local playerInv = player:getInventory()
local amputatedClothingItemName = TocFindAmputationOrProsthesisName(partName, player, "Amputation")
local amputatedClothingItemName = JCIO_Common.FindAmputationOrProsthesisName(partName, player, "Amputation")
local amputatedClothingItem = playerInv:FindAndReturn(amputatedClothingItemName)
player:removeWornItem(amputatedClothingItem)
@@ -170,10 +170,8 @@ JCIO.UpdateOnTick = function()
return
end
--local toc_data = player:getModData().TOC
local jcioModData = player:getModData().JCIO
if jcioModData ~= nil then
CheckIfPlayerIsInfected(player, jcioModData.limbs)
UpdatePlayerHealth(player, jcioModData.limbs)
@@ -239,7 +237,7 @@ JCIO.UpdateEveryOneMinute = function()
-- Updates toc data in a global way, basically player:transmitModData but it works
-- Updates JCIO data in a global way, basically player:transmitModData but it works
-- Sends only Limbs since the other stuff is mostly static
if jcioModData ~= nil then
-- FIXME Send little packets instead of the whole thing?

View File

@@ -57,56 +57,4 @@ JCIO_Visuals.SetBloodOnAmputation = function(player, bodyPart)
player:addBlood(bloodBodyPartType, false, true, false)
player:addBlood(BloodBodyPartType.Torso_Lower, false, true, false)
end
function TocSetCorrectTextureForAmputation(item, player, cicatrized)
local human_visual = player:getHumanVisual()
local texture_string = human_visual:getSkinTexture()
local is_hairy = string.find(texture_string, "a$")
-- Hairy bodies
if is_hairy then
texture_string = texture_string:sub(1, -2) -- Removes b at the end to make it compatible
end
local matched_index = string.match(texture_string, "%d$")
if is_hairy then
matched_index = matched_index + 5
end
if cicatrized then
if is_hairy then
matched_index = matched_index + 5 -- to use the cicatrized texture on hairy bodies
else
matched_index = matched_index + 10 -- cicatrized texture only, no hairs
end
end
--print("JCIO: Setting texture " .. matched_index)
item:getVisual():setTextureChoice(tonumber(matched_index - 1)) -- it counts from 0, so we have to subtract 1
end
function TocSetBloodOnAmputation(player, body_part)
local body_part_type = body_part:getType()
local blood_body_part_type
if body_part_type == BodyPartType.Hand_R then
blood_body_part_type = BloodBodyPartType.ForeArm_R
elseif body_part_type == BodyPartType.Hand_L then
blood_body_part_type = BloodBodyPartType.ForeArm_L
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
end
--print("JCIO: Adding blood based on " .. tostring(body_part_type))
player:addBlood(blood_body_part_type, false, true, false)
player:addBlood(BloodBodyPartType.Torso_Lower, false, true, false)
end

View File

@@ -61,7 +61,7 @@ function JCIO_CutLimbAction:start()
end
if self.patient == self.surgeon then
TocDamagePlayerDuringAmputation(self.patient, self.partName)
JCIO.DamagePlayerDuringAmputation(self.patient, self.partName)
else
sendClientCommand(self.surgeon, "JCIO", "AskDamageOtherPlayer", {self.patient:getOnlineID(), self.partName})
end

View File

@@ -65,7 +65,7 @@ function JCIO_UninstallProsthesisAction:new(surgeon, patient, partName)
local limbsData = patient:getModData().JCIO.limbs
o.item = TocFindItemInProstBodyLocation(partName, patient)
o.item = JCIO_Common.FindItemInProstBodyLocation(partName, patient)
o.character = surgeon -- For animation purposes
o.patient = patient

View File

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 671 B

After

Width:  |  Height:  |  Size: 671 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 381 B

View File

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 683 B

View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

View File

Before

Width:  |  Height:  |  Size: 843 B

After

Width:  |  Height:  |  Size: 843 B

View File

Before

Width:  |  Height:  |  Size: 641 B

After

Width:  |  Height:  |  Size: 641 B

View File

Before

Width:  |  Height:  |  Size: 671 B

After

Width:  |  Height:  |  Size: 671 B

View File

Before

Width:  |  Height:  |  Size: 512 B

After

Width:  |  Height:  |  Size: 512 B

View File

Before

Width:  |  Height:  |  Size: 298 B

After

Width:  |  Height:  |  Size: 298 B

View File

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 683 B

View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

View File

Before

Width:  |  Height:  |  Size: 444 B

After

Width:  |  Height:  |  Size: 444 B

View File

Before

Width:  |  Height:  |  Size: 677 B

After

Width:  |  Height:  |  Size: 677 B

View File

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

View File

Before

Width:  |  Height:  |  Size: 617 B

After

Width:  |  Height:  |  Size: 617 B

View File

Before

Width:  |  Height:  |  Size: 393 B

After

Width:  |  Height:  |  Size: 393 B

View File

Before

Width:  |  Height:  |  Size: 541 B

After

Width:  |  Height:  |  Size: 541 B

View File

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 855 B

View File

Before

Width:  |  Height:  |  Size: 513 B

After

Width:  |  Height:  |  Size: 513 B

View File

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 552 B

View File

Before

Width:  |  Height:  |  Size: 893 B

After

Width:  |  Height:  |  Size: 893 B

View File

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 781 B

View File

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 842 B

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 671 B

After

Width:  |  Height:  |  Size: 671 B

View File

Before

Width:  |  Height:  |  Size: 981 B

After

Width:  |  Height:  |  Size: 981 B

View File

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 282 B

View File

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 683 B

View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

View File

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 680 B

View File

Before

Width:  |  Height:  |  Size: 658 B

After

Width:  |  Height:  |  Size: 658 B

View File

Before

Width:  |  Height:  |  Size: 683 B

After

Width:  |  Height:  |  Size: 683 B

View File

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 521 B

View File

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 302 B

View File

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 692 B

View File

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 723 B

View File

Before

Width:  |  Height:  |  Size: 445 B

After

Width:  |  Height:  |  Size: 445 B

View File

Before

Width:  |  Height:  |  Size: 668 B

After

Width:  |  Height:  |  Size: 668 B

View File

Before

Width:  |  Height:  |  Size: 691 B

After

Width:  |  Height:  |  Size: 691 B

View File

Before

Width:  |  Height:  |  Size: 607 B

After

Width:  |  Height:  |  Size: 607 B

View File

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

View File

Before

Width:  |  Height:  |  Size: 546 B

After

Width:  |  Height:  |  Size: 546 B

View File

Before

Width:  |  Height:  |  Size: 864 B

After

Width:  |  Height:  |  Size: 864 B

View File

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 516 B

View File

Before

Width:  |  Height:  |  Size: 557 B

After

Width:  |  Height:  |  Size: 557 B

View File

Before

Width:  |  Height:  |  Size: 888 B

After

Width:  |  Height:  |  Size: 888 B

View File

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

View File

Before

Width:  |  Height:  |  Size: 838 B

After

Width:  |  Height:  |  Size: 838 B

View File

Before

Width:  |  Height:  |  Size: 885 B

After

Width:  |  Height:  |  Size: 885 B