Code for testing, hit radio1 key to create a Cool Entity that will fly through everything.
Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
new g_spriteIndexLaserBeam
public plugin_init()
{
register_clcmd("radio1", "CreateCoolEntity")
register_think("my_cool_entity", "CoolEntity_Think")
}
public plugin_precache()
{
g_spriteIndexLaserBeam = precache_model("sprites/laserbeam.spr")
}
public CreateCoolEntity(index)
{
new Float:origin[3]
entity_get_vector(index, EV_VEC_origin, origin)
new entity = create_entity("info_target")
entity_set_string(entity, EV_SZ_classname, "my_cool_entity")
entity_set_int(entity, EV_INT_solid, SOLID_BBOX)
entity_set_int(entity, EV_INT_movetype, MOVETYPE_NOCLIP)
entity_set_edict(entity, EV_ENT_owner, index)
entity_set_model(entity, "models/player/sas/sas.mdl")
entity_set_size(entity, Float:{-16.0, -16.0, -16.0}, Float:{16.0, 16.0, 16.0})
entity_set_origin(entity, origin)
new Float:velocity[3]
velocity_by_aim(index, 150, velocity)
entity_set_vector(entity, EV_VEC_velocity, velocity)
entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.1)
return PLUGIN_HANDLED
}
public CoolEntity_Think(entity)
{
if (!IsInWorld(entity))
{
// Queue entity for deletion
// This is safier than removing the entity directly
entity_set_int(entity, EV_INT_flags, FL_KILLME)
entity_set_int(entity, EV_INT_effects, EF_NODRAW)
return
}
new Float:origin[3]
entity_get_vector(entity, EV_VEC_origin, origin)
static traceHandle
traceHandle = 0
engfunc(EngFunc_TraceMonsterHull, entity, origin, origin, DONT_IGNORE_MONSTERS, entity, traceHandle)
if (get_tr2(traceHandle, TR_StartSolid) || get_tr2(traceHandle, TR_AllSolid))
{
get_tr2(traceHandle, TR_vecEndPos, origin)
// Create an explosion here
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS)
write_coord_f(origin[0])
write_coord_f(origin[1])
write_coord_f(origin[2])
write_coord_f(origin[0])
write_coord_f(origin[1])
write_coord_f(origin[2] + 9999.0)
write_short(g_spriteIndexLaserBeam)
write_byte(0)
write_byte(0)
write_byte(100)
write_byte(20)
write_byte(0)
write_byte(255)
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(0)
message_end()
}
entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.1)
}