We've moved! Join us as we continue development on our new site at umod.org!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  1. Hello,

    I'm trying to make an anti offline raid plugin but I don't know how to check if an item is under the influence of a tool cupboard.

    I tried using an overlapSphere on the cupboard but it's not accurate and covers more entities than needed because the cupboard radius is not a sphere.

    A little help ?

    Thanks,
    Exorion.
     
  2. This plugin uses an OverlapSphere, so it probably doesn't work as expected.
    Code:
    foreach (var collider in Physics.OverlapSphere(cup.transform.position, distance))
     
    PaiN likes this.
  3. Nope, I stopped coding for a bit, I'll try tonight.
     
  4. Well nope, doesn't work. I need to get the construction to trigger the hook but it doesn't. When I shoot it, it does not trigger, even when I build it inside the zone. The entity need to move inside the zone to trigger the hook.
     
  5. Another method to try that might get same results:

    Maybe do a check for HitIinitator.userID vs the HitEntity.OwnerID. Then if its not equal (aka.. not the owner). and the HitEntity.OwnerID is not part of the Active player list.. then Null damage. or something like that. I don't have the coding in front of me. but I use the basic concept for some of my damage control for my server.

    Of course this would protect anything player has deployed/built if they when offline, whether under building privilege or not.
     
  6. Yeah I had the same idea but I'm not the admin, I'm only the plugin dev x)

    We found this plugin http://oxidemod.org/plugins/antiofflineraid.1464/ that works like intended, it protects the base like you said, and it's fine. The issue is that on our server almost no one plays alone, so an easy counter and usebug to this plugin would be to create the base with another account, disconnect, and play with the main account normally but with the protection because the builder is offline. So our admin said he wanted a plugin that uses cupboards instead. It can be still countered but it's more difficult and less obious on how it works.

    Thanks for the help tho :)
     
  7. You can do something like the following to check for cupboard overlaps:
    Code:
    // check for cupboards which overlap the entity
    var hit = Physics.OverlapSphere(entity.transform.position, 0.5f, LayerMask.GetMask("Trigger"));
    // loop through cupboards
    foreach (var ent in hit)
    {
        BuildingPrivlidge privs = ent.GetComponentInParent<BuildingPrivlidge>();
        if (privs != null)
            // cupboard overlap - do something here
    }
     
    Garbage Collector and Exorion like this.
  8. Thanks a lot, it works :)
     
  9. I am trying to use this as well. This is probably not right although I do get some hits which, usually blocks adjacent to the cupboard:

    Collider[] hit = Physics.OverlapSphere(entity.transform.position, 0.5f);

    If I use one of the following, I get zero hits:

    Collider[] hit = Physics.OverlapSphere(entity.transform.position, 0.5f, LayerMask.GetMask("Trigger"));
    Collider[] hit = Physics.OverlapSphere(entity.transform.position, 0.5f, LayerMask.GetMask("Construction"));

    Basically, I am trying to verify that an entity (building block) is within the influence of a tool cupboard.
     
    Last edited by a moderator: Aug 17, 2018
  10. This seems to be satisfactory:

    Collider[] hit = Physics.OverlapSphere(entity.transform.position, 50f, LayerMask.GetMask("Trigger"));

    EDIT: Nope, I'll stop now.