Initialization and some other stuff done
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -54,6 +54,7 @@
|
|||||||
"getClassFieldVal",
|
"getClassFieldVal",
|
||||||
"SandboxVars",
|
"SandboxVars",
|
||||||
"getClassField",
|
"getClassField",
|
||||||
"ISWearClothing"
|
"ISWearClothing",
|
||||||
|
"SyncXp"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
------------------------------------------
|
------------------------------------------
|
||||||
-------- JUST CUT IT OFF --------
|
------------- JUST CUT IT OFF ------------
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
----------- CUT LIMB FUNCTIONS -----------
|
----------- CUT LIMB FUNCTIONS -----------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function TocCheckIfStillInfected(limbs_data)
|
local function TocCheckIfStillInfected(limbs_data)
|
||||||
if limbs_data == nil then
|
if limbs_data == nil then
|
||||||
return
|
return
|
||||||
@@ -125,12 +132,17 @@ local function FindTourniquetInWornItems(patient, side)
|
|||||||
end
|
end
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Main function for cutting a limb
|
--- Main function for cutting a limb
|
||||||
---@param partName string the part name to amputate
|
---@param partName string the part name to amputate
|
||||||
---@param surgeonFactor any the surgeon factor, which will determine some stats for the inflicted wound
|
---@param surgeonFactor any the surgeon factor, which will determine some stats for the inflicted wound
|
||||||
---@param bandageTable any bandages info
|
---@param bandageTable any bandages info
|
||||||
---@param painkiller_table any painkillers info, not used
|
---@param painkillerTable any painkillers info, not used
|
||||||
function TocCutLimb(partName, surgeonFactor, bandageTable, painkiller_table)
|
JCIO.CutLimb = function(partName, surgeonFactor, bandageTable, painkillerTable)
|
||||||
|
|
||||||
-- TODO Separate Cut Limb in side and limb instead of single part_name
|
-- TODO Separate Cut Limb in side and limb instead of single part_name
|
||||||
|
|
||||||
@@ -202,24 +214,24 @@ function TocCutLimb(partName, surgeonFactor, bandageTable, painkiller_table)
|
|||||||
|
|
||||||
-- A check for is_cut shouldn't be necessary here since if we've got here we've already checked it out enough
|
-- A check for is_cut shouldn't be necessary here since if we've got here we've already checked it out enough
|
||||||
|
|
||||||
if limbsData[partName].is_cut == false then
|
if limbsData[partName].isCut == false then
|
||||||
limbsData[partName].is_cut = true
|
limbsData[partName].isCut = true
|
||||||
limbsData[partName].is_amputation_shown = true
|
limbsData[partName].isAmputationShown = true
|
||||||
limbsData[partName].cicatrization_time = partsParameters[partName].cicatrization_base_time - surgeonFactor * 50
|
limbsData[partName].cicatrizationTime = partsParameters[partName].cicatrizationBaseTime - surgeonFactor * 50
|
||||||
|
|
||||||
for _, depended_v in pairs(limbsData[partName].depends_on) do
|
for _, depended_v in pairs(limbsData[partName].depends_on) do
|
||||||
limbsData[depended_v].is_cut = true
|
limbsData[depended_v].isCut = true
|
||||||
limbsData[depended_v].is_amputation_shown = false
|
limbsData[depended_v].isAmputationShown = false
|
||||||
limbsData[depended_v].cicatrization_time = partsParameters[partName].cicatrization_base_time -
|
limbsData[depended_v].cicatrizationTime = partsParameters[partName].cicatrizationBaseTime -
|
||||||
surgeonFactor * 50
|
surgeonFactor * 50
|
||||||
|
|
||||||
local should_depended_v_be_healed_of_bite = limbsData[depended_v].is_infected and
|
local canHealDependedV = limbsData[depended_v].isInfected and
|
||||||
bodyDamage:getInfectionLevel() < 20
|
bodyDamage:getInfectionLevel() < 20
|
||||||
local depended_body_part = bodyDamage:getBodyPart(TocGetBodyPartFromPartName(depended_v))
|
local depended_body_part = bodyDamage:getBodyPart(TocGetBodyPartFromPartName(depended_v))
|
||||||
TocSetParametersForMissingLimb(depended_body_part, should_depended_v_be_healed_of_bite)
|
TocSetParametersForMissingLimb(depended_body_part, canHealDependedV)
|
||||||
|
|
||||||
if should_depended_v_be_healed_of_bite then
|
if canHealDependedV then
|
||||||
limbsData[depended_v].is_infected = false
|
limbsData[depended_v].isInfected = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -229,8 +241,8 @@ function TocCutLimb(partName, surgeonFactor, bandageTable, painkiller_table)
|
|||||||
|
|
||||||
-- Heal the infection here
|
-- Heal the infection here
|
||||||
local body_damage = player:getBodyDamage()
|
local body_damage = player:getBodyDamage()
|
||||||
if limbsData[partName].is_infected and body_damage:getInfectionLevel() < 20 then
|
if limbsData[partName].isInfected and body_damage:getInfectionLevel() < 20 then
|
||||||
limbsData[partName].is_infected = false
|
limbsData[partName].isInfected = false
|
||||||
|
|
||||||
-- NOT THE ADIACENT ONE!!!
|
-- NOT THE ADIACENT ONE!!!
|
||||||
bodyPart:SetBitten(false)
|
bodyPart:SetBitten(false)
|
||||||
@@ -264,7 +276,7 @@ function TocCutLimb(partName, surgeonFactor, bandageTable, painkiller_table)
|
|||||||
TocSetBloodOnAmputation(getPlayer(), adjacentBodyPart)
|
TocSetBloodOnAmputation(getPlayer(), adjacentBodyPart)
|
||||||
|
|
||||||
if partName == "Left_Foot" or partName == "Right_Foot" then
|
if partName == "Left_Foot" or partName == "Right_Foot" then
|
||||||
SetMissingFootAnimation(true)
|
JCIOAnims.SetMissingFootAnimation(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
-- Thanks to Glytcher and Matías N. Salas for helping out with this
|
-- Thanks to Glytcher and Matías N. Salas for helping out with this
|
||||||
|
|
||||||
function SetMissingFootAnimation(check)
|
if JCIOAnims == nil then
|
||||||
|
JCIOAnims = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
JCIOAnims.SetMissingFootAnimation = function(check)
|
||||||
local player = getPlayer()
|
local player = getPlayer()
|
||||||
player:setVariable("IsCrawling", tostring(check))
|
player:setVariable("IsCrawling", tostring(check))
|
||||||
|
|
||||||
@@ -12,7 +15,11 @@ function SetMissingFootAnimation(check)
|
|||||||
|
|
||||||
sendClientCommand(player, "TOC", "NotifyNewCrawlAnimation", {id = player:getOnlineID(), check = check})
|
sendClientCommand(player, "TOC", "NotifyNewCrawlAnimation", {id = player:getOnlineID(), check = check})
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
JCIOAnims.CheckAndSetMissingFootAnims = function(modData)
|
||||||
|
|
||||||
|
if modData.JCIO.limbs["Left_Foot"].isCut or modData.JCIO.limbs["Right_Foot"].isCut then
|
||||||
|
JCIOAnims.SetMissingFootAnimation(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -8,7 +8,7 @@ Rewritten by: Pao
|
|||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
|
||||||
local function InitializeTraits()
|
JCIO.InitializeTraits = function()
|
||||||
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8,
|
local amp1 = TraitFactory.addTrait("Amputee_Hand", getText("UI_trait_Amputee_Hand"), -8,
|
||||||
getText("UI_trait_Amputee_Hand_desc"), false, false)
|
getText("UI_trait_Amputee_Hand_desc"), false, false)
|
||||||
amp1:addXPBoost(Perks.Left_Hand, 4)
|
amp1:addXPBoost(Perks.Left_Hand, 4)
|
||||||
@@ -34,89 +34,29 @@ local function InitializeTraits()
|
|||||||
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
|
TraitFactory.setMutualExclusive("Amputee_LowerArm", "Amputee_UpperArm")
|
||||||
end
|
end
|
||||||
-- TODO Refactor this
|
-- TODO Refactor this
|
||||||
local function TocUpdateBaseData(mod_data)
|
|
||||||
-- TODO Gonna delete this soon, overhauling the whole init thing
|
|
||||||
|
|
||||||
-- TODO The prosthetic knife needs to be a weapon first and foremost, so other than a
|
JCIO.CutLimbForTrait = function(player, jcioModData, partName)
|
||||||
-- clothing item it needs to be a weapon too (an invisible one maybe?)
|
|
||||||
|
|
||||||
--local prosthesis_list = { "WoodenHook", "MetalHook", "MetalHand", "ProstheticKnife" }
|
local limbParameters = jcioModData.limbParameters
|
||||||
|
local limbsData = jcioModData.limbs
|
||||||
|
|
||||||
local accepted_prosthesis_hand = { "WoodenHook", "MetalHook", "MetalHand", "ProstheticKnife" }
|
local amputationClothingItem = player:getInventory():AddItem("TOC.Amputation_" .. partName)
|
||||||
local accepted_prosthesis_lowerarm = { "WoodenHook", "MetalHook", "MetalHand", "ProstheticKnife" }
|
JCIOVisuals.SetTextureForAmputation(amputationClothingItem, player, true)
|
||||||
local accepted_prosthesis_upperarm = {} -- For future stuff
|
|
||||||
local accepted_prosthesis_foot = {}
|
|
||||||
|
|
||||||
for _, side in pairs(JCIO.sideNames) do
|
player:setWornItem(amputationClothingItem:getBodyLocation(), amputationClothingItem)
|
||||||
for _, limb in pairs(JCIO.limbNames) do
|
limbsData[partName].isCut = true
|
||||||
|
limbsData[partName].isOperated = true
|
||||||
local part_name = side .. "_" .. limb
|
limbsData[partName].isAmputationShown = true
|
||||||
|
limbsData[partName].isCicatrized = true
|
||||||
|
|
||||||
-- Check if part was initialized, in case of previous errors
|
|
||||||
if mod_data.TOC.Limbs[part_name] == nil then
|
|
||||||
JCIO.InitPart(mod_data.TOC.Limbs, part_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
if limb == "Hand" then
|
|
||||||
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700
|
|
||||||
mod_data.TOC.Limbs[part_name].depends_on = {}
|
|
||||||
|
|
||||||
|
|
||||||
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_hand
|
|
||||||
mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.3
|
|
||||||
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.2
|
|
||||||
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.1
|
|
||||||
--mod_data.TOC.Prosthesis["ProstheticKnife"][part_name].prosthesis_factor = 1.5
|
|
||||||
|
|
||||||
|
|
||||||
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.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_lowerarm
|
|
||||||
|
|
||||||
mod_data.TOC.Prosthesis["WoodenHook"][part_name].prosthesis_factor = 1.35
|
|
||||||
mod_data.TOC.Prosthesis["MetalHook"][part_name].prosthesis_factor = 1.25
|
|
||||||
mod_data.TOC.Prosthesis["MetalHand"][part_name].prosthesis_factor = 1.15
|
|
||||||
--mod_data.TOC.Prosthesis["ProstheticKnife"][part_name].prosthesis_factor = 1.6
|
|
||||||
|
|
||||||
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.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_upperarm
|
|
||||||
elseif limb == "Foot" then
|
|
||||||
mod_data.TOC.Limbs[part_name].cicatrization_base_time = 1700
|
|
||||||
mod_data.TOC.Limbs[part_name].depends_on = {}
|
|
||||||
mod_data.TOC.Prosthesis.Accepted_Prosthesis[part_name] = accepted_prosthesis_foot
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
for _, v in pairs(limbParameters[partName].dependsOn) do
|
||||||
|
limbsData[v].isCut = true
|
||||||
|
limbsData[v].isOperated = true
|
||||||
|
limbsData[v].isAmputationShown = false
|
||||||
|
limbsData[v].isCicatrized = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
JCIO.CutLimbForTrait = function(player, limbs_data, part_name)
|
|
||||||
local amputation_clothing_item = player:getInventory():AddItem("TOC.Amputation_" .. part_name)
|
|
||||||
TocSetCorrectTextureForAmputation(amputation_clothing_item, player, true)
|
|
||||||
|
|
||||||
player:setWornItem(amputation_clothing_item:getBodyLocation(), amputation_clothing_item)
|
|
||||||
limbs_data[part_name].is_cut = true
|
|
||||||
limbs_data[part_name].is_operated = true
|
|
||||||
limbs_data[part_name].is_amputation_shown = true
|
|
||||||
limbs_data[part_name].is_cicatrized = true
|
|
||||||
|
|
||||||
for _, v in pairs(limbs_data[part_name].depends_on) do
|
|
||||||
limbs_data[v].is_cut = true
|
|
||||||
limbs_data[v].is_operated = true
|
|
||||||
limbs_data[v].is_amputation_shown = false
|
|
||||||
limbs_data[v].is_cicatrized = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
JCIO.InitPart = function(limbs_data, part_name)
|
JCIO.InitPart = function(limbs_data, part_name)
|
||||||
|
|
||||||
limbs_data[part_name].is_cut = false
|
limbs_data[part_name].is_cut = false
|
||||||
@@ -132,6 +72,7 @@ JCIO.InitPart = function(limbs_data, part_name)
|
|||||||
limbs_data[part_name].equipped_prosthesis = {}
|
limbs_data[part_name].equipped_prosthesis = {}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
JCIO.SetInitData = function(modData, player)
|
JCIO.SetInitData = function(modData, player)
|
||||||
print("TOC: Creating mod_data.TOC")
|
print("TOC: Creating mod_data.TOC")
|
||||||
--------
|
--------
|
||||||
@@ -221,20 +162,17 @@ JCIO.SetInitData = function(modData, player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set data like prosthesis lists, cicatrization time etc
|
|
||||||
-- TODO Change this
|
|
||||||
TocUpdateBaseData(modData)
|
|
||||||
|
|
||||||
-- Setup traits
|
-- Setup traits
|
||||||
if player:HasTrait("Amputee_Hand") then
|
if player:HasTrait("Amputee_Hand") then
|
||||||
JCIO.CutLimbForTrait(player, modData.JCIO.limbs, "Left_Hand")
|
JCIO.CutLimbForTrait(player, modData.JCIO, "Left_Hand")
|
||||||
elseif player:HasTrait("Amputee_LowerArm") then
|
elseif player:HasTrait("Amputee_LowerArm") then
|
||||||
JCIO.CutLimbForTrait(player, modData.TOC.limbs, "Left_LowerArm")
|
JCIO.CutLimbForTrait(player, modData.JCIO, "Left_LowerArm")
|
||||||
elseif player:HasTrait("Amputee_UpperArm") then
|
elseif player:HasTrait("Amputee_UpperArm") then
|
||||||
JCIO.CutLimbForTrait(player, modData.TOC.limbs, "Left_UpperArm")
|
JCIO.CutLimbForTrait(player, modData.JCIO, "Left_UpperArm")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
JCIO.Init = function(_, player)
|
JCIO.Init = function(_, player)
|
||||||
|
|
||||||
local modData = player:getModData()
|
local modData = player:getModData()
|
||||||
@@ -242,10 +180,8 @@ JCIO.Init = function(_, player)
|
|||||||
JCIO.SetInitData(modData, player)
|
JCIO.SetInitData(modData, player)
|
||||||
else
|
else
|
||||||
JCIOCompat.CheckCompatibilityWithOlderVersions(modData)
|
JCIOCompat.CheckCompatibilityWithOlderVersions(modData)
|
||||||
|
JCIOAnims.CheckAndSetMissingFootAnims(modData)
|
||||||
|
|
||||||
-- TODO This is gonna be deleted and moved directly to TOC
|
|
||||||
TocUpdateBaseData(modData) -- Since it's gonna be common to update stuff
|
|
||||||
TocCheckLegsAmputations(modData)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Compat fix with older versions
|
-- Compat fix with older versions
|
||||||
@@ -277,24 +213,24 @@ local function InitializeJustCutItOff()
|
|||||||
JCIO.limbParameters[partName] = {}
|
JCIO.limbParameters[partName] = {}
|
||||||
|
|
||||||
if limb == "Hand" then
|
if limb == "Hand" then
|
||||||
JCIO.limbParameters[partName].cicatrization_base_time = 1700
|
JCIO.limbParameters[partName].cicatrizationBaseTime = 1700
|
||||||
JCIO.limbParameters[partName].depends_on = {}
|
JCIO.limbParameters[partName].dependsOn = {}
|
||||||
elseif limb == "LowerArm" then
|
elseif limb == "LowerArm" then
|
||||||
JCIO.limbParameters[partName].cicatrization_base_time = 1800
|
JCIO.limbParameters[partName].cicatrizationBaseTime = 1800
|
||||||
JCIO.limbParameters[partName].depends_on = { side .. "_Hand", }
|
JCIO.limbParameters[partName].dependsOn = { side .. "_Hand", }
|
||||||
elseif limb == "UpperArm" then
|
elseif limb == "UpperArm" then
|
||||||
JCIO.limbParameters[partName].cicatrization_base_time = 2000
|
JCIO.limbParameters[partName].cicatrizationBaseTime = 2000
|
||||||
JCIO.limbParameters[partName].depends_on = { side .. "_Hand", side .. "_LowerArm", }
|
JCIO.limbParameters[partName].dependsOn = { side .. "_Hand", side .. "_LowerArm", }
|
||||||
elseif limb == "Foot" then
|
elseif limb == "Foot" then
|
||||||
JCIO.limbParameters[partName].cicatrization_base_time = 1700
|
JCIO.limbParameters[partName].cicatrizationBaseTime = 1700
|
||||||
JCIO.limbParameters[partName].depends_on = {}
|
JCIO.limbParameters[partName].dependsOn = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
InitializeTraits()
|
JCIO.InitializeTraits()
|
||||||
Events.OnCreatePlayer.Add(JCIO.Init)
|
Events.OnCreatePlayer.Add(JCIO.Init)
|
||||||
|
|
||||||
-- Setup updates
|
-- Setup updates
|
||||||
|
|||||||
112
media/lua/client/JCIO_Visuals.lua
Normal file
112
media/lua/client/JCIO_Visuals.lua
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
------------------------------------------
|
||||||
|
------------- JUST CUT IT OFF ------------
|
||||||
|
------------------------------------------
|
||||||
|
------------ VISUALS FUNCTIONS -----------
|
||||||
|
|
||||||
|
|
||||||
|
if JCIOVisuals == nil then
|
||||||
|
JCIOVisuals = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
JCIOVisuals.SetTextureForAmputation = function(item, player, cicatrized)
|
||||||
|
local humanVisual = player:getHumanVisual()
|
||||||
|
local textureString = humanVisual:getSkinTexture()
|
||||||
|
|
||||||
|
local isHairy = string.find(textureString, "a$")
|
||||||
|
-- Hairy bodies
|
||||||
|
if isHairy then
|
||||||
|
textureString = textureString:sub(1, -2) -- Removes b at the end to make it compatible
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local matchedIndex = string.match(textureString, "%d$")
|
||||||
|
|
||||||
|
if isHairy then
|
||||||
|
matchedIndex = matchedIndex + 5
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if cicatrized then
|
||||||
|
if isHairy then
|
||||||
|
matchedIndex = matchedIndex + 5 -- to use the cicatrized texture on hairy bodies
|
||||||
|
else
|
||||||
|
matchedIndex = matchedIndex + 10 -- cicatrized texture only, no hairs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--print("TOC: Setting texture " .. matched_index)
|
||||||
|
item:getVisual():setTextureChoice(tonumber(matchedIndex - 1)) -- it counts from 0, so we have to subtract 1
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
JCIOVisuals.SetBloodOnAmputation = function(player, bodyPart)
|
||||||
|
|
||||||
|
local bodyPartType = bodyPart:getType()
|
||||||
|
local bloodBodyPartType
|
||||||
|
|
||||||
|
if bodyPartType == BodyPartType.Hand_R then
|
||||||
|
bloodBodyPartType = BloodBodyPartType.ForeArm_R
|
||||||
|
elseif bodyPartType == BodyPartType.Hand_L then
|
||||||
|
bloodBodyPartType = BloodBodyPartType.ForeArm_L
|
||||||
|
elseif bodyPartType == BodyPartType.Forearm_L or bodyPartType == BodyPartType.UpperArm_L then
|
||||||
|
bloodBodyPartType = BloodBodyPartType.UpperArm_L
|
||||||
|
elseif bodyPartType == BodyPartType.Forearm_R or bodyPartType == BodyPartType.UpperArm_R then
|
||||||
|
bloodBodyPartType = BloodBodyPartType.UpperArm_R
|
||||||
|
end
|
||||||
|
|
||||||
|
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("TOC: 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("TOC: 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
|
||||||
@@ -33,7 +33,14 @@ end
|
|||||||
|
|
||||||
ServerCommands.CutLimb = function(arg)
|
ServerCommands.CutLimb = function(arg)
|
||||||
local data = arg["toSend"]
|
local data = arg["toSend"]
|
||||||
TocCutLimb(data[1], data[2], data[3], data[4])
|
|
||||||
|
local partName = data[1]
|
||||||
|
local surgeonFactor = data[2]
|
||||||
|
local bandageTable = data[3]
|
||||||
|
local painkillerTable = data[4]
|
||||||
|
|
||||||
|
|
||||||
|
JCIO.CutLimb(partName, surgeonFactor, bandageTable, painkillerTable)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -77,45 +77,44 @@ function TocResetEverything()
|
|||||||
|
|
||||||
|
|
||||||
-- Reset special flag for legs amputations
|
-- Reset special flag for legs amputations
|
||||||
SetMissingFootAnimation(false)
|
JCIOAnims.SetMissingFootAnimation(false)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Set correct body locations for items in inventory
|
-- Set correct body locations for items in inventory
|
||||||
function TocResetClothingItemBodyLocation(player, side, limb)
|
function TocResetClothingItemBodyLocation(player, side, limb)
|
||||||
local player_inventory = player:getInventory()
|
|
||||||
local limbs_data = player:getModData().TOC.Limbs
|
|
||||||
local amputation_item_name = TocGetAmputationFullTypeFromInventory(player, side, limb)
|
|
||||||
local equipped_prosthesis_item_name = TocGetEquippedProsthesisFullTypeFromInventory(player, side, limb)
|
|
||||||
print(amputation_item_name)
|
|
||||||
print(equipped_prosthesis_item_name)
|
|
||||||
|
|
||||||
if amputation_item_name ~= nil then
|
local playerInv = player:getInventory()
|
||||||
|
local limbsData = player:getModData().JCIO.limbs
|
||||||
|
|
||||||
local amputation_item = player_inventory:FindAndReturn(amputation_item_name)
|
local amputationItemName = TocGetAmputationFullTypeFromInventory(player, side, limb)
|
||||||
if amputation_item ~= nil then
|
local equippedProsthesisItemName = TocGetEquippedProsthesisFullTypeFromInventory(player, side, limb)
|
||||||
player:removeWornItem(amputation_item)
|
|
||||||
player:getInventory():Remove(amputation_item)
|
|
||||||
amputation_item = player_inventory:AddItem(amputation_item_name)
|
|
||||||
TocSetCorrectTextureForAmputation(amputation_item, player, limbs_data[side .. "_" .. limb].is_cicatrized)
|
|
||||||
|
|
||||||
player:setWornItem(amputation_item:getBodyLocation(), amputation_item)
|
if amputationItemName ~= nil then
|
||||||
|
|
||||||
|
local amputationItem = playerInv:FindAndReturn(amputationItemName)
|
||||||
|
if amputationItem ~= nil then
|
||||||
|
player:removeWornItem(amputationItem)
|
||||||
|
player:getInventory():Remove(amputationItem)
|
||||||
|
amputationItem = playerInv:AddItem(amputationItemName)
|
||||||
|
JCIOVisuals.SetTextureForAmputation(amputationItem, player, limbsData[side .. "_" .. limb].is_cicatrized)
|
||||||
|
player:setWornItem(amputationItem:getBodyLocation(), amputationItem)
|
||||||
end
|
end
|
||||||
amputation_item = nil -- reset it
|
amputationItem = nil -- reset it
|
||||||
end
|
end
|
||||||
|
|
||||||
if equipped_prosthesis_item_name ~= nil then
|
if equippedProsthesisItemName ~= nil then
|
||||||
local prosthesis_item = player_inventory:FindAndReturn(equipped_prosthesis_item_name)
|
local prosthesisItem = playerInv:FindAndReturn(equippedProsthesisItemName)
|
||||||
if prosthesis_item ~= nil then
|
if prosthesisItem ~= nil then
|
||||||
print("Resetting " .. prosthesis_item:getName())
|
print("Resetting " .. prosthesisItem:getName())
|
||||||
player:removeWornItem(prosthesis_item)
|
player:removeWornItem(prosthesisItem)
|
||||||
player:getInventory():Remove(prosthesis_item)
|
player:getInventory():Remove(prosthesisItem)
|
||||||
prosthesis_item = player_inventory:AddItem(equipped_prosthesis_item_name)
|
prosthesisItem = playerInv:AddItem(equippedProsthesisItemName)
|
||||||
player:setWornItem(prosthesis_item:getBodyLocation(), prosthesis_item)
|
player:setWornItem(prosthesisItem:getBodyLocation(), prosthesisItem)
|
||||||
|
|
||||||
end
|
end
|
||||||
prosthesis_item = nil -- reset it
|
prosthesisItem = nil -- reset it
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -93,13 +93,3 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------------------
|
|
||||||
function TocCheckLegsAmputations(mod_data)
|
|
||||||
|
|
||||||
if mod_data.TOC.Limbs["Left_Foot"].is_cut or mod_data.TOC.Limbs["Right_Foot"].is_cut then
|
|
||||||
SetMissingFootAnimation(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
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("TOC: 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("TOC: 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
|
|
||||||
@@ -122,7 +122,7 @@ function ISCutLimb:perform()
|
|||||||
SendCutLimb(self.patient, self.part_name, surgeon_factor, bandage_table, painkiller_table)
|
SendCutLimb(self.patient, self.part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||||
sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()})
|
sendClientCommand(self.surgeon, "TOC", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()})
|
||||||
else
|
else
|
||||||
TocCutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table)
|
JCIO.CutLimb(self.part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
|
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
|
||||||
|
|||||||
Reference in New Issue
Block a user