Some More stuff
This commit is contained in:
@@ -18,7 +18,7 @@ local function TocCheckIfStillInfected(limbs_data)
|
||||
local check = false
|
||||
|
||||
|
||||
for _, v in pairs(GetBodyParts()) do
|
||||
for _, v in pairs(JCIO_Common.GetPartNames()) do
|
||||
if limbs_data[v].is_infected then
|
||||
check = true
|
||||
end
|
||||
@@ -33,7 +33,7 @@ end
|
||||
|
||||
local function TocCureInfection(body_damage, part_name)
|
||||
|
||||
local body_part_type = body_damage:getBodyPart(TocGetBodyPartFromPartName(part_name))
|
||||
local body_part_type = body_damage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(part_name))
|
||||
|
||||
body_damage:setInfected(false)
|
||||
body_part_type:SetInfected(false)
|
||||
@@ -106,7 +106,7 @@ function TocDamagePlayerDuringAmputation(patient, part_name)
|
||||
|
||||
-- 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 = TocGetBodyPartFromPartName(part_name)
|
||||
local body_part_type = JCIO_Common.GetBodyPartFromPartName(part_name)
|
||||
local body_damage = patient:getBodyDamage()
|
||||
local body_damage_part = body_damage:getBodyPart(body_part_type)
|
||||
|
||||
@@ -158,8 +158,8 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
||||
-- Cut Forearm -> Damage in Upperarm
|
||||
-- Cut UpperArm -> Damage to torso
|
||||
local bodyDamage = player:getBodyDamage()
|
||||
local bodyPart = bodyDamage:getBodyPart(TocGetBodyPartFromPartName(partName))
|
||||
local adjacentBodyPart = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(partName))
|
||||
local bodyPart = bodyDamage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName))
|
||||
local adjacentBodyPart = player:getBodyDamage():getBodyPart(JCIO_Common.GetAdjacentBodyPartFromPartName(partName))
|
||||
|
||||
local stats = player:getStats()
|
||||
|
||||
@@ -170,7 +170,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
||||
TocSetParametersForMissingLimb(bodyPart, false)
|
||||
|
||||
-- Use a tourniquet if available
|
||||
local tourniquetItem = FindTourniquetInWornItems(player, TocGetSideFromPartName(partName))
|
||||
local tourniquetItem = FindTourniquetInWornItems(player, JCIO_Common.GetSideFromPartName(partName))
|
||||
|
||||
local baseDamageValue = 100
|
||||
|
||||
@@ -227,7 +227,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
||||
|
||||
local canHealDependedV = limbsData[depended_v].isInfected and
|
||||
bodyDamage:getInfectionLevel() < 20
|
||||
local depended_body_part = bodyDamage:getBodyPart(TocGetBodyPartFromPartName(depended_v))
|
||||
local depended_body_part = bodyDamage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(depended_v))
|
||||
TocSetParametersForMissingLimb(depended_body_part, canHealDependedV)
|
||||
|
||||
if canHealDependedV then
|
||||
@@ -264,7 +264,7 @@ JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
||||
TocDeleteOtherAmputatedLimbs(side)
|
||||
|
||||
--Equip new model for amputation
|
||||
local amputation_clothing_item_name = TocFindAmputatedClothingFromPartName(partName)
|
||||
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)
|
||||
|
||||
@@ -22,11 +22,11 @@ end
|
||||
local function SetBodyPartsStatusAfterOperation(player, limbParameters, partName, useOven)
|
||||
|
||||
|
||||
local bodyPartType = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(partName))
|
||||
local bodyPartType = player:getBodyDamage():getBodyPart(JCIO_Common.GetAdjacentBodyPartFromPartName(partName))
|
||||
FixSingleBodyPartType(bodyPartType, useOven)
|
||||
|
||||
for _, v in pairs(limbParameters[partName].dependsOn) do
|
||||
local dependedBodyPartType = player:getBodyDamage():getBodyPart(TocGetAdjacentBodyPartFromPartName(v))
|
||||
local dependedBodyPartType = player:getBodyDamage():getBodyPart(JCIO_Common.GetAdjacentBodyPartFromPartName(v))
|
||||
FixSingleBodyPartType(dependedBodyPartType, useOven)
|
||||
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
function TocCutLocal(_, player, part_name)
|
||||
if TocGetSawInInventory(player) ~= nil then
|
||||
if JCIO_Common.GetSawInInventory(player) ~= nil then
|
||||
ISTimedActionQueue.add(ISCutLimb:new(player, player, part_name))
|
||||
else
|
||||
player:Say("I don't have a saw on me")
|
||||
|
||||
123
media/lua/client/Interface/JCIO_ContextMenus.lua
Normal file
123
media/lua/client/Interface/JCIO_ContextMenus.lua
Normal file
@@ -0,0 +1,123 @@
|
||||
-- TODO this should be moved
|
||||
|
||||
local function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
|
||||
sendClientCommand(surgeon, "JCIO", "AskToResetEverything", { patient:getOnlineID() })
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
if JCIO_ContextMenu == nil then
|
||||
JCIO_ContextMenu = {}
|
||||
end
|
||||
|
||||
JCIO_ContextMenu.CreateCheatsMenu = function(playerId, context, worldObjects, _)
|
||||
local clickedPlayers = {}
|
||||
local currentClickedPlayer = nil
|
||||
|
||||
local localPlayer = getSpecificPlayer(playerId)
|
||||
--local players = getOnlinePlayers()
|
||||
|
||||
for _, v in pairs(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())
|
||||
if sq then
|
||||
for i = 0, sq:getMovingObjects():size() - 1 do
|
||||
local o = sq:getMovingObjects():get(i)
|
||||
if instanceof(o, "IsoPlayer") then
|
||||
currentClickedPlayer = o
|
||||
|
||||
if clickedPlayers[currentClickedPlayer:getUsername()] == nil then
|
||||
|
||||
-- FIXME this is to prevent context menu spamming. Find a better way
|
||||
clickedPlayers[currentClickedPlayer:getUsername()] = true
|
||||
|
||||
if localPlayer:getAccessLevel() == "Admin" or isDebugEnabled() then
|
||||
local rootOption = context:addOption("Just Cut It Off Cheats on " .. currentClickedPlayer:getUsername())
|
||||
local rootMenu = context:getNew(context)
|
||||
|
||||
if currentClickedPlayer == localPlayer then
|
||||
rootMenu:addOption("Reset JCIO for me", _, JCIO_Cheat.ResetEverything)
|
||||
|
||||
else
|
||||
rootMenu:addOption("Reset JCIO for " .. currentClickedPlayer:getUsername(), _, TryToToResetEverythingOtherPlayer,
|
||||
currentClickedPlayer, localPlayer)
|
||||
|
||||
end
|
||||
context:addSubMenu(rootOption, rootMenu)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects,
|
||||
-- cut_menu, operate_menu)
|
||||
--TocContextMenus.FillCheatMenu(context, cheat_menu)
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
JCIO_ContextMenu.CreateOperateWithOvenMenu = function(playerId, context, worldObjects, test)
|
||||
local player = getSpecificPlayer(playerId)
|
||||
-- TODO Let the player move towards the oven
|
||||
|
||||
local partData = player:getModData().JCIO.limbs
|
||||
local isMainMenuAlreadyCreated = false
|
||||
|
||||
for _, currentObject in pairs(worldObjects) do
|
||||
if instanceof(currentObject, "IsoStove") and (player:HasTrait("Brave") or player:getPerkLevel(Perks.Strength) >= 6) then
|
||||
|
||||
-- Check temperature
|
||||
if currentObject:getCurrentTemperature() > 250 then
|
||||
|
||||
for _, partName in ipairs(JCIO_Common.GetPartNames()) do
|
||||
if partData[partName].isCut and partData[partName].isAmputationShown and
|
||||
not partData[partName].isOperated then
|
||||
local subMenu = context:getNew(context);
|
||||
|
||||
if isMainMenuAlreadyCreated == false then
|
||||
local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldObjects, nil);
|
||||
context:addSubMenu(rootMenu, subMenu)
|
||||
isMainMenuAlreadyCreated = true
|
||||
end
|
||||
subMenu:addOption(getText('UI_ContextMenu_' .. partName), worldObjects, TocOperateLocal,
|
||||
getSpecificPlayer(playerId), partName,true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
break -- stop searching for stoves
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
JCIO_ContextMenu.CreateNewMenu = function(name, context, rootMenu)
|
||||
|
||||
local new_option = rootMenu:addOption(name)
|
||||
local new_menu = context:getNew(context)
|
||||
context:addSubMenu(new_option, new_menu)
|
||||
|
||||
return new_menu
|
||||
end
|
||||
|
||||
JCIO_ContextMenu.FillCheatMenus = function(context, cheat_menu)
|
||||
|
||||
if cheat_menu then
|
||||
local cheat_cut_and_fix_menu = JCIO_ContextMenu.CreateNewMenu("Cut and Fix", context, cheat_menu)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Events.OnFillWorldObjectContextMenu.Add(JCIO_ContextMenu.CreateOperateWithOvenMenu) -- this is probably too much
|
||||
Events.OnFillWorldObjectContextMenu.Add(JCIO_ContextMenu.CreateCheatsMenu) -- TODO Add check only when admin is active
|
||||
@@ -60,7 +60,7 @@ local function GetImageName(partName, limbsData)
|
||||
name = "media/ui/TOC/Empty.png"
|
||||
elseif not part_data.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(TocGetBodyPartFromPartName(partName)):bitten() then -- Not cut but bitten
|
||||
getPlayer():getBodyDamage():getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName)):bitten() then -- Not cut but bitten
|
||||
name = "media/ui/TOC/" .. partName .. "/Bite.png"
|
||||
else -- Not cut
|
||||
name = "media/ui/TOC/" .. partName .. "/Base.png"
|
||||
@@ -100,7 +100,7 @@ end
|
||||
|
||||
local function IsPartBitten(partData, partName)
|
||||
return not partData.isCut and
|
||||
getPlayer():getBodyDamage():getBodyPart(TocGetBodyPartFromPartName(partName)):bitten()
|
||||
getPlayer():getBodyDamage():getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName)):bitten()
|
||||
end
|
||||
|
||||
local function FindMinMax(lv)
|
||||
@@ -243,11 +243,11 @@ JCIO_UI.SetupDescUI = function(surgeon, patient, limbsData, partName)
|
||||
-- TODO add check for cuts and scratches
|
||||
descUI["status"]:setText("Not cut")
|
||||
descUI["status"]:setColor(1, 1, 1, 1)
|
||||
if TocGetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(limbsData, partName) then
|
||||
if JCIO_Common.GetSawInInventory(surgeon) and not CheckIfProsthesisAlreadyInstalled(limbsData, partName) then
|
||||
descUI["b1"]:setVisible(true)
|
||||
descUI["b1"]:setText("Cut")
|
||||
descUI["b1"]:addArg("option", "Cut")
|
||||
elseif TocGetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(limbsData, partName) then
|
||||
elseif JCIO_Common.GetSawInInventory(surgeon) and CheckIfProsthesisAlreadyInstalled(limbsData, partName) then
|
||||
descUI["b1"]:setVisible(true)
|
||||
descUI["b1"]:setText("Remove prosthesis before")
|
||||
descUI["b1"]:addArg("option", "Nothing")
|
||||
@@ -582,18 +582,18 @@ end
|
||||
|
||||
|
||||
|
||||
TocTempTable = {patient = nil, surgeon = nil}
|
||||
JCIO_UI.onlineTempTable = {patient = nil, surgeon = nil}
|
||||
|
||||
JCIO.RefreshClientMenu = function(_)
|
||||
if mainUI:getIsVisible() == false then
|
||||
Events.OnTick.Remove(JCIO.RefreshClientMenu)
|
||||
TocTempTable.patient = nil
|
||||
TocTempTable.surgeon = nil
|
||||
JCIO_UI.onlineTempTable.patient = nil
|
||||
JCIO_UI.onlineTempTable.surgeon = nil
|
||||
|
||||
else
|
||||
|
||||
local limbs_data = TocTempTable.patient:getModData().TOC.Limbs
|
||||
JCIO_UI.SetupMainUI(TocTempTable.patient, TocTempTable.patient, limbs_data)
|
||||
local limbs_data = JCIO_UI.onlineTempTable.patient:getModData().TOC.Limbs
|
||||
JCIO_UI.SetupMainUI(JCIO_UI.onlineTempTable.patient, JCIO_UI.onlineTempTable.patient, limbs_data)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -604,14 +604,14 @@ JCIO.RefreshOtherPlayerMenu = function(_)
|
||||
if mainUI:getIsVisible() == false then
|
||||
|
||||
Events.OnTick.Remove(JCIO.RefreshOtherPlayerMenu)
|
||||
TocTempTable.patient = nil
|
||||
TocTempTable.surgeon = nil
|
||||
JCIO_UI.onlineTempTable.patient = nil
|
||||
JCIO_UI.onlineTempTable.surgeon = nil
|
||||
|
||||
else
|
||||
if ModData.get("TOC_PLAYER_DATA")[TocTempTable.patient:getUsername()] ~= nil then
|
||||
local other_player_part_data = ModData.get("TOC_PLAYER_DATA")[TocTempTable.patient:getUsername()]
|
||||
if ModData.get("JCIO_PLAYER_DATA")[JCIO_UI.onlineTempTable.patient:getUsername()] ~= nil then
|
||||
local otherPlayerPartData = ModData.get("JCIO_PLAYER_DATA")[JCIO_UI.onlineTempTable.patient:getUsername()]
|
||||
|
||||
JCIO_UI.SetupMainUI(TocTempTable.surgeon, TocTempTable.patient, other_player_part_data[1])
|
||||
JCIO_UI.SetupMainUI(JCIO_UI.onlineTempTable.surgeon, JCIO_UI.onlineTempTable.patient, otherPlayerPartData[1])
|
||||
|
||||
|
||||
end
|
||||
@@ -630,8 +630,8 @@ function ISNewHealthPanel.onClickJCIO(button)
|
||||
local surgeon = button.otherPlayer
|
||||
local patient = button.character
|
||||
|
||||
TocTempTable.patient = patient
|
||||
TocTempTable.surgeon = surgeon
|
||||
JCIO_UI.onlineTempTable.patient = patient
|
||||
JCIO_UI.onlineTempTable.surgeon = surgeon
|
||||
|
||||
-- MP Handling
|
||||
if surgeon then
|
||||
@@ -671,10 +671,6 @@ function ISNewHealthPanel.onClickJCIO(button)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function ISHealthPanel:createChildren()
|
||||
ISHealthPanel_createChildren(self)
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
-- TODO this should be moved
|
||||
|
||||
local function TryToToResetEverythingOtherPlayer(_, patient, surgeon)
|
||||
sendClientCommand(surgeon, "TOC", "AskToResetEverything", { patient:getOnlineID() })
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------------------------------
|
||||
|
||||
TocContextMenus = {}
|
||||
|
||||
|
||||
TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
|
||||
local clicked_players_table = {}
|
||||
local clicked_player = nil
|
||||
|
||||
local local_player = getSpecificPlayer(player)
|
||||
--local players = getOnlinePlayers()
|
||||
|
||||
for k, v in pairs(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())
|
||||
if sq then
|
||||
for i = 0, sq:getMovingObjects():size() - 1 do
|
||||
local o = sq:getMovingObjects():get(i)
|
||||
if instanceof(o, "IsoPlayer") then
|
||||
clicked_player = o
|
||||
|
||||
if clicked_players_table[clicked_player:getUsername()] == nil then
|
||||
|
||||
-- FIXME this is to prevent context menu spamming. Find a better way
|
||||
clicked_players_table[clicked_player:getUsername()] = true
|
||||
|
||||
if local_player:getAccessLevel() == "Admin" or isDebugEnabled() then
|
||||
local root_option = context:addOption("The Only Cure Cheats on " .. clicked_player:getUsername())
|
||||
local root_menu = context:getNew(context)
|
||||
|
||||
if clicked_player == local_player then
|
||||
root_menu:addOption("Reset TOC for me", _, TocResetEverything)
|
||||
|
||||
else
|
||||
root_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer,
|
||||
clicked_player, local_player)
|
||||
|
||||
end
|
||||
context:addSubMenu(root_option, root_menu)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- TocContextMenus.FillCutAndOperateMenus(local_player, clicked_player, worldObjects,
|
||||
-- cut_menu, operate_menu)
|
||||
--TocContextMenus.FillCheatMenu(context, cheat_menu)
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjects, test)
|
||||
local player_obj = getSpecificPlayer(player)
|
||||
-- TODO Let the player move towards the oven
|
||||
|
||||
local part_data = player_obj:getModData().TOC.Limbs
|
||||
local is_main_menu_already_created = false
|
||||
|
||||
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
|
||||
|
||||
-- Check temperature
|
||||
if v_stove:getCurrentTemperature() > 250 then
|
||||
|
||||
-- ipairs here to keep the order
|
||||
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
|
||||
local subMenu = context:getNew(context);
|
||||
|
||||
if is_main_menu_already_created == false then
|
||||
local rootMenu = context:addOption(getText('UI_ContextMenu_OperateOven'), worldObjects, nil);
|
||||
context:addSubMenu(rootMenu, subMenu)
|
||||
is_main_menu_already_created = true
|
||||
end
|
||||
subMenu:addOption(getText('UI_ContextMenu_' .. v_bodypart), worldObjects, TocOperateLocal,
|
||||
getSpecificPlayer(player), v_bodypart,true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
break -- stop searching for stoves
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
TocContextMenus.CreateNewMenu = function(name, context, root_menu)
|
||||
|
||||
local new_option = root_menu:addOption(name)
|
||||
local new_menu = context:getNew(context)
|
||||
context:addSubMenu(new_option, new_menu)
|
||||
|
||||
return new_menu
|
||||
end
|
||||
|
||||
TocContextMenus.CreateCheatMenu = function(context, root_menu, local_player, clicked_player)
|
||||
if local_player:getAccessLevel() == "Admin" or isDebugEnabled() then
|
||||
|
||||
local cheat_menu = TocContextMenus.CreateNewMenu("Cheat", context, root_menu)
|
||||
|
||||
if clicked_player == local_player then
|
||||
cheat_menu:addOption("Reset TOC for me", _, TocResetEverything)
|
||||
|
||||
else
|
||||
cheat_menu:addOption("Reset TOC for " .. clicked_player:getUsername(), _, TryToToResetEverythingOtherPlayer,
|
||||
clicked_player, local_player)
|
||||
|
||||
end
|
||||
|
||||
return cheat_menu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
TocContextMenus.FillCheatMenus = function(context, cheat_menu)
|
||||
|
||||
if cheat_menu then
|
||||
local cheat_cut_and_fix_menu = TocContextMenus.CreateNewMenu("Cut and Fix", context, cheat_menu)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateOperateWithOvenMenu) -- this is probably too much
|
||||
Events.OnFillWorldObjectContextMenu.Add(TocContextMenus.CreateMenus)
|
||||
57
media/lua/client/JCIO_Cheats.lua
Normal file
57
media/lua/client/JCIO_Cheats.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
------------------------------------------
|
||||
------------- JUST CUT IT OFF ------------
|
||||
------------------------------------------
|
||||
---------------- CHEATS -----------------
|
||||
|
||||
|
||||
if JCIO_Cheat == nil then
|
||||
JCIO_Cheat = {}
|
||||
end
|
||||
|
||||
|
||||
JCIO_Cheat.ResetEverything = function()
|
||||
-- This has to be run on the local player to be sure that we're correctly reassigning everything
|
||||
local player = getPlayer()
|
||||
local playerInv = player:getInventory()
|
||||
local modData = player:getModData()
|
||||
modData.JCIO = nil
|
||||
|
||||
-- Removes traits just to be sure
|
||||
local customTraits = player:getTraits()
|
||||
customTraits:remove("Amputee_Hand")
|
||||
customTraits:remove("Amputee_LowerArm")
|
||||
customTraits:remove("Amputee_UpperArm")
|
||||
|
||||
|
||||
JCIO.Init(_, player)
|
||||
|
||||
-- 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")
|
||||
if amputationItemName ~= nil then
|
||||
local amputationItem = playerInv:FindAndReturn(amputationItemName)
|
||||
if amputationItem ~= nil then
|
||||
print("Resetting " .. amputationItem:getName())
|
||||
player:removeWornItem(amputationItem)
|
||||
player:getInventory():Remove(amputationItem)
|
||||
end
|
||||
amputationItem = nil -- reset it
|
||||
end
|
||||
if prostItemName ~= nil then
|
||||
local prostItem = playerInv:FindAndReturn(prostItemName)
|
||||
if prostItem ~= nil then
|
||||
print("Resetting " .. prostItem:getName())
|
||||
player:removeWornItem(prostItem)
|
||||
player:getInventory():Remove(prostItem)
|
||||
end
|
||||
prostItem = nil -- reset it
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Reset special flag for legs amputations
|
||||
JCIO_Anims.SetMissingFootAnimation(false)
|
||||
|
||||
end
|
||||
@@ -41,7 +41,7 @@ JCIO_Compat.MapOldDataToNew = function(modData)
|
||||
print("JCIO: found old data from TOC")
|
||||
|
||||
|
||||
TocResetEverything()
|
||||
JCIO_Cheat.ResetEverything()
|
||||
|
||||
-- Another check just in case the user is using Mr Bounty og version. I really don't wanna map that out so let's just reset everything directly
|
||||
|
||||
@@ -124,7 +124,7 @@ JCIO_Compat.MapOldDataToNew = function(modData)
|
||||
|
||||
if modData.JCIO.limbs[newName].isCut then
|
||||
print("JCIO: Found old cut limb, reapplying model")
|
||||
local cloth = getPlayer():getInventory():AddItem(TocFindAmputatedClothingFromPartName(newName))
|
||||
local cloth = getPlayer():getInventory():AddItem(JCIO_Common.FindAmputatedClothingName(newName))
|
||||
getPlayer():setWornItem(cloth:getBodyLocation(), cloth)
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ ServerCommands.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(TocGetBodyPartFromPartName(ui
|
||||
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(JCIO_Common.GetBodyPartFromPartName(ui
|
||||
.responsePartName)):bitten()
|
||||
end
|
||||
|
||||
@@ -113,7 +113,7 @@ ServerCommands.CanResetEverything = function(arg)
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
ServerCommands.ResetEverything = function(_)
|
||||
TocResetEverything()
|
||||
JCIO_Cheat.ResetEverything()
|
||||
end
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ end
|
||||
Events.OnReceiveGlobalModData.Add(TOC_OnReceiveGlobalModData)
|
||||
|
||||
function TOC_OnConnected()
|
||||
ModData.request("TOC_PLAYER_DATA")
|
||||
ModData.request("JCIO_PLAYER_DATA")
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,44 @@
|
||||
function GetBodyParts()
|
||||
local bodyparts = {
|
||||
"Right_Hand", "Right_LowerArm", "Right_UpperArm", "Left_Hand",
|
||||
"Left_LowerArm", "Left_UpperArm"
|
||||
}
|
||||
return bodyparts
|
||||
------------------------------------------
|
||||
------------- JUST CUT IT OFF ------------
|
||||
------------------------------------------
|
||||
------------ COMMON FUNCTIONS ------------
|
||||
|
||||
|
||||
|
||||
if JCIO_Common == nil then
|
||||
JCIO_Common = {}
|
||||
end
|
||||
|
||||
function GetProsthesisList()
|
||||
return {"WoodenHook", "MetalHook", "MetalHand"}
|
||||
|
||||
JCIO_Common.partNames = {}
|
||||
|
||||
JCIO_Common.GeneratePartNames = function()
|
||||
|
||||
local partNamesTable = {}
|
||||
for _, side in ipairs(JCIO.sideNames) do
|
||||
for _, limb in ipairs(JCIO.limbNames) do
|
||||
local tempPartName = side .. "_" .. limb
|
||||
table.insert(partNamesTable, tempPartName)
|
||||
end
|
||||
end
|
||||
|
||||
JCIO_Common.partNames = partNamesTable
|
||||
|
||||
end
|
||||
|
||||
function TocFindAmputatedClothingFromPartName(part_name)
|
||||
return "TOC.Amputation_" .. part_name
|
||||
|
||||
|
||||
JCIO_Common.GetPartNames = function()
|
||||
if JCIO_Common.partNames.size() == nil then
|
||||
JCIO_Common.GeneratePartNames()
|
||||
end
|
||||
|
||||
function GetLimbsBodyPartTypes()
|
||||
return JCIO_Common.partNames
|
||||
end
|
||||
|
||||
JCIO_Common.GetAcceptableBodyPartTypes = function()
|
||||
|
||||
-- TODO Add Foot_L and Foot_R
|
||||
return {
|
||||
BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.UpperArm_R,
|
||||
BodyPartType.Hand_L, BodyPartType.ForeArm_L, BodyPartType.UpperArm_L
|
||||
@@ -24,7 +46,7 @@ function GetLimbsBodyPartTypes()
|
||||
|
||||
end
|
||||
|
||||
function GetOtherBodyPartTypes()
|
||||
JCIO_Common.GetOtherBodyPartTypes = function()
|
||||
|
||||
return {
|
||||
BodyPartType.Torso_Upper, BodyPartType.Torso_Lower, BodyPartType.Head,
|
||||
@@ -36,28 +58,30 @@ function GetOtherBodyPartTypes()
|
||||
|
||||
end
|
||||
|
||||
function GetAcceptingProsthesisBodyPartTypes()
|
||||
|
||||
return {
|
||||
BodyPartType.Hand_R, BodyPartType.ForeArm_R, BodyPartType.Hand_L,
|
||||
BodyPartType.ForeArm_L
|
||||
}
|
||||
function GetProsthesisList()
|
||||
-- TODO Not gonna work anymore
|
||||
return {"WoodenHook", "MetalHook", "MetalHand"}
|
||||
|
||||
end
|
||||
|
||||
function TocGetPartNameFromBodyPartType(body_part)
|
||||
function JCIO_Common.FindAmputatedClothingName(partName)
|
||||
return "TOC.Amputation_" .. partName
|
||||
end
|
||||
|
||||
if body_part == BodyPartType.Hand_R then
|
||||
function JCIO_Common.GetPartNameFromBodyPartType(bodyPartType)
|
||||
|
||||
if bodyPartType == BodyPartType.Hand_R then
|
||||
return "Right_Hand"
|
||||
elseif body_part == BodyPartType.ForeArm_R then
|
||||
elseif bodyPartType == BodyPartType.ForeArm_R then
|
||||
return "Right_LowerArm"
|
||||
elseif body_part == BodyPartType.UpperArm_R then
|
||||
elseif bodyPartType == BodyPartType.UpperArm_R then
|
||||
return "Right_UpperArm"
|
||||
elseif body_part == BodyPartType.Hand_L then
|
||||
elseif bodyPartType == BodyPartType.Hand_L then
|
||||
return "Left_Hand"
|
||||
elseif body_part == BodyPartType.ForeArm_L then
|
||||
elseif bodyPartType == BodyPartType.ForeArm_L then
|
||||
return "Left_LowerArm"
|
||||
elseif body_part == BodyPartType.UpperArm_L then
|
||||
elseif bodyPartType == BodyPartType.UpperArm_L then
|
||||
return "Left_UpperArm"
|
||||
else
|
||||
return nil
|
||||
@@ -67,62 +91,65 @@ end
|
||||
|
||||
|
||||
-- 1:1 map of part_name to BodyPartType
|
||||
function TocGetBodyPartFromPartName(part_name)
|
||||
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_UpperArm" then return BodyPartType.UpperArm_R 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_UpperArm" then return BodyPartType.UpperArm_L end
|
||||
function JCIO_Common.GetBodyPartFromPartName(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
|
||||
if partName == "Left_Hand" then return BodyPartType.Hand_L end
|
||||
if partName == "Left_LowerArm" then return BodyPartType.ForeArm_L end
|
||||
if partName == "Left_UpperArm" then return BodyPartType.UpperArm_L end
|
||||
|
||||
-- New Legs stuff
|
||||
if part_name == "Right_Foot" then return BodyPartType.Foot_R end
|
||||
if part_name == "Left_Foot" then return BodyPartType.Foot_L end
|
||||
if partName == "Right_Foot" then return BodyPartType.Foot_R end
|
||||
if partName == "Left_Foot" then return BodyPartType.Foot_L end
|
||||
|
||||
end
|
||||
|
||||
-- Custom mapping to make more sense when cutting a limb
|
||||
function TocGetAdjacentBodyPartFromPartName(part_name)
|
||||
function JCIO_Common.GetAdjacentBodyPartFromPartName(partName)
|
||||
|
||||
if part_name == "Right_Hand" then return BodyPartType.ForeArm_R end
|
||||
if part_name == "Right_LowerArm" then return BodyPartType.UpperArm_R end
|
||||
if part_name == "Right_UpperArm" then return BodyPartType.Torso_Upper end
|
||||
if part_name == "Left_Hand" then return BodyPartType.ForeArm_L end
|
||||
if part_name == "Left_LowerArm" then return BodyPartType.UpperArm_L end
|
||||
if part_name == "Left_UpperArm" then return BodyPartType.Torso_Upper end
|
||||
|
||||
if part_name == "Right_Foot" then return BodyPartType.LowerLeg_R end
|
||||
if part_name == "Left_Foot" then return BodyPartType.LowerLeg_L end
|
||||
if partName == "Right_Hand" then return BodyPartType.ForeArm_R end
|
||||
if partName == "Right_LowerArm" then return BodyPartType.UpperArm_R end
|
||||
if partName == "Right_UpperArm" then return BodyPartType.Torso_Upper end
|
||||
if partName == "Left_Hand" then return BodyPartType.ForeArm_L end
|
||||
if partName == "Left_LowerArm" then return BodyPartType.UpperArm_L end
|
||||
if partName == "Left_UpperArm" then return BodyPartType.Torso_Upper end
|
||||
if partName == "Right_Foot" then return BodyPartType.LowerLeg_R end
|
||||
if partName == "Left_Foot" then return BodyPartType.LowerLeg_L end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function TocFindCorrectClothingProsthesis(item_name, part_name)
|
||||
function TocFindCorrectClothingProsthesis(itemName, partName)
|
||||
|
||||
local correct_name = "TOC.Prost_" .. part_name .. "_" .. item_name
|
||||
return correct_name
|
||||
-- TODO This is not gonna work soon, so don't use this
|
||||
local correctName = "TOC.Prost_" .. partName .. "_" .. itemName
|
||||
return correctName
|
||||
|
||||
end
|
||||
|
||||
function TocGetAmputationItemInInventory(player, part_name)
|
||||
JCIO_Common.GetAmputationItemInInventory = function(player, partName)
|
||||
|
||||
local player_inventory = player:getInventory()
|
||||
local amputation_item_name = TocFindAmputationOrProsthesisName(part_name, player, "Amputation")
|
||||
local amputation_item = player_inventory:FindAndReturn(amputation_item_name)
|
||||
return amputation_item
|
||||
local playerInv = player:getInventory()
|
||||
local amputationItemName = TocFindAmputationOrProsthesisName(partName, player, "Amputation")
|
||||
local amputationItem = playerInv:FindAndReturn(amputationItemName)
|
||||
return amputationItem
|
||||
end
|
||||
|
||||
function TocGetSawInInventory(surgeon)
|
||||
function JCIO_Common.GetSawInInventory(surgeon)
|
||||
|
||||
local player_inv = surgeon:getInventory()
|
||||
local item = player_inv:getItemFromType("Saw") or player_inv:getItemFromType("GardenSaw") or
|
||||
player_inv:getItemFromType("Chainsaw")
|
||||
local playerInv = surgeon:getInventory()
|
||||
local item = playerInv:getItemFromType("Saw") or playerInv:getItemFromType("GardenSaw") or
|
||||
playerInv:getItemFromType("Chainsaw")
|
||||
return item
|
||||
end
|
||||
|
||||
function TocGetSideFromPartName(part_name)
|
||||
|
||||
if string.find(part_name, "Left") then
|
||||
|
||||
|
||||
function JCIO_Common.GetSideFromPartName(partName)
|
||||
|
||||
if string.find(partName, "Left") then
|
||||
return "Left"
|
||||
else
|
||||
return "Right"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
------------------------------------------
|
||||
-------- JUST CUT IT OFF --------
|
||||
------------- JUST CUT IT OFF ------------
|
||||
------------------------------------------
|
||||
------------ DEBUG FUNCTIONS -------------
|
||||
--------- TEST AND DEBUG FUNCTIONS -------
|
||||
|
||||
------ TEST FUNCTIONS, DON'T USE THESE!!! ---------------
|
||||
|
||||
-- Side functions
|
||||
local function TocGetAmputationFullTypeFromInventory(player, side, limb)
|
||||
@@ -27,61 +28,6 @@ local function TocGetEquippedProsthesisFullTypeFromInventory(player, side, limb)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TocResetEverything()
|
||||
-- This has to be run on the local player to be sure that we're correctly reassigning everything
|
||||
local player = getPlayer()
|
||||
local player_inventory = player:getInventory()
|
||||
local mod_data = player:getModData()
|
||||
mod_data.TOC = nil
|
||||
|
||||
-- Removes traits just to be sure
|
||||
local toc_traits = player:getTraits()
|
||||
toc_traits:remove("Amputee_Hand")
|
||||
toc_traits:remove("Amputee_LowerArm")
|
||||
toc_traits:remove("Amputee_UpperArm")
|
||||
|
||||
|
||||
JCIO.Init(_, player)
|
||||
|
||||
-- Destroy the amputation or prosthesis item
|
||||
|
||||
for _, side in pairs(JCIO.sideNames) do
|
||||
for _, limb in pairs(JCIO.limbNames) do
|
||||
|
||||
local part_name = side .. "_" .. limb
|
||||
local amputation_item_name = TocFindAmputationOrProsthesisName(part_name, player, "Amputation")
|
||||
local prosthesis_item_name = TocFindAmputationOrProsthesisName(part_name, player, "Prosthesis")
|
||||
if amputation_item_name ~= nil then
|
||||
local amputation_item = player_inventory:FindAndReturn(amputation_item_name)
|
||||
if amputation_item ~= nil then
|
||||
print("Resetting " .. amputation_item:getName())
|
||||
player:removeWornItem(amputation_item)
|
||||
player:getInventory():Remove(amputation_item)
|
||||
end
|
||||
amputation_item = nil -- reset it
|
||||
end
|
||||
if prosthesis_item_name ~= nil then
|
||||
local prosthesis_item = player_inventory:FindAndReturn(prosthesis_item_name)
|
||||
if prosthesis_item ~= nil then
|
||||
print("Resetting " .. prosthesis_item:getName())
|
||||
player:removeWornItem(prosthesis_item)
|
||||
player:getInventory():Remove(prosthesis_item)
|
||||
end
|
||||
prosthesis_item = nil -- reset it
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Reset special flag for legs amputations
|
||||
JCIO_Anims.SetMissingFootAnimation(false)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Set correct body locations for items in inventory
|
||||
function TocResetClothingItemBodyLocation(player, side, limb)
|
||||
|
||||
@@ -118,14 +64,8 @@ function TocResetClothingItemBodyLocation(player, side, limb)
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
------ TEST FUNCTIONS, DON'T USE THESE!!! ---------------
|
||||
|
||||
function TocTestBodyLocations()
|
||||
|
||||
local group = BodyLocations.getGroup("Human")
|
||||
|
||||
@@ -22,7 +22,7 @@ function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
local modifiedMaxTime = originalMaxTime
|
||||
local burnFactor = 1.3 -- TODO Move this crap
|
||||
|
||||
for _, partName in pairs(GetBodyParts()) do
|
||||
for _, partName in pairs(JCIO_Common.GetPartNames()) do
|
||||
if limbsData[partName].isCut then
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ local function CheckIfPlayerIsInfected(player, limbsData)
|
||||
local bodyDamage = player:getBodyDamage()
|
||||
|
||||
-- Check for amputable limbs
|
||||
for _, v in ipairs(GetLimbsBodyPartTypes()) do
|
||||
local partName = TocGetPartNameFromBodyPartType(v)
|
||||
for _, v in ipairs(JCIO_Common.GetAcceptableBodyPartTypes()) do
|
||||
local partName = JCIO_Common.GetPartNameFromBodyPartType(v)
|
||||
local partData = limbsData[partName]
|
||||
local bodyPart = bodyDamage:getBodyPart(v)
|
||||
|
||||
@@ -21,7 +21,7 @@ local function CheckIfPlayerIsInfected(player, limbsData)
|
||||
end
|
||||
|
||||
-- Check for everything else
|
||||
for _, v in pairs(GetOtherBodyPartTypes()) do
|
||||
for _, v in pairs(JCIO_Common.GetOtherBodyPartTypes()) do
|
||||
if bodyDamage:getBodyPart(v):bitten() then
|
||||
limbsData.isOtherBodypartInfected = true -- Even one is enough, stop cycling if we find it
|
||||
break
|
||||
@@ -31,10 +31,10 @@ end
|
||||
local function ManagePhantomPain(player, limbsData)
|
||||
local body_damage = player:getBodyDamage()
|
||||
|
||||
for _, partName in pairs(GetBodyParts()) do
|
||||
for _, partName in pairs(JCIO_Common.GetPartNames()) do
|
||||
|
||||
if limbsData[partName].isCut and limbsData[partName].isAmputationShown and ZombRand(1, 100) < 10 then
|
||||
local body_part = body_damage:getBodyPart(TocGetBodyPartFromPartName(partName))
|
||||
local body_part = body_damage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName))
|
||||
local added_pain
|
||||
if limbsData[partName].isCauterized then added_pain = 60 else added_pain = 30 end
|
||||
body_part:setAdditionalPain(ZombRand(1, added_pain))
|
||||
@@ -57,7 +57,7 @@ local function SetHealthStatusForBodyPart(partData, partName, player)
|
||||
|
||||
|
||||
local bodyDamage = player:getBodyDamage()
|
||||
local bodyPart = bodyDamage:getBodyPart(TocGetBodyPartFromPartName(partName))
|
||||
local bodyPart = bodyDamage:getBodyPart(JCIO_Common.GetBodyPartFromPartName(partName))
|
||||
if not bodyPart then
|
||||
print("JCIO ERROR: Can't update health of " .. partName)
|
||||
return false
|
||||
@@ -143,7 +143,7 @@ local function UpdatePlayerHealth(player, partData)
|
||||
|
||||
if player:HasTrait("Insensitive") then bodyDamage:setPainReduction(49) end
|
||||
|
||||
for _, partName in pairs(GetBodyParts()) do
|
||||
for _, partName in pairs(JCIO_Common.GetPartNames()) do
|
||||
if partData[partName].isCut then
|
||||
SetHealthStatusForBodyPart(partData, partName, player)
|
||||
|
||||
@@ -191,12 +191,12 @@ JCIO.UpdateEveryTenMinutes = function()
|
||||
end
|
||||
|
||||
-- Updates the cicatrization time
|
||||
for _, partName in pairs(GetBodyParts()) do
|
||||
for _, partName in pairs(JCIO_Common.GetPartNames()) do
|
||||
if partData[partName].isCut and not partData[partName].isCicatrized then
|
||||
|
||||
--Wound cleanliness contributes to cicatrization
|
||||
-- TODO we reset this stuff every time we restart the game for compat reason, this is an issue
|
||||
local amputatedLimbItem = TocGetAmputationItemInInventory(player, partName)
|
||||
local amputatedLimbItem = JCIO_Common.GetAmputationItemInInventory(player, partName)
|
||||
local itemDirtyness = amputatedLimbItem:getDirtyness()/100
|
||||
local itemBloodyness = amputatedLimbItem:getBloodLevel()/100
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ function ISCutLimb:start()
|
||||
-- TODO Add a check so you can't cut your arm if you don't have hands or if you only have one arm and want to cut that same arm.
|
||||
|
||||
self:setActionAnim("SawLog")
|
||||
local saw_item = TocGetSawInInventory(self.surgeon)
|
||||
local saw_item = JCIO_Common.GetSawInInventory(self.surgeon)
|
||||
self.surgeon:getEmitter():playSound("Amputation_Sound")
|
||||
|
||||
-- Return whatever object we've got in the inventory
|
||||
|
||||
@@ -44,7 +44,7 @@ function ISInstallProsthesis:perform()
|
||||
-- local toc_data = self.character:getModData().TOC
|
||||
--local part_name = TocGetPartNameFromBodyPartType(self.bodyPart:getType())
|
||||
|
||||
local body_part_type = TocGetBodyPartFromPartName(self.part_name)
|
||||
local body_part_type = JCIO_Common.GetBodyPartFromPartName(self.part_name)
|
||||
|
||||
-- Check if can be performed. This shouldn't be necessary, but just to be sure
|
||||
if body_part_type == BodyPartType.UpperArm_L or body_part_type == BodyPartType.UpperArm_R then
|
||||
|
||||
@@ -49,15 +49,15 @@ end
|
||||
|
||||
-- Global Mod Data data handler
|
||||
ClientCommands.ChangePlayerState = function(playerObj, args)
|
||||
ModData.get("TOC_PLAYER_DATA")[playerObj:getUsername()] = args
|
||||
ModData.transmit("TOC_PLAYER_DATA")
|
||||
ModData.get("JCIO_PLAYER_DATA")[playerObj:getUsername()] = args
|
||||
ModData.transmit("JCIO_PLAYER_DATA")
|
||||
end
|
||||
|
||||
|
||||
------ Global Mod Data -----------
|
||||
|
||||
function TOC_OnInitGlobalModData()
|
||||
ModData.getOrCreate("TOC_PLAYER_DATA")
|
||||
ModData.getOrCreate("JCIO_PLAYER_DATA")
|
||||
end
|
||||
|
||||
Events.OnInitGlobalModData.Add(TOC_OnInitGlobalModData)
|
||||
|
||||
Reference in New Issue
Block a user