The pupose of this is to allow demomen in tfc to stick their remote pipebombs to players and walls, the bit im having trouble with is detaching the entity from the player when they die. I've tried entity_set_edict(pipebomb, EV_ENT_aiment,0) but that doesnt work :O
I thought about making the pipebomb just explode but when I remove the entity and create an explosion it messes up the demoman's pipe count (they can lay up to 8) and i don't really want to have to fiddle around with pdata aswell as working out the explosion radius so it matches :(
Code:
#include <amxmodx>
#include <engine>
public plugin_init()
{
register_plugin("stickypipes", "1.0", "watch")
register_cvar("tfc_stickypipes", "1")
register_event("DeathMsg", "death_event", "a")
register_touch("tf_gl_pipebomb", "*", "touch_pipebomb")
}
public touch_pipebomb(pipebomb, touch)
{
if (!get_cvar_num("tfc_stickypipes"))
return PLUGIN_CONTINUE
if(is_valid_ent(touch))
{
new classname[32]
entity_get_string(touch, EV_SZ_classname, classname, 31)
if(equal(classname, "player"))
{
// attach the pipebomb to the player
entity_set_int(pipebomb, EV_INT_movetype, MOVETYPE_FOLLOW)
entity_set_edict(pipebomb, EV_ENT_aiment, touch)
// remove the trail from the pipebomb
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(99)
write_short(pipebomb)
message_end()
return PLUGIN_CONTINUE
}
// if the touched entity is anything but an func_wall dont allow it to stick as the entity could move
if(!equal(classname, "func_wall"))
return PLUGIN_CONTINUE
}
// stick the pipebomb
entity_set_int(pipebomb, EV_INT_movetype, MOVETYPE_NONE)
return PLUGIN_CONTINUE
}
// if they die make the pipebomb fall off them otherwise it will just follow them back to spawn
public death_event()
{
if (!get_cvar_num("tfc_stickypipes"))
return PLUGIN_CONTINUE
new id = read_data(2)
new pipebomb = find_ent_by_class(-1, "tf_gl_pipebomb")
while(pipebomb > 0)
{
if(entity_get_edict(pipebomb, EV_ENT_aiment) == id)
{
// deattach the entity here
}
pipebomb = find_ent_by_class(pipebomb, "tf_gl_pipebomb")
}
return PLUGIN_CONTINUE
}
thanks :)
__________________