Core/Waypoints: Allow the table waypoint_data to use Takeoff and Land waypoints.

This commit is contained in:
Subv
2014-07-25 19:04:38 -05:00
parent a98737d5d9
commit b5d025938e
5 changed files with 47 additions and 7 deletions

View File

@@ -0,0 +1 @@
ALTER TABLE `waypoint_data` CHANGE `move_flag` `move_type` INT(11) NOT NULL DEFAULT 0;

View File

@@ -161,13 +161,28 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
if (node->orientation && node->delay)
init.SetFacing(node->orientation);
init.SetWalk(!node->run);
switch (node->move_type)
{
case WAYPOINT_MOVE_TYPE_LAND:
init.SetAnimation(Movement::ToGround);
break;
case WAYPOINT_MOVE_TYPE_TAKEOFF:
init.SetAnimation(Movement::ToFly);
break;
case WAYPOINT_MOVE_TYPE_RUN:
init.SetWalk(false);
break;
case WAYPOINT_MOVE_TYPE_WALK:
init.SetWalk(true);
break;
}
init.Launch();
//Call for creature group update
if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
{
creature->SetWalk(!node->run);
creature->SetWalk(node->move_type != WAYPOINT_MOVE_TYPE_RUN);
creature->GetFormation()->LeaderMoveTo(formationDest.x, formationDest.y, formationDest.z);
}

View File

@@ -42,7 +42,7 @@ void WaypointMgr::Load()
uint32 oldMSTime = getMSTime();
// 0 1 2 3 4 5 6 7 8 9
QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data ORDER BY id, point");
QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
@@ -73,7 +73,14 @@ void WaypointMgr::Load()
wp->y = y;
wp->z = z;
wp->orientation = o;
wp->run = fields[6].GetBool();
wp->move_type = fields[6].GetUInt32();
if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX)
{
TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", wp->id);
continue;
}
wp->delay = fields[7].GetUInt32();
wp->event_id = fields[8].GetUInt32();
wp->event_chance = fields[9].GetInt16();
@@ -126,7 +133,14 @@ void WaypointMgr::ReloadPath(uint32 id)
wp->y = y;
wp->z = z;
wp->orientation = o;
wp->run = fields[5].GetBool();
wp->move_type = fields[5].GetUInt32();
if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX)
{
TC_LOG_ERROR("sql.sql", "Waypoint %u in waypoint_data has invalid move_type, ignoring", wp->id);
continue;
}
wp->delay = fields[6].GetUInt32();
wp->event_id = fields[7].GetUInt32();
wp->event_chance = fields[8].GetUInt8();

View File

@@ -21,13 +21,23 @@
#include <vector>
enum WaypointMoveType
{
WAYPOINT_MOVE_TYPE_WALK,
WAYPOINT_MOVE_TYPE_RUN,
WAYPOINT_MOVE_TYPE_LAND,
WAYPOINT_MOVE_TYPE_TAKEOFF,
WAYPOINT_MOVE_TYPE_MAX
};
struct WaypointData
{
uint32 id;
float x, y, z, orientation;
uint32 delay;
uint32 event_id;
bool run;
uint32 move_type;
uint8 event_chance;
};

View File

@@ -51,7 +51,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
PrepareStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID, "UPDATE waypoint_data SET wpguid = ? WHERE id = ? and point = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_MAX_ID, "SELECT MAX(id) FROM waypoint_data", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_MAX_POINT, "SELECT MAX(point) FROM waypoint_data WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID, "SELECT point, position_x, position_y, position_z, orientation, move_type, delay, action, action_chance FROM waypoint_data WHERE id = ? ORDER BY point", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_BY_ID, "SELECT point, position_x, position_y, position_z FROM waypoint_data WHERE id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, "SELECT position_x, position_y, position_z FROM waypoint_data WHERE point = 1 AND id = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID, "SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE id = ? ORDER BY point DESC LIMIT 1", CONNECTION_SYNCH);