Advertisement
Guest User

Untitled

a guest
May 30th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.03 KB | None | 0 0
  1. diff -r c442c036446d src/game/Level2.cpp
  2. --- a/src/game/Level2.cpp   Thu Jun 10 20:32:08 2010 +0200
  3. +++ b/src/game/Level2.cpp   Thu Jun 10 20:33:31 2010 +0200
  4. @@ -42,6 +42,7 @@
  5.  #include <map>
  6.  #include "GlobalEvents.h"
  7.  #include "OutdoorPvPMgr.h"
  8. +#include "Transports.h"
  9.  
  10.  #include "TargetedMovementGenerator.h"                      // for HandleNpcUnFollowCommand
  11.  #include "CreatureGroups.h"
  12. @@ -1005,6 +1006,13 @@
  13.      float o = chr->GetOrientation();
  14.      Map *map = chr->GetMap();
  15.  
  16. +   if(chr->GetTransport())
  17. +   {
  18. +       chr->GetTransport()->AddNpcPassager(id, chr->GetTransOffsetX(),chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
  19. +       WorldDatabase.PQuery("INSERT INTO creature_transport (entry, npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (%u, %u, %f, %f, %f, %f)", chr->GetTransport()->GetEntry(), id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
  20. +       return true;
  21. +   }
  22. +
  23.      Creature* pCreature = new Creature;
  24.      if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
  25.      {
  26. diff -r c442c036446d src/game/Transports.cpp
  27. --- a/src/game/Transports.cpp   Thu Jun 10 20:32:08 2010 +0200
  28. +++ b/src/game/Transports.cpp   Thu Jun 10 20:33:31 2010 +0200
  29. @@ -108,6 +108,17 @@
  30.          //If we someday decide to use the grid to track transports, here:
  31.          t->SetMap(MapManager::Instance().CreateMap(mapid, t, 0));
  32.  
  33. +       // On spawn les npc lié au transport
  34. +       QueryResult_AutoPtr npc_transport = WorldDatabase.PQuery("SELECT npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO FROM creature_transport WHERE entry = '%u'", entry);
  35. +       if(npc_transport)
  36. +       {
  37. +           do
  38. +           {
  39. +               Field *fields = npc_transport->Fetch();
  40. +               t->AddNpcPassager(fields[0].GetUInt32(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat());
  41. +           } while( npc_transport->NextRow() );
  42. +       }
  43. +
  44.          //t->GetMap()->Add<GameObject>((GameObject *)t);
  45.          ++count;
  46.      } while (result->NextRow());
  47. @@ -458,6 +469,19 @@
  48.      //correct me if I'm wrong O.o
  49.      //yes, you're right
  50.  
  51. +   for(std::set<uint64>::iterator itr = m_NpcPassagerSet.begin(); itr != m_NpcPassagerSet.end();)
  52. +   {
  53. +       std::set<uint64>::iterator it2 = itr;
  54. +       ++itr;
  55. +
  56. +       uint64 guid = (*it2);
  57. +       if(Creature* npc = Creature::GetCreature(*this,guid))
  58. +       {
  59. +           npc->AddObjectToRemoveList();
  60. +       }
  61. +   }
  62. +   m_NpcPassagerSet.clear();
  63. +
  64.      ResetMap();
  65.      Map * newMap = MapManager::Instance().CreateMap(newMapid, this, 0);
  66.      SetMap(newMap);
  67. @@ -468,6 +492,17 @@
  68.          UpdateForMap(oldMap);
  69.          UpdateForMap(newMap);
  70.      }
  71. +
  72. +   // On spawn les npc lié au transport
  73. +   QueryResult_AutoPtr npc_transport = WorldDatabase.PQuery("SELECT npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO FROM creature_transport WHERE entry = '%u'", GetGUIDLow());
  74. +   if(npc_transport)
  75. +   {
  76. +       do
  77. +       {
  78. +           Field *fields = npc_transport->Fetch();
  79. +           AddNpcPassager(fields[0].GetUInt32(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat());
  80. +       } while( npc_transport->NextRow() );
  81. +   }
  82.  }
  83.  
  84.  bool Transport::AddPassenger(Player* passenger)
  85. @@ -509,8 +544,49 @@
  86.          }
  87.          else
  88.          {
  89. +           SetOrientation(GetAngle(m_next->second.x,m_next->second.y)+3.1415926f);
  90.              Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
  91. -        }
  92. +           if(m_NpcPassagerSet.size()>0)
  93. +           {  
  94. +               // On update les positions des npcs
  95. +               for(std::set<uint64>::iterator itr = m_NpcPassagerSet.begin(); itr != m_NpcPassagerSet.end();)
  96. +               {
  97. +                   std::set<uint64>::iterator it2 = itr;
  98. +                   ++itr;
  99. +
  100. +                   uint64 guid = (*it2);
  101. +                   if(Creature* npc = Creature::GetCreature(*this,guid))
  102. +                   {
  103. +                       float x, y, z, o;
  104. +                       o = GetOrientation() + npc->m_movementInfo.t_o;
  105. +                       x = GetPositionX() + (npc->m_movementInfo.t_x*cos(GetOrientation()) + npc->m_movementInfo.t_y*sin(GetOrientation()+3.14159f));
  106. +                       y = GetPositionY() + (npc->m_movementInfo.t_y*cos(GetOrientation()) + npc->m_movementInfo.t_x*sin(GetOrientation()));
  107. +                       z = GetPositionZ() + npc->m_movementInfo.t_z;
  108. +                       npc->Relocate(x, y, z,o);
  109. +                       npc->SetHomePosition(x,y,z,o);
  110. +                       npc->SetPosition(x,y,z,o,true)  ;
  111. +                       npc->GetMap()->CreatureRelocation(npc, x, y, z, o);
  112. +                   }
  113. +                   /*else if(Pet* npc = sObjectAccessor.GetPetInWorld(guid))
  114. +                   {
  115. +                       float x, y, z, o;
  116. +                       x = GetPositionX() + pCreature->m_movementInfo.t_x;
  117. +                       y = GetPositionY() + pCreature->m_movementInfo.t_y;
  118. +                       z = GetPositionY() + pCreature->m_movementInfo.t_z;
  119. +                       o = GetOrientation() + pCreature->m_movementInfo.t_o;
  120. +                       npc->Relocate(x, y, z);
  121. +                   }*/
  122. +                   else
  123. +                   {
  124. +                       m_NpcPassagerSet.erase(guid);
  125. +                       continue;
  126. +                   }
  127. +               }
  128. +           }
  129. +
  130. +       }
  131. +      
  132. +
  133.  /*
  134.          if (m_curr->second.delayed)
  135.          {
  136. @@ -548,7 +624,7 @@
  137.  
  138.          if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES) == 0)
  139.              sLog.outDetail("%s moved to %d %f %f %f %d", this->m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
  140. -
  141. +      
  142.          //Transport Event System
  143.          CheckForEvent(this->GetEntry(), m_curr->second.id);
  144.      }
  145. @@ -587,3 +663,35 @@
  146.      }
  147.  }
  148.  
  149. +void Transport::AddNpcPassager(uint32 entry, float x, float y, float z, float o)
  150. +{
  151. +   Map* map = GetMap();
  152. +    Creature* pCreature = new Creature;
  153. +   if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), this->GetPhaseMask(), entry, 0,(uint32)this->GetGOInfo()->faction,0,0,0,0))
  154. +    {
  155. +        delete pCreature;
  156. +        return;
  157. +    }
  158. +   pCreature->SetTransport(this);
  159. +   pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
  160. +   pCreature->m_movementInfo.guid = GetGUID();
  161. +   pCreature->m_movementInfo.t_x = x;
  162. +   pCreature->m_movementInfo.t_y = y;
  163. +   pCreature->m_movementInfo.t_z = z;
  164. +   pCreature->m_movementInfo.t_o = o;
  165. +   pCreature->setActive(true);
  166. +    pCreature->Relocate(x + GetPositionX(), y + GetPositionY(), z + GetPositionZ() , o + GetOrientation());
  167. +
  168. +    if(!pCreature->IsPositionValid())
  169. +    {
  170. +        sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
  171. +        delete pCreature;
  172. +        return;
  173. +    }
  174. +
  175. +   pCreature->AIM_Initialize();
  176. +
  177. +    map->Add(pCreature);
  178. +   m_NpcPassagerSet.insert(pCreature->GetGUID());
  179. +}
  180. +
  181. diff -r c442c036446d src/game/Transports.h
  182. --- a/src/game/Transports.h Thu Jun 10 20:32:08 2010 +0200
  183. +++ b/src/game/Transports.h Thu Jun 10 20:33:31 2010 +0200
  184. @@ -71,6 +71,8 @@
  185.          typedef std::set<Player*> PlayerSet;
  186.          PlayerSet const& GetPassengers() const { return m_passengers; }
  187.  
  188. +       mutable std::set<uint64> m_NpcPassagerSet;
  189. +       void AddNpcPassager(uint32 entry, float x, float y, float z, float o);
  190.      private:
  191.          struct WayPoint
  192.          {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement