Raised This Month: $ Target: $400
 0% 

Map Entity Extender (module)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LunaTheReborn
Junior Member
Join Date: Feb 2020
Old 10-07-2024 , 02:07   Map Entity Extender (module)
Reply With Quote #1

Introduction
This is a module that allows one to process some 'missing class entity' that comes with the map. For example, wanna play CS on some TFC map? Or having trouble handling some custom renderer on the server side?

This module is NOT for currently existing classes, like "info_target" which already comes with a managing class CBaseEntity.
This is for some edge cases where a map comes with an entity that your MP.DLL has no corresponding class to manage it.
The module will therefore inject a 'fake' class to manage this entity and forward two of many member functions to your AMX plugin.

Natives
Only three of them. Super straightforward.
Code:
/*
* Purpose: Inject an entity class into the engine, and register a callback function of its Spawn()
* @param szClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @param szSpawnCallback: The local AMX callback function which will be invoked during DispatchSpawn() phase.
						The local AMX callback function must come with a signature the same as Ham_Spawn.
* @return int32_t: 0 if fail, other numbers if succeed.
* @except AMX_ERR_NATIVE: Throw if no such AMX callback is found.
*/
native MEE_RegisterEntitySpawn(const szClassName[], const szSpawnCallback[]);

/*
* Purpose: Inject an entity class into the engine, and register a callback function of its KeyValue()
* @param szClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @param szKvdCallback:	The local AMX callback function which will be invoked during DispatchKeyValue() phase.
						The local AMX callback function must come with a signature as follows:
						public callback(iEntity, const szKey[], const szValue[]) -> bool
* @return int32_t: 0 if fail, other numbers if succeed.
* @except AMX_ERR_NATIVE: Throw if no such AMX callback is found.
*/
native MEE_RegisterEntityKvd(const szClassName[], const szKvdCallback[]);

/*
* Purpose: Replace a managing class of one entity with another.
* @param szOriginalClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @param szDestClassName: Entity class name, same as the one typed into LINK_ENTITY_TO_CLASS() macro in HLSDK.
* @return bool: 0 on fail, 1 on success.
* @except AMX_ERR_NATIVE: Another replacement had been registered and clashed.
* @note: Be extremely careful with this one, as it might cause memory access errors everywhere.
A safe example will be to treat spawning points from DoDC, TFC maps as if they were the CSCZ one.
*/
native MEE_ReplaceLinkedClass(const szOriginalClassName[], const szDestClassName[]);
You can use RegisterHamFromEntity() to further manipulate the entity in the Spawn() forward I provided. They will work as if it's on CBaseEntity, or "info_target" dummy thingy.

Supported games
Counter-Strike
Counter-Strike: Condition Zero
Untested on other games.

Souce code & Runtime
Available here.
You will need VC Runtime 2022 from Microsoft.
Linux is unsupported and never will.
Attached Files
File Type: zip MapEntityExt.zip (109.6 KB, 47 views)

Last edited by LunaTheReborn; 10-07-2024 at 02:22. Reason: Supply and clarify some the core purpose.
LunaTheReborn is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 10-07-2024 , 17:04   Re: Map Entity Extender (module)
Reply With Quote #2

nice, write a workflow *.yml
__________________
mlibre is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode