PDA

View Full Version : differences between DODW_ constants and death msg weaponids....


diamond-optic
12-04-2007, 03:11 PM
well i was doing some stuff with death messages and i noticed when using dod_get_user_weapon to get the players current weapon to print to the death msg that some weapons were not matching up..

and i went thru the death msg weapon values one by one and found them to be different then the DODW_ constants... here's what i came up with:

DODW_ constants (from dodconst.inc):
/* DoD weapons */ //passed id
enum {
DODW_AMERKNIFE = 1, // 1
DODW_GERKNIFE, // 2
DODW_COLT, // 3
DODW_LUGER, // 4
DODW_GARAND, // 5
DODW_SCOPED_KAR, // 6
DODW_THOMPSON, // 7
DODW_STG44, // 8
DODW_SPRINGFIELD, // 9
DODW_KAR, //10
DODW_BAR, //11
DODW_MP40, //12
DODW_HANDGRENADE, //13
DODW_STICKGRENADE, //14
DODW_STICKGRENADE_EX, //15
DODW_HANDGRENADE_EX, //16
DODW_MG42, //17
DODW_30_CAL, //18
DODW_SPADE, //19
DODW_M1_CARBINE, //20
DODW_MG34, //21
DODW_GREASEGUN, //22
DODW_FG42, //23
DODW_K43, //24
DODW_ENFIELD, //25
DODW_STEN, //26
DODW_BREN, //27
DODW_WEBLEY, //28
DODW_BAZOOKA, //29
DODW_PANZERSCHRECK, //30
DODW_PIAT, //31
DODW_SCOPED_FG42, //32
DODW_FOLDING_CARBINE, //33
DODW_KAR_BAYONET, //34
DODW_SCOPED_ENFIELD, //35
DODW_MILLS_BOMB, //36
DODW_BRITKNIFE, //37
DODW_GARAND_BUTT, //38
DODW_ENFIELD_BAYONET, //39
DODW_MORTAR, //40
DODW_K43_BUTT, //41
};and here's the death message weapon constants i came up with
/* DoD Death Message weapons */
enum {
DODDMW_AMERKNIFE = 1, // 1
DODDMW_GERKNIFE, // 2
DODDMW_COLT, // 3
DODDMW_LUGER, // 4
DODDMW_GARAND, // 5
DODDMW_SCOPED_KAR, // 6
DODDMW_THOMPSON, // 7
DODDMW_STG44, // 8
DODDMW_SPRINGFIELD, // 9
DODDMW_KAR, //10
DODDMW_BAR, //11
DODDMW_MP40, //12
DODDMW_HANDGRENADE, //13
DODDMW_STICKGRENADE, //14
DODDMW_STICKGRENADE_EX, //15
DODDMW_HANDGRENADE_EX, //16
DODDMW_MG42, //17
DODDMW_30_CAL, //18
DODDMW_SPADE, //19
DODDMW_M1_CARBINE, //20
DODDMW_MG34, //21
DODDMW_GREASEGUN, //22
DODDMW_FG42, //23
DODDMW_K43, //24
DODDMW_ENFIELD, //25
DODDMW_STEN, //26
DODDMW_BREN, //27
DODDMW_WEBLEY, //28
DODDMW_BAZOOKA, //29
DODDMW_PANZERSCHRECK, //30
DODDMW_PIAT, //31
DODDMW_MORTAR, //32
DODDMW_BINOCULARS, //33 (obviously never used)
DODDMW_SATCHEL, //34
DODDMW_SCOPED_FG42, //35
DODDMW_FOLDING_CARBINE, //36
DODDMW_KAR_BAYONET, //37
DODDMW_SCOPED_ENFIELD, //38
DODDMW_MILLS_BOMB, //39
DODDMW_BRITKNIFE, //40
DODDMW_MORTAR_UNKNOWN, //41 (couldnt find any instance of this actually being used)
DODDMW_GARAND_BUTT, //42 (also used for k43 buttstock)
DODDMW_ENFIELD_BAYONET //43
};you'll notice some big differences (like death msg ids for binoculars, satchels.. two mortars (one of which i couldnt find actually being used by the game anywhere) and the garand_butt is used for both garand & k43 buttstock kills

ive got a lot more testing to do.. but im wondering if maybe the DODW_ constants might be wrong.. or if its another stupid way dod is written where the weapon ids dont match.. cause its causing a shit load of problems when trying to make a death msg with a players current in-hand weapon.. unless its not supposed to match.. lol

for example.. if they are holding a british knife.. and you pass that id (from dod_get_user_weapon) to a death msg, it shows up as a bayonet..

but its kinda hard to test all the DODW_ constants, cause you cant exactly be holding a bayonet or a mortar to check those IDs... but when i get a chance later im gonna check out the weapon ids used in the death forward (common sense is telling me they should match the death msg weapon ids not the DODW_ constant ids)

tho in anycase.. im sure a stock could probably be made to convert the DODW_ constant ids over to the proper death message weapon ids

** on a side note, i noticed with the DODW_ constants, that the DODW_MILLS_BOMB doesnt seem to be used (at least anywhere ive seen so far).. it always comes up as a HANDGRENADE (or with the _EX on the end for a live nade thats been picked back up) so im assuming its no different whether its US or british for the nades and the map info determines what model is shown... **


anyway anyone else notice this? as im sure this *might* cause some problems with plugins that are using these things.. but ill post when once i have some more information.. and depending what i can come up with i might put in a bug report on the amxx site to at least get the death message weapon ids added to the dodconst.inc file

Wilson [29th ID]
12-04-2007, 03:43 PM
Can you ellaborate on the specific problems that are actually being caused?

The British knife problem is pretty easily explained:
Both the british knife and british mills bomb are actually the american knife/handgrenade entities, but they look like the british ones.

Remember that stock that converts an Enfield to Scoped and an FG42 to scoped? I'm pretty sure the same pdata offset will convert the American Knife to British and the american grenade to a british mills bomb. I'm pretty sure I've actually tried that - it's just been a while.

None the less, I'm sure you know that if you do a get_user_weapon() on a bloke who's holding a british knife, it will return DODW_AMERKNIFE and on a mills bomb return DODW_HANDGRENADE.

So essentially, you can ignore the british knife and mills bomb constants. If you have to create a death message, you can test if the map is british first.

Apart from the British bit, what is the problem?

The m1 folding carbine works the same way - as you can see it's replaced by the regular carbine except in para maps. I would be the same pdata offset is used for its conversion there too.

My guess would be that the DOD team originally had separate entities for the Handgrenade, Millsbomb, Amerknife, Britknife, Enfield, Scoped Enfield, FG42, Scoped FG42, M1Carbine, and Folding M1 Carbine...but then realised they could just incorporate the differences into a pdata toggle and "save space" or something.

Obviously the constant lists are not 100% accurate to each other...but my main question is where is the problem?

diamond-optic
12-04-2007, 04:03 PM
well the nade stuff isnt my main concern..

say you want to create a death msg with a players current weapon..

.. lets say they are holding the british knife, so you do dod_get_user_weapon on them to get the weapon id, which returns 37 (or DODW_BRITKNIFE)

then you create the death msg and pass the id you got from dod_get_user_weapon as the weapon value (3rd argument in the message).. the death msg shows the weapon as a kar bayonet (and says bayonet in the console) ..to get the british knife to actually show up in the death message, you have to use 40, not 37...

..i guess its probably supposed to be that way... but to me it seems like it could cause all sorts of problems when trying to create death messages using weapon ids that you get thru some other method.. as you would have to compensate for some IDs equaling one weapon when using them for one thing, then equaling a different weapon when passing thru a death msg


but im thinking.. if the death message weapon ids get added to the dodconst.inc and i say write up a real simple stock to convert DODW_ constant IDs into death message IDs then it shouldnt really be a problem i guess, especially as it seems only some of the ids are different, so most of them you wouldnt need to touch

(and since there is no dod stocks include file, maybe we could get some of the other useful dod stocks that are posted in various places on the boards into one)

Wilson [29th ID]
12-04-2007, 11:48 PM
I'm very shocked to hear that dod_get_user_weapon() returns DODW_BRITKNIFE..are you sure about that?

I'd be willing to bet that if you use regular core's get_user_weapon() it will return DODW_AMERKNIFE

Try that and see. You can also check pdata offset 90 which I believe is the weapon id.

diamond-optic
12-05-2007, 01:12 AM
doing this:

new ammo, clip, zGun = dod_get_user_weapon(id,clip,ammo)
client_print(0,print_chat,"in hand weapon: %d",zGun)prints 37 (DODW_AMERKNIFE is 1)

also tried it with the core get_user_weapon and its no different

Wilson [29th ID]
12-05-2007, 05:04 AM
Ah - now I know what I was thinking of.

If you get the entity name instead of get_user_weapon(), it will return weapon_amerknife instead of weapon_britknife.

Zor
12-12-2007, 09:50 AM
I thought I added those to the stock file...must not have come up the chain yet...will look into it later on!

Cheers!

Vet
05-20-2008, 06:37 PM
This is what I've been using to GET the proper weapon from DeathMsg.
I suppose it'd be to opposite when writing a DeathMsg.

register_event("DeathMsg", "event_death", "a")

public event_death()
{
static killer, victim, wpnindex
killer = read_data(1)
victim = read_data(2)
wpnindex = DM_wpnindex(killer, read_data(3))
...

stock DM_wpnindex(id, wpn) { // correct wpnindex value from DOD DeathMsg event
switch (wpn) {
case 32:
wpn = DODW_MORTAR
case 33, 34, 41:
wpn = 0 // NA - use world kill
case 35..40:
wpn -= 3
case 42:
wpn = get_user_team(id) == 1 ? DODW_GARAND_BUTT : DODW_K43_BUTT
case 43:
wpn = DODW_ENFIELD_BAYONET
}
return wpn
}

diamond-optic
05-21-2008, 04:45 AM
sorta old and should probably be changed from if statements to a switch and only use the final return... but anyway this does the reverse :)

http://www.dodplugins.net/forums/showpost.php?p=8500&postcount=4


...and one thing with yours is with this:
wpn = get_user_team(id) == 1 ? DODW_GARAND_BUTT : DODW_K43_BUTTit would return the wrong weapon if youre using the enemy's gun

Vet
05-22-2008, 01:54 AM
Ah, good catch. I never thought about that.

Vet
05-23-2008, 11:59 PM
Changing case 42 to this seems to work OK.

...
case 42:
wpn = pev(id, pev_weapons) & (1 << DODW_GARAND) ? DODW_GARAND_BUTT : DODW_K43_BUTT
...