#include <amxmodx>
#include <xs>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>
#define PLUGIN "无敌盛焰"
#define VERSION "1.1"
#define AUTHOR "xingke"
#define CSW_NEWXM1014 10055
new const g_extra_pipe[] = { "火焰连喷" };
new const NWEXM1014[3][] = {"models/v_xm1014_sy.mdl", "models/p_xm1014_sy.mdl", "models/w_xm1014_sy.mdl"}
new const weapon_fire_sprite[] = { "sprites/explode1.spr" }
new fire_spr
new g_pipe
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("CurWeapon", "Event_CurWeapon", "be", "1=1")
register_forward(FM_SetModel, "fw_SetModel", 1)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_xm1014", "fw_priattack", 1)
RegisterHam(Ham_TakeDamage, "player", "FwdTakeDamage")
register_clcmd("/buy_xm1014", "buy_newxm1014")
g_pipe = zp_register_extra_item(g_extra_pipe, 100, ZP_TEAM_HUMAN); //500是价格 自己修改
}
public plugin_precache()
{
for(new i = 0; i < 3; ++i) engfunc(EngFunc_PrecacheModel, NWEXM1014)
fire_spr = precache_model(weapon_fire_sprite)
}
public plugin_natives()
{
register_native("give_newxm1014", "buy_newxm1014",1)
}
public zp_extra_item_selected(id, item)
{
if(item == g_pipe)
{
buy_newxm1014(id)
}
}
public buy_newxm1014(id) //购买物品
{
if(!is_user_connected(id) || !is_user_alive(id))
return PLUGIN_HANDLED
if(user_has_weapon(id,CSW_XM1014)) engclient_cmd(id, "drop", "weapon_xm1014")
new iEntity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "weapon_xm1014"))
new Float:vecOrigin[3]
pev(id, pev_origin, vecOrigin)
set_pev(iEntity, pev_origin, vecOrigin)
set_pev(iEntity, pev_spawnflags, SF_NORESPAWN)
set_pev(iEntity, pev_iuser4, CSW_NEWXM1014)
dllfunc(DLLFunc_Spawn, iEntity)
dllfunc(DLLFunc_Touch, iEntity, id)
set_pdata_int(id, 376+get_pdata_int(iEntity, 49, 4), 120, 4)
return PLUGIN_HANDLED
}
public Event_CurWeapon(id)
{
if(!is_user_connected(id) || !is_user_alive(id))
return PLUGIN_HANDLED
new iEntity = get_pdata_cbase(id, 373)
if (iEntity > 0)
{
if(pev(iEntity, pev_iuser4) == CSW_NEWXM1014)
{
set_pev(id, pev_viewmodel2, NWEXM1014[0])
set_pev(id, pev_weaponmodel2, NWEXM1014[1])
}
}
return PLUGIN_CONTINUE
}
public fw_SetModel(iEntity, szModel[])
{
new owner = pev(iEntity, pev_owner)
if (!is_user_connected(owner) || !is_user_alive(owner))
return FMRES_IGNORED
if (strcmp(szModel, "models/w_xm1014.mdl"))
return FMRES_IGNORED
new szClassName[32]
pev(iEntity, pev_classname, szClassName, charsmax(szClassName))
if (strcmp(szClassName, "weaponbox"))
return FMRES_IGNORED
new iWeapon = get_pdata_cbase(iEntity, 35, 4)
if (iWeapon <= 0)
return FMRES_IGNORED
if (pev(iWeapon, pev_iuser4) != CSW_NEWXM1014)
return FMRES_IGNORED
engfunc(EngFunc_SetModel, iEntity, NWEXM1014[2])
return FMRES_SUPERCEDE
}
public FwdTakeDamage(victim, inflictor, attacker, Float:damage, damage_bits)
{
if(!is_user_connected(attacker) || !is_user_alive(attacker))
return HAM_IGNORED
new iEntity = get_pdata_cbase(attacker, 373)
if (iEntity > 0)
{
if (pev(iEntity, pev_iuser4) == CSW_NEWXM1014)
{
damage *= 5.6 //武器威力,自己试试,
SetHamParamFloat(4, damage)
return HAM_HANDLED
}
}
return HAM_IGNORED
}
public fw_priattack(weapon)
{
new id
id = pev(weapon, pev_owner)
new iEntity = get_pdata_cbase(id, 373)
if (iEntity > 0)
{
if (pev(iEntity, pev_iuser4) == CSW_NEWXM1014 && get_pdata_int(iEntity, 51, 4) > 0 && is_user_alive(id))
{
new Float:fOrigin[3], Float:fVelocity[3]
pev(id, pev_origin, fOrigin)
velocity_by_aim(id, 35, fVelocity)
new Float:fTemp[3], iFireOrigin[3]
xs_vec_add(fOrigin, fVelocity, fTemp)
FVecIVec(fTemp, iFireOrigin)
new Float:fFireVelocity[3], iFireVelocity[3]
velocity_by_aim(id, 120, fFireVelocity)
FVecIVec(fFireVelocity, iFireVelocity)
show_firespr(id, iFireOrigin, iFireVelocity)
}
}
}
public show_firespr(id, origin[3], velocity[3])
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(120)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_coord(velocity[0])
write_coord(velocity[1])
write_coord(velocity[2] + 5)
write_short(fire_spr)
write_byte(1)
write_byte(10)
write_byte(1)
write_byte(5)
message_end()
}
求大嬸們的指點==
|