Advertisement
Guest User

Extract the patch directory Wotje vehicles for 9609 for by Jethrogibbs

a guest
Mar 20th, 2010
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 184.45 KB | None | 0 0
  1. diff --git a/sql/v01_vehicle_data.sql b/sql/v01_vehicle_data.sql
  2. new file mode 100644
  3. index 0000000..74dc665
  4. --- a/sql/v01_vehicle_data.sql
  5. +++ b/sql/v01_vehicle_data.sql
  6. @@ -0,0 +1,21 @@
  7. +--
  8. +-- Table structure for table `vehicle_data`
  9. +--
  10. +
  11. +DROP TABLE IF EXISTS `vehicle_data`;
  12. +CREATE TABLE `vehicle_data` (
  13. +  `entry` mediumint(5) unsigned NOT NULL,
  14. +  `flags` mediumint(8) unsigned NOT NULL default '0',
  15. +  `Spell1` mediumint(8) unsigned NOT NULL default '0',
  16. +  `Spell2` mediumint(8) unsigned NOT NULL default '0',
  17. +  `Spell3` mediumint(8) unsigned NOT NULL default '0',
  18. +  `Spell4` mediumint(8) unsigned NOT NULL default '0',
  19. +  `Spell5` mediumint(8) unsigned NOT NULL default '0',
  20. +  `Spell6` mediumint(8) unsigned NOT NULL default '0',
  21. +  `Spell7` mediumint(8) unsigned NOT NULL default '0',
  22. +  `Spell8` mediumint(8) unsigned NOT NULL default '0',
  23. +  `Spell9` mediumint(8) unsigned NOT NULL default '0',
  24. +  `Spell10` mediumint(8) unsigned NOT NULL default '0',
  25. +  `req_aura` mediumint(8) unsigned NOT NULL default '0',
  26. +  PRIMARY KEY  (`entry`)
  27. +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Vehicle System';
  28. \ No newline at end of file
  29. diff --git a/sql/v02_vehicle_seat_data.sql b/sql/v02_vehicle_seat_data.sql
  30. new file mode 100644
  31. index 0000000..5c3a390
  32. --- a/sql/v02_vehicle_seat_data.sql
  33. +++ b/sql/v02_vehicle_seat_data.sql
  34. @@ -0,0 +1,10 @@
  35. +--
  36. +-- Table structure for table `vehicle_seat_data`
  37. +--
  38. +
  39. +DROP TABLE IF EXISTS `vehicle_seat_data`;
  40. +CREATE TABLE `vehicle_seat_data` (
  41. +  `seat` mediumint(5) unsigned NOT NULL,
  42. +  `flags` mediumint(8) unsigned NOT NULL default '0',
  43. +  PRIMARY KEY  (`seat`)
  44. +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Vehicle Seat System';
  45. \ No newline at end of file
  46. diff --git a/sql/v03_creature_addon_tables.sql b/sql/v03_creature_addon_tables.sql
  47. new file mode 100644
  48. index 0000000..7240ed4
  49. --- a/sql/v03_creature_addon_tables.sql
  50. +++ b/sql/v03_creature_addon_tables.sql
  51. @@ -0,0 +1,7 @@
  52. +ALTER TABLE creature_addon
  53. +  ADD COLUMN    vehicle_id           smallint(5) unsigned NOT NULL default '0' AFTER moveflags,
  54. +  ADD COLUMN    passengers           text AFTER vehicle_id;
  55. +
  56. +ALTER TABLE creature_template_addon
  57. +  ADD COLUMN    vehicle_id           smallint(5) unsigned NOT NULL default '0' AFTER moveflags,
  58. +  ADD COLUMN    passengers           text AFTER vehicle_id;
  59. \ No newline at end of file
  60. diff --git a/sql/v10_vehicle_test_data.sql b/sql/v10_vehicle_test_data.sql
  61. new file mode 100644
  62. index 0000000..e3fee71
  63. --- a/sql/v10_vehicle_test_data.sql
  64. +++ b/sql/v10_vehicle_test_data.sql
  65. @@ -0,0 +1,485 @@
  66. +INSERT INTO `vehicle_data` VALUES
  67. +('106', '4', '50896', '0', '50652', '0', '0', '0', '0', '0', '0', '0', '0'),
  68. +('116', '5', '51362', '51421', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  69. +('117', '4', '50652', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  70. +('156', '24', '53114', '0', '53110', '0', '0', '0', '0', '0', '0', '0', '0'),
  71. +('200', '30', '52362', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  72. +('210', '166', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  73. +('1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  74. +('6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  75. +('7', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  76. +('8', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  77. +('14', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  78. +('16', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  79. +('17', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  80. +('21', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  81. +('22', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  82. +('23', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  83. +('24', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  84. +('25', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  85. +('26', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  86. +('27', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  87. +('28', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  88. +('29', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  89. +('30', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  90. +('31', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  91. +('32', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  92. +('33', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  93. +('34', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  94. +('35', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  95. +('36', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  96. +('37', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  97. +('38', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  98. +('39', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  99. +('40', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  100. +('41', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  101. +('42', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  102. +('43', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  103. +('44', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  104. +('46', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  105. +('47', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  106. +('48', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  107. +('49', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  108. +('50', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  109. +('51', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  110. +('52', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  111. +('53', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  112. +('54', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  113. +('55', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  114. +('56', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  115. +('57', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  116. +('58', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  117. +('59', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  118. +('60', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  119. +('61', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  120. +('62', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  121. +('64', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  122. +('65', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  123. +('69', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  124. +('70', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  125. +('71', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  126. +('72', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  127. +('74', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  128. +('75', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  129. +('76', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  130. +('77', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  131. +('79', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  132. +('80', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  133. +('81', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  134. +('86', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  135. +('87', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  136. +('88', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  137. +('89', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  138. +('90', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  139. +('91', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  140. +('92', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  141. +('93', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  142. +('97', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  143. +('99', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  144. +('100', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  145. +('102', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  146. +('104', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  147. +('105', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  148. +('107', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  149. +('108', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  150. +('109', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  151. +('110', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  152. +('111', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  153. +('112', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  154. +('113', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  155. +('114', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  156. +('115', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  157. +('118', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  158. +('120', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  159. +('121', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  160. +('122', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  161. +('124', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  162. +('125', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  163. +('126', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  164. +('127', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  165. +('128', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  166. +('129', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  167. +('130', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  168. +('131', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  169. +('132', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  170. +('134', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  171. +('137', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  172. +('138', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  173. +('139', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  174. +('142', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  175. +('143', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  176. +('145', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  177. +('146', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  178. +('147', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  179. +('148', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  180. +('149', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  181. +('150', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  182. +('152', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  183. +('153', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  184. +('154', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  185. +('158', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  186. +('160', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  187. +('162', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  188. +('163', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  189. +('164', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  190. +('165', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  191. +('166', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  192. +('167', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  193. +('168', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  194. +('169', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  195. +('171', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  196. +('173', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  197. +('174', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  198. +('175', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  199. +('176', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  200. +('177', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  201. +('178', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  202. +('179', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  203. +('180', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  204. +('181', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  205. +('182', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  206. +('183', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  207. +('186', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  208. +('188', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  209. +('189', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  210. +('190', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  211. +('191', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  212. +('192', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  213. +('193', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  214. +('194', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  215. +('196', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  216. +('197', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  217. +('198', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  218. +('199', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  219. +('201', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  220. +('202', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  221. +('203', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  222. +('204', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  223. +('205', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  224. +('206', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  225. +('207', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  226. +('208', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  227. +('209', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  228. +('211', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  229. +('212', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  230. +('213', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  231. +('214', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  232. +('215', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  233. +('216', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  234. +('217', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  235. +('218', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  236. +('219', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  237. +('220', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  238. +('221', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  239. +('222', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  240. +('223', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  241. +('224', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  242. +('225', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  243. +('226', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  244. +('227', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  245. +('228', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  246. +('229', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  247. +('230', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  248. +('231', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  249. +('232', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  250. +('233', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  251. +('234', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  252. +('236', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  253. +('237', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  254. +('238', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  255. +('240', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  256. +('241', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  257. +('242', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  258. +('243', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  259. +('244', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  260. +('245', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  261. +('246', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  262. +('247', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  263. +('248', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  264. +('249', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  265. +('250', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  266. +('252', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  267. +('253', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  268. +('254', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  269. +('255', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  270. +('256', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  271. +('257', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  272. +('258', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  273. +('259', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  274. +('260', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  275. +('261', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  276. +('262', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  277. +('263', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  278. +('264', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  279. +('265', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  280. +('266', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  281. +('267', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  282. +('268', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  283. +('269', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  284. +('270', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  285. +('271', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  286. +('272', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  287. +('273', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  288. +('274', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  289. +('275', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  290. +('276', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  291. +('277', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  292. +('278', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  293. +('279', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  294. +('280', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  295. +('281', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  296. +('282', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  297. +('283', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  298. +('284', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  299. +('285', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  300. +('286', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  301. +('287', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  302. +('288', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  303. +('289', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  304. +('290', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  305. +('291', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  306. +('292', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  307. +('293', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  308. +('294', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  309. +('295', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  310. +('296', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  311. +('297', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  312. +('298', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  313. +('299', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  314. +('300', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  315. +('301', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  316. +('302', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  317. +('303', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  318. +('304', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  319. +('305', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  320. +('308', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  321. +('309', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  322. +('310', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  323. +('311', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  324. +('312', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  325. +('313', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  326. +('314', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  327. +('315', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  328. +('316', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  329. +('317', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  330. +('318', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  331. +('320', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  332. +('321', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  333. +('322', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  334. +('323', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  335. +('324', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  336. +('325', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  337. +('327', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  338. +('328', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  339. +('329', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  340. +('331', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  341. +('332', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  342. +('335', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  343. +('336', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  344. +('337', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  345. +('338', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  346. +('339', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  347. +('340', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  348. +('341', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  349. +('342', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  350. +('343', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  351. +('344', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  352. +('345', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  353. +('347', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  354. +('348', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  355. +('352', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  356. +('353', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  357. +('354', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  358. +('356', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  359. +('357', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  360. +('358', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  361. +('359', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  362. +('363', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  363. +('368', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  364. +('369', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  365. +('370', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  366. +('371', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  367. +('372', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  368. +('373', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  369. +('374', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  370. +('375', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  371. +('376', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  372. +('380', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  373. +('381', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  374. +('385', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  375. +('387', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  376. +('388', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  377. +('389', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  378. +('390', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  379. +('392', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  380. +('395', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  381. +('396', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  382. +('397', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  383. +('399', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  384. +('135', '12', '52362', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
  385. +('349', '24', '62544', '62575', '62960', '62552', '64077', '62863', '0', '0', '0', '0', '62853'),
  386. +('68', '24', '52435', '52576', '52588', '0', '0', '0', '0', '0', '0', '0', '0');
  387. +
  388. +UPDATE creature_template SET maxhealth = 133525, minhealth = 133525, maxmana = 51360, minmana = 51360 WHERE entry = 28670;
  389. +UPDATE creature_template SET maxhealth = 50000, minhealth = 50000 WHERE entry = 28094;
  390. +UPDATE creature_template SET maxhealth = 75000, minhealth = 75000 WHERE entry IN (28312,32627);
  391. +UPDATE creature_template SET maxhealth = 50000, minhealth = 50000 WHERE entry IN (28319,32629);
  392. +
  393. +UPDATE creature_template SET minlevel = 80, maxlevel = 80 WHERE entry IN (28312,32627,28319,32629,28094,28670);
  394. +
  395. +UPDATE creature_template SET speed = 2, InhabitType = 1 WHERE entry IN (28312,32627,28319,32629,28094,29929,28782);
  396. +UPDATE creature_template SET speed = 2.4, InhabitType = 4 WHERE entry IN (28670);
  397. +UPDATE creature_template SET mechanic_immune_mask = 652951551 WHERE entry IN (28670,28312,32627,28319,32629,28094,29929,28782);
  398. +
  399. +DELETE FROM npc_spellclick_spells WHERE npc_entry in (28670, 28312, 32629, 28319, 32627, 28094, 29929, 28782);
  400. +INSERT INTO npc_spellclick_spells VALUES
  401. +(28670, 52196, 0, 0, 0, 0),
  402. +(28312, 60968, 0, 0, 0, 1),
  403. +(32627, 60968, 0, 0, 0, 1),
  404. +(28319, 60968, 0, 0, 0, 1),
  405. +(32629, 60968, 0, 0, 0, 1),
  406. +(28094, 60968, 0, 0, 0, 1),
  407. +(29929, 58961, 0, 0, 0, 1),
  408. +(28782, 52280, 12687, 1, 12687, 1);
  409. +
  410. +DELETE FROM creature_template_addon WHERE entry in (28670, 28312, 32629, 28319, 32627, 28094, 29929, 28782);
  411. +INSERT INTO creature_template_addon VALUES
  412. +(28670, 0, 50331648, 1, 0, 1024, 156, NULL, '53112 0 53112 1'),
  413. +(28312, 0, 0, 0, 0, 0, 117, '28319 7', NULL),
  414. +(32627, 0, 0, 0, 0, 0, 117, '32629 7', NULL),
  415. +(28319, 0, 0, 0, 0, 0, 116, NULL, NULL),
  416. +(32629, 0, 0, 0, 0, 0, 116, NULL, NULL),
  417. +(28094, 0, 0, 0, 0, 0, 106, NULL, NULL),
  418. +(29929, 0, 0, 0, 0, 0, 210, NULL, NULL),
  419. +(28782, 0, 0, 0, 0, 0, 200, NULL, NULL);
  420. +
  421. +DELETE FROM vehicle_data WHERE entry in (106, 116, 117, 156, 200, 210);
  422. +INSERT INTO vehicle_data VALUES (106, 4, 50896, 0, 50652, 0, 0, 0, 0, 0, 0, 0, 0),
  423. +(116, 5, 51362, 51421, 0, 0, 0, 0, 0, 0, 0, 0, 0),
  424. +(117, 4, 50652, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
  425. +(156, 24, 53114, 0, 53110, 0, 0, 0, 0, 0, 0, 0, 0),
  426. +(200, 30, 52362, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
  427. +(210, 166, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  428. +
  429. +DELETE FROM vehicle_seat_data WHERE seat in (1643, 1648, 1649, 1650, 1652, 1554, 1556, 1557, 1986, 1987, 2144, 2181, 2182);
  430. +INSERT INTO vehicle_seat_data VALUES
  431. +(1643, 3),
  432. +(1648, 3),
  433. +(1649, 2),
  434. +(1650, 2),
  435. +(1652, 4),
  436. +(1554, 3),
  437. +(1556, 6),
  438. +(1557, 6),
  439. +(1986, 3),
  440. +(1987, 8),
  441. +(2144, 1),
  442. +(2181, 1),
  443. +(2182, 0);
  444. +
  445. +/* Some quests
  446. +Argent tournament*/
  447. +UPDATE creature_template SET speed = '1.5', unit_flags = 8 WHERE entry IN (33844,33845);
  448. +DELETE FROM creature_addon WHERE guid IN (SELECT guid FROM creature WHERE id IN (33844,33845));
  449. +DELETE FROM creature WHERE id IN (33844,33845);
  450. +DELETE FROM vehicle_data WHERE entry in (349);
  451. +INSERT INTO `vehicle_data` VALUES ('349', '24', '62544', '62575', '62960', '62552', '64077', '62863', '0', '0', '0', '0', '62853');
  452. +DELETE FROM vehicle_seat_data WHERE seat in (3129);
  453. +INSERT INTO `vehicle_seat_data` VALUES ('3129', '1');
  454. +INSERT INTO `npc_spellclick_spells` VALUES ('33842', '63791', '13829', '1', '0', '3');
  455. +INSERT INTO `npc_spellclick_spells` VALUES ('33842', '63791', '13839', '1', '0', '3');
  456. +INSERT INTO `npc_spellclick_spells` VALUES ('33842', '63791', '13838', '1', '0', '3');
  457. +INSERT INTO `npc_spellclick_spells` VALUES ('33843', '63792', '13828', '1', '0', '3');
  458. +INSERT INTO `npc_spellclick_spells` VALUES ('33843', '63792', '13837', '1', '0', '3');
  459. +INSERT INTO `npc_spellclick_spells` VALUES ('33843', '63792', '13835', '1', '0', '3');
  460. +DELETE FROM creature_template_addon WHERE entry IN (33844,33845);
  461. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (33844, 0, 0, 2049, 0, 0, 349, '', '');
  462. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (33845, 0, 0, 2049, 0, 0, 349, '', '');
  463. +
  464. +/*Quest Into the Realm of Shadows (12687)*/
  465. +UPDATE creature_template SET faction_A = 2082, faction_H = 2082, unit_flags = 0 WHERE entry = 28782;
  466. +DELETE FROM creature_addon WHERE guid IN (SELECT guid FROM creature WHERE id = 28782);
  467. +DELETE FROM vehicle_data WHERE entry in (135);
  468. +INSERT INTO vehicle_data VALUES (135, 12, 52362, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  469. +DELETE FROM vehicle_seat_data WHERE seat in (1871);
  470. +INSERT INTO vehicle_seat_data VALUES (1871, 1);
  471. +DELETE FROM npc_spellclick_spells WHERE npc_entry in (28782);
  472. +INSERT INTO npc_spellclick_spells VALUES (28782, 52349, 12687, 1, 12687, 3);
  473. +DELETE FROM creature_template_addon WHERE entry IN (28782);
  474. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (28782, 0, 0, 1, 0, 0, 135, '', '');
  475. +
  476. +/*Quest Grand Theft Palomino (12680)*/
  477. +DELETE FROM creature_addon WHERE guid IN (SELECT guid FROM creature WHERE id IN (28605,28606,28607));
  478. +REPLACE INTO spell_script_target VALUES (52264,1,28653);
  479. +DELETE FROM vehicle_data WHERE entry in (123);
  480. +INSERT INTO vehicle_data VALUES (123, 12, 52264, 52268, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  481. +DELETE FROM vehicle_seat_data WHERE seat in (1782);
  482. +INSERT INTO vehicle_seat_data VALUES (1782, 1);
  483. +DELETE FROM npc_spellclick_spells WHERE npc_entry in (28605,28606,28607);
  484. +INSERT INTO npc_spellclick_spells VALUES (28605, 52263, 12680, 1, 12680, 3);
  485. +INSERT INTO npc_spellclick_spells VALUES (28606, 52263, 12680, 1, 12680, 3);
  486. +INSERT INTO npc_spellclick_spells VALUES (28607, 52263, 12680, 1, 12680, 3);
  487. +DELETE FROM creature_template_addon WHERE entry IN (28605,28606,28607);
  488. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (28605, 0, 0, 1, 0, 0, 123, '', '');
  489. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (28606, 0, 0, 1, 0, 0, 123, '', '');
  490. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (28607, 0, 0, 1, 0, 0, 123, '', '');
  491. +
  492. +/*Quest Going Bearback*/
  493. +DELETE FROM npc_spellclick_spells WHERE npc_entry in (29598);
  494. +INSERT INTO npc_spellclick_spells VALUES (29598, 54908, 12851, 1, 12851, 1);
  495. +DELETE FROM creature_template_addon WHERE entry IN (29598);
  496. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (29598, 0, 0, 1, 0, 0, 308, '', '');
  497. +DELETE FROM vehicle_data WHERE entry in (308);
  498. +INSERT INTO `vehicle_data` VALUES ('308', '24', '54897', '54907', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  499. +REPLACE INTO vehicle_seat_data VALUES (2699, 3);
  500. +
  501. +/*Mamonth*/
  502. +DELETE FROM creature_template_addon WHERE entry in (32633,32640);
  503. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (32633, 0, 0, 1, 0, 0, 312, '', '');
  504. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (32640, 0, 0, 1, 0, 0, 312, '', '');
  505. +DELETE FROM vehicle_data WHERE entry in (312);
  506. +
  507. +/*Massacre At Light's Point*/
  508. +UPDATE `creature_template` SET `minhealth` = 26140, `maxhealth` = 26140, `dynamicflags` = 0, `minmana` = 2117, `maxmana` = 2117, `unit_flags` = 772, `minlevel` = 55, `maxlevel` = 55, `unk16` = 10, `unk17` = 1, `InhabitType` = 3, `scale` = 1, `mindmg` = 685, `maxdmg` = 715, `armor` = 3232, `attackpower` = 214, `unit_class` = 2, `type` = 10  WHERE `entry` = 28833;
  509. +UPDATE `creature_template` SET `minhealth` = 26140, `maxhealth` = 26140, `dynamicflags` = 0, `minmana` = 0, `maxmana` = 0, `unit_flags` = 772, `minlevel` = 55, `maxlevel` = 55, `unk16` = 10, `unk17` = 1, `InhabitType` = 3, `scale` = 1, `mindmg` = 685, `maxdmg` = 715, `armor` = 3232, `attackpower` = 214, `unit_class` = 2, `type` = 10  WHERE `entry` = 28887;
  510. +
  511. +DELETE FROM creature_addon WHERE guid IN (SELECT guid FROM creature WHERE id IN (28887,28833));
  512. +DELETE FROM vehicle_data WHERE entry in (68);
  513. +INSERT INTO `vehicle_data` VALUES ('68', '24', '52435', '52576', '52588', '0', '0', '0', '0', '0', '0', '0', '0');
  514. +DELETE FROM vehicle_seat_data WHERE seat in (1301);
  515. +INSERT INTO `vehicle_seat_data` VALUES ('1301', '3');
  516. +INSERT INTO `npc_spellclick_spells` VALUES ('28833', '52447', '12701', '1', '12701', '1');
  517. +INSERT INTO `npc_spellclick_spells` VALUES ('28887', '52447', '12701', '1', '12701', '1');
  518. +
  519. +DELETE FROM creature_template_addon WHERE entry IN (28887,28833);
  520. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (28887, 0, 0, 2049, 0, 0, 68, '', '');
  521. +INSERT INTO creature_template_addon (`entry`, `mount`, `bytes1`, `bytes2`, `emote`, `moveflags`, `vehicle_id`, `passengers`, `auras`) VALUES (28833, 0, 0, 2049, 0, 0, 68, '', '');
  522. +
  523. +
  524. +
  525. +/*Traveler's Tundra Mammoth */
  526. +REPLACE INTO npc_spellclick_spells VALUES (32633, 52196, 0, 0, 0, 0);
  527. +REPLACE INTO creature_template_addon VALUES (32633, 0, 0, 0, 0, 0, 312, NULL, NULL);
  528. +REPLACE INTO vehicle_data VALUES (312, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  529. +
  530. +/* Grand Ice Mammoth */
  531. +REPLACE INTO npc_spellclick_spells VALUES (31857, 52196, 0, 0, 0, 0);
  532. +REPLACE INTO creature_template_addon VALUES (31857, 0, 0, 0, 0, 0, 312, NULL, NULL);
  533. +
  534. +/* Salvaged Chopper */
  535. +REPLACE INTO npc_spellclick_spells VALUES (33062, 52196, 0, 0, 0, 0);
  536. +REPLACE INTO creature_template_addon VALUES (33062, 0, 0, 0, 0, 0, 335, NULL, NULL);
  537. +REPLACE INTO vehicle_data VALUES (335, 12, 62974, 62286, 62299, 64660, 0, 0, 0, 0, 0, 0, 0);
  538. +REPLACE INTO vehicle_seat_data VALUES (3005, 1);
  539. +
  540. +/* Salvaged Demolisher */
  541. +REPLACE INTO npc_spellclick_spells VALUES (33109, 52196, 0, 0, 0, 0);
  542. +REPLACE INTO creature_template_addon VALUES (33109, 0, 0, 0, 0, 0, 338, NULL, NULL);
  543. +REPLACE INTO vehicle_data VALUES (338, 12, 62306, 62490, 62308, 62324, 0, 0, 0, 0, 0, 0, 0);
  544. +REPLACE INTO vehicle_seat_data VALUES (3011, 1);
  545. +
  546. +/* Salvaged Siege Engine */
  547. +REPLACE INTO npc_spellclick_spells VALUES (33060, 52196, 0, 0, 0, 0);
  548. +REPLACE INTO creature_template_addon VALUES (33060, 0, 0, 0, 0, 0, 336, NULL, NULL);
  549. +REPLACE INTO vehicle_data VALUES (336, 12, 62345, 62522, 62346, 0, 0, 0, 0, 0, 0, 0, 0);
  550. +REPLACE INTO vehicle_seat_data VALUES (3006, 1);
  551. \ No newline at end of file
  552. diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp
  553. index b6a5e35..280cd5c 100644
  554. --- a/src/game/AggressorAI.cpp
  555. +++ b/src/game/AggressorAI.cpp
  556. @@ -103,7 +103,7 @@ void AggressorAI::EnterEvadeMode()
  557.          //i_tracker.Reset(TIME_INTERVAL_LOOK);
  558.      }
  559.  
  560. -    if (!m_creature->isCharmed())
  561. +    if(!m_creature->isCharmed() && !m_creature->GetVehicleGUID())
  562.      {
  563.          m_creature->RemoveAllAuras();
  564.  
  565. diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
  566. index fb4d9e5..67f6da6 100644
  567. --- a/src/game/BattleGroundMgr.cpp
  568. +++ b/src/game/BattleGroundMgr.cpp
  569. @@ -1345,11 +1345,15 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg)
  570.                  *data << (uint32)0x00000001;                // count of next fields
  571.                  *data << (uint32)((BattleGroundEYScore*)itr->second)->FlagCaptures;         // flag captures
  572.                  break;
  573. +            case BATTLEGROUND_SA:
  574. +                *data << (uint32)0x00000002;                // count of next fields
  575. +                *data << (uint32)((BattleGroundSAScore*)itr->second)->DemolishersDestroyed; // demolishers destroyed
  576. +                *data << (uint32)((BattleGroundSAScore*)itr->second)->GatesDestroyed;       // gates destroyed
  577. +                break;
  578.              case BATTLEGROUND_NA:
  579.              case BATTLEGROUND_BE:
  580.              case BATTLEGROUND_AA:
  581.              case BATTLEGROUND_RL:
  582. -            case BATTLEGROUND_SA:                           // wotlk
  583.              case BATTLEGROUND_DS:                           // wotlk
  584.              case BATTLEGROUND_RV:                           // wotlk
  585.              case BATTLEGROUND_IC:                           // wotlk
  586. diff --git a/src/game/BattleGroundSA.h b/src/game/BattleGroundSA.h
  587. index 31a3ffa..9324999 100644
  588. --- a/src/game/BattleGroundSA.h
  589. +++ b/src/game/BattleGroundSA.h
  590. @@ -24,8 +24,10 @@ class BattleGround;
  591.  class BattleGroundSAScore : public BattleGroundScore
  592.  {
  593.      public:
  594. -        BattleGroundSAScore() {};
  595. +        BattleGroundSAScore(): DemolishersDestroyed(0), GatesDestroyed(0) {};
  596.          virtual ~BattleGroundSAScore() {};
  597. +        uint32 DemolishersDestroyed;
  598. +        uint32 GatesDestroyed;
  599.  };
  600.  
  601.  class BattleGroundSA : public BattleGround
  602. diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
  603. index 5111aec..003f2a0 100644
  604. --- a/src/game/Chat.cpp
  605. +++ b/src/game/Chat.cpp
  606. @@ -474,6 +474,8 @@ ChatCommand * ChatHandler::getCommandTable()
  607.          { "spell_scripts",               SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellScriptsCommand,            "", NULL },
  608.          { "spell_target_position",       SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellTargetPositionCommand,     "", NULL },
  609.          { "spell_threats",               SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadSpellThreatsCommand,            "", NULL },
  610. +        { "vehicle_data",                SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadVehicleDataCommand,             "", NULL },
  611. +        { "vehicle_seat_data",           SEC_ADMINISTRATOR, true,  &ChatHandler::HandleReloadVehicleSeatDataCommand,         "", NULL },
  612.  
  613.          { NULL,                          0,                 false, NULL,                                                     "", NULL }
  614.      };
  615. @@ -1815,7 +1817,7 @@ Creature* ChatHandler::getSelectedCreature()
  616.      if(!m_session)
  617.          return NULL;
  618.  
  619. -    return m_session->GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(m_session->GetPlayer()->GetSelection());
  620. +    return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(),m_session->GetPlayer()->GetSelection());
  621.  }
  622.  
  623.  char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
  624. diff --git a/src/game/Chat.h b/src/game/Chat.h
  625. index da0563e..e7ba487 100644
  626. --- a/src/game/Chat.h
  627. +++ b/src/game/Chat.h
  628. @@ -396,6 +396,8 @@ class ChatHandler
  629.          bool HandleReloadSpellTargetPositionCommand(const char* args);
  630.          bool HandleReloadSpellThreatsCommand(const char* args);
  631.          bool HandleReloadSpellPetAurasCommand(const char* args);
  632. +        bool HandleReloadVehicleDataCommand(const char* args);
  633. +        bool HandleReloadVehicleSeatDataCommand(const char* args);
  634.  
  635.          bool HandleResetAchievementsCommand(const char * args);
  636.          bool HandleResetAllCommand(const char * args);
  637. diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
  638. index cd4123c..b79676b 100644
  639. --- a/src/game/Creature.cpp
  640. +++ b/src/game/Creature.cpp
  641. @@ -43,6 +43,7 @@
  642.  #include "GridNotifiers.h"
  643.  #include "GridNotifiersImpl.h"
  644.  #include "CellImpl.h"
  645. +#include "Vehicle.h"
  646.  
  647.  // apply implementation of the singletons
  648.  #include "Policies/SingletonImp.h"
  649. @@ -1059,7 +1060,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const
  650.      }
  651.      m_originalEntry = Entry;
  652.  
  653. -    Object::_Create(guidlow, Entry, HIGHGUID_UNIT);
  654. +   Object::_Create(guidlow, Entry, HIGHGUID_UNIT);
  655.  
  656.      if (!UpdateEntry(Entry, team, data, false))
  657.          return false;
  658. @@ -1285,6 +1286,8 @@ void Creature::setDeathState(DeathState s)
  659.          }
  660.  
  661.          Unit::setDeathState(CORPSE);
  662. +        if(isVehicle())
  663. +            ((Vehicle*)this)->Die();
  664.      }
  665.      if (s == JUST_ALIVED)
  666.      {
  667. @@ -1388,6 +1391,32 @@ bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, SpellEffectIn
  668.              return true;
  669.      }
  670.  
  671. +    // Heal immunity
  672. +    if (isVehicle() && !(((Vehicle*)this)->GetVehicleFlags() & VF_CAN_BE_HEALED))
  673. +    {
  674. +        switch(spellInfo->Effect[index])
  675. +        {
  676. +            case SPELL_EFFECT_APPLY_AURA:
  677. +                switch(spellInfo->EffectApplyAuraName[index])
  678. +                {
  679. +                    case SPELL_AURA_PERIODIC_HEAL:
  680. +                    case SPELL_AURA_OBS_MOD_HEALTH:
  681. +                    case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
  682. +                    case SPELL_AURA_MOD_REGEN:
  683. +                        return true;
  684. +                    default: break;
  685. +                }
  686. +                break;
  687. +            case SPELL_EFFECT_HEAL:
  688. +            case SPELL_EFFECT_HEAL_MAX_HEALTH:
  689. +            // NOTE : this too?
  690. +            case SPELL_EFFECT_HEAL_MECHANICAL:
  691. +            case SPELL_EFFECT_HEAL_PCT:
  692. +                return true;
  693. +            default : break;
  694. +        }
  695. +    }
  696. +
  697.      return Unit::IsImmunedToSpellEffect(spellInfo, index);
  698.  }
  699.  
  700. @@ -1870,6 +1899,29 @@ bool Creature::IsInEvadeMode() const
  701.      return !i_motionMaster.empty() && i_motionMaster.GetCurrentMovementGeneratorType() == HOME_MOTION_TYPE;
  702.  }
  703.  
  704. +float Creature::GetBaseSpeed() const
  705. +{
  706. +    if( isPet() )
  707. +    {
  708. +        switch( ((Pet*)this)->getPetType() )
  709. +        {
  710. +            case SUMMON_PET:
  711. +            case HUNTER_PET:
  712. +            {
  713. +                //fixed speed fur hunter (and summon!?) pets
  714. +                return 1.15;
  715. +            }
  716. +            case GUARDIAN_PET:
  717. +            case MINI_PET:
  718. +            {
  719. +                //speed of CreatureInfo for guardian- and minipets
  720. +                break;
  721. +            }
  722. +        }
  723. +    }
  724. +    return m_creatureInfo->speed_run;
  725. +}
  726. +
  727.  bool Creature::HasSpell(uint32 spellID) const
  728.  {
  729.      uint8 i;
  730. diff --git a/src/game/Creature.h b/src/game/Creature.h
  731. index 0ffd48d..b7b5889 100644
  732. --- a/src/game/Creature.h
  733. +++ b/src/game/Creature.h
  734. @@ -211,6 +211,15 @@ struct CreatureDataAddonAura
  735.      SpellEffectIndex effect_idx;
  736.  };
  737.  
  738. +struct CreatureDataAddonPassengers
  739. +{
  740. +    CreatureDataAddonPassengers() : entry(0), guid(0), seat_idx(-1) {}
  741. +
  742. +    uint32 entry;
  743. +    uint32 guid;
  744. +    int8 seat_idx;
  745. +};
  746. +
  747.  // from `creature_addon` table
  748.  struct CreatureDataAddon
  749.  {
  750. @@ -219,7 +228,9 @@ struct CreatureDataAddon
  751.      uint32 bytes1;
  752.      uint32 bytes2;
  753.      uint32 emote;
  754. -    uint32 splineFlags;
  755. +   uint32 splineFlags;
  756. +    uint32 vehicle_id;
  757. +    CreatureDataAddonPassengers const* passengers;          // loaded as char* "entry1 seatid1 entry2 seatid2 ... "  
  758.      CreatureDataAddonAura const* auras;                     // loaded as char* "spell1 eff1 spell2 eff2 ... "
  759.  };
  760.  
  761. @@ -396,6 +407,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
  762.          void GetRespawnCoord(float &x, float &y, float &z, float* ori = NULL, float* dist =NULL) const;
  763.          uint32 GetEquipmentId() const { return m_equipmentId; }
  764.  
  765. +        bool CreateVehicleKit(uint32 id);
  766. +        Vehicle *GetVehicleKit()const { return m_vehicleKit; }
  767. +
  768.          CreatureSubtype GetSubtype() const { return m_subtype; }
  769.          bool isPet() const { return m_subtype == CREATURE_SUBTYPE_PET; }
  770.          bool isVehicle() const { return m_subtype == CREATURE_SUBTYPE_VEHICLE; }
  771. @@ -560,6 +574,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
  772.  
  773.          MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; }
  774.          void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; }
  775. +        float GetBaseSpeed() const;
  776.  
  777.          // for use only in LoadHelper, Map::Add Map::CreatureCellRelocation
  778.          Cell const& GetCurrentCell() const { return m_currentCell; }
  779. @@ -666,7 +681,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
  780.          float CombatStartX;
  781.          float CombatStartY;
  782.          float CombatStartZ;
  783. -
  784. +        Vehicle* m_vehicleKit;
  785.          float m_summonXpoint;
  786.          float m_summonYpoint;
  787.          float m_summonZpoint;
  788. diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
  789. index b650b65..944442b 100644
  790. --- a/src/game/CreatureAI.cpp
  791. +++ b/src/game/CreatureAI.cpp
  792. @@ -26,6 +26,10 @@ CreatureAI::~CreatureAI()
  793.  
  794.  void CreatureAI::AttackedBy( Unit* attacker )
  795.  {
  796. +    // vehicle dont have threat list, so this is unnecessary, because it calls move chase
  797. +    if(m_creature->isVehicle())
  798. +        return;
  799. +
  800.      if(!m_creature->getVictim())
  801.          AttackStart(attacker);
  802.  }
  803. diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp
  804. index ae0a674..73c9091 100644
  805. --- a/src/game/CreatureEventAI.cpp
  806. +++ b/src/game/CreatureEventAI.cpp
  807. @@ -851,6 +851,7 @@ void CreatureEventAI::JustReachedHome()
  808.  
  809.  void CreatureEventAI::EnterEvadeMode()
  810.  {
  811. +    m_creature->ExitVehicle();
  812.      m_creature->RemoveAllAuras();
  813.      m_creature->DeleteThreatList();
  814.      m_creature->CombatStop(true);
  815. diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h
  816. index 2d8fec6..23e9c1b 100644
  817. --- a/src/game/DBCStructure.h
  818. +++ b/src/game/DBCStructure.h
  819. @@ -1690,7 +1690,7 @@ struct VehicleEntry
  820.      uint32  m_uiLocomotionType;                             // 34
  821.      float   m_msslTrgtImpactTexRadius;                      // 35
  822.      uint32  m_uiSeatIndicatorType;                          // 36
  823. -                                                            // 37, new in 3.1
  824. +    uint32  m_powerType;                                    // 37, new in 3.1                                                        // 37, new in 3.1
  825.                                                              // 38, new in 3.1
  826.                                                              // 39, new in 3.1
  827.  };
  828. diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h
  829. index 4743476..a7d6c3f 100644
  830. --- a/src/game/DBCfmt.h
  831. +++ b/src/game/DBCfmt.h
  832. @@ -103,7 +103,7 @@ const char TaxiNodesEntryfmt[]="nifffssssssssssssssssxii";
  833.  const char TaxiPathEntryfmt[]="niii";
  834.  const char TaxiPathNodeEntryfmt[]="diiifffiixx";
  835.  const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
  836. -const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx";
  837. +const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifiixx";
  838.  const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx";
  839.  const char WorldMapAreaEntryfmt[]="xinxffffixx";
  840.  const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx";
  841. diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
  842. index 217690f..8a2c4bc 100644
  843. --- a/src/game/GameObject.cpp
  844. +++ b/src/game/GameObject.cpp
  845. @@ -436,11 +436,7 @@ void GameObject::Update(uint32 /*p_time*/)
  846.              if(!m_respawnDelayTime)
  847.                  return;
  848.  
  849. -            if(!m_spawnedByDefault)
  850. -            {
  851. -                m_respawnTime = 0;
  852. -                return;
  853. -            }
  854. +            m_respawnTime = m_spawnedByDefault ? time(NULL) + m_respawnDelayTime : 0;
  855.  
  856.              // since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
  857.              m_respawnTime = time(NULL) + m_respawnDelayTime;
  858. @@ -1543,3 +1539,14 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
  859.      return tester_faction->IsFriendlyTo(*target_faction);
  860.  }
  861.  
  862. +void GameObject::DealSiegeDamage(uint32 damage)
  863. +{
  864. +    m_actualHealth -= damage;
  865. +
  866. +    // TODO : there are a lot of thinghts to do here
  867. +    if(m_actualHealth < 0)
  868. +    {
  869. +        m_actualHealth = GetGOInfo()->destructibleBuilding.intactNumHits;
  870. +        SetLootState(GO_JUST_DEACTIVATED);
  871. +    }
  872. +}
  873. \ No newline at end of file
  874. diff --git a/src/game/GameObject.h b/src/game/GameObject.h
  875. index 9cf06b3..8d51222 100644
  876. --- a/src/game/GameObject.h
  877. +++ b/src/game/GameObject.h
  878. @@ -691,12 +691,14 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
  879.  
  880.          bool isActiveObject() const { return false; }
  881.          uint64 GetRotation() const { return m_rotation; }
  882. +        void DealSiegeDamage(uint32 damage);
  883.      protected:
  884.          uint32      m_spellId;
  885.          time_t      m_respawnTime;                          // (secs) time of next respawn (or despawn if GO have owner()),
  886.          uint32      m_respawnDelayTime;                     // (secs) if 0 then current GO state no dependent from timer
  887.          LootState   m_lootState;
  888.          bool        m_spawnedByDefault;
  889. +        int32       m_actualHealth;                         // current health state
  890.          time_t      m_cooldownTime;                         // used as internal reaction delay time store (not state change reaction).
  891.                                                              // For traps this: spell casting cooldown, for doors/buttons: reset time.
  892.          std::list<uint32> m_SkillupList;
  893. diff --git a/src/game/GridNotifiers.cpp b/src/game/GridNotifiers.cpp
  894. index ca2e6fd..38f7f6d 100644
  895. --- a/src/game/GridNotifiers.cpp
  896. +++ b/src/game/GridNotifiers.cpp
  897. @@ -141,7 +141,10 @@ VisibleNotifier::Notify()
  898.      {
  899.          // target aura duration for caster show only if target exist at caster client
  900.          if((*vItr)!=&i_player && (*vItr)->isType(TYPEMASK_UNIT))
  901. +        {
  902.              i_player.SendAurasForTarget((Unit*)(*vItr));
  903. +            i_player.BuildVehicleInfo((Unit*)(*vItr));
  904. +        }
  905.  
  906.          // non finished movements show to player
  907.          if((*vItr)->GetTypeId()==TYPEID_UNIT && ((Creature*)(*vItr))->isAlive())
  908. diff --git a/src/game/Group.h b/src/game/Group.h
  909. index 397363e..bf6f3f7 100644
  910. --- a/src/game/Group.h
  911. +++ b/src/game/Group.h
  912. @@ -92,7 +92,8 @@ enum GroupUpdateFlags
  913.      GROUP_UPDATE_FLAG_PET_AURAS         = 0x00040000,       // uint64 mask, for each bit set uint32 spellid + uint8 unk, pet auras...
  914.      GROUP_UPDATE_FLAG_VEHICLE_SEAT      = 0x00080000,       // uint32 vehicle_seat_id (index from VehicleSeat.dbc)
  915.      GROUP_UPDATE_PET                    = 0x0007FC00,       // all pet flags
  916. -    GROUP_UPDATE_FULL                   = 0x0007FFFF,       // all known flags
  917. +    GROUP_UPDATE_VEHICLE                = 0x000FFC00,       // all vehicle flags
  918. +    GROUP_UPDATE_FULL                   = 0x000FFFFF,       // all known flags
  919.  };
  920.  
  921.  #define GROUP_UPDATE_FLAGS_COUNT          20
  922. diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp
  923. index fea6261..2f684b2 100644
  924. --- a/src/game/GroupHandler.cpp
  925. +++ b/src/game/GroupHandler.cpp
  926. @@ -28,6 +28,7 @@
  927.  #include "Group.h"
  928.  #include "SocialMgr.h"
  929.  #include "Util.h"
  930. +#include "Vehicle.h"
  931.  
  932.  /* differeces from off:
  933.      -you can uninvite yourself - is is useful
  934. @@ -690,7 +691,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
  935.          }
  936.      }
  937.  
  938. -    Pet *pet = player->GetPet();
  939. +    Unit *pet = player->GetCharmOrPet();
  940.      if (mask & GROUP_UPDATE_FLAG_PET_GUID)
  941.      {
  942.          if(pet)
  943. @@ -773,6 +774,11 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
  944.          else
  945.              *data << (uint64) 0;
  946.      }
  947. +
  948. +    if (mask & GROUP_UPDATE_FLAG_VEHICLE_SEAT)
  949. +    {
  950. +        *data << (uint32) player->m_SeatData.dbc_seat;
  951. +    }
  952.  }
  953.  
  954.  /*this procedure handles clients CMSG_REQUEST_PARTY_MEMBER_STATS request*/
  955. @@ -794,7 +800,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
  956.          return;
  957.      }
  958.  
  959. -    Pet *pet = player->GetPet();
  960. +    Unit *pet = player->GetCharmOrPet();
  961.  
  962.      WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
  963.      data << uint8(0);                                       // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
  964. @@ -802,7 +808,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
  965.  
  966.      uint32 mask1 = 0x00040BFF;                              // common mask, real flags used 0x000040BFF
  967.      if(pet)
  968. -        mask1 = 0x7FFFFFFF;                                 // for hunters and other classes with pets
  969. +        mask1 = 0xFFFFFFFF;                                 // for hunters and other classes with pets
  970.  
  971.      Powers powerType = player->getPowerType();
  972.      data << (uint32) mask1;                                 // group update mask
  973. @@ -856,6 +862,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
  974.              }
  975.          }
  976.          data.put<uint64>(petMaskPos,petauramask);           // GROUP_UPDATE_FLAG_PET_AURAS
  977. +        data << (uint32) player->m_SeatData.dbc_seat;
  978.      }
  979.      else
  980.      {
  981. diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp
  982. index 103b08a..10975f4 100644
  983. --- a/src/game/Level3.cpp
  984. +++ b/src/game/Level3.cpp
  985. @@ -74,6 +74,9 @@ bool ChatHandler::HandleReloadAllCommand(const char*)
  986.      HandleReloadReservedNameCommand("");
  987.      HandleReloadMangosStringCommand("");
  988.      HandleReloadGameTeleCommand("");
  989. +
  990. +    HandleReloadVehicleDataCommand("");
  991. +    HandleReloadVehicleSeatDataCommand("");
  992.      return true;
  993.  }
  994.  
  995. @@ -891,6 +894,22 @@ bool ChatHandler::HandleReloadMailLevelRewardCommand(const char* /*arg*/)
  996.      return true;
  997.  }
  998.  
  999. +bool ChatHandler::HandleReloadVehicleDataCommand(const char*)
  1000. +{
  1001. +    sLog.outString( "Re-Loading `vehicle_data` Table!" );
  1002. +    sObjectMgr.LoadVehicleData();
  1003. +    SendGlobalSysMessage("DB table `vehicle_data` reloaded.");
  1004. +    return true;
  1005. +}
  1006. +
  1007. +bool ChatHandler::HandleReloadVehicleSeatDataCommand(const char*)
  1008. +{
  1009. +    sLog.outString( "Re-Loading `vehicle_seat_data` Table!" );
  1010. +    sObjectMgr.LoadVehicleSeatData();
  1011. +    SendGlobalSysMessage("DB table `vehicle_seat_data` reloaded.");
  1012. +    return true;
  1013. +}
  1014. +
  1015.  bool ChatHandler::HandleLoadScriptsCommand(const char* args)
  1016.  {
  1017.      if(!LoadScriptingModule(args)) return true;
  1018. diff --git a/src/game/Map.h b/src/game/Map.h
  1019. index b22cad1..c8f4b10 100644
  1020. --- a/src/game/Map.h
  1021. +++ b/src/game/Map.h
  1022. @@ -37,7 +37,6 @@
  1023.  #include <bitset>
  1024.  #include <list>
  1025.  
  1026. -class Creature;
  1027.  class Unit;
  1028.  class WorldPacket;
  1029.  class InstanceData;
  1030. diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
  1031. index d958930..bfa2b5a 100644
  1032. --- a/src/game/MiscHandler.cpp
  1033. +++ b/src/game/MiscHandler.cpp
  1034. @@ -266,6 +266,7 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ )
  1035.      //Can not logout if...
  1036.      if( GetPlayer()->isInCombat() ||                        //...is in combat
  1037.          GetPlayer()->duel         ||                        //...is in Duel
  1038. +        GetPlayer()->GetVehicleGUID() ||                    //...is in vehicle
  1039.                                                              //...is jumping ...is falling
  1040.          GetPlayer()->m_movementInfo.HasMovementFlag(MovementFlags(MOVEFLAG_FALLING | MOVEFLAG_FALLINGFAR)))
  1041.      {
  1042. diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
  1043. index 0cb045c..ca7bebd 100644
  1044. --- a/src/game/MovementHandler.cpp
  1045. +++ b/src/game/MovementHandler.cpp
  1046. @@ -248,7 +248,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
  1047.      }
  1048.  
  1049.      /* handle special cases */
  1050. -    if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT))
  1051. +    if (movementInfo.HasMovementFlag(MOVEFLAG_ONTRANSPORT) && !mover->GetVehicleGUID())
  1052.      {
  1053.          // transports size limited
  1054.          // (also received at zeppelin/lift leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
  1055. @@ -296,6 +296,17 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
  1056.          // now client not include swimming flag in case jumping under water
  1057.          plMover->SetInWater( !plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z) );
  1058.      }
  1059. +    if (movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING))
  1060. +    {
  1061. +        if(mover->GetTypeId() == TYPEID_UNIT)
  1062. +        {
  1063. +            if(((Creature*)mover)->isVehicle() && !((Creature*)mover)->canSwim())
  1064. +            {
  1065. +                // NOTE : we should enter evade mode here, but...
  1066. +                ((Vehicle*)mover)->SetSpawnDuration(1);
  1067. +            }
  1068. +        }
  1069. +    }
  1070.  
  1071.      /*----------------------*/
  1072.  
  1073. @@ -354,7 +365,11 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
  1074.      else                                                    // creature charmed
  1075.      {
  1076.          if(mover->IsInWorld())
  1077. +        {
  1078.              mover->GetMap()->CreatureRelocation((Creature*)mover, movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o);
  1079. +            if(((Creature*)mover)->isVehicle())
  1080. +                ((Vehicle*)mover)->RellocatePassengers(mover->GetMap());
  1081. +        }
  1082.      }
  1083.  }
  1084.  
  1085. @@ -437,6 +452,12 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
  1086.      uint64 guid;
  1087.      recv_data >> guid;
  1088.  
  1089. +    if(_player->m_mover_in_queve && _player->m_mover_in_queve->GetGUID() == guid)
  1090. +    {
  1091. +        _player->m_mover = _player->m_mover_in_queve;
  1092. +        _player->m_mover_in_queve = NULL;
  1093. +    }
  1094. +
  1095.      if(_player->m_mover->GetGUID() != guid)
  1096.      {
  1097.          sLog.outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " I64FMT " and should be " I64FMT, _player->m_mover->GetGUID(), guid);
  1098. @@ -476,18 +497,169 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data)
  1099.      recv_data >> guid.ReadAsPacked();
  1100.      recv_data >> mi;
  1101.  
  1102. -    uint64 vehicleGUID = _player->GetCharmGUID();
  1103. +    uint64 vehicleGUID = _player->GetVehicleGUID();
  1104.  
  1105.      if(!vehicleGUID)                                        // something wrong here...
  1106.          return;
  1107.  
  1108.      _player->m_movementInfo = mi;
  1109.  
  1110. -    // using charm guid, because we don't have vehicle guid...
  1111. -    if(Vehicle *vehicle = _player->GetMap()->GetVehicle(vehicleGUID))
  1112. +    if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  1113. +    {
  1114. +        if(vehicle->GetVehicleFlags() & VF_DESPAWN_AT_LEAVE)
  1115. +            vehicle->Dismiss();
  1116. +        else
  1117. +            _player->ExitVehicle();
  1118. +    }
  1119. +}
  1120. +
  1121. +void WorldSession::HandleRequestVehicleExit(WorldPacket &recv_data)
  1122. +{
  1123. +    sLog.outDebug("WORLD: Recvd CMSG_REQUEST_VEHICLE_EXIT");
  1124. +    recv_data.hexlike();
  1125. +
  1126. +    uint64 vehicleGUID = _player->GetVehicleGUID();
  1127. +
  1128. +    if(!vehicleGUID)                                        // something wrong here...
  1129. +        return;
  1130. +
  1131. +    if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  1132. +    {
  1133. +        _player->ExitVehicle();
  1134. +    }
  1135. +}
  1136. +
  1137. +void WorldSession::HandleRequestVehiclePrevSeat(WorldPacket &recv_data)
  1138. +{
  1139. +    sLog.outDebug("WORLD: Recvd CMSG_REQUEST_VEHICLE_PREV_SEAT");
  1140. +    recv_data.hexlike();
  1141. +
  1142. +    uint64 vehicleGUID = _player->GetVehicleGUID();
  1143. +
  1144. +    if(!vehicleGUID)                                        // something wrong here...
  1145. +        return;
  1146. +
  1147. +    if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  1148. +    {
  1149. +        int8 prv_seat = _player->m_SeatData.seat;
  1150. +        if(Vehicle *v = vehicle->GetNextEmptySeat(&prv_seat, false, false))
  1151. +        {
  1152. +            vehicle->RemovePassenger(_player);
  1153. +            _player->EnterVehicle(v, prv_seat, false);
  1154. +        }
  1155. +    }
  1156. +}
  1157. +
  1158. +void WorldSession::HandleRequestVehicleNextSeat(WorldPacket &recv_data)
  1159. +{
  1160. +    sLog.outDebug("WORLD: Recvd CMSG_REQUEST_VEHICLE_NEXT_SEAT");
  1161. +    recv_data.hexlike();
  1162. +
  1163. +    uint64 vehicleGUID = _player->GetVehicleGUID();
  1164. +
  1165. +    if(!vehicleGUID)                                        // something wrong here...
  1166. +        return;
  1167. +
  1168. +    if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  1169. +    {
  1170. +        int8 nxt_seat = _player->m_SeatData.seat;
  1171. +        if(Vehicle *v = vehicle->GetNextEmptySeat(&nxt_seat, true, false))
  1172. +        {
  1173. +            vehicle->RemovePassenger(_player);
  1174. +            _player->EnterVehicle(v, nxt_seat, false);
  1175. +        }
  1176. +    }
  1177. +}
  1178. +
  1179. +void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket &recv_data)
  1180. +{
  1181. +    sLog.outDebug("WORLD: Recvd CMSG_REQUEST_VEHICLE_SWITCH_SEAT");
  1182. +    recv_data.hexlike();
  1183. +
  1184. +    uint64 vehicleGUID = _player->GetVehicleGUID();
  1185. +
  1186. +    if(!vehicleGUID)                                        // something wrong here...
  1187. +        return;
  1188. +
  1189. +    if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  1190.      {
  1191. -        // Aura::HandleAuraControlVehicle will call Player::ExitVehicle
  1192. -        vehicle->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
  1193. +        ObjectGuid guid;
  1194. +        recv_data >> guid.ReadAsPacked();
  1195. +
  1196. +        int8 seatId = 0;
  1197. +        recv_data >> seatId;
  1198. +
  1199. +        if(!guid.IsEmpty())
  1200. +        {
  1201. +            if(vehicleGUID != guid.GetRawValue())
  1202. +            {
  1203. +                if(Vehicle *veh = ObjectAccessor::GetVehicle(guid.GetRawValue()))
  1204. +                {
  1205. +                    if(!_player->IsWithinDistInMap(veh, 10))
  1206. +                        return;
  1207. +
  1208. +                    if(Vehicle *v = veh->FindFreeSeat(&seatId, false))
  1209. +                    {
  1210. +                        vehicle->RemovePassenger(_player);
  1211. +                        _player->EnterVehicle(v, seatId, false);
  1212. +                    }
  1213. +                }
  1214. +                return;
  1215. +            }
  1216. +        }
  1217. +        if(Vehicle *v = vehicle->FindFreeSeat(&seatId, false))
  1218. +        {
  1219. +            vehicle->RemovePassenger(_player);
  1220. +            _player->EnterVehicle(v, seatId, false);
  1221. +        }
  1222. +    }
  1223. +}
  1224. +
  1225. +void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data)
  1226. +{
  1227. +    sLog.outDebug("WORLD: Recvd CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE");
  1228. +    recv_data.hexlike();
  1229. +
  1230. +    uint64 vehicleGUID = _player->GetVehicleGUID();
  1231. +
  1232. +    if(!vehicleGUID)                                        // something wrong here...
  1233. +        return;
  1234. +
  1235. +    if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  1236. +    {
  1237. +        MovementInfo mi;
  1238. +        recv_data >> mi;
  1239. +        //_player->m_movementInfo = mi;
  1240. +
  1241. +        ObjectGuid guid;
  1242. +        recv_data >> guid.ReadAsPacked();
  1243. +
  1244. +        int8 seatId = 0;
  1245. +        recv_data >> seatId;
  1246. +
  1247. +        if(!guid.IsEmpty())
  1248. +        {
  1249. +            if(vehicleGUID != guid.GetRawValue())
  1250. +            {
  1251. +                if(Vehicle *veh = ObjectAccessor::GetVehicle(guid.GetRawValue()))
  1252. +                {
  1253. +                    if(!_player->IsWithinDistInMap(veh, 10))
  1254. +                        return;
  1255. +
  1256. +                    if(Vehicle *v = veh->FindFreeSeat(&seatId, false))
  1257. +                    {
  1258. +                        vehicle->RemovePassenger(_player);
  1259. +                        _player->EnterVehicle(v, seatId, false);
  1260. +                    }
  1261. +                }
  1262. +                return;
  1263. +            }
  1264. +        }
  1265. +        if(Vehicle *v = vehicle->FindFreeSeat(&seatId, false))
  1266. +        {
  1267. +            vehicle->RemovePassenger(_player);
  1268. +            _player->EnterVehicle(v, seatId, false);
  1269. +        }
  1270.      }
  1271.  }
  1272.  
  1273. @@ -550,4 +722,4 @@ void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data)
  1274.      recv_data >> agree;
  1275.  
  1276.      _player->SummonIfPossible(agree);
  1277. -}
  1278. +}
  1279. \ No newline at end of file
  1280. diff --git a/src/game/Object.cpp b/src/game/Object.cpp
  1281. index 1c5a12f..9a9ee6d 100644
  1282. --- a/src/game/Object.cpp
  1283. +++ b/src/game/Object.cpp
  1284. @@ -284,6 +284,9 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
  1285.                          }
  1286.                      }
  1287.                  }
  1288. +                if(((Unit*)this)->GetVehicleGUID())
  1289. +                    moveFlags2 |= (MOVEFLAG_ONTRANSPORT | MOVEFLAG_ROOT);
  1290. +
  1291.              }
  1292.              break;
  1293.              case TYPEID_PLAYER:
  1294. @@ -298,6 +301,8 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
  1295.                  // remove unknown, unused etc flags for now
  1296.                  player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_SPLINE_ENABLED);
  1297.  
  1298. +                if(((Unit*)this)->GetVehicleGUID())
  1299. +                    moveFlags2 |= (MOVEFLAG_ONTRANSPORT | MOVEFLAG_ROOT);
  1300.                  if(player->isInFlight())
  1301.                  {
  1302.                      ASSERT(player->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
  1303. @@ -1675,6 +1680,42 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
  1304.      return pCreature;
  1305.  }
  1306.  
  1307. +Vehicle* WorldObject::SummonVehicle(uint32 id, float x, float y, float z, float ang, uint32 vehicleId)
  1308. +{
  1309. +    Vehicle *v = new Vehicle;
  1310. +
  1311. +    Map *map = GetMap();
  1312. +    uint32 team = 0;
  1313. +    if (GetTypeId()==TYPEID_PLAYER)
  1314. +        team = ((Player*)this)->GetTeam();
  1315. +
  1316. +    if(!v->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, GetPhaseMask(), id, vehicleId, team))
  1317. +    {
  1318. +        delete v;
  1319. +        return NULL;
  1320. +    }
  1321. +
  1322. +    if (x == 0.0f && y == 0.0f && z == 0.0f)
  1323. +        GetClosePoint(x, y, z, v->GetObjectSize());
  1324. +
  1325. +    v->Relocate(x, y, z, ang);
  1326. +
  1327. +    if(!v->IsPositionValid())
  1328. +    {
  1329. +        sLog.outError("ERROR: Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
  1330. +            v->GetGUIDLow(), v->GetEntry(), v->GetPositionX(), v->GetPositionY());
  1331. +        delete v;
  1332. +        return NULL;
  1333. +    }
  1334. +    map->Add((Creature*)v);
  1335. +    v->AIM_Initialize();
  1336. +
  1337. +    if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI())
  1338. +        ((Creature*)this)->AI()->JustSummoned((Creature*)v);
  1339. +
  1340. +    return v;
  1341. +}
  1342. +
  1343.  namespace MaNGOS
  1344.  {
  1345.      class NearUsedPosDo
  1346. diff --git a/src/game/Object.h b/src/game/Object.h
  1347. index 3b805df..2dbc70c 100644
  1348. --- a/src/game/Object.h
  1349. +++ b/src/game/Object.h
  1350. @@ -69,6 +69,7 @@ class Unit;
  1351.  class Map;
  1352.  class UpdateMask;
  1353.  class InstanceData;
  1354. +class Vehicle;
  1355.  
  1356.  typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
  1357.  
  1358. @@ -475,6 +476,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
  1359.          void BuildUpdateData(UpdateDataMapType &);
  1360.  
  1361.          Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime);
  1362. +        Vehicle* SummonVehicle(uint32 id, float x, float y, float z, float ang, uint32 vehicleId = NULL);
  1363. +
  1364.      protected:
  1365.          explicit WorldObject();
  1366.  
  1367. diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp
  1368. index d2330fc..873118d 100644
  1369. --- a/src/game/ObjectAccessor.cpp
  1370. +++ b/src/game/ObjectAccessor.cpp
  1371. @@ -53,6 +53,21 @@ ObjectAccessor::~ObjectAccessor()
  1372.      }
  1373.  }
  1374.  
  1375. +Creature*
  1376. +ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const &u, ObjectGuid guid)
  1377. +{
  1378. +    if(guid.IsPlayer() || !u.IsInWorld())
  1379. +        return NULL;
  1380. +
  1381. +    if(guid.IsPet())
  1382. +        return u.GetMap()->GetPet(guid);
  1383. +
  1384. +    if(guid.IsVehicle())
  1385. +        return u.GetMap()->GetVehicle(guid);
  1386. +
  1387. +    return u.GetMap()->GetCreature(guid);
  1388. +}
  1389. +
  1390.  Unit*
  1391.  ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid)
  1392.  {
  1393. @@ -62,10 +77,7 @@ ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid)
  1394.      if(guid.IsPlayer())
  1395.          return FindPlayer(guid);
  1396.  
  1397. -    if (!u.IsInWorld())
  1398. -        return NULL;
  1399. -
  1400. -    return u.GetMap()->GetCreatureOrPetOrVehicle(guid);
  1401. +    return GetCreatureOrPetOrVehicle(u, guid);
  1402.  }
  1403.  
  1404.  Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
  1405. diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h
  1406. index e704f10..3edd6d5 100644
  1407. --- a/src/game/ObjectAccessor.h
  1408. +++ b/src/game/ObjectAccessor.h
  1409. @@ -38,6 +38,7 @@
  1410.  class Creature;
  1411.  class Unit;
  1412.  class GameObject;
  1413. +class Vehicle;
  1414.  class WorldObject;
  1415.  class Map;
  1416.  
  1417. @@ -91,12 +92,20 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
  1418.          // global (obj used for map only location local guid objects (pets currently)
  1419.          static Unit*   GetUnitInWorld(WorldObject const& obj, ObjectGuid guid);
  1420.  
  1421. -        // FIXME: map local object with global search
  1422. +        // map local object with global search
  1423.          static Creature*   GetCreatureInWorld(ObjectGuid guid)   { return FindHelper<Creature>(guid); }
  1424.          static GameObject* GetGameObjectInWorld(ObjectGuid guid) { return FindHelper<GameObject>(guid); }
  1425. +        static Pet*        GetGameObjectInWorld(uint64 guid, Pet*        /*fake*/) { return FindHelper<Pet>(guid); }
  1426. +        static Vehicle*    GetGameObjectInWorld(uint64 guid, Vehicle*    /*fake*/) { return FindHelper<Vehicle>(guid); }
  1427.  
  1428.          // possible local search for specific object map
  1429.          static Unit* GetUnit(WorldObject const &, ObjectGuid guid);
  1430. +        static Creature* GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid guid);
  1431. +        //static Player* GetPlayer(Unit const &, uint64 guid) { return FindPlayer(guid); }
  1432. +        //static Corpse* GetCorpse(WorldObject const &u, uint64 guid);
  1433. +        //static Pet* GetPet(uint64 guid) { return GetObjectInWorld(guid, (Pet*)NULL); }
  1434. +        static Vehicle* GetVehicle(uint64 guid) { return GetGameObjectInWorld(guid, (Vehicle*)NULL); }
  1435. +        //static Player* FindPlayer(uint64);
  1436.  
  1437.          // Player access
  1438.          static Player* FindPlayer(ObjectGuid guid);
  1439. @@ -164,6 +173,9 @@ inline Unit* ObjectAccessor::GetUnitInWorld(WorldObject const& obj, ObjectGuid g
  1440.      if (guid.IsPet())
  1441.          return obj.IsInWorld() ? obj.GetMap()->GetPet(guid) : NULL;
  1442.  
  1443. +    if (guid.IsVehicle())
  1444. +        return obj.IsInWorld() ? ((Unit*)obj.GetMap()->GetVehicle(guid)) : NULL;
  1445. +
  1446.      return GetCreatureInWorld(guid);
  1447.  }
  1448.  
  1449. diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
  1450. index f863a4c..ccb06f9 100644
  1451. --- a/src/game/ObjectMgr.cpp
  1452. +++ b/src/game/ObjectMgr.cpp
  1453. @@ -830,6 +830,93 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
  1454.      endAura.effect_idx = EFFECT_INDEX_0;
  1455.  }
  1456.  
  1457. +void ObjectMgr::ConvertCreatureAddonPassengers(CreatureDataAddon* addon, char const* table, char const* guidEntryStr)
  1458. +{
  1459. +    // Now add the passengers, format "creature_entry/guid seatindex creature_entry/guid seatindex..."
  1460. +    char *p,*s;
  1461. +    std::vector<int> val;
  1462. +    s=p=(char*)reinterpret_cast<char const*>(addon->passengers);
  1463. +    if(p)
  1464. +    {
  1465. +        while (p[0]!=0)
  1466. +        {
  1467. +            ++p;
  1468. +            if (p[0]==' ')
  1469. +            {
  1470. +                val.push_back(atoi(s));
  1471. +                s=++p;
  1472. +            }
  1473. +        }
  1474. +        if (p!=s)
  1475. +            val.push_back(atoi(s));
  1476. +
  1477. +        // free char* loaded memory
  1478. +        delete[] (char*)reinterpret_cast<char const*>(addon->passengers);
  1479. +
  1480. +        // wrong list
  1481. +        if (val.size()%2)
  1482. +        {
  1483. +            addon->auras = NULL;
  1484. +            sLog.outErrorDb("Creature (%s: %u) has wrong `passengers` data in `%s`.",guidEntryStr,addon->guidOrEntry,table);
  1485. +            return;
  1486. +        }
  1487. +    }
  1488. +
  1489. +    // empty list
  1490. +    if(val.empty())
  1491. +    {
  1492. +        addon->passengers = NULL;
  1493. +        return;
  1494. +    }
  1495. +
  1496. +    // replace by new structures array
  1497. +    const_cast<CreatureDataAddonPassengers*&>(addon->passengers) = new CreatureDataAddonPassengers[val.size()/2+1];
  1498. +
  1499. +    int i=0;
  1500. +    for(int j=0;j<val.size()/2;++j)
  1501. +    {
  1502. +        CreatureDataAddonPassengers& cPas = const_cast<CreatureDataAddonPassengers&>(addon->passengers[i]);
  1503. +        if(guidEntryStr == "Entry")
  1504. +            cPas.entry = (uint32)val[2*j+0];
  1505. +        else
  1506. +            cPas.guid = (uint32)val[2*j+0];
  1507. +        cPas.seat_idx = (int8)val[2*j+1];
  1508. +        if ( cPas.seat_idx > 7 )
  1509. +        {
  1510. +            sLog.outErrorDb("Creature (%s: %u) has wrong seat %u for creature %u in `passengers` field in `%s`.",guidEntryStr,addon->guidOrEntry,cPas.seat_idx,cPas.entry,table);
  1511. +            continue;
  1512. +        }
  1513. +        if(cPas.entry == 0 && cPas.guid == 0)
  1514. +        {
  1515. +            sLog.outErrorDb("Creature (%s: %u) has NULL creature entry/guid in `passengers` field in `%s`.",guidEntryStr,addon->guidOrEntry,table);
  1516. +            continue;
  1517. +        }
  1518. +        if(cPas.entry > 0)
  1519. +        {
  1520. +            if(!sCreatureStorage.LookupEntry<CreatureInfo>(cPas.entry))
  1521. +            {
  1522. +                sLog.outErrorDb("Creature (%s: %u) has wrong creature entry/guid %u `passengers` field in `%s`.",guidEntryStr,addon->guidOrEntry,cPas.entry,table);
  1523. +                continue;
  1524. +            }
  1525. +        }
  1526. +        else
  1527. +        {
  1528. +            if(mCreatureDataMap.find(cPas.guid)==mCreatureDataMap.end())
  1529. +            {
  1530. +                sLog.outErrorDb("Creature (%s: %u) has wrong creature entry/guid %u `passengers` field in `%s`.",guidEntryStr,addon->guidOrEntry,cPas.guid,table);
  1531. +                continue;
  1532. +            }
  1533. +        }
  1534. +        ++i;
  1535. +    }
  1536. +
  1537. +    // fill terminator element (after last added)
  1538. +    CreatureDataAddonPassengers& endPassenger = const_cast<CreatureDataAddonPassengers&>(addon->passengers[i]);
  1539. +    endPassenger.entry = 0;
  1540. +    endPassenger.guid = 0;
  1541. +    endPassenger.seat_idx = -1;
  1542. +}
  1543. +
  1544.  void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment)
  1545.  {
  1546.      creatureaddons.Load();
  1547. @@ -863,6 +950,7 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry
  1548.          }
  1549.  
  1550.          ConvertCreatureAddonAuras(const_cast<CreatureDataAddon*>(addon), creatureaddons.GetTableName(), entryName);
  1551. +        ConvertCreatureAddonPassengers(const_cast<CreatureDataAddon*>(addon), creatureaddons.GetTableName(), entryName);
  1552.      }
  1553.  }
  1554.  
  1555. @@ -5811,6 +5899,8 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
  1556.              return m_ItemGuids.Generate();
  1557.          case HIGHGUID_UNIT:
  1558.              return m_CreatureGuids.Generate();
  1559. +        case HIGHGUID_VEHICLE:
  1560. +            return m_VehicleGuids.Generate();
  1561.          case HIGHGUID_PLAYER:
  1562.              return m_CharGuids.Generate();
  1563.          case HIGHGUID_GAMEOBJECT:
  1564. @@ -8524,6 +8614,126 @@ CreatureInfo const* GetCreatureTemplateStore(uint32 entry)
  1565.      return sCreatureStorage.LookupEntry<CreatureInfo>(entry);
  1566.  }
  1567.  
  1568. +void ObjectMgr::LoadVehicleData()
  1569. +{
  1570. +    mVehicleData.clear();
  1571. +
  1572. +    QueryResult *result = WorldDatabase.Query("SELECT entry, flags, Spell1, Spell2, Spell3, Spell4, Spell5, Spell6, Spell7, Spell8, Spell9, Spell10, req_aura FROM vehicle_data");
  1573. +    if(!result)
  1574. +    {
  1575. +        barGoLink bar( 1 );
  1576. +        bar.step();
  1577. +
  1578. +        sLog.outString();
  1579. +        sLog.outString( ">> Loaded 0 vehicle data" );
  1580. +        sLog.outErrorDb("`vehicle_data` table is empty!");
  1581. +        return;
  1582. +    }
  1583. +
  1584. +    uint32 count = 0;
  1585. +
  1586. +    barGoLink bar( result->GetRowCount() );
  1587. +    do
  1588. +    {
  1589. +        bar.step();
  1590. +
  1591. +        Field* fields = result->Fetch();
  1592. +
  1593. +        VehicleDataStructure VDS;
  1594. +        // NOTE : we can use spellid or creature id
  1595. +        uint32 v_entry      = fields[0].GetUInt32();
  1596. +        VDS.v_flags         = fields[1].GetUInt32();
  1597. +        for(uint8 j = 0; j < MAX_VEHICLE_SPELLS; j++)
  1598. +        {
  1599. +            VDS.v_spells[j] = fields[j+2].GetUInt32();
  1600. +        }
  1601. +        VDS.req_aura        = fields[12].GetUInt32();
  1602. +
  1603. +        VehicleEntry const *vehicleInfo = sVehicleStore.LookupEntry(v_entry);
  1604. +        if(!vehicleInfo)
  1605. +        {
  1606. +            sLog.outErrorDb("Vehicle id %u listed in `vehicle_data` does not exist",v_entry);
  1607. +            continue;
  1608. +        }
  1609. +        for(uint8 j = 0; j < MAX_VEHICLE_SPELLS; j++)
  1610. +        {
  1611. +            if(VDS.v_spells[j])
  1612. +            {
  1613. +                SpellEntry const* j_spell = sSpellStore.LookupEntry(VDS.v_spells[j]);
  1614. +                if(!j_spell)
  1615. +                {
  1616. +                    sLog.outErrorDb("Spell %u listed in `vehicle_data` does not exist, skipped",VDS.v_spells[j]);
  1617. +                    VDS.v_spells[j] = 0;
  1618. +                }
  1619. +            }
  1620. +        }
  1621. +        if(VDS.req_aura)
  1622. +        {
  1623. +            SpellEntry const* i_spell = sSpellStore.LookupEntry(VDS.req_aura);
  1624. +            if(!i_spell)
  1625. +            {
  1626. +                sLog.outErrorDb("Spell %u listed in `vehicle_data` does not exist, skipped",VDS.req_aura);
  1627. +                VDS.req_aura = 0;
  1628. +            }
  1629. +        }
  1630. +
  1631. +        mVehicleData[v_entry] = VDS;
  1632. +        ++count;
  1633. +    }
  1634. +    while (result->NextRow());
  1635. +
  1636. +    delete result;
  1637. +
  1638. +    sLog.outString();
  1639. +    sLog.outString( ">> Loaded %u vehicle data", count );
  1640. +}
  1641. +
  1642. +void ObjectMgr::LoadVehicleSeatData()
  1643. +{
  1644. +    mVehicleSeatData.clear();
  1645. +
  1646. +    QueryResult *result = WorldDatabase.Query("SELECT seat,flags FROM vehicle_seat_data");
  1647. +
  1648. +    if( !result )
  1649. +    {
  1650. +        barGoLink bar( 1 );
  1651. +
  1652. +        bar.step();
  1653. +
  1654. +        sLog.outString();
  1655. +        sLog.outString( ">> Loaded 0 vehicle seat data" );
  1656. +        sLog.outErrorDb("`vehicle_seat_data` table is empty!");
  1657. +        return;
  1658. +    }
  1659. +    uint32 count = 0;
  1660. +
  1661. +    barGoLink bar( result->GetRowCount() );
  1662. +    do
  1663. +    {
  1664. +        bar.step();
  1665. +
  1666. +        Field *fields = result->Fetch();
  1667. +        uint32 entry  = fields[0].GetUInt32();
  1668. +        uint32 flag   = fields[1].GetUInt32();
  1669. +
  1670. +        VehicleSeatEntry const *vsInfo = sVehicleSeatStore.LookupEntry(entry);
  1671. +        if(!vsInfo)
  1672. +        {
  1673. +            sLog.outErrorDb("Vehicle seat %u listed in `vehicle_seat_data` does not exist",entry);
  1674. +            continue;
  1675. +        }
  1676. +
  1677. +        mVehicleSeatData[entry] = flag;
  1678. +        ++count;
  1679. +    }
  1680. +    while (result->NextRow());
  1681. +
  1682. +    delete result;
  1683. +
  1684. +    sLog.outString();
  1685. +    sLog.outString( ">> Loaded %u vehicle seat data", count );
  1686. +}
  1687. +
  1688.  Quest const* GetQuestTemplateStore(uint32 entry)
  1689.  {
  1690.      return sObjectMgr.GetQuestTemplate(entry);
  1691. diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
  1692. index 0cd0547..8dabb26 100644
  1693. --- a/src/game/ObjectMgr.h
  1694. +++ b/src/game/ObjectMgr.h
  1695. @@ -370,6 +370,8 @@ extern LanguageDesc lang_description[LANGUAGES_COUNT];
  1696.  MANGOS_DLL_SPEC LanguageDesc const* GetLanguageDescByID(uint32 lang);
  1697.  
  1698.  class PlayerDumpReader;
  1699. +// vehicle system
  1700. +#define MAX_VEHICLE_SPELLS 6
  1701.  
  1702.  template<typename T>
  1703.  class IdGenerator
  1704. @@ -389,6 +391,16 @@ class IdGenerator
  1705.          T m_nextGuid;
  1706.  };
  1707.  
  1708. +struct VehicleDataStructure
  1709. +{
  1710. +    uint32 v_flags;                                         // vehicle flags, see enum CustomVehicleFLags
  1711. +    uint32 v_spells[MAX_VEHICLE_SPELLS];                    // spells
  1712. +    uint32 req_aura;                                        // requieres aura on player to enter (eg. in wintergrasp)
  1713. +};
  1714. +
  1715. +typedef UNORDERED_MAP<uint32, VehicleDataStructure> VehicleDataMap;
  1716. +typedef std::map<uint32,uint32> VehicleSeatDataMap;
  1717. +
  1718.  class ObjectMgr
  1719.  {
  1720.      friend class PlayerDumpReader;
  1721. @@ -655,6 +667,9 @@ class ObjectMgr
  1722.          void LoadVendors();
  1723.          void LoadTrainerSpell();
  1724.  
  1725. +        void LoadVehicleData();
  1726. +        void LoadVehicleSeatData();
  1727. +
  1728.          std::string GeneratePetName(uint32 entry);
  1729.          uint32 GetBaseXP(uint32 level) const;
  1730.          uint32 GetXPForLevel(uint32 level) const;
  1731. @@ -883,6 +898,24 @@ class ObjectMgr
  1732.  
  1733.          int GetOrNewIndexForLocale(LocaleConstant loc);
  1734.  
  1735. +        VehicleDataMap mVehicleData;
  1736. +        VehicleSeatDataMap mVehicleSeatData;
  1737. +
  1738. +        uint32 GetSeatFlags(uint32 seatid)
  1739. +        {
  1740. +            VehicleSeatDataMap::iterator i = mVehicleSeatData.find(seatid);
  1741. +            if(i == mVehicleSeatData.end())
  1742. +                return NULL;
  1743. +            else
  1744. +                return i->second;
  1745. +        }
  1746. +        VehicleDataStructure const* GetVehicleData(uint32 entry) const
  1747. +        {
  1748. +            VehicleDataMap::const_iterator itr = mVehicleData.find(entry);
  1749. +            if(itr==mVehicleData.end()) return NULL;
  1750. +            return &itr->second;
  1751. +        }
  1752. +
  1753.          SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const
  1754.          {
  1755.              return SpellClickInfoMapBounds(mSpellClickInfoMap.lower_bound(creature_id),mSpellClickInfoMap.upper_bound(creature_id));
  1756. @@ -921,6 +954,7 @@ class ObjectMgr
  1757.          ObjectGuidGenerator<HIGHGUID_ITEM>       m_ItemGuids;
  1758.          ObjectGuidGenerator<HIGHGUID_GAMEOBJECT> m_GameobjectGuids;
  1759.          ObjectGuidGenerator<HIGHGUID_CORPSE>     m_CorpseGuids;
  1760. +        ObjectGuidGenerator<HIGHGUID_VEHICLE>    m_VehicleGuids;
  1761.  
  1762.          QuestMap            mQuestTemplates;
  1763.  
  1764. @@ -977,6 +1011,7 @@ class ObjectMgr
  1765.          void CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids);
  1766.          void LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment);
  1767.          void ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
  1768. +        void ConvertCreatureAddonPassengers(CreatureDataAddon* addon, char const* table, char const* guidEntryStr);
  1769.          void LoadQuestRelationsHelper(QuestRelations& map,char const* table);
  1770.  
  1771.          MailLevelRewardMap m_mailLevelRewardMap;
  1772. diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp
  1773. index 13ae079..950753c 100644
  1774. --- a/src/game/Opcodes.cpp
  1775. +++ b/src/game/Opcodes.cpp
  1776. @@ -1168,10 +1168,10 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
  1777.      /*0x473*/ { "CMSG_CHAR_CUSTOMIZE",                          STATUS_AUTHED,   &WorldSession::HandleCharCustomize             },
  1778.      /*0x474*/ { "SMSG_CHAR_CUSTOMIZE",                          STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1779.      /*0x475*/ { "SMSG_PET_RENAMEABLE",                          STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1780. -    /*0x476*/ { "CMSG_REQUEST_VEHICLE_EXIT",                    STATUS_NEVER,    &WorldSession::Handle_NULL                     },
  1781. -    /*0x477*/ { "CMSG_REQUEST_VEHICLE_PREV_SEAT",               STATUS_NEVER,    &WorldSession::Handle_NULL                     },
  1782. -    /*0x478*/ { "CMSG_REQUEST_VEHICLE_NEXT_SEAT",               STATUS_NEVER,    &WorldSession::Handle_NULL                     },
  1783. -    /*0x479*/ { "CMSG_REQUEST_VEHICLE_SWITCH_SEAT",             STATUS_NEVER,    &WorldSession::Handle_NULL                     },
  1784. +    /*0x476*/ { "CMSG_REQUEST_VEHICLE_EXIT",                    STATUS_LOGGEDIN, &WorldSession::HandleRequestVehicleExit        },
  1785. +    /*0x477*/ { "CMSG_REQUEST_VEHICLE_PREV_SEAT",               STATUS_LOGGEDIN, &WorldSession::HandleRequestVehiclePrevSeat    },
  1786. +    /*0x478*/ { "CMSG_REQUEST_VEHICLE_NEXT_SEAT",               STATUS_LOGGEDIN, &WorldSession::HandleRequestVehicleNextSeat    },
  1787. +    /*0x479*/ { "CMSG_REQUEST_VEHICLE_SWITCH_SEAT",             STATUS_LOGGEDIN, &WorldSession::HandleRequestVehicleSwitchSeat  },
  1788.      /*0x47A*/ { "CMSG_PET_LEARN_TALENT",                        STATUS_LOGGEDIN, &WorldSession::HandlePetLearnTalent            },
  1789.      /*0x47B*/ { "CMSG_PET_UNLEARN_TALENTS",                     STATUS_NEVER,    &WorldSession::Handle_NULL                     },
  1790.      /*0x47C*/ { "SMSG_SET_PHASE_SHIFT",                         STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1791. @@ -1205,7 +1205,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
  1792.      /*0x498*/ { "SMSG_SERVER_FIRST_ACHIEVEMENT",                STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1793.      /*0x499*/ { "SMSG_PET_LEARNED_SPELL",                       STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1794.      /*0x49A*/ { "SMSG_PET_REMOVED_SPELL",                       STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1795. -    /*0x49B*/ { "CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE",      STATUS_NEVER,    &WorldSession::Handle_NULL                     },
  1796. +    /*0x49B*/ { "CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE",      STATUS_LOGGEDIN, &WorldSession::HandleChangeSeatsOnControlledVehicle},
  1797.      /*0x49C*/ { "CMSG_HEARTH_AND_RESURRECT",                    STATUS_LOGGEDIN, &WorldSession::HandleHearthandResurrect        },
  1798.      /*0x49D*/ { "SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA",    STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1799.      /*0x49E*/ { "SMSG_CRITERIA_DELETED",                        STATUS_NEVER,    &WorldSession::Handle_ServerSide               },
  1800. diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
  1801. index 9881020..294439b 100644
  1802. --- a/src/game/Pet.cpp
  1803. +++ b/src/game/Pet.cpp
  1804. @@ -39,7 +39,7 @@ char const* petTypeSuffix[MAX_PET_TYPE] =
  1805.  
  1806.  Pet::Pet(PetType type) :
  1807.  Creature(CREATURE_SUBTYPE_PET), m_removed(false), m_petType(type), m_happinessTimer(7500), m_duration(0), m_resetTalentsCost(0),
  1808. -m_bonusdamage(0), m_resetTalentsTime(0), m_usedTalentCount(0), m_auraUpdateMask(0), m_loading(false),
  1809. +m_bonusdamage(0), m_resetTalentsTime(0), m_usedTalentCount(0), m_loading(false),
  1810.  m_declinedname(NULL), m_petModeFlags(PET_MODE_DEFAULT)
  1811.  {
  1812.      m_name = "Pet";
  1813. diff --git a/src/game/Pet.h b/src/game/Pet.h
  1814. index 2e35117..c811825 100644
  1815. --- a/src/game/Pet.h
  1816. +++ b/src/game/Pet.h
  1817. @@ -235,10 +235,6 @@ class Pet : public Creature
  1818.          time_t  m_resetTalentsTime;
  1819.          uint32  m_usedTalentCount;
  1820.  
  1821. -        const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
  1822. -        void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
  1823. -        void ResetAuraUpdateMask() { m_auraUpdateMask = 0; }
  1824. -
  1825.          // overwrite Creature function for name localization back to WorldObject version without localization
  1826.          const char* GetNameForLocaleIdx(int32 locale_idx) const { return WorldObject::GetNameForLocaleIdx(locale_idx); }
  1827.  
  1828. @@ -250,7 +246,6 @@ class Pet : public Creature
  1829.          PetType m_petType;
  1830.          int32   m_duration;                                 // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
  1831.          int32   m_bonusdamage;
  1832. -        uint64  m_auraUpdateMask;
  1833.          bool    m_loading;
  1834.  
  1835.          DeclinedName *m_declinedname;
  1836. diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp
  1837. index 9ae70b7..652ed9c 100644
  1838. --- a/src/game/PetHandler.cpp
  1839. +++ b/src/game/PetHandler.cpp
  1840. @@ -286,7 +286,7 @@ void WorldSession::HandlePetNameQuery( WorldPacket & recv_data )
  1841.  
  1842.  void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
  1843.  {
  1844. -    Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(petguid);
  1845. +    Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
  1846.      if(!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
  1847.          return;
  1848.  
  1849. @@ -318,7 +318,12 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
  1850.  
  1851.      recv_data >> petguid;
  1852.  
  1853. -    Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(petguid);
  1854. +    // FIXME: charmed case
  1855. +    //Pet* pet = ObjectAccessor::Instance().GetPet(petguid);
  1856. +    if(ObjectAccessor::FindPlayer(petguid))
  1857. +        return;
  1858. +
  1859. +    Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);
  1860.  
  1861.      if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
  1862.      {
  1863. @@ -506,7 +511,8 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
  1864.          return;
  1865.  
  1866.      // pet/charmed
  1867. -    if (Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(guid))
  1868. +    Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
  1869. +    if(pet)
  1870.      {
  1871.          if(pet->isPet())
  1872.          {
  1873. @@ -560,29 +566,32 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
  1874.      uint8  state;                                           //1 for on, 0 for off
  1875.      recvPacket >> guid >> spellid >> state;
  1876.  
  1877. -    if(!_player->GetPet() && !_player->GetCharm())
  1878. +    if (!_player->GetPet() && !_player->GetCharm())
  1879.          return;
  1880.  
  1881. -    Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(guid);
  1882. +    if(ObjectAccessor::FindPlayer(guid))
  1883. +        return;
  1884.  
  1885. -    if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
  1886. +    Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
  1887. +
  1888. +    if (!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
  1889.      {
  1890.          sLog.outError( "HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() );
  1891.          return;
  1892.      }
  1893.  
  1894.      // do not add not learned spells/ passive spells
  1895. -    if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
  1896. +    if (!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
  1897.          return;
  1898.  
  1899.      CharmInfo *charmInfo = pet->GetCharmInfo();
  1900. -    if(!charmInfo)
  1901. +    if (!charmInfo)
  1902.      {
  1903.          sLog.outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
  1904.          return;
  1905.      }
  1906.  
  1907. -    if(pet->isCharmed())
  1908. +    if (pet->isCharmed())
  1909.                                                              //state can be used as boolean
  1910.          pet->GetCharmInfo()->ToggleCreatureAutocast(spellid, state);
  1911.      else
  1912. @@ -607,7 +616,10 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
  1913.      if (!_player->GetPet() && !_player->GetCharm())
  1914.          return;
  1915.  
  1916. -    Creature* pet = _player->GetMap()->GetCreatureOrPetOrVehicle(guid);
  1917. +    if (GUID_HIPART(guid) == HIGHGUID_PLAYER)
  1918. +        return;
  1919. +
  1920. +    Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
  1921.  
  1922.      if (!pet || (pet != _player->GetPet() && pet!= _player->GetCharm()))
  1923.      {
  1924. diff --git a/src/game/Player.cpp b/src/game/Player.cpp
  1925. index e2bb2a0..ed86e6b 100644
  1926. --- a/src/game/Player.cpp
  1927. +++ b/src/game/Player.cpp
  1928. @@ -364,7 +364,6 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
  1929.      // group is initialized in the reference constructor
  1930.      SetGroupInvite(NULL);
  1931.      m_groupUpdateMask = 0;
  1932. -    m_auraUpdateMask = 0;
  1933.  
  1934.      duel = NULL;
  1935.  
  1936. @@ -487,6 +486,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputa
  1937.      m_summon_z = 0.0f;
  1938.  
  1939.      m_mover = this;
  1940. +    m_mover_in_queve = NULL;
  1941.  
  1942.      m_miniPet = 0;
  1943.      m_contestedPvPTimer = 0;
  1944. @@ -1649,6 +1649,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
  1945.          m_transport = NULL;
  1946.          m_movementInfo.SetTransportData(0, 0.0f, 0.0f, 0.0f, 0.0f, 0, -1);
  1947.      }
  1948. +    ExitVehicle();
  1949.  
  1950.      // The player was ported to another map and looses the duel immediately.
  1951.      // We have to perform this check before the teleport, otherwise the
  1952. @@ -2129,7 +2130,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
  1953.          return NULL;
  1954.  
  1955.      // exist (we need look pets also for some interaction (quest/etc)
  1956. -    Creature *unit = GetMap()->GetCreatureOrPetOrVehicle(guid);
  1957. +    Creature *unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
  1958.      if (!unit)
  1959.          return NULL;
  1960.  
  1961. @@ -7883,6 +7884,9 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
  1962.          case 3703:
  1963.              NumberOfFields = 11;
  1964.              break;
  1965. +        case 4384:
  1966. +            NumberOfFields = 30;
  1967. +            break;
  1968.          default:
  1969.              NumberOfFields = 12;
  1970.              break;
  1971. @@ -8201,6 +8205,41 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
  1972.              break;
  1973.          case 3703:                                          // Shattrath City
  1974.              break;
  1975. +        case 4384:                                          // SA
  1976. +            /*if (bg && bg->GetTypeID() == BATTLEGROUND_SA)
  1977. +                bg->FillInitialWorldStates(data);
  1978. +            else
  1979. +            {*/
  1980. +                // 1-3 A defend, 4-6 H defend, 7-9 unk defend, 1 - ok, 2 - half destroyed, 3 - destroyed
  1981. +                data << uint32(0xf09) << uint32(0x4);       // 7  3849 Gate of Temple
  1982. +                data << uint32(0xe36) << uint32(0x4);       // 8  3638 Gate of Yellow Moon
  1983. +                data << uint32(0xe27) << uint32(0x4);       // 9  3623 Gate of Green Emerald
  1984. +                data << uint32(0xe24) << uint32(0x4);       // 10 3620 Gate of Blue Sapphire
  1985. +                data << uint32(0xe21) << uint32(0x4);       // 11 3617 Gate of Red Sun
  1986. +                data << uint32(0xe1e) << uint32(0x4);       // 12 3614 Gate of Purple Ametyst
  1987. +
  1988. +                data << uint32(0xdf3) << uint32(0x0);       // 13 3571 bonus timer (1 - on, 0 - off)
  1989. +                data << uint32(0xded) << uint32(0x0);       // 14 3565 Horde Attacker
  1990. +                data << uint32(0xdec) << uint32(0x1);       // 15 3564 Alliance Attacker
  1991. +                // End Round (timer), better explain this by example, eg. ends in 19:59 -> A:BC
  1992. +                data << uint32(0xde9) << uint32(0x9);       // 16 3561 C
  1993. +                data << uint32(0xde8) << uint32(0x5);       // 17 3560 B
  1994. +                data << uint32(0xde7) << uint32(0x19);      // 18 3559 A
  1995. +                data << uint32(0xe35) << uint32(0x1);       // 19 3637 East g - Horde control
  1996. +                data << uint32(0xe34) << uint32(0x1);       // 20 3636 West g - Horde control
  1997. +                data << uint32(0xe33) << uint32(0x1);       // 21 3635 South g - Horde control
  1998. +                data << uint32(0xe32) << uint32(0x0);       // 22 3634 East g - Alliance control
  1999. +                data << uint32(0xe31) << uint32(0x0);       // 23 3633 West g - Alliance control
  2000. +                data << uint32(0xe30) << uint32(0x0);       // 24 3632 South g - Alliance control
  2001. +                data << uint32(0xe2f) << uint32(0x1);       // 25 3631 Chamber of Ancients - Horde control
  2002. +                data << uint32(0xe2e) << uint32(0x0);       // 26 3630 Chamber of Ancients - Alliance control
  2003. +                data << uint32(0xe2d) << uint32(0x0);       // 27 3629 Beach1 - Horde control
  2004. +                data << uint32(0xe2c) << uint32(0x0);       // 28 3628 Beach2 - Horde control
  2005. +                data << uint32(0xe2b) << uint32(0x1);       // 29 3627 Beach1 - Alliance control
  2006. +                data << uint32(0xe2a) << uint32(0x1);       // 30 3626 Beach2 - Alliance control
  2007. +                // and many unks...
  2008. +            //}
  2009. +            break;
  2010.          default:
  2011.              data << uint32(0x914) << uint32(0x0);           // 7
  2012.              data << uint32(0x913) << uint32(0x0);           // 8
  2013. @@ -12741,7 +12780,8 @@ void Player::PrepareQuestMenu( uint64 guid )
  2014.      QuestRelations* pObjectQIR;
  2015.  
  2016.      // pets also can have quests
  2017. -    if (Creature *pCreature = GetMap()->GetCreatureOrPetOrVehicle(guid))
  2018. +    Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, guid);
  2019. +    if( pCreature )
  2020.      {
  2021.          pObject = (Object*)pCreature;
  2022.          pObjectQR  = &sObjectMgr.mCreatureQuestRelations;
  2023. @@ -12835,7 +12875,8 @@ void Player::SendPreparedQuest(uint64 guid)
  2024.          std::string title = "";
  2025.  
  2026.          // need pet case for some quests
  2027. -        if (Creature *pCreature = GetMap()->GetCreatureOrPetOrVehicle(guid))
  2028. +        Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
  2029. +        if (pCreature)
  2030.          {
  2031.              uint32 textid = GetGossipTextId(pCreature);
  2032.  
  2033. @@ -12899,7 +12940,8 @@ Quest const * Player::GetNextQuest( uint64 guid, Quest const *pQuest )
  2034.      QuestRelations* pObjectQR;
  2035.      QuestRelations* pObjectQIR;
  2036.  
  2037. -    if (Creature *pCreature = GetMap()->GetCreatureOrPetOrVehicle(guid))
  2038. +    Creature *pCreature = ObjectAccessor::GetCreatureOrPetOrVehicle(*this,guid);
  2039. +    if( pCreature )
  2040.      {
  2041.          pObject = (Object*)pCreature;
  2042.          pObjectQR  = &sObjectMgr.mCreatureQuestRelations;
  2043. @@ -17656,7 +17698,10 @@ void Player::HandleStealthedUnitsDetection()
  2044.                  // target aura duration for caster show only if target exist at caster client
  2045.                  // send data at target visibility change (adding to client)
  2046.                  if((*i)!=this && (*i)->isType(TYPEMASK_UNIT))
  2047. +                {
  2048.                      SendAurasForTarget(*i);
  2049. +                    BuildVehicleInfo(*i);
  2050. +                }
  2051.              }
  2052.          }
  2053.          else
  2054. @@ -17691,7 +17736,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
  2055.      if(npc)
  2056.      {
  2057.          // not let cheating with start flight mounted
  2058. -        if(IsMounted())
  2059. +        if(IsMounted() || GetVehicleGUID())
  2060.          {
  2061.              WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4);
  2062.              data << uint32(ERR_TAXIPLAYERALREADYMOUNTED);
  2063. @@ -17720,6 +17765,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
  2064.      else
  2065.      {
  2066.          RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
  2067. +        ExitVehicle();
  2068.  
  2069.          if( m_ShapeShiftFormSpellId && m_form != FORM_BATTLESTANCE && m_form != FORM_BERSERKERSTANCE && m_form != FORM_DEFENSIVESTANCE && m_form != FORM_SHADOW )
  2070.              RemoveAurasDueToSpell(m_ShapeShiftFormSpellId);
  2071. @@ -18847,7 +18893,10 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe
  2072.              // target aura duration for caster show only if target exist at caster client
  2073.              // send data at target visibility change (adding to client)
  2074.              if(target!=this && target->isType(TYPEMASK_UNIT))
  2075. +            {
  2076.                  SendAurasForTarget((Unit*)target);
  2077. +                BuildVehicleInfo((Unit*)target);
  2078. +            }
  2079.  
  2080.              if(target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isAlive())
  2081.                  ((Creature*)target)->SendMonsterMoveWithSpeedToCurrentDestination(this);
  2082. @@ -18918,13 +18967,22 @@ void Player::InitPrimaryProfessions()
  2083.  void Player::SendComboPoints()
  2084.  {
  2085.      Unit *combotarget = ObjectAccessor::GetUnit(*this, m_comboTarget);
  2086. -    if (combotarget)
  2087. -    {
  2088. -        WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1);
  2089. -        data << combotarget->GetPackGUID();
  2090. -        data << uint8(m_comboPoints);
  2091. -        GetSession()->SendPacket(&data);
  2092. -    }
  2093. +    if (!combotarget)
  2094. +        return;
  2095. +
  2096. +    WorldPacket data;
  2097. +    if(!GetVehicleGUID())
  2098. +        data.Initialize(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1);
  2099. +    else{
  2100. +       if(Unit *vehicle = ObjectAccessor::GetUnit(*this, GetVehicleGUID()))
  2101. +       {
  2102. +           data.Initialize(SMSG_PET_UPDATE_COMBO_POINTS, vehicle->GetPackGUID().size()+combotarget->GetPackGUID().size()+1);
  2103. +           data << vehicle->GetPackGUID();
  2104. +       }else return;
  2105. +    }
  2106. +    data << combotarget->GetPackGUID();
  2107. +    data << uint8(m_comboPoints);
  2108. +    GetSession()->SendPacket(&data);
  2109.  }
  2110.  
  2111.  void Player::AddComboPoints(Unit* target, int8 count)
  2112. @@ -19043,10 +19101,18 @@ void Player::SendInitialPacketsBeforeAddToMap()
  2113.          m_movementInfo.AddMovementFlag(MOVEFLAG_FLYING);
  2114.  
  2115.      m_mover = this;
  2116. +    m_mover_in_queve = NULL;
  2117.  }
  2118.  
  2119.  void Player::SendInitialPacketsAfterAddToMap()
  2120.  {
  2121. +    if(getClass() == CLASS_DEATH_KNIGHT)
  2122. +        ResyncRunes(MAX_RUNES);
  2123. +
  2124. +    WorldPacket data0(SMSG_SET_PHASE_SHIFT, 4);
  2125. +    data0 << uint32(GetPhaseMask());
  2126. +    GetSession()->SendPacket(&data0);
  2127. +
  2128.      // update zone
  2129.      uint32 newzone, newarea;
  2130.      GetZoneAndAreaId(newzone,newarea);
  2131. @@ -19086,6 +19152,14 @@ void Player::SendInitialPacketsAfterAddToMap()
  2132.          SendMessageToSet(&data2,true);
  2133.      }
  2134.  
  2135. +    if(GetVehicleGUID())
  2136. +    {
  2137. +        WorldPacket data3(SMSG_FORCE_MOVE_ROOT, 10);
  2138. +        data3 << GetPackGUID();
  2139. +        data3 << (uint32)((m_SeatData.s_flags & SF_CAN_CAST) ? 2 : 0);
  2140. +        SendMessageToSet(&data3,true);
  2141. +    }
  2142. +
  2143.      SendAurasForTarget(this);
  2144.      SendEnchantmentDurations();                             // must be after add to map
  2145.      SendItemDurations();                                    // must be after add to map
  2146. @@ -19100,7 +19174,7 @@ void Player::SendUpdateToOutOfRangeGroupMembers()
  2147.  
  2148.      m_groupUpdateMask = GROUP_UPDATE_FLAG_NONE;
  2149.      m_auraUpdateMask = 0;
  2150. -    if(Pet *pet = GetPet())
  2151. +    if(Unit *pet = GetCharmOrPet())
  2152.          pet->ResetAuraUpdateMask();
  2153.  }
  2154.  
  2155. @@ -19518,7 +19592,7 @@ void Player::UpdateForQuestWorldObjects()
  2156.          }
  2157.          else if (itr->IsCreatureOrVehicle())
  2158.          {
  2159. -            Creature *obj = GetMap()->GetCreatureOrPetOrVehicle(*itr);
  2160. +            Creature *obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
  2161.              if(!obj)
  2162.                  continue;
  2163.  
  2164. @@ -19803,6 +19877,8 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
  2165.          {
  2166.              /// not get Xp in PvP or no not gray players in group
  2167.              xp = (PvP || !not_gray_member_with_max_level) ? 0 : MaNGOS::XP::Gain(not_gray_member_with_max_level, pVictim);
  2168. +            if(GetVehicleGUID() && !(m_SeatData.v_flags & VF_GIVE_EXP))
  2169. +                xp = 0;
  2170.  
  2171.              /// skip in check PvP case (for speed, not used)
  2172.              bool is_raid = PvP ? false : sMapStore.LookupEntry(GetMapId())->IsRaid() && pGroup->isRaidGroup();
  2173. @@ -19856,6 +19932,8 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
  2174.      else                                                    // if (!pGroup)
  2175.      {
  2176.          xp = PvP ? 0 : MaNGOS::XP::Gain(this, pVictim);
  2177. +        if(GetVehicleGUID() && !(m_SeatData.v_flags & VF_GIVE_EXP))
  2178. +            xp = 0;
  2179.  
  2180.          // honor can be in PvP and !PvP (racial leader) cases
  2181.          if(RewardHonor(pVictim,1))
  2182. @@ -20338,96 +20416,28 @@ void Player::ApplyGlyphs(bool apply)
  2183.          ApplyGlyph(i,apply);
  2184.  }
  2185.  
  2186. -void Player::EnterVehicle(Vehicle *vehicle)
  2187. +void Player::SendEnterVehicle(Vehicle *vehicle)
  2188.  {
  2189. -    VehicleEntry const *ve = sVehicleStore.LookupEntry(vehicle->GetVehicleId());
  2190. -    if(!ve)
  2191. -        return;
  2192. -
  2193. -    VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(ve->m_seatID[0]);
  2194. -    if(!veSeat)
  2195. -        return;
  2196. -
  2197. -    vehicle->SetCharmerGUID(GetGUID());
  2198. -    vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  2199. -    vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
  2200. -    vehicle->setFaction(getFaction());
  2201. -
  2202. -    SetCharm(vehicle);                                      // charm
  2203. -    SetFarSightGUID(vehicle->GetGUID());                    // set view
  2204. -
  2205. -    SetClientControl(vehicle, 1);                           // redirect controls to vehicle
  2206. -    SetMover(vehicle);
  2207. +    m_movementInfo.AddMovementFlag(MOVEFLAG_ONTRANSPORT);
  2208. +    m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT);
  2209.  
  2210. -    WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
  2211. -    GetSession()->SendPacket(&data);
  2212. -
  2213. -    data.Initialize(MSG_MOVE_TELEPORT_ACK, 30);
  2214. -    data << GetPackGUID();
  2215. -    data << uint32(0);                                      // counter?
  2216. -    data << uint32(MOVEFLAG_ONTRANSPORT);                   // transport
  2217. -    data << uint16(0);                                      // special flags
  2218. -    data << uint32(getMSTime());                            // time
  2219. -    data << vehicle->GetPositionX();                        // x
  2220. -    data << vehicle->GetPositionY();                        // y
  2221. -    data << vehicle->GetPositionZ();                        // z
  2222. -    data << vehicle->GetOrientation();                      // o
  2223. -    // transport part, TODO: load/calculate seat offsets
  2224. -    data << uint64(vehicle->GetGUID());                     // transport guid
  2225. -    data << float(veSeat->m_attachmentOffsetX);             // transport offsetX
  2226. -    data << float(veSeat->m_attachmentOffsetY);             // transport offsetY
  2227. -    data << float(veSeat->m_attachmentOffsetZ);             // transport offsetZ
  2228. -    data << float(0);                                       // transport orientation
  2229. -    data << uint32(getMSTime());                            // transport time
  2230. -    data << uint8(0);                                       // seat
  2231. -    // end of transport part
  2232. -    data << uint32(0);                                      // fall time
  2233. -    GetSession()->SendPacket(&data);
  2234. -
  2235. -    data.Initialize(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1);
  2236. -    data << uint64(vehicle->GetGUID());
  2237. -    data << uint16(0);
  2238. -    data << uint32(0);
  2239. -    data << uint32(0x00000101);
  2240. -
  2241. -    for(uint32 i = 0; i < 10; ++i)
  2242. -        data << uint16(0) << uint8(0) << uint8(i+8);
  2243. -
  2244. -    data << uint8(0);
  2245. -    data << uint8(0);
  2246. -    GetSession()->SendPacket(&data);
  2247. -}
  2248. -
  2249. -void Player::ExitVehicle(Vehicle *vehicle)
  2250. -{
  2251. -    vehicle->SetCharmerGUID(0);
  2252. -    vehicle->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  2253. -    vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
  2254. -    vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
  2255. -
  2256. -    SetCharm(NULL);
  2257. -    SetFarSightGUID(0);
  2258. -
  2259. -    SetClientControl(vehicle, 0);
  2260. -    SetMover(NULL);
  2261. +    if(m_transport)                                         // if we were on a transport, leave
  2262. +    {
  2263. +        m_transport->RemovePassenger(this);
  2264. +        m_transport = NULL;
  2265. +    }
  2266. +    // vehicle is our transport from now, if we get to zeppelin or boat
  2267. +    // with vehicle, ONLY my vehicle will be passenger on that transport
  2268. +    // player ----> vehicle ----> zeppelin
  2269.  
  2270. -    WorldPacket data(MSG_MOVE_TELEPORT_ACK, 30);
  2271. -    data << GetPackGUID();
  2272. -    data << uint32(0);                                      // counter?
  2273. -    data << uint32(MOVEFLAG_ROOT);                          // fly unk
  2274. -    data << uint16(MOVEFLAG2_UNK4);                         // special flags
  2275. -    data << uint32(getMSTime());                            // time
  2276. -    data << vehicle->GetPositionX();                        // x
  2277. -    data << vehicle->GetPositionY();                        // y
  2278. -    data << vehicle->GetPositionZ();                        // z
  2279. -    data << vehicle->GetOrientation();                      // o
  2280. -    data << uint32(0);                                      // fall time
  2281. +    WorldPacket data(SMSG_BREAK_TARGET, 8);
  2282. +    data << vehicle->GetPackGUID();
  2283.      GetSession()->SendPacket(&data);
  2284.  
  2285. -    RemovePetActionBar();
  2286. -
  2287. -    // maybe called at dummy aura remove?
  2288. -    // CastSpell(this, 45472, true);                        // Parachute
  2289. +    /*data.Initialize(SMSG_UNKNOWN_1191, 12);
  2290. +    data << uint64(GetGUID());
  2291. +    data << uint64(vehicle->GetVehicleId());                      // not sure
  2292. +    SendMessageToSet(&data, true);*/
  2293.  }
  2294.  
  2295.  bool Player::isTotalImmune()
  2296. @@ -20492,7 +20502,8 @@ void Player::ConvertRune(uint8 index, RuneType newType)
  2297.  
  2298.  void Player::ResyncRunes(uint8 count)
  2299.  {
  2300. -    WorldPacket data(SMSG_RESYNC_RUNES, count * 2);
  2301. +    WorldPacket data(SMSG_RESYNC_RUNES, 4 + count * 2);
  2302. +    data << uint32(count + 1);
  2303.      for(uint32 i = 0; i < count; ++i)
  2304.      {
  2305.          data << uint8(GetCurrentRune(i));                   // rune type
  2306. diff --git a/src/game/Player.h b/src/game/Player.h
  2307. index e381363..c78f40b 100644
  2308. --- a/src/game/Player.h
  2309. +++ b/src/game/Player.h
  2310. @@ -2110,6 +2110,10 @@ class MANGOS_DLL_SPEC Player : public Unit
  2311.          bool HasMovementFlag(MovementFlags f) const;        // for script access to m_movementInfo.HasMovementFlag
  2312.          void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode);
  2313.          Unit *m_mover;
  2314. +        Unit *m_mover_in_queve;
  2315. +
  2316. +        void SetMoverInQueve(Unit* pet) {m_mover_in_queve = pet ? pet : this; }
  2317. +
  2318.          void SetFallInformation(uint32 time, float z)
  2319.          {
  2320.              m_lastFallTime = time;
  2321. @@ -2129,8 +2133,8 @@ class MANGOS_DLL_SPEC Player : public Unit
  2322.          void SetClientControl(Unit* target, uint8 allowMove);
  2323.          void SetMover(Unit* target) { m_mover = target ? target : this; }
  2324.  
  2325. -        void EnterVehicle(Vehicle *vehicle);
  2326. -        void ExitVehicle(Vehicle *vehicle);
  2327. +        // vehicle system
  2328. +        void SendEnterVehicle(Vehicle *vehicle);
  2329.  
  2330.          uint64 GetFarSight() const { return GetUInt64Value(PLAYER_FARSIGHT); }
  2331.          void SetFarSightGUID(uint64 guid);
  2332. @@ -2232,8 +2236,6 @@ class MANGOS_DLL_SPEC Player : public Unit
  2333.          uint8 GetSubGroup() const { return m_group.getSubGroup(); }
  2334.          uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; }
  2335.          void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; }
  2336. -        const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
  2337. -        void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
  2338.          Player* GetNextRandomRaidMember(float radius);
  2339.          PartyResult CanUninviteFromGroup() const;
  2340.          // BattleGround Group System
  2341. @@ -2479,7 +2481,6 @@ class MANGOS_DLL_SPEC Player : public Unit
  2342.          GroupReference m_originalGroup;
  2343.          Group *m_groupInvite;
  2344.          uint32 m_groupUpdateMask;
  2345. -        uint64 m_auraUpdateMask;
  2346.  
  2347.          uint64 m_miniPet;
  2348.  
  2349. diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp
  2350. index d484ceb..902fe7b 100644
  2351. --- a/src/game/QuestHandler.cpp
  2352. +++ b/src/game/QuestHandler.cpp
  2353. @@ -647,7 +647,7 @@ void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket
  2354.          if (itr->IsCreatureOrPet())
  2355.          {
  2356.              // need also pet quests case support
  2357. -            Creature *questgiver = GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(*itr);
  2358. +            Creature *questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(),*itr);
  2359.              if(!questgiver || questgiver->IsHostileTo(_player))
  2360.                  continue;
  2361.              if(!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
  2362. diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp
  2363. index 2ea08d4..0b9bdd3 100644
  2364. --- a/src/game/ReactorAI.cpp
  2365. +++ b/src/game/ReactorAI.cpp
  2366. @@ -116,6 +116,7 @@ ReactorAI::EnterEvadeMode()
  2367.          DEBUG_LOG("Creature stopped attacking, victim %s [guid=%u]", victim->isAlive() ? "out run him" : "is dead", m_creature->GetGUIDLow());
  2368.      }
  2369.  
  2370. +    m_creature->ExitVehicle();
  2371.      m_creature->RemoveAllAuras();
  2372.      m_creature->DeleteThreatList();
  2373.      i_victimGuid = 0;
  2374. diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
  2375. index bcbca0b..f388554 100644
  2376. --- a/src/game/SharedDefines.h
  2377. +++ b/src/game/SharedDefines.h
  2378. @@ -2447,6 +2447,29 @@ enum DiminishingGroup
  2379.      DIMINISHING_LIMITONLY
  2380.  };
  2381.  
  2382. +
  2383. +/* NOTE : vehicles and seats has their own flags in DBC,
  2384. +but for now, they are too unknown for us, to use them */
  2385. +enum CustomVehicleFLags
  2386. +{
  2387. +    VF_CANT_MOVE                    = 0x0001,                   // vehicle cant move, only turn, maybe handle by some auras?
  2388. +    VF_FACTION                      = 0x0002,                   // vehicle retain its own faction
  2389. +    VF_DESPAWN_NPC                  = 0x0004,                   // vehicle will delete npc on spellclick
  2390. +    VF_DESPAWN_AT_LEAVE             = 0x0008,                   // vehicle will be deleted when rider leaves
  2391. +    VF_CAN_BE_HEALED                = 0x0010,                   // vehicle can be healed
  2392. +    VF_GIVE_EXP                     = 0x0020,                   // vehicle will give exp for killing enemies
  2393. +    VF_MOVEMENT                     = 0x0040,                   // vehicle will move on its own, not depending on rider, however rider can cast spells
  2394. +    VF_NON_SELECTABLE               = 0x0080                    // vehicle will be not selectable after rider enter
  2395. +    //VF_HAS_FUEL                     = 0x0100,                   // TODO : find out what energy type is fuel and implement this
  2396. +};
  2397. +
  2398. +enum CustomVehicleSeatFLags
  2399. +{
  2400. +    SF_MAIN_RIDER                   = 0x0001,                   // the one who controlls vehicle, can also cast spells
  2401. +    SF_UNATTACKABLE                 = 0x0002,                   // hided inside, and unatackable until vehicle is destroyed
  2402. +    SF_CAN_CAST                     = 0x0004,                   // player/npc can rotate, and cast OWN spells
  2403. +    SF_UNACCESSIBLE                 = 0x0008                    // player cant enter this seat by normal way (only by script)
  2404. +};
  2405.  enum ResponseCodes
  2406.  {
  2407.      RESPONSE_SUCCESS                                       = 0x00,
  2408. diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
  2409. index d44df94..021b89a 100644
  2410. --- a/src/game/Spell.cpp
  2411. +++ b/src/game/Spell.cpp
  2412. @@ -1406,8 +1406,11 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
  2413.          case TARGET_SELF2:
  2414.          case TARGET_AREAEFFECT_CUSTOM:
  2415.          case TARGET_AREAEFFECT_CUSTOM_2:
  2416. +        {
  2417. +            // used for targeting gameobjects
  2418.              targetUnitMap.push_back(m_caster);
  2419.              break;
  2420. +        }
  2421.          case TARGET_RANDOM_ENEMY_CHAIN_IN_AREA:
  2422.          {
  2423.              m_targets.m_targetMask = 0;
  2424. @@ -1655,6 +1658,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
  2425.                      break;
  2426.                  default:
  2427.                      FillAreaTargets(targetUnitMap, m_targets.m_destX, m_targets.m_destY, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE);
  2428. +
  2429. +                    // exclude caster (this can be important if this not original caster, for example vehicle)
  2430. +                    targetUnitMap.remove(m_caster);
  2431.                      break;
  2432.              }
  2433.              break;
  2434. @@ -3046,7 +3052,7 @@ void Spell::finish(bool ok)
  2435.          m_caster->resetAttackTimer(RANGED_ATTACK);*/
  2436.  
  2437.      // Clear combo at finish state
  2438. -    if(m_caster->GetTypeId() == TYPEID_PLAYER && NeedsComboPoints(m_spellInfo))
  2439. +    if((m_caster->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_caster)->isVehicle()) && NeedsComboPoints(m_spellInfo))
  2440.      {
  2441.          // Not drop combopoints if negative spell and if any miss on enemy exist
  2442.          bool needDrop = true;
  2443. @@ -3062,7 +3068,12 @@ void Spell::finish(bool ok)
  2444.              }
  2445.          }
  2446.          if (needDrop)
  2447. -            ((Player*)m_caster)->ClearComboPoints();
  2448. +        {
  2449. +            if(m_caster->GetTypeId() == TYPEID_PLAYER)
  2450. +                ((Player*)m_caster)->ClearComboPoints();
  2451. +            else
  2452. +                ((Player*)m_caster->GetCharmer())->ClearComboPoints();
  2453. +        }
  2454.      }
  2455.  
  2456.      // potions disabled by client, send event "not in combat" if need
  2457. @@ -4256,11 +4267,16 @@ SpellCastResult Spell::CheckCast(bool strict)
  2458.          return locRes;
  2459.  
  2460.      // not let players cast spells at mount (and let do it to creatures)
  2461. -    if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell &&
  2462. +    if ((m_caster->IsMounted() || m_caster->GetVehicleGUID()) && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell &&
  2463.          !IsPassiveSpell(m_spellInfo->Id) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED))
  2464.      {
  2465.          if (m_caster->isInFlight())
  2466.              return SPELL_FAILED_NOT_ON_TAXI;
  2467. +        else if(m_caster->GetVehicleGUID())
  2468. +        {
  2469. +            if(!(m_caster->m_SeatData.s_flags & SF_CAN_CAST))
  2470. +                return SPELL_FAILED_NOT_MOUNTED;
  2471. +        }
  2472.          else
  2473.              return SPELL_FAILED_NOT_MOUNTED;
  2474.      }
  2475. @@ -5080,7 +5096,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
  2476.                                                              //TARGET_DUELVSPLAYER is positive AND negative
  2477.                      duelvsplayertar |= (m_spellInfo->EffectImplicitTargetA[j] == TARGET_DUELVSPLAYER);
  2478.                  }
  2479. -                if(m_caster->IsFriendlyTo(target) && !duelvsplayertar)
  2480. +                if(m_caster->IsFriendlyTo(_target) && !duelvsplayertar)
  2481.                  {
  2482.                      return SPELL_FAILED_BAD_TARGETS;
  2483.                  }
  2484. @@ -5091,6 +5107,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
  2485.              return SPELL_FAILED_NOT_READY;
  2486.      }
  2487.  
  2488. +    // NOTE : this is done twice, also in spell->prepare(&(spell->m_targets));
  2489.      return CheckCast(true);
  2490.  }
  2491.  
  2492. @@ -6024,7 +6041,8 @@ bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff )
  2493.          if ((!m_IsTriggeredSpell || target != m_targets.getUnitTarget()) &&
  2494.              target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) &&
  2495.              m_spellInfo->EffectImplicitTargetA[eff] != TARGET_SCRIPT &&
  2496. -            m_spellInfo->EffectImplicitTargetB[eff] != TARGET_SCRIPT )
  2497. +            m_spellInfo->EffectImplicitTargetB[eff] != TARGET_SCRIPT &&
  2498. +            m_spellInfo->EffectImplicitTargetA[eff] != TARGET_MASTER )
  2499.              return false;
  2500.      }
  2501.  
  2502. diff --git a/src/game/Spell.h b/src/game/Spell.h
  2503. index 86520d6..f3d4043 100644
  2504. --- a/src/game/Spell.h
  2505. +++ b/src/game/Spell.h
  2506. @@ -356,6 +356,8 @@ class Spell
  2507.          void EffectPlayMusic(SpellEffectIndex eff_idx);
  2508.          void EffectSpecCount(SpellEffectIndex eff_idx);
  2509.          void EffectActivateSpec(SpellEffectIndex eff_idx);
  2510. +        void EffectSummonVehicle(SpellEffectIndex eff_idx);
  2511. +        void EffectDamageBuilding(SpellEffectIndex eff_idx);
  2512.  
  2513.          Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID = 0, Spell** triggeringContainer = NULL );
  2514.          ~Spell();
  2515. diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
  2516. index 3ee1892..d6b9a46 100644
  2517. --- a/src/game/SpellAuras.cpp
  2518. +++ b/src/game/SpellAuras.cpp
  2519. @@ -3627,7 +3627,7 @@ void Aura::HandleModPossess(bool apply, bool Real)
  2520.              m_target->GetMotionMaster()->Clear();
  2521.              m_target->GetMotionMaster()->MoveIdle();
  2522.          }
  2523. -        else if(m_target->GetTypeId() == TYPEID_PLAYER)
  2524. +        else if(m_target->GetTypeId() == TYPEID_PLAYER && !m_target->GetVehicleGUID())
  2525.          {
  2526.              ((Player*)m_target)->SetClientControl(m_target, 0);
  2527.          }
  2528. @@ -3644,7 +3644,7 @@ void Aura::HandleModPossess(bool apply, bool Real)
  2529.          m_target->SetCharmerGUID(0);
  2530.          p_caster->InterruptSpell(CURRENT_CHANNELED_SPELL);  // the spell is not automatically canceled when interrupted, do it now
  2531.  
  2532. -        if(m_target->GetTypeId() == TYPEID_PLAYER)
  2533. +        if(m_target->GetTypeId() == TYPEID_PLAYER && !m_target->GetVehicleGUID())
  2534.          {
  2535.              ((Player*)m_target)->setFactionForRace(m_target->getRace());
  2536.              ((Player*)m_target)->SetClientControl(m_target, 1);
  2537. @@ -3913,10 +3913,13 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
  2538.              m_target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client
  2539.          }
  2540.  
  2541. -        WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
  2542. -        data << m_target->GetPackGUID();
  2543. -        data << uint32(0);
  2544. -        m_target->SendMessageToSet(&data, true);
  2545. +        if(!m_target->hasUnitState(UNIT_STAT_ON_VEHICLE))
  2546. +        {
  2547. +            WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
  2548. +            data << m_target->GetPackGUID();
  2549. +            data << uint32(0);
  2550. +            m_target->SendMessageToSet(&data,true);
  2551. +        }
  2552.  
  2553.          // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
  2554.          if(GetId() == 39837)
  2555. @@ -3966,7 +3969,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
  2556.          m_target->clearUnitState(UNIT_STAT_STUNNED);
  2557.          m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
  2558.  
  2559. -        if(!m_target->hasUnitState(UNIT_STAT_ROOT))         // prevent allow move if have also root effect
  2560. +        if(!m_target->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_ON_VEHICLE))         // prevent allow move if have also root effect
  2561.          {
  2562.              if(m_target->getVictim() && m_target->isAlive())
  2563.                  m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
  2564. @@ -4181,11 +4184,13 @@ void Aura::HandleAuraModRoot(bool apply, bool Real)
  2565.  
  2566.          if(m_target->GetTypeId() == TYPEID_PLAYER)
  2567.          {
  2568. -            WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
  2569. -            data << m_target->GetPackGUID();
  2570. -            data << (uint32)2;
  2571. -            m_target->SendMessageToSet(&data, true);
  2572. -
  2573. +            if(!m_target->hasUnitState(UNIT_STAT_ON_VEHICLE))
  2574. +            {
  2575. +                WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
  2576. +                data << m_target->GetPackGUID();
  2577. +                data << (uint32)2;
  2578. +                m_target->SendMessageToSet(&data,true);
  2579. +            }
  2580.              //Clear unit movement flags
  2581.              ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE);
  2582.          }
  2583. @@ -4223,7 +4228,7 @@ void Aura::HandleAuraModRoot(bool apply, bool Real)
  2584.  
  2585.          m_target->clearUnitState(UNIT_STAT_ROOT);
  2586.  
  2587. -        if(!m_target->hasUnitState(UNIT_STAT_STUNNED))      // prevent allow move if have also stun effect
  2588. +        if(!m_target->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_ON_VEHICLE))      // prevent allow move if have also stun effect
  2589.          {
  2590.              if(m_target->getVictim() && m_target->isAlive())
  2591.                  m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
  2592. @@ -4254,7 +4259,7 @@ void Aura::HandleAuraModSilence(bool apply, bool Real)
  2593.                  if(spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
  2594.                      // Stop spells on prepare or casting state
  2595.                      m_target->InterruptSpell(CurrentSpellTypes(i), false);
  2596. -    }
  2597. +   }
  2598.      else
  2599.      {
  2600.          // Real remove called after current aura remove from lists, check if other similar auras active
  2601. @@ -6699,7 +6704,7 @@ void Aura::HandleModRatingFromStat(bool apply, bool Real)
  2602.  
  2603.  void Aura::HandleForceMoveForward(bool apply, bool Real)
  2604.  {
  2605. -    if(!Real || m_target->GetTypeId() != TYPEID_PLAYER)
  2606. +    if(!Real)
  2607.          return;
  2608.      if(apply)
  2609.          m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
  2610. @@ -8054,28 +8059,36 @@ void Aura::HandleArenaPreparation(bool apply, bool Real)
  2611.   */
  2612.  void Aura::HandleAuraControlVehicle(bool apply, bool Real)
  2613.  {
  2614. -    if(!Real)
  2615. -        return;
  2616. +     if(!Real)
  2617. +         return;
  2618.  
  2619. -    Unit *player = GetCaster();
  2620. +    Unit *caster = GetCaster();
  2621.      Vehicle *vehicle = dynamic_cast<Vehicle*>(m_target);
  2622. -    if(!player || player->GetTypeId() != TYPEID_PLAYER || !vehicle)
  2623. +    if(!caster || !vehicle)
  2624. +        return;
  2625. +
  2626. +    // this can happen due to wrong caster/target spell handling
  2627. +    // note : SPELL_AURA_CONTROL_VEHICLE can have EffectImplicitTargetA
  2628. +    // TARGET_SCRIPT, TARGET_DUELVSPLAYER.. etc
  2629. +    if(caster->GetGUID() == vehicle->GetGUID())
  2630.          return;
  2631.  
  2632.      if (apply)
  2633.      {
  2634. -        if(Pet *pet = player->GetPet())
  2635. -            pet->Remove(PET_SAVE_AS_CURRENT);
  2636. -        ((Player*)player)->EnterVehicle(vehicle);
  2637. +        if(caster->GetTypeId() == TYPEID_PLAYER)
  2638. +        {
  2639. +            WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
  2640. +            ((Player*)caster)->GetSession()->SendPacket(&data);
  2641. +        }
  2642. +        // if we leave and enter again, this will refresh
  2643. +        int32 duration = GetSpellMaxDuration(GetSpellProto());
  2644. +        if(duration > 0)
  2645. +            vehicle->SetSpawnDuration(duration);
  2646.      }
  2647.      else
  2648.      {
  2649. -        SpellEntry const *spell = GetSpellProto();
  2650. -
  2651.          // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
  2652. -        player->RemoveAurasDueToSpell(spell->Id);
  2653. -
  2654. -        ((Player*)player)->ExitVehicle(vehicle);
  2655. +        caster->RemoveAurasDueToSpell(GetId());
  2656.      }
  2657.  }
  2658.  
  2659. diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
  2660. index 6db4481..0697bbb 100644
  2661. --- a/src/game/SpellEffects.cpp
  2662. +++ b/src/game/SpellEffects.cpp
  2663. @@ -54,6 +54,7 @@
  2664.  #include "ScriptCalls.h"
  2665.  #include "SkillDiscovery.h"
  2666.  #include "Formulas.h"
  2667. +#include "Vehicle.h"
  2668.  
  2669.  pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
  2670.  {
  2671. @@ -144,9 +145,9 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
  2672.      &Spell::EffectStuck,                                    // 84 SPELL_EFFECT_STUCK
  2673.      &Spell::EffectSummonPlayer,                             // 85 SPELL_EFFECT_SUMMON_PLAYER
  2674.      &Spell::EffectActivateObject,                           // 86 SPELL_EFFECT_ACTIVATE_OBJECT
  2675. -    &Spell::EffectNULL,                                     // 87 SPELL_EFFECT_WMO_DAMAGE (57 spells in 3.3.2)
  2676. -    &Spell::EffectNULL,                                     // 88 SPELL_EFFECT_WMO_REPAIR (2 spells in 3.3.2)
  2677. -    &Spell::EffectNULL,                                     // 89 SPELL_EFFECT_WMO_CHANGE (7 spells in 3.3.2)
  2678. +    &Spell::EffectDamageBuilding,                           // 87 SPELL_EFFECT_WMO_DAMAGE
  2679. +    &Spell::EffectUnused,                                   // 88 SPELL_EFFECT_WMO_REPAIR
  2680. +    &Spell::EffectUnused,                                   // 89 SPELL_EFFECT_WMO_CHANGE
  2681.      &Spell::EffectKillCreditPersonal,                       // 90 SPELL_EFFECT_KILL_CREDIT              Kill credit but only for single person
  2682.      &Spell::EffectUnused,                                   // 91 SPELL_EFFECT_THREAT_ALL               one spell: zzOLDBrainwash
  2683.      &Spell::EffectEnchantHeldItem,                          // 92 SPELL_EFFECT_ENCHANT_HELD_ITEM
  2684. @@ -3768,7 +3769,7 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)
  2685.                  case SUMMON_PROP_TYPE_SIEGE_VEH:
  2686.                  case SUMMON_PROP_TYPE_DRAKE_VEH:
  2687.                      // TODO
  2688. -                    // EffectSummonVehicle(i);
  2689. +                    EffectSummonVehicle(eff_idx);
  2690.                      break;
  2691.                  default:
  2692.                      sLog.outError("EffectSummonType: Unhandled summon type %u", summon_prop->Type);
  2693. @@ -3797,7 +3798,7 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)
  2694.          case SUMMON_PROP_GROUP_VEHICLE:
  2695.          {
  2696.              // TODO
  2697. -            // EffectSummonVehicle(i);
  2698. +            EffectSummonVehicle(eff_idx);
  2699.              break;
  2700.          }
  2701.          default:
  2702. @@ -3805,7 +3806,6 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)
  2703.              break;
  2704.      }
  2705.  }
  2706. -
  2707.  void Spell::DoSummon(SpellEffectIndex eff_idx)
  2708.  {
  2709.      if (m_caster->GetPetGUID())
  2710. @@ -6148,13 +6148,15 @@ void Spell::EffectAddComboPoints(SpellEffectIndex /*eff_idx*/)
  2711.      if(!unitTarget)
  2712.          return;
  2713.  
  2714. -    if(m_caster->GetTypeId() != TYPEID_PLAYER)
  2715. -        return;
  2716. -
  2717.      if(damage <= 0)
  2718.          return;
  2719.  
  2720. -    ((Player*)m_caster)->AddComboPoints(unitTarget, damage);
  2721. +    if(m_caster->GetTypeId() != TYPEID_PLAYER)
  2722. +    {
  2723. +        if(((Creature*)m_caster)->isVehicle())
  2724. +            ((Player*)m_caster->GetCharmer())->AddComboPoints(unitTarget, damage);
  2725. +    }else
  2726. +        ((Player*)m_caster)->AddComboPoints(unitTarget, damage);
  2727.  }
  2728.  
  2729.  void Spell::EffectDuel(SpellEffectIndex eff_idx)
  2730. @@ -7406,6 +7408,54 @@ void Spell::EffectRenamePet(SpellEffectIndex /*eff_idx*/)
  2731.      unitTarget->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED);
  2732.  }
  2733.  
  2734. +void Spell::EffectSummonVehicle(SpellEffectIndex eff_idx)
  2735. +{
  2736. +    uint32 creature_entry = m_spellInfo->EffectMiscValue[eff_idx];
  2737. +    if(!creature_entry)
  2738. +        return;
  2739. +
  2740. +    float px, py, pz;
  2741. +    // If dest location if present
  2742. +    if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
  2743. +    {
  2744. +        // Summon unit in dest location
  2745. +        px = m_targets.m_destX;
  2746. +        py = m_targets.m_destY;
  2747. +        pz = m_targets.m_destZ;
  2748. +    }
  2749. +    // Summon if dest location not present near caster
  2750. +    else
  2751. +        m_caster->GetClosePoint(px,py,pz,3.0f);
  2752. +
  2753. +    Vehicle *v = m_caster->SummonVehicle(creature_entry, px, py, pz, m_caster->GetOrientation());
  2754. +    if(!v)
  2755. +        return;
  2756. +
  2757. +    v->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
  2758. +    v->SetCreatorGUID(m_caster->GetGUID());
  2759. +
  2760. +    if(damage)
  2761. +    {
  2762. +        m_caster->CastSpell(v, damage, true);
  2763. +        m_caster->EnterVehicle(v, 0);
  2764. +    }
  2765. +    int32 duration = GetSpellMaxDuration(m_spellInfo);
  2766. +    if(duration > 0)
  2767. +        v->SetSpawnDuration(duration);
  2768. +}
  2769. +
  2770. +void Spell::EffectDamageBuilding(SpellEffectIndex eff_idx)
  2771. +{
  2772. +    if(!gameObjTarget)
  2773. +        return;
  2774. +
  2775. +    if(gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
  2776. +        return;
  2777. +
  2778. +    // NOTE : this can be increased by scaling stat system in vehicles
  2779. +    gameObjTarget->DealSiegeDamage(damage);
  2780. +}
  2781. +
  2782.  void Spell::EffectPlayMusic(SpellEffectIndex eff_idx)
  2783.  {
  2784.      if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
  2785. diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp
  2786. index 2d8c2e1..b85882c 100644
  2787. --- a/src/game/SpellHandler.cpp
  2788. +++ b/src/game/SpellHandler.cpp
  2789. @@ -27,6 +27,7 @@
  2790.  #include "Spell.h"
  2791.  #include "ScriptCalls.h"
  2792.  #include "Totem.h"
  2793. +#include "Vehicle.h"
  2794.  #include "SpellAuras.h"
  2795.  
  2796.  void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
  2797. @@ -298,6 +299,11 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
  2798.          return;
  2799.      }
  2800.  
  2801. +    // vehicle spells are handled by CMSG_PET_CAST_SPELL,
  2802. +    // but player is still able to cast own spells
  2803. +    if(_player->GetCharmGUID() && _player->GetCharmGUID() == _player->GetVehicleGUID())
  2804. +        mover = _player;
  2805. +
  2806.      sLog.outDebug("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i",
  2807.          spellId, cast_count, unk_flags, (uint32)recvPacket.size());
  2808.  
  2809. @@ -460,7 +466,7 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
  2810.          return;
  2811.      }
  2812.  
  2813. -    Creature* pet = GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(guid);
  2814. +    Creature* pet=ObjectAccessor::GetCreatureOrPetOrVehicle(*_player,guid);
  2815.  
  2816.      if(!pet)
  2817.      {
  2818. @@ -548,20 +554,67 @@ void WorldSession::HandleSpellClick( WorldPacket & recv_data )
  2819.      if (_player->isInCombat())                              // client prevent click and set different icon at combat state
  2820.          return;
  2821.  
  2822. -    Creature *unit = _player->GetMap()->GetCreatureOrPetOrVehicle(guid);
  2823. +    Creature *unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
  2824.      if (!unit || unit->isInCombat())                        // client prevent click and set different icon at combat state
  2825.          return;
  2826.  
  2827. -    SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(unit->GetEntry());
  2828. -    for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
  2829. +    if(!_player->IsWithinDistInMap(unit, 10))
  2830. +        return;
  2831. +
  2832. +    // cheater?
  2833. +    if(!unit->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK))
  2834. +        return;
  2835. +
  2836. +    uint32 vehicleId = 0;
  2837. +    CreatureDataAddon const *cainfo = unit->GetCreatureAddon();
  2838. +    if(cainfo)
  2839. +        vehicleId = cainfo->vehicle_id;
  2840. +
  2841. +    // handled other (hacky) way to avoid overwriting auras
  2842. +    if(vehicleId || unit->isVehicle())
  2843.      {
  2844. -        if (itr->second.IsFitToRequirements(_player))
  2845. +        if(!unit->isAlive())
  2846. +            return;
  2847. +
  2848. +        if(_player->GetVehicleGUID())
  2849. +            return;
  2850. +
  2851. +        // create vehicle if no one present and kill the original creature to avoid double, triple etc spawns
  2852. +        if(!unit->isVehicle())
  2853.          {
  2854. -            Unit *caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit;
  2855. -            Unit *target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit;
  2856. +            Vehicle *v = _player->SummonVehicle(unit->GetEntry(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), vehicleId);
  2857. +            if(!v)
  2858. +                return;
  2859.  
  2860. -            caster->CastSpell(target, itr->second.spellId, true);
  2861. +            if(v->GetVehicleFlags() & VF_DESPAWN_NPC)
  2862. +            {
  2863. +                v->SetSpawnDuration(unit->GetRespawnDelay()*IN_MILISECONDS);
  2864. +                unit->setDeathState(JUST_DIED);
  2865. +                unit->RemoveCorpse();
  2866. +                unit->SetHealth(0);
  2867. +            }
  2868. +            unit = v;
  2869.          }
  2870. +
  2871. +        if(((Vehicle*)unit)->GetVehicleData())
  2872. +            if(uint32 r_aura = ((Vehicle*)unit)->GetVehicleData()->req_aura)
  2873. +                if(!_player->HasAura(r_aura))
  2874. +                    return;
  2875. +
  2876. +        _player->EnterVehicle((Vehicle*)unit, 0);
  2877.      }
  2878. -}
  2879. +    else
  2880. +    {
  2881. +        SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(unit->GetEntry());
  2882. +        for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
  2883. +        {
  2884. +            if (itr->second.IsFitToRequirements(_player))
  2885. +            {
  2886. +                Unit *caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit;
  2887. +                Unit *target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit;
  2888.  
  2889. +                caster->CastSpell(target, itr->second.spellId, true);
  2890. +            }
  2891. +        }
  2892. +    }
  2893. +}
  2894. diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
  2895. index b9af5d0..935d1f9 100644
  2896. --- a/src/game/Unit.cpp
  2897. +++ b/src/game/Unit.cpp
  2898. @@ -46,6 +46,7 @@
  2899.  #include "CellImpl.h"
  2900.  #include "Path.h"
  2901.  #include "Traveller.h"
  2902. +#include "Vehicle.h"
  2903.  #include "VMapFactory.h"
  2904.  #include "MovementGenerator.h"
  2905.  
  2906. @@ -250,6 +251,9 @@ Unit::Unit()
  2907.      // remove aurastates allowing special moves
  2908.      for(int i=0; i < MAX_REACTIVE; ++i)
  2909.          m_reactiveTimer[i] = 0;
  2910. +
  2911. +    m_auraUpdateMask = 0;
  2912. +    m_vehicleGUID = 0;
  2913.  }
  2914.  
  2915.  Unit::~Unit()
  2916. @@ -8008,15 +8012,10 @@ void Unit::setPowerType(Powers new_powertype)
  2917.          if(((Player*)this)->GetGroup())
  2918.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POWER_TYPE);
  2919.      }
  2920. -    else if(((Creature*)this)->isPet())
  2921. +    else if(Unit* owner = GetCharmerOrOwner())
  2922.      {
  2923. -        Pet *pet = ((Pet*)this);
  2924. -        if(pet->isControlled())
  2925. -        {
  2926. -            Unit *owner = GetOwner();
  2927. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  2928. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE);
  2929. -        }
  2930. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  2931. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_POWER_TYPE);
  2932.      }
  2933.  
  2934.      switch(new_powertype)
  2935. @@ -8324,6 +8323,14 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
  2936.      if(GetTypeId()==TYPEID_PLAYER && IsMounted())
  2937.          return false;
  2938.  
  2939. +    // player (also npc?) cannot attack on vehicle
  2940. +    if(GetTypeId()==TYPEID_PLAYER && GetVehicleGUID())
  2941. +        return false;
  2942. +
  2943. +    // player (also npc?) cannot attack on vehicle
  2944. +    if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isVehicle() && GetCharmerGUID())
  2945. +        return false;
  2946. +
  2947.      // nobody can attack GM in GM-mode
  2948.      if(victim->GetTypeId()==TYPEID_PLAYER)
  2949.      {
  2950. @@ -10794,6 +10801,11 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio)
  2951.      }
  2952.  
  2953.      float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus;
  2954. +
  2955. +    //apply creature's base speed
  2956. +    if(GetTypeId() == TYPEID_UNIT)
  2957. +        bonus *= ((Creature*)this)->GetBaseSpeed();
  2958. +
  2959.      // now we ready for speed calculation
  2960.      float speed  = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus;
  2961.  
  2962. @@ -10990,6 +11002,7 @@ void Unit::setDeathState(DeathState s)
  2963.  
  2964.      if (s == JUST_DIED)
  2965.      {
  2966. +        ExitVehicle();
  2967.          RemoveAllAurasOnDeath();
  2968.          RemoveGuardians();
  2969.          UnsummonAllTotems();
  2970. @@ -11215,7 +11228,8 @@ bool Unit::SelectHostileTarget()
  2971.      }
  2972.  
  2973.      // enter in evade mode in other case
  2974. -    ((Creature*)this)->AI()->EnterEvadeMode();
  2975. +    if(!((Creature*)this)->isVehicle())
  2976. +        ((Creature*)this)->AI()->EnterEvadeMode();
  2977.  
  2978.      return false;
  2979.  }
  2980. @@ -11226,7 +11240,14 @@ bool Unit::SelectHostileTarget()
  2981.  
  2982.  int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex effect_index, int32 effBasePoints, Unit const* target)
  2983.  {
  2984. -    Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL;
  2985. +    Player* unitPlayer;
  2986. +
  2987. +    if(GetTypeId() == TYPEID_PLAYER)
  2988. +        unitPlayer = (Player*)this;
  2989. +    else if(((Creature*)this)->isVehicle())
  2990. +        unitPlayer = (Player*)GetCharmer();
  2991. +    else
  2992. +        unitPlayer = NULL;
  2993.  
  2994.      uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0;
  2995.  
  2996. @@ -11281,7 +11302,14 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, SpellEffectIndex
  2997.  
  2998.  int32 Unit::CalculateSpellDuration(SpellEntry const* spellProto, SpellEffectIndex effect_index, Unit const* target)
  2999.  {
  3000. -    Player* unitPlayer = (GetTypeId() == TYPEID_PLAYER) ? (Player*)this : NULL;
  3001. +    Player* unitPlayer;
  3002. +
  3003. +    if(GetTypeId() == TYPEID_PLAYER)
  3004. +        unitPlayer = (Player*)this;
  3005. +    else if(((Creature*)this)->isVehicle())
  3006. +        unitPlayer = (Player*)GetCharmer();
  3007. +    else
  3008. +        unitPlayer = NULL;
  3009.  
  3010.      uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0;
  3011.  
  3012. @@ -11691,15 +11719,10 @@ void Unit::SetHealth(uint32 val)
  3013.          if(((Player*)this)->GetGroup())
  3014.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_HP);
  3015.      }
  3016. -    else if(((Creature*)this)->isPet())
  3017. +    else if(Unit* owner = GetCharmerOrOwner())
  3018.      {
  3019. -        Pet *pet = ((Pet*)this);
  3020. -        if(pet->isControlled())
  3021. -        {
  3022. -            Unit *owner = GetOwner();
  3023. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3024. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP);
  3025. -        }
  3026. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3027. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP);
  3028.      }
  3029.  }
  3030.  
  3031. @@ -11714,15 +11737,10 @@ void Unit::SetMaxHealth(uint32 val)
  3032.          if(((Player*)this)->GetGroup())
  3033.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_HP);
  3034.      }
  3035. -    else if(((Creature*)this)->isPet())
  3036. +    else if(Unit* owner = GetCharmerOrOwner())
  3037.      {
  3038. -        Pet *pet = ((Pet*)this);
  3039. -        if(pet->isControlled())
  3040. -        {
  3041. -            Unit *owner = GetOwner();
  3042. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3043. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP);
  3044. -        }
  3045. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3046. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP);
  3047.      }
  3048.  
  3049.      if(val < health)
  3050. @@ -11758,20 +11776,19 @@ void Unit::SetPower(Powers power, uint32 val)
  3051.          if(((Player*)this)->GetGroup())
  3052.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER);
  3053.      }
  3054. -    else if(((Creature*)this)->isPet())
  3055. +    else if(Unit* owner = GetCharmerOrOwner())
  3056.      {
  3057. -        Pet *pet = ((Pet*)this);
  3058. -        if(pet->isControlled())
  3059. -        {
  3060. -            Unit *owner = GetOwner();
  3061. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3062. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
  3063. -        }
  3064. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3065. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
  3066.  
  3067. -        // Update the pet's character sheet with happiness damage bonus
  3068. -        if(pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS)
  3069. +        if(((Creature*)this)->isPet())
  3070.          {
  3071. -            pet->UpdateDamagePhysical(BASE_ATTACK);
  3072. +            Pet *pet = ((Pet*)this);
  3073. +            // Update the pet's character sheet with happiness damage bonus
  3074. +            if(pet->getPetType() == HUNTER_PET && power == POWER_HAPPINESS)
  3075. +            {
  3076. +                pet->UpdateDamagePhysical(BASE_ATTACK);
  3077. +            }
  3078.          }
  3079.      }
  3080.  }
  3081. @@ -11787,15 +11804,10 @@ void Unit::SetMaxPower(Powers power, uint32 val)
  3082.          if(((Player*)this)->GetGroup())
  3083.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER);
  3084.      }
  3085. -    else if(((Creature*)this)->isPet())
  3086. +    else if(Unit* owner = GetCharmerOrOwner())
  3087.      {
  3088. -        Pet *pet = ((Pet*)this);
  3089. -        if(pet->isControlled())
  3090. -        {
  3091. -            Unit *owner = GetOwner();
  3092. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3093. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER);
  3094. -        }
  3095. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3096. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER);
  3097.      }
  3098.  
  3099.      if(val < cur_power)
  3100. @@ -11812,15 +11824,10 @@ void Unit::ApplyPowerMod(Powers power, uint32 val, bool apply)
  3101.          if(((Player*)this)->GetGroup())
  3102.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_CUR_POWER);
  3103.      }
  3104. -    else if(((Creature*)this)->isPet())
  3105. +    else if(Unit* owner = GetCharmerOrOwner())
  3106.      {
  3107. -        Pet *pet = ((Pet*)this);
  3108. -        if(pet->isControlled())
  3109. -        {
  3110. -            Unit *owner = GetOwner();
  3111. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3112. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
  3113. -        }
  3114. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3115. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_POWER);
  3116.      }
  3117.  }
  3118.  
  3119. @@ -11834,15 +11841,10 @@ void Unit::ApplyMaxPowerMod(Powers power, uint32 val, bool apply)
  3120.          if(((Player*)this)->GetGroup())
  3121.              ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_MAX_POWER);
  3122.      }
  3123. -    else if(((Creature*)this)->isPet())
  3124. +    else if(Unit* owner = GetCharmerOrOwner())
  3125.      {
  3126. -        Pet *pet = ((Pet*)this);
  3127. -        if(pet->isControlled())
  3128. -        {
  3129. -            Unit *owner = GetOwner();
  3130. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3131. -                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER);
  3132. -        }
  3133. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3134. +            ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_POWER);
  3135.      }
  3136.  }
  3137.  
  3138. @@ -11896,6 +11898,7 @@ void Unit::RemoveFromWorld()
  3139.  
  3140.  void Unit::CleanupsBeforeDelete()
  3141.  {
  3142. +    ExitVehicle();                                          // make sure we always leave vehicle, otherwise it will crash
  3143.      if(m_uint32Values)                                      // only for fully created object
  3144.      {
  3145.          InterruptNonMeleeSpells(true);
  3146. @@ -12633,8 +12636,12 @@ void Unit::SetFeared(bool apply, uint64 const& casterGUID, uint32 spellID, uint3
  3147.          }
  3148.      }
  3149.  
  3150. -    if (GetTypeId() == TYPEID_PLAYER)
  3151. +    if (GetTypeId() == TYPEID_PLAYER && !GetVehicleGUID())
  3152.          ((Player*)this)->SetClientControl(this, !apply);
  3153. +
  3154. +    if (Unit* owner = GetCharmer())
  3155. +        if (owner->GetTypeId() == TYPEID_PLAYER)
  3156. +            ((Player*)owner)->SetClientControl(this, !apply);
  3157.  }
  3158.  
  3159.  void Unit::SetConfused(bool apply, uint64 const& casterGUID, uint32 spellID)
  3160. @@ -12663,8 +12670,12 @@ void Unit::SetConfused(bool apply, uint64 const& casterGUID, uint32 spellID)
  3161.          }
  3162.      }
  3163.  
  3164. -    if(GetTypeId() == TYPEID_PLAYER)
  3165. +    if(GetTypeId() == TYPEID_PLAYER && !GetVehicleGUID())
  3166.          ((Player*)this)->SetClientControl(this, !apply);
  3167. +
  3168. +    if (Unit* owner = GetCharmer())
  3169. +        if (owner->GetTypeId() == TYPEID_PLAYER)
  3170. +            ((Player*)owner)->SetClientControl(this, !apply);
  3171.  }
  3172.  
  3173.  void Unit::SetFeignDeath(bool apply, uint64 const& casterGUID, uint32 /*spellID*/)
  3174. @@ -12768,13 +12779,9 @@ void Unit::SetDisplayId(uint32 modelId)
  3175.  {
  3176.      SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
  3177.  
  3178. -    if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
  3179. +    if(Unit *owner = GetCharmerOrOwner())
  3180.      {
  3181. -        Pet *pet = ((Pet*)this);
  3182. -        if(!pet->isControlled())
  3183. -            return;
  3184. -        Unit *owner = GetOwner();
  3185. -        if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3186. +        if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3187.              ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
  3188.      }
  3189.  }
  3190. @@ -13073,16 +13080,14 @@ void Unit::UpdateAuraForGroup(uint8 slot)
  3191.              player->SetAuraUpdateMask(slot);
  3192.          }
  3193.      }
  3194. -    else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
  3195. +    else if(GetTypeId() == TYPEID_UNIT)
  3196.      {
  3197. -        Pet *pet = ((Pet*)this);
  3198. -        if(pet->isControlled())
  3199. +        if(Unit *owner = GetCharmerOrOwner())
  3200.          {
  3201. -            Unit *owner = GetOwner();
  3202. -            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3203. +            if((owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
  3204.              {
  3205.                  ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS);
  3206. -                pet->SetAuraUpdateMask(slot);
  3207. +                SetAuraUpdateMask(slot);
  3208.              }
  3209.          }
  3210.      }
  3211. @@ -13389,6 +13394,7 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca
  3212.          ((Player*)this)->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0));
  3213.      else
  3214.      {
  3215. +        ExitVehicle();
  3216.          Creature* c = (Creature*)this;
  3217.          // Creature relocation acts like instant movement generator, so current generator expects interrupt/reset calls to react properly
  3218.          if (!c->GetMotionMaster()->empty())
  3219. @@ -13459,6 +13465,134 @@ struct SetPvPHelper
  3220.      void operator()(Unit* unit) const { unit->SetPvP(state); }
  3221.      bool state;
  3222.  };
  3223. +void Unit::EnterVehicle(Vehicle *vehicle, int8 seat_id, bool force)
  3224. +{
  3225. +    // dont allow multiple vehicles
  3226. +    ExitVehicle();
  3227. +
  3228. +    RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
  3229. +    // NOTE : shapeshift too?
  3230. +
  3231. +    Vehicle *v = vehicle->FindFreeSeat(&seat_id, force);
  3232. +    if(!v)
  3233. +        return;
  3234. +
  3235. +    VehicleEntry const *ve = sVehicleStore.LookupEntry(v->GetVehicleId());
  3236. +    if(!ve)
  3237. +        return;
  3238. +
  3239. +    VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(ve->m_seatID[seat_id]);
  3240. +    if(!veSeat)
  3241. +        return;
  3242. +
  3243. +    m_SeatData.OffsetX = (veSeat->m_attachmentOffsetX + v->GetObjectSize()) * GetFloatValue(OBJECT_FIELD_SCALE_X);      // transport offsetX
  3244. +    m_SeatData.OffsetY = (veSeat->m_attachmentOffsetY + v->GetObjectSize()) * GetFloatValue(OBJECT_FIELD_SCALE_X);      // transport offsetY
  3245. +    m_SeatData.OffsetZ = (veSeat->m_attachmentOffsetZ + v->GetObjectSize()) * GetFloatValue(OBJECT_FIELD_SCALE_X);      // transport offsetZ
  3246. +    m_SeatData.Orientation = veSeat->m_passengerYaw;                                                                    // NOTE : needs confirmation
  3247. +    m_SeatData.c_time = v->GetCreationTime();
  3248. +    m_SeatData.dbc_seat = veSeat->m_ID;
  3249. +    m_SeatData.seat = seat_id;
  3250. +    m_SeatData.s_flags = sObjectMgr.GetSeatFlags(veSeat->m_ID);
  3251. +    m_SeatData.v_flags = v->GetVehicleFlags();
  3252. +
  3253. +    addUnitState(UNIT_STAT_ON_VEHICLE);
  3254. +    InterruptNonMeleeSpells(false);
  3255. +
  3256. +    if(Pet *pet = GetPet())
  3257. +        pet->Remove(PET_SAVE_AS_CURRENT);
  3258. +
  3259. +    if(GetTypeId() == TYPEID_PLAYER)
  3260. +        ((Player*)this)->SendEnterVehicle(v);
  3261. +
  3262. +    WorldPacket data(SMSG_MONSTER_MOVE_TRANSPORT, 60);
  3263. +    data << GetPackGUID();
  3264. +    data << v->GetPackGUID();
  3265. +    data << uint8(m_SeatData.seat);
  3266. +    data << uint8(0);                                       // new in 3.1
  3267. +    data << v->GetPositionX() << v->GetPositionY() << v->GetPositionZ();
  3268. +    data << uint32(getMSTime());
  3269. +
  3270. +    data << uint8(4);                                       // unknown
  3271. +    data << float(0);                                       // facing angle
  3272. +
  3273. +    data << uint32(SPLINEFLAG_UNKNOWN9);
  3274. +
  3275. +    data << uint32(0);                                      // Time in between points
  3276. +    data << uint32(1);                                      // 1 single waypoint
  3277. +    data << m_SeatData.OffsetX;
  3278. +    data << m_SeatData.OffsetY;
  3279. +    data << m_SeatData.OffsetZ;
  3280. +    SendMessageToSet(&data, true);
  3281. +
  3282. +    v->AddPassenger(this, seat_id, force);
  3283. +}
  3284. +
  3285. +void Unit::ExitVehicle()
  3286. +{
  3287. +    if(uint64 vehicleGUID = GetVehicleGUID())
  3288. +    {
  3289. +        float v_size = 0.0f;
  3290. +        if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  3291. +        {
  3292. +            if(m_SeatData.s_flags & SF_MAIN_RIDER)
  3293. +            {
  3294. +                if(vehicle->GetVehicleFlags() & VF_DESPAWN_AT_LEAVE)
  3295. +                {
  3296. +                    // will be deleted at next update
  3297. +                    vehicle->SetSpawnDuration(1);
  3298. +                }
  3299. +            }
  3300. +            v_size = vehicle->GetObjectSize();
  3301. +            vehicle->RemovePassenger(this);
  3302. +        }
  3303. +        SetVehicleGUID(0);
  3304. +
  3305. +        clearUnitState(UNIT_STAT_ON_VEHICLE);
  3306. +
  3307. +        if(GetTypeId() == TYPEID_PLAYER)
  3308. +        {
  3309. +            ((Player*)this)->ResummonPetTemporaryUnSummonedIfAny();
  3310. +            ((Player*)this)->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT);
  3311. +            ((Player*)this)->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ROOT);
  3312. +        }
  3313. +
  3314. +        float x = GetPositionX();
  3315. +        float y = GetPositionY();
  3316. +        float z = GetPositionZ() + 2.0f;
  3317. +        GetClosePoint(x, y, z, 2.0f + v_size);
  3318. +        SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE, 0);
  3319. +    }
  3320. +}
  3321. +
  3322. +void Unit::BuildVehicleInfo(Unit *target)
  3323. +{
  3324. +    if(!target)
  3325. +        return;
  3326. +
  3327. +    if(!target->GetVehicleGUID())
  3328. +        return;
  3329. +
  3330. +    uint32 veh_time = getMSTimeDiff(target->m_SeatData.c_time,getMSTime());
  3331. +    WorldPacket data(MSG_MOVE_HEARTBEAT, 100);
  3332. +    data << target->GetPackGUID();
  3333. +    data << uint32(MOVEFLAG_ONTRANSPORT | MOVEFLAG_ROOT);
  3334. +    data << uint16(0);
  3335. +    data << uint32(getMSTime());
  3336. +    data << float(target->GetPositionX());
  3337. +    data << float(target->GetPositionY());
  3338. +    data << float(target->GetPositionZ());
  3339. +    data << float(target->GetOrientation());
  3340. +    data.appendPackGUID(target->GetVehicleGUID());
  3341. +    data << float(target->m_SeatData.OffsetX);
  3342. +    data << float(target->m_SeatData.OffsetY);
  3343. +    data << float(target->m_SeatData.OffsetZ);
  3344. +    data << float(target->m_SeatData.Orientation);
  3345. +    data << uint32(veh_time);
  3346. +    data << uint8 (target->m_SeatData.seat);
  3347. +    data << uint32(0);
  3348. +    if(GetTypeId() == TYPEID_PLAYER)
  3349. +        ((Player*)this)->GetSession()->SendPacket(&data);
  3350. +}
  3351.  
  3352.  void Unit::SetPvP( bool state )
  3353.  {
  3354. diff --git a/src/game/Unit.h b/src/game/Unit.h
  3355. index 8266046..4009664 100644
  3356. --- a/src/game/Unit.h
  3357. +++ b/src/game/Unit.h
  3358. @@ -300,6 +300,7 @@ class Pet;
  3359.  class Path;
  3360.  class PetAura;
  3361.  class Totem;
  3362. +class Vehicle;
  3363.  
  3364.  struct SpellImmune
  3365.  {
  3366. @@ -433,24 +434,25 @@ enum UnitState
  3367.      UNIT_STAT_FOLLOW_MOVE     = 0x00008000,
  3368.      UNIT_STAT_FLEEING         = 0x00010000,                     // FleeMovementGenerator/TimedFleeingMovementGenerator active/onstack
  3369.      UNIT_STAT_FLEEING_MOVE    = 0x00020000,
  3370. +    UNIT_STAT_ON_VEHICLE      = 0x00040000,                     // Unit is on vehicle
  3371.  
  3372.      // masks (only for check)
  3373.  
  3374.      // can't move currently
  3375. -    UNIT_STAT_CAN_NOT_MOVE    = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED,
  3376. +    UNIT_STAT_CAN_NOT_MOVE    = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED | UNIT_STAT_ON_VEHICLE,
  3377.  
  3378.      // stay by different reasons
  3379.      UNIT_STAT_NOT_MOVE        = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
  3380. -                                UNIT_STAT_DISTRACTED,
  3381. +                                UNIT_STAT_DISTRACTED | UNIT_STAT_ON_VEHICLE,
  3382.  
  3383.      // stay or scripted movement for effect( = in player case you can't move by client command)
  3384.      UNIT_STAT_NO_FREE_MOVE    = UNIT_STAT_ROOT | UNIT_STAT_STUNNED | UNIT_STAT_DIED |
  3385.                                  UNIT_STAT_IN_FLIGHT |
  3386. -                                UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
  3387. +                                UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_ON_VEHICLE,
  3388.  
  3389.      // not react at move in sight or other
  3390.      UNIT_STAT_CAN_NOT_REACT   = UNIT_STAT_STUNNED | UNIT_STAT_DIED |
  3391. -                                UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING,
  3392. +                                UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_ON_VEHICLE,
  3393.  
  3394.      // masks (for check or reset)
  3395.  
  3396. @@ -1073,6 +1075,24 @@ typedef std::set<uint64> GuardianPetList;
  3397.  
  3398.  struct SpellProcEventEntry;                                 // used only privately
  3399.  
  3400. +// vehicle system
  3401. +struct SeatData
  3402. +{
  3403. +    SeatData() : OffsetX(0.0f), OffsetY(0.0f),  OffsetZ(0.0f), Orientation(0.0f),
  3404. +                c_time(0), dbc_seat(0), seat(0), s_flags(0), v_flags(0) {}
  3405. +
  3406. +    float OffsetX;
  3407. +    float OffsetY;
  3408. +    float OffsetZ;
  3409. +    float Orientation;
  3410. +    uint32 c_time;
  3411. +    uint32 dbc_seat;
  3412. +    uint8 seat;
  3413. +    //custom, used as speedup
  3414. +    uint32 s_flags;
  3415. +    uint32 v_flags;
  3416. +};
  3417. +
  3418.  class MANGOS_DLL_SPEC Unit : public WorldObject
  3419.  {
  3420.      public:
  3421. @@ -1329,6 +1349,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
  3422.          }
  3423.          bool HasAura(uint32 spellId) const;
  3424.  
  3425. +        const uint64& GetAuraUpdateMask() const { return m_auraUpdateMask; }
  3426. +        void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
  3427. +        void ResetAuraUpdateMask() { m_auraUpdateMask = 0; }
  3428. +
  3429.          bool virtual HasSpell(uint32 /*spellID*/) const { return false; }
  3430.  
  3431.          bool HasStealthAura()      const { return HasAuraType(SPELL_AURA_MOD_STEALTH); }
  3432. @@ -1426,6 +1450,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
  3433.          Unit* GetCharm() const;
  3434.          void Uncharm();
  3435.          Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); }
  3436. +        Unit* GetCharmOrPet() const { return GetCharmGUID() ? GetCharm() : (Unit*)GetPet(); }
  3437.          Unit* GetCharmerOrOwnerOrSelf()
  3438.          {
  3439.              if(Unit* u = GetCharmerOrOwner())
  3440. @@ -1804,6 +1829,15 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
  3441.          // Movement info
  3442.          MovementInfo m_movementInfo;
  3443.  
  3444. +         // vehicle system
  3445. +         void EnterVehicle(Vehicle *vehicle, int8 seat_id, bool force = false);
  3446. +         void ExitVehicle();
  3447. +         uint64 GetVehicleGUID() { return m_vehicleGUID; }
  3448. +         void SetVehicleGUID(uint64 guid) { m_vehicleGUID = guid; }
  3449. +         // using extra variables to avoid problems with transports
  3450. +         SeatData m_SeatData;
  3451. +         void BuildVehicleInfo(Unit *target = NULL);
  3452. +
  3453.      protected:
  3454.          explicit Unit ();
  3455.  
  3456. @@ -1851,6 +1885,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
  3457.          uint32 m_reactiveTimer[MAX_REACTIVE];
  3458.          uint32 m_regenTimer;
  3459.          uint32 m_lastManaUseTimer;
  3460. +        uint64  m_auraUpdateMask;
  3461. +        uint64 m_vehicleGUID;
  3462.  
  3463.          uint64 m_InteractionObject;
  3464.  
  3465. diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
  3466. index b92e542..0a3eec2 100644
  3467. --- a/src/game/Vehicle.cpp
  3468. +++ b/src/game/Vehicle.cpp
  3469. @@ -18,12 +18,14 @@
  3470.  
  3471.  #include "Common.h"
  3472.  #include "Log.h"
  3473. -#include "ObjectMgr.h"
  3474.  #include "Vehicle.h"
  3475.  #include "Unit.h"
  3476.  #include "Util.h"
  3477. +#include "WorldPacket.h"
  3478. +#include "InstanceData.h"
  3479.  
  3480. -Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE), m_vehicleId(0)
  3481. +Vehicle::Vehicle() : Creature(CREATURE_SUBTYPE_VEHICLE), m_vehicleId(0), m_vehicleInfo(NULL), m_spawnduration(0),
  3482. +                     despawn(false), m_creation_time(0), m_VehicleData(NULL)
  3483.  {
  3484.      m_updateFlag = (UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_VEHICLE);
  3485.  }
  3486. @@ -54,42 +56,690 @@ void Vehicle::RemoveFromWorld()
  3487.  void Vehicle::setDeathState(DeathState s)                       // overwrite virtual Creature::setDeathState and Unit::setDeathState
  3488.  {
  3489.      Creature::setDeathState(s);
  3490. +    if(s == JUST_DIED)
  3491. +    {
  3492. +        if(GetVehicleFlags() & VF_DESPAWN_NPC)
  3493. +            Dismiss();
  3494. +        else
  3495. +            RemoveAllPassengers();
  3496. +    }
  3497.  }
  3498.  
  3499.  void Vehicle::Update(uint32 diff)
  3500.  {
  3501.      Creature::Update(diff);
  3502. +    InstallAllAccessories();
  3503. +
  3504. +    if(despawn)
  3505. +    {
  3506. +        m_spawnduration -= diff;
  3507. +        if(m_spawnduration < 0)
  3508. +            Dismiss();
  3509. +        despawn = false;
  3510. +    }
  3511. +
  3512. +    if(m_regenTimer <= diff)
  3513. +    {
  3514. +        RegeneratePower(getPowerType());
  3515. +        m_regenTimer = 4000;
  3516. +    }
  3517. +    else
  3518. +        m_regenTimer -= diff;
  3519.  }
  3520.  
  3521. -bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team)
  3522. +void Vehicle::RegeneratePower(Powers power)
  3523. +{
  3524. +    uint32 curValue = GetPower(power);
  3525. +    uint32 maxValue = GetMaxPower(power);
  3526. +
  3527. +    if (curValue >= maxValue)
  3528. +        return;
  3529. +
  3530. +    float addvalue = 0.0f;
  3531. +
  3532. +    // hack: needs more research of power type from the dbc.
  3533. +    // It must contains some info about vehicles like Salvaged Chopper.
  3534. +    if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE)
  3535. +        return;
  3536. +
  3537. +    addvalue = 20.0f;
  3538. +
  3539. +    ModifyPower(power, (int32)addvalue);
  3540. +}
  3541. +
  3542. +bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data)
  3543.  {
  3544.      SetMap(map);
  3545. +    SetPhaseMask(phaseMask,false);
  3546. +
  3547. +    CreatureInfo const *cinfo = sObjectMgr.GetCreatureTemplate(Entry);
  3548. +    if(!cinfo)
  3549. +    {
  3550. +        sLog.outErrorDb("Creature entry %u does not exist.", Entry);
  3551. +        return false;
  3552. +    }
  3553.  
  3554.      Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);
  3555.  
  3556. -    if(!InitEntry(Entry, team))
  3557. +    if(!UpdateEntry(Entry, team, data))
  3558.          return false;
  3559.  
  3560. -    m_defaultMovementType = IDLE_MOTION_TYPE;
  3561. +    if(!vehicleId)
  3562. +    {
  3563. +        CreatureDataAddon const *cainfo = GetCreatureAddon();
  3564. +        if(!cainfo)
  3565. +            return false;
  3566. +        vehicleId = cainfo->vehicle_id;
  3567. +    }
  3568. +    if(!SetVehicleId(vehicleId))
  3569. +        return false;
  3570.  
  3571. -    AIM_Initialize();
  3572. +    LoadCreaturesAddon();
  3573.  
  3574. -    SetVehicleId(vehicleId);
  3575. +    m_regenHealth = false;
  3576. +    m_creation_time = getMSTime();
  3577.  
  3578. -    SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  3579.      SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
  3580. +    //RemoveMonsterMoveFlag(MONSTER_MOVE_WALK);
  3581. +
  3582. +    //Notify the map's instance data.
  3583. +    //Only works if you create the object in it, not if it is moves to that map.
  3584. +    //Normally non-players do not teleport to other maps.
  3585. +    if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData())
  3586. +    {
  3587. +        ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this);
  3588. +    }
  3589. +    
  3590. +    if(m_vehicleInfo->m_powerType == POWER_TYPE_STEAM)
  3591. +    {
  3592. +        setPowerType(POWER_ENERGY);
  3593. +        SetMaxPower(POWER_ENERGY, 100);
  3594. +        SetPower(POWER_ENERGY, 100);
  3595. +    }
  3596. +    else if(m_vehicleInfo->m_powerType == POWER_TYPE_PYRITE)
  3597. +    {
  3598. +        setPowerType(POWER_ENERGY);
  3599. +        SetMaxPower(POWER_ENERGY, 50);
  3600. +        SetPower(POWER_ENERGY, 50);
  3601. +    }
  3602. +    else
  3603. +    {
  3604. +        for (uint32 i = 0; i < MAX_VEHICLE_SPELLS; ++i)
  3605. +        {
  3606. +            if(!GetVehicleData()->v_spells[i])
  3607. +                continue;
  3608. +            SpellEntry const *spellInfo = sSpellStore.LookupEntry(GetVehicleData()->v_spells[i]);
  3609. +            if(!spellInfo)
  3610. +                continue;
  3611.  
  3612. -    CreatureInfo const *ci = GetCreatureInfo();
  3613. -    setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
  3614. +            if(spellInfo->powerType == POWER_MANA)
  3615. +                break;
  3616.  
  3617. -    SelectLevel(ci);
  3618. +            if(spellInfo->powerType == POWER_ENERGY)
  3619. +            {
  3620. +                setPowerType(POWER_ENERGY);
  3621. +                SetMaxPower(POWER_ENERGY, 100);
  3622. +                SetPower(POWER_ENERGY, 100);
  3623. +                break;
  3624. +            }
  3625. +        }
  3626. +    }
  3627. +    SetHealth(GetMaxHealth());
  3628. +    InstallAllAccessories();
  3629.  
  3630.      return true;
  3631.  }
  3632.  
  3633. +bool Vehicle::SetVehicleId(uint32 vehicleid)
  3634. +{
  3635. +    VehicleEntry const *vehicleInfo = sVehicleStore.LookupEntry(vehicleid);
  3636. +    if(!vehicleInfo)
  3637. +        return false;
  3638. +
  3639. +    m_vehicleId = vehicleid;
  3640. +    m_vehicleInfo = vehicleInfo;
  3641. +
  3642. +    // can be NULL
  3643. +    VehicleDataStructure const *VDStructure = sObjectMgr.GetVehicleData(vehicleid);
  3644. +    if(VDStructure)
  3645. +        m_VehicleData = VDStructure;
  3646. +
  3647. +    InitSeats();
  3648. +    EmptySeatsCountChanged();
  3649. +    return true;
  3650. +}
  3651. +
  3652. +void Vehicle::InitSeats()
  3653. +{
  3654. +    m_Seats.clear();
  3655. +
  3656. +    for(uint32 i = 0; i < MAX_SEAT; ++i)
  3657. +    {
  3658. +        uint32 seatId = m_vehicleInfo->m_seatID[i];
  3659. +        if(seatId)
  3660. +        {
  3661. +            if(VehicleSeatEntry const *veSeat = sVehicleSeatStore.LookupEntry(seatId))
  3662. +            {
  3663. +                VehicleSeat newseat;
  3664. +                //newseat.seatInfo = veSeat;
  3665. +                newseat.passenger = NULL;
  3666. +                newseat.flags = SEAT_FREE;
  3667. +                newseat.vs_flags = sObjectMgr.GetSeatFlags(seatId);
  3668. +                m_Seats[i] = newseat;
  3669. +            }
  3670. +        }
  3671. +    }
  3672. +    // NOTE : there can be vehicles without seats (eg. 180) - probably some TEST vehicles
  3673. +}
  3674. +void Vehicle::ChangeSeatFlag(uint8 seat, uint8 flag)
  3675. +{
  3676. +    SeatMap::iterator i_seat = m_Seats.find(seat);
  3677. +    // this should never happen
  3678. +    if(i_seat == m_Seats.end())
  3679. +        return;
  3680. +
  3681. +    if(i_seat->second.flags != flag)
  3682. +    {
  3683. +        i_seat->second.flags = flag;
  3684. +        EmptySeatsCountChanged();
  3685. +    }
  3686. +}
  3687. +Vehicle* Vehicle::FindFreeSeat(int8 *seatid, bool force)
  3688. +{
  3689. +    SeatMap::const_iterator i_seat = m_Seats.find(*seatid);
  3690. +    if(i_seat == m_Seats.end())
  3691. +        return GetFirstEmptySeat(seatid, force);
  3692. +    if((i_seat->second.flags & (SEAT_FULL | SEAT_VEHICLE_FULL)) || (!force && (i_seat->second.vs_flags & SF_UNACCESSIBLE)))
  3693. +        return GetNextEmptySeat(seatid, true, force);
  3694. +    if(i_seat->second.flags & SEAT_VEHICLE_FREE)
  3695. +    {
  3696. +        // this should never be NULL
  3697. +        if(Vehicle *v = (Vehicle*)i_seat->second.passenger)
  3698. +            return v->FindFreeSeat(seatid, force);
  3699. +        return NULL;
  3700. +    }
  3701. +    return this;
  3702. +}
  3703. +
  3704. +Vehicle* Vehicle::GetFirstEmptySeat(int8 *seatId, bool force)
  3705. +{
  3706. +    for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
  3707. +    {
  3708. +        if(itr->second.flags & SEAT_FREE)
  3709. +        {
  3710. +            if(!force && (itr->second.vs_flags & SF_UNACCESSIBLE))
  3711. +                continue;
  3712. +
  3713. +            *seatId = itr->first;
  3714. +            return this;
  3715. +        }
  3716. +        else if(itr->second.flags & SEAT_VEHICLE_FREE)
  3717. +        {
  3718. +            *seatId = itr->first;
  3719. +            if(Vehicle *v = (Vehicle*)itr->second.passenger)
  3720. +                return v->FindFreeSeat(seatId, force);
  3721. +        }
  3722. +    }
  3723. +
  3724. +    return NULL;
  3725. +}
  3726. +
  3727. +Vehicle* Vehicle::GetNextEmptySeat(int8 *seatId, bool next, bool force)
  3728. +{
  3729. +    SeatMap::const_iterator i_seat = m_Seats.find(*seatId);
  3730. +    if(i_seat == m_Seats.end()) return GetFirstEmptySeat(seatId, force);
  3731. +
  3732. +    while((i_seat->second.flags & (SEAT_FULL | SEAT_VEHICLE_FULL)) || (!force && (i_seat->second.vs_flags & SF_UNACCESSIBLE)))
  3733. +    {
  3734. +        if(next)
  3735. +        {
  3736. +            ++i_seat;
  3737. +            if(i_seat == m_Seats.end())
  3738. +                i_seat = m_Seats.begin();
  3739. +        }
  3740. +        else
  3741. +        {
  3742. +            if(i_seat == m_Seats.begin())
  3743. +                i_seat = m_Seats.end();
  3744. +            --i_seat;
  3745. +        }
  3746. +        if(i_seat->first == *seatId)
  3747. +            return NULL;
  3748. +    }
  3749. +    *seatId = i_seat->first;
  3750. +    if(i_seat->second.flags & SEAT_VEHICLE_FREE)
  3751. +    {
  3752. +        if(Vehicle *v = (Vehicle*)i_seat->second.passenger)
  3753. +            return v->FindFreeSeat(seatId, force);
  3754. +        return NULL;
  3755. +    }
  3756. +
  3757. +    return this;
  3758. +}
  3759. +
  3760. +int8 Vehicle::GetEmptySeatsCount(bool force)
  3761. +{
  3762. +    int8 count = 0;
  3763. +    for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
  3764. +   {
  3765. +        if(itr->second.flags & (SEAT_FREE | SEAT_VEHICLE_FREE))
  3766. +        {
  3767. +            if(!force && (itr->second.vs_flags & SF_UNACCESSIBLE))
  3768. +                continue;
  3769. +
  3770. +            count++;
  3771. +        }
  3772. +    }
  3773. +
  3774. +    return count;
  3775. +}
  3776. +
  3777. +void Vehicle::EmptySeatsCountChanged()
  3778. +{
  3779. +    uint8 m_count = GetTotalSeatsCount();
  3780. +    uint8 p_count = GetEmptySeatsCount(false);
  3781. +    uint8 u_count = GetEmptySeatsCount(true);
  3782. +
  3783. +    // seats accesibles by players
  3784. +    if(p_count > 0)
  3785. +        SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  3786. +    else
  3787. +        RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
  3788. +
  3789. +    if(u_count == m_count)
  3790. +    {
  3791. +        RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
  3792. +    }
  3793. +    else
  3794. +        SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
  3795. +
  3796. +    if(uint64 vehicleGUID = GetVehicleGUID())
  3797. +    {
  3798. +        if(Vehicle *vehicle = ObjectAccessor::GetVehicle(vehicleGUID))
  3799. +        {
  3800. +            if(u_count > 0)
  3801. +                vehicle->ChangeSeatFlag(m_SeatData.seat, SEAT_VEHICLE_FREE);
  3802. +            else
  3803. +                vehicle->ChangeSeatFlag(m_SeatData.seat, SEAT_VEHICLE_FULL);
  3804. +        }
  3805. +    }
  3806. +}
  3807. +
  3808. +
  3809. +
  3810.  void Vehicle::Dismiss()
  3811.  {
  3812. +    RemoveAllPassengers();
  3813.      SendObjectDeSpawnAnim(GetGUID());
  3814.      CombatStop();
  3815.      AddObjectToRemoveList();
  3816.  }
  3817. +
  3818. +void Vehicle::RellocatePassengers(Map *map)
  3819. +{
  3820. +    for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
  3821. +    {
  3822. +        if(itr->second.flags & SEAT_FULL)
  3823. +        {
  3824. +            // passenger cant be NULL here
  3825. +            Unit *passengers = itr->second.passenger;
  3826. +            assert(passengers);
  3827. +
  3828. +            float xx = GetPositionX() + passengers->m_SeatData.OffsetX;
  3829. +            float yy = GetPositionY() + passengers->m_SeatData.OffsetY;
  3830. +            float zz = GetPositionZ() + passengers->m_SeatData.OffsetZ;
  3831. +            //float oo = passengers->m_SeatData.Orientation;
  3832. +            // this is not correct, we should recalculate
  3833. +            // actual rotation depending on vehicle
  3834. +            float oo = passengers->GetOrientation();
  3835. +
  3836. +            if(passengers->GetTypeId() == TYPEID_PLAYER)
  3837. +                ((Player*)passengers)->SetPosition(xx, yy, zz, oo);
  3838. +            else
  3839. +                map->CreatureRelocation((Creature*)passengers, xx, yy, zz, oo);
  3840. +        }
  3841. +        else if(itr->second.flags & (SEAT_VEHICLE_FULL | SEAT_VEHICLE_FREE))
  3842. +        {
  3843. +            // passenger cant be NULL here
  3844. +            Unit *passengers = itr->second.passenger;
  3845. +            assert(passengers);
  3846. +
  3847. +            float xx = GetPositionX() + passengers->m_SeatData.OffsetX;
  3848. +            float yy = GetPositionY() + passengers->m_SeatData.OffsetY;
  3849. +            float zz = GetPositionZ() + passengers->m_SeatData.OffsetZ;
  3850. +            //float oo = passengers->m_SeatData.Orientation;
  3851. +            // this is not correct, we should recalculate
  3852. +            // actual rotation depending on vehicle
  3853. +            float oo = passengers->GetOrientation();
  3854. +
  3855. +            map->CreatureRelocation((Creature*)passengers, xx, yy, zz, oo);
  3856. +            ((Vehicle*)passengers)->RellocatePassengers(map);
  3857. +        }
  3858. +    }
  3859. +}
  3860. +
  3861. +void Vehicle::AddPassenger(Unit *unit, int8 seatId, bool force)
  3862. +{
  3863. +    SeatMap::iterator seat;
  3864. +    seat = m_Seats.find(seatId);
  3865. +
  3866. +    // this should never happen
  3867. +    if(seat == m_Seats.end())
  3868. +        return;
  3869. +
  3870. +    unit->SetVehicleGUID(GetGUID());
  3871. +
  3872. +    seat->second.passenger = unit;
  3873. +    if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->isVehicle())
  3874. +    {
  3875. +        if(((Vehicle*)unit)->GetEmptySeatsCount(true) == 0)
  3876. +            seat->second.flags = SEAT_VEHICLE_FULL;
  3877. +        else
  3878. +            seat->second.flags = SEAT_VEHICLE_FREE;
  3879. +    }
  3880. +    else
  3881. +    {
  3882. +        seat->second.flags = SEAT_FULL;
  3883. +    }
  3884. +
  3885. +    if(unit->GetTypeId() == TYPEID_PLAYER)
  3886. +    {
  3887. +        WorldPacket data0(SMSG_FORCE_MOVE_ROOT, 10);
  3888. +        data0 << unit->GetPackGUID();
  3889. +        data0 << (uint32)((seat->second.vs_flags & SF_CAN_CAST) ? 2 : 0);
  3890. +        unit->SendMessageToSet(&data0,true);
  3891. +    }
  3892. +
  3893. +    if(seat->second.vs_flags & SF_MAIN_RIDER)
  3894. +    {
  3895. +        if(!(GetVehicleFlags() & VF_MOVEMENT))
  3896. +        {
  3897. +            GetMotionMaster()->Clear(false);
  3898. +            GetMotionMaster()->MoveIdle();
  3899. +            SetCharmerGUID(unit->GetGUID());
  3900. +            unit->SetUInt64Value(UNIT_FIELD_CHARM, GetGUID());
  3901. +            if(unit->GetTypeId() == TYPEID_PLAYER)
  3902. +            {
  3903. +                ((Player*)unit)->SetMoverInQueve(this);
  3904. +                ((Player*)unit)->SetClientControl(this, 1);
  3905. +            }
  3906. +            if(canFly() || HasAuraType(SPELL_AURA_FLY) || HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED))
  3907. +            {
  3908. +                WorldPacket data3(SMSG_MOVE_SET_CAN_FLY, 12);
  3909. +                data3<< GetPackGUID();
  3910. +                data3 << (uint32)(0);
  3911. +                SendMessageToSet(&data3,false);
  3912. +            }
  3913. +        }
  3914. +
  3915. +        SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(GetEntry());
  3916. +        for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
  3917. +        {
  3918. +            if (unit->GetTypeId() == TYPEID_UNIT || itr->second.IsFitToRequirements((Player*)unit))
  3919. +            {
  3920. +                Unit *caster = (itr->second.castFlags & 0x1) ? unit : this;
  3921. +                Unit *target = (itr->second.castFlags & 0x2) ? unit : this;
  3922. +
  3923. +                caster->CastSpell(target, itr->second.spellId, true);
  3924. +            }
  3925. +        }
  3926. +        if(unit->GetTypeId() == TYPEID_PLAYER)
  3927. +        {
  3928. +            // it should be added only on rider enter?
  3929. +            if(((Player*)unit)->GetGroup())
  3930. +                ((Player*)unit)->SetGroupUpdateFlag(GROUP_UPDATE_VEHICLE);
  3931. +
  3932. +            ((Player*)unit)->SetFarSightGUID(GetGUID());
  3933. +
  3934. +            BuildVehicleActionBar((Player*)unit);
  3935. +        }
  3936. +
  3937. +        if(!(GetVehicleFlags() & VF_FACTION))
  3938. +            setFaction(unit->getFaction());
  3939. +
  3940. +        if(GetVehicleFlags() & VF_CANT_MOVE)
  3941. +        {
  3942. +            WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
  3943. +            data2<< GetPackGUID();
  3944. +            data2 << (uint32)(2);
  3945. +            SendMessageToSet(&data2,false);
  3946. +        }
  3947. +
  3948. +        if(GetVehicleFlags() & VF_NON_SELECTABLE)
  3949. +            SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  3950. +    }
  3951. +    if(seat->second.vs_flags & SF_UNATTACKABLE)
  3952. +        unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  3953. +
  3954. +    EmptySeatsCountChanged();
  3955. +}
  3956. +
  3957. +void Vehicle::RemovePassenger(Unit *unit)
  3958. +{
  3959. +    SeatMap::iterator seat;
  3960. +    for(seat = m_Seats.begin(); seat != m_Seats.end(); ++seat)
  3961. +    {
  3962. +        if((seat->second.flags & (SEAT_FULL | SEAT_VEHICLE_FREE | SEAT_VEHICLE_FULL)) && seat->second.passenger == unit)
  3963. +        {
  3964. +            unit->SetVehicleGUID(0);
  3965. +
  3966. +            if(seat->second.vs_flags & SF_MAIN_RIDER)
  3967. +            {
  3968. +                RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
  3969. +                if(unit->GetTypeId() == TYPEID_PLAYER)
  3970. +                {
  3971. +                    ((Player*)unit)->SetMover(unit);
  3972. +                    ((Player*)unit)->SetClientControl(unit, 1);
  3973. +                    ((Player*)unit)->SetMoverInQueve(NULL);
  3974. +                    ((Player*)unit)->RemovePetActionBar();
  3975. +
  3976. +                    if(((Player*)unit)->GetGroup())
  3977. +                        ((Player*)unit)->SetGroupUpdateFlag(GROUP_UPDATE_VEHICLE);
  3978. +                }
  3979. +                unit->SetCharm(NULL);
  3980. +                SetCharmerGUID(NULL);
  3981. +                setFaction(GetCreatureInfo()->faction_A);
  3982. +            }
  3983. +            if(GetVehicleFlags() & VF_NON_SELECTABLE)
  3984. +                RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  3985. +            if(seat->second.vs_flags & SF_UNATTACKABLE)
  3986. +                unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
  3987. +            // restore player control
  3988. +            if(unit->GetTypeId() == TYPEID_PLAYER)
  3989. +            {
  3990. +                ((Player*)unit)->SetFarSightGUID(NULL);
  3991. +
  3992. +                if(seat->second.vs_flags & SF_CAN_CAST)
  3993. +                {
  3994. +                    WorldPacket data0(SMSG_FORCE_MOVE_UNROOT, 10);
  3995. +                    data0 << unit->GetPackGUID();
  3996. +                    data0 << (uint32)(2);                        // can rotate
  3997. +                    unit->SendMessageToSet(&data0,true);
  3998. +                }
  3999. +                else
  4000. +                {
  4001. +                    WorldPacket data1(SMSG_FORCE_MOVE_UNROOT, 10);
  4002. +                    data1 << unit->GetPackGUID();
  4003. +                    data1 << (uint32)(0);                        // cannot rotate
  4004. +                    unit->SendMessageToSet(&data1,true);
  4005. +                }
  4006. +            }
  4007. +            unit->m_SeatData.OffsetX = 0.0f;
  4008. +            unit->m_SeatData.OffsetY = 0.0f;
  4009. +            unit->m_SeatData.OffsetZ = 0.0f;
  4010. +            unit->m_SeatData.Orientation = 0.0f;
  4011. +            unit->m_SeatData.c_time = 0;
  4012. +            unit->m_SeatData.dbc_seat = 0;
  4013. +            unit->m_SeatData.seat = 0;
  4014. +            unit->m_SeatData.s_flags = 0;
  4015. +            unit->m_SeatData.v_flags = 0;
  4016. +
  4017. +            seat->second.passenger = NULL;
  4018. +            seat->second.flags = SEAT_FREE;
  4019. +            EmptySeatsCountChanged();
  4020. +            break;
  4021. +        }
  4022. +    }
  4023. +}
  4024. +
  4025. +void Vehicle::RemoveAllPassengers()
  4026. +{
  4027. +    for(SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
  4028. +    {
  4029. +        if(itr->second.flags & SEAT_FULL)
  4030. +        {
  4031. +            if(Unit *passenger = itr->second.passenger)                     // this cant be NULL, but..
  4032. +                passenger->ExitVehicle();
  4033. +        }
  4034. +        else if(itr->second.flags & (SEAT_VEHICLE_FULL | SEAT_VEHICLE_FREE))
  4035. +        {
  4036. +            if(Unit *passenger = itr->second.passenger)                     // this cant be NULL, but..
  4037. +            {
  4038. +                passenger->ExitVehicle();
  4039. +                ((Vehicle*)passenger)->Dismiss();
  4040. +            }
  4041. +        }
  4042. +    }
  4043. +    // make sure everything is cleared
  4044. +    InitSeats();
  4045. +}
  4046. +
  4047. +bool Vehicle::HasSpell(uint32 spell) const
  4048. +{
  4049. +    if(!m_VehicleData)
  4050. +        return false;
  4051. +
  4052. +    for(uint8 j = 0; j < MAX_VEHICLE_SPELLS; j++)
  4053. +    {
  4054. +        if(m_VehicleData->v_spells[j] == spell)
  4055. +            return true;
  4056. +    }
  4057. +
  4058. +    return false;
  4059. +}
  4060. +
  4061. +void Vehicle::BuildVehicleActionBar(Player *plr) const
  4062. +{
  4063. +    WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*10+1+1);
  4064. +    data << uint64(GetGUID());
  4065. +    data << uint16(0x00000000);                     // creature family, not used in vehicles
  4066. +    data << uint32(0x00000000);                     // unk
  4067. +    data << uint32(0x00000101);                     // react state
  4068. +
  4069. +    for(uint32 i = 0; i <= MAX_VEHICLE_SPELLS; ++i)
  4070. +    {
  4071. +        data << uint16(m_VehicleData ? m_VehicleData->v_spells[i] : NULL) << uint8(0) << uint8(i+8);
  4072. +    }
  4073. +
  4074. +    data << uint8(0);                               //aditional spells in spellbook, not used in vehicles
  4075. +
  4076. +    uint8 cooldownsCount = m_CreatureSpellCooldowns.size() + m_CreatureCategoryCooldowns.size();
  4077. +    data << uint8(cooldownsCount);
  4078. +    time_t curTime = time(NULL);
  4079. +
  4080. +    for(CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end(); ++itr)
  4081. +    {
  4082. +        time_t cooldown = (itr->second > curTime) ? (itr->second - curTime) * IN_MILISECONDS : 0;
  4083. +
  4084. +        data << uint32(itr->first);                         // spellid
  4085. +        data << uint16(0);                                  // spell category?
  4086. +        data << uint32(cooldown);                           // cooldown
  4087. +        data << uint32(0);                                  // category cooldown
  4088. +    }
  4089. +
  4090. +    for(CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.begin(); itr != m_CreatureCategoryCooldowns.end(); ++itr)
  4091. +    {
  4092. +        time_t cooldown = (itr->second > curTime) ? (itr->second - curTime) * IN_MILISECONDS : 0;
  4093. +
  4094. +        data << uint32(itr->first);                         // spellid
  4095. +        data << uint16(0);                                  // spell category?
  4096. +        data << uint32(0);                                  // cooldown
  4097. +        data << uint32(cooldown);                           // category cooldown
  4098. +    }
  4099. +
  4100. +    plr->GetSession()->SendPacket(&data);
  4101. +
  4102. +    data.Initialize(SMSG_PET_GUIDS, 12);
  4103. +    data << uint32(1);                                        // count
  4104. +    data << uint64(GetGUID());
  4105. +    plr->GetSession()->SendPacket(&data);
  4106. +}
  4107. +void Vehicle::InstallAllAccessories()
  4108. +{
  4109. +    //TODO: Move this into DB!!!
  4110. +    switch(GetEntry())
  4111. +    {
  4112. +        //case 27850:InstallAccessory(27905,1);break;
  4113. +        case 28782:InstallAccessory(28768,0,false, false);break; // Acherus Deathcharger
  4114. +        case 28312:InstallAccessory(28319,7,true);break;
  4115. +        case 32627:InstallAccessory(32629,7,true);break;
  4116. +        case 32930:
  4117. +            InstallAccessory(32933,0);
  4118. +            InstallAccessory(32934,1);
  4119. +            break;
  4120. +        case 33109:InstallAccessory(33167,1, true);break;
  4121. +        case 33060:InstallAccessory(33067,7, true);break;
  4122. +        case 33113:
  4123. +            InstallAccessory(33114,0, true);
  4124. +            InstallAccessory(33114,1, true);
  4125. +            InstallAccessory(33114,2, true);
  4126. +            InstallAccessory(33114,3, true);
  4127. +            InstallAccessory(33139,7);
  4128. +            break;
  4129. +        case 33114:
  4130. +            InstallAccessory(33143,2); // Overload Control Device
  4131. +            InstallAccessory(33142,1); // Leviathan Defense Turret
  4132. +            break;
  4133. +        case 33214:InstallAccessory(33218,1,false,false);break; // Mechanolift 304-A
  4134. +    }
  4135. +}
  4136. +
  4137. +void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool isVehicle, bool minion)
  4138. +{
  4139. +    if(Unit *passenger = GetPassenger(seatId))
  4140. +    {
  4141. +        // already installed
  4142. +        if(passenger->GetEntry() == entry)
  4143. +        {
  4144. +            assert(passenger->GetTypeId() == TYPEID_UNIT);
  4145. +            return;
  4146. +        }
  4147. +        passenger->ExitVehicle(); // this should not happen
  4148. +    }
  4149. +
  4150. +    //TODO: accessory should be minion
  4151. +    if(isVehicle)
  4152. +    {
  4153. +        if(Vehicle *accessory = SummonVehicle(entry, 0, 0, 0, 0))
  4154. +        {
  4155. +            accessory->EnterVehicle(this, seatId);
  4156. +            // This is not good, we have to send update twice
  4157. +            WorldPacket data;
  4158. +            accessory->BuildHeartBeatMsg(&data);
  4159. +            accessory->SendMessageToSet(&data, false);
  4160. +        }
  4161. +    }else{
  4162. +        if(Creature *accessory = SummonCreature(entry, 0, 0, 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000))
  4163. +        {
  4164. +            accessory->EnterVehicle(this, seatId);
  4165. +            // This is not good, we have to send update twice
  4166. +            WorldPacket data;
  4167. +            accessory->BuildHeartBeatMsg(&data);
  4168. +            accessory->SendMessageToSet(&data, false);
  4169. +        }
  4170. +    }
  4171. +}
  4172. +Unit *Vehicle::GetPassenger(int8 seatId) const
  4173. +{
  4174. +    SeatMap::const_iterator seat = m_Seats.find(seatId);
  4175. +    if(seat == m_Seats.end()) return NULL;
  4176. +    return seat->second.passenger;
  4177. +}
  4178. +void Vehicle::Die()
  4179. +{
  4180. +    for (SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
  4181. +        if(Unit *passenger = itr->second.passenger)
  4182. +            if(((Creature*)passenger)->isVehicle())
  4183. +               ((Vehicle*)passenger)->Dismiss();
  4184. +    RemoveAllPassengers();
  4185. +}
  4186. \ No newline at end of file
  4187. diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h
  4188. index 45d50f5..5705c29 100644
  4189. --- a/src/game/Vehicle.h
  4190. +++ b/src/game/Vehicle.h
  4191. @@ -22,6 +22,34 @@
  4192.  #include "ObjectGuid.h"
  4193.  #include "Creature.h"
  4194.  #include "Unit.h"
  4195. +#include "ObjectMgr.h"
  4196. +
  4197. +struct VehicleSeat
  4198. +{
  4199. +    //VehicleSeatEntry const *seatInfo;
  4200. +    Unit* passenger;
  4201. +    uint8 flags;
  4202. +    uint32 vs_flags;
  4203. +};
  4204. +
  4205. +enum VehicleSeatFlags
  4206. +{
  4207. +    SEAT_FREE           = 0x01,                             // free seat
  4208. +    SEAT_FULL           = 0x02,                             // seat occupied by player/creature
  4209. +    // special cases
  4210. +    SEAT_VEHICLE_FREE   = 0x04,                             // seat occupied by vehicle, but that vehicle is free
  4211. +    SEAT_VEHICLE_FULL   = 0x08                              // seat occupied by vehicle and that vehicle is full too
  4212. +};
  4213. +
  4214. +enum PowerType
  4215. +{
  4216. +    POWER_TYPE_PYRITE = 41,
  4217. +    POWER_TYPE_STEAM  = 61
  4218. +};
  4219. +
  4220. +#define MAX_SEAT 8
  4221. +
  4222. +typedef std::map<int8, VehicleSeat> SeatMap;
  4223.  
  4224.  class Vehicle : public Creature
  4225.  {
  4226. @@ -32,19 +60,55 @@ class Vehicle : public Creature
  4227.          void AddToWorld();
  4228.          void RemoveFromWorld();
  4229.  
  4230. -        bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team);
  4231. +        void Die();
  4232. +        bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data = NULL);
  4233.  
  4234.          void setDeathState(DeathState s);                   // overwrite virtual Creature::setDeathState and Unit::setDeathState
  4235.          void Update(uint32 diff);                           // overwrite virtual Creature::Update and Unit::Update
  4236.  
  4237. +        void RegeneratePower(Powers power);
  4238. +
  4239.          uint32 GetVehicleId() { return m_vehicleId; }
  4240. -        void SetVehicleId(uint32 vehicleid) { m_vehicleId = vehicleid; }
  4241. +        bool SetVehicleId(uint32 vehicleid);
  4242. +
  4243. +        void InitSeats();
  4244. +
  4245. +        void ChangeSeatFlag(uint8 seat, uint8 flag);
  4246. +        Vehicle* FindFreeSeat(int8 *seatid, bool force = true);
  4247. +        Vehicle* GetNextEmptySeat(int8 *seatId, bool next = true, bool force = true);
  4248. +        Vehicle* GetFirstEmptySeat(int8 *seatId, bool force = true);
  4249. +        int8 GetEmptySeatsCount(bool force = true);
  4250. +        void EmptySeatsCountChanged();
  4251. +        int8 GetTotalSeatsCount() { return m_Seats.size(); }
  4252.  
  4253.          void Dismiss();
  4254.  
  4255. +        void RellocatePassengers(Map *map);
  4256. +        void AddPassenger(Unit *unit, int8 seatId, bool force = true);
  4257. +        void RemovePassenger(Unit *unit);
  4258. +        void RemoveAllPassengers();
  4259. +
  4260. +        bool HasSpell(uint32 spell) const;
  4261. +        void SetSpawnDuration(int32 duration)
  4262. +        {
  4263. +            duration < 1 ? despawn = false : despawn = true;
  4264. +            m_spawnduration = duration;
  4265. +        }
  4266. +        VehicleDataStructure const* GetVehicleData() { return m_VehicleData; }
  4267. +        uint32 GetVehicleFlags() { return m_VehicleData ? m_VehicleData->v_flags : NULL; }
  4268. +        uint32 GetCreationTime() { return m_creation_time; }
  4269. +        void BuildVehicleActionBar(Player *plr) const;
  4270. +        void InstallAllAccessories();
  4271. +        Unit *GetPassenger(int8 seatId) const;
  4272.      protected:
  4273.          uint32 m_vehicleId;
  4274. -
  4275. +        VehicleEntry const *m_vehicleInfo;
  4276. +        VehicleDataStructure const *m_VehicleData;
  4277. +        uint32 m_creation_time;
  4278. +        SeatMap m_Seats;
  4279. +        bool despawn;
  4280. +        int32 m_spawnduration;
  4281. +        void InstallAccessory(uint32 entry, int8 seatId, bool isVehicle = false, bool minion = true);
  4282.      private:
  4283.          void SaveToDB(uint32, uint8)                        // overwrited of Creature::SaveToDB     - don't must be called
  4284.          {
  4285. diff --git a/src/game/World.cpp b/src/game/World.cpp
  4286. index 853a7a4..0f272d6 100644
  4287. --- a/src/game/World.cpp
  4288. +++ b/src/game/World.cpp
  4289. @@ -1198,6 +1198,11 @@ void World::SetInitialWorldSettings()
  4290.      sLog.outString( "Loading Scripts text locales..." );    // must be after Load*Scripts calls
  4291.      sObjectMgr.LoadDbScriptStrings();
  4292.  
  4293. +    sLog.outString( "Loading VehicleData..." );
  4294. +    sObjectMgr.LoadVehicleData();
  4295. +    sLog.outString( "Loading VehicleSeatData..." );
  4296. +    sObjectMgr.LoadVehicleSeatData();
  4297. +
  4298.      sLog.outString( "Loading CreatureEventAI Texts...");
  4299.      sEventAIMgr.LoadCreatureEventAI_Texts(false);       // false, will checked in LoadCreatureEventAI_Scripts
  4300.  
  4301. diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h
  4302. index caa794a..c0b2316 100644
  4303. --- a/src/game/WorldSession.h
  4304. +++ b/src/game/WorldSession.h
  4305. @@ -389,6 +389,11 @@ class MANGOS_DLL_SPEC WorldSession
  4306.          void HandleSetActiveMoverOpcode(WorldPacket &recv_data);
  4307.          void HandleMoveNotActiveMover(WorldPacket &recv_data);
  4308.          void HandleDismissControlledVehicle(WorldPacket &recv_data);
  4309. +        void HandleRequestVehicleExit(WorldPacket &recv_data);
  4310. +        void HandleRequestVehiclePrevSeat(WorldPacket &recv_data);
  4311. +        void HandleRequestVehicleNextSeat(WorldPacket &recv_data);
  4312. +        void HandleRequestVehicleSwitchSeat(WorldPacket &recv_data);
  4313. +        void HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data);
  4314.          void HandleMoveTimeSkippedOpcode(WorldPacket &recv_data);
  4315.  
  4316.          void HandleRequestRaidInfoOpcode( WorldPacket & recv_data );
  4317. diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp
  4318. index 74a76c6..6713f01 100644
  4319. --- a/src/game/debugcmds.cpp
  4320. +++ b/src/game/debugcmds.cpp
  4321. @@ -627,7 +627,8 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
  4322.  
  4323.      Vehicle *v = new Vehicle;
  4324.      Map *map = m_session->GetPlayer()->GetMap();
  4325. -    if (!v->Create(map->GenerateLocalLowGuid(HIGHGUID_VEHICLE), map, entry, id, m_session->GetPlayer()->GetTeam()))
  4326. +
  4327. +    if (!v->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, m_session->GetPlayer()->GetPhaseMaskForSpawn(), entry, id, m_session->GetPlayer()->GetTeam()))
  4328.      {
  4329.          delete v;
  4330.          return false;
  4331. @@ -647,6 +648,7 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
  4332.      }
  4333.  
  4334.      map->Add((Creature*)v);
  4335. +    v->AIM_Initialize();
  4336.  
  4337.      return true;
  4338.  }
  4339. diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp
  4340. index 9f8e32a..2f4e329 100644
  4341. --- a/src/shared/Database/SQLStorage.cpp
  4342. +++ b/src/shared/Database/SQLStorage.cpp
  4343. @@ -27,9 +27,9 @@ extern DatabaseMysql  WorldDatabase;
  4344.  
  4345.  const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiis";
  4346.  const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiii";
  4347. -const char CreatureDataAddonInfofmt[]="iiiiiis";
  4348. +const char CreatureDataAddonInfofmt[]="iiiiiiiss";
  4349.  const char CreatureModelfmt[]="iffbi";
  4350. -const char CreatureInfoAddonInfofmt[]="iiiiiis";
  4351. +const char CreatureInfoAddonInfofmt[]="iiiiiiiss";
  4352.  const char EquipmentInfofmt[]="iiii";
  4353.  const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis";
  4354.  const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement