Hello all, I need help with this code. The aim origin seems a bit off. Can anyone fix it? And the other thing is how do i block the default hornetgun fire sound? Tried to hook forward fm_emitsound but it seems the sounds aren't registered there. Also, from bmod's hornetgun.cpp, there's a "MOMMASPLAT" sprite however I can't find it anywhere in the sprites folder.
Код:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#define IsPlayer(%1) (1 <= %1 <= get_maxplayers())
new const m_pPlayer = 28
new const m_flNextSecondaryAttack = 36
new const LINUX_OFFSET_WEAPONS = 4
new const LINUX_OFFSET_AMMO = 5
new const OFFSET_AMMO_HORNETGUN = 321
new iZapBeamSpr, m_sGlowSpr, splat
public plugin_init()
{
register_plugin("[BMOD] Weapon: Hornetgun", "1.0", "Rango")
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_hornetgun", "Hornetgun_SecondaryAttack_Pre", 0)
}
public plugin_precache()
{
iZapBeamSpr = precache_model("sprites/lgtning.spr")
m_sGlowSpr = precache_model("sprites/glow04.spr")
splat = precache_model("sprites/mommaspit.spr")
precache_sound("leech/leech_bite1.wav")
precache_sound("weapons/electro4.wav")
}
public Hornetgun_SecondaryAttack_Pre(const hornetgun)
{
new player = get_pdata_cbase(hornetgun, m_pPlayer, LINUX_OFFSET_WEAPONS)
new HornetAmmo = get_pdata_int(player, OFFSET_AMMO_HORNETGUN, LINUX_OFFSET_AMMO)
if(HornetAmmo >= 4)
{
new Float:fAimOrigin[3]
new Float:fPlayerOrigin[3]
new Float:fAimVector[3]
pev(player, pev_v_angle, fAimVector)
angle_vector(fAimVector, ANGLEVECTOR_FORWARD, fAimVector)
pev(player, pev_origin, fPlayerOrigin)
fAimVector[0] = fAimVector[0] * 9999.0 + fPlayerOrigin[0]
fAimVector[1] = fAimVector[1] * 9999.0 + fPlayerOrigin[1]
fAimVector[2] = fAimVector[2] * 9999.0 + fPlayerOrigin[2]
new iTr = create_tr2()
engfunc(EngFunc_TraceLine, fPlayerOrigin, fAimVector, DONT_IGNORE_MONSTERS, player, iTr)
get_tr2(iTr, TR_vecEndPos, fAimOrigin)
free_tr2(iTr)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS)
engfunc(EngFunc_WriteCoord, fPlayerOrigin[0])
engfunc(EngFunc_WriteCoord, fPlayerOrigin[1])
engfunc(EngFunc_WriteCoord, fPlayerOrigin[2])
engfunc(EngFunc_WriteCoord, fAimOrigin[0])
engfunc(EngFunc_WriteCoord, fAimOrigin[1])
engfunc(EngFunc_WriteCoord, fAimOrigin[2])
write_short(iZapBeamSpr) // sprite index
write_byte(0) // Starting frame
write_byte(0) // framerate * 0.1
write_byte(3) // life * 0.1
write_byte(200) // width
write_byte(2) // noise
write_byte(220) // color r, g, b
write_byte(220) // color r, g, b
write_byte(255) // color r, g, b
write_byte(255) // brightness
write_byte(0) // scroll speed
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_WORLDDECAL)
engfunc(EngFunc_WriteCoord, fAimOrigin[0])
engfunc(EngFunc_WriteCoord, fAimOrigin[1])
engfunc(EngFunc_WriteCoord, fAimOrigin[2])
write_byte(splat)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_SPRITETRAIL)
engfunc(EngFunc_WriteCoord, fPlayerOrigin[0])
engfunc(EngFunc_WriteCoord, fPlayerOrigin[1])
engfunc(EngFunc_WriteCoord, fPlayerOrigin[2])
engfunc(EngFunc_WriteCoord, fAimOrigin[0])
engfunc(EngFunc_WriteCoord, fAimOrigin[1])
engfunc(EngFunc_WriteCoord, fAimOrigin[2])
write_short(m_sGlowSpr) // model
write_byte(20) // count
write_byte(10) // life * 10
write_byte(random_num(1, 2)) // size * 10
write_byte(10) // amplitude * 0.1
write_byte(0) // speed * 100
message_end()
engfunc(EngFunc_EmitAmbientSound, player, fAimOrigin, "weapons/electro4.wav", 0.5, ATTN_NORM, 0, random_num(140, 160))
set_pdata_float(hornetgun, m_flNextSecondaryAttack, 1.0, LINUX_OFFSET_WEAPONS)
UTIL_PlayWeaponAnimation(player, 5)
set_pdata_int(player, OFFSET_AMMO_HORNETGUN, HornetAmmo - 4, LINUX_OFFSET_AMMO)
return HAM_SUPERCEDE
}
return HAM_SUPERCEDE
}
stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
set_pev(Player, pev_weaponanim, Sequence)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
write_byte(Sequence)
write_byte(pev(Player, pev_body))
message_end()
}