AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   detaching an entity (https://forums.alliedmods.net/showthread.php?t=24523)

watch 02-25-2006 11:10

detaching an entity
 
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 :)

v3x 02-25-2006 12:26

Code:
entity_set_int(pipebomb, EV_INT_movetype, MOVETYPE_NONE); entity_set_edict(pipebomb, EV_ENT_aiment, 0); drop_to_floor(pipebomb);
Think that's how you'd do it ;]

If drop_to_floor doesn't work, try setting the verticle velocity to a negative number.


All times are GMT -4. The time now is 20:21.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.