FireBullets(): Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
'''<code>FireBullets()</code>''' is a method which handles damage for any [[hitscan]] weapon. It is passed [[FireBulletsInfo_t]] as it's required parameter, which describes the bullet in question. | '''<code>FireBullets()</code>''' is a method which handles damage for any [[hitscan]] weapon. It is passed [[FireBulletsInfo_t]] as it's required parameter, which describes the bullet in question. | ||
== | == Members == | ||
'''<code>info</code>''' | '''<code>info</code>''' | ||
Line 14: | Line 14: | ||
'''<code>iPlayerDamage</code>''' | '''<code>iPlayerDamage</code>''' | ||
:If it's deemed we are damaging a player, this is used instead of <code>flActualDamage</code> | :If it's deemed we are damaging a player, this is used instead of <code>flActualDamage</code> | ||
'''<code>tr</code>''' | |||
:<code>[[TraceLine]]</code> used when the weapon fired. <code>tr.m_pEnt</code> is the entity that was intersected e.g. NPC, crate, wall. | |||
== Damage == | |||
This is the core function where the damage is done to the entity. <code>DispatchTraceAttack</code> is passed <code>dmgInfo</code> which contains the attacker, damage value and damage type. | |||
CTakeDamageInfo dmgInfo( this, pAttacker, flActualDamage, nActualDamageType ); | |||
CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, vecDir, tr.endpos ); | |||
dmgInfo.ScaleDamageForce( info.m_flDamageForceScale ); | |||
dmgInfo.SetAmmoType( info.m_iAmmoType ); | |||
tr.m_pEnt->DispatchTraceAttack( dmgInfo, vecDir, &tr ); | |||
== See also == | |||
* [[AmmoDef]] | |||
* <code>[[FireBulletsInfo t]]</code> | |||
* <code>[[TraceLine]]</code> | |||
[[Category:Weapons programming]] |
Revision as of 16:23, 12 February 2010
FireBullets()
is a method which handles damage for any hitscan weapon. It is passed FireBulletsInfo_t as it's required parameter, which describes the bullet in question.
Members
info
- Name given to the
FireBulletsInfo
struct that is passed into method.
pAmmoDef
- Stores the ammo definition in a pointer.
flActualDamage
- Used to define the damage to be done to entity.
iPlayerDamage
- If it's deemed we are damaging a player, this is used instead of
flActualDamage
tr
TraceLine
used when the weapon fired.tr.m_pEnt
is the entity that was intersected e.g. NPC, crate, wall.
Damage
This is the core function where the damage is done to the entity. DispatchTraceAttack
is passed dmgInfo
which contains the attacker, damage value and damage type.
CTakeDamageInfo dmgInfo( this, pAttacker, flActualDamage, nActualDamageType ); CalculateBulletDamageForce( &dmgInfo, info.m_iAmmoType, vecDir, tr.endpos ); dmgInfo.ScaleDamageForce( info.m_flDamageForceScale ); dmgInfo.SetAmmoType( info.m_iAmmoType ); tr.m_pEnt->DispatchTraceAttack( dmgInfo, vecDir, &tr );