Page 1 of 1

gg_ffa_bots

Posted: Fri Feb 02, 2018 12:16 am
by satoon101
I'm trying to recreate L'In20Cible's gg_ffa_bots plugin from this thread, but I am having some issues.

The signatures have changed, so even the above will no longer work on Windows when using ES/GunGame51. Outside of that, my issue is that I am getting an error when running the following on Linux:

Syntax: Select all

# ../gungame/plugins/custom/gg_ffa_bots/gg_ffa_bots.py

"""."""

# =============================================================================
# >> IMPORTS
# =============================================================================
from entities.entity import Entity
from memory import Convention, DataType, find_binary, make_object
from memory.hooks import PreHook
from players.entity import Player

server = find_binary('server')

# GetTeamNumber = server[b'\x8B\x81\xC0\x01\x00\x00\xC3'].make_function(
GetTeamNumber = server['_ZNK11CBaseEntity13GetTeamNumberEv'].make_function(
Convention.THISCALL,
[DataType.POINTER],
DataType.INT,
)

InSameTeam = server[
# b'\x55\x8B\xEC\x8B\x45\x08\x85\xC0\x57\x8B\xF9\x75\x07\x32'
# b'\xC0\x5F\x5D\xC2\x04\x00\x8B\x80\xC0\x01\x00\x00\x56\x50'
'_ZNK11CBaseEntity10InSameTeamEPS_'
].make_function(
Convention.THISCALL,
[DataType.POINTER, DataType.POINTER],
DataType.BOOL,
)

OnAudibleEvent = server[
# b'\x55\x8B\xEC\x83\xEC\x18\x56\x57\x8B\x7D\x0C\x85\xFF\x8B\xF1'
# b'\x0F\x84\x2A\x2A\x2A\x2A\x57\xE8\x2A\x2A\x2A\x2A\x84\xC0'
'_ZN6CCSBot14OnAudibleEventEP10IGameEventP11CBasePlayerf12PriorityTypebbPK6Vector'
].make_function(
Convention.THISCALL,
[
DataType.POINTER,
DataType.POINTER,
DataType.POINTER,
DataType.FLOAT,
DataType.INT,
DataType.BOOL,
DataType.BOOL,
DataType.POINTER,
],
DataType.VOID,
)

OnPlayerRadio = server[
# b'\x55\x8B\xEC\x83\xEC\x0C\x56\x8B\xF1\x8B\x06\x8B\x90\x00'
# b'\x01\x00\x00\xFF\xD2\x84\xC0\x0F\x84\xE0\x00\x00\x00\x8B'
'_ZN6CCSBot13OnPlayerRadioEP10IGameEvent'
].make_function(
Convention.THISCALL,
[DataType.POINTER, DataType.POINTER],
DataType.VOID,
)

_hacked_teams = {}


@PreHook(GetTeamNumber)
def _pre_get_team_number(stack_data):
""""""
if not stack_data[0] in _hacked_teams:
return

value = _hacked_teams[stack_data[0]]
del _hacked_teams[stack_data[0]]
return value


@PreHook(InSameTeam)
def _pre_in_same_team(stack_data):
""""""
if stack_data[0] != stack_data[1]:
entity = make_object(Entity, stack_data[0])
if entity.classname == 'player':
player = Player(entity.index)
if player.is_fake_client():
return False


@PreHook(OnAudibleEvent)
def _pre_on_audible_event(stack_data):
""""""
if stack_data[1]:
entity = make_object(Entity, stack_data[1])
team_number = entity.team_index
entity2 = make_object(Entity, stack_data[7])
if entity2.team_index == team_number:
_hacked_teams[stack_data[1]] = 5 - team_number


@PreHook(OnPlayerRadio)
def _pre_on_player_radio(stack_data):
""""""
return 0

And the error I am getting is:

Syntax: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/gungame/plugins/custom/gg_ffa_bots/gg_ffa_bots.py", line 91, in _pre_on_audible_event
entity = make_object(Entity, stack_data[1])
File "../addons/source-python/packages/source-python/entities/_base.py", line 218, in _obj
return cls(index_from_pointer(ptr))

ValueError: Conversion from "Pointer" (<_memory.Pointer object at 0xeae7ee90>) to "Index" failed.


Does anyone see what I'm doing wrong?

Also, would someone help me get those signatures for Windows? I have been very unsuccessful in doing that myself, so far.

*Edit: I should mention that this is for CS:S. CS:GO has the mp_teammates_are_enemies cvar that handles this by itself.

Re: gg_ffa_bots

Posted: Fri Feb 02, 2018 5:44 am
by Ayuto
I'm currently on the phone, but the symbol looks like stack_data[1] is an IGameEvent.

Re: gg_ffa_bots

Posted: Fri Feb 02, 2018 6:06 am
by L'In20Cible
Ayuto wrote:I'm currently on the phone, but the symbol looks like stack_data[1] is an IGameEvent.

Correct. If an argument was [1] using SPE, it will be [2] using SP because SPE added the this pointer at the end while SP insert it at the beginning. As for the signatures, you can check BotAttackControl on SM; I think they maintains up-to-date signatures.

Re: gg_ffa_bots

Posted: Fri Feb 02, 2018 7:59 pm
by satoon101
L'In20Cible wrote:
Ayuto wrote:I'm currently on the phone, but the symbol looks like stack_data[1] is an IGameEvent.

Correct. If an argument was [1] using SPE, it will be [2] using SP because SPE added the this pointer at the end while SP insert it at the beginning. As for the signatures, you can check BotAttackControl on SM; I think they maintains up-to-date signatures.

Awesome! That was it, thank you both! I completely forgot that SPE moved the this pointer to the end.

Thanks for the tip on the signatures, I'll get on that tonight.