@@ -3,67 +3,49 @@ hook.Add("InitPostEntity", "WardenACF1", function()
33
44 local oldCanDamage = ACF .Permissions .CanDamage
55 function ACF .Permissions .CanDamage (ent , _ , dmgInfo )
6- local perm = Warden .GetPermission (Warden .PERMISSION_ACF , true )
7- if not perm then return oldCanDamage (ent , nil , dmgInfo ) end
8-
9- local attacker = dmgInfo :GetAttacker ()
10-
11- if not perm :GetEnabled () then
12- if not oldCanDamage (ent , nil , dmgInfo ) then return false end
13- if not Warden .CheckPermission (attacker , ent , Warden .PERMISSION_DAMAGE ) then return false end
14- if not perm :GetDefault () then return false end
15-
16- return
17- end
18-
19- if ACF .EnableSafezones and ACF .Permissions .Safezones then
20- if ACF .Permissions .IsInSafezone (ent :GetPos ()) then return false end
21- if IsValid (attacker ) and ACF .Permissions .IsInSafezone (attacker :GetPos ()) then return false end
22- end
23-
24- if not Warden .CheckPermission (attacker , ent , Warden .PERMISSION_ACF ) then return false end
6+ if not oldCanDamage (ent , nil , dmgInfo ) then return false end
7+ if not Warden .CheckPermission (dmgInfo :GetAttacker (), ent , Warden .PERMISSION_DAMAGE ) then return false end
258 end
269
2710 hook .Add (" ACF_PreDamageEntity" , " ACF_DamagePermissionCore" , ACF .Permissions .CanDamage )
2811
29- local doSquishyDamage = ACF .Damage .doSquishyDamage
12+ local doSquishy
13+ local oldDealDamage = ACF .Damage .dealDamage
14+ function ACF .Damage .dealDamage (ent , dmgResult , dmgInfo )
15+ doSquishy = not Warden .CheckPermission (dmgInfo :GetAttacker (), ent , Warden .PERMISSION_ACF )
16+ local result = oldDealDamage (ent , dmgResult , dmgInfo )
17+ doSquishy = nil
3018
31- local function isForcedSquishy (ent )
32- local owner = ent :WardenGetOwner ()
33- if not IsValid (owner ) or not owner :IsPlayer () then return false end
34-
35- local squishy = owner :GetInfoNum (" warden_acf_squishy_damage" , - 1 )
36- if squishy < 0 then return Warden .GetServerBool (" acf_default_squishy_damage" , false ) end
37-
38- return squishy ~= 0
19+ return result
3920 end
4021
22+ local doSquishyDamage = ACF .Damage .doSquishyDamage
4123 local function overrideOnDamage (self , ...)
42- -- use the squishy damage handler instead of the entity's custom method
43- if isForcedSquishy (self ) then
24+ if doSquishy then
4425 return doSquishyDamage (self , ... )
4526 end
27+
4628 return self :ACF_OldOnDamage (... )
4729 end
4830
4931 local oldCheck = ACF .Check
5032 function ACF .Check (ent , forceUpdate )
5133 local value = oldCheck (ent , forceUpdate )
52- if value ~= false then
53- if isForcedSquishy (ent ) then
54- if ent .ACF_OnDamage and not ent .ACF_OldOnDamage then
55- ent .ACF_OldOnDamage = ent .ACF_OnDamage
56- ent .ACF_OnDamage = overrideOnDamage
57- end
34+ if not value then return value end
5835
59- -- tell ACF to treat this entity as squishy
60- return " Squishy"
61- else
62- if ent .ACF_OldOnDamage then
63- ent .ACF_OnDamage = ent .ACF_OldOnDamage
64- ent .ACF_OldOnDamage = nil
65- end
36+ if doSquishy then
37+ if ent .ACF_OnDamage and not ent .ACF_OldOnDamage then
38+ ent .ACF_OldOnDamage = ent .ACF_OnDamage
39+ ent .ACF_OnDamage = overrideOnDamage
6640 end
41+
42+ -- tell ACF to treat this entity as squishy
43+ return " Squishy"
44+ end
45+
46+ if ent .ACF_OldOnDamage then
47+ ent .ACF_OnDamage = ent .ACF_OldOnDamage
48+ ent .ACF_OldOnDamage = nil
6749 end
6850
6951 return value
0 commit comments