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

feat: Pathfinding v3 #3676

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

feat: Pathfinding v3 #3676

wants to merge 27 commits into from

Conversation

Henrybk
Copy link
Contributor

@Henrybk Henrybk commented Oct 8, 2022

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:

  • add checks for config key useweapon
  • add checks for use skill ( openkore is using autoattack everytime even when only skill is necessary)

@Henrybk Henrybk marked this pull request as draft October 8, 2022 18:25
@Henrybk
Copy link
Contributor Author

Henrybk commented Oct 9, 2022

I am satisfied with the code as of now, so I am changing this PR from draft to Ready for review.
Needs testing.

@Henrybk Henrybk marked this pull request as ready for review October 9, 2022 13:24
@Henrybk Henrybk self-assigned this Oct 9, 2022
@hexhexD
Copy link
Member

hexhexD commented Jan 8, 2023

I have been using this patch for few days on my bot that's running 24/7. It's rock solid. 👍

);

my $sendAttack = 0;
if ($self->{actor}->isa('Actor::You') && $config{"attackSendAttackWithMove"}) {
Copy link
Member

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.

@LastRoze
Copy link
Contributor

I have been using this patch for few days on my bot that's running 24/7. It's rock solid. 👍

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.

@alisonrag alisonrag changed the title New Pathfinding v3 feat: Pathfinding v3 Feb 22, 2023
@alisonrag
Copy link
Contributor

alisonrag commented Feb 22, 2023

I have been using this patch for few days on my bot that's running 24/7. It's rock solid. 👍

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.

dlls was recompiled using a different perl version.
this should run using strawbery perl 5.32 32bits and running using openkore.pl

@LastRoze
Copy link
Contributor

LastRoze commented Feb 25, 2023

Haven't got time to test it, will do it this Sunday, seems promising 🎉

-- Edit --

Can't test this actually, since I don't have RO Offline, too lazy to compile it myself. Welp if someone is interested in testing please do it. Seems like a cool feature to have.

@alisonrag
Copy link
Contributor

install strawberry perl 5.32 32bits:
https://strawberryperl.com/download/5.32.1.1/strawberry-perl-5.32.1.1-32bit.msi

run openkore.pl

if not work just go with cmd until openkore folder type gmake and copy the generated dlls to openkore folder

@Henrybk
Copy link
Contributor Author

Henrybk commented Sep 17, 2023

Updated to master and added a few more checks

@Henrybk
Copy link
Contributor Author

Henrybk commented Sep 19, 2023

The issue with attackUseWeapon/Skills and attackSendAttackWithMove should be fixed now.

@hexhexD
Copy link
Member

hexhexD commented Oct 7, 2023

Maybe it's a good idea to also change how we set maxdistance here:

$args->{attackMethod}{maxDistance} = 1;

I had a issue where a attackskillslot has a timeout checkSelfCondition returns 0 and the subsequent block will not select that skill. then the bot will behave like a melee and try to approach the monster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants