# =============================================================================
# >> IMPORTS
# =============================================================================
from enum import IntEnum
import memory
from memory import Convention
from memory import DataType
from players.entity import Player
from filters.players import PlayerIter
from events import Event
from menus import SimpleMenu
from menus import SimpleOption
from core import PLATFORM
from core import SOURCE_ENGINE_BRANCH
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# CCSBot::MoveTo(Vector const&, RouteType)
# _ZN6CCSBot6MoveToERK6Vector9RouteType
if SOURCE_ENGINE_BRANCH == 'css':
if PLATFORM == 'windows':
identifier = b'\x55\x8B\xEC\x8B\x45\x08\xD9\x00\xD9\x99\xF8\x1A\x00\x00'
else:
identifier = '_ZN6CCSBot6MoveToERK6Vector9RouteType'
elif SOURCE_ENGINE_BRANCH == 'csgo':
if PLATFORM == 'windows':
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'
else:
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'
else:
raise ValueError('Unsupported game.')
server = memory.find_binary('server')
MoveTo = server[identifier].make_function(
Convention.THISCALL,
[DataType.POINTER, DataType.POINTER, DataType.INT],
DataType.VOID
)
class RouteType(IntEnum):
FASTEST = 0
SAFEST = 1
UNKNOWN = 2
# =============================================================================
# >> EVENTS
# =============================================================================
@Event('player_jump')
def player_jump(event):
menu.send()
# =============================================================================
# >> CALLBACKS
# =============================================================================
def select_callback(menu, player_index, option):
player = Player(player_index)
destination = player.get_view_coordinates()
for bot in PlayerIter(is_filters='bot'):
MoveTo(bot, destination, RouteType.FASTEST)
return menu
menu = SimpleMenu(
[SimpleOption(1, 'Move bots')],
select_callback=select_callback
)