azerothcore / azerothcore-wotlk

Complete Open Source and Modular solution for MMO
http://www.azerothcore.org
GNU Affero General Public License v3.0
6.58k stars 2.63k forks source link

[ScriptAI] Many boss can't fly when use ScirptAI temporary access to sky #18551

Open kissingers opened 8 months ago

kissingers commented 8 months ago

Current Behaviour

Any combination of the following contains with me->SetDisableGravity(true); can not fly or stay on the sky after any action. So many bosses lose the ability to fly, or fly into the air and fall down quickly. It feels like the disable gravity temporary marker is not working.

me->SetCanFly(true); me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF); me->SendMovementFlagUpdate();

Expected Blizzlike Behaviour

They can fly at some event until finished the event.

Source

No response

Steps to reproduce the problem

look at boss felmyst,illidan , nightbane,when the sky phase , after they cast spell, they all fall to grand.

Extra Notes

https://github.com/azerothcore/azerothcore-wotlk/issues/15855

AC rev. hash/commit

AzerothCore rev. 9616433b6609+ 2024-03-10 16:52:03 -0300 (master branch) (Unix, RelWithDebInfo, Static)

Operating system

debian12 x64

Custom changes or Modules

No response

kissingers commented 8 months ago

https://github.com/azerothcore/azerothcore-wotlk/issues/18488 https://github.com/azerothcore/azerothcore-wotlk/issues/15855

kissingers commented 8 months ago

It seem when use me->HandleEmoteCommand(EMOTE_ONESHOT_LIFTOFF) after cast any spell or move , it will fall to grand.

Grimdhex commented 3 months ago

Can you provide an example ? Firstly, SetCanFly uage is completely wrong. This method is often badly used, but it is mainly for players. You should use "SetDisableGravity" for creatures. Then you need to use the right MotionMaster movement.

For example, with Kael'thas issue, it's MotionMaster::MoveTakeoff and not MovePoint (and when flying, cast others spells doesn't break GravityFlag). But I according that the behaviour of MotionMaster seems weird.

kissingers commented 3 months ago

Can you provide an example ? Firstly, SetCanFly uage is completely wrong. This method is often badly used, but it is mainly for players. You should use "SetDisableGravity" for creatures. Then you need to use the right MotionMaster movement.

For example, with Kael'thas issue, it's MotionMaster::MoveTakeoff and not MovePoint (and when flying, cast others spells doesn't break GravityFlag). But I according that the behaviour of MotionMaster seems weird.

Yes, I find the way to fix the problem for some boss, such as Felmyst like this way: https://github.com/azerothcore/azerothcore-wotlk/commit/46ba1ba6a327db712a219cef8f09d2c24ae7bc5a

and nightbane seems alread ok till now fix. but illidan still will first fly to sky and then drop to ground and run at ground not fly at sky, it seems there is PR to be testing for illidan, might need fix the problem at the PR or later.

kissingers commented 3 months ago

And I find when felmyst at sky fly, if cast spell, will need add flow code again, otherwise will drop to ground and run at ground, it seems cast spell auto stop SetDisableGravity(true) , I think only need update the status once till SetDisableGravity(false) , cast the spell will not stop the status. so it might a problem. me->SetDisableGravity(true); me->SendMovementFlagUpdate();

Grimdhex commented 3 months ago

I've debug Kael'Thas and you have effectly right. m_movementInfo loose the movement flag after reaching the first DoCastSelf following but the spline flag keep in memory the movement mode. This is why we have such variable situations.

I will try to look depper why this flag is lost when the creature cast (or maybe do) something.

sogladev commented 1 month ago

After setting SetDisableGravity(true) and engaging a movement spline, the very next Creature::Update() will remove that flag if the creature_template_movement.Flight is set to 0 https://github.com/azerothcore/azerothcore-wotlk/blob/a196f7f28aa263dc7f9c532e15839f3b409fb68f/src/server/game/Entities/Creature/Creature.cpp#L3442

call stack picture ![creature_update_movement_disable_gravity](https://github.com/user-attachments/assets/50ade84f-d198-43ab-ae80-ca0315d972fc)

For Felmyst: creature_template_movement.Flight is 0. Maybe this can be set to 2 (Flight) similar to Nightbane

For Kael: creature_template_movement.Flight = 0. Maybe 1 (Disable Gravity) and enabling gravity on init/reset but I found it is not needed

What worked for me is sending the disable gravity flag once the first spline finishes (MovementInform) and before sending the next spline like

me->SetDisableGravity(true);
me->SendMovementFlagUpdate();
me->GetMotionMaster()->MoveTakeoff(...)

MoveTakeoff seems to be better than MovePoint for flight. MovePoint can prevent flight as it checks for conditions like casting and causes movement to be like - - - - instead of smooth ------
, but can mess with animations due to init.SetAnimation(Movement::ToFly) It prevents the drowning emote from being applied correctly

Illidan can be done the same way I think as the flight is only a small part of his overall movement