-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement CBaseEntity::Fire<Bullets[3]|Buckshots>
hooks.
#202
Implement CBaseEntity::Fire<Bullets[3]|Buckshots>
hooks.
#202
Conversation
FEDERICOMB96
commented
Jun 21, 2021
- Implement "CBaseEntity::Fire<Bullets[3]|Buckshots>" hooks.
- Added new hook table "GamedllFunc_CBaseEntity".
- Added new hookchain argument type "ATYPE_VECTOR"
* Implement "CBaseEntity::Fire<Bullets[3]|Buckshots>" hooks. * Added new hook table "GamedllFunc_CBaseEntity". * Added new hookchain argument type "ATYPE_VECTOR"
Apparently there is a strange bug with Get/SetHookChainReturn, basically GetHookChainReturn is not returning the correct values and SetHookChainReturn is not applying values correctly, not sure if I would call this a bug but more than a implementation typo on my end, so if someone can check it that would be good |
@FEDERICOMB96 Done. Can you test it? |
Works fine now. I forgot to add ATYPE_VECTOR in SetHookChainArg native |
I tried this #include <amxmodx>
#include <reapi>
#include <xs>
public plugin_init()
{
RegisterHookChain(RG_CBaseEntity_FireBullets3, "RG_CBaseEntity_FireBullets3_pre", 0);
RegisterHookChain(RG_CBaseEntity_FireBullets3, "RG_CBaseEntity_FireBullets3_Post", 1);
}
public RG_CBaseEntity_FireBullets3_pre(pEntity, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, pevAttacker, bool:bPistol, shared_rand)
{
server_print("RG_CBaseEntity_FireBullets3_pre: pEntity %i, Float:vecSrc[3] {%f, %f, %f}, Float:vecDirShooting[3] {%f, %f, %f}, Float:vecSpread %f, ",
pEntity, vecSrc[0], vecSrc[1], vecSrc[2], vecDirShooting[0], vecDirShooting[1], vecDirShooting[2], vecSpread);
server_print("Float:flDistance %f, iPenetration %i, iBulletType %i, iDamage %i, Float:flRangeModifier %f, pevAttacker %i, bool:bPistol %i, shared_rand %i",
flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
new Float:vecRet[3];
xs_vec_set(vecRet, 50.0, 50.0, 50.0);
SetHookChainArg(3, ATYPE_VECTOR, vecRet);
//SetHookChainReturn(ATYPE_VECTOR, vecRet);
}
public RG_CBaseEntity_FireBullets3_Post(pEntity, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, pevAttacker, bool:bPistol, shared_rand)
{
server_print("RG_CBaseEntity_FireBullets3_post: pEntity %i, Float:vecSrc[3] {%f, %f, %f}, Float:vecDirShooting[3] {%f, %f, %f}, Float:vecSpread %f, ",
pEntity, vecSrc[0], vecSrc[1], vecSrc[2], vecDirShooting[0], vecDirShooting[1], vecDirShooting[2], vecSpread);
server_print("Float:flDistance %f, iPenetration %i, iBulletType %i, iDamage %i, Float:flRangeModifier %f, pevAttacker %i, bool:bPistol %i, shared_rand %i",
flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
new Float:vecRet[3];
GetHookChainReturn(ATYPE_VECTOR, vecRet);
client_print(0, print_chat, "Float:vecRet[3] {%f, %f, %f}", vecRet[0], vecRet[1], vecRet[2]);
} but SetHookChainArg throws an error I think the problem is here (hook_callback.h): inline AType getApiType(Vector) { return ATYPE_VECTOR; }
inline AType getApiType(Vector&) { return ATYPE_VECTOR; } |
@FEDERICOMB96 yes, vecDirShooting[0] = vecRet[0];
vecDirShooting[1] = vecRet[1];
vecDirShooting[2] = vecRet[2]; |
Oh i didn't know this, it works 😮 |
yes |
CBaseEntity::Fire<Bullets[3]|Buckshots>
hooks.
Done. |