Core/WaypointMgr: Allow to set orientation to waypoints.

- Instead of the need to use a waypoint_script to change orientation on waypoint arrival.
This commit is contained in:
kaelima
2011-10-15 18:38:27 +02:00
parent 83a3da2630
commit 97e5140a1d
5 changed files with 28 additions and 17 deletions
@@ -0,0 +1 @@
ALTER TABLE `waypoint_data` ADD `orientation` float NOT NULL DEFAULT '0' AFTER `position_z`;
@@ -206,7 +206,13 @@ WaypointMovementGenerator<Creature>::Update(Creature &unit, const uint32 diff)
MovementInform(unit);
unit.UpdateWaypointID(i_currentNode);
unit.ClearUnitState(UNIT_STAT_ROAMING);
unit.Relocate(node->x, node->y, node->z);
if (node->orientation)
{
unit.Relocate(node->x, node->y, node->z, node->orientation);
unit.SetFacing(node->orientation, NULL);
}
else
unit.Relocate(node->x, node->y, node->z);
}
}
else
@@ -43,7 +43,7 @@ void WaypointMgr::Load()
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT id, point, position_x, position_y, position_z, 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_flag, delay, action, action_chance FROM waypoint_data ORDER BY id, point");
if (!result)
{
@@ -65,6 +65,7 @@ void WaypointMgr::Load()
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
float o = fields[5].GetFloat();
Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y);
@@ -73,10 +74,11 @@ void WaypointMgr::Load()
wp->x = x;
wp->y = y;
wp->z = z;
wp->run = fields[5].GetBool();
wp->delay = fields[6].GetUInt32();
wp->event_id = fields[7].GetUInt32();
wp->event_chance = fields[8].GetUInt8();
wp->orientation = o;
wp->run = fields[6].GetBool();
wp->delay = fields[7].GetUInt32();
wp->event_id = fields[8].GetUInt32();
wp->event_chance = fields[9].GetUInt8();
path.push_back(wp);
++count;
@@ -98,7 +100,7 @@ void WaypointMgr::ReloadPath(uint32 id)
_waypointStore.erase(itr);
}
QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id);
QueryResult result = WorldDatabase.PQuery("SELECT point, position_x, position_y, position_z, orientation, move_flag, delay, action, action_chance FROM waypoint_data WHERE id = %u ORDER BY point", id);
if (!result)
return;
@@ -112,6 +114,7 @@ void WaypointMgr::ReloadPath(uint32 id)
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
float o = fields[4].GetFloat();
Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y);
@@ -120,10 +123,11 @@ void WaypointMgr::ReloadPath(uint32 id)
wp->x = x;
wp->y = y;
wp->z = z;
wp->run = fields[4].GetBool();
wp->delay = fields[5].GetUInt32();
wp->event_id = fields[6].GetUInt32();
wp->event_chance = fields[7].GetUInt8();
wp->orientation = o;
wp->run = fields[5].GetBool();
wp->delay = fields[6].GetUInt32();
wp->event_id = fields[7].GetUInt32();
wp->event_chance = fields[8].GetUInt8();
path.push_back(wp);
@@ -26,7 +26,7 @@
struct WaypointData
{
uint32 id;
float x, y, z;
float x, y, z, orientation;
bool run;
uint32 delay;
uint32 event_id;
+5 -5
View File
@@ -858,7 +858,7 @@ public:
else
Maxpoint = 0;
result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid);
result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation FROM waypoint_data WHERE point ='%u' AND id = '%u'", Maxpoint, pathid);
if (!result)
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid);
@@ -866,13 +866,13 @@ public:
return false;
}
Field* fields = result->Fetch();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 id = VISUAL_WAYPOINT;
Player* chr = handler->GetSession()->GetPlayer();
float o = chr->GetOrientation();
Map* map = chr->GetMap();
Creature* creature = new Creature;