Fixed prosth stuff

This commit is contained in:
Pao
2023-01-13 22:49:41 +01:00
parent 416fcfb9a2
commit 59d834c91e
8 changed files with 93 additions and 263 deletions

View File

@@ -14,3 +14,27 @@ There are 3 prosthesis models, wooden hook, metal hook and metal hand. Equipped
# Context # Context
This is the beta of my first mod, it means that the main features are there, but I'm still adding features and fixing bugs. I also learn how to use git with this mod. I envy an act 2 to my mod for the legs once it is finished. If you want to redo the model, texture and icon, you are welcome! Contact me on the official game discord. @MrBounty. If you encounter a bug, try to detail as much as possible the conditions for the appearance of the bug. Like the exact action that created this bug and the previous few actions, or whatever you think is relevant. This is the beta of my first mod, it means that the main features are there, but I'm still adding features and fixing bugs. I also learn how to use git with this mod. I envy an act 2 to my mod for the legs once it is finished. If you want to redo the model, texture and icon, you are welcome! Contact me on the official game discord. @MrBounty. If you encounter a bug, try to detail as much as possible the conditions for the appearance of the bug. Like the exact action that created this bug and the previous few actions, or whatever you think is relevant.
[h1]The Only Cure but better[\h1]
A working version for SP and MP.
I'm not gonna bother "adding" stuff, for now.
If Mr Bounty returns, I'm probably not gonna continue this.
[h1]FIXED[/h1]
- The Only Cure UI not showing in MP
- Operating with oven completely broken
- Invisible prosthesis on female models (still WIP, forearms especially)
[h1]ADDED[/h1]
- Debug cheats (MP Compatible) to reset amputations
- More stuff
Workshop ID: 2915572347
Mod ID: Amputation2
Workshop ID: 2915572347
Mod ID: Amputation2

View File

@@ -123,7 +123,7 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
-- admin stuff -- admin stuff
if clickedPlayer:getAccessLevel() == "Admin" then if player_obj:getAccessLevel() == "Admin" then
local cheat_option = rootMenu:addOption("Cheat") local cheat_option = rootMenu:addOption("Cheat")
local cheat_menu = context:getNew(context) local cheat_menu = context:getNew(context)
context:addSubMenu(cheat_option, cheat_menu) context:addSubMenu(cheat_option, cheat_menu)
@@ -144,7 +144,7 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
-- todo add checks so that we don't show these menus if a player has already beeen operated or amputated -- todo add checks so that we don't show these menus if a player has already beeen operated or amputated
local player_toc_data = getPlayer():getModData().TOC
for k_part, v_part in ipairs(GetBodyParts()) do for k_part, v_part in ipairs(GetBodyParts()) do
@@ -152,9 +152,9 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
if clickedPlayer == player_obj then if clickedPlayer == player_obj then
if getPlayer():getModData().TOC[v_part].is_cut == false then if player_toc_data[v_part].is_cut == false then
cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, CutLocal, player_obj, player_obj, v_part) cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, CutLocal, player_obj, player_obj, v_part)
elseif getPlayer():getModData().TOC[v_part].is_operated == false then elseif player_toc_data[v_part].is_operated == false and player_toc_data[v_part].is_amputation_shown then
operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, OperateLocal, player_obj, player_obj, v_part) operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, OperateLocal, player_obj, player_obj, v_part)
end end
@@ -187,7 +187,12 @@ end
TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjects, test) TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjects, test)
local player_obj = getSpecificPlayer(player) local player_obj = getSpecificPlayer(player)
--local clickedPlayer --local clickedPlayer
local modData = player_obj:getModData()
-- TODO Add a way to move the player towards the oven
local toc_data = player_obj:getModData().TOC
local is_main_menu_already_created = false local is_main_menu_already_created = false
@@ -201,7 +206,7 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
if v_stove:getCurrentTemperature() > 250 then if v_stove:getCurrentTemperature() > 250 then
for k_bodypart, v_bodypart in ipairs(GetBodyParts()) do for k_bodypart, v_bodypart in ipairs(GetBodyParts()) do
if modData.TOC[v_bodypart].is_cut and not modData.TOC[v_bodypart].is_operated then if toc_data[v_bodypart].is_cut and toc_data[v_bodypart].is_amputation_shown and not toc_data[v_bodypart].is_operated then
local subMenu = context:getNew(context); local subMenu = context:getNew(context);
if is_main_menu_already_created == false then if is_main_menu_already_created == false then

View File

@@ -39,7 +39,6 @@ function ISInstallProsthesis:perform()
local prosthesis_table = { local prosthesis_table = {
WoodenHook = { WoodenHook = {
material_id = 1 material_id = 1
}, },
@@ -49,24 +48,28 @@ function ISInstallProsthesis:perform()
MetalHand = { MetalHand = {
material_id = 3 material_id = 3
} }
} }
print(self.item) -- print(self.item)
-- TODO there is something wrong with how I'm managing prosthesis. they don't apply
-- TODO cheatMenu are fucked up, admin access is wrong
-- TODO make a parser or something I dont care -- TODO make a parser or something I dont care
-- Check Item before doing any of this shit maybe -- Check Item before doing any of this shit maybe
-- Assemble the correct name for the object -- Assemble the correct name for the object
local prosthesis_name = self.item:getname() .. "_" .. Right .. "_" .. Forearm --local prosthesis_name = self.item:getname() .. "_" .. Right .. "_" .. Forearm
-- for _, v in ipairs(GetLimbsBodyPartTypes()) do -- for _, v in ipairs(GetLimbsBodyPartTypes()) do
-- if v ~= BodyPartType.UpperArm_L or v ~= BodyPartType.UpperArm_R then -- if v ~= BodyPartType.UpperArm_L or v ~= BodyPartType.UpperArm_R then
-- if self.bodyPart:getType() == v then -- if self.bodyPart:getType() == v then
-- --local item_name = "TOC." -- --local item_name = "TOC."
-- --local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10 -- TODO why do we need this? -- --local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10
-- TODO why do we need this?
-- end -- end
@@ -136,21 +139,17 @@ function ISInstallProsthesis:perform()
if self.cloth ~= nil then if self.cloth ~= nil then
if self.bodyPart:getType() == BodyPartType.Hand_R then if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.IsEquiped = true; modData.TOC.RightHand.is_prosthesis_equipped = true;
modData.TOC.RightHand.Equip_mat_id = mat_id; modData.TOC.RightHand.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.RightHand.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.IsEquiped = true; modData.TOC.RightForearm.is_prosthesis_equipped = true;
modData.TOC.RightForearm.Equip_mat_id = mat_id; modData.TOC.RightForearm.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.RightForearm.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.Hand_L then elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.IsEquiped = true; modData.TOC.LeftHand.is_prosthesis_equipped = true;
modData.TOC.LeftHand.Equip_mat_id = mat_id; modData.TOC.LeftHand.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.LeftHand.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.IsEquiped = true; modData.TOC.LeftForearm.is_prosthesis_equipped = true;
modData.TOC.LeftForearm.Equip_mat_id = mat_id; modData.TOC.LeftForearm.prothesis_factor = find_protheseFact_TOC(self.cloth);
modData.TOC.LeftForearm.EquipFact = find_protheseFact_TOC(self.cloth);
end end
self.character:getInventory():Remove(self.item); self.character:getInventory():Remove(self.item);

View File

@@ -29,7 +29,7 @@ function ISOperateLimb:start()
end end
function ISOperateLimb:findArgs() function ISOperateLimb:findArgs()
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor); local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor)
if self.use_oven then if self.use_oven then
surgeon_factor = surgeon_factor + 100 surgeon_factor = surgeon_factor + 100
@@ -60,12 +60,12 @@ function ISOperateLimb:perform()
SendOperateLimb(self.patient, self.part_name, surgeon_factor, use_oven) SendOperateLimb(self.patient, self.part_name, surgeon_factor, use_oven)
--SendOperateArm(self.patient, self.part_name, surgeon_factor, use_oven) --SendOperateArm(self.patient, self.part_name, surgeon_factor, use_oven)
else else
OperateArm(self.part_name, surgeon_factor, use_oven) TheOnlyCure.OperateLimb(self.part_name, surgeon_factor, use_oven)
end end
self.surgeon:getXp():AddXP(Perks.Doctor, 400) self.surgeon:getXp():AddXP(Perks.Doctor, 400)
-- FIXME Add a check for kit to prevent errors -- FIXME Add a check for kit to prevent errors
if self.kit then if self.kit and not use_oven then
self.surgeon:getInventory():Remove(self.kit) self.surgeon:getInventory():Remove(self.kit)
end end

View File

@@ -41,19 +41,33 @@ function ISUninstallProsthesis:perform()
end end
end end
local modData = self.character:getModData() local toc_data = self.character:getModData().TOC
local body_part_type = self.bodyPart:getType()
local accepting_body_parts = GetAcceptingProsthesisBodyParts()
if accepting_body_parts == nil then
return -- should never happen
end
--if accepting_body_parts[body_part_type] then
-- toc_data[TOC_getBodyPart(body_part_type)]
--end
if self.bodyPart:getType() == BodyPartType.Hand_R then if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.is_prosthesis_equipped = false toc_data.RightHand.is_prosthesis_equipped = false
modData.TOC.RightHand.prothesis_factor = 1 toc_data.RightHand.prothesis_factor = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.is_prosthesis_equipped = false toc_data.RightForearm.is_prosthesis_equipped = false
modData.TOC.RightForearm.prothesis_factor = 1 toc_data.RightForearm.prothesis_factor = 1
elseif self.bodyPart:getType() == BodyPartType.Hand_L then elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.is_prosthesis_equipped = false toc_data.LeftHand.is_prosthesis_equipped = false
modData.TOC.LeftHand.prothesis_factor = 1 toc_data.LeftHand.prothesis_factor = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.is_prosthesis_equipped = false toc_data.LeftForearm.is_prosthesis_equipped = false
modData.TOC.LeftForearm.prothesis_factor = 1 toc_data.LeftForearm.prothesis_factor = 1
end end
local weight = math.floor(self.item:getWeight() * 10 + 0.5) local weight = math.floor(self.item:getWeight() * 10 + 0.5)

View File

@@ -1,133 +0,0 @@
require "TimedActions/ISBaseTimedAction"
ISInstallProthesis = ISBaseTimedAction:derive("ISInstallProthesis");
function ISInstallProthesis:isValid()
return true;
end
function ISInstallProthesis:update()
self.item:setJobDelta(self:getJobDelta());
end
function ISInstallProthesis:start()
self.item:setJobType("Install prothesis");
self.item:setJobDelta(0.0);
self:setActionAnim("WearClothing");
self:setAnimVariable("WearClothingLocation", "Jacket");
end
function ISInstallProthesis:stop()
ISBaseTimedAction.stop(self);
self.item:setJobDelta(0.0);
end
function ISInstallProthesis:perform()
self.item:setJobDelta(0.0);
local modData = self.character:getModData();
local lor = 0
local foh = 0
if self.bodyPart:getType() == BodyPartType.Hand_R then lor = 1; foh = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then lor = 1; foh = 2
elseif self.bodyPart:getType() == BodyPartType.Hand_L then lor = 0; foh = 1
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then lor = 0; foh = 2
end
local mat_id = 0
local weight = math.floor(self.item:getWeight() * 10 + 0.5) / 10
if weight == 1 and foh == 1 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_right_noHand");
mat_id = 1;
else
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_left_noHand");
mat_id = 1;
end
elseif weight == 0.5 and foh == 1 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_right_noHand");
mat_id = 2;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_left_noHand");
mat_id = 2;
end
elseif weight == 0.3 and foh == 1 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_right_noHand");
mat_id = 3;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_left_noHand");
mat_id = 3;
end
elseif weight == 1 and foh == 2 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_right_noForearm");
mat_id = 1;
else
self.cloth = self.character:getInventory():AddItem("TOC.WoodenHook_left_noForearm");
mat_id = 1;
end
elseif weight == 0.5 and foh == 2 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_right_noForearm");
mat_id = 2;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHook_left_noForearm");
mat_id = 2;
end
elseif weight == 0.3 and foh == 2 then
if lor == 1 then
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_right_noForearm");
mat_id = 3;
else
self.cloth = self.character:getInventory():AddItem("TOC.MetalHand_left_noForearm");
mat_id = 3;
end
end
if self.cloth ~= nil then
if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.IsEquiped = true;
modData.TOC.RightHand.Equip_mat_id = mat_id;
modData.TOC.RightHand.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.IsEquiped = true;
modData.TOC.RightForearm.Equip_mat_id = mat_id;
modData.TOC.RightForearm.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.IsEquiped = true;
modData.TOC.LeftHand.Equip_mat_id = mat_id;
modData.TOC.LeftHand.EquipFact = find_protheseFact_TOC(self.cloth);
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.IsEquiped = true;
modData.TOC.LeftForearm.Equip_mat_id = mat_id;
modData.TOC.LeftForearm.EquipFact = find_protheseFact_TOC(self.cloth);
end
self.character:getInventory():Remove(self.item);
self.character:setWornItem(self.cloth:getBodyLocation(), self.cloth);
end
self.character:transmitModData()
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self);
end
function ISInstallProthesis:new(character, item, bodyPart)
local o = ISBaseTimedAction.new(self, character);
o.item = item;
o.bodyPart = bodyPart;
o.maxTime = 100;
o.stopOnWalk = true;
o.stopOnRun = true;
o.cloth = nil;
o.ignoreHandsWounds = false;
o.fromHotbar = true; -- just to disable hotbar:update() during the wearing
if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o;
end

View File

@@ -1,92 +0,0 @@
require "TimedActions/ISBaseTimedAction"
ISUninstallProthesis = ISBaseTimedAction:derive("ISUninstallProthesis");
function ISUninstallProthesis:isValid()
return true;
end
function ISUninstallProthesis:update()
self.item:setJobDelta(self:getJobDelta());
end
function ISUninstallProthesis:start()
self.item:setJobType("Uninstall prothesis");
self.item:setJobDelta(0.0);
self:setActionAnim("WearClothing");
if self.item:IsClothing() then
self:setAnimVariable("WearClothingLocation", "Jacket")
elseif self.item:IsInventoryContainer() and self.item:canBeEquipped() ~= "" then
self:setAnimVariable("WearClothingLocation", "Jacket")
end
end
function ISUninstallProthesis:stop()
ISBaseTimedAction.stop(self);
self.item:setJobDelta(0.0);
end
function ISUninstallProthesis:perform()
self.item:getContainer():setDrawDirty(true);
self.item:setJobDelta(0.0);
if instanceof(self.item, "InventoryContainer") and self.item:canBeEquipped() ~= "" then
self.character:removeFromHands(self.item);
self.character:setWornItem(self.item:canBeEquipped(), self.item);
getPlayerInventory(self.character:getPlayerNum()):refreshBackpacks();
elseif self.item:getCategory() == "Clothing" then
if self.item:getBodyLocation() ~= "" then
self.character:setWornItem(self.item:getBodyLocation(), self.item);
end
end
local modData = self.character:getModData()
if self.bodyPart:getType() == BodyPartType.Hand_R then
modData.TOC.RightHand.IsEquiped = false;
modData.TOC.RightHand.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
modData.TOC.RightForearm.IsEquiped = false;
modData.TOC.RightForearm.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
modData.TOC.LeftHand.IsEquiped = false;
modData.TOC.LeftHand.EquipFact = 1;
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
modData.TOC.LeftForearm.IsEquiped = false;
modData.TOC.LeftForearm.EquipFact = 1;
end
local weight = math.floor(self.item:getWeight() * 10 + 0.5)
if weight == 10 then
self.character:getInventory():AddItem("TOC.WoodenHook")
elseif weight == 5 then
self.character:getInventory():AddItem("TOC.MetalHook")
elseif weight == 3 then
self.character:getInventory():AddItem("TOC.MetalHand")
elseif weight == 20 then
self.character:getInventory():AddItem("TOC.WoodenHook")
elseif weight == 15 then
self.character:getInventory():AddItem("TOC.MetalHook")
elseif weight == 12 then
self.character:getInventory():AddItem("TOC.MetalHand")
end
self.character:setWornItem(self.item:getBodyLocation(), nil);
self.character:getInventory():Remove(self.item);
self.character:transmitModData();
-- needed to remove from queue / start next.
ISBaseTimedAction.perform(self);
end
function ISUninstallProthesis:new(character, item, bodyPart)
local o = ISBaseTimedAction.new(self, character);
o.item = item;
o.character = character;
o.bodyPart = bodyPart;
o.maxTime = 100;
o.stopOnWalk = true;
o.stopOnRun = true;
o.ignoreHandsWounds = false;
o.fromHotbar = true; -- just to disable hotbar:update() during the wearing
if o.character:isTimedActionInstant() then o.maxTime = 1; end
return o;
end

View File

@@ -19,6 +19,17 @@ function GetOtherBodyPartTypes()
end end
function GetAcceptingProsthesisBodyParts()
function GetLimbsBodyPartTypes()
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R,
BodyPartType.Hand_L, BodyPartType.ForeArm_L}
end
end
function find_clothName_TOC(bodyPart) function find_clothName_TOC(bodyPart)
if bodyPart:getType() == BodyPartType.Hand_R then return "TOC.ArmRight_noHand" if bodyPart:getType() == BodyPartType.Hand_R then return "TOC.ArmRight_noHand"
@@ -93,9 +104,11 @@ function find_protheseFact_TOC(item)
end end
function CanBeCut(partName) function CanBeCut(partName)
return not getPlayer():getModData().TOC[partName].IsCut return not getPlayer():getModData().TOC[partName].is_cut
end end
function CanBeOperate(partName) function CanBeOperate(partName)
return getPlayer():getModData().TOC[partName].IsCut and not getPlayer():getModData().TOC[partName].IsOperated and not getPlayer():getModData().TOC[partName].IsCicatrized return getPlayer():getModData().TOC[partName].is_cut
and not getPlayer():getModData().TOC[partName].is_operated
and not getPlayer():getModData().TOC[partName].is_cicatrized
end end