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); MovementInform(unit);
unit.UpdateWaypointID(i_currentNode); unit.UpdateWaypointID(i_currentNode);
unit.ClearUnitState(UNIT_STAT_ROAMING); 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 else
@@ -43,7 +43,7 @@ void WaypointMgr::Load()
{ {
uint32 oldMSTime = getMSTime(); 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) if (!result)
{ {
@@ -65,6 +65,7 @@ void WaypointMgr::Load()
float x = fields[2].GetFloat(); float x = fields[2].GetFloat();
float y = fields[3].GetFloat(); float y = fields[3].GetFloat();
float z = fields[4].GetFloat(); float z = fields[4].GetFloat();
float o = fields[5].GetFloat();
Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y); Trinity::NormalizeMapCoord(y);
@@ -73,10 +74,11 @@ void WaypointMgr::Load()
wp->x = x; wp->x = x;
wp->y = y; wp->y = y;
wp->z = z; wp->z = z;
wp->run = fields[5].GetBool(); wp->orientation = o;
wp->delay = fields[6].GetUInt32(); wp->run = fields[6].GetBool();
wp->event_id = fields[7].GetUInt32(); wp->delay = fields[7].GetUInt32();
wp->event_chance = fields[8].GetUInt8(); wp->event_id = fields[8].GetUInt32();
wp->event_chance = fields[9].GetUInt8();
path.push_back(wp); path.push_back(wp);
++count; ++count;
@@ -98,7 +100,7 @@ void WaypointMgr::ReloadPath(uint32 id)
_waypointStore.erase(itr); _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) if (!result)
return; return;
@@ -112,6 +114,7 @@ void WaypointMgr::ReloadPath(uint32 id)
float x = fields[1].GetFloat(); float x = fields[1].GetFloat();
float y = fields[2].GetFloat(); float y = fields[2].GetFloat();
float z = fields[3].GetFloat(); float z = fields[3].GetFloat();
float o = fields[4].GetFloat();
Trinity::NormalizeMapCoord(x); Trinity::NormalizeMapCoord(x);
Trinity::NormalizeMapCoord(y); Trinity::NormalizeMapCoord(y);
@@ -120,10 +123,11 @@ void WaypointMgr::ReloadPath(uint32 id)
wp->x = x; wp->x = x;
wp->y = y; wp->y = y;
wp->z = z; wp->z = z;
wp->run = fields[4].GetBool(); wp->orientation = o;
wp->delay = fields[5].GetUInt32(); wp->run = fields[5].GetBool();
wp->event_id = fields[6].GetUInt32(); wp->delay = fields[6].GetUInt32();
wp->event_chance = fields[7].GetUInt8(); wp->event_id = fields[7].GetUInt32();
wp->event_chance = fields[8].GetUInt8();
path.push_back(wp); path.push_back(wp);
@@ -26,7 +26,7 @@
struct WaypointData struct WaypointData
{ {
uint32 id; uint32 id;
float x, y, z; float x, y, z, orientation;
bool run; bool run;
uint32 delay; uint32 delay;
uint32 event_id; uint32 event_id;
+5 -5
View File
@@ -858,7 +858,7 @@ public:
else else
Maxpoint = 0; 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) if (!result)
{ {
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid);
@@ -866,13 +866,13 @@ public:
return false; return false;
} }
Field* fields = result->Fetch(); Field* fields = result->Fetch();
float x = fields[0].GetFloat(); float x = fields[0].GetFloat();
float y = fields[1].GetFloat(); float y = fields[1].GetFloat();
float z = fields[2].GetFloat(); float z = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 id = VISUAL_WAYPOINT; uint32 id = VISUAL_WAYPOINT;
Player* chr = handler->GetSession()->GetPlayer(); Player* chr = handler->GetSession()->GetPlayer();
float o = chr->GetOrientation();
Map* map = chr->GetMap(); Map* map = chr->GetMap();
Creature* creature = new Creature; Creature* creature = new Creature;