PDA

View Full Version : DoD Stocks


Wilson [29th ID]
12-21-2007, 12:29 AM
These are stocks that have come in quite handy and will hopefully be implemented into the DoDx module eventually.

Until then, feel free to use them and post up some others that you have created.


// Returns entity name of provided wpnid
// Will pass the weaponname into the 2nd argument
stock dod_get_weapon_name( wpnid, weaponname[], len )

// Returns entity number of the client's weapon
// Provide *either* wpnid (ie. DODW_GARAND) *or* weaponname (ie. "weapon_garand")
stock dod_get_weapon_ent( id, wpnid=0, weaponname[] = "" )

// Returns DODW_ id of the weapon entity provided
stock dod_get_weapon_id( wpnent )

// Special Scoped Weapons (ie. FG42, Enfield) are not their own weapon entities
// but use the entities of similar weapons and this offset to distinguish
// Returns whether or not the weapon is set to special
// Provide *either* wpnid (ie. DODW_GARAND) *or* weaponname (ie. "weapon_garand")
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock dod_scoped_weapon( id, wpnid, weaponname[] = "", set = -1 )

// Gets or Sets the prone state of the client
// Values: 0=Not Proned, 1=Proned, 2=Proned and Deployed
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock dod_prone_state( id, set = -1 )

// Gets or Sets whether or not the current weapon (ie. Rocket) is shouldered
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock dod_shouldered( id, set = -1 )

// Returns whether or not the provided wpnid is a deployable weapon
stock dod_is_deployable( wpnid )

// Gets or Sets the client's deploy state
// Values: 0=Not Deployed, 1=Deployable, 2=Deployed
// Only use the set param (value of 2, 1 or 0) to set this offset; ignore it to "get"
// the current value
stock dod_deploy_state( id, set = -1 )

// Gets or Sets client's current stamina
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock Float:dod_stamina( id, Float:set = -1.0 )

// Gets or Sets the fuse on a grenade entity
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock Float:dod_fuse( grenindex, Float:set = -1.0 )

// Tests if client has cl_autoreload enabled - Or sets it for them
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock dod_autoreload( id, set = -1 )

// by diamond-optic (12.24.07)
// converts weapon ids (from dod_get_user_weapon for example)
// into the ids used for those weapons in death messages
stock dod_weaponid_to_deathmsgid( weaponid )

// Provided simply for convenience/logic
stock dod_is_map_british()

diamond-optic
12-23-2007, 04:57 AM
just a reminder.. if this gets included with amxx (which it should) zor needs to add #include <dod_stocks> to the dodx.inc and dodfun.inc


:-)

Wilson [29th ID]
12-23-2007, 10:36 AM
Most of these could be incorporated into the module, which would be even better.

diamond-optic
12-24-2007, 08:22 PM
////////////////////////////////////////////////////////////////////
// by diamond-optic (12.24.07)
//
// converts weapon ids (from dod_get_user_weapon for example)
// into the ids used for those weapons in death messages
//
stock dod_weaponid_to_deathmsgid(weaponid)
{
if(weaponid > 31 && weaponid < 38)
return weaponid+3
else if(weaponid == 38 || weaponid == 41)
return 42
else if(weaponid == 39)
return 43
else if(weaponid == 40)
return 32

return weaponid
}

Wilson [29th ID]
01-03-2008, 01:50 PM
// Only use the set param (value of 1 or 0) to set this offset; ignore it to "get"
// the current value
stock Float:dod_fuse( grenindex, Float:set = -1.0 ) {
new Float:gametime = get_gametime();
if( set > -1.0 ) set_pev( grenindex, pev_dmgtime, gametime + set );
return pev( grenindex, pev_dmgtime ) - gametime;
}


This is a much more "to the point" way than the dodfun module's way.

I've got a few other new ones too - I'll update this thread very shortly.

Wilson [29th ID]
04-06-2008, 12:42 PM
Updated 06 APR 2008. Lots of new stuff.

diamond-optic
04-13-2008, 10:23 PM
here's one i just threw together today while doing some long overdue work on my gore plugin.. pass it an id and a hitplace value and it will return the origin (integer) of the bone for that hitplace.

And im pretty sure the bone values are correct, or at least they seem correct enough lol.. But they arent always perfect, since its the half life engine, the origin of a bone might not be exactly where the player models is visible at (as in shooting a leg on a running player will sometimes show the 'origin' as being a little infront of the leg or behind etc etc..)


useful for calling in damage/death forwards (passing victim & hitplace)

stock get_hitplace_origin(id,hitplace)
{
new Float:fOrigin[3],Float:angles[3],hitOrigin[3]

switch(hitplace)
{
case HIT_HEAD: hitplace = 19
case HIT_CHEST: hitplace = 11
case HIT_LEFTARM: hitplace = 15
case HIT_RIGHTARM: hitplace = 18
case HIT_STOMACH: hitplace = 9
case HIT_GENERIC: hitplace = 10
case HIT_LEFTLEG: hitplace = 3
case HIT_RIGHTLEG: hitplace = 6
}

engfunc(EngFunc_GetBonePosition,id,hitplace,fOrigi n,angles)

hitOrigin[0] = floatround(fOrigin[0])
hitOrigin[1] = floatround(fOrigin[1])
hitOrigin[2] = floatround(fOrigin[2])

return hitOrigin
}