Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # vim: set expandtab tabstop=4 shiftwidth=4:
- import bl2sdk
- class TooMuchConsole(bl2sdk.BL2MOD):
- Name = "Too Much Console!"
- Description = "Triggers a crash after a certain number of getall statements"
- Author = 'apocalyptech'
- tick_func_name = 'WillowGame.WillowGameViewportClient.Tick'
- tick_hook_name = 'TickHook'
- command_list = []
- waiting_for_command = False
- elapsed_time = 0
- iteration_count = 0
- class_blacklist = set([
- 'Field',
- 'Object',
- ])
- def Enable(self):
- # We need to have a non-class function to call
- def staticDoApocTick(caller: bl2sdk.UObject, function: bl2sdk.UFunction, params: bl2sdk.FStruct) -> bool:
- """
- Processes a UE tick
- """
- if self.waiting_for_command:
- self.elapsed_time += params.DeltaTime
- if self.elapsed_time >= self.waiting_for_command:
- self.waiting_for_command = False
- self.elapsed_time = 0
- self.doGetall()
- return True
- # Generate a list of 500 getall statements to run
- for obj in bl2sdk.UObject.FindAll('Class'):
- if obj.Name not in self.class_blacklist:
- self.command_list.append('getall {} name'.format(obj.Name))
- self.command_list.sort()
- del self.command_list[500:]
- # Set up hooks
- bl2sdk.RegisterHook(self.tick_func_name, self.tick_hook_name, staticDoApocTick)
- # report to the user
- pc = bl2sdk.GetEngine().GamePlayers[0].Actor
- pc.ConsoleCommand('say Will start doing periodic dumps in 9 seconds...')
- # Dive! Dive!
- self.elapsed_time = 0
- self.waiting_for_command = 9
- def Disable(self):
- # Get rid of hooks
- bl2sdk.RemoveHook(self.tick_func_name, self.tick_hook_name)
- def doGetall(self):
- """
- Runs a bunch of getall statements
- """
- pc = bl2sdk.GetEngine().GamePlayers[0].Actor
- self.iteration_count += 1
- pc.ConsoleCommand('say Running Iteration {}...'.format(self.iteration_count))
- for command in self.command_list:
- pc.ConsoleCommand(command)
- # Queue up our next run
- self.elapsed_time = 0
- self.waiting_for_command = 9
- bl2sdk.Mods.append(TooMuchConsole())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement