Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # vim: set expandtab tabstop=4 shiftwidth=4:
  3.  
  4. import bl2sdk
  5.  
  6. class TooMuchConsole(bl2sdk.BL2MOD):
  7.  
  8. Name = "Too Much Console!"
  9. Description = "Triggers a crash after a certain number of getall statements"
  10. Author = 'apocalyptech'
  11.  
  12. tick_func_name = 'WillowGame.WillowGameViewportClient.Tick'
  13. tick_hook_name = 'TickHook'
  14.  
  15. command_list = []
  16. waiting_for_command = False
  17. elapsed_time = 0
  18. iteration_count = 0
  19.  
  20. class_blacklist = set([
  21. 'Field',
  22. 'Object',
  23. ])
  24.  
  25. def Enable(self):
  26.  
  27. # We need to have a non-class function to call
  28. def staticDoApocTick(caller: bl2sdk.UObject, function: bl2sdk.UFunction, params: bl2sdk.FStruct) -> bool:
  29. """
  30. Processes a UE tick
  31. """
  32. if self.waiting_for_command:
  33. self.elapsed_time += params.DeltaTime
  34. if self.elapsed_time >= self.waiting_for_command:
  35. self.waiting_for_command = False
  36. self.elapsed_time = 0
  37. self.doGetall()
  38. return True
  39.  
  40. # Generate a list of 500 getall statements to run
  41. for obj in bl2sdk.UObject.FindAll('Class'):
  42. if obj.Name not in self.class_blacklist:
  43. self.command_list.append('getall {} name'.format(obj.Name))
  44. self.command_list.sort()
  45. del self.command_list[500:]
  46.  
  47. # Set up hooks
  48. bl2sdk.RegisterHook(self.tick_func_name, self.tick_hook_name, staticDoApocTick)
  49.  
  50. # report to the user
  51. pc = bl2sdk.GetEngine().GamePlayers[0].Actor
  52. pc.ConsoleCommand('say Will start doing periodic dumps in 9 seconds...')
  53.  
  54. # Dive! Dive!
  55. self.elapsed_time = 0
  56. self.waiting_for_command = 9
  57.  
  58. def Disable(self):
  59.  
  60. # Get rid of hooks
  61. bl2sdk.RemoveHook(self.tick_func_name, self.tick_hook_name)
  62.  
  63. def doGetall(self):
  64. """
  65. Runs a bunch of getall statements
  66. """
  67. pc = bl2sdk.GetEngine().GamePlayers[0].Actor
  68. self.iteration_count += 1
  69. pc.ConsoleCommand('say Running Iteration {}...'.format(self.iteration_count))
  70. for command in self.command_list:
  71. pc.ConsoleCommand(command)
  72.  
  73. # Queue up our next run
  74. self.elapsed_time = 0
  75. self.waiting_for_command = 9
  76.  
  77. bl2sdk.Mods.append(TooMuchConsole())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement