08/03/2022, 11:50 AM
Alguien puede modificar esto para que me ande en el Half-Life: DeathMatch
Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <xs>
#define PLUGIN "Gun Drop Effect"
#define VERSION "1.0"
#define AUTHOR "Williams"
#define DROP_GUN_MODEL "models/gundrop.mdl"
#define DROP_GUN_CLASSNAME "drop_gun_ef"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_SetModel, "xFwSetModel")
register_forward(FM_Think, "xFwThink")
register_forward(FM_Touch, "xFwTouch")
}
public plugin_precache()
{
precache_model(DROP_GUN_MODEL)
}
public xFwTouch(touched, ent)
{
if(!pev_valid(ent))
return FMRES_IGNORED
static xClassName[32]
pev(ent, pev_classname, xClassName, charsmax(xClassName))
if(equal(xClassName, "weaponbox") || equal(xClassName, DROP_GUN_CLASSNAME))
{
xFlatEnt(ent)
}
return FMRES_IGNORED
}
public xFwThink(ent)
{
if(!pev_valid(ent))
return FMRES_IGNORED
static xClassName[32]
pev(ent, pev_classname, xClassName, charsmax(xClassName))
if(!equal(xClassName, DROP_GUN_CLASSNAME))
return FMRES_IGNORED
static xWpn
xWpn = pev(ent, pev_iuser1)
if(!pev_valid(xWpn))
{
set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME)
return FMRES_SUPERCEDE
}
set_pev(ent, pev_nextthink, get_gametime())
return FMRES_IGNORED
}
public xFwSetModel(ent, model[])
{
if(!pev_valid(ent) || !equali(model, "models/w_", 8) || equali(model, "models/w_weaponbox.mdl"))
return FMRES_IGNORED
static xClassName[32]
pev(ent, pev_classname, xClassName, charsmax(xClassName))
if(!equal(xClassName, "weaponbox"))
return FMRES_IGNORED
static xGunDrop
xGunDrop = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if(!pev_valid(xGunDrop))
return FMRES_IGNORED
set_pev(xGunDrop, pev_classname, DROP_GUN_CLASSNAME)
engfunc(EngFunc_SetModel, xGunDrop, DROP_GUN_MODEL)
set_pev(xGunDrop, pev_iuser1, ent)
set_pev(xGunDrop, pev_framerate, 1.0)
set_pev(xGunDrop, pev_animtime, get_gametime())
set_pev(xGunDrop, pev_movetype, MOVETYPE_FOLLOW)
set_pev(xGunDrop, pev_aiment, ent)
set_pev(xGunDrop, pev_nextthink, get_gametime())
return FMRES_IGNORED
}
stock xFlatEnt(ent)
{
if(pev(ent, pev_flags) & ~FL_ONGROUND) return
static Float:origin[3], Float:traceto[3], trace = 0, Float:fraction, Float:angles[3], Float:angles2[3]
pev(ent, pev_origin, origin)
pev(ent, pev_angles, angles)
xs_vec_sub(origin, Float:{0.0, 0.0, 10.0}, traceto)
engfunc(EngFunc_TraceLine, origin, traceto, IGNORE_MONSTERS, ent, trace)
get_tr2(trace, TR_flFraction, fraction)
if(fraction == 1.0) return
static Float:original_forward[3]
angle_vector(angles, ANGLEVECTOR_FORWARD, original_forward)
static Float:right[3], Float:up[3], Float:fwd[3]
get_tr2(trace, TR_vecPlaneNormal, up)
if(up[2] == 1.0) return
xs_vec_cross(original_forward, up, right)
xs_vec_cross(up, right, fwd)
vector_to_angle(fwd, angles)
vector_to_angle(right, angles2)
angles[2] = -1.0 * angles2[0]
set_pev(ent, pev_angles, angles)
}