-
Notifications
You must be signed in to change notification settings - Fork 8
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
Improve creature leashing behaviour. #93
base: epoch-core
Are you sure you want to change the base?
Conversation
…hcore-wotlk#19751) * Init. https: //github.com/vmangos/core/commit/7d2f1e2923734ea1b983eeaa0208cfd158d4af02 Co-Authored-By: ratkosrb <35845488+ratkosrb@users.noreply.github.com> * Hackfix for pets. * Whoops. * Correct evade uses. * Conflict. * Actually fix grace timer. * Add visibility distance check. Creatures should always fail combat checks in the open world if they're outside of visibility distance, might not be the case for worldbosses. --------- Co-authored-by: ratkosrb <35845488+ratkosrb@users.noreply.github.com> (cherry picked from commit azerothcore/azerothcore-wotlk@bf18b9b)
…azerothcore-wotlk#19923) * Init. * Use GetGameTime() instead of system call. Co-Authored-By: Anton Popovichenko <walkline.ua@gmail.com> * Update leash timer if rooted. * Remove unnecessary checks, add extension for fanning. More parity with VMaNGOS implementation. --------- Co-authored-by: Anton Popovichenko <walkline.ua@gmail.com> (cherry picked from commit azerothcore/azerothcore-wotlk@00e35a2)
(azerothcore/azerothcore-wotlk#19880) Init. (cherry picked from commit azerothcore/azerothcore-wotlk@632d7f5)
Same as vMangos, with 1.5 sec sometimes the leash timer would reset while the mob was chasing and attacking, leading to a very long leash...
SPELL_ATTR1_DISMISS_PET. The fix present in Project-Epoch#88 solves the interaction for players but breaks the interaction for NPCs. We need both accessors to handle all cases.
Note: The pets will reset at the same time as their owner, but they are not in a UNIT_STATE_EVADE --> they can be attacked again, and the owner will reaggro after he reaches his home position (unless he recalls his pet, then the initial one will be dismissed).
ones. This allows us to link creatures on the initial aggro but keep the ones which were pulled after the initial aggro on separate leash timers.
For reference if you want to implement it :
|
This reverts commit c745d8c. If we make the pet evade when the master evades, the same outcome is achieved, and we do not overcomplicate code.
Initially there was a blanket EngageWithTarget(). Use that only if we have no AI that can call AttackStart(), since AttackStart() calls EngageWithTarget for creatures.
I'll take your word for it, implemented a simple if/else case for it; not sure if the uint32 return value has anything to do with time_t addition Reverted the linked leashes for creatures and pets, it seems that even though they had separate leashes, they both update at more or less the same time; less code added by me is better, and most jarring cases are fixed by making pet evade when the owner evades. Still unsure what the best approach AssistDelayEvent::Execute is to initiate combat, but so far it seems to work fine like this so ... |
Signed-off-by: zana244 <50482785+zana244@users.noreply.github.com>
Signed-off-by: zana244 <50482785+zana244@users.noreply.github.com>
New year's gift! :D
Using a few patches from AC, which are themselves based on the creature leashing logic from vmangos.
Features:
Creatures which get called for assistance on the initial aggro pull will share the same leash timer with the initial target.
Link the leash timers of creatures and their pets, so they will keep each other in combat when either updates the leash timer.
Implement a rudimentary evade for the pets of creatures when the owner creature evades.
If a mob is not moving for about 5 seconds, while being able to attack the player, it will reupdate his leash timer.
Leash timer remains the same -> 12 seconds.
Extra -- Properly fix spells with SPELL_ATTR1_DISMISS_PET which I had broken in #88
My initial fix works for players, the initial TC state worked only for creatures. Incorporate both to handle players/creatures.
Shortcomings:
This is due to the check in CanCreatureAttack()
return victim->IsInDist(&m_homePosition, dist);
Even if the leash timer expired, the creatures cannot reset if the victim (the player generally) is still within a HUGE radius around their home position. --> if you skirt outside the radius of a creature's home position, but within the radius of a linked creature, the former will reset while the latter will still attack you.
vmangos solves this (I think ? maybe not this particular issue) by having an m_leashDistance assigned to each creature (most likely a config value) and checking it in Creature::Update --> presumably to allow some creatures to leash further than others.
When the owner creature evades, the pet is not in a true UNIT_STATE_EVADE --> you can attack it back and it will reaggro;
generally not a big issue, since most creatures recall their pet and dismiss this one when they reach their home position. Did not mess with UNIT_STATE_EVADE (yet), since there might be creatures who do not call their pet (or better yet, dismiss it), such that there is noone in the core to remove the UNIT_STATE_EVADE flag on the pet, rendering it permanently in an EVADE state.
This behaviour was present even before this PR, but at least now both the pet and the owner evade at the same time.
A bit unsure about the fanning aspect of mobs, and if they should reset the leash timer or not during this movement. I reverted the reset timer due to movement to around 5 seconds (vmangos value), since the one in AC (1.5 sec) would lead to a lot of false positives where the leash timer would reupdate while the mob would catch up to the player and attack him for < 1 sec.
Unsure if it's related to the i_recalculateTravel (in AC) and m_bRecalculateTravel (in vmangos) variables in the MovementGenerators (I commented out the code in this PR).
To differentiate between the initial CallAssistance() issued on initial pull and the CallAssistance() while mobs are chasing you, implement another bool variable which is true only for the first CallAssistance --> it allows us to know whether we should link the leash timers or not.