Restored OnTocClientCommands
This commit is contained in:
@@ -12,6 +12,56 @@ Commands["ResponseCanAct"] = function(arg)
|
|||||||
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TOC_getBodyPart(ui.responsePartName)):bitten()
|
ui.responseActionIsBitten = getPlayerByOnlineID(arg["From"]):getBodyDamage():getBodyPart(TOC_getBodyPart(ui.responsePartName)):bitten()
|
||||||
end
|
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 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"] = "CanOperateLimb";
|
||||||
|
arg["toSend"] = part_name;
|
||||||
|
sendClientCommand("TOC", "SendServer", arg);
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function AskCanResetEverything(_, other_player)
|
||||||
|
GetConfirmUIMP().responseReceive = false;
|
||||||
|
local arg = {}
|
||||||
|
arg["From"] = getPlayer():getOnlineID()
|
||||||
|
arg["To"] = other_player:getOnlineID()
|
||||||
|
arg["command"] = "CanResetEverything"
|
||||||
|
arg["toSend"] = {}
|
||||||
|
sendClientCommand("TOC", "SendServer", arg)
|
||||||
|
end
|
||||||
|
|
||||||
-- Patient (receive)
|
-- Patient (receive)
|
||||||
Commands["CutLimb"] = function(arg)
|
Commands["CutLimb"] = function(arg)
|
||||||
local arg = arg["toSend"]
|
local arg = arg["toSend"]
|
||||||
@@ -20,7 +70,7 @@ end
|
|||||||
|
|
||||||
Commands["OperateLimb"] = function(arg)
|
Commands["OperateLimb"] = function(arg)
|
||||||
local arg = arg["toSend"]
|
local arg = arg["toSend"]
|
||||||
OperateLimb(arg[1], arg[2], arg[3])
|
TheOnlyCure.OperateLimb(arg[1], arg[2], arg[3])
|
||||||
end
|
end
|
||||||
|
|
||||||
Commands["CanCutLimb"] = function(arg)
|
Commands["CanCutLimb"] = function(arg)
|
||||||
@@ -43,6 +93,21 @@ Commands["CanOperateLimb"] = function(arg)
|
|||||||
sendClientCommand("TOC", "SendServer", arg)
|
sendClientCommand("TOC", "SendServer", arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Commands["CanResetEverything"] = function(arg)
|
||||||
|
local arg = arg["toSend"] --useless
|
||||||
|
|
||||||
|
arg["To"] = arg["From"]
|
||||||
|
arg["From"] = getPlayer():getOnlineID()
|
||||||
|
arg["command"] = "ResponseCanAct"
|
||||||
|
arg["toSend"] = {}
|
||||||
|
sendClientCommand("TOC", "SendServer", arg)
|
||||||
|
--ResetEverything()
|
||||||
|
end
|
||||||
|
|
||||||
|
Commands["ResetEverything"] = function(arg)
|
||||||
|
local arg = arg["toSend"]
|
||||||
|
ResetEverything()
|
||||||
|
end
|
||||||
|
|
||||||
local function OnTocServerCommand(module, command, args)
|
local function OnTocServerCommand(module, command, args)
|
||||||
if module == 'TOC' then
|
if module == 'TOC' then
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ local function OperateLocal(_, patient, surgeon, part_name, use_oven)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--TODO Make the name more unique
|
||||||
function TheOnlyCure.TryActionOnOtherPlayerLocal(_, part_name, action, surgeon, patient)
|
function TryActionOnOtherPlayerLocal(_, part_name, action, surgeon, patient)
|
||||||
|
|
||||||
local ui = GetConfirmUIMP()
|
local ui = GetConfirmUIMP()
|
||||||
if not ui then
|
if not ui then
|
||||||
@@ -32,14 +32,12 @@ function TheOnlyCure.TryActionOnOtherPlayerLocal(_, part_name, action, surgeon,
|
|||||||
|
|
||||||
if action == "Cut" then
|
if action == "Cut" then
|
||||||
AskCanCutLimb(patient, part_name)
|
AskCanCutLimb(patient, part_name)
|
||||||
--AskCanCutArm(patient, part_name);
|
|
||||||
elseif action == "Operate" then
|
elseif action == "Operate" then
|
||||||
AskCanOperateLimb(patient, part_name)
|
AskCanOperateLimb(patient, part_name)
|
||||||
--AskCanOperateArm(patient, part_name);
|
|
||||||
end
|
end
|
||||||
ui.actionAct = action;
|
ui.actionAct = action
|
||||||
ui.partNameAct = part_name;
|
ui.partNameAct = part_name
|
||||||
ui.patient = patient;
|
ui.patient = patient
|
||||||
SetConfirmUIMP("Wait server")
|
SetConfirmUIMP("Wait server")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -90,6 +88,23 @@ function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, t
|
|||||||
local cutMenu = context:getNew(context);
|
local cutMenu = context:getNew(context);
|
||||||
local operateMenu = context:getNew(context);
|
local operateMenu = context:getNew(context);
|
||||||
|
|
||||||
|
|
||||||
|
-- admin stuff
|
||||||
|
if clickedPlayer:getAccessLevel() == "Admin" then
|
||||||
|
local cheat_option = rootMenu:addOption("Cheat")
|
||||||
|
local cheat_menu = context:getNew(context)
|
||||||
|
context:addSubMenu(cheat_option, cheat_menu)
|
||||||
|
|
||||||
|
|
||||||
|
if clickedPlayer == player_obj then
|
||||||
|
cheat_menu:addOption("Reset TOC for me", worldObjects, ResetEverything, clickedPlayer)
|
||||||
|
|
||||||
|
else
|
||||||
|
cheat_menu:addOption("Reset TOC for " .. clickedPlayer:getUsername(), worldObjects, AskCanResetEverything, clickedPlayer)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context:addSubMenu(rootOption, rootMenu);
|
context:addSubMenu(rootOption, rootMenu);
|
||||||
context:addSubMenu(cutOption, cutMenu);
|
context:addSubMenu(cutOption, cutMenu);
|
||||||
context:addSubMenu(operateOption, operateMenu);
|
context:addSubMenu(operateOption, operateMenu);
|
||||||
@@ -105,8 +120,8 @@ function ISWorldObjectContextMenu.OnFillTOCMenu(player, context, worldObjects, t
|
|||||||
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)
|
||||||
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)
|
||||||
else
|
else
|
||||||
cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TheOnlyCure.TryActionOnOtherPlayerLocal, v_part, "Cut", player_obj, clickedPlayer)
|
cutMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TryActionOnOtherPlayerLocal, v_part, "Cut", player_obj, clickedPlayer)
|
||||||
operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TheOnlyCure.TryActionOnOtherPlayerLocal, v_part, "Operate", player_obj, clickedPlayer);
|
operateMenu:addOption(getText('UI_ContextMenu_' .. v_part), worldObjects, TryActionOnOtherPlayerLocal, v_part, "Operate", player_obj, clickedPlayer);
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
22
media/lua/client/TOC_Debug.lua
Normal file
22
media/lua/client/TOC_Debug.lua
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
function ResetEverything()
|
||||||
|
|
||||||
|
local player = getPlayer()
|
||||||
|
local mod_data = player:getModData() -- TODO we need to send data...
|
||||||
|
mod_data.TOC = nil
|
||||||
|
TheOnlyCure.InitTheOnlyCure(_, player)
|
||||||
|
|
||||||
|
-- Destroy the amputation model
|
||||||
|
|
||||||
|
for _,v in ipairs(GetBodyParts()) do
|
||||||
|
local cloth = player:getInventory():FindAndReturn(find_clothName2_TOC(v))
|
||||||
|
|
||||||
|
if cloth ~= nil then
|
||||||
|
player:removeWornItem(cloth)
|
||||||
|
player:getInventory():Remove(cloth:getName())
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
player:transmitModData()
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
-- CutLimb
|
-- CutLimb
|
||||||
function TheOnlyCure.CheckIfStillInfected(toc_data)
|
-- TODO if TheONlyCure. triggers an errors
|
||||||
|
function CheckIfStillInfected(toc_data)
|
||||||
if toc_data == nil then
|
if toc_data == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -21,7 +22,8 @@ function TheOnlyCure.CheckIfStillInfected(toc_data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function TheOnlyCure.CureInfection(body_damage)
|
-- TODO this triggers an error
|
||||||
|
function CureInfection(body_damage)
|
||||||
body_damage:setInfected(false)
|
body_damage:setInfected(false)
|
||||||
body_damage:setInfectionMortalityDuration(-1)
|
body_damage:setInfectionMortalityDuration(-1)
|
||||||
body_damage:setInfectionTime(-1)
|
body_damage:setInfectionTime(-1)
|
||||||
@@ -38,7 +40,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- OperateLimb
|
-- OperateLimb
|
||||||
function TheOnlyCure.SetBodyPartsStatusAfterOperation(player, toc_data, part_name, use_oven)
|
function SetBodyPartsStatusAfterOperation(player, toc_data, part_name, use_oven)
|
||||||
--for _, v in ipairs(GetBodyParts()) do
|
--for _, v in ipairs(GetBodyParts()) do
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -160,8 +160,8 @@ function TheOnlyCure.CutLimb(part_name, surgeon_factor, bandage_table, painkille
|
|||||||
body_part_type:SetBitten(false)
|
body_part_type:SetBitten(false)
|
||||||
|
|
||||||
-- Second check, let's see if there is any other infected limb.
|
-- Second check, let's see if there is any other infected limb.
|
||||||
if TheOnlyCure.CheckIfStillInfected(toc_data) == false then
|
if CheckIfStillInfected(toc_data) == false then
|
||||||
TheOnlyCure.CureInfection(body_damage)
|
CureInfection(body_damage)
|
||||||
getPlayer():Say("I'm gonna be fine")
|
getPlayer():Say("I'm gonna be fine")
|
||||||
else
|
else
|
||||||
getPlayer():Say("I'm still gonna die...")
|
getPlayer():Say("I'm still gonna die...")
|
||||||
@@ -211,7 +211,7 @@ function TheOnlyCure.OperateLimb(part_name, surgeon_factor, use_oven)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
TheOnlyCure.SetBodyPartsStatusAfterOperation(player, toc_data, part_name, use_oven)
|
SetBodyPartsStatusAfterOperation(player, toc_data, part_name, use_oven)
|
||||||
player:transmitModData()
|
player:transmitModData()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
-- 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
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- A rly big thx to Fenris_Wolf and Chuck to help me with that. Love you guy
|
--- A rly big thx to Fenris_Wolf and Chuck to help me with that. Love you guy
|
||||||
if isClient() then return end
|
--if isClient() then return end
|
||||||
|
|
||||||
---Server side
|
---Server side
|
||||||
local Commands = {}
|
local Commands = {}
|
||||||
@@ -9,44 +9,6 @@ Commands["SendServer"] = function(player, arg)
|
|||||||
sendServerCommand(otherPlayer, "TOC", arg["command"], arg)
|
sendServerCommand(otherPlayer, "TOC", arg["command"], arg)
|
||||||
end
|
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 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
|
|
||||||
|
|
||||||
local function OnTocClientCommand(module, command, player, args)
|
local function OnTocClientCommand(module, command, player, args)
|
||||||
if module == 'TOC' then
|
if module == 'TOC' then
|
||||||
print(command)
|
print(command)
|
||||||
@@ -62,7 +24,7 @@ local function OnTocClientCommand(module, command, player, args)
|
|||||||
local surgeon_id = args[1]
|
local surgeon_id = args[1]
|
||||||
local toc_data = args[2]
|
local toc_data = args[2]
|
||||||
sendServerCommand(surgeon, "TOC", "SendTocData", {surgeon_id, toc_data})
|
sendServerCommand(surgeon, "TOC", "SendTocData", {surgeon_id, toc_data})
|
||||||
elseif command == Commands[command] then
|
elseif Commands[command] then
|
||||||
args = args or {}
|
args = args or {}
|
||||||
Commands[command](_, args)
|
Commands[command](_, args)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user