FireBullets3 & FireBuckshots not working

Сообщения
219
Реакции
42
Half-fixed at post #5

Two issues.

1) rg_fire_bullets3 and rg_fire_buckshots (rg_fire_bullets too) are not working aren't creating decals.
They do nothing.

2) Also hooks (recently added https://github.com/s1lentq/reapi/pull/202) are returning the value of pEntity same as pevAttacker value.
Seems to be a game mistake?
So, we have pevAttacker value two times.
Or probably is a mistake on documentation? https://github.com/s1lentq/reapi/blob/master/reapi/src/natives/natives_misc.cpp#L373

Test code (hook and natives):
Код:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <reapi>

public plugin_init()
{
    register_clcmd("say /test", "clcmd_saytest")

    // weapons except shotguns
    RegisterHookChain(RG_CBaseEntity_FireBullets3, "RG_CBaseEntity_FireBullets3_pre", 0);
    RegisterHookChain(RG_CBaseEntity_FireBullets3, "RG_CBaseEntity_FireBullets3_post", 1);

    // only shotguns
    RegisterHookChain(RG_CBaseEntity_FireBuckshots, "RG_CBaseEntity_FireBuckshots_pre", 0);
    RegisterHookChain(RG_CBaseEntity_FireBuckshots, "RG_CBaseEntity_FireBuckshots_post", 1);

    // don't know
    RegisterHookChain(RG_CBaseEntity_FireBullets, "RG_CBaseEntity_FireBullets_pre", 0);
    RegisterHookChain(RG_CBaseEntity_FireBullets, "RG_CBaseEntity_FireBullets_post", 1);
}

public clcmd_saytest(id)
{
    fireBullets3(id)
}

fireBullets3(pevOwner)
{
    new this = get_member(pevOwner, m_pActiveItem);

    new Float:vecSrc[3], Float:vecDir[3];
    ExecuteHam(Ham_Player_GetGunPosition, pevOwner, vecSrc);
    global_get(glb_v_forward, vecDir);

    new Float:flBurstSpread = get_member(this, m_Weapon_fBurstSpread);
    new iRandomSeed = get_member(pevOwner, random_seed);

    rg_fire_bullets3(this, pevOwner, vecSrc, vecDir, flBurstSpread, 8192.0, 5, BULLET_PLAYER_762MM, 32, 8.0, false, iRandomSeed);
    // that's how hook is been called by game (wrong 1st parameter?)
    //rg_fire_bullets3(pevOwner, pevOwner, vecSrc, vecDir, flBurstSpread, 8192.0, 5, BULLET_PLAYER_762MM, 32, 8.0, false, iRandomSeed);

    //new Float:flSpread[3]
    //rg_fire_buckshots(this, pevOwner, 1, vecSrc, vecDir, flSpread, 8192.0, 0, 10)
    //rg_fire_bullets(this, pevOwner, 1, vecSrc, vecDir, flSpread, 8192.0, BULLET_PLAYER_762MM, 0, 10)
}

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);
}

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);
}

public RG_CBaseEntity_FireBuckshots_pre(pEntity, cShots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], Float:flDistance, iTracerFreq, iDamage, pevAttacker)
{
    server_print("RG_CBaseEntity_FireBuckshots_pre: pEntity %i, cShots %i, Float:vecSrc[3] {%f, %f, %f}, Float:vecDirShooting[3] {%f, %f, %f}, Float:vecSpread[3] {%f, %f, %f}, ",
        pEntity, cShots, vecSrc[0], vecSrc[1], vecSrc[2], vecDirShooting[0], vecDirShooting[1], vecDirShooting[2], vecSpread[0], vecSpread[1], vecSpread[2]);

    server_print("Float:flDistance %f, iTracerFreq %i, iDamage %i, pevAttacker %i",
        flDistance, iTracerFreq, iDamage, pevAttacker);
}

public RG_CBaseEntity_FireBuckshots_post(pEntity, cShots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], Float:flDistance, iTracerFreq, iDamage, pevAttacker)
{
    server_print("RG_CBaseEntity_FireBuckshots_post: pEntity %i, cShots %i, Float:vecSrc[3] {%f, %f, %f}, Float:vecDirShooting[3] {%f, %f, %f}, Float:vecSpread[3] {%f, %f, %f}, ",
        pEntity, cShots, vecSrc[0], vecSrc[1], vecSrc[2], vecDirShooting[0], vecDirShooting[1], vecDirShooting[2], vecSpread[0], vecSpread[1], vecSpread[2]);

    server_print("Float:flDistance %f, iTracerFreq %i, iDamage %i, pevAttacker %i",
        flDistance, iTracerFreq, iDamage, pevAttacker);
}

public RG_CBaseEntity_FireBullets_pre(pEntity, cShots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker)
{
    server_print("RG_CBaseEntity_FireBullets_pre: pEntity %i, cShots %i, Float:vecSrc[3] {%f, %f, %f}, Float:vecDirShooting[3] {%f, %f, %f}, Float:vecSpread[3] {%f, %f, %f}, ",
        pEntity, cShots, vecSrc[0], vecSrc[1], vecSrc[2], vecDirShooting[0], vecDirShooting[1], vecDirShooting[2], vecSpread[0], vecSpread[1], vecSpread[2]);

    server_print("Float:flDistance %f, iBulletType %i, iTracerFreq %i, iDamage %i, pevAttacker %i",
        flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
}

public RG_CBaseEntity_FireBullets_post(pEntity, cShots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker)
{
    server_print("RG_CBaseEntity_FireBullets_post: pEntity %i, cShots %i, Float:vecSrc[3] {%f, %f, %f}, Float:vecDirShooting[3] {%f, %f, %f}, Float:vecSpread[3] {%f, %f, %f}, ",
        pEntity, cShots, vecSrc[0], vecSrc[1], vecSrc[2], vecDirShooting[0], vecDirShooting[1], vecDirShooting[2], vecSpread[0], vecSpread[1], vecSpread[2]);

    server_print("Float:flDistance %f, iBulletType %i, iTracerFreq %i, iDamage %i, pevAttacker %i",
        flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
}
 
Последнее редактирование:
Сообщения
192
Реакции
148
Помог
1 раз(а)
raulitop, ловишь попадание и рисуешь декали
 
Сообщения
219
Реакции
42
Well, seems fireBullets3 taken from here: https://dev-cs.ru/threads/3149/
Has wrong get aim vector. (see code below to fix)
Now shot direction is good.

BUT, rg_fire_bullets3, rg_fire_buckshots, rg_fire_bullets will never create a decal effect.
That's handled by playbackevent.
So, in order to create a decal. You must send a playbackevent (like in commented fixed code below).

BE CAREFUL, because calling playbackevent will cause you call shot animation, shot sound and decal creation.
Yes, all at the same time. It's impossible to separate them.
So, if you want to change shot sound or shot animation. You can't call playbackevent.
You must create a 'fake' decal message on TraceAttack function getting vecEnd position.
Something like this (do checks to be only on your weapon): https://forums.alliedmods.net/showthread.php?t=148432&page=2

Код:
fireBullets3(pevOwner)
{
    new this = get_member(pevOwner, m_pActiveItem);

    new Float:vecSrc[3];
    ExecuteHam(Ham_Player_GetGunPosition, pevOwner, vecSrc);

    new Float:vecAngle[3], Float:vecPunchAngle[3], Float:vecDir[3];
    pev(pevOwner, pev_v_angle, vecAngle);
    pev(pevOwner, pev_punchangle, vecPunchAngle);

    vecAngle[0] += vecPunchAngle[0];
    vecAngle[1] += vecPunchAngle[1];
    vecAngle[2] += vecPunchAngle[2];

    engfunc(EngFunc_MakeVectors, vecAngle);
    global_get(glb_v_forward, vecDir);

    new Float:flBurstSpread = get_member(this, m_Weapon_fBurstSpread); // here is returning 0.0 always. But anyways
    new iRandomSeed = get_member(pevOwner, random_seed);

    rg_fire_bullets3(this, pevOwner, vecSrc, vecDir, flBurstSpread, 8192.0, 5, BULLET_PLAYER_762MM, 32, 8.0, false, iRandomSeed);
    // that's how hook is been called (wrong 1st parameter?)
    //rg_fire_bullets3(pevOwner, pevOwner, vecSrc, vecDir, flBurstSpread, 8192.0, 5, BULLET_PLAYER_762MM, 32, 8.0, false, iRandomSeed);

    // animation, sound and decals
    //engfunc(EngFunc_PlaybackEvent, FEV_HOSTONLY, pevOwner, g_iEvent, 0.0, NULL_VECTOR, NULL_VECTOR, 0.0, 0.0, floatround(vecPunchAngle[0] * 100.0), floatround(vecPunchAngle[1] * 100.0), false, false);

    //new Float:flSpread[3]
    //rg_fire_buckshots(this, pevOwner, 1, vecSrc, vecDir, flSpread, 8192.0, 0, 10)
    //rg_fire_bullets(this, pevOwner, 1, vecSrc, vecDir, flSpread, 8192.0, BULLET_PLAYER_762MM, 0, 10)
}
 
Последнее редактирование:

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу