aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/melee
diff options
context:
space:
mode:
authorNeoministein <57015772+Neoministein@users.noreply.github.com>2023-06-24 00:42:12 +0200
committerGitHub <noreply@github.com>2023-06-24 00:42:12 +0200
commit68e34153fb72328d549aa362ff40dac467ce8f39 (patch)
treed6c42448e138a4fb09d1546a9b5c1179e168a56c /Northstar.Custom/mod/scripts/vscripts/melee
parent6ff307c15ef5c5797f5a0d2b2ed26ff4aa018ddd (diff)
downloadNorthstarMods-68e34153fb72328d549aa362ff40dac467ce8f39.tar.gz
NorthstarMods-68e34153fb72328d549aa362ff40dac467ce8f39.zip
Add ability to disable executions via a Callback (#633)
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/melee')
-rw-r--r--Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut16
1 files changed, 15 insertions, 1 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut b/Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut
index dfd957e1..95ab3915 100644
--- a/Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut
+++ b/Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut
@@ -27,6 +27,7 @@ global function IsInExecutionMeleeState
global function GetLungeTargetForPlayer
global function Melee_IsAllowed
global function IsAttackerRef
+global function AddCallback_IsValidMeleeExecutionTarget
#if SERVER
global function Melee_Enable
@@ -88,7 +89,7 @@ struct
table<string, table<string,SyncedMeleeChooser> > syncedMeleeChoosers
table<SyncedMeleeChooser, array<void functionref( SyncedMeleeChooser actions, SyncedMelee action, entity player, entity target )> > syncedMeleeServerCallbacks
table<SyncedMeleeChooser, bool functionref( SyncedMelee action, entity player, entity target ) > syncedMeleeServerThink
-
+ array<bool functionref(entity attacker, entity target)> isValidMeleeExecutionTargetCallBacks
string lastExecutionUsed = ""
} file
@@ -183,6 +184,11 @@ vector function GetEyeOrigin( entity ent )
return ent.EyePosition()
}
+void function AddCallback_IsValidMeleeExecutionTarget( bool functionref( entity attacker, entity target ) callbackFunc )
+{
+ file.isValidMeleeExecutionTargetCallBacks.append( callbackFunc )
+}
+
//Called after pressing the melee button to recheck for targets
bool function CodeCallback_IsValidMeleeExecutionTarget( entity attacker, entity target )
{
@@ -310,6 +316,14 @@ bool function CodeCallback_IsValidMeleeExecutionTarget( entity attacker, entity
if ( !PlayerMelee_IsExecutionReachable( attacker, target, 0.3 ) )
return false
+ foreach ( callbackFunc in file.isValidMeleeExecutionTargetCallBacks )
+ {
+ if ( !callbackFunc( attacker, target ) )
+ {
+ return false
+ }
+ }
+
return true
}