def OnRun(self, msg: JSON) -> None: time: float = 0 for i in range(4): time += max(0, random.uniform( self.DROP_DELAY - self.DROP_VARIATION, self.DROP_DELAY - self.DROP_VARIATION )) AsyncUtil.RunIn( time, unrealsdk.GetEngine().GamePlayers[0].Actor.ServerThrowPawnActiveWeapon ) if i == 1: AsyncUtil.RunIn(time + self.DISPLAY_DELAY, lambda: self.ShowRedemption(msg))
def OnEnd(self) -> None: ShowChatMessage("Crowd Control:", f"{self.Name} wore off.", ShowTimestamp=False) unrealsdk.RemoveHook("WillowGame.WillowHUDGFxMovie.Start", "CCHideHUD") # Seems the hook sticks around a tick or something, this doesn't work unless I delay it AsyncUtil.RunIn(0.05, unrealsdk.GetEngine().GamePlayers[0].Actor.DisplayHUD)
def OnRun(self, msg: JSON) -> None: """ Callback function for whenever a queued messages should be activated. This implementation makes sure the effect properly runs for the specified duration, so if you need to overwrite it make sure to call this function from your's. If the effect is already running then this function will restart the timer. """ AsyncUtil.CancelFutureCallbacks(f"CC-{self.Name}-Stop") self.OnStart(msg) AsyncUtil.RunIn(self._DurationOption.CurrentValue, self.OnEnd, f"CC-{self.Name}-Stop")
def OnRun(self, msg: JSON) -> None: # Replicate `self.ShowRedemption()` but using the fake name def Internal() -> None: user = "******" try: user = msg["data"]["redemption"]["user"]["login"] except KeyError: pass ShowHUDMessage("Crowd Control", f"{user} redeemed '{self.FakeName}'") AsyncUtil.RunIn(0.1, Internal)
def ShowFailedMessage(self, msg: JSON) -> None: def Internal() -> None: user = "******" try: user = msg["data"]["redemption"]["user"]["login"] except KeyError: pass ShowHUDMessage( "Crowd Control", f"{user} tried to redeem '{self.Name}', but forgot that this world doesn't have any enemies." ) # There's a small delay after closing menus before we can properly show a message AsyncUtil.RunIn(0.1, Internal)
def OnRun(self, msg: JSON) -> None: def Internal() -> None: self.ShowRedemption(msg) PC = unrealsdk.GetEngine().GamePlayers[0].Actor wanted_vel = max(self.MIN_VELOCITY, maths.sqrt(PC.Pawn.Velocity.X ** 2 + PC.Pawn.Velocity.Y ** 2)) conversion = maths.pi / 0x7fff PC.Pawn.DoJump(PC.bUpdating) PC.Pawn.Velocity = ( maths.cos(PC.Rotation.Yaw * conversion) * wanted_vel, maths.sin(PC.Rotation.Yaw * conversion) * wanted_vel, PC.Pawn.Velocity.Z # This now includes jumping velocity ) # There's a bit of a delay after unpausing before this works right AsyncUtil.RunIn(0.2, Internal)
def ShowRedemption(self, msg: JSON) -> None: """ Small helper function that displays a UserFeedback HUDMessage with info about who redeemed this effect. Args: msg: The decoded JSON channel points event message. """ def Internal() -> None: user = "******" try: user = msg["data"]["redemption"]["user"]["login"] except KeyError: pass ShowHUDMessage("Crowd Control", f"{user} redeemed '{self.Name}'") # There's a small delay after closing menus before we can properly show a message AsyncUtil.RunIn(0.1, Internal)
def _RunFront() -> None: self.OnRun(self._Queue[0]) AsyncUtil.RunIn(self._IntervalOption.CurrentValue, _Loop)
def OnRun(self, msg: JSON) -> None: unrealsdk.GetEngine().GamePlayers[0].Actor.ServerThrowPawnActiveWeapon() AsyncUtil.RunIn(self.DISPLAY_DELAY, lambda: self.ShowRedemption(msg))
def OnRun(self, msg: JSON) -> None: self.ShowRedemption(msg) AsyncUtil.RunIn(self.TIME_BEFORE_ACTIVATE, lambda: AsyncUtil.RunWhen(IsInGame, self.Activate))
def Execute(self) -> None: AsyncUtil.RunIn(self.Delay, self.OnFinishExecution)