Raised This Month: $ Target: $400
 0% 

Register entity removing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 03-13-2006 , 00:55   Register entity removing
Reply With Quote #1

How would I register when an entity is removed / deleted? Or even when an entity takes damage. (not a player). register_event apparently does not work for entities, just players.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-13-2006 , 01:30  
Reply With Quote #2

register_event works for what the mod uses it for.

You can tell when an entity is removed by hooking FM.
Taking damage cannot be done through current hookings.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
VEN
Veteran Member
Join Date: Jan 2005
Old 03-13-2006 , 04:41  
Reply With Quote #3

Is it for bugs?
If so read http://forums.alliedmods.net/showthread.php?t=25365
It's possible to catch emitted sounds when func_breakable entity takes damage.
You have only check if entity is visible then it's still not "dead" and if EF_NODRAW is set then entity "destroyed".

Also FM note: you can't catch removing of some entities like weaponbox etc.
VEN is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-13-2006 , 15:45  
Reply With Quote #4

That is because they are removed internally.

In theory, you can simply check to see if they still exist each and every server frame, but that would be silly.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 03-13-2006 , 16:38  
Reply With Quote #5

exactly what I am trying to avoid, setting 50 tasks every 1.0 second to see if they died.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
T(+)rget
Senior Member
Join Date: Mar 2004
Old 03-13-2006 , 17:42  
Reply With Quote #6

Why don't you hook pfnThink?

Then check the damage when its thinking, none done set the think inside itself of 0.1 or something, else create effects and remove the entity.

Note on Creation:
entity_set_float(entity, EV_FL_takedamage, DAMAGE_YES)
entity_set_float(entity, EV_FL_health, 10000.0)
entity_set_float(entity, EV_FL_nextthink, get_gametime() + 0.1) // starts your entity thinking

I give a ridiculous amount of HP because if it hits <= 0 then the entity will auto-remove by the engine
T(+)rget is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-13-2006 , 18:32  
Reply With Quote #7

Not all entities can be hooked using PFN think.

set tasks are inappropriate for this. A thinking entity is much much less laggy. I'd look into it.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 03-13-2006 , 18:33  
Reply With Quote #8

*looking into it*
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
VEN
Veteran Member
Join Date: Jan 2005
Old 03-14-2006 , 02:42  
Reply With Quote #9

As i said before make entity as func_breakable and check for it's EF_NODRAW flag every emit_sound. Register tasks/thinks unnecessarily in my opinion.
And not all entities removes at health <= 0, func_breakable entity is one of the examples.
VEN is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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