openkore
openkore copied to clipboard
feat: Pathfinding v3
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)
I am satisfied with the code as of now, so I am changing this PR from draft to Ready for review. Needs testing.
I have been using this patch for few days on my bot that's running 24/7. It's rock solid. 👍
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.
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
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.
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
Updated to master and added a few more checks
The issue with attackUseWeapon/Skills and attackSendAttackWithMove should be fixed now.
Maybe it's a good idea to also change how we set maxdistance here: https://github.com/OpenKore/openkore/blob/21aba245ae05c3533d71f6f3689f5b7d09bdc6d4/src/AI/Attack.pm#L391
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.