From 48d88e1afe9367f4feceaeaa7d293a86de4e6a4c Mon Sep 17 00:00:00 2001 From: Samuel T Date: Wed, 8 Nov 2023 18:54:04 +0000 Subject: [PATCH] spellbook: ToggleSleep magic word --- etc/toon.dc | 1 + otp/avatar/LocalAvatar.py | 3 +++ toontown/spellbook/MagicWordIndex.py | 9 +++++++++ toontown/toon/DistributedToon.py | 6 ++++++ toontown/toon/DistributedToonAI.py | 3 +++ 5 files changed, 22 insertions(+) diff --git a/etc/toon.dc b/etc/toon.dc index 9e0fef8..5c4ed03 100755 --- a/etc/toon.dc +++ b/etc/toon.dc @@ -618,6 +618,7 @@ dclass DistributedToon : DistributedPlayer { setNeverStartedPartyRefunded(uint64, int8, uint16) ownrecv; setDISLname(string) ram; setDISLid(uint32) ram db airecv; + toggleSleep() ownrecv; }; dclass DistributedCCharBase : DistributedObject { diff --git a/otp/avatar/LocalAvatar.py b/otp/avatar/LocalAvatar.py index 2b689cc..b8e04ec 100644 --- a/otp/avatar/LocalAvatar.py +++ b/otp/avatar/LocalAvatar.py @@ -61,6 +61,7 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis self.soundRun = None self.soundWalk = None self.sleepFlag = 0 + self.noSleep = 0 self.isDisguised = 0 self.movingFlag = 0 self.swimmingFlag = 0 @@ -984,6 +985,8 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis return def gotoSleep(self): + if self.noSleep: + return if not self.sleepFlag: self.b_setAnimState('Sleep', self.animMultiplier) self.sleepFlag = 1 diff --git a/toontown/spellbook/MagicWordIndex.py b/toontown/spellbook/MagicWordIndex.py index 3f5b62d..1e22159 100644 --- a/toontown/spellbook/MagicWordIndex.py +++ b/toontown/spellbook/MagicWordIndex.py @@ -705,6 +705,15 @@ class Teleport(MagicWord): return f"Successfully teleporting {toon.getName()} to zone {zone}." +class ToggleSleep(MagicWord): + aliases = ["sleep", "nosleep", "neversleep", "togglesleeping", "insomnia"] + desc = "Toggles sleeping for the target." + execLocation = MagicWordConfig.EXEC_LOC_SERVER + + def handleWord(self, invoker, avId, toon, *args): + toon.d_toggleSleep() + return f"Toggled sleeping for {toon.getName()}." + class Fireworks(MagicWord): aliases = ["firework"] desc = "Starts a firework show." diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index 0602211..35f1b60 100644 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -2589,3 +2589,9 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute def getTransitioning(self): return self.transitioning + + def toggleSleep(self): + if base.localAvatar.noSleep: + base.localAvatar.noSleep = 0 + else: + base.localAvatar.noSleep = 1 \ No newline at end of file diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index cf78958..79b9990 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -4129,6 +4129,9 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo zoneId]) self.air.send(dg) + def d_toggleSleep(self): + self.sendUpdate('toggleSleep', []) + @staticmethod def staticGetLogicalZoneChangeAllEvent(): return 'DOLogicalChangeZone-all'