Open satoon101 opened 9 years ago
Too bad I didn't notice this earlier. Back in the day, when I just got around to the memory stuff, my first found signature was CBaseAnimating::Dissolve
.
I know that signatures are hard to maintain etc, but still, it's one of the options to solve this! The fact that the target function contains a library-wide unique string ragdoll_dissolved
simplifies this approach.
So. I've cleaned up the code and made sure that the signature is up-to-date. This is only for CS:S, though.
dissolver.py
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python
from core import GAME_NAME
from engines.server import global_vars
from memory import make_object, NULL
from memory.manager import TypeManager
from paths import PLUGIN_DATA_PATH
# Dissolver
from .info import info
# =============================================================================
# >> TYPES
# =============================================================================
DISSOLVER_DATA_PATH = PLUGIN_DATA_PATH / info.name
TYPE_FILE_PATH = DISSOLVER_DATA_PATH / GAME_NAME / 'CBaseAnimating.ini'
if TYPE_FILE_PATH.isfile():
manager = TypeManager()
DissolvableEntity = manager.create_type_from_file(
'CBaseAnimating', TYPE_FILE_PATH)
else:
from warnings import warn
warn("Entity dissolving is not supported by this game")
manager = DissolvableEntity = None
# =============================================================================
# >> FUNCTIONS
# =============================================================================
def dissolve(entity, effect_type=0):
if DissolvableEntity is None:
return
dissolvable_entity = make_object(DissolvableEntity, entity.pointer)
dissolvable_entity.dissolve(
NULL, global_vars.current_time, False, effect_type, entity.origin, 2)
# =============================================================================
# >> TESTS
# =============================================================================
from events import Event
from filters.entities import EntityIter
@Event('player_jump')
def on_player_jump(game_event):
for i, entity in enumerate(EntityIter('weapon_ak47')):
dissolve(entity, i % 4)
data/plugins/dissolver/cstrike/CBaseAnimating.ini
binary = server
[function]
# bool CBaseAnimating::Dissolve(CBaseEntity *, const char *pMaterialName, float flStartTime, bool bNPCOnly, int nDissolveType, Vector vDissolverOrigin, int iMagnitude )
[[dissolve]]
identifier_linux = _ZN14CBaseAnimating8DissolveEPKcfbi6Vectori
identifier_windows = 55 8B EC 80 7D 10 00 56 57
convention = THISCALL
arguments = POINTER, FLOAT, BOOL, INT, POINTER, INT
return_type = BOOL
Well, this issue was more to find a way to know which weapons to dissolve (though it was clearly poorly worded). I can still use the same env_entity_dissolver entity to dissolve weapons as I do ragdolls.
Currently only ragdolls are removed/dissolved. Find a way to dissolve the player's weapons on death.