Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weapon drop callback + Fix for weapons still dropping #692

Merged
merged 20 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions Northstar.CustomServers/mod/scripts/vscripts/_loadouts_mp.gnut
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ void function SvLoadoutsMP_Init()
AddClientCommandCallback( "InGameMPMenuClosed", ClientCommandCallback_InGameMPMenuClosed )
AddClientCommandCallback( "LoadoutMenuClosed", ClientCommandCallback_LoadoutMenuClosed )
}

AddCallback_OnPlayerKilled( DestroyDroppedWeapon )
}

void function SetLoadoutGracePeriodEnabled( bool enabled )
Expand All @@ -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")
NoCatt marked this conversation as resolved.
Show resolved Hide resolved
NoCatt marked this conversation as resolved.
Show resolved Hide resolved
else
FlagClear("WeaponDropsAllowed")
NoCatt marked this conversation as resolved.
Show resolved Hide resolved
}

void function AddCallback_OnTryGetTitanLoadout( TryGetTitanLoadoutCallbackType callback )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void function BaseGametype_Init_MPSP()
AddCallback_OnPlayerKilled( CheckForAutoTitanDeath )
RegisterSignal( "PlayerRespawnStarted" )
RegisterSignal( "KillCamOver" )

FlagInit( "WeaponDropsAllowed", true )
}

void function SetIntermissionCamera( entity camera )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +45,7 @@ struct
]

table<entity, AccumulatedDamageData> playerAccumulatedDamageData
array< void functionref( entity ) > weaponDroppedCallbacks
} file

void function CodeCallback_Init()
Expand Down Expand Up @@ -1030,4 +1033,25 @@ 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
NoCatt marked this conversation as resolved.
Show resolved Hide resolved
if ( !IsValid( weapon ) )
return
//Might look a bit hacky to put it here, but thats how SP does it
NoCatt marked this conversation as resolved.
Show resolved Hide resolved
if ( !Flag( "WeaponDropsAllowed" ) )
{
weapon.Destroy()
return
}

foreach( callback in file.weaponDroppedCallbacks )
callback( weapon )
}
#endif // #if MP