• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Problem with hostile mob detection.

    Discussion in 'Community Developer Forum' started by eniac, Feb 9, 2017.

    1. eniac

      eniac Member

      Joined:
      Jul 22, 2010
      Messages:
      107
      Likes Received:
      2
      Trophy Points:
      18
      Hey I have made a plugin that will automatically activate and deactivate stealth while gathering. Stealthy
      But I just now realised that it will not only use stealth on hostile mobs, but on every mob. Even neutral ones.

      Does anyone have an idea how to sort out hostile mobs ?

      I'm currently using:
      Code:
      GameObjectManager.GetObjectsOfType<BattleCharacter>().Where((u, i) => u.Type == GameObjectType.BattleNpc &&                                                                                                                       
                                                                      u.Location.Distance(Core.Player.Location) < 30 &&
                                                                      u.CanAttack &&
                                                                      u.IsVisible).FirstOrDefault() != null
       
    2. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,335
      Likes Received:
      380
      Trophy Points:
      83
      There isn't an api for checking a mobs reaction to the player currently, ill see about adding one.

      Also, you can safely assume that everything returned from getobjectsoftype will be x type, so you can remove the u.Type == GameObjectType.BattleNpc to save from having todo an extra memory read.
       
    3. eniac

      eniac Member

      Joined:
      Jul 22, 2010
      Messages:
      107
      Likes Received:
      2
      Trophy Points:
      18
      Ok, thank you for the answer I will remove "u.Type == GameObjectType.BattleNpc". Looking forward to the hostile enemy api addition.
       
    4. mastahg

      mastahg Administrator Staff Member

      Joined:
      Feb 27, 2011
      Messages:
      5,335
      Likes Received:
      380
      Trophy Points:
      83
      You can now do battlechar.StatusFlags.HasFlag(StatusFlags.Hostile) to check if a mob will aggro when you are near it. You should also check if the npc is much lower level as low enemies that are hostile wont aggro higher level players, im not sure what the breakpoint is for this.
       
    5. becto

      becto Member

      Joined:
      Mar 14, 2014
      Messages:
      104
      Likes Received:
      5
      Trophy Points:
      18
      after 10 levels the mobs don't agro.
       
    6. eniac

      eniac Member

      Joined:
      Jul 22, 2010
      Messages:
      107
      Likes Received:
      2
      Trophy Points:
      18
      Thanks so much mastahg. I just updated my plugin - testing at the moment.
       

    Share This Page