After the
update of CTakeDamageInfo struct,
CTakeDamageInfo::CTakeDamageInfo has also changed.
The second argument of CTakeDamageInfo has been changed from CBaseEntity* to CSGOAttackerInfo*.
Right now CBaseCSGrenadeProjectile(the base class of CMolotovProjectile) contains CSGOAttackerInfo, which will be copied to the inferno on Detonate.
The offset of CSGOAttackerInfo in CBaseCSGrenadeProjectile is 1300 on Linux and 1276 on Windows.
Offset for inferno is 2936 on Linux and 2912 on Windows.
If you want to set the attacker to Projectile, you can create a CustomType like this.
Syntax: Select all
# Source.Python Imports
# Core
import core
# Entities
from entities.entity import Entity
# Memory
from memory import get_object_pointer
from memory import make_object
from memory.manager import CustomType
from memory.manager import Type
from memory.manager import manager
class CSGOAttackerInfo(CustomType, metaclass=manager):
need_init = manager.instance_attribute(Type.BOOL, 0, "bool m_bNeedInit")
handle = manager.instance_attribute(Type.INT, 4, "EHANDLE m_hHndl")
is_player = manager.instance_attribute(Type.BOOL, 8, "bool m_bIsPlayer")
is_world = manager.instance_attribute(Type.BOOL, 9, "bool m_bIsWorld")
client_index = manager.instance_attribute(Type.INT, 12, "int m_iClientIndex")
survival_team = manager.instance_attribute(Type.INT, 16, "int m_nSurvivalTeam")
team_checked = manager.instance_attribute(Type.INT, 20, "int m_iTeamChecked")
team_num = manager.instance_attribute(Type.INT, 24, "int m_iTeamNum")
userid = manager.instance_attribute(Type.INT, 28, "int m_iUserId")
def set_attacker_info(attacker, entity, offset):
attacker_info = make_object(CSGOAttackerInfo, get_object_pointer(entity)+offset)
attacker_info.need_init = False
attacker_info.handle = attacker.inthandle
attacker_info.is_player = True
attacker_info.is_world = False
attacker_info.client_index = attacker.index
attacker_info.survival_team = -1
attacker_info.team_checked = attacker.team_index
attacker_info.team_num = attacker.team_index
attacker_info.userid = attacker.userid
if core.PLATFORM == "linux":
offset = 1300
else:
offset = 1276
def spawn_molotov(attacker, origin):
molotov = Entity.create("molotov_projectile")
molotov.origin = origin
set_attacker_info(attacker, molotov, offset)
molotov.spawn()
molotov.call_input("InitializeSpawnFromWorld")
Or you can use the function that CBaseCSGrenadeProjectile uses to set the attacker.
Syntax: Select all
# Core
import core
# Entities
from entities.entity import Entity
# Memory
from memory import Convention
from memory import DataType
from memory import find_binary
# Players
from players.entity import Player
if core.PLATFORM == "linux":
signature = b"\x55\x89\xE5\x57\x56\x53\x83\xEC\x2C\xC7\x45\xDC\x00\x00\x00\x00\x8B\x5D\x08"
else:
signature = b"\x55\x8B\xEC\x53\x8B\x5D\x08\x56\x57\x8B\xF9\x53"
# void CBaseCSGrenadeProjectile::SetAttacker( CBaseCSGrenadeProjectile * this , CBaseCombatCharacter * attacker )
set_attacker = find_binary("server", srv_check=False)[signature].make_function(
Convention.THISCALL, (
DataType.POINTER,
DataType.POINTER,
),
DataType.VOID,
)
attacker = Player(1)
molotov = Entity.create("molotov_projectile")
molotov.origin = attacker.origin
set_attacker(molotov, attacker)
molotov.spawn()
molotov.call_input("InitializeSpawnFromWorld")