Fixed prosth stuff
This commit is contained in:
@@ -123,7 +123,7 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
|
||||
|
||||
|
||||
-- admin stuff
|
||||
if clickedPlayer:getAccessLevel() == "Admin" then
|
||||
if player_obj:getAccessLevel() == "Admin" then
|
||||
local cheat_option = rootMenu:addOption("Cheat")
|
||||
local cheat_menu = context:getNew(context)
|
||||
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
|
||||
|
||||
|
||||
|
||||
local player_toc_data = getPlayer():getModData().TOC
|
||||
|
||||
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 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)
|
||||
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)
|
||||
|
||||
end
|
||||
@@ -187,7 +187,12 @@ end
|
||||
TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjects, test)
|
||||
local player_obj = getSpecificPlayer(player)
|
||||
--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
|
||||
|
||||
@@ -201,7 +206,7 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
|
||||
if v_stove:getCurrentTemperature() > 250 then
|
||||
|
||||
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);
|
||||
|
||||
if is_main_menu_already_created == false then
|
||||
|
||||
@@ -39,7 +39,6 @@ function ISInstallProsthesis:perform()
|
||||
|
||||
|
||||
local prosthesis_table = {
|
||||
|
||||
WoodenHook = {
|
||||
material_id = 1
|
||||
},
|
||||
@@ -49,24 +48,28 @@ function ISInstallProsthesis:perform()
|
||||
MetalHand = {
|
||||
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
|
||||
-- Check Item before doing any of this shit maybe
|
||||
-- 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
|
||||
-- if v ~= BodyPartType.UpperArm_L or v ~= BodyPartType.UpperArm_R then
|
||||
|
||||
|
||||
-- if self.bodyPart:getType() == v then
|
||||
-- --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
|
||||
|
||||
@@ -136,21 +139,17 @@ function ISInstallProsthesis:perform()
|
||||
|
||||
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);
|
||||
modData.TOC.RightHand.is_prosthesis_equipped = true;
|
||||
modData.TOC.RightHand.prothesis_factor = 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);
|
||||
modData.TOC.RightForearm.is_prosthesis_equipped = true;
|
||||
modData.TOC.RightForearm.prothesis_factor = 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);
|
||||
modData.TOC.LeftHand.is_prosthesis_equipped = true;
|
||||
modData.TOC.LeftHand.prothesis_factor = 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);
|
||||
modData.TOC.LeftForearm.is_prosthesis_equipped = true;
|
||||
modData.TOC.LeftForearm.prothesis_factor = find_protheseFact_TOC(self.cloth);
|
||||
end
|
||||
|
||||
self.character:getInventory():Remove(self.item);
|
||||
|
||||
@@ -29,7 +29,7 @@ function ISOperateLimb:start()
|
||||
end
|
||||
|
||||
function ISOperateLimb:findArgs()
|
||||
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor);
|
||||
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor)
|
||||
|
||||
if self.use_oven then
|
||||
surgeon_factor = surgeon_factor + 100
|
||||
@@ -60,12 +60,12 @@ function ISOperateLimb:perform()
|
||||
SendOperateLimb(self.patient, self.part_name, surgeon_factor, use_oven)
|
||||
--SendOperateArm(self.patient, self.part_name, surgeon_factor, use_oven)
|
||||
else
|
||||
OperateArm(self.part_name, surgeon_factor, use_oven)
|
||||
TheOnlyCure.OperateLimb(self.part_name, surgeon_factor, use_oven)
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
|
||||
-- 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)
|
||||
end
|
||||
|
||||
|
||||
@@ -41,19 +41,33 @@ function ISUninstallProsthesis:perform()
|
||||
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
|
||||
modData.TOC.RightHand.is_prosthesis_equipped = false
|
||||
modData.TOC.RightHand.prothesis_factor = 1
|
||||
toc_data.RightHand.is_prosthesis_equipped = false
|
||||
toc_data.RightHand.prothesis_factor = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_R then
|
||||
modData.TOC.RightForearm.is_prosthesis_equipped = false
|
||||
modData.TOC.RightForearm.prothesis_factor = 1
|
||||
toc_data.RightForearm.is_prosthesis_equipped = false
|
||||
toc_data.RightForearm.prothesis_factor = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.Hand_L then
|
||||
modData.TOC.LeftHand.is_prosthesis_equipped = false
|
||||
modData.TOC.LeftHand.prothesis_factor = 1
|
||||
toc_data.LeftHand.is_prosthesis_equipped = false
|
||||
toc_data.LeftHand.prothesis_factor = 1
|
||||
elseif self.bodyPart:getType() == BodyPartType.ForeArm_L then
|
||||
modData.TOC.LeftForearm.is_prosthesis_equipped = false
|
||||
modData.TOC.LeftForearm.prothesis_factor = 1
|
||||
toc_data.LeftForearm.is_prosthesis_equipped = false
|
||||
toc_data.LeftForearm.prothesis_factor = 1
|
||||
end
|
||||
|
||||
local weight = math.floor(self.item:getWeight() * 10 + 0.5)
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -19,6 +19,17 @@ function GetOtherBodyPartTypes()
|
||||
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)
|
||||
if bodyPart:getType() == BodyPartType.Hand_R then return "TOC.ArmRight_noHand"
|
||||
@@ -93,9 +104,11 @@ function find_protheseFact_TOC(item)
|
||||
end
|
||||
|
||||
function CanBeCut(partName)
|
||||
return not getPlayer():getModData().TOC[partName].IsCut
|
||||
return not getPlayer():getModData().TOC[partName].is_cut
|
||||
end
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user