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

Add crosshair target changed callback #893

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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: 20 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/client/cl_player.gnut
NachosChipeados marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ global function GetWaveSpawnTime
global function ServerCallback_HideNextSpawnMessage

global function ClientCodeCallback_OnHealthChanged

// Northstar
global function AddCallback_OnCrosshairCurrentTargetChanged
global function ClientCodeCallback_OnCrosshairCurrentTargetChanged
global function Pressed_TitanNextMode
global function ClientCodeCallback_OnGib
Expand Down Expand Up @@ -70,6 +73,9 @@ struct {
var law_missile_tracer = null
float nextSpawnTime = 0.0
entity lastEarnedReward // primarily used to check if we should still show the reward message after a delay

// Northstar
array< void functionref( entity, entity ) > OnCrosshairCurrentTargetChangedCallbacks
} file

struct BloodDecalParams
Expand Down Expand Up @@ -1515,6 +1521,14 @@ void function ClientCodeCallback_OnHealthChanged( entity ent, int oldHealth, int
ent.Signal( "HealthChanged", { oldHealth = oldHealth, newHealth = newHealth } )
}

// Northstar
void function AddCallback_OnCrosshairCurrentTargetChanged( void functionref( entity, entity ) callbackFunc )
{
Assert( !file.OnCrosshairCurrentTargetChangedCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddCallback_OnCrosshairCurrentTargetChanged" )

file.OnCrosshairCurrentTargetChangedCallbacks.append( callbackFunc )
}

void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player, entity newTarget )
{
if ( IsLobby() )
Expand All @@ -1524,6 +1538,12 @@ void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player,

if ( IsValid( newTarget ) )
TryOfferRodeoBatteryHint( newTarget )

// Northstar
foreach ( callback in file.OnCrosshairCurrentTargetChangedCallbacks )
{
callback( player, newTarget )
}
}

void function SetupPlayerAnimEvents( entity player )
Expand Down
28 changes: 28 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/client/cl_sp_player.gnut
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From which VPK is that vanilla file from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its in all sp vpks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, so ig it's the same in all of them? I'll check ig and then add it from one of them ^^

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ global function GetWaveSpawnTime
global function ServerCallback_HideNextSpawnMessage

global function ClientCodeCallback_OnHealthChanged

// Northstar
global function AddCallback_OnCrosshairCurrentTargetChanged
global function ClientCodeCallback_OnCrosshairCurrentTargetChanged

global function Pressed_TitanNextMode
global function ClientCodeCallback_OnGib
global function ClientPilotSpawned
Expand Down Expand Up @@ -59,6 +64,9 @@ struct {
var law_missile_tracer = null
float nextSpawnTime = 0.0
var UI_friendlyText

// Northstar
array< void functionref( entity, entity ) > OnCrosshairCurrentTargetChangedCallbacks
} file

struct BloodDecalParams
Expand Down Expand Up @@ -1261,6 +1269,26 @@ void function ClientCodeCallback_OnHealthChanged( entity ent, int oldHealth, int
ent.Signal( "HealthChanged", { oldHealth = oldHealth, newHealth = newHealth } )
}

// Northstar
void function AddCallback_OnCrosshairCurrentTargetChanged( void functionref( entity, entity ) callbackFunc )
{
Assert( !file.OnCrosshairCurrentTargetChangedCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddCallback_OnCrosshairCurrentTargetChanged" )

file.OnCrosshairCurrentTargetChangedCallbacks.append( callbackFunc )
}

void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player, entity newTarget )
{
if ( IsLobby() )
return;
if ( !IsValid( player ) )
return

foreach ( callback in file.OnCrosshairCurrentTargetChangedCallbacks )
{
callback( player, newTarget )
}
}

void function SetupPlayerAnimEvents( entity player )
{
Expand Down
Loading