Overrided mods instead of just replacing them
This commit is contained in:
@@ -1,164 +0,0 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
require "TimedActions/ISEquipWeaponAction"
|
||||
local burnFact = 1.3
|
||||
|
||||
function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
if maxTime ~= -1 then
|
||||
local maxTime_org = maxTime
|
||||
-- add a slight maxtime if the character is unhappy
|
||||
maxTime = maxTime + ((self.character:getMoodles():getMoodleLevel(MoodleType.Unhappy)) * 10)
|
||||
|
||||
-- add more time if the character have his hands wounded
|
||||
if not self.ignoreHandsWounds then
|
||||
for i=BodyPartType.ToIndex(BodyPartType.Hand_L), BodyPartType.ToIndex(BodyPartType.ForeArm_R) do
|
||||
local part = self.character:getBodyDamage():getBodyPart(BodyPartType.FromIndex(i));
|
||||
maxTime = maxTime + part:getPain();
|
||||
end
|
||||
end
|
||||
|
||||
-- Apply a multiplier based on body temperature.
|
||||
maxTime = maxTime * self.character:getTimedActionTimeModifier();
|
||||
|
||||
if self.noAfectByCut then return maxTime; end
|
||||
--Added if cut
|
||||
local modData = getPlayer():getModData()
|
||||
local protPartNames = {"RightHand", "RightForearm", "LeftHand", "LeftForearm"}
|
||||
local otherPartNames = {"RightArm", "LeftArm"}
|
||||
|
||||
--TODO this is dumb, it just makes action a lot slower, without checking for special cases like reading. Find a better way
|
||||
for i,name in ipairs(protPartNames) do
|
||||
if modData.TOC[name].is_cut then
|
||||
if modData.TOC[name].is_prosthesis_equipped then
|
||||
maxTime = maxTime * modData.TOC[name].prosthesis_factor
|
||||
else
|
||||
maxTime = maxTime * 2;
|
||||
end
|
||||
if modData.TOC[name].is_cauterized then maxTime = maxTime * burnFact end
|
||||
end
|
||||
end
|
||||
|
||||
for i,name in ipairs(otherPartNames) do
|
||||
if modData.TOC[name].is_cut then
|
||||
maxTime = maxTime * 2
|
||||
if modData.TOC[name].is_cauterized then maxTime = maxTime * burnFact end
|
||||
end
|
||||
end
|
||||
|
||||
-- Protheses perks stuff
|
||||
if modData.TOC.RightHand.is_cut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.RightHand)) / 20) end
|
||||
if modData.TOC.LeftHand.is_cut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.LeftHand)) / 20) end
|
||||
|
||||
if maxTime > 10 * maxTime_org then maxTime = 10 * maxTime_org end
|
||||
end
|
||||
return maxTime;
|
||||
end
|
||||
|
||||
function ISEquipWeaponAction:perform()
|
||||
if self.sound then
|
||||
self.character:getEmitter():stopSound(self.sound)
|
||||
end
|
||||
|
||||
self.item:setJobDelta(0.0);
|
||||
|
||||
if self:isAlreadyEquipped(self.item) then
|
||||
ISBaseTimedAction.perform(self);
|
||||
return
|
||||
end
|
||||
|
||||
if self.character:isEquippedClothing(self.item) then
|
||||
self.character:removeWornItem(self.item)
|
||||
triggerEvent("OnClothingUpdated", self.character)
|
||||
end
|
||||
|
||||
self.item:getContainer():setDrawDirty(true);
|
||||
forceDropHeavyItems(self.character)
|
||||
|
||||
if self.fromHotbar then
|
||||
local hotbar = getPlayerHotbar(self.character:getPlayerNum());
|
||||
hotbar.chr:removeAttachedItem(self.item);
|
||||
self:setOverrideHandModels(self.item, nil)
|
||||
end
|
||||
|
||||
if not self.twoHands then
|
||||
-- equip primary weapon
|
||||
if(self.primary) then
|
||||
-- if the previous weapon need to be equipped in both hands, we then remove it
|
||||
if self.character:getSecondaryHandItem() and self.character:getSecondaryHandItem():isRequiresEquippedBothHands() then
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
-- if this weapon is already equiped in the 2nd hand, we remove it
|
||||
if(self.character:getSecondaryHandItem() == self.item or self.character:getSecondaryHandItem() == self.character:getPrimaryHandItem()) then
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
if not self.character:getPrimaryHandItem() or self.character:getPrimaryHandItem() ~= self.item then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
end
|
||||
else -- second hand weapon
|
||||
-- if the previous weapon need to be equipped in both hands, we then remove it
|
||||
if self.character:getPrimaryHandItem() and self.character:getPrimaryHandItem():isRequiresEquippedBothHands() then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
end
|
||||
-- if this weapon is already equiped in the 1st hand, we remove it
|
||||
if(self.character:getPrimaryHandItem() == self.item or self.character:getSecondaryHandItem() == self.character:getPrimaryHandItem()) then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
end
|
||||
if not self.character:getSecondaryHandItem() or self.character:getSecondaryHandItem() ~= self.item then
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
end
|
||||
else
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
|
||||
local modData = self.character:getModData()
|
||||
if not self.item:isRequiresEquippedBothHands() then
|
||||
if modData.TOC.RightHand.is_cut then
|
||||
if modData.TOC.RightForearm.is_cut then
|
||||
if not modData.TOC.RightForearm.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
else
|
||||
if not modData.TOC.RightHand.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
end
|
||||
end
|
||||
if modData.TOC.LeftHand.is_cut then
|
||||
if modData.TOC.LeftForearm.is_cut then
|
||||
if not modData.TOC.LeftForearm.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
else
|
||||
if not modData.TOC.LeftHand.is_prosthesis_equipped then
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
end
|
||||
end
|
||||
if (modData.TOC.RightHand.is_cut and not (modData.TOC.RightHand.is_prosthesis_equipped or modData.TOC.RightForearm.is_prosthesis_equipped)) and (modData.TOC.LeftHand.is_cut and not (modData.TOC.LeftHand.is_prosthesis_equipped or modData.TOC.LeftForearm.is_prosthesis_equipped)) then
|
||||
self.character:dropHandItems();
|
||||
end
|
||||
end
|
||||
|
||||
if self.item:isRequiresEquippedBothHands() and ((modData.TOC.RightHand.is_cut and not modData.TOC.RightHand.is_prosthesis_equipped) or (modData.TOC.RightForearm.is_cut and not modData.TOC.RightForearm.is_prosthesis_equipped) or (modData.TOC.LeftHand.is_cut and not modData.TOC.LeftHand.is_prosthesis_equipped) or (modData.TOC.LeftForearm.is_cut and not modData.TOC.LeftForearm.is_prosthesis_equipped)) then
|
||||
self.character:dropHandItems();
|
||||
end
|
||||
|
||||
--if self.item:canBeActivated() and ((instanceof("Drainable", self.item) and self.item:getUsedDelta() > 0) or not instanceof("Drainable", self.item)) then
|
||||
if self.item:canBeActivated() then
|
||||
self.item:setActivated(true);
|
||||
end
|
||||
getPlayerInventory(self.character:getPlayerNum()):refreshBackpacks();
|
||||
|
||||
-- needed to remove from queue / start next.
|
||||
ISBaseTimedAction.perform(self);
|
||||
end
|
||||
@@ -47,7 +47,7 @@ function ISInstallProsthesis:perform()
|
||||
|
||||
|
||||
if part_name then
|
||||
toc_data[part_name].is_prosthesis_equipped = true
|
||||
toc_data[part_name].is_prosthesis_equipped = true -- TODO should we show that the hand has a prost too if it's installed in the forearm?
|
||||
toc_data[part_name].prosthesis_factor = TocFindProsthesisFactorFromItem(self.cloth)
|
||||
|
||||
self.character:getInventory():Remove(self.item)
|
||||
|
||||
@@ -43,13 +43,13 @@ function ISUninstallProsthesis:perform()
|
||||
|
||||
local toc_data = self.character:getModData().TOC
|
||||
local body_part_type = self.bodyPart:getType()
|
||||
local accepting_body_parts = GetAcceptingProsthesisBodyParts()
|
||||
local accepting_body_parts = GetAcceptingProsthesisBodyPartTypes()
|
||||
|
||||
if accepting_body_parts == nil then
|
||||
return -- should never happen
|
||||
end
|
||||
|
||||
for _, v in ipairs(GetAcceptingProsthesisBodyParts()) do
|
||||
for _, v in ipairs(GetAcceptingProsthesisBodyPartTypes()) do
|
||||
if self.bodyPart:getType() == v then
|
||||
local part_name = FindTocBodyPartNameFromBodyPartType(v)
|
||||
|
||||
|
||||
94
media/lua/client/TimedActions/OverridedFunctions.lua
Normal file
94
media/lua/client/TimedActions/OverridedFunctions.lua
Normal file
@@ -0,0 +1,94 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
require "TimedActions/ISEquipWeaponAction"
|
||||
|
||||
|
||||
local og_ISEquipTimedActionAdjustMaxTime = ISBaseTimedAction.adjustMaxTime
|
||||
|
||||
function ISBaseTimedAction:adjustMaxTime(maxTime)
|
||||
|
||||
local original_max_time = og_ISEquipTimedActionAdjustMaxTime(self, maxTime) -- TODO will it work?
|
||||
local modified_max_time = original_max_time
|
||||
|
||||
local toc_data = getPlayer():getModData().TOC
|
||||
local burn_factor = 1.3
|
||||
|
||||
-- To make it faster, let's have everything already written in another func
|
||||
local all_body_parts = GetBodyParts()
|
||||
|
||||
|
||||
-- TODO this gets awfully slow really quick, doesn't even make much sense.
|
||||
for _, part_name in ipairs(all_body_parts) do
|
||||
|
||||
|
||||
if toc_data[part_name].is_cut then
|
||||
|
||||
if toc_data[part_name].is_prosthesis_equipped then
|
||||
modified_max_time = modified_max_time * toc_data[part_name].prosthesis_factor
|
||||
|
||||
else
|
||||
modified_max_time = modified_max_time * 2
|
||||
end
|
||||
if toc_data[part_name].is_cauterized then
|
||||
modified_max_time = modified_max_time * burn_factor
|
||||
end
|
||||
|
||||
|
||||
-- Perk scaling
|
||||
if part_name == "RightHand" or part_name == "LeftHand" then
|
||||
modified_max_time = modified_max_time * (1 + (9 - self.character:getPerkLevel(Perks[part_name])) / 20 )
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if modified_max_time > 10 * original_max_time then modified_max_time = 10 * original_max_time end
|
||||
return modified_max_time
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local og_ISEquipWeaponActionPerform = ISEquipWeaponAction.perform
|
||||
|
||||
function ISEquipWeaponAction:perform()
|
||||
og_ISEquipWeaponActionPerform(self)
|
||||
local toc_data = self.character:getModData().TOC
|
||||
local can_be_held = {}
|
||||
|
||||
for _, side in ipairs ({"Left", "Right"}) do
|
||||
can_be_held[side] = true
|
||||
|
||||
if toc_data[side .. "Hand"].is_cut then
|
||||
if toc_data[side .. "Forearm"].is_cut then
|
||||
if not toc_data[side .. "Forearm"].is_prosthesis_equipped then
|
||||
can_be_held[side] = false
|
||||
end
|
||||
elseif not toc_data[side .. "Hand"].is_prosthesis_equipped then
|
||||
can_be_held[side] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not self.item:isRequiresEquippedBothHands() then
|
||||
if can_be_held["Right"] and not can_be_held["Left"] then
|
||||
self.character:setPrimaryHandItem(self.item)
|
||||
self.character:setSecondaryHandItem(nil)
|
||||
elseif not can_be_held["Right"] and can_be_held["Left"] then
|
||||
self.character:setPrimaryHandItem(nil)
|
||||
self.character:setSecondaryHandItem(nil)
|
||||
elseif not can_be_held["Left"] and not can_be_held["Right"] then
|
||||
self.character:dropHandItems()
|
||||
end
|
||||
else
|
||||
if (can_be_held["Right"] and not can_be_held["Left"]) or
|
||||
(not can_be_held["Right"] and can_be_held["Left"]) or
|
||||
(not can_be_held["Left"] and not can_be_held["Right"]) then
|
||||
self.character:dropHandItems()
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -24,7 +24,7 @@ function GetOtherBodyPartTypes()
|
||||
end
|
||||
|
||||
|
||||
function GetAcceptingProsthesisBodyParts()
|
||||
function GetAcceptingProsthesisBodyPartTypes()
|
||||
|
||||
|
||||
return {BodyPartType.Hand_R, BodyPartType.ForeArm_R,
|
||||
@@ -33,8 +33,13 @@ function GetAcceptingProsthesisBodyParts()
|
||||
|
||||
end
|
||||
|
||||
function GetAcceptingProsthesisBodyParts()
|
||||
return {"RightHand", "RightForearm", "LeftHand", "LeftForearm"}
|
||||
end
|
||||
|
||||
|
||||
function GetNonAcceptingProsthesisBodyParts()
|
||||
return {"RightArm", "LeftArm"}
|
||||
end
|
||||
local function PartNameToBodyLocation(name)
|
||||
if name == "RightHand" then return "ArmRight_Prot" end
|
||||
if name == "RightForearm" then return "ArmRight_Prot" end
|
||||
|
||||
Reference in New Issue
Block a user