Jump to content

Locked boxes can't be broken on PVE

Closed 0.5.0 0.5.1

Cargonia
Cargonia

Posted

I love the addition of the option to lock the deployed boxes. Unfortunately it seems the boxes are not breakable on PVE. This is caused by the TruePVE plugin and its "LockedBoxesImmortal" flag. 

There is a fix though, if you add this code in after line 3012:

private void OnCollectiblePickedup(CollectibleEntity collectible, CustomPet customPet, Item item)
{
	if (customPet) customPet.CustomBrain.OnCollectiblePickedup(item);
}

// start new code
private object CanEntityTakeDamage(BaseEntity entity, HitInfo info)
{
  if (entity is StorageContainer && info?.InitiatorPlayer != null
      && !(info.InitiatorPlayer is CustomPet)
      && PluginEntityComponent.TryGetComponent<DropContainer>(entity, out _))
    return true;
  return null;
}
// end new code

#endregion

When any entity takes damage, this hook checks if:

  1. The target is a StorageContainer (cheap type check, skips 99%+ of calls early)
  2. The damage source is a real player (not decay, fire, animals, heli, etc.)
  3. The player is not a CustomPet bot (prevents bots destroying their own boxes)
  4. The entity has a DropContainer component (confirming it's an NPC-deployed container)

If all conditions pass, it returns true, which tells TruePVE to allow the damage — bypassing the immortal flag. Player-owned locked boxes remain fully protected.

I have tested this on my server and it seems to work. If you don't see any issues on the plugin's side with this, I would love if this could be added.

walkinrey

Posted

Changed Status from Pending to Work in Progress

walkinrey

Posted

Changed Status from Work in Progress to Closed

Changed Fixed In to Next Version

About Us

Codefling is the largest marketplace for plugins, maps, tools, and more, making it easy for customers to discover new content and for creators to monetize their work.

Downloads
2.4m
Total downloads
Customers
10.9k
Customers served
Files Sold
156.8k
Marketplace sales
Payments
3.4m
Processed total
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.