From 68e34153fb72328d549aa362ff40dac467ce8f39 Mon Sep 17 00:00:00 2001 From: Neoministein <57015772+Neoministein@users.noreply.github.com> Date: Sat, 24 Jun 2023 00:42:12 +0200 Subject: Add ability to disable executions via a Callback (#633) --- .../mod/scripts/vscripts/melee/sh_melee.gnut | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Northstar.Custom/mod') diff --git a/Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut b/Northstar.Custom/mod/scripts/vscripts/melee/sh_melee.gnut index dfd957e1d..95ab39158 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 > syncedMeleeChoosers table > syncedMeleeServerCallbacks table syncedMeleeServerThink - + array 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 } -- cgit v1.2.3