Advertisement
Ayuto

Control bots

Mar 20th, 2015
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.50 KB | None | 0 0
  1. # =============================================================================
  2. # >> IMPORTS
  3. # =============================================================================
  4. from enum import IntEnum
  5.  
  6. import memory
  7.  
  8. from memory import Convention
  9. from memory import DataType
  10.  
  11. from players.entity import Player
  12. from filters.players import PlayerIter
  13.  
  14. from events import Event
  15.  
  16. from menus import SimpleMenu
  17. from menus import SimpleOption
  18.  
  19. from core import PLATFORM
  20. from core import SOURCE_ENGINE_BRANCH
  21.  
  22.  
  23. # =============================================================================
  24. # >> GLOBAL VARIABLES
  25. # =============================================================================
  26. # CCSBot::MoveTo(Vector  const&, RouteType)
  27. # _ZN6CCSBot6MoveToERK6Vector9RouteType
  28. if SOURCE_ENGINE_BRANCH == 'css':
  29.     if PLATFORM == 'windows':
  30.         identifier = b'\x55\x8B\xEC\x8B\x45\x08\xD9\x00\xD9\x99\xF8\x1A\x00\x00'
  31.     else:
  32.         identifier = '_ZN6CCSBot6MoveToERK6Vector9RouteType'
  33. elif SOURCE_ENGINE_BRANCH == 'csgo':
  34.     if PLATFORM == 'windows':
  35.         identifier = b'\x55\x8B\xEC\x8B\x55\x08\x8B\x02\x89\x81\x2A\x2A\x2A\x2A\x8B\x42\x04\x89\x81\x2A\x2A\x2A\x2A\x8B\x42\x08\x89\x81\x2A\x2A\x2A\x2A\x8B\x45\x0C'
  36.     else:
  37.         identifier = b'\x55\x89\xE5\x8B\x55\x0C\x8B\x45\x08\x8B\x0A\x89\x88\x2A\x2A\x2A\x2A\x8B\x4A\x04\x89\x88\x2A\x2A\x2A\x2A\x8B\x52\x08\x89\x90\x2A\x2A\x2A\x2A\x8B\x55\x10\x89\x90'
  38. else:
  39.     raise ValueError('Unsupported game.')
  40.  
  41.  
  42. server = memory.find_binary('server')
  43.  
  44. MoveTo = server[identifier].make_function(
  45.     Convention.THISCALL,
  46.     [DataType.POINTER, DataType.POINTER, DataType.INT],
  47.     DataType.VOID
  48. )
  49.  
  50. class RouteType(IntEnum):
  51.     FASTEST = 0
  52.     SAFEST = 1
  53.     UNKNOWN = 2
  54.  
  55.  
  56. # =============================================================================
  57. # >> EVENTS
  58. # =============================================================================
  59. @Event('player_jump')
  60. def player_jump(event):
  61.     menu.send()
  62.  
  63.  
  64. # =============================================================================
  65. # >> CALLBACKS
  66. # =============================================================================
  67. def select_callback(menu, player_index, option):
  68.     player = Player(player_index)
  69.     destination = player.get_view_coordinates()
  70.  
  71.     for bot in PlayerIter(is_filters='bot'):
  72.         MoveTo(bot, destination, RouteType.FASTEST)
  73.  
  74.     return menu
  75.  
  76. menu = SimpleMenu(
  77.     [SimpleOption(1, 'Move bots')],
  78.     select_callback=select_callback
  79. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement