diff options
author | NoCatt <86153630+NoCatt@users.noreply.github.com> | 2024-02-29 00:37:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 00:37:57 +0100 |
commit | 51eb5eade9aedd69b64a293e95c008a8a8d1f908 (patch) | |
tree | d6242fee4c3df52c0ee2a7402f1fafeb26daa9b8 /Northstar.CustomServers/mod/scripts/vscripts/mp | |
parent | f2041fbb144707e68c8c772d418479b6ac53bf07 (diff) | |
download | NorthstarMods-51eb5eade9aedd69b64a293e95c008a8a8d1f908.tar.gz NorthstarMods-51eb5eade9aedd69b64a293e95c008a8a8d1f908.zip |
Add weapon dropped callbackv1.24.3-rc2v1.24.3-rc1
Adds a callback for when a weapon is dropped.
In the progress this also fixes weapons still dropping unintentionally in certain case.
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut | 2 | ||||
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut index 9288f75e..b77a37b2 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype_mp.gnut @@ -43,6 +43,8 @@ void function BaseGametype_Init_MPSP() AddCallback_OnPlayerKilled( CheckForAutoTitanDeath ) RegisterSignal( "PlayerRespawnStarted" ) RegisterSignal( "KillCamOver" ) + + FlagInit( "WeaponDropsAllowed", true ) } void function SetIntermissionCamera( entity camera ) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut index ff281d6e..8644296e 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_codecallbacks.gnut @@ -18,6 +18,8 @@ global function CodeCallback_OnProjectileGrappled global function DamageInfo_ScaleDamage global function CodeCallback_CheckPassThroughAddsMods global function SetTitanMeterGainScale +global function CodeCallback_WeaponDropped +global function AddCallback_OnWeaponDropped #if MP global function CodeCallback_OnServerAnimEvent @@ -43,6 +45,7 @@ struct ] table<entity, AccumulatedDamageData> playerAccumulatedDamageData + array< void functionref( entity ) > weaponDroppedCallbacks } file void function CodeCallback_Init() @@ -1030,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 |