fuck
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -16,6 +16,7 @@
|
||||
"instanceof",
|
||||
"getPlayerInventory",
|
||||
"sendServerCommand",
|
||||
"TraitFactory"
|
||||
"TraitFactory",
|
||||
"ISWorldObjectContextMenu"
|
||||
]
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
--- A rly big thx to Fenris_Wolf and Chuck to help me with that. Love you guy
|
||||
local Commands = {}
|
||||
|
||||
-- Surgeon (send)
|
||||
function SendCutArm(player, partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount)
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["To"] = player:getOnlineID();
|
||||
arg["command"] = "CutArm";
|
||||
arg["toSend"] = {partName, surgeonFact, useBandage, bandageAlcool, usePainkiller, painkillerCount};
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
|
||||
function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
local arg = {}
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["To"] = player:getOnlineID()
|
||||
arg["command"] = "CutLimb"
|
||||
arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table}
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function SendOperateArm(player, partName, surgeonFact, useOven)
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["To"] = player:getOnlineID();
|
||||
arg["command"] = "OperateArm";
|
||||
arg["toSend"] = {partName, surgeonFact, useOven};
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
function AskCanCutArm(player, partName)
|
||||
GetConfirmUIMP().responseReceive = false;
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["To"] = player:getOnlineID();
|
||||
arg["command"] = "CanCutArm";
|
||||
arg["toSend"] = partName;
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
function AskCanOperateArm(player, partName)
|
||||
GetConfirmUIMP().responseReceive = false;
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["To"] = player:getOnlineID();
|
||||
arg["command"] = "CanOperateArm";
|
||||
arg["toSend"] = partName;
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
Commands["responseCanArm"] = function(arg)
|
||||
local ui = GetConfirmUIMP()
|
||||
ui.responseReceive = true;
|
||||
ui.responseAction = arg["toSend"][2];
|
||||
ui.responsePartName = arg["toSend"][1];
|
||||
ui.responseCan = arg["toSend"][3];
|
||||
ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername();
|
||||
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TOC_getBodyPart(ui.responsePartName)):bitten();
|
||||
end
|
||||
|
||||
|
||||
-- Patient (receive)
|
||||
Commands["CutLimb"] = function(arg)
|
||||
local arg = arg["toSend"]
|
||||
TheOnlyCure.CutLimb(arg[1], arg[2], arg[3], arg[4])
|
||||
end
|
||||
|
||||
|
||||
Commands["CutArm"] = function(arg)
|
||||
local arg = arg["toSend"];
|
||||
CutArm(arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Commands["OperateArm"] = function(arg)
|
||||
local arg = arg["toSend"];
|
||||
OperateArm(arg[1], arg[2], arg[3]);
|
||||
end
|
||||
|
||||
Commands["CanCutArm"] = function(arg)
|
||||
local partName = arg["toSend"];
|
||||
|
||||
arg["To"] = arg["From"];
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["command"] = "responseCanArm";
|
||||
arg["toSend"] = {partName, "Cut", CanBeCut(partName)};
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
Commands["CanOperateArm"] = function(arg)
|
||||
local partName = arg["toSend"];
|
||||
|
||||
arg["To"] = arg["From"];
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["command"] = "responseCanArm";
|
||||
arg["toSend"] = {partName, "Operate", CanBeOperate(partName)};
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- todo why is this here? this doesnt make any sense
|
||||
-- Event
|
||||
local onServerCommand = function(module, command, args)
|
||||
-- TODO this doesn't belong here.
|
||||
if module == "TOC" and Commands[command] then
|
||||
args = args or {}
|
||||
Commands[command](args)
|
||||
end
|
||||
end
|
||||
|
||||
Events.OnServerCommand.Add(onServerCommand)
|
||||
@@ -1,3 +1,87 @@
|
||||
-- Synchronization and MP related stuff
|
||||
|
||||
local Commands = {}
|
||||
|
||||
function SendCutLimb(player, part_name, surgeon_factor, bandage_table, painkiller_table)
|
||||
local arg = {}
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["To"] = player:getOnlineID()
|
||||
arg["command"] = "CutLimb"
|
||||
arg["toSend"] = {part_name, surgeon_factor, bandage_table, painkiller_table}
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
function SendOperateLimb(player, part_name, surgeon_factor, use_oven)
|
||||
local arg = {}
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["To"] = player:getOnlineID()
|
||||
arg["command"] = "OperateLimb"
|
||||
arg["toSend"] = {part_name, surgeon_factor, use_oven}
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
function AskCanCutLimb(player, part_name)
|
||||
GetConfirmUIMP().responseReceive = false;
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["To"] = player:getOnlineID();
|
||||
arg["command"] = "CanCutLimb";
|
||||
arg["toSend"] = part_name;
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
function AskCanOperateLimb(player, part_name)
|
||||
GetConfirmUIMP().responseReceive = false;
|
||||
local arg = {};
|
||||
arg["From"] = getPlayer():getOnlineID();
|
||||
arg["To"] = player:getOnlineID();
|
||||
arg["command"] = "CanOperateArm";
|
||||
arg["toSend"] = part_name;
|
||||
sendClientCommand("TOC", "SendServer", arg);
|
||||
end
|
||||
|
||||
Commands["ResponseCanAct"] = function(arg)
|
||||
local ui = GetConfirmUIMP()
|
||||
ui.responseReceive = true
|
||||
ui.responseAction = arg["toSend"][2]
|
||||
ui.responsePartName = arg["toSend"][1]
|
||||
ui.responseCan = arg["toSend"][3]
|
||||
ui.responseUserName = getPlayerByOnlineID(arg["From"]):getUsername()
|
||||
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TOC_getBodyPart(ui.responsePartName)):bitten()
|
||||
end
|
||||
|
||||
-- Patient (receive)
|
||||
Commands["CutLimb"] = function(arg)
|
||||
local arg = arg["toSend"]
|
||||
TheOnlyCure.CutLimb(arg[1], arg[2], arg[3], arg[4])
|
||||
end
|
||||
|
||||
Commands["OperateLimb"] = function(arg)
|
||||
local arg = arg["toSend"]
|
||||
OperateLimb(arg[1], arg[2], arg[3])
|
||||
end
|
||||
|
||||
Commands["CanCutLimb"] = function(arg)
|
||||
local part_name = arg["toSend"]
|
||||
|
||||
arg["To"] = arg["From"]
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["command"] = "ResponseCanAct"
|
||||
arg["toSend"] = {part_name, "Cut", CanBeCut(part_name)}
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Commands["CanOperateLimb"] = function(arg)
|
||||
local part_name = arg["toSend"]
|
||||
|
||||
arg["To"] = arg["From"]
|
||||
arg["From"] = getPlayer():getOnlineID()
|
||||
arg["command"] = "ResponseCanAct"
|
||||
arg["toSend"] = {part_name, "Operate", CanBeOperate(part_name)}
|
||||
sendClientCommand("TOC", "SendServer", arg)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +116,9 @@ local function OnTocServerCommand(module, command, args)
|
||||
|
||||
-- ew a global var.... but dunno if there's a better way to do this
|
||||
MP_other_player_toc_data = args[2]
|
||||
elseif Commands[command] then
|
||||
args = args or {}
|
||||
Commands[command](args)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
require "TimedActions/ISBaseTimedAction"
|
||||
|
||||
ISOperateLimb = ISBaseTimedAction:derive("ISOperateLimb");
|
||||
|
||||
function ISOperateLimb:isValid()
|
||||
return self.patientX == self.patient:getX() and self.patientY == self.patient:getY();
|
||||
end
|
||||
|
||||
function ISOperateLimb:waitToStart()
|
||||
if self.patient == self.surgeon then
|
||||
return false
|
||||
end
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
return self.surgeon:shouldBeTurning()
|
||||
end
|
||||
|
||||
function ISOperateLimb:update()
|
||||
if self.patient ~= self.surgeon then
|
||||
self.surgeon:faceThisObject(self.patient)
|
||||
end
|
||||
end
|
||||
|
||||
function ISOperateLimb:start()
|
||||
self:setActionAnim("MedicalCheck");
|
||||
if self.use_oven then
|
||||
self.sound = self.patient:getEmitter():playSound("Burn_sound")
|
||||
self:forceComplete();
|
||||
end
|
||||
end
|
||||
|
||||
function ISOperateLimb:findArgs()
|
||||
local surgeon_factor = self.surgeon:getPerkLevel(Perks.Doctor);
|
||||
|
||||
if self.use_oven then
|
||||
surgeon_factor = surgeon_factor + 100
|
||||
else
|
||||
if self.kit then
|
||||
local weight = math.floor(self.kit:getWeight() * 10 + 0.5)
|
||||
if weight == 1 then
|
||||
surgeon_factor = surgeon_factor + 2
|
||||
elseif weight == surgeon_factor then
|
||||
surgeon_factor = surgeon_factor + 4
|
||||
elseif weight == 3 then
|
||||
surgeon_factor = surgeon_factor + 6
|
||||
end
|
||||
end
|
||||
|
||||
if self.surgeon:getDescriptor():getProfession() == "surgeon" then surgeon_factor = surgeon_factor + 10 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "doctor" then surgeon_factor = surgeon_factor + 5 end
|
||||
if self.surgeon:getDescriptor():getProfession() == "nurse" then surgeon_factor = surgeon_factor + 2 end
|
||||
end
|
||||
|
||||
return surgeon_factor, self.use_oven;
|
||||
end
|
||||
|
||||
function ISOperateLimb:perform()
|
||||
local surgeon_factor, use_oven = self:findArgs()
|
||||
|
||||
if self.patient ~= self.surgeon and isClient() then
|
||||
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)
|
||||
end
|
||||
self.surgeon:getXp():AddXP(Perks.Doctor, 400)
|
||||
|
||||
-- FIXME Add a check for kit to prevent errors
|
||||
if self.kit then
|
||||
self.surgeon:getInventory():Remove(self.kit)
|
||||
end
|
||||
|
||||
ISBaseTimedAction.perform(self)
|
||||
end
|
||||
|
||||
function ISOperateLimb:new(patient, surgeon, kit, part_name, use_oven)
|
||||
local o = ISBaseTimedAction.new(self, patient)
|
||||
o.part_name = part_name
|
||||
o.patient = patient
|
||||
o.character = surgeon -- For anim
|
||||
o.patientX = patient:getX()
|
||||
o.patientY = patient:getY()
|
||||
o.surgeon = surgeon
|
||||
o.kit = kit
|
||||
|
||||
o.use_oven = use_oven
|
||||
|
||||
|
||||
--o.use_oven = use_oven;
|
||||
if use_oven 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
|
||||
|
||||
Reference in New Issue
Block a user