Compare commits

..

No commits in common. "e1f5064c9df720d33bbe7a52525b44ee895e283b" and "6db44b5296b259de52618f05cb0b4adc2866d955" have entirely different histories.

2 changed files with 13 additions and 18 deletions

View File

@ -7,7 +7,7 @@ INSERT INTO `ai_playerbot_texts`
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`, `text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`) `text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
VALUES ( VALUES (
1743, 1740,
'bot_not_your_master', 'bot_not_your_master',
"You are not my master!", "You are not my master!",
0, 0, 0, 0,
@ -35,7 +35,7 @@ INSERT INTO `ai_playerbot_texts`
`text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`, `text_loc1`, `text_loc2`, `text_loc3`, `text_loc4`,
`text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`) `text_loc5`, `text_loc6`, `text_loc7`, `text_loc8`)
VALUES ( VALUES (
1744, 1741,
'bot_rndbot_no_logout', 'bot_rndbot_no_logout',
"You can't command me to logout!", "You can't command me to logout!",
0, 0, 0, 0,
@ -56,4 +56,4 @@ VALUES (
-- ruRU -- ruRU
"Ты не можешь приказать мне выйти из игры!"); "Ты не можешь приказать мне выйти из игры!");
INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('bot_rndbot_no_logout', 100); INSERT INTO ai_playerbot_texts_chance (name, probability) VALUES ('bot_rndbot_no_logout', 100);

View File

@ -948,15 +948,14 @@ void MovementAction::UpdateMovementState()
const auto liquidState = bot->GetLiquidData().Status; const auto liquidState = bot->GetLiquidData().Status;
const float gZ = bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ()); const float gZ = bot->GetMapWaterOrGroundLevel(bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ());
const bool onGroundZ = bot->GetPositionZ() < gZ + 1.f; const bool onGroundZ = bot->GetPositionZ() < gZ + 1.f;
const bool wantsSwim = liquidState == LIQUID_MAP_IN_WATER || liquidState == LIQUID_MAP_UNDER_WATER; const bool canSwim = liquidState == LIQUID_MAP_IN_WATER || liquidState == LIQUID_MAP_UNDER_WATER;
const bool wantsFly = bot->HasIncreaseMountedFlightSpeedAura() || bot->HasFlyAura(); const bool canFly = bot->HasIncreaseMountedFlightSpeedAura() || bot->HasFlyAura();
const bool canWaterWalk = bot->HasWaterWalkAura(); const bool canWaterWalk = bot->HasWaterWalkAura();
const bool isMasterFlying = master ? master->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) : true; const bool isMasterFlying = master ? master->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) : true;
const bool isMasterSwimming = master ? master->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) : true; const bool isMasterSwimming = master ? master->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING) : true;
const bool isFlying = bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING); const bool isFlying = bot->HasUnitMovementFlag(MOVEMENTFLAG_FLYING);
const bool isSwimming = bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING); const bool isSwimming = bot->HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
const bool isWaterWalking = bot->HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); const bool isWaterWalking = bot->HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING);
const bool hasGravityDisabled = bot->HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY);
bool movementFlagsUpdated = false; bool movementFlagsUpdated = false;
// handle water (fragile logic do not alter without testing every detail, animation and transition) // handle water (fragile logic do not alter without testing every detail, animation and transition)
@ -971,11 +970,11 @@ void MovementAction::UpdateMovementState()
else if ((!canWaterWalk || isMasterSwimming) && isWaterWalking) else if ((!canWaterWalk || isMasterSwimming) && isWaterWalking)
{ {
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); bot->RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING);
if (wantsSwim) if (canSwim)
bot->SetSwim(true); bot->SetSwim(true);
movementFlagsUpdated = true; movementFlagsUpdated = true;
} }
else if (!wantsSwim && isSwimming) else if (!canSwim && isSwimming)
{ {
bot->SetSwim(false); bot->SetSwim(false);
movementFlagsUpdated = true; movementFlagsUpdated = true;
@ -991,21 +990,17 @@ void MovementAction::UpdateMovementState()
} }
// handle flying // handle flying
if (wantsFly && !isFlying && isMasterFlying) if ((canFly && !isFlying) && isMasterFlying)
{ {
bot->AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); bot->AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY);
bot->AddUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); bot->AddUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY);
bot->AddUnitMovementFlag(MOVEMENTFLAG_FLYING); bot->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
movementFlagsUpdated = true;
// required for transition and state monitoring.
if (MotionMaster* mm = bot->GetMotionMaster())
mm->MoveTakeoff(0, {bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ() + 1.F}, 0.F, true);
} }
else if (!wantsFly && !isWaterWalking && (isFlying || hasGravityDisabled)) else if ((!canFly && !isWaterWalking && isFlying) || (!isMasterFlying && isFlying && onGroundZ))
{
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY);
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY);
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
movementFlagsUpdated = true;
}
else if (!isMasterFlying && isFlying && onGroundZ)
{ {
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); bot->RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY);
bot->RemoveUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); bot->RemoveUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY);