Added modchecker and modified how sound is handled

This commit is contained in:
Pao
2023-03-01 15:24:03 +01:00
parent 515788dc24
commit d2f5c05d10
7 changed files with 56 additions and 16 deletions

View File

@@ -56,6 +56,7 @@
"getClassField", "getClassField",
"ISWearClothing", "ISWearClothing",
"SyncXp", "SyncXp",
"ISClothingExtraAction" "ISClothingExtraAction",
"SwapItConfig"
] ]
} }

View File

@@ -239,5 +239,11 @@ local function InitializeJustCutItOff()
Events.EveryOneMinute.Add(JCIO.UpdateEveryOneMinute) Events.EveryOneMinute.Add(JCIO.UpdateEveryOneMinute)
-- Mod Checker
CheckMyModTable = CheckMyModTable or {}
CheckMyModTable["JCIO"] = 2915572347
end end
Events.OnGameBoot.Add(InitializeJustCutItOff) Events.OnGameBoot.Add(InitializeJustCutItOff)

View File

@@ -211,8 +211,8 @@ function ISWearClothing:isValid()
end end
-- This is to manage the watches, we don't want them equipped over an amputated limb of course
local og_ISWearClothingExtraAction = ISClothingExtraAction.isValid local og_ISWearClothingExtraAction = ISClothingExtraAction.isValid
function ISClothingExtraAction:isValid() function ISClothingExtraAction:isValid()
local baseCheck = og_ISWearClothingExtraAction(self) local baseCheck = og_ISWearClothingExtraAction(self)

View File

@@ -23,13 +23,43 @@ function JCIO_CutLimbAction:update()
if self.patient ~= self.surgeon then if self.patient ~= self.surgeon then
self.surgeon:faceThisObject(self.patient) self.surgeon:faceThisObject(self.patient)
end end
local worldSoundRadius = 3
local soundDelay = 6
-- Sound handling
if self.soundTime + soundDelay < getTimestamp() then
self.soundTime = getTimestamp()
if not self.chatacter:getEmitter():isPlaying(self.sawSound) then
self.sawSound = self.character:getEmitter():playSound("Amputation_Sound")
end
end
-- TODO This is to handle MP I guess?
if worldSoundRadius > 0 then
self.worldSoundTime = getTimestamp()
addSound(self.surgeon, self.surgeon:getX(), self.surgeon:getY(), self.surgeon:getZ(), worldSoundRadius, worldSoundRadius)
end
end end
function JCIO_CutLimbAction:stop() function JCIO_CutLimbAction:stop()
print("Stopping ISCutLimb") print("Stopping ISCutLimb")
self.surgeon:getEmitter():stopSoundByName("Amputation_Sound")
sendClientCommand(self.surgeon, "JCIO", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()}) -- Handles sound
if self.sawSound and self.sawSound ~= 0 and self.surgeon:getEmitter():isPlaying(self.sawSound) then
self.surgeon:getEmitter():stopSound(self.sawSound)
end
-- TODO test this with more than 2 players -- TODO test this with more than 2 players
-- TODO this gets bugged when player dies while amputating -- TODO this gets bugged when player dies while amputating
@@ -44,8 +74,11 @@ function JCIO_CutLimbAction:start()
-- TODO Add a check so you can't cut your arm if you don't have hands or if you only have one arm and want to cut that same arm. -- TODO Add a check so you can't cut your arm if you don't have hands or if you only have one arm and want to cut that same arm.
self:setActionAnim("SawLog") self:setActionAnim("SawLog")
local saw_item = JCIO_Common.GetSawInInventory(self.surgeon) local sawItem = JCIO_Common.GetSawInInventory(self.surgeon)
self.surgeon:getEmitter():playSound("Amputation_Sound")
self.soundTime = 0
self.worldSoundTime = 0
self.sawSound = self.surgeon:getEmitter():playSound("Amputation_Sound")
-- Return whatever object we've got in the inventory -- Return whatever object we've got in the inventory
if self.surgeon:getPrimaryHandItem() then if self.surgeon:getPrimaryHandItem() then
@@ -55,8 +88,8 @@ function JCIO_CutLimbAction:start()
ISTimedActionQueue.add(ISUnequipAction:new(self.surgeon, self.surgeon:getSecondaryHandItem(), 2)); ISTimedActionQueue.add(ISUnequipAction:new(self.surgeon, self.surgeon:getSecondaryHandItem(), 2));
end end
if saw_item then if sawItem then
self:setOverrideHandModels(saw_item:getStaticModel(), nil) self:setOverrideHandModels(sawItem:getStaticModel(), nil)
end end
@@ -124,7 +157,7 @@ function JCIO_CutLimbAction:perform()
if self.patient ~= self.surgeon and isClient() then if self.patient ~= self.surgeon and isClient() then
SendCutLimb(self.patient, self.partName, surgeon_factor, bandage_table, painkiller_table) SendCutLimb(self.patient, self.partName, surgeon_factor, bandage_table, painkiller_table)
sendClientCommand(self.surgeon, "JCIO", "AskStopAmputationSound", {surgeon_id = self.surgeon:getOnlineID()}) sendClientCommand(self.surgeon, "JCIO", "AskStopAmputationSound", {surgeonID = self.surgeon:getOnlineID()})
else else
JCIO.CutLimb(self.partName, surgeon_factor, bandage_table, painkiller_table) JCIO.CutLimb(self.partName, surgeon_factor, bandage_table, painkiller_table)
end end

View File

@@ -28,7 +28,7 @@ end
ClientCommands.AskStopAmputationSound = function(_, args) ClientCommands.AskStopAmputationSound = function(_, args)
print("JCIO: We're in AskStopAmputationSound") print("JCIO: We're in AskStopAmputationSound")
sendServerCommand("JCIO", "StopAmputationSound", {surgeon_id = args.surgeon_id}) sendServerCommand("JCIO", "StopAmputationSound", {surgeon_id = args.surgeonID})
end end

View File

@@ -2,8 +2,8 @@ module base {
sound Amputation_Sound { sound Amputation_Sound {
category = Player, category = Player,
loop = true, loop = false,
is3D = true, is3D = true,
clip { clip {
file = media/sound/Cut_sound.ogg, file = media/sound/Cut_sound.ogg,
distanceMax = 3, distanceMax = 3,

View File

@@ -1,6 +1,6 @@
version=1 version=1
id=2916771109 id=2915572347
title=JUST CUT IT OFF DEV title=Just Cut It Off
description=Just for testing and shit description=TODO
tags= tags=
visibility=public visibility=public