Fixing interactions
This commit is contained in:
@@ -69,6 +69,12 @@ end
|
|||||||
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
|
---Used to heal an area that has been cut previously. There's an exception for bites, those are managed differently
|
||||||
---@param bodyPart BodyPart
|
---@param bodyPart BodyPart
|
||||||
function LocalPlayerController.HealArea(bodyPart)
|
function LocalPlayerController.HealArea(bodyPart)
|
||||||
|
|
||||||
|
bodyPart:setFractureTime(0)
|
||||||
|
|
||||||
|
bodyPart:setScratched(false, true)
|
||||||
|
bodyPart:setScratchTime(0)
|
||||||
|
|
||||||
bodyPart:setBleeding(false)
|
bodyPart:setBleeding(false)
|
||||||
bodyPart:setBleedingTime(0)
|
bodyPart:setBleedingTime(0)
|
||||||
|
|
||||||
@@ -149,12 +155,13 @@ function LocalPlayerController.HandleDamage(character)
|
|||||||
|
|
||||||
-- Generic injury, let's heal it since they already cut the limb off
|
-- Generic injury, let's heal it since they already cut the limb off
|
||||||
if bodyPart:HasInjury() then
|
if bodyPart:HasInjury() then
|
||||||
|
TOC_DEBUG.print("Healing area - " .. limbName)
|
||||||
LocalPlayerController.HealArea(bodyPart)
|
LocalPlayerController.HealArea(bodyPart)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Special case for bites\zombie infections
|
-- Special case for bites\zombie infections
|
||||||
if bodyPart:IsInfected() then
|
if bodyPart:IsInfected() then
|
||||||
TOC_DEBUG.print("Healed from zombie infection " .. tostring(bodyPart))
|
TOC_DEBUG.print("Healed from zombie infection - " .. limbName)
|
||||||
LocalPlayerController.HealZombieInfection(bd, bodyPart, limbName, dcInst)
|
LocalPlayerController.HealZombieInfection(bd, bodyPart, limbName, dcInst)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -233,7 +240,7 @@ function LocalPlayerController.UpdateAmputations()
|
|||||||
-- We need to get the BloodBodyPartType to find out how dirty the zone is
|
-- We need to get the BloodBodyPartType to find out how dirty the zone is
|
||||||
local bbptEnum = BloodBodyPartType[limbName]
|
local bbptEnum = BloodBodyPartType[limbName]
|
||||||
local modifier = 0.01 * SandboxVars.TOC.WoundDirtynessMultiplier
|
local modifier = 0.01 * SandboxVars.TOC.WoundDirtynessMultiplier
|
||||||
|
|
||||||
local dirtynessVis = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum)
|
local dirtynessVis = visual:getDirt(bbptEnum) + visual:getBlood(bbptEnum)
|
||||||
local dirtynessWound = dcInst:getWoundDirtyness(limbName) + modifier
|
local dirtynessWound = dcInst:getWoundDirtyness(limbName) + modifier
|
||||||
|
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ function CleanWoundAction:perform()
|
|||||||
self.bodyPart:setAdditionalPain(self.bodyPart:getAdditionalPain() + addPain)
|
self.bodyPart:setAdditionalPain(self.bodyPart:getAdditionalPain() + addPain)
|
||||||
self.bandage:Use()
|
self.bandage:Use()
|
||||||
|
|
||||||
local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart)
|
-- TOC Data handling
|
||||||
|
|
||||||
-- TODO CHeck if correct in MP
|
local limbName = CommonMethods.GetLimbNameFromBodyPart(self.bodyPart)
|
||||||
local dcInst = DataController.GetInstance(self.otherPlayer:getUsername())
|
local dcInst = DataController.GetInstance(self.otherPlayer:getUsername())
|
||||||
|
|
||||||
local currentWoundDirtyness = dcInst:getWoundDirtyness(limbName)
|
local currentWoundDirtyness = dcInst:getWoundDirtyness(limbName)
|
||||||
@@ -102,6 +102,7 @@ function CleanWoundAction:perform()
|
|||||||
|
|
||||||
dcInst:setWoundDirtyness(limbName, newWoundDirtyness)
|
dcInst:setWoundDirtyness(limbName, newWoundDirtyness)
|
||||||
|
|
||||||
|
dcInst:apply()
|
||||||
|
|
||||||
-- Clean visual
|
-- Clean visual
|
||||||
local bbptEnum = BloodBodyPartType[limbName]
|
local bbptEnum = BloodBodyPartType[limbName]
|
||||||
|
|||||||
@@ -49,7 +49,12 @@ function ISHealthPanel:doBodyPartContextMenu(bodyPart, x, y)
|
|||||||
local playerNum = self.otherPlayer and self.otherPlayer:getPlayerNum() or self.character:getPlayerNum()
|
local playerNum = self.otherPlayer and self.otherPlayer:getPlayerNum() or self.character:getPlayerNum()
|
||||||
|
|
||||||
-- To not recreate it but reuse the one that has been created in the original method
|
-- To not recreate it but reuse the one that has been created in the original method
|
||||||
|
|
||||||
|
-- TODO This will work ONLY when an addOption has been already done in the og method.
|
||||||
local context = getPlayerContextMenu(playerNum)
|
local context = getPlayerContextMenu(playerNum)
|
||||||
|
context:bringToTop()
|
||||||
|
context:setVisible(true)
|
||||||
|
|
||||||
|
|
||||||
local cutLimbInteraction = CutLimbInteractionHandler:new(self, bodyPart)
|
local cutLimbInteraction = CutLimbInteractionHandler:new(self, bodyPart)
|
||||||
self:checkItems({cutLimbInteraction})
|
self:checkItems({cutLimbInteraction})
|
||||||
@@ -222,7 +227,7 @@ function ISHealthPanel:getDamagedParts()
|
|||||||
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
|
local limbName = StaticData.LIMBS_IND_STR[bodyPartTypeStr]
|
||||||
|
|
||||||
if ISHealthPanel.cheat or bodyPart:HasInjury() or bodyPart:bandaged() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0 or bodyPart:getAdditionalPain() > 10 or bodyPart:getStiffness() > 5 or (mdh:getIsCut(limbName) and mdh:getIsVisible(limbName)) then
|
if ISHealthPanel.cheat or bodyPart:HasInjury() or bodyPart:bandaged() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0 or bodyPart:getAdditionalPain() > 10 or bodyPart:getStiffness() > 5 or (mdh:getIsCut(limbName) and mdh:getIsVisible(limbName)) then
|
||||||
table.insert(result, bodyPart)
|
table.insert(result, bodyPart)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ function BaseHandler:new(panel, bodyPart)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BaseHandler:isInjured()
|
function BaseHandler:isInjured()
|
||||||
|
TOC_DEBUG.print("Running isInjured")
|
||||||
local bodyPart = self.bodyPart
|
local bodyPart = self.bodyPart
|
||||||
return (bodyPart:HasInjury() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0) and not bodyPart:bandaged()
|
return (bodyPart:HasInjury() or bodyPart:stitched() or bodyPart:getSplintFactor() > 0) and not bodyPart:bandaged()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,22 +37,22 @@ function WoundCleaningInteractionHandler:addToMenu(context)
|
|||||||
--TOC_DEBUG.print("WoundCleaningInteraction addToMenu")
|
--TOC_DEBUG.print("WoundCleaningInteraction addToMenu")
|
||||||
local types = self:getAllItemTypes(self.items.ITEMS)
|
local types = self:getAllItemTypes(self.items.ITEMS)
|
||||||
if #types > 0 and self:isValid() then
|
if #types > 0 and self:isValid() then
|
||||||
--TOC_DEBUG.print("WoundCleaningInteraction inside addToMenu")
|
TOC_DEBUG.print("WoundCleaningInteraction inside addToMenu")
|
||||||
local option = context:addOption(getText("ContextMenu_CleanWound"), nil)
|
local option = context:addOption(getText("ContextMenu_CleanWound"), nil)
|
||||||
local subMenu = context:getNew(context)
|
local subMenu = context:getNew(context)
|
||||||
context:addSubMenu(option, subMenu)
|
context:addSubMenu(option, subMenu)
|
||||||
for i=1, #types do
|
for i=1, #types do
|
||||||
local item = self:getItemOfType(self.items.ITEMS, types[i])
|
local item = self:getItemOfType(self.items.ITEMS, types[i])
|
||||||
--TOC_DEBUG.print(item:getName())
|
|
||||||
subMenu:addOption(item:getName(), self, self.onMenuOptionSelected, item:getFullType())
|
subMenu:addOption(item:getName(), self, self.onMenuOptionSelected, item:getFullType())
|
||||||
|
TOC_DEBUG.print(item:getName())
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function WoundCleaningInteractionHandler:dropItems(items)
|
function WoundCleaningInteractionHandler:dropItems(items)
|
||||||
local types = self:getAllItemTypes(items)
|
local types = self:getAllItemTypes(items)
|
||||||
if #self.items.ITEMS > 0 and #types == 1 and self:isInjured() and self.bodyPart:isNeedBurnWash() then
|
if #self.items.ITEMS > 0 and #types == 1 and self:isActionValid() then
|
||||||
-- FIXME: A bandage can be used to clean a burn or bandage it
|
|
||||||
self:onMenuOptionSelected(types[1])
|
self:onMenuOptionSelected(types[1])
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -60,18 +60,16 @@ function WoundCleaningInteractionHandler:dropItems(items)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function WoundCleaningInteractionHandler:isValid()
|
function WoundCleaningInteractionHandler:isValid()
|
||||||
-- TODO Check if cut and not cicatrized and dirty
|
self:checkItems()
|
||||||
|
return self:isActionValid()
|
||||||
|
end
|
||||||
|
|
||||||
-- todo get username
|
function WoundCleaningInteractionHandler:isActionValid()
|
||||||
if self.limbName == nil then return false end
|
if self.limbName == nil then return false end
|
||||||
|
|
||||||
local dcInst = DataController.GetInstance(self.username)
|
local dcInst = DataController.GetInstance(self.username)
|
||||||
|
|
||||||
--and dcInst:getWoundDirtyness(self.limbName) > 0.1
|
|
||||||
local check = dcInst:getIsCut(self.limbName) and not dcInst:getIsCicatrized(self.limbName) and dcInst:getWoundDirtyness(self.limbName) > 0
|
local check = dcInst:getIsCut(self.limbName) and not dcInst:getIsCicatrized(self.limbName) and dcInst:getWoundDirtyness(self.limbName) > 0
|
||||||
--TOC_DEBUG.print("WoundCleaningInteraction isValid: " .. tostring(check))
|
--TOC_DEBUG.print("WoundCleaningInteraction isValid: " .. tostring(check))
|
||||||
return check
|
return check
|
||||||
--return self:getItemOfType(self.items.ITEMS, itemType)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function WoundCleaningInteractionHandler:perform(previousAction, itemType)
|
function WoundCleaningInteractionHandler:perform(previousAction, itemType)
|
||||||
|
|||||||
Reference in New Issue
Block a user