mirror of
https://github.com/R2Northstar/NorthstarMods
synced 2024-11-12 05:27:40 +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( "InGameMPMenuClosed", ClientCommandCallback_InGameMPMenuClosed )
|
||||||
AddClientCommandCallback( "LoadoutMenuClosed", ClientCommandCallback_LoadoutMenuClosed )
|
AddClientCommandCallback( "LoadoutMenuClosed", ClientCommandCallback_LoadoutMenuClosed )
|
||||||
}
|
}
|
||||||
|
|
||||||
AddCallback_OnPlayerKilled( DestroyDroppedWeapon )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void function SetLoadoutGracePeriodEnabled( bool enabled )
|
void function SetLoadoutGracePeriodEnabled( bool enabled )
|
||||||
@ -62,20 +60,10 @@ void function SetLoadoutGracePeriodEnabled( bool enabled )
|
|||||||
|
|
||||||
void function SetWeaponDropsEnabled( bool enabled )
|
void function SetWeaponDropsEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
file.weaponDropsEnabled = enabled
|
if( enabled )
|
||||||
}
|
FlagSet( "WeaponDropsAllowed" )
|
||||||
|
else
|
||||||
void function DestroyDroppedWeapon( entity victim, entity attacker, var damageInfo )
|
FlagClear( "WeaponDropsAllowed" )
|
||||||
{
|
|
||||||
if ( !file.weaponDropsEnabled && IsValid( victim.GetActiveWeapon() ) )
|
|
||||||
thread DelayDestroyDroppedWeapon( victim.GetActiveWeapon() )
|
|
||||||
}
|
|
||||||
|
|
||||||
void function DelayDestroyDroppedWeapon( entity weapon )
|
|
||||||
{
|
|
||||||
WaitEndFrame()
|
|
||||||
if ( IsValid( weapon ) )
|
|
||||||
weapon.Destroy()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void function AddCallback_OnTryGetTitanLoadout( TryGetTitanLoadoutCallbackType callback )
|
void function AddCallback_OnTryGetTitanLoadout( TryGetTitanLoadoutCallbackType callback )
|
||||||
|
@ -43,6 +43,8 @@ void function BaseGametype_Init_MPSP()
|
|||||||
AddCallback_OnPlayerKilled( CheckForAutoTitanDeath )
|
AddCallback_OnPlayerKilled( CheckForAutoTitanDeath )
|
||||||
RegisterSignal( "PlayerRespawnStarted" )
|
RegisterSignal( "PlayerRespawnStarted" )
|
||||||
RegisterSignal( "KillCamOver" )
|
RegisterSignal( "KillCamOver" )
|
||||||
|
|
||||||
|
FlagInit( "WeaponDropsAllowed", true )
|
||||||
}
|
}
|
||||||
|
|
||||||
void function SetIntermissionCamera( entity camera )
|
void function SetIntermissionCamera( entity camera )
|
||||||
|
@ -18,6 +18,8 @@ global function CodeCallback_OnProjectileGrappled
|
|||||||
global function DamageInfo_ScaleDamage
|
global function DamageInfo_ScaleDamage
|
||||||
global function CodeCallback_CheckPassThroughAddsMods
|
global function CodeCallback_CheckPassThroughAddsMods
|
||||||
global function SetTitanMeterGainScale
|
global function SetTitanMeterGainScale
|
||||||
|
global function CodeCallback_WeaponDropped
|
||||||
|
global function AddCallback_OnWeaponDropped
|
||||||
|
|
||||||
#if MP
|
#if MP
|
||||||
global function CodeCallback_OnServerAnimEvent
|
global function CodeCallback_OnServerAnimEvent
|
||||||
@ -43,6 +45,7 @@ struct
|
|||||||
]
|
]
|
||||||
|
|
||||||
table<entity, AccumulatedDamageData> playerAccumulatedDamageData
|
table<entity, AccumulatedDamageData> playerAccumulatedDamageData
|
||||||
|
array< void functionref( entity ) > weaponDroppedCallbacks
|
||||||
} file
|
} file
|
||||||
|
|
||||||
void function CodeCallback_Init()
|
void function CodeCallback_Init()
|
||||||
@ -1030,4 +1033,26 @@ void function CodeCallback_OnServerAnimEvent( entity ent, string eventName )
|
|||||||
|
|
||||||
PerfEnd( PerfIndexServer.CB_OnServerAnimEvent )
|
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
|
#endif // #if MP
|
Loading…
Reference in New Issue
Block a user