AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   (OLD) Bug Reports (https://forums.alliedmods.net/forumdisplay.php?f=24)
-   -   [CSX] client_death reports wpnid as 0 when killed by bomb (https://forums.alliedmods.net/showthread.php?t=47157)

Geesu 11-11-2006 01:30

[CSX] client_death reports wpnid as 0 when killed by bomb
 
Shouldn't it return CSW_C4? If you are killed by the bomb in CS it says you were killed by weapon id 0.

Test code:
Code:
public client_death( killer,victim,wpnindex,hitplace,TK ) {     client_print( victim, print_chat, "[DEBUG] You were killed by %d with weapon %d", killer, wpnindex ); }

Result:
Quote:

[DEBUG] You were killed by 1 with weapon 0

Geesu 11-11-2006 01:44

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
Also, this is how i'm working around it:

Code:
// All we want to check is if the user was killed by the bomb public client_death( iAttacker, iVictim, iWeapon, hitplace, TK ) {     // Check out who the inflictor was     new iInflictor = entity_get_edict( iVictim, EV_ENT_dmg_inflictor );     // Check to see if the death was from the bomb     if ( 0 < iInflictor < MAXPLAYERS && iWeapon != CSW_HEGRENADE && iInflictor )     {                 if ( is_valid_ent ( iInflictor ) )         {             new szClassName[64];             entity_get_string( iInflictor, EV_SZ_classname, szClassName, 63 );             // Check the classname of our inflictor             if ( equali( szClassName, "grenade" ) || equali( szClassName, "env_explosion" ) )             {                 iWeapon = CSW_C4;                 iAttacker = 0;                 real_death_call( iVictim, iAttacker, iWeapon, 0 );             }         }     } }

VEN 11-12-2006 03:43

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
I believe in the older versions of CSX it returned CSW_C4. Though the planted C4 isn't actually a "weapon_c4" but a "grenade" which isn't a weapon. [edited]

BAILOPAN 11-12-2006 04:01

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
Indeed, when you are killed by C4, you are killed by a grenade.

However, the question is whether CSX should be abstracting past this or not.

VEN 11-12-2006 04:40

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
Currently, IIRC, the forward return HE grenade weapon index for HE grenade kill. So why it was made to not return CSW_C4 [cut]. Seems illogical to me.

In my opinion "abstracting" wouldn't make worse since players can't kill someone with actual "weapon_hegrenade" or "weapon_c4" anyway.

BAILOPAN 11-12-2006 05:00

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
I don't like that, and if I were to redo it (which I can't, for backwards compatibility), I would make it be consistent and return WEAPON_HEGRENADE.

That said, my thoughts: Encapsulating it to return CSW_C4 is a good idea. Saying you can't kill them with the "actual weapon" is semantics at best, implementation dependent at worst. What wpnindex should mean is "which weapon CAUSED death." By your logic, it should return the index of an M4A1 instead of WEAPON_M4A1, because it was actually a bullet that killed them ;)

As long as it doesn't break old code I don't mind making this change.

Geesu 11-12-2006 13:30

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
yay! BAIL ftw!

VEN 11-13-2006 09:35

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
I've made some testings and found that if you standing close to the center of the explosion it will return WID == 0 (dmg_inflictor has "env_explosion" classname). But if you are not close it will return CSW_C4 (dmg_inflictor's classname is "grenade" in this case). So the forward able to return CSW_C4 but not in the all cases.

But i personally would not use client_death forward anyway, at least because it's not called on user_kill native execution or on falldamage death.

Geesu 11-14-2006 14:43

Re: [CSX] client_death reports wpnid as 0 when killed by bomb
 
True, thats why you do the check like in my above example :)


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

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