11hook .Add (" PostGamemodeLoaded" , " WardenACFCompat" , function ()
2- if not ACF or not ACF .Permissions then return end
2+ if not ACF or not ACF .Permissions or not ACF . Damage then return end
33
44 local oldCanDamage = ACF .Permissions .CanDamage
55 function ACF .Permissions .CanDamage (ent , _ , dmgInfo )
@@ -12,12 +12,47 @@ hook.Add("PostGamemodeLoaded", "WardenACFCompat", function()
1212
1313 local attacker = dmgInfo :GetAttacker ()
1414 if not Warden .CheckPermission (attacker , ent , Warden .PERMISSION_DAMAGE ) then return false end
15- if not Warden .CheckPermission (attacker , ent , Warden .PERMISSION_GRAVGUN ) then return false end
1615
17- return true
16+ return oldCanDamage ( ent , nil , dmgInfo )
1817 end
1918
2019 hook .Add (" ACF_PreDamageEntity" , " ACF_DamagePermissionCore" , ACF .Permissions .CanDamage )
2120
21+ local doSquishyDamage = ACF .Damage .doSquishyDamage
22+
23+ local function isForcedSquishy (ent )
24+ local owner = ent :WardenGetOwner ()
25+ return IsValid (owner ) and owner :IsPlayer () and owner :GetInfoNum (" warden_acf_squishy_damage" , 1 ) ~= 0
26+ end
27+
28+ local function overrideOnDamage (self , ...)
29+ -- use the squishy damage handler instead of the entity's custom method
30+ if isForcedSquishy (self ) then
31+ return doSquishyDamage (self , ... )
32+ end
33+ return self :ACF_OldOnDamage (... )
34+ end
35+
36+ local oldCheck = ACF .Check
37+ function ACF .Check (ent , forceUpdate )
38+ local value = oldCheck (ent , forceUpdate )
39+ if value ~= false then
40+ if isForcedSquishy (ent ) then
41+ if ent .ACF_OnDamage and not ent .ACF_OldOnDamage then
42+ ent .ACF_OldOnDamage = ent .ACF_OnDamage
43+ ent .ACF_OnDamage = overrideOnDamage
44+ end
45+ -- tell ACF to treat this entity as squishy
46+ return " Squishy"
47+ else
48+ if ent .ACF_OldOnDamage then
49+ ent .ACF_OnDamage = ent .ACF_OldOnDamage
50+ ent .ACF_OldOnDamage = nil
51+ end
52+ end
53+ end
54+ return value
55+ end
56+
2257 SetGlobalBool (" WardenACF" , true )
2358end )
0 commit comments