diff options
author | Neoministein <57015772+Neoministein@users.noreply.github.com> | 2023-06-24 00:42:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-24 00:42:12 +0200 |
commit | 68e34153fb72328d549aa362ff40dac467ce8f39 (patch) | |
tree | d6c42448e138a4fb09d1546a9b5c1179e168a56c | |
parent | 6ff307c15ef5c5797f5a0d2b2ed26ff4aa018ddd (diff) | |
download | NorthstarMods-68e34153fb72328d549aa362ff40dac467ce8f39.tar.gz NorthstarMods-68e34153fb72328d549aa362ff40dac467ce8f39.zip |
Add ability to disable executions via a Callback (#633)
-rw-r--r-- | Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut | 16 |
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 } |