more setup stuff for modular prosthetics
This commit is contained in:
@@ -6,19 +6,47 @@
|
|||||||
|
|
||||||
---Equip a prosthesis transforming a normal item into a clothing item
|
---Equip a prosthesis transforming a normal item into a clothing item
|
||||||
---@param part_name string
|
---@param part_name string
|
||||||
|
---@param prosthesis_item any the prosthesis item
|
||||||
---@param prosthesis_base_name string
|
---@param prosthesis_base_name string
|
||||||
function TocEquipProsthesis(part_name, prosthesis_base_name)
|
function TocEquipProsthesis(part_name, prosthesis_item, prosthesis_base_name)
|
||||||
|
|
||||||
-- TODO probably will have to move this from the TOC menu to classic equip to have dynamic durability
|
-- TODO probably will have to move this from the TOC menu to classic equip to have dynamic durability
|
||||||
|
-- TODO We need to pass the original item so we can get its data!
|
||||||
|
|
||||||
local player = getPlayer()
|
local player = getPlayer()
|
||||||
|
|
||||||
local toc_data = player:getModData().TOC
|
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 prosthesis_name = TocFindCorrectClothingProsthesis(prosthesis_base_name, part_name)
|
||||||
local added_prosthesis = player:getInventory():AddItem(prosthesis_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,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--print("TOC: Test durability new item " .. added_prosthesis_mod_data.TOC.durability)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if part_name ~= nil then
|
if part_name ~= nil then
|
||||||
|
|
||||||
if added_prosthesis ~= nil then
|
if added_prosthesis ~= nil then
|
||||||
@@ -44,6 +72,8 @@ end
|
|||||||
function TocUnequipProsthesis(patient, part_name, equipped_prosthesis)
|
function TocUnequipProsthesis(patient, part_name, equipped_prosthesis)
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO Pass the parameters generated from EquipProsthesis to the re-generated normal item
|
||||||
|
|
||||||
local toc_data = patient:getModData().TOC
|
local toc_data = patient:getModData().TOC
|
||||||
toc_data.Limbs[part_name].is_prosthesis_equipped = false
|
toc_data.Limbs[part_name].is_prosthesis_equipped = false
|
||||||
|
|
||||||
@@ -54,14 +84,21 @@ function TocUnequipProsthesis(patient, part_name, equipped_prosthesis)
|
|||||||
for _, prost_v in ipairs(GetProsthesisList()) do
|
for _, prost_v in ipairs(GetProsthesisList()) do
|
||||||
local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v)
|
local prosthesis_name = string.match(equipped_prosthesis_full_type, prost_v)
|
||||||
if prosthesis_name then
|
if prosthesis_name then
|
||||||
patient:getInventory():AddItem("TOC." .. prosthesis_name)
|
|
||||||
|
-- Get mod data from equipped prosthesis so we can get its parameters
|
||||||
|
local equipped_prosthesis_mod_data = equipped_prosthesis:getModData()
|
||||||
|
|
||||||
|
|
||||||
|
local base_prosthesis_item = patient:getInventory():AddItem("TOC." .. prosthesis_name)
|
||||||
|
local base_prosthesis_item_mod_data = base_prosthesis_item.getModData()
|
||||||
|
base_prosthesis_item_mod_data.TOC = {
|
||||||
|
durability = equipped_prosthesis_mod_data.TOC.durability,
|
||||||
|
speed = equipped_prosthesis_mod_data.TOC.speed
|
||||||
|
}
|
||||||
|
|
||||||
patient:setWornItem(equipped_prosthesis:getBodyLocation(), nil)
|
patient:setWornItem(equipped_prosthesis:getBodyLocation(), nil)
|
||||||
patient:getInventory():Remove(equipped_prosthesis)
|
patient:getInventory():Remove(equipped_prosthesis)
|
||||||
toc_data.Limbs[part_name].equipped_prosthesis = nil
|
toc_data.Limbs[part_name].equipped_prosthesis = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -68,10 +68,11 @@ end
|
|||||||
ServerCommands.EquipProsthesis = function(arg)
|
ServerCommands.EquipProsthesis = function(arg)
|
||||||
|
|
||||||
-- part_name = arg[1]
|
-- part_name = arg[1]
|
||||||
-- prosthesis = arg[2]
|
-- prosthesis_item = arg[2]
|
||||||
|
-- prosthesis_name = arg[3]
|
||||||
|
|
||||||
local data = arg["toSend"]
|
local data = arg["toSend"]
|
||||||
TocEquipProsthesis(data[1], data[2])
|
TocEquipProsthesis(data[1], data[2], data[3])
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -199,12 +200,12 @@ function SendOperateLimb(player, part_name, surgeon_factor, use_oven)
|
|||||||
sendClientCommand("TOC", "SendServer", arg)
|
sendClientCommand("TOC", "SendServer", arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function SendEquipProsthesis(player, part_name, prosthesis_base_name)
|
function SendEquipProsthesis(player, part_name, item, prosthesis_base_name)
|
||||||
local arg = {}
|
local arg = {}
|
||||||
arg["From"] = getPlayer():getOnlineID()
|
arg["From"] = getPlayer():getOnlineID()
|
||||||
arg["To"] = player:getOnlineID()
|
arg["To"] = player:getOnlineID()
|
||||||
arg["command"] = "EquipProsthesis"
|
arg["command"] = "EquipProsthesis"
|
||||||
arg["toSend"] = { part_name, prosthesis_base_name}
|
arg["toSend"] = { part_name, item, prosthesis_base_name}
|
||||||
sendClientCommand("TOC", "SendServer", arg)
|
sendClientCommand("TOC", "SendServer", arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -146,5 +146,7 @@ function TocTestItem()
|
|||||||
local found_item = player_inventory:FindAndReturn(item_name)
|
local found_item = player_inventory:FindAndReturn(item_name)
|
||||||
|
|
||||||
print(found_item:getID())
|
print(found_item:getID())
|
||||||
|
print("_______________")
|
||||||
|
found_item:setID(12334)
|
||||||
|
print(found_item:getID())
|
||||||
end
|
end
|
||||||
@@ -28,9 +28,11 @@ local TopStats = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function GenerateEquippedProsthesis(prosthesis_item)
|
function GenerateEquippedProsthesis(prosthesis_item, limb)
|
||||||
-- TODO Durability should be decided from the clothing item xml. Same thing for disassembling stuff
|
-- 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
|
||||||
|
|
||||||
local durability = 0
|
local durability = 0
|
||||||
local speed = 0
|
local speed = 0
|
||||||
|
|
||||||
@@ -54,39 +56,36 @@ function GenerateEquippedProsthesis(prosthesis_item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO This won't work since if we unequip it we would lose this stuff. We need to bind it to the item
|
local item_mod_data = prosthesis_item:getModData()
|
||||||
local prosthesis_table = {
|
|
||||||
prost_id = prosthesis_item:getID(),
|
--------------------
|
||||||
prost_name = prosthesis_name,
|
-- TEST STUFF
|
||||||
|
durability = 12
|
||||||
|
speed = 51
|
||||||
|
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
|
||||||
|
item_mod_data.TOC = {
|
||||||
durability = durability,
|
durability = durability,
|
||||||
speed = speed
|
speed = speed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return prosthesis_table
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local ProsthesisRecipe = {}
|
--local ProsthesisRecipe = {}
|
||||||
|
|
||||||
|
|
||||||
function ProsthesisRecipe.OnCreate.Hook(items, result, player, selectedItem)
|
-- function ProsthesisRecipe.OnCreate.Hook(items, result, player, selectedItem)
|
||||||
|
|
||||||
-- Set mod data for item with durability and all that crap
|
-- -- Set mod data for item with durability and all that crap
|
||||||
|
|
||||||
|
|
||||||
-- when we equip a prosthesis, we're gonna pass these parameters to the newly generated clothing item
|
-- -- 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
|
-- -- when we unequip it, we regen the normal item with the parameters from the clothing item
|
||||||
|
|
||||||
|
|
||||||
end
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function DoWeReallyNeedThis()
|
|
||||||
|
|
||||||
-- We need a durability check... so in modData
|
|
||||||
|
|
||||||
--
|
|
||||||
end
|
|
||||||
@@ -3,6 +3,9 @@ require "TimedActions/ISBaseTimedAction"
|
|||||||
ISInstallProsthesis = ISBaseTimedAction:derive("ISInstallProsthesis");
|
ISInstallProsthesis = ISBaseTimedAction:derive("ISInstallProsthesis");
|
||||||
|
|
||||||
function ISInstallProsthesis:isValid()
|
function ISInstallProsthesis:isValid()
|
||||||
|
|
||||||
|
-- TODO add here conditions if the action can be performed or not, so if thing is in inventory
|
||||||
|
-- TODO 'not sure about multiplayer, maybe an overriding check?
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -49,17 +52,19 @@ function ISInstallProsthesis:perform()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.surgeon:getInventory():Remove(prosthesis_base_name) -- Removes the base item and substitute it with the part one
|
|
||||||
|
|
||||||
|
|
||||||
if self.patient ~= self.surgeon and isClient() then
|
if self.patient ~= self.surgeon and isClient() then
|
||||||
|
|
||||||
SendEquipProsthesis(self.patient, self.part_name, prosthesis_base_name)
|
SendEquipProsthesis(self.patient, self.part_name, self.item, prosthesis_base_name)
|
||||||
else
|
else
|
||||||
TocEquipProsthesis(self.part_name, prosthesis_base_name)
|
TocEquipProsthesis(self.part_name, self.item, prosthesis_base_name)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
self.surgeon:getInventory():Remove(prosthesis_base_name) -- Removes the base item after we transferred everything
|
||||||
|
|
||||||
-- needed to remove from queue / start next.
|
-- needed to remove from queue / start next.
|
||||||
ISBaseTimedAction.perform(self)
|
ISBaseTimedAction.perform(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ recipe Make wooden hook
|
|||||||
Category: Surgeon,
|
Category: Surgeon,
|
||||||
Tooltip: Recipe_Tooltip_Wooden_hook,
|
Tooltip: Recipe_Tooltip_Wooden_hook,
|
||||||
NeedToBeLearn: true,
|
NeedToBeLearn: true,
|
||||||
OnCreate: ProsthesisRecipe.OnCreate.Hook,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recipe Make metal hook
|
recipe Make metal hook
|
||||||
|
|||||||
Reference in New Issue
Block a user