Is there any way to view the deaths of chickens in CSGO and who killed the animal?
Thanks in advance!
CSGO Chicken Entities
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Syntax: Select all
# ../chicken/chicken.py
# ============================================================================
# >> IMPORTS
# ============================================================================
# Source.Python Imports
# Core
from core import PLATFORM
# Entities
from entities import TakeDamageInfo
from entities.helpers import index_from_pointer
# Memory
from memory import Convention
from memory import DataType
from memory import find_binary
from memory import get_object_pointer
from memory import make_object
from memory.hooks import PreHook
# Messages
from messages import SayText2
# Players
from players.entity import PlayerEntity
# ============================================================================
# >> GLOBAL VARIABLES
# ============================================================================
# Get the CChiken::Event_Killed function ...
CHICKEN_KILLED_FUNC = find_binary('server').find_address(
'_ZN8CChicken12Event_KilledERK15CTakeDamageInfo' if
PLATFORM == 'linux' else b'\x55\x8B\xEC\x83\xEC\x18\x56\x51\x68\x40'
).make_function(Convention.THISCALL,
(DataType.POINTER, DataType.POINTER), DataType.VOID)
# ============================================================================
# >> HOOKS
# ============================================================================
@PreHook(CHICKEN_KILLED_FUNC)
def pre_chicken_killed(arguments):
"""Pre CChiken::Event_Killed hook callback."""
# Get the CTakeDamageInfo instance...
info = make_object(TakeDamageInfo, arguments[1])
# Get the index of the chicken...
index = index_from_pointer(arguments[0])
# Get the PlayerEntity instance of the attacker...
attacker = PlayerEntity(info.attacker)
# Display a message...
SayText2(message='{0} killed a chicken (index: {1}).'.format(
attacker.name, index)).send()
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
While testing the creation code, I noticed the game is firing the following event when a chicken is dying:
Which means we doesn't have to hook anything. The following snippet allows you to spawn chickens with "/chicken" and notify everyone when a chicken get killed.
Code: Select all
"other_death"
{
"otherid" "short" // other entity ID who died
"othertype" "string" // other entity type
"attacker" "short" // user ID who killed
"weapon" "string" // weapon name killer used
"weapon_itemid" "string" // inventory item id of weapon killer used
"weapon_fauxitemid" "string" // faux item id of weapon killer used
"weapon_originalowner_xuid" "string"
"headshot" "bool" // singals a headshot
"penetrated" "short" // number of objects shot penetrated before killing target
}
Which means we doesn't have to hook anything. The following snippet allows you to spawn chickens with "/chicken" and notify everyone when a chicken get killed.
Syntax: Select all
# ../chicken/chicken.py
# ============================================================================
# >> IMPORTS
# ============================================================================
# Source.Python Imports
# Events
from events import Event
# Entities
from entities.entity import BaseEntity
from entities.helpers import create_entity
from entities.helpers import spawn_entity
# Messages
from messages import SayText2
# Players
from players.helpers import index_from_userid
from players.entity import PlayerEntity
# ============================================================================
# >> GAME EVENTS
# ============================================================================
@Event
def player_say(game_event):
"""Fired every time a player is typing something."""
# Make sure the typed text was "/chicken"...
if game_event.get_string('text') != '/chicken':
return
# Create a chicken entity...
chicken = BaseEntity(create_entity('chicken'))
# Move the chicken where the player is looking at...
chicken.origin = PlayerEntity(index_from_userid(game_event.get_int(
'userid'))).get_view_coordinates()
# Finally, spawn the chicken entity...
spawn_entity(chicken.index)
@Event
def other_death(game_event):
"""Fired when a non-player entity is dying."""
# Make sure the entity was a chicken...
if game_event.get_string('othertype') != 'chicken':
return
# Get the attacker's userid...
userid = game_event.get_int('attacker')
# Make sure the attacker was a player...
if not userid:
return
# Get a PlayerEntity instance of the attacker...
attacker = PlayerEntity(index_from_userid(game_event.get_int('attacker')))
# Display a message...
SayText2(message='{0} killed a chicken (index: {1}).'.format(
attacker.name, game_event.get_int('otherid'))).send()
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 69 guests