AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Determine a grenades origin at explosion AND the owner (https://forums.alliedmods.net/showthread.php?t=25228)

Geesu 03-10-2006 12:18

Determine a grenades origin at explosion AND the owner
 
Is this possible?

I want to determine the origin of where the grenade explodes, but I also want to determine the owner and how much damage it dealt.

I could catch the effect that is thrown when it explodes, but then I can't query that ent ID (to get the owner) b/c it will have been destroyed.

Any ideas?

Thanks,
Josh

VEN 03-10-2006 13:09

I do not see any problem here.
AFAIR, grenade entity exist at explosion.
I believe all what you asked is possible.

Brad 03-10-2006 13:18

VEN: While he did only ask if it was possible, I think he was really asking how he would go about doing it.

v3x 03-10-2006 13:51

Maybe hook the explosion sound with FM_EmitSound? Dunno :o

Geesu 03-10-2006 16:14

Well one thing I just thought of... The damage event also passes coords so that arrows can be drawn on the screen and indicate to the player which direction the damage came from.

I wonder if that coord would be the origin of the grenade explosion... I'm going to test this :P

Kraugh 03-10-2006 20:15

counter-strike grenades are a mystery!

Code:
public plugin_init() {    register_think("grenade","think_grenade"); } public think_grenade(ent) {    new hack = get_pdata_int(ent,118);    new oldhack = entity_get_int(ent,EV_INT_iuser1);    if(hack && !oldhack) {       // here comes explosion    }    entity_set_int(ent,EV_INT_iuser1,hack); }

you'll have to filter out c4 from this (they are considered grenades), but other than that it should alert one "think" (< 0.1 second) before a grenade explodes. you should also be able to grab EV_ENT_owner as usual.

Geesu 03-10-2006 22:58

Thanks, that will occur before the on_damage event right?

Also, how would I link the amount of damage done back to that function?

Kraugh 03-10-2006 23:04

it will occur before damage. you can't tell how much damage is done, all this does is hook right before the grenade explodes. offset 118 changes from 0 to 1 the think prior to explosion.

VEN 03-11-2006 07:35

I believe that better catch the explosion sound as v3x said, because it indicates exact the moment of explosion.

Kraugh's method seems less precise since grenades thinks not instantly but with something like 0.1sec delay.

Here is grenades explosion sound list:
Code:

HE Grenade
  weapons/debris1.wav
  weapons/debris2.wav
  weapons/debris3.wav

Flashbang
  weapons/flashbang-1.wav
  weapons/flashbang-2.wav

Smoke Grenade
  weapons/sg_explode.wav


knekter 03-11-2006 09:51

Code:
register_message(23, "grenade_explosion"); public grenade_explosion() {     if(get_msg_arg_int(1) == 3 && get_msg_arg_int (6) == 25 && get_msg_arg_int (7) == 30)     {         new Float:pos[3];         pos[0] = get_msg_arg_float(2);         pos[1] = get_msg_arg_float(3);         pos[2] = get_msg_arg_float(4);         // Code...     } }


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

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