first commit
This commit is contained in:
163
media/lua/client/TimedActions/AddedToOther.lua
Normal file
163
media/lua/client/TimedActions/AddedToOther.lua
Normal file
@@ -0,0 +1,163 @@
|
||||
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"}
|
||||
|
||||
for i,name in ipairs(protPartNames) do
|
||||
if modData.TOC[name].IsCut then
|
||||
if modData.TOC[name].IsEquiped then
|
||||
maxTime = maxTime * modData.TOC[name].EquipFact;
|
||||
else
|
||||
maxTime = maxTime * 2;
|
||||
end
|
||||
if modData.TOC[name].IsBurn then maxTime = maxTime * burnFact end
|
||||
end
|
||||
end
|
||||
|
||||
for i,name in ipairs(otherPartNames) do
|
||||
if modData.TOC[name].IsCut then
|
||||
maxTime = maxTime * 2
|
||||
if modData.TOC[name].IsBurn then maxTime = maxTime * burnFact end
|
||||
end
|
||||
end
|
||||
|
||||
-- Protheses perks stuff
|
||||
if modData.TOC.RightHand.IsCut then maxTime = maxTime * (1 + (9 - self.character:getPerkLevel(Perks.RightHand)) / 20) end
|
||||
if modData.TOC.LeftHand.IsCut 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.IsCut then
|
||||
if modData.TOC.RightForearm.IsCut then
|
||||
if not modData.TOC.RightForearm.IsEquiped then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
else
|
||||
if not modData.TOC.RightHand.IsEquiped then
|
||||
self.character:setPrimaryHandItem(nil);
|
||||
self.character:setSecondaryHandItem(self.item);
|
||||
end
|
||||
end
|
||||
end
|
||||
if modData.TOC.LeftHand.IsCut then
|
||||
if modData.TOC.LeftForearm.IsCut then
|
||||
if not modData.TOC.LeftForearm.IsEquiped then
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
else
|
||||
if not modData.TOC.LeftHand.IsEquiped then
|
||||
self.character:setPrimaryHandItem(self.item);
|
||||
self.character:setSecondaryHandItem(nil);
|
||||
end
|
||||
end
|
||||
end
|
||||
if (modData.TOC.RightHand.IsCut and not (modData.TOC.RightHand.IsEquiped or modData.TOC.RightForearm.IsEquiped)) and (modData.TOC.LeftHand.IsCut and not (modData.TOC.LeftHand.IsEquiped or modData.TOC.LeftForearm.IsEquiped)) then
|
||||
self.character:dropHandItems();
|
||||
end
|
||||
end
|
||||
|
||||
if self.item:isRequiresEquippedBothHands() and ((modData.TOC.RightHand.IsCut and not modData.TOC.RightHand.IsEquiped) or (modData.TOC.RightForearm.IsCut and not modData.TOC.RightForearm.IsEquiped) or (modData.TOC.LeftHand.IsCut and not modData.TOC.LeftHand.IsEquiped) or (modData.TOC.LeftForearm.IsCut and not modData.TOC.LeftForearm.IsEquiped)) 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
|
||||
96
media/lua/client/TimedActions/NewOnCut.lua
Normal file
96
media/lua/client/TimedActions/NewOnCut.lua
Normal file
@@ -0,0 +1,96 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
IsCutArm = ISBaseTimedAction:derive("IsCutArm");
|
||||
|
||||
function IsCutArm:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
|
||||
end
|
||||
|
||||
function IsCutArm:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function IsCutArm:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
end
|
||||
|
||||
function IsCutArm:start()
|
||||
if self.patient == self.surgeon then
|
||||
self:setActionAnim("WearClothing");
|
||||
self:setAnimVariable("WearClothingLocation", "Jacket")
|
||||
else
|
||||
self:setActionAnim("Loot")
|
||||
self.patient:SetVariable("LootPosition", "Mid")
|
||||
end
|
||||
end
|
||||
|
||||
function IsCutArm:findArgs()
|
||||
local useBandage, bandageAlcool, usePainkiller, painkillerCount
|
||||
local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 15 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 9 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 4 end
|
||||
|
||||
local bandage = self.surgeon:getInventory():FindAndReturn('Bandage');
|
||||
local albandage = self.surgeon:getInventory():FindAndReturn('AlcoholBandage');
|
||||
if albandage then
|
||||
useBandage = true;
|
||||
bandageAlcool = true;
|
||||
self.patient:getInventory():Remove(albandage);
|
||||
surgeonFact = surgeonFact + 4
|
||||
elseif bandage then
|
||||
useBandage = true;
|
||||
self.patient:getInventory():Remove(bandage);
|
||||
surgeonFact = surgeonFact + 2
|
||||
end
|
||||
|
||||
local painkiller = self.surgeon:getInventory():FindAndReturn('Pills');
|
||||
if painkiller then
|
||||
usePainkiller = true;
|
||||
painkillerCount = painkiller:getRemainingUses();
|
||||
end
|
||||
|
||||
return surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount;
|
||||
end
|
||||
|
||||
function IsCutArm:perform()
|
||||
local surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount = self:findArgs();
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
SendCutArm(self.patient, self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
|
||||
else
|
||||
CutArm(self.partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount);
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400);
|
||||
|
||||
ISBaseTimedAction.perform(self);
|
||||
end
|
||||
|
||||
function IsCutArm:new(patient, surgeon, partName)
|
||||
local o = {}
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
o.partName = partName;
|
||||
o.bodyPart = TOC_getBodyPart(partName);
|
||||
o.character = surgeon; -- For anim
|
||||
|
||||
o.surgeon = surgeon; -- Surgeon or player that make the operation
|
||||
o.patient = patient; -- Player to cut
|
||||
|
||||
o.patientX = patient:getX();
|
||||
o.patientY = patient:getY();
|
||||
|
||||
o.maxTime = 1000 - (surgeon:getPerkLevel(Perks.Doctor) * 50);
|
||||
o.stopOnWalk = true;
|
||||
o.stopOnRun = true;
|
||||
o.ignoreHandsWounds = false;
|
||||
o.fromHotbar = true;
|
||||
if o.patient:isTimedActionInstant() then o.maxTime = 1; end
|
||||
return o;
|
||||
end
|
||||
89
media/lua/client/TimedActions/NewOnOperate.lua
Normal file
89
media/lua/client/TimedActions/NewOnOperate.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
ISOperateArm = ISBaseTimedAction:derive("ISOperateArm");
|
||||
|
||||
function ISOperateArm:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
|
||||
end
|
||||
|
||||
function ISOperateArm:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function ISOperateArm:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
end
|
||||
|
||||
function ISOperateArm:start()
|
||||
self:setActionAnim("MedicalCheck");
|
||||
if self.UseOven then
|
||||
self.sound = self.patient:getEmitter():playSound("Burn_sound")
|
||||
self:forceComplete();
|
||||
end
|
||||
end
|
||||
|
||||
function ISOperateArm:findArgs()
|
||||
local surgeonFact = self.surgeon:getPerkLevel(Perks.Doctor);
|
||||
|
||||
if self.UseOven then
|
||||
surgeonFact = surgeonFact + 100;
|
||||
else
|
||||
if self.kit then
|
||||
local weight = math.floor(self.kit:getWeight() * 10 + 0.5)
|
||||
if weight == 1 then
|
||||
surgeonFact = surgeonFact + 2;
|
||||
elseif weight == surgeonFact2 then
|
||||
surgeonFact = surgeonFact + 4;
|
||||
elseif weight == 3 then
|
||||
surgeonFact = surgeonFact + 6;
|
||||
end
|
||||
end
|
||||
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeonFact = surgeonFact + 10 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeonFact = surgeonFact + 5 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeonFact = surgeonFact + 2 end
|
||||
end
|
||||
|
||||
return surgeonFact, self.useOven;
|
||||
end
|
||||
|
||||
function ISOperateArm:perform()
|
||||
local surgeonFact, useOven = self:findArgs();
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
SendOperateArm(self.patient, self.partName, surgeonFact, useOven);
|
||||
else
|
||||
OperateArm(self.partName, surgeonFact, useOven);
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400);
|
||||
if self.kit then
|
||||
self.surgeon:getInventory():Remove(self.kit);
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self);
|
||||
end
|
||||
|
||||
function ISOperateArm:new(patient, surgeon, kit, partName, UseOven)
|
||||
local o = ISBaseTimedAction.new(self, patient);
|
||||
o.partName = partName;
|
||||
o.patient = patient;
|
||||
o.character = surgeon; -- For anim
|
||||
o.patientX = patient:getX();
|
||||
o.patientY = patient:getY();
|
||||
o.surgeon = surgeon;
|
||||
o.kit = kit;
|
||||
o.UseOven = UseOven;
|
||||
if UseOven then o.maxTime = 30 else o.maxTime = 200 - (surgeon:getPerkLevel(Perks.Doctor) * 10) end
|
||||
o.stopOnWalk = true;
|
||||
o.stopOnRun = true;
|
||||
o.ignoreHandsWounds = false;
|
||||
o.fromHotbar = true;
|
||||
if o.patient:isTimedActionInstant() then o.maxTime = 1; end
|
||||
return o;
|
||||
end
|
||||
133
media/lua/client/TimedActions/OnInstallProthesis.lua
Normal file
133
media/lua/client/TimedActions/OnInstallProthesis.lua
Normal file
@@ -0,0 +1,133 @@
|
||||
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
|
||||
92
media/lua/client/TimedActions/OnUninstallProthesis.lua
Normal file
92
media/lua/client/TimedActions/OnUninstallProthesis.lua
Normal file
@@ -0,0 +1,92 @@
|
||||
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
|
||||
Reference in New Issue
Block a user