Non-owner Twig additions are not removable

Currently, someone who isnt a friend of the base builder, can still build twig on their base.

Because of No Raid, this prevents the Owner from being able to remove or damage the Twig, requiring them to remove wood from their TC and decay the twig additions.

A fix needs to be in place that allows a base owner to delete or damage twig structures added to their base.

replace OnEntityTakeDamage with this:

private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo info)
{
    if (entity is BuildingBlock || entity.name.Contains("deploy") || entity.name.Contains("building"))
    {
        var player = info?.Initiator?.ToPlayer();

        if (!player || player.IsNpc || !entity.OwnerID.IsSteamId())
        {
            return null;
        }

        if (cFile.FriendBypass.Enabled)
        {
            // Owner checks
            if (cFile.FriendBypass.PlayerOwner.Enabled && player.userID == entity.OwnerID)
            {
                return null;
            }

            // NEW: Twig griefing protection via building ID match
            if (entity is BuildingBlock block && block.grade == BuildingGrade.Enum.Twigs)
            {
                var building = block.GetBuilding();
                if (building != null)
                {
                    foreach (var part in building.buildingBlocks)
                    {
                        if (part != null && part.OwnerID == player.userID && part.net.ID != block.net.ID)
                        {
                            // Player owns part of this structure, allow them to remove the twig
                            return null;
                        }
                    }
                }
            }

            // Friend checks
            if (Friends)
            {
                var hasFriend = Friends?.Call("HasFriend", entity.OwnerID.ToString(), player.UserIDString) ?? false;
                if (cFile.FriendBypass.FriendsApi.Enabled && (bool)hasFriend)
                {
                    return null;
                }
            }

            if (Clans)
            {
                var targetClan = (string)Clans?.Call("GetClanOf", entity.OwnerID.ToString());
                var playerClan = (string)Clans?.Call("GetClanOf", player.UserIDString);
                if (cFile.FriendBypass.RustIoClans.Enabled && playerClan != null && targetClan != null && targetClan == playerClan)
                {
                    return null;
                }
            }
        }

        // Prevents player from damaging after friendbypass checks
        if (cFile.StopAllRaiding)
        {
            PrintToChat(player, Lang("CantDamage", player.UserIDString));
            return true;
        }

        // No raid command checks
        if (!_canRaid)
        {
            PrintToChat(player, Lang("Cmd_CantRaid", player.UserIDString, GetFormattedTime((_cachedRaidTime.AddMinutes(_startMinutes)
                - DateTime.UtcNow).TotalSeconds)));
            return true;
        }

        // Wipe raid checks
        if (cFile.WipeRaiding.Enabled && !_canWipeRaid)
        {
            PrintToChat(player, Lang("Cmd_CantRaid", player.UserIDString, GetFormattedTime((_cachedWipeTime.AddMinutes(cFile.WipeRaiding.MinsFromWipe)
                - DateTime.UtcNow).TotalSeconds)));
            return true;
        }

        if (cFile.WipeRaiding.Enabled)
        {
            return null;
        }
    }
    return null;
}
 
=====
 
This checks a twigs structure owner id vs the base id its attached to.
If the twig is made by someone other than the owner, they can now damage it.
cheers

I simply use the AntiLadderandTwig mod.

im not installing another mod to make a mod work.

especially when I am capable of fixing it.

 

Though adding ladders is a good idea.



Merged post

Ryan has DMs disabled so I cant contact him.

Here is a version of NoRaid that allows you to damage Twig and Ladders added to your base.

NoRaid 1.3.3