mirror of
https://github.com/R2Northstar/NorthstarMods
synced 2026-08-25 12:29:17 -04:00
Adds OnWeaponAttackCallbacks (#983)
* remove thread that breaks boosts * add OnWeaponAttack callbacks * add to file struct --------- Co-authored-by: cat_or_not <41955154+catornot@users.noreply.github.com>
This commit is contained in:
parent
94fabac8f9
commit
672a3f5fc9
1 changed files with 26 additions and 1 deletions
|
|
@ -25,6 +25,10 @@ global function CodeCallback_WeaponDropped
|
|||
global function AddCallback_OnWeaponDropped
|
||||
#endif
|
||||
|
||||
global function CodeCallback_OnWeaponAttack
|
||||
global function AddCallback_OnWeaponAttack
|
||||
global function RemoveCallback_OnWeaponAttack
|
||||
|
||||
struct AccumulatedDamageData
|
||||
{
|
||||
float accumulatedDamage
|
||||
|
|
@ -46,6 +50,7 @@ struct
|
|||
|
||||
table<entity, AccumulatedDamageData> playerAccumulatedDamageData
|
||||
array< void functionref( entity ) > weaponDroppedCallbacks
|
||||
array< void functionref( entity, entity, string, int ) > weaponAttackCallbacks
|
||||
} file
|
||||
|
||||
void function CodeCallback_Init()
|
||||
|
|
@ -1055,4 +1060,24 @@ void function CodeCallback_WeaponDropped( entity weapon )
|
|||
foreach( callback in file.weaponDroppedCallbacks )
|
||||
callback( weapon )
|
||||
}
|
||||
#endif // #if MP
|
||||
#endif // #if MP
|
||||
|
||||
void function AddCallback_OnWeaponAttack( void functionref( entity player, entity weapon, string weaponName, int attackIndex ) callbackFunc )
|
||||
{
|
||||
Assert( !file.weaponAttackCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddCallback_OnWeaponAttackCallback" )
|
||||
file.weaponAttackCallbacks.append( callbackFunc )
|
||||
}
|
||||
|
||||
void function RemoveCallback_OnWeaponAttack( void functionref( entity player, entity weapon, string weaponName, int attackIndex ) callbackFunc )
|
||||
{
|
||||
Assert( file.weaponAttackCallbacks.contains( callbackFunc ), "Tried to remove " + string( callbackFunc ) + " with RemoveCallback_OnWeaponAttackCallback but it was not found" )
|
||||
file.weaponAttackCallbacks.fastremovebyvalue( callbackFunc )
|
||||
}
|
||||
|
||||
void function CodeCallback_OnWeaponAttack(entity player, entity weapon, string weaponName,int shotsFired)
|
||||
{
|
||||
foreach ( callbackFunc in file.weaponAttackCallbacks )
|
||||
{
|
||||
callbackFunc( player, weapon, weaponName, shotsFired )
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue