Core/Movement: Added Velocity field to waypoint_path table (#29837)

This commit is contained in:
ModoX
2024-04-02 04:12:52 +02:00
committed by GitHub
parent 47e4bf06d3
commit e8f7d41536
6 changed files with 38 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
DELIMITER ;;
CREATE PROCEDURE waypoint_path_velocity_2024_04_02_00() BEGIN
IF NOT EXISTS (SELECT * FROM `information_schema`.`columns` WHERE `table_schema`=SCHEMA() AND `table_name`='waypoint_path' AND `column_name`='Velocity') THEN
ALTER TABLE `waypoint_path`
ADD COLUMN `Velocity` float NULL DEFAULT NULL AFTER `Flags`;
END IF;
END;;
DELIMITER ;
CALL waypoint_path_velocity_2024_04_02_00();
DROP PROCEDURE IF EXISTS waypoint_path_velocity_2024_04_02_00;
UPDATE `waypoint_path` SET `Velocity`=4.0 WHERE `PathId`=9301100;
UPDATE `waypoint_path` SET `Velocity`=35.0 WHERE `PathId` IN(11432300, 11432301, 11432302, 11432303, 11432304);

View File

@@ -417,6 +417,9 @@ void WaypointMovementGenerator<Creature>::StartMove(Creature* owner, bool relaun
break;
}
if (GetPath()->Velocity && !_speed)
_speed = GetPath()->Velocity;
if (_speed)
init.SetVelocity(*_speed);

View File

@@ -81,6 +81,7 @@ struct WaypointPath
uint32 Id = 0;
WaypointMoveType MoveType = WaypointMoveType::Walk;
EnumFlag<WaypointPathFlags> Flags = WaypointPathFlags::None;
Optional<float> Velocity;
};
#endif

View File

@@ -38,8 +38,8 @@ void WaypointMgr::_LoadPaths()
_pathStore.clear();
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT PathId, MoveType, Flags FROM waypoint_path");
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT PathId, MoveType, Flags, Velocity FROM waypoint_path");
if (!result)
{
@@ -88,15 +88,25 @@ void WaypointMgr::LoadPathFromDB(Field* fields)
uint32 pathId = fields[0].GetUInt32();
WaypointPath& path = _pathStore[pathId];
path.Id = pathId;
path.MoveType = WaypointMoveType(fields[1].GetUInt8());
path.MoveType = WaypointMoveType(fields[1].GetUInt8());;
if (path.MoveType >= WaypointMoveType::Max)
{
TC_LOG_ERROR("sql.sql", "PathId {} in `waypoint_path` has invalid MoveType {}, ignoring", pathId, AsUnderlyingType(path.MoveType));
return;
}
path.Id = pathId;
path.Flags = WaypointPathFlags(fields[2].GetUInt8());
if (!fields[3].IsNull())
{
if (fields[3].GetFloat() > 0.0f)
path.Velocity = fields[3].GetFloat();
else
TC_LOG_ERROR("sql.sql", "PathId {} in `waypoint_path` has invalid velocity {}, using default velocity instead", pathId, fields[3].GetFloat());
}
path.Nodes.clear();
}

View File

@@ -325,7 +325,7 @@ struct boss_guarm : public BossAI
DoCastAOE(SPELL_HEADLONG_CHARGE_PERIODIC_DAMAGE, true);
DoCastAOE(SPELL_HEADLONG_CHARGE_AT, true);
me->GetMotionMaster()->MovePath(HeadlongChargePairs[headlongChargeId].PathID, false, {}, 35.0f);
me->GetMotionMaster()->MovePath(HeadlongChargePairs[headlongChargeId].PathID, false);
}
else if (pointId == POINT_BERSERK_JUMP)
{
@@ -333,7 +333,7 @@ struct boss_guarm : public BossAI
DoCastAOE(SPELL_BERSERK_CHARGE_AT);
DoCastAOE(SPELL_ROARING_LEAP_INITIAL_KNOCKBACK, true);
me->GetMotionMaster()->MovePath(BerserkerPair.PathID, false, {}, 35.0f);
me->GetMotionMaster()->MovePath(BerserkerPair.PathID, false);
}
}
}

View File

@@ -217,7 +217,7 @@ struct npc_kayn_sunfury_invasion_begins : public ScriptedAI
else if (pointId == POINT_KAYN_MOVE_TO_DEMON)
{
me->SetAIAnimKitId(ANIM_DH_RUN);
me->GetMotionMaster()->MovePath(PATH_KAYN_ATTACK_DEMON, false, {}, 4.0f);
me->GetMotionMaster()->MovePath(PATH_KAYN_ATTACK_DEMON, false);
}
}