-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat: Pathfinding v3 + Attack rework #3676
Conversation
I am satisfied with the code as of now, so I am changing this PR from draft to Ready for review. |
I have been using this patch for few days on my bot that's running 24/7. It's rock solid. 👍 |
src/Task/Route.pm
Outdated
); | ||
|
||
my $sendAttack = 0; | ||
if ($self->{actor}->isa('Actor::You') && $config{"attackSendAttackWithMove"}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A $config{"attackUseWeapon"}
seems necessary here.
I use Henry's repo with his pathing branch and the XSTool.dll failed to load, can you share the working repo, so I can test this too, thanks. |
Will also make some optimizations by moving some heavily used functions to XS/C++, initially only checkLOS, maybe later also distances, canMove and canAttack |
Tested homunculus basic attacking and char random_walking while the homunculus is killing mobs, working well enough, can be improved a bit in the future, added TODO messages for the future. Still needs to be tested:
|
Oops I did not meant to push the test branch merge of the fix slaves PR, guess I'll have to put this one in a pause until that one is merged. |
All testing complete (albeit done with the slave PR merged here) should be good to merge after a bit of cleaning, commenting and tagging messages. If anyone intends to test this now would be a good time. |
Ready for testing, changing it from Draft to Pull Request |
avoid stucks on attack defining max attack distance using information from server
|
This is a rework of the current pathfinding algorithm based on my finding looking into the hercules emulator.
This PR actually has a lot of changes so I will be updating this comment little by little while rewiewing the code, for now this is only a draft.
Main changes:
1- Implements the Drunk plugin logic directly into the pathfinding algorithm, in the form of the config key route_randomFactor
(example: https://www.youtube.com/watch?v=sLRZoqQKMeQ)
2- Separates the avoidWalls logic from the weight logic, creating a new variable exclusive for custom weight maps, making, possible and easy the creation of plugins such as my NewAStarAvoid (included) (example: https://www.youtube.com/watch?v=Rov7DZ8wL9s&t=5s)
3- Implements a second pathfinding mode that simulates the client pathfinding by using the same heuristic as it to aquire the most precise position for a given character (calcPosFromPathfinding), this is used to calculate interception points in meetingPosition and alike.
4- Implements 2 new checks based on the client code to define one an actor can move to another spot (Field::canMove) or attack a target at another spot (Utils::canAttack), should never fail.
5- Actually uses client distance to calculate interactions, which is diferent from distance and blockDistance, removing the diference between melee and ranged.
6- Uses the emulator chase logic to approach targets, how this works:
When you send an attack packet to the emulator it checks if you are moving to the target, if you are then it stores the attack intention and checks in the emulator itself after every tick if the attack can be started and starts it when possible.
By using this information we can send after every move packet a new attack packet to start the chase logic and make the emulator attack for us.
Extra changes:
1- AI::findAction rework, added skip parameter.
2- Moved checkMonsterCleanness , provoke check and sitting->stand to before attack::main
3- Unified giveUp logic (except provoke and KS. Maybe TODO?)
4- Unified range and LOS checks in Utils::canAttack and removed them from AI::Attack
5- runFromTarget now loops distance from runFromTarget_dist up to clientSight instead of 0->14
6- Added attackBeyondMaxDistance_waitForAgressive for melee
7- Recalculate slave route whenever the character moves
8- Never move slave to the same cell as the character
9- Add setRoute2 to Wx to print both attack and move route
10- Optimization in meetingPosition to never check the same cell twice
TODO:
BUGS:
This seems to be caused by rathena range increase when following and continous attacking
Future insights:
Video showing it working:
Youtube