More setup stuff for prosthesis

This commit is contained in:
Pao
2023-02-13 17:20:16 +01:00
parent 4973e235bc
commit fa6e89cdc7
7 changed files with 173 additions and 110 deletions

View File

@@ -14,33 +14,9 @@ function TocEquipProsthesis(part_name, prosthesis_item, prosthesis_base_name)
-- TODO We need to pass the original item so we can get its data!
local player = getPlayer()
local toc_data = player:getModData().TOC
local item_mod_data = prosthesis_item:getModData()
if item_mod_data.TOC == nil then
GenerateEquippedProsthesis(prosthesis_item, "Test") -- TODO Change it with the limb
item_mod_data = prosthesis_item:getModData() -- Updates it
end
--print("TOC: Test durability normal item " .. item_mod_data.TOC.durability)
local prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
local added_prosthesis = player:getInventory():AddItem(prosthesis_name)
-- Add parameters to added_prosthesis
local added_prosthesis_mod_data = added_prosthesis:getModData()
added_prosthesis_mod_data.TOC = {
durability = item_mod_data.TOC.durability,
speed = item_mod_data.TOC.speed,
}
local equipped_prosthesis = GenerateEquippedProsthesis(prosthesis_item, player:getInventory(), "Hand")
--print("TOC: Test durability new item " .. added_prosthesis_mod_data.TOC.durability)
@@ -49,16 +25,16 @@ function TocEquipProsthesis(part_name, prosthesis_item, prosthesis_base_name)
if part_name ~= nil then
if added_prosthesis ~= nil then
if equipped_prosthesis ~= nil then
toc_data.Limbs[part_name].is_prosthesis_equipped = true
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name]
toc_data.Limbs[part_name].equipped_prosthesis = toc_data.Prosthesis[prosthesis_base_name][part_name] -- TODO Change this, it's old
if player:isFemale() then
added_prosthesis:getVisual():setTextureChoice(1)
equipped_prosthesis:getVisual():setTextureChoice(1)
else
added_prosthesis:getVisual():setTextureChoice(0)
equipped_prosthesis:getVisual():setTextureChoice(0)
end
player:setWornItem(added_prosthesis:getBodyLocation(), added_prosthesis)
player:setWornItem(equipped_prosthesis:getBodyLocation(), equipped_prosthesis)

View File

@@ -7,6 +7,8 @@ require "ISUI/ISInventoryPaneContextMenu"
local og_ISBaseTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime
function ISBaseTimedAction:adjustMaxTime(maxTime)
-- TODO we can customize it better through clothing items modifier, you mook
-- RunSpeedModifier = 0.93 for example
local original_max_time = og_ISBaseTimedActionAdjustMaxTime(self, maxTime)
if original_max_time ~= -1 then

View File

@@ -1,4 +1,5 @@
local BaseStats = {
-- Use the XLSX as a base for these stats
local base_table = {
LeatherBase = {
durability = 25,
speed = 15
@@ -18,72 +19,173 @@ local BaseStats = {
}
local TopStats = {
local top_table = {
MetalHook = {
durability = 1,
speed = 1,
},
WoodenHook = {
durability = 1,
speed = 1,
}
}
function GenerateEquippedProsthesis(prosthesis_item, limb)
-- TODO Durability should be decided from the clothing item xml. Same thing for disassembling stuff
-- TODO some stuff should be defined by the limb, like -10 if forearm in speed
-- -- when we equip a prosthesis, we're gonna pass these parameters to the newly generated clothing item
-- -- when we unequip it, we regen the normal item with the parameters from the clothing item
local durability = 0
local speed = 0
local prosthesis_name = prosthesis_item:getFullType()
for base_name, base_values in pairs(BaseStats) do
local function GetProsthesisStats(array_stats, prosthesis_name)
local durability
local speed
for name, values in pairs(array_stats) do
-- Check the name of the prosthesis item, set the correct values
if string.find(prosthesis_name, base_name) then
durability = base_values.durability
speed = base_values.speed
if string.find(prosthesis_name, name) then
durability = values.durability
speed = values.speed
return durability, speed
end
end
for top_name, top_values in pairs(TopStats) do
-- Check the name of the prosthesis item, set the correct values
if string.find(prosthesis_name, top_name) then
durability = durability + top_values.durability
speed = speed + top_values.speed
end
end
local item_mod_data = prosthesis_item:getModData()
--------------------
-- TEST STUFF
durability = 12
speed = 51
-------------------
item_mod_data.TOC = {
durability = durability,
speed = speed,
}
end
--local ProsthesisRecipe = {}
---comment
---@param prosthesis_item any Normal item
---@param inventory any player inventory
---@param limb any
---@return unknown equipped_prosthesis clothing item equipped prosthesis
function GenerateEquippedProsthesis(prosthesis_item, inventory, limb)
-- TODO Durability should be decided from the clothing item xml. Same thing for disassembling stuff
-- TODO some stuff should be defined by the limb, like -10 if forearm in speed
-- when we equip a prosthesis, we're gonna pass these parameters to the newly generated clothing item
-- when we unequip it, we regen the normal item with the parameters from the clothing item
-- function ProsthesisRecipe.OnCreate.Hook(items, result, player, selectedItem)
-- -- Set mod data for item with durability and all that crap
local prosthesis_name = prosthesis_item:getFullType()
local item_mod_data = prosthesis_item:getModData()
-- end
local durability_base = 0
local speed_base = 0
local durability_top = 0
local speed_top = 0
-- Check the item mod data if the values are different than the default values
if item_mod_data.TOC ~= nil then
durability_base = item_mod_data.base_durability
durability_top = item_mod_data.top_durability
-- else
-- durability_base, speed_base = GetProsthesisStats(base_table, prosthesis_name)
-- durability_top, speed_top = GetProsthesisStats(top_table, prosthesis_name)
end
local equipped_prosthesis = inventory:AddItem(prosthesis_name)
equipped_prosthesis:setCondition(prosthesis_item:getCondition())
equipped_prosthesis:getModData().TOC = {
base_durability = durability_base,
top_durability = durability_top,
}
return equipped_prosthesis
end
----------------------------------------------------------
-- Recipe functions
ProsthesisRecipes = {}
local function GetProshetsisPartName(array_stats, prosthesis_name)
for name, _ in pairs(array_stats) do
if string.find(prosthesis_name, name) then
return name
end
end
end
-- Creates the Normal Prosthesis Item
function ProsthesisRecipes.OnCreateProsthesis(items, result, player, selectedItem)
-- TODO We need a screwdriver to craft it? Some screws maybe
-- Set mod data for item with durability and all that crap
-- Get condition from the items
local condition = 0
for i=1,items:size() do
local item = items:get(i-1)
condition = condition + item:getCondition()
end
result:setCondition(condition) -- Should be the sum?
result:getModData().TOC = {
base_durability = 100,
top_durability = 100, -- Stores it here too so we can re-reference it for later
}
end
-- Reassign the correct condition to each item
function ProsthesisRecipes.OnDisassembleProsthesis(item, result_items, player, selectedItem)
-- Check durability of original item
local item_mod_data = item.getModData().TOC
local durability_top = item_mod_data.top.durability
local durability_base = item_mod_data.base.durability
-- TODO do we actually need to store speed again?
local speed_top = item_mod_data.top.speed
local speed_base = item_mod_data.base.speed
-- Check name of the item
local prosthesis_item_name = item:getFullType()
local base_name = GetProshetsisPartName(base_table, prosthesis_item_name)
local top_name = GetProshetsisPartName(top_table, prosthesis_item_name)
print("TOC: " .. base_name .. " and " .. top_name)
local player_inv = player:getInventory()
local part_base = player_inv:AddItem("TOC.ProstPart" .. base_name)
part_base:setCondition(durability_base)
local part_top = player_inv:AddItem("TOC.ProstPart" .. top_name)
part_top:setCondition(durability_top)
end
function ProsthesisRecipes.OnCreateProsthesisPartItem(items, result, player, selectedItem)
-- TODO Assign condition here from the table
end
-- Parts should have a default condition max set at creation
-- When we create a prosthesis, we carry the condition from the parts
-- If we disassemble the prosthesis, the condition will be carried back to the parts
-- Speed stat should be managed in another way, so change it

View File

@@ -170,8 +170,6 @@ local function UpdatePlayerHealth(player, part_data)
end
-- MAIN UPDATE FUNCTIONS
local function TocUpdateOnTick()
local player = getPlayer()
@@ -187,6 +185,7 @@ local function TocUpdateOnTick()
end
local function TocUpdateEveryTenMinutes()
local player = getPlayer()
@@ -229,6 +228,7 @@ local function TocUpdateEveryTenMinutes()
end
end
local function TocUpdateEveryOneMinute()
local player = getPlayer()
@@ -258,6 +258,14 @@ end
local function TocOnDamage(player, type, amount)
end
Events.OnTick.Add(TocUpdateOnTick)
Events.EveryTenMinutes.Add(TocUpdateEveryTenMinutes)
Events.EveryOneMinute.Add(TocUpdateEveryOneMinute)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
models_stuff/foot_icon.psd Normal file

Binary file not shown.

View File

@@ -69,14 +69,6 @@ def generate_clothing_item(name, model, texture_choices):
with open(path_idtable, "ab") as file:
tree_guid.write(file, encoding='utf-8', pretty_print=True)
def generate_recipe(recipe_name, recipe_items, result_name, time, skill_required, tooltip):
root_element = f"recipe {recipe_name}\n"
root_element += "\t{\n"
@@ -153,16 +145,13 @@ excel_path = r'python_helpers/modules_prost.xlsx'
df_base = read_table(excel_path, "BaseTable")
df_top = read_table(excel_path, "TopTable")
# CLOTHING GENERATION PASS
limbs = ["Hand", "LowerArm"]
sides = ["Left", "Right"]
prost_bodylocations = ["TOC_ArmRightProsthesis", "TOC_ArmLeftProsthesis"]
texture_types = ["Wooden", "Metal"]
# CLOTHING GENERATION PASS
for base_row in df_base.iterrows():
for top_row in df_top.iterrows():
base_name = base_row[1][0]
@@ -174,11 +163,6 @@ for base_row in df_base.iterrows():
texture_choices = {r"Amputations\\Upperarm\\skin01_b"}
generate_clothing_item(current_name, "test", texture_choices)
# ITEM GENERATION PASS - ASSEMBLED
for base_row in df_base.iterrows():
for top_row in df_top.iterrows():
@@ -199,7 +183,6 @@ for base_row in df_base.iterrows():
icon = "metalLeg"
generate_item(item_id, weight, item_type, display_category, display_name, icon, "TempTooltip", "false", clothing_item_name, bl, "Hands")
# ITEM GENERATION PASS - Single item to assemble stuff
def generate_normal_items(df, type):
for row in df.iterrows():
@@ -234,11 +217,3 @@ for base_row in df_base.iterrows():
skill_required = ["FirstAid","2"] # TODO Change this
tooltip = "Tooltip_test"
generate_recipe(recipe_name, recipe_items, result, time, skill_required, tooltip)
# GENERATE NEW GUID TABLE