Bots/AI to shooting each other when ffa is on

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
Alex Winchester
Junior Member
Posts: 6
Joined: Tue May 16, 2023 4:30 pm

Bots/AI to shooting each other when ffa is on

Postby Alex Winchester » Wed May 17, 2023 2:58 pm

Hello,

I would like make another request for a plugin that makes bots on the same team shoot/kill each other when free for all is on,
User avatar
satoon101
Project Leader
Posts: 2698
Joined: Sat Jul 07, 2012 1:59 am

Re: Bots/AI to shooting each other when ffa is on

Postby satoon101 » Thu May 18, 2023 6:53 pm

All credit goes to L'In20Cible who created this back in the EventScripts days. This is a slightly modified version of GunGame-FFA-Bots.

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Python
import binascii

# Source.Python
from core import PLATFORM
from entities.entity import Entity
from memory import Convention, DataType, find_binary, make_object
from memory.hooks import PreHook
from players.entity import Player


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
_memory_data = {
"linux": {
"GetTeamNumber": "_ZNK11CBaseEntity13GetTeamNumberEv",
"InSameTeam": "_ZNK11CBaseEntity10InSameTeamEPS_",
"OnAudibleEvent": "_ZN6CCSBot14OnAudibleEventEP10IGameEventP11CBasePlayerf12PriorityTypebbPK6Vector",
"OnPlayerRadio": "_ZN6CCSBot13OnPlayerRadioEP10IGameEvent"
},
"windows": {
"GetTeamNumber": " 8B 81 F4 01 00 00 C3",
"InSameTeam": " 55 8B EC 8B 45 08 57 8B F9 85 C0 75 2A 32 C0 5F 5D C2 04 00",
"OnAudibleEvent": " 55 8B EC 83 EC 1C 56 8B 75 0C 57 8B F9 85 F6",
"OnPlayerRadio": " 55 8B EC 83 EC 0C 57 8B F9 8B 07 8B 80 04 01 00 00 FF D0 84 C0"
}
}
_data = _memory_data.get(PLATFORM, {})
if PLATFORM == 'windows':
for _key, _value in _data.items():
_data[_key] = binascii.unhexlify(_value.replace(' ', ''))

server = find_binary('server')

GetTeamNumber = server[_data['GetTeamNumber']].make_function(
Convention.THISCALL,
[DataType.POINTER],
DataType.INT,
)

InSameTeam = server[_data['InSameTeam']].make_function(
Convention.THISCALL,
[DataType.POINTER, DataType.POINTER],
DataType.BOOL,
)

OnAudibleEvent = server[_data['OnAudibleEvent']].make_function(
Convention.THISCALL,
[
DataType.POINTER,
DataType.POINTER,
DataType.POINTER,
DataType.FLOAT,
DataType.INT,
DataType.BOOL,
DataType.BOOL,
DataType.POINTER,
],
DataType.VOID,
)

OnPlayerRadio = server[_data['OnPlayerRadio']].make_function(
Convention.THISCALL,
[DataType.POINTER, DataType.POINTER],
DataType.VOID,
)

_hacked_teams = {}


# =============================================================================
# >> FUNCTION HOOKS
# =============================================================================
@PreHook(OnAudibleEvent)
def _pre_on_audible_event(stack_data):
"""Store the opposite team for later retrieval."""
other = stack_data[2]
if not other:
return

entity = make_object(Entity, other)
team_number = entity.team_index
entity2 = make_object(Entity, stack_data[0])
if entity2.team_index == team_number:
_hacked_teams[other] = 5 - team_number


@PreHook(GetTeamNumber)
def _pre_get_team_number(stack_data):
"""Retrieve the opposite team from above and return that value."""
pointer = stack_data[0]
if pointer not in _hacked_teams:
return None

value = _hacked_teams[pointer]
del _hacked_teams[pointer]
return value


@PreHook(InSameTeam)
def _pre_in_same_team(stack_data):
"""Return False for bots from InSameTeam."""
other = stack_data[1]
if stack_data[0] == other:
return None

entity = make_object(Entity, other)
if entity.classname != 'player':
return None

player = Player(entity.index)
if player.is_fake_client():
return False


@PreHook(OnPlayerRadio)
def _pre_on_player_radio(stack_data):
"""Return 0 when radio commands are issued."""
return 0

Also, this is assuming that the game you're using this on is CS:S.
Image
Alex Winchester
Junior Member
Posts: 6
Joined: Tue May 16, 2023 4:30 pm

Re: Bots/AI to shooting each other when ffa is on

Postby Alex Winchester » Thu May 18, 2023 9:22 pm

Yes this is for CS:S

and it works

Thank you very much

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 8 guests