Cicatrization visuals reimplemented

This commit is contained in:
ZioPao
2024-05-01 23:21:15 +02:00
parent c621a56f67
commit fa1d86ae7e
7 changed files with 123 additions and 24 deletions

View File

@@ -25,6 +25,22 @@
<textureChoices>Amputations\Human\Forearm\skin04_hairy_b</textureChoices> <textureChoices>Amputations\Human\Forearm\skin04_hairy_b</textureChoices>
<textureChoices>Amputations\Human\Forearm\skin05_hairy_b</textureChoices> <textureChoices>Amputations\Human\Forearm\skin05_hairy_b</textureChoices>
<!-- HUMAN AFTER CICATRIZATION -->
<textureChoices>Body\MaleBody01</textureChoices>
<textureChoices>Body\MaleBody02</textureChoices>
<textureChoices>Body\MaleBody03</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05</textureChoices>
<textureChoices>Body\MaleBody01a</textureChoices>
<textureChoices>Body\MaleBody02a</textureChoices>
<textureChoices>Body\MaleBody03a</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05a</textureChoices>
<!-- ZOMBIE --> <!-- ZOMBIE -->
<textureChoices>Amputations\Zombie\Forearm\z_skin01_l1</textureChoices> <textureChoices>Amputations\Zombie\Forearm\z_skin01_l1</textureChoices>
<textureChoices>Amputations\Zombie\Forearm\z_skin01_l2</textureChoices> <textureChoices>Amputations\Zombie\Forearm\z_skin01_l2</textureChoices>

View File

@@ -23,6 +23,22 @@
<textureChoices>Amputations\Human\Forearm\skin04_hairy_b</textureChoices> <textureChoices>Amputations\Human\Forearm\skin04_hairy_b</textureChoices>
<textureChoices>Amputations\Human\Forearm\skin05_hairy_b</textureChoices> <textureChoices>Amputations\Human\Forearm\skin05_hairy_b</textureChoices>
<!-- HUMAN AFTER CICATRIZATION -->
<textureChoices>Body\MaleBody01</textureChoices>
<textureChoices>Body\MaleBody02</textureChoices>
<textureChoices>Body\MaleBody03</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05</textureChoices>
<textureChoices>Body\MaleBody01a</textureChoices>
<textureChoices>Body\MaleBody02a</textureChoices>
<textureChoices>Body\MaleBody03a</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05a</textureChoices>
<!-- ZOMBIE --> <!-- ZOMBIE -->
<textureChoices>Amputations\Zombie\Forearm\z_skin01_l1</textureChoices> <textureChoices>Amputations\Zombie\Forearm\z_skin01_l1</textureChoices>
<textureChoices>Amputations\Zombie\Forearm\z_skin01_l2</textureChoices> <textureChoices>Amputations\Zombie\Forearm\z_skin01_l2</textureChoices>

View File

@@ -21,4 +21,36 @@
<textureChoices>Amputations\Human\Upperarm\skin03_hairy_b</textureChoices> <textureChoices>Amputations\Human\Upperarm\skin03_hairy_b</textureChoices>
<textureChoices>Amputations\Human\Upperarm\skin04_hairy_b</textureChoices> <textureChoices>Amputations\Human\Upperarm\skin04_hairy_b</textureChoices>
<textureChoices>Amputations\Human\Upperarm\skin05_hairy_b</textureChoices> <textureChoices>Amputations\Human\Upperarm\skin05_hairy_b</textureChoices>
<!-- HUMAN AFTER CICATRIZATION -->
<textureChoices>Body\MaleBody01</textureChoices>
<textureChoices>Body\MaleBody02</textureChoices>
<textureChoices>Body\MaleBody03</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05</textureChoices>
<textureChoices>Body\MaleBody01a</textureChoices>
<textureChoices>Body\MaleBody02a</textureChoices>
<textureChoices>Body\MaleBody03a</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05a</textureChoices>
<!-- ZOMBIE -->
<textureChoices>Amputations\Zombie\Upperarm\z_skin01_l1</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin01_l2</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin01_l3</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin02_l1</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin02_l2</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin02_l3</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin03_l1</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin03_l2</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin03_l3</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin04_l1</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin04_l2</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin04_l3</textureChoices>
</clothingItem> </clothingItem>

View File

@@ -22,6 +22,21 @@
<textureChoices>Amputations\Human\Upperarm1\skin04_hairy_b</textureChoices> <textureChoices>Amputations\Human\Upperarm1\skin04_hairy_b</textureChoices>
<textureChoices>Amputations\Human\Upperarm1\skin05_hairy_b</textureChoices> <textureChoices>Amputations\Human\Upperarm1\skin05_hairy_b</textureChoices>
<!-- HUMAN AFTER CICATRIZATION -->
<textureChoices>Body\MaleBody01</textureChoices>
<textureChoices>Body\MaleBody02</textureChoices>
<textureChoices>Body\MaleBody03</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05</textureChoices>
<textureChoices>Body\MaleBody01a</textureChoices>
<textureChoices>Body\MaleBody02a</textureChoices>
<textureChoices>Body\MaleBody03a</textureChoices>
<textureChoices>Body\MaleBody04</textureChoices>
<textureChoices>Body\MaleBody05a</textureChoices>
<!-- ZOMBIE --> <!-- ZOMBIE -->
<textureChoices>Amputations\Zombie\Upperarm\z_skin01_l1</textureChoices> <textureChoices>Amputations\Zombie\Upperarm\z_skin01_l1</textureChoices>
<textureChoices>Amputations\Zombie\Upperarm\z_skin01_l2</textureChoices> <textureChoices>Amputations\Zombie\Upperarm\z_skin01_l2</textureChoices>

View File

@@ -1,4 +1,3 @@
local CommandsData = require("TOC/CommandsData") local CommandsData = require("TOC/CommandsData")
------------------- -------------------
@@ -9,21 +8,18 @@ local function AddAdminTocOptions(playerNum, context, worldobjects)
if not isAdmin() then return end if not isAdmin() then return end
local players = {} local players = {}
for _,v in ipairs(worldobjects) do for _, v in ipairs(worldobjects) do
for x = v:getSquare():getX() - 1, v:getSquare():getX() + 1 do
for x=v:getSquare():getX()-1,v:getSquare():getX()+1 do for y = v:getSquare():getY() - 1, v:getSquare():getY() + 1 do
for y=v:getSquare():getY()-1,v:getSquare():getY()+1 do local sq = getCell():getGridSquare(x, y, v:getSquare():getZ());
local sq = getCell():getGridSquare(x,y,v:getSquare():getZ());
if sq then if sq then
for z=0,sq:getMovingObjects():size()-1 do for z = 0, sq:getMovingObjects():size() - 1 do
local o = sq:getMovingObjects():get(z) local o = sq:getMovingObjects():get(z)
if instanceof(o, "IsoPlayer") then if instanceof(o, "IsoPlayer") then
---@cast o IsoPlayer ---@cast o IsoPlayer
local oId = o:getOnlineID() local oId = o:getOnlineID()
players[oId] = o players[oId] = o
end end
end end
end end
@@ -33,7 +29,6 @@ local function AddAdminTocOptions(playerNum, context, worldobjects)
for _, pl in pairs(players) do for _, pl in pairs(players) do
---@cast pl IsoPlayer ---@cast pl IsoPlayer
local clickedPlayerNum = pl:getOnlineID() local clickedPlayerNum = pl:getOnlineID()
@@ -43,10 +38,9 @@ local function AddAdminTocOptions(playerNum, context, worldobjects)
context:addSubMenu(option, subMenu) context:addSubMenu(option, subMenu)
subMenu:addOption(getText("ContextMenu_Admin_ResetTOC"), nil, function() subMenu:addOption(getText("ContextMenu_Admin_ResetTOC"), nil, function()
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization, {patientNum=clickedPlayerNum} ) sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization,
{ patientNum = clickedPlayerNum })
end) end)
end end
end end
Events.OnFillWorldObjectContextMenu.Add(AddAdminTocOptions) Events.OnFillWorldObjectContextMenu.Add(AddAdminTocOptions)

View File

@@ -27,9 +27,11 @@ function ItemsController.Player.GetAmputationTexturesIndex(playerObj, isCicatriz
end end
if isCicatrized then if isCicatrized then
matchedIndex = matchedIndex + (isHairy and 5 or 10) -- We add 5 is it's the texture texture, else 10 matchedIndex = matchedIndex + (isHairy and 5 or 10) -- We add 5 is it's the texture, else 10
end end
TOC_DEBUG.print("isCicatrized= " .. tostring(isCicatrized))
TOC_DEBUG.print("Amputation Texture Index: " .. tostring(matchedIndex))
return matchedIndex - 1 return matchedIndex - 1
end end
@@ -75,13 +77,12 @@ end
---Deletes all the old amputation items, used for resets ---Deletes all the old amputation items, used for resets
---@param playerObj IsoPlayer ---@param playerObj IsoPlayer
function ItemsController.Player.DeleteAllOldAmputationItems(playerObj) function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
-- This part is a workaround for a pretty shitty implementation on the java side. Check ProsthesisHandler for more infos -- This part is a workaround for a pretty shitty implementation on the java side. Check ProsthesisHandler for more infos
local group = BodyLocations.getGroup("Human") local group = BodyLocations.getGroup("Human")
group:setMultiItem("TOC_Arm", false) group:setMultiItem("TOC_Arm", false)
group:setMultiItem("TOC_ArmProst", false) group:setMultiItem("TOC_ArmProst", false)
for i=1, #StaticData.LIMBS_STR do for i = 1, #StaticData.LIMBS_STR do
local limbName = StaticData.LIMBS_STR[i] local limbName = StaticData.LIMBS_STR[i]
local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName local clothItemName = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName
local clothItem = playerObj:getInventory():FindAndReturn(clothItemName) local clothItem = playerObj:getInventory():FindAndReturn(clothItemName)
@@ -93,7 +94,6 @@ function ItemsController.Player.DeleteAllOldAmputationItems(playerObj)
group:setMultiItem("TOC_Arm", true) group:setMultiItem("TOC_Arm", true)
group:setMultiItem("TOC_ArmProst", true) group:setMultiItem("TOC_ArmProst", true)
end end
---Spawns and equips the correct amputation item to the player. ---Spawns and equips the correct amputation item to the player.
@@ -109,7 +109,31 @@ function ItemsController.Player.SpawnAmputationItem(playerObj, limbName)
playerObj:setWornItem(clothingItem:getBodyLocation(), clothingItem) playerObj:setWornItem(clothingItem:getBodyLocation(), clothingItem)
end end
---Search through worn items and modifies a specific amputation item
---@param playerObj IsoPlayer
---@param limbName string
---@param isCicatrized boolean
function ItemsController.Player.OverrideAmputationItemVisuals(playerObj, limbName, isCicatrized)
local wornItems = playerObj:getWornItems()
local fullType = StaticData.AMPUTATION_CLOTHING_ITEM_BASE .. limbName
for i = 1, wornItems:size() do
local it = wornItems:get(i - 1)
if it then
local wornItem = wornItems:get(i - 1):getItem()
TOC_DEBUG.print(wornItem:getFullType())
if wornItem:getFullType() == fullType then
TOC_DEBUG.print("Found amputation item for " .. limbName)
-- change it here
local texId = ItemsController.Player.GetAmputationTexturesIndex(playerObj, isCicatrized)
wornItem:getVisual():setTextureChoice(texId)
playerObj:resetModelNextFrame() -- necessary to update the model
return
end
end
end
end
--* Zombie Methods *-- --* Zombie Methods *--
---@class ItemsController.Zombie ---@class ItemsController.Zombie
@@ -135,14 +159,14 @@ end
function ItemsController.Zombie.GetAmputationTexturesIndex(zombie) function ItemsController.Zombie.GetAmputationTexturesIndex(zombie)
local x = zombie:getHumanVisual():getSkinTexture() local x = zombie:getHumanVisual():getSkinTexture()
-- Starting ID for zombies = 10 -- Starting ID for zombies = 20
-- 3 levels -- 3 levels
local matchedIndex = tonumber(x:match("ZedBody0(%d)")) - 1 local matchedIndex = tonumber(x:match("ZedBody0(%d)")) - 1
matchedIndex = matchedIndex * 3 matchedIndex = matchedIndex * 3
local level = tonumber(x:match("%d$")) - 1 -- it's from 1 to 3, but we're using it like 0 indexed arrays local level = tonumber(x:match("%d$")) - 1 -- it's from 1 to 3, but we're using it like 0 indexed arrays
local finalId = 10 + matchedIndex + level local finalId = 20 + matchedIndex + level
--print("Zombie texture index: " .. tostring(finalId)) --print("Zombie texture index: " .. tostring(finalId))
return finalId return finalId
end end

View File

@@ -262,6 +262,9 @@ function LocalPlayerController.UpdateAmputations()
if cicTime <= 0 then if cicTime <= 0 then
TOC_DEBUG.print(tostring(limbName) .. " is cicatrized") TOC_DEBUG.print(tostring(limbName) .. " is cicatrized")
dcInst:setIsCicatrized(limbName, true) dcInst:setIsCicatrized(limbName, true)
-- Set visual
local ItemsController = require("TOC/Controllers/ItemsController")
ItemsController.Player.OverrideAmputationItemVisuals(pl, limbName, true)
end end
end end
end end
@@ -304,7 +307,6 @@ function LocalPlayerController.CanItemBeEquipped(itemObj, limbName)
return true return true
end end
--- Drop all items from the affected limb --- Drop all items from the affected limb
---@param limbName string ---@param limbName string
function LocalPlayerController.DropItemsAfterAmputation(limbName) function LocalPlayerController.DropItemsAfterAmputation(limbName)