Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way of detecting how many mobs are attacking the player? #631

Closed
lionaneesh opened this issue Dec 4, 2024 · 32 comments
Closed

Any way of detecting how many mobs are attacking the player? #631

lionaneesh opened this issue Dec 4, 2024 · 32 comments
Labels
feature request This is a request for a new feature, or an expansion of an existing feature.

Comments

@lionaneesh
Copy link

Is your feature request related to a problem? Please describe.
Hello, so in some zones with red mobs sometimes the red mobs can spawn behind the bot and the bot already is pulling another mob, in such situations i'd like to script to run away.

Describe the solution you'd like
If its possible to get what all mobs are attacking the player and hopefully their guids.

Describe alternatives you've considered
Looked around in the addon, i couldn't find any way to get the number of mobs attacking the player.

@lionaneesh lionaneesh added the feature request This is a request for a new feature, or an expansion of an existing feature. label Dec 4, 2024
@Xian55
Copy link
Owner

Xian55 commented Dec 4, 2024

Gooday.

I would like to make a distinction between what kind of status the project can or cannot detect.

What cannot detect the addon:

  • Body pulled enemy mobs which are not yet on the combat log.
  • These enemies are engaged in combat by the player or players pet.
  • The enemy mob targets the player or its pet.
  • If the enemy has ranged attack, most likely casting a spell.
  • If the enemy is melee, possibly running towards the player or pet.

What the addon can detect:

  • Enemies which are on the combat log.
  • These enemies dealt damage to the player or the players pet.(DamageTaken)
  • Player or its pet dealt damage to the enemy(DamageDone)

The addon parses the combat log related to the player and and its pet, based on that can expose enemy related info such as

  • Currently how many different source the player or its pet received damage(DamageTaken)

DamageTaken guids sources calculated by the addon and exposed to the c# client.

The CombatLog only contains valid state while the player is in combat.

@Xian55
Copy link
Owner

Xian55 commented Dec 4, 2024

pulling another mob, in such situations i'd like to script to run away

Similiar issue was brought to my attention in the past.

Im just not sure how you can determine a safe direction to run at.

If you could further elaborate your plan we might get into a bargain position.

My intention is to avoid you spening implementing a Proof of concept or more detailed code which might be flawed from the get go.

@lionaneesh
Copy link
Author

Hey @Xian55 I basically figured out a rudimentary way. So in CombatGoal I am storing safe positions whenever I kill a mob and store it in a queue. Then when I detect that multiple mobs are attacking me, I turn in the direction of last safe position and press forward for 12 seconds. The problem is that when I try to run sometimes I will get stuck on a tree or a hill and the bot is dead again.

Is there anyway to leverage the navigation engine to navigate the same way as we do in the route to a safe position back and run till the mobs no longer aggro?

@lionaneesh
Copy link
Author

I could also share my patch but its very rough and work in progress. Do you have any ideas on how to use the navigation engine to move and how to keep running till we detect that the mobs dont aggro us anymore?

@lionaneesh
Copy link
Author

@Xian55 for your reference, i have added my commit: #632

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

First thing first.

Im pretty happy withe the current state of the combat goal. It does simple logic and in my humble opinion it should keep that way.

Basically a goal should only have basic task to complete. This way it can be ensured that the code kept clean as it can be.

Lets say a new goal is getting introduced which i would call "Flee".

The flees only goal would be to get out of combat by running away from the mobs.

Flee goal entering criterias

  • Player in combat
  • Damage taken count greater then X

Flee goal update loop

  • Follows the past known safely marked waypoints / locations.

Challanges

  • Q: What locations should be marked safe?
  • A: the best bet are the recently visited locations in the past Y seconds.
  • Q: Where does the safe locations are stored ?
  • A: As of now i would store them in GoapAgentState in a stack. When it used we pop a location as navigation input. So basically moving backwards.
  • Have to minimise player turning as enemy mobs always move in a straight line.
  • Have to avoid getting dazed.

Theres a navigation component which can be hooked into any Goal.

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

@Xian55 for your reference, i have added my commit: #632

In the upcoming few days i have limited tech access.

I will probably going to into the details next week.


Ive looked at the code at this state i would not accept this one for sure primarily because while the player moves forward the whole thread is blocked. Neutralizes bot to react to any changes meanwhile

@lionaneesh
Copy link
Author

lionaneesh commented Dec 5, 2024

@Xian55 I agree CombatGoal is probably not the best place to do this. I think FleeGoal will be a good addition. I think safe position should be the location where we killed last set of mobs, because it ensures there is less probability that there are more mobs spawning there.

In my opinion, Flee goal should be done when Player in combat and number of mobs attacking > X; where X could be taken from the Json.

A: As of now i would store them in GoapAgentState in a stack. When it used we pop a location as navigation input. So basically moving backwards.

Perfect that sounds really good.

Have to minimise player turning as enemy mobs always move in a straight line.
Have to avoid getting dazed.

Yes that will be perfect if we can get most optimal route that is a straight line and safe. We can use probably strafing and jumping to avoid getting dazed but this could be worked upon in stages.

Theres a navigation component which can be hooked into any Goal.

Navigation component you mean GoalsComponent/Navigation?

Ive looked at the code at this state i would not accept this one for sure primarily because while the player moves forward the whole thread is blocked. Neutralizes bot to react to any changes meanwhile

Yes for sure dont accept it, its just to show you my idea. I need to figure how to do it better.

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

I mean this whole problem can be avoided by killing mobs what your current character can handle easily.

Like picking a route which is not densly populated with mobs.

There are not many obstacles at the near terrain.

Killing enemy mobs which are below 2-3 level lower compare to your character.

By keeping in mind these simple principles the following issue should not occour.

@lionaneesh
Copy link
Author

@Xian55 Thats not true, I have tried that a lot and experimented with that idea a lot. For example as a Mage in Dun Morogh, you can farm boars and stuff but even if you are 2-3 levels above and hit into 3 winter wolves you cant kill them.

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

@Xian55 I agree CombatGoal is probably not the best place to do this. I think FleeGoal will be a good addition. I think safe position should be the location where we killed last set of mobs, because it ensures there is less probability that there are more mobs spawning there.

In my opinion, Flee goal should be done when Player in combat and number of mobs attacking > X; where X could be taken from the Json.

A: As of now i would store them in GoapAgentState in a stack. When it used we pop a location as navigation input. So basically moving backwards.

Perfect that sounds really good.

Have to minimise player turning as enemy mobs always move in a straight line.
Have to avoid getting dazed.

Yes that will be perfect if we can get most optimal route that is a straight line and safe. We can use probably strafing and jumping to avoid getting dazed but this could be worked upon in stages.

Theres a navigation component which can be hooked into any Goal.

Navigation component you mean GoalsComponent/Navigation?

Ive looked at the code at this state i would not accept this one for sure primarily because while the player moves forward the whole thread is blocked. Neutralizes bot to react to any changes meanwhile

Yes for sure dont accept it, its just to show you my idea. I need to figure how to do it better.


Yes implementing strafe movement will be amazing addition.

GoalsComponent/Navigation

Yes, correct.

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

@Xian55 Thats not true, I have tried that a lot and experimented with that idea a lot. For example as a Mage in Dun Morogh, you can farm boars and stuff but even if you are 2-3 levels above and hit into 3 winter wolves you cant kill them.

As a mage in early level you should aim to get your wand asap. Thats going to speed things up. Not to mention you can regen quite a lot of mana as well

@lionaneesh
Copy link
Author

@Xian55 Thats beside the point, I wanna make a bot that I can leave and farm the zones to kill mobs that aggro me and be safe. I will try to experiment with the Navigation Component meanwhile.

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

I just want to add another bit of info related why fleegoal should be preferred instead of adding rhe logic in to the combatgoal.

There are different modes how the bot can run.

For example in Attended* modes the fleegoal should no be enabled.

@lionaneesh
Copy link
Author

@Xian55 one more question do you know how I can check if the mobs have lost aggro or not?

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

You exit combat

@lionaneesh
Copy link
Author

so !bits.Combat? Really

@Xian55
Copy link
Owner

Xian55 commented Dec 5, 2024

Yessir.

On the other hand you check

DamageTaken.Count

If that value is zero that means while the player is in combat no mob dealth damage to the player.

The combatlog compontent automatically cleans up the damage taken guids once the player left combat.

@lionaneesh
Copy link
Author

Hey @Xian55 I was able to use the NavigateComponent in the CombatGoal. This allows me to navigate better, but the problem is while I am running away and when I am out of mobs range, I leave combat and Plan changes to ParallelGoal. But this doesn't give me chance to update the state that we are safe. Can you recommend me how to handle this? Currently my patch: #632 again we dont need to push this, just adding it here for your reference.

@Xian55
Copy link
Owner

Xian55 commented Dec 6, 2024

I am running away and when I am out of mobs range, I leave combat

Well the goap goals designed to take care of a singular task only.

The CombatGoal designed to respect the combat rotation in the described classconfig action priorities until the target has died.

In prior, CombatGoal had no movement implemented beside get into melee range by pressing interact with target.

Thats why i suggested to go with a completely separate plan, FleeGoal.

Each and ever GoapGoal has a precondition, until that given condition is met, a goal will get execution time.


On the other hand your current implementation conflicts with another goapgoal called target pet target.

This goal is getting added for hunters and warlocks but in leter expansion mage getting water elemental pet as well.

@lionaneesh
Copy link
Author

Hey @Xian55 thanks for your responses, its super helpful. So right now I have updated it to make it simpler, it just adds navigation to last safe point but seems like the bot stops after a few steps? I am not sure why that is happening. Can you check my code once? Added a new commit here: #632 ; is it because playerNavigation gets overwritten somewhere? I guess we are still in combat goal till the time we are in combat so nothing else should interfere with Player Nav, but I still see whenever the bot tries to run to last safe point it stops after few steps :( .

@lionaneesh
Copy link
Author

Also sometimes even when it escapes the mobs after that while targetting the next mob after it just keeps on moving around and missing all spells.

@Xian55
Copy link
Owner

Xian55 commented Dec 6, 2024

Like i said before in order to test your solution in isolation i would strongly suggest to separate your feature into a Flee goal.

This way you can ensure that only your logic gets executed and does not interfere with existing code.

@lionaneesh
Copy link
Author

@Xian55 if I would wanna add a new FleeGoal with prerequisite as Combat and Damage taken count greater then X won't it interfere with CombatGoal?

@lionaneesh
Copy link
Author

Also, shall I use the same format as the ParallelGoal for the FleeGoal?

@Xian55
Copy link
Owner

Xian55 commented Dec 6, 2024

@Xian55 if I would wanna add a new FleeGoal with prerequisite as Combat and Damage taken count greater then X won't it interfere with CombatGoal?

While you are fighting with a mob, then accidently body pulling X amount of extra mob, what do you want to do?

A: Are you feeling comfortable that you can kill them while your are kiting them?

B: Do you want to survive without dying, thus running away from possible death situation?

A: imples that you want to do multiple goal at once, and and fight the mobs meanwhile running away then when an ability is ready then just look at the mob cast it mid air then run.

B: suggest that you want to avoid death at all cost.

I have a strong suspicion that you want B.

@lionaneesh
Copy link
Author

Yes, I want B. I wanna be safe at all costs.

@lionaneesh
Copy link
Author

Okay @Xian55 I figured out what was my issue, I wasn't clearing the Navigation point OnExit in Combat. Thats why after the combat the character was doing weird moves. Now its working perfectly as expected! Thanks so much for helping. Now I am thinking to add a FleeGoal to give back to this project. Do you think I should make it like ParallelGoal?

@Xian55
Copy link
Owner

Xian55 commented Dec 6, 2024

Okay @Xian55 I figured out what was my issue, I wasn't clearing the Navigation point OnExit in Combat. Thats why after the combat the character was doing weird moves. Now its working perfectly as expected! Thanks so much for helping. Now I am thinking to add a FleeGoal to give back to this project. Do you think I should make it like ParallelGoal?

No, i dont think so.

ParallelGoal is not something what you use as a base class build upon.

ParalellGoal is primary used to execute actions which may have similar precondition and may or may not have to be executed at once.

Like if the player missing mana and hp you can initiate drinking water for mana and eat food at the same time.

However awaiting their buff effect are belong to a different goal, wait for drink and wait for food.

@lionaneesh
Copy link
Author

@Xian55 I am tryting to create a new goal FleeGoal as we discussed. Now my issue is that safepoints are not available inside any datastruct in the Goal. Shall I create a goap event for the safepoints? Also, is it possible for us to have a feature to add safe points in the route using the web ui?

@Xian55
Copy link
Owner

Xian55 commented Dec 8, 2024

Gooday, i think i mentioned a possible storage which was the GoapAgentState

@Xian55
Copy link
Owner

Xian55 commented Dec 15, 2024

Closing due #636 has been merged !

@Xian55 Xian55 closed this as completed Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request This is a request for a new feature, or an expansion of an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants