diff options
author | GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> | 2024-08-14 17:31:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 17:31:06 +0200 |
commit | fa4e319c0b60cd68a3dccaa4322e3c35cfa1e385 (patch) | |
tree | 4a78391c5008a4aa50d81fbca5d9f26bb475cd96 /Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut | |
parent | bcec5a5e9edd2a2af3a017ea4b250a9ba1112e6f (diff) | |
parent | 7aa3958ccd8e32970736654dfae0c7a87f0798bb (diff) | |
download | NorthstarMods-fa4e319c0b60cd68a3dccaa4322e3c35cfa1e385.tar.gz NorthstarMods-fa4e319c0b60cd68a3dccaa4322e3c35cfa1e385.zip |
Merge branch 'main' into permanent-amped-weapons-fix-pr
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut index 425a8b8b..0d1b42b7 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut @@ -21,6 +21,8 @@ global function SetTitanMeterGainScale #if MP global function CodeCallback_OnServerAnimEvent +global function CodeCallback_WeaponDropped +global function AddCallback_OnWeaponDropped #endif struct AccumulatedDamageData @@ -43,6 +45,7 @@ struct ] table<entity, AccumulatedDamageData> playerAccumulatedDamageData + array< void functionref( entity ) > weaponDroppedCallbacks } file void function CodeCallback_Init() @@ -283,12 +286,26 @@ void function CodeCallback_DamagePlayerOrNPC( entity ent, var damageInfo ) return RunClassDamageFinalCallbacks( ent, damageInfo ) + #if VERBOSE_DAMAGE_PRINTOUTS printt( " after class damage final callbacks:", DamageInfo_GetDamage( damageInfo ) ) #endif if ( DamageInfo_GetDamage( damageInfo ) == 0 ) return + // Added via AddEntityCallback_OnFinalDamaged + foreach ( callbackFunc in ent.e.entFinalDamageCallbacks ) + { + callbackFunc( ent, damageInfo ) + } + + #if VERBOSE_DAMAGE_PRINTOUTS + printt( " afterAddEntityCallback_OnFinalDamaged callbacks:", DamageInfo_GetDamage( damageInfo ) ) + #endif + + if ( DamageInfo_GetDamage( damageInfo ) == 0 ) + return + if ( DamageInfo_GetCustomDamageType( damageInfo ) & DF_DOOMED_HEALTH_LOSS ) DamageInfo_AddDamageFlags( damageInfo, DAMAGEFLAG_NOPAIN ) @@ -1016,4 +1033,26 @@ void function CodeCallback_OnServerAnimEvent( entity ent, string eventName ) PerfEnd( PerfIndexServer.CB_OnServerAnimEvent ) } + +void function AddCallback_OnWeaponDropped( void functionref( entity ) callback ) +{ + file.weaponDroppedCallbacks.append( callback ) +} + +void function CodeCallback_WeaponDropped( entity weapon ) +{ + // shamelessly taken form SP + if ( !IsValid( weapon ) ) + return + + // Might look a bit hacky to put it here, but thats how SP does it + if ( !Flag( "WeaponDropsAllowed" ) ) + { + weapon.Destroy() + return + } + + foreach( callback in file.weaponDroppedCallbacks ) + callback( weapon ) +} #endif // #if MP
\ No newline at end of file |