Crafting block stopped working

Crafting block stopped working a few FP updates back.

Still get the chat notice that you are blocked, but crafting happens anyway.

Did you get any updates on this? I have a server admin having the same issue.

ItsNatoriousB

Did you get any updates on this? I have a server admin having the same issue.

Nope, nothing.

There could be a plugin conflict. Are you using anything that allows instant crafting?

For example, Bayonet and the HE Grenade Launcher does not cause combat block even with the following settings

  "Combat": {
    "Block": {
      "damageTypes": [
        "Bullet",
        "Arrow",
        "Blunt",
        "Stab",
        "Slash",
        "Explosion",
        "Heat",
        "ElectricShock",
        "Fun_Water"
      ],​

I've done some debugging and basically see that in the OnPlayerAttack attack hook, the weapon does not register the correct damage.  I confirmed this by printing the values of hitInfo.damageTypes.types in IsCombatDamage

01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0
01:17 [Info] [No Escape] dtList.types [index]: 0

@Wulf

NoEscape 2.1.34 Fix for CraftBlock not working.

XFe6ACa5EmrPqN3.png FuelStream

@Wulf

NoEscape 2.1.34 Fix for CraftBlock not working.

Any reason why the CUI anchors were changed?
Zr9sRBv2QugzuWI.jpg Wulf
Any reason why the CUI anchors were changed?

To clear them from the native rust info on the right.
They drown in crafting, tea boost, radiation etc.
Practical, but in the end just personal preference I guess.

I forgot that I changed the CUI anchors a while back, it should of course have been a clean copy with the fix that I uploaded.
Sorry about that.

cfW4FvI2Xu46kaA.png FuelStream

I forgot that I changed the CUI anchors a while back, it should of course have been a clean copy with the fix that I uploaded.
Sorry about that.

No worries, if it makes sense then might as well have it.

Why was my post moved into this thread?  Not sure it has been addressed, but my issue is with combat blocking not craft blocking.


Edit: Just confirmed it is still not working in game

whY0A0iqRewbrXU.jpg Wulf
No worries, if it makes sense then might as well have it.

New and old anchors.

tmBOcjw2H9Z18Jy.jpg HORRIBLEJUNGLER

Why was my post moved into this thread?  Not sure it has been addressed, but my issue is with combat blocking not craft blocking.

Edit: Just confirmed it is still not working in game

Here is an updated version with Melee and Explosives working.

@Wulf I'm not sure this should be Master as Steen said it's a botchy workaround to get things working, but it works.
I'm running it myself right now.

YZUY7naIpjGQewt.png FuelStream

Here is an updated version with Melee and Explosives working.

@Wulf I'm not sure this should be Master as Steen said it's a botchy workaround to get things working, but it works.
I'm running it myself right now.

Thanks, I'll test it out.  I do wonder why the OnPlayerAttack hook receives weapon info differently for meele/explosives still though.  Having to call OnPlayerAttack under certain conditions inside OnEntityTakeDamage seems like a workaround.  I'm still learning umod, but it seems like this indicates some bad logic/oversight in the code that fires the OnEntityTakeDamage hook.

Merged post

Looks like the fix works.  I have two problems with the version you gave me - the combat block was centered while the raid block was still on the right hand side of the screen.  I fixed that myself already so not that big of a deal.  The other is that the raid block timer gui does not refresh for anyone except the one who caused the combat block.  ex. Person 1 C4's wall.  Person 1 gets raid block and timer ticks down.  Person 2, owner of the entity gets raid block, timer is stuck at the initialized value and does not tick down.
tmBOcjw2H9Z18Jy.jpg HORRIBLEJUNGLER

Thanks, I'll test it out.  I do wonder why the OnPlayerAttack hook receives weapon info differently for meele/explosives still though.  Having to call OnPlayerAttack under certain conditions inside OnEntityTakeDamage seems like a workaround.  I'm still learning umod, but it seems like this indicates some bad logic/oversight in the code that fires the OnEntityTakeDamage hook.

Merged post

Looks like the fix works.  I have two problems with the version you gave me - the combat block was centered while the raid block was still on the right hand side of the screen.  I fixed that myself already so not that big of a deal.  The other is that the raid block timer gui does not refresh for anyone except the one who caused the combat block.  ex. Person 1 C4's wall.  Person 1 gets raid block and timer ticks down.  Person 2, owner of the entity gets raid block, timer is stuck at the initialized value and does not tick down.

Thanks for the info, I could have sworn I moved both CUI anchors, anything else would be stupid but I guess I didn't. xD
I don't use the raid block features at all, so only light raid testing was done with this version, sorry.
This version is kind of a mess of bandaids and quickies and the plug itself is unmaintained so hopefully, someone will come and rewrite some sections and give it the love it deserves.

Narrowed it down to a race condition at line 1417 in StartRaidBlocking(BasePlayer target, Vector3 position, bool createZone = true).  The null check assumes the call to Destroy on all "NoEscape" components completes before the next call to GetComponent.

            foreach (var comp in target.gameObject.GetComponents<Component>().ToList())
            {
                if (!(comp is CombatBlock) && comp.ToString().Contains("NoEscape"))
                {
                    UnityEngine.Object.Destroy(comp); // RaidBlock object found - destroy
                }
            }

            var raidBlocker = target.gameObject.GetComponent<RaidBlock>(); // Found to-be destroyed object
            if (raidBlocker == null) // Object is NOT null
            {
                raidBlocker = target.gameObject.AddComponent<RaidBlock>();
            }​
            // vvvvvv object gets deleted somewhere here, and becomes null after the null-check vvvvvv

Commenting the delete fixes it.  I see the code in StartCombatBlocking is similar but I don't experience the same problem.  I'm guessing it will work most of the time if the Component (Raid/CombatBlock) is early enough in the GetComponents list to allow enough time for the object to be destroyed.  



Merged post

After some more testing, I believe the best way to fix this is to just remove the GetComponent call after the delete for both Raid and Combat blocking and add a new component every time.

        void StartRaidBlocking(BasePlayer target, Vector3 position, bool createZone = true)
        {
            if (HasPerm(target.UserIDString, "disable"))
            {
                return;
            }

            if (target.gameObject == null)
            {
                return;
            }

            if (Interface.Call("CanRaidBlock", target, position, createZone) != null)
            {
                return;
            }

            if (target.gameObject == null)
                return;

            foreach (var comp in target.gameObject.GetComponents<Component>().ToList())
                if (!(comp is CombatBlock) && comp.ToString().Contains("NoEscape"))
                    UnityEngine.Object.Destroy(comp);

            var raidBlocker = target.gameObject.AddComponent<RaidBlock>();
/*          var raidBlocker = target.gameObject.GetComponent<RaidBlock>();
            if (raidBlocker == null)
            {
                raidBlocker = target.gameObject.AddComponent<RaidBlock>();
            }*/

            Interface.CallHook("OnRaidBlock", target, position);

            raidBlocker.lastBlock = DateTime.Now;

            if (raidBlockNotify)
                SendBlockMessage(target, raidBlocker, "Raid Block Notifier", "Raid Block Complete");

            if (useZoneManager && createZone && (zoneEnter || zoneLeave))
                CreateRaidZone(position);
        }

        void StartCombatBlocking(BasePlayer target)
        {
            if (HasPerm(target.UserIDString, "disable"))
            {
                return;
            }
            if (target.gameObject == null)
            {
                return;
            }

            if (Interface.Call("CanCombatBlock", target) != null)
            {
                return;
            }
            foreach (var comp in target.gameObject.GetComponents<Component>().ToList())
                if (!(comp is RaidBlock) && comp.ToString().Contains("NoEscape"))
                    UnityEngine.Object.Destroy(comp);

            var combatBlocker = target.gameObject.AddComponent<CombatBlock>();
/*          var combatBlocker = target.gameObject.GetComponent<CombatBlock>();
            if (combatBlocker == null)
            {
                combatBlocker = target.gameObject.AddComponent<CombatBlock>();
            }*/
            Interface.CallHook("OnCombatBlock", target);
            combatBlocker.lastBlock = DateTime.Now;

            if (combatBlockNotify)
                SendBlockMessage(target, combatBlocker, "Combat Block Notifier", "Combat Block Complete");
        }​