mirror of
https://github.com/R2Northstar/NorthstarMods
synced 2024-11-09 02:03:01 +01:00
Add weapon dropped callback
Adds a callback for when a weapon is dropped. In the progress this also fixes weapons still dropping unintentionally in certain case.
This commit is contained in:
parent
f2041fbb14
commit
51eb5eade9
@ -51,8 +51,6 @@ void function SvLoadoutsMP_Init()
|
||||
AddClientCommandCallback( "InGameMPMenuClosed", ClientCommandCallback_InGameMPMenuClosed )
|
||||
AddClientCommandCallback( "LoadoutMenuClosed", ClientCommandCallback_LoadoutMenuClosed )
|
||||
}
|
||||
|
||||
AddCallback_OnPlayerKilled( DestroyDroppedWeapon )
|
||||
}
|
||||
|
||||
void function SetLoadoutGracePeriodEnabled( bool enabled )
|
||||
@ -62,20 +60,10 @@ void function SetLoadoutGracePeriodEnabled( bool enabled )
|
||||
|
||||
void function SetWeaponDropsEnabled( bool enabled )
|
||||
{
|
||||
file.weaponDropsEnabled = enabled
|
||||
}
|
||||
|
||||
void function DestroyDroppedWeapon( entity victim, entity attacker, var damageInfo )
|
||||
{
|
||||
if ( !file.weaponDropsEnabled && IsValid( victim.GetActiveWeapon() ) )
|
||||
thread DelayDestroyDroppedWeapon( victim.GetActiveWeapon() )
|
||||
}
|
||||
|
||||
void function DelayDestroyDroppedWeapon( entity weapon )
|
||||
{
|
||||
WaitEndFrame()
|
||||
if ( IsValid( weapon ) )
|
||||
weapon.Destroy()
|
||||
if( enabled )
|
||||
FlagSet( "WeaponDropsAllowed" )
|
||||
else
|
||||
FlagClear( "WeaponDropsAllowed" )
|
||||
}
|
||||
|
||||
void function AddCallback_OnTryGetTitanLoadout( TryGetTitanLoadoutCallbackType callback )
|
||||
|
@ -43,6 +43,8 @@ void function BaseGametype_Init_MPSP()
|
||||
AddCallback_OnPlayerKilled( CheckForAutoTitanDeath )
|
||||
RegisterSignal( "PlayerRespawnStarted" )
|
||||
RegisterSignal( "KillCamOver" )
|
||||
|
||||
FlagInit( "WeaponDropsAllowed", true )
|
||||
}
|
||||
|
||||
void function SetIntermissionCamera( entity camera )
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user