Advertisement
Guest User

Untitled

a guest
Aug 16th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.51 KB | None | 0 0
  1. /*
  2. *
  3. */
  4.  
  5. #include "OutdoorPvPCA.h"
  6. #include "Player.h"
  7. #include "ObjectMgr.h"
  8. #include "OutdoorPvPMgr.h"
  9. #include "WorldPacket.h"
  10. #include "Language.h"
  11. #include "World.h"
  12. #include "ScriptPCH.h"
  13. #include "ScriptedEscortAI.h"
  14.  
  15. const uint32 CA_LANG_LOOSE_TOWER[CA_TOWER_NUM] =
  16. {
  17. LANG_OPVP_CA_LOOSE_TOWER_A_A,
  18. LANG_OPVP_CA_LOOSE_TOWER_B_A,
  19. LANG_OPVP_CA_LOOSE_TOWER_C_A,
  20. LANG_OPVP_CA_LOOSE_TOWER_D_H,
  21. LANG_OPVP_CA_LOOSE_TOWER_E_H,
  22. LANG_OPVP_CA_LOOSE_TOWER_F_H
  23. };
  24.  
  25. const uint32 CA_LANG_KILLED_N_BOSS[CA_BOSSES_NUM] =
  26. {
  27. LANG_OPVP_CA_KILLED_N_BOSS_A,
  28. LANG_OPVP_CA_KILLED_N_BOSS_H
  29. };
  30.  
  31. OutdoorPvPCA::OutdoorPvPCA()
  32. {
  33. m_TypeId = OUTDOOR_PVP_CA;
  34. }
  35.  
  36. bool OutdoorPvPCA::SetupOutdoorPvP()
  37. {
  38. RegisterZone(CA_OUTDOORPVP_ZONE);
  39. AddTowersToCA();
  40. AddCreepsSummonNpcToCA();
  41. AddNeutrallBossToCA();
  42. AddNeutrallCreepsToCA();
  43. AddCreatureTeleporter();
  44. AddBossesToCA();
  45. AddObjectBuffs();
  46. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr)
  47. {
  48. UpdateCreatureInfo(*itr);
  49. };
  50. return true;
  51. }
  52.  
  53. void OutdoorPvPCA::AddTowersToCA()
  54. {
  55. for (int i = 0; i < CA_TOWER_NUM; i)
  56. {
  57. AddCreature(i,creatures[i].entry,creatures[i].teamval,creatures[i].map,creatures[i].x,creatures[i].y,creatures[i].z,creatures[i].o,1000000);
  58. check_towers[i] = 0;
  59. }
  60. }
  61.  
  62. void OutdoorPvPCA::AddObjectBuffs()
  63. {
  64. for (int i = 0; i < CA_OBJ_NUM; i)
  65. {
  66. AddObject(i,objects[i].entry,objects[i].map,objects[i].x,objects[i].y,objects[i].z,objects[i].o,objects[i].rot0,objects[i].rot1,objects[i].rot2,objects[i].rot3);
  67. }
  68. }
  69.  
  70. void OutdoorPvPCA::AddBossesToCA()
  71. {
  72. for (int i = CA_TOWER_NUM; i < (CA_TOWER_NUM,CA_BOSSES_NUM); i)
  73. {
  74. AddCreature(i,creatures[i].entry,creatures[i].teamval,creatures[i].map,creatures[i].x,creatures[i].y,creatures[i].z,creatures[i].o,1000000);
  75. }
  76. }
  77.  
  78. void OutdoorPvPCA::AddCreepsSummonNpcToCA()
  79. {
  80. for (int i = (CA_TOWER_NUM,CA_BOSSES_NUM); i < (CA_TOWER_NUM,CA_BOSSES_NUM,CA_SUMMON_NPC_NUM); i)
  81. {
  82. AddCreature(i,creatures[i].entry,creatures[i].teamval,creatures[i].map,creatures[i].x,creatures[i].y,creatures[i].z,creatures[i].o,1000000);
  83. }
  84. }
  85.  
  86. void OutdoorPvPCA::AddNeutrallBossToCA()
  87. {
  88. for (int i = (CA_TOWER_NUM,CA_BOSSES_NUM,CA_SUMMON_NPC_NUM); i < (CA_TOWER_NUM,CA_BOSSES_NUM,CA_SUMMON_NPC_NUM,CA_NEUTRALL_BOSS_NUM); i)
  89. {
  90. AddCreature(i,creatures[i].entry,creatures[i].teamval,creatures[i].map,creatures[i].x,creatures[i].y,creatures[i].z,creatures[i].o,1000000);
  91. }
  92. }
  93.  
  94. void OutdoorPvPCA::AddNeutrallCreepsToCA()
  95. {
  96. for (int i = (CA_TOWER_NUM,CA_BOSSES_NUM,CA_SUMMON_NPC_NUM,CA_NEUTRALL_BOSS_NUM); i < (CA_TOWER_NUM,CA_BOSSES_NUM,CA_SUMMON_NPC_NUM,CA_NEUTRALL_BOSS_NUM,CA_NEUTRALL_CREEP_NUM); i)
  97. {
  98. AddCreature(i,creatures[i].entry,creatures[i].teamval,creatures[i].map,creatures[i].x,creatures[i].y,creatures[i].z,creatures[i].o,1000000);
  99. }
  100. }
  101.  
  102. void OutdoorPvPCA::AddCreatureTeleporter()
  103. {
  104. AddCreature(CREATURE_OTHER, 500006, 0, 37, 66.929f, 906.698f, 343.026f, 2.244f, 1000000);
  105. AddCreature(CREATURE_OTHER, 500006, 0, 37, 1215.098f, 249.887f, 355.152f, 5.710f, 1000000);
  106. }
  107.  
  108. void OutdoorPvPCA::TeleportPlayersOnCA(TeamId team)
  109. {
  110. for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); itr)
  111. {
  112. uint64 playerGuid = *itr;
  113. ++itr;
  114.  
  115. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  116. if (player->isDead())
  117. {
  118. player->ResurrectPlayer(100,false);
  119. player->TeleportTo(SPAWN[player->GetTeamId()].map,SPAWN[player->GetTeamId()].x,SPAWN[player->GetTeamId()].y,SPAWN[player->GetTeamId()].z,SPAWN[player->GetTeamId()].o,0);
  120. } }
  121. }
  122.  
  123. OutdoorPvPCACreType OutdoorPvPCA::GetCreatureType(uint32 entry) const
  124. {
  125. switch(entry)
  126. {
  127. case 500100:
  128. case 500101:
  129. case 500102:
  130. case 500110:
  131. case 500111:
  132. case 500112:
  133. return CREATURE_TOWER;
  134. case 500109:
  135. case 500119:
  136. return CREATURE_BOSS;
  137. case 500107:
  138. case 500117:
  139. return CREATURE_CREEPS;
  140. default:
  141. return CREATURE_OTHER;
  142. }
  143. }
  144.  
  145. void OutdoorPvPCA::OnCreatureCreate(Creature *creature)
  146. {
  147. uint32 entry = creature->GetEntry();
  148. switch(GetCreatureType(entry))
  149. {
  150. case CREATURE_TOWER:
  151. case CREATURE_BOSS:
  152. case CREATURE_OTHER:
  153. case CREATURE_CREEPS:
  154. {
  155. UpdateCreatureInfo(creature);
  156. m_creature.insert(creature);
  157. break;
  158. }
  159. }
  160. }
  161.  
  162. void OutdoorPvPCA::OnCreatureRemove(Creature *creature)
  163. {
  164. uint32 entry = creature->GetEntry();
  165. switch(GetCreatureType(entry))
  166. {
  167. case CREATURE_TOWER:
  168. case CREATURE_BOSS:
  169. case CREATURE_OTHER:
  170. case CREATURE_CREEPS:
  171. {
  172. m_creature.erase(creature);
  173. break;
  174. }
  175. }
  176. }
  177.  
  178. bool OutdoorPvPCA::UpdateCreatureInfo(Creature* creature)
  179. {
  180. if (!creature)
  181. return false;
  182. uint32 entry = creature->GetEntry();
  183.  
  184. switch(GetCreatureType(entry))
  185. {
  186. case CREATURE_BOSS:
  187. case CREATURE_TOWER:
  188. case CREATURE_OTHER:
  189. case CREATURE_CREEPS:
  190. if (!creature->IsAlive())
  191. {
  192. creature->Respawn(true);
  193. creature->SetVisible(true);
  194. }
  195. return false;
  196. default:
  197. return false;
  198. }
  199. }
  200.  
  201. void OutdoorPvPCA::RespawnAllCreaturesOnCA()
  202. {
  203. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr)
  204. if(((*itr)->GetEntry() == 500107) || ((*itr)->GetEntry() == 500117))
  205. (*itr)->DespawnOrUnsummon(true);
  206. else
  207. (*itr)->Respawn(true);
  208. }
  209.  
  210. void OutdoorPvPCA::CheckNPC()
  211. {
  212. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr)
  213. {
  214. if((*itr)->isDead())
  215. {
  216. for(int i = 0; i < CA_TOWER_NUM; i)
  217. {
  218. if((*itr)->GetEntry() == CA_NPC[i].entry && check_towers[i] == 0)
  219. {
  220. check_towers[i] = 1;
  221. sWorld->SendZoneText(CA_OUTDOORPVP_ZONE,sObjectMgr->GetTrinityStringForDBCLocale(CA_LANG_LOOSE_TOWER[i]));
  222. break;
  223. }
  224. }
  225. if((*itr)->GetEntry() == CA_NPC[6].entry)
  226. {
  227. Rewards(TEAM_HORDE);
  228. RestartCA();
  229. }
  230. if((*itr)->GetEntry() == CA_NPC[7].entry)
  231. {
  232. Rewards(TEAM_ALLIANCE);
  233. RestartCA();
  234. }
  235. }
  236. }
  237. }
  238.  
  239. void OutdoorPvPCA::RestartCA()
  240. {
  241. TeleportPlayersOnCA(TEAM_HORDE);
  242. TeleportPlayersOnCA(TEAM_ALLIANCE);
  243. for (int i = 0; i < CA_TOWER_NUM; i)
  244. {
  245. check_towers[i] = 0;
  246. }
  247. RespawnAllCreaturesOnCA();
  248. }
  249. void OutdoorPvPCA::HandleKill(Player* killer, Unit* killed)
  250. {
  251. uint32 entry = killed->GetEntry();
  252. for (int i = (CA_TOWER_NUM,CA_SUMMON_NPC_NUM,CA_BOSSES_NUM); i < (CA_NEUTRALL_BOSS_NUM,CA_TOWER_NUM,CA_SUMMON_NPC_NUM,CA_BOSSES_NUM); i)
  253. {
  254. if (entry == CA_NPC[i].entry)
  255. {
  256. sWorld->SendZoneText(CA_OUTDOORPVP_ZONE,sObjectMgr->GetTrinityStringForDBCLocale(CA_LANG_KILLED_N_BOSS[killer->GetTeamId()]));
  257. killer->CastSpell(killer,SPELL_KILL_BOSS_NEUTRAL,true);
  258. TeamCastSpell(killer->GetTeamId(),SPELL_KILL_BOSS_NEUTRAL_ALL);
  259. break;
  260. }
  261. }
  262. for (int i = (CA_TOWER_NUM,CA_SUMMON_NPC_NUM,CA_BOSSES_NUM,CA_NEUTRALL_BOSS_NUM); i < (CA_NEUTRALL_BOSS_NUM,CA_TOWER_NUM,CA_SUMMON_NPC_NUM,CA_BOSSES_NUM,CA_NEUTRALL_CREEP_NUM); i)
  263. {
  264. if (entry == CA_NPC[i].entry)
  265. {
  266. killer->CastSpell(killer,SPELL_KILL_CREEP_NEUTRAL,true);
  267. break;
  268. }
  269. }
  270. }
  271. void OutdoorPvPCA::UpdateTenacityStack()
  272. {
  273. TeamId team = TEAM_NEUTRAL;
  274. uint32 allianceNum = 0;
  275. uint32 hordeNum = 0;
  276. int32 newStack = 0;
  277.  
  278. for (PlayerSet::iterator itr = m_players[TEAM_ALLIANCE].begin(); itr != m_players[TEAM_ALLIANCE].end(); itr)
  279. {
  280. uint64 playerGuid = *itr;
  281. ++itr;
  282.  
  283. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  284. if (player->getLevel() > 79)
  285. allianceNum;
  286. }
  287. for (PlayerSet::iterator itr = m_players[TEAM_HORDE].begin(); itr != m_players[TEAM_HORDE].end(); itr)
  288. {
  289. uint64 playerGuid = *itr;
  290. ++itr;
  291.  
  292. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  293. if (player->getLevel() > 79)
  294. hordeNum;
  295. }
  296. if (allianceNum && hordeNum)
  297. {
  298. if (allianceNum < hordeNum)
  299. newStack = int32((float(hordeNum) / float(allianceNum) - 1)*4); // positive, should cast on alliance
  300. else if (allianceNum > hordeNum)
  301. newStack = int32((1 - float(allianceNum) / float(hordeNum))*4); // negative, should cast on horde
  302. }
  303.  
  304. if (newStack == m_tenacityStack)
  305. return;
  306.  
  307. if (m_tenacityStack > 0 && newStack <= 0) // old buff was on alliance
  308. team = TEAM_ALLIANCE;
  309. else if (m_tenacityStack < 0 && newStack >= 0) // old buff was on horde
  310. team = TEAM_HORDE;
  311.  
  312. m_tenacityStack = newStack;
  313.  
  314. // Remove old buff
  315. if (team != TEAM_NEUTRAL)
  316. {
  317. for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); itr)
  318. {
  319. uint64 playerGuid = *itr;
  320. ++itr;
  321.  
  322. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  323. if (player->getLevel() > 79)
  324. player->RemoveAurasDueToSpell(SPELL_TENACITY);
  325.  
  326. for (CreatureSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); itr)
  327. (*itr)->RemoveAurasDueToSpell(SPELL_TENACITY_VEHICLE);
  328. }
  329. }
  330. // Apply new buff
  331. if (newStack)
  332. {
  333. team = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE;
  334. if (newStack < 0)
  335. newStack = -newStack;
  336. if (newStack > 20)
  337. newStack = 20;
  338.  
  339. for (PlayerSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); itr)
  340. {
  341. uint64 playerGuid = *itr;
  342. ++itr;
  343.  
  344. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  345. if (player->getLevel() > 79)
  346. {
  347. player->SetAuraStack(SPELL_TENACITY, player , newStack);
  348. }
  349. }
  350. for (CreatureSet::const_iterator itr = m_vehicles[team].begin(); itr != m_vehicles[team].end(); itr)
  351. (*itr)->SetAuraStack(SPELL_TENACITY_VEHICLE, (*itr), newStack);
  352. }
  353. }
  354.  
  355. void OutdoorPvPCA::HandlePlayerEnterZone(Player * plr, uint32 zone)
  356. {
  357. const creature_type* creatures = CA_NPC;
  358. if (plr->GetTeam() == ALLIANCE)
  359. {
  360. int i = 0;
  361. while (i < (CA_TOWER_NUM/2))
  362. {
  363. if (check_towers[i] == 0)
  364. plr->CastSpell(plr,Buff[i],true);
  365. i;
  366. }
  367. }
  368. else
  369. {
  370. int i = (CA_TOWER_NUM/2);
  371. while (i < CA_TOWER_NUM)
  372. {
  373. if (check_towers[i] == 0)
  374. plr->CastSpell(plr,Buff[i],true);
  375. i;
  376. }
  377. }
  378.  
  379. OutdoorPvP::HandlePlayerEnterZone(plr,zone);
  380. UpdateTenacityStack();
  381. }
  382.  
  383. void OutdoorPvPCA::HandlePlayerLeaveZone(Player * plr, uint32 zone)
  384. {
  385. if (plr->GetTeam() == ALLIANCE)
  386. {
  387. for (int i = 0; i < (CA_TOWER_NUM/2); i)
  388. plr->RemoveAurasDueToSpell(Buff[i]);
  389. }
  390. else
  391. {
  392. for (int i = 0; i < (CA_TOWER_NUM/2); i)
  393. plr->RemoveAurasDueToSpell(Buff[i]);
  394. }
  395. plr->RemoveAurasDueToSpell(SPELL_TENACITY);
  396. OutdoorPvP::HandlePlayerLeaveZone(plr, zone);
  397. UpdateTenacityStack();
  398. }
  399.  
  400. void OutdoorPvPCA::HandleKillImpl(Player *plr, Unit * killed)
  401. {
  402. if (killed->GetTypeId() == TYPEID_PLAYER && plr->GetTeam() != killed->ToPlayer()->GetTeam())
  403. plr->AddItem(KILLREWARD,1);
  404. }
  405.  
  406. void OutdoorPvPCA::Rewards(TeamId team)
  407. {
  408. for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); itr)
  409. {
  410. uint64 playerGuid = *itr;
  411. ++itr;
  412.  
  413. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  414. player->AddItem(WINREWARD,10);
  415. }
  416. }
  417.  
  418. void OutdoorPvPCA::ResurrectSystem(TeamId team)
  419. {
  420. for (PlayerSet::iterator itr = m_players[team].begin(); itr != m_players[team].end(); itr)
  421. {
  422. uint64 playerGuid = *itr;
  423. ++itr;
  424.  
  425. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  426. if (player->isDead())
  427. {
  428. player->TeleportTo(SPAWN[player->GetTeamId()].map,SPAWN[player->GetTeamId()].x,SPAWN[player->GetTeamId()].y,SPAWN[player->GetTeamId()].z,SPAWN[player->GetTeamId()].o,0);
  429. player->ResurrectPlayer(100, false);
  430. }
  431. }
  432. }
  433.  
  434. void OutdoorPvPCA::AddCre(uint32 type, uint32 guid, uint32 entry)
  435. {
  436. if (!entry)
  437. {
  438. const CreatureData *data = sObjectMgr->GetCreatureData(guid);
  439. if (!data)
  440. return;
  441. entry = data->id;
  442. }
  443. m_Creatures[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_UNIT);
  444. m_CreatureTypes[m_Creatures[type]] = type;
  445. }
  446.  
  447. bool OutdoorPvPCA::AddCreature(uint32 type, uint32 entry, uint32 team, uint32 map, float x, float y, float z, float o, uint32 spawntimedelay)
  448. {
  449. if (uint32 guid = sObjectMgr->AddCreData(entry, team, map, x, y, z, o, spawntimedelay))
  450. {
  451. AddCre(type, guid, entry);
  452. return true;
  453. }
  454.  
  455. return false;
  456. }
  457.  
  458. bool OutdoorPvPCA::DelCreature(uint32 type)
  459. {
  460. if (!m_Creatures[type])
  461. {
  462. return false;
  463. }
  464.  
  465. Creature *cr = HashMapHolder<Creature>::Find(m_Creatures[type]);
  466. if (!cr)
  467. {
  468. // can happen when closing the core
  469. m_Creatures[type] = 0;
  470. return false;
  471. }
  472. uint32 guid = cr->GetDBTableGUIDLow();
  473. // Don't save respawn time
  474. cr->SetRespawnTime(0);
  475. cr->RemoveCorpse();
  476. PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
  477. stmt->setUInt32(0, guid);
  478. CharacterDatabase.Execute(stmt);
  479.  
  480. cr->AddObjectToRemoveList();
  481. sObjectMgr->DeleteCreatureData(guid);
  482. m_CreatureTypes[m_Creatures[type]] = 0;
  483. m_Creatures[type] = 0;
  484. return true;
  485. }
  486.  
  487. bool OutdoorPvPCA::AddObject(uint32 type, uint32 entry, uint32 map, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3)
  488. {
  489. if (uint32 guid = sObjectMgr->AddGOData(entry, map, x, y, z, o, 0, rotation0, rotation1, rotation2, rotation3))
  490. {
  491. AddGO(type, guid, entry);
  492. return true;
  493. }
  494. return false;
  495. }
  496.  
  497. void OutdoorPvPCA::AddGO(uint32 type, uint32 guid, uint32 entry)
  498. {
  499. if (!entry)
  500. {
  501. const GameObjectData *data = sObjectMgr->GetGOData(guid);
  502. if (!data)
  503. return;
  504. entry = data->id;
  505. }
  506. m_Objects[type] = MAKE_NEW_GUID(guid, entry, HIGHGUID_GAMEOBJECT);
  507. m_ObjectTypes[m_Objects[type]]=type;
  508. }
  509.  
  510. bool OutdoorPvPCA::DelObject(uint32 type)
  511. {
  512. if (!m_Objects[type])
  513. return false;
  514.  
  515. GameObject *obj = HashMapHolder<GameObject>::Find(m_Objects[type]);
  516. if (!obj)
  517. {
  518. m_Objects[type] = 0;
  519. return false;
  520. }
  521. uint32 guid = obj->GetDBTableGUIDLow();
  522. obj->SetRespawnTime(0); // not save respawn time
  523. obj->Delete();
  524. sObjectMgr->DeleteGOData(guid);
  525. m_ObjectTypes[m_Objects[type]] = 0;
  526. m_Objects[type] = 0;
  527. return true;
  528. }
  529.  
  530. bool OutdoorPvPCA::Update(uint32 diff)
  531. {
  532. bool changed = OutdoorPvP::Update(diff);
  533. if (!changed)
  534. {
  535. int i = 0;
  536. while (i < CA_TOWER_NUM)
  537. {
  538. if (i < (CA_TOWER_NUM/2))
  539. if (check_towers[i] == 0)
  540. {
  541. for (PlayerSet::iterator itr = m_players[TEAM_ALLIANCE].begin(); itr != m_players[TEAM_ALLIANCE].end(); itr)
  542. {
  543. uint64 playerGuid = *itr;
  544. ++itr;
  545.  
  546. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  547. if(!player->HasAura(Buff[i]))
  548. {
  549. player->CastSpell(player, Buff[i], true);
  550. } }
  551. }
  552. else
  553. {
  554. for (PlayerSet::iterator itr = m_players[TEAM_ALLIANCE].begin(); itr != m_players[TEAM_ALLIANCE].end(); itr)
  555. {
  556. uint64 playerGuid = *itr;
  557. ++itr;
  558.  
  559. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  560. (player->RemoveAura(Buff[i]));
  561. }
  562. }
  563. else
  564. if (check_towers[i] == 0)
  565. {
  566. for (PlayerSet::iterator itr = m_players[TEAM_HORDE].begin(); itr != m_players[TEAM_HORDE].end(); itr++)
  567. {
  568. uint64 playerGuid = *itr;
  569. ++itr;
  570.  
  571. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  572. if(!player->HasAura(Buff[i]))
  573. {
  574. player->CastSpell(player, Buff[i], true);
  575. } }
  576. }
  577. else
  578. for (PlayerSet::iterator itr = m_players[TEAM_HORDE].begin(); itr != m_players[TEAM_HORDE].end(); itr)
  579. {
  580. uint64 playerGuid = *itr;
  581. ++itr;
  582.  
  583. if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
  584. (player->RemoveAura(Buff[i]));
  585. i;
  586. } }
  587. for(int i = 0; i < (CA_TOWER_NUM/2 - 1); i)
  588. {
  589. if(check_towers[i] == 0)
  590. {
  591. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr++)
  592. {
  593. if((*itr)->GetEntry() == CA_NPC[(i)].entry)
  594. (*itr)->SetFullHealth();
  595. }
  596. }
  597. }
  598. for(int i = (CA_TOWER_NUM/2); i < (CA_TOWER_NUM - 1); i)
  599. {
  600. if(check_towers[i] == 0)
  601. {
  602. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr++)
  603. {
  604. if((*itr)->GetEntry() == CA_NPC[(i)].entry)
  605. (*itr)->SetFullHealth();
  606. }
  607. }
  608. }
  609. if(check_towers[2] == 0)
  610. {
  611. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr)
  612. {
  613. if((*itr)->GetEntry() == CA_NPC[6].entry)
  614. (*itr)->SetFullHealth();
  615. if((*itr)->GetEntry() == CA_NPC[8].entry)
  616. (*itr)->SetFullHealth();
  617. }
  618. }
  619. if(check_towers[5] == 0)
  620. {
  621. for (CreatureSet::iterator itr = m_creature.begin(); itr != m_creature.end(); itr)
  622. {
  623. if((*itr)->GetEntry() == CA_NPC[7].entry)
  624. (*itr)->SetFullHealth();
  625. if((*itr)->GetEntry() == CA_NPC[9].entry)
  626. (*itr)->SetFullHealth();
  627. }
  628. }
  629. ResurrectSystem(TEAM_HORDE);
  630. ResurrectSystem(TEAM_ALLIANCE);
  631. CheckNPC();
  632. }
  633. return changed;
  634. }
  635.  
  636. class OutdoorPvP_crater : public OutdoorPvPScript
  637. {
  638. public:
  639.  
  640. OutdoorPvP_crater ()
  641. : OutdoorPvPScript("outdoorpvp_ca")
  642. {
  643. }
  644.  
  645. OutdoorPvP* GetOutdoorPvP() const
  646. {
  647. return new OutdoorPvPCA();
  648. }
  649. };
  650.  
  651. class npc_control_tower : public CreatureScript
  652. {
  653. public:
  654. npc_control_tower() : CreatureScript("npc_control_tower") { }
  655.  
  656. struct npc_control_towerAI : CasterAI
  657. {
  658. npc_control_towerAI(Creature* c) : CasterAI(c) {}
  659.  
  660. void InitializeAI()
  661. {
  662. CasterAI::InitializeAI();
  663. std::list<Unit*> targets;
  664. Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 55);
  665. Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
  666. me->VisitNearbyObject(55, searcher);
  667. me->m_CombatDistance = 55;
  668. me->m_SightDistance = 55;
  669. me->ApplySpellImmune(0, IMMUNITY_ID, SPELL_DMG, true);
  670. me->CastSpell(me,SPELL_BUFF_TOWER,true);
  671. for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); iter)
  672. {
  673. //(*iter)->IsAlwaysDetectableFor(me);
  674. //(*iter)->IsAlwaysVisibleFor(me);
  675. me->Attack((*iter), false);
  676. break;
  677. }
  678. }
  679.  
  680. void UpdateAI(uint32 diff)
  681. {
  682. CasterAI::UpdateAI(diff);
  683. }
  684. };
  685.  
  686. CreatureAI *GetAI(Creature* creature) const
  687. {
  688. return new npc_control_towerAI(creature);
  689. }
  690. };
  691.  
  692. class npc_summon_npc : public CreatureScript
  693. {
  694. public:
  695. npc_summon_npc() : CreatureScript("npc_summon_npc") { }
  696.  
  697. struct npc_summon_npcAI : CasterAI
  698. {
  699. npc_summon_npcAI(Creature* c) : CasterAI(c) {}
  700.  
  701. uint32 m_uiTimer;
  702.  
  703. void InitializeAI()
  704. {
  705. CasterAI::InitializeAI();
  706. me->ApplySpellImmune(0, IMMUNITY_ID, SPELL_DMG, true);
  707. me->setActive(true);
  708. }
  709.  
  710. void Reset()
  711. {
  712. m_uiTimer = 60000;
  713. }
  714.  
  715. void UpdateAI(uint32 diff)
  716. {
  717. CasterAI::UpdateAI(diff);
  718. if (m_uiTimer <= diff)
  719. {
  720. m_uiTimer = 60000;
  721. if(me->GetEntry() == 500118)
  722. {
  723. me->SummonCreature(500117, me->GetPositionX()+2.0f, me->GetPositionY()+7.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  724. me->SummonCreature(500117, me->GetPositionX()+6.0f, me->GetPositionY()+12.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  725. me->SummonCreature(500117, me->GetPositionX()-2.0f, me->GetPositionY()+2.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  726. me->SummonCreature(500117, me->GetPositionX()-6.0f, me->GetPositionY()-3.0f, me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  727. }
  728. if(me->GetEntry() == 500108)
  729. {
  730. me->SummonCreature(500107, me->GetPositionX()+2.0f, me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  731. me->SummonCreature(500107, me->GetPositionX()+6.0f, me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  732. me->SummonCreature(500107, me->GetPositionX()-2.0f, me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  733. me->SummonCreature(500107, me->GetPositionX()-6.0f, me->GetPositionY(), me->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 1000);
  734. }
  735. }
  736. else
  737. m_uiTimer -= diff;
  738. }
  739. };
  740.  
  741. CreatureAI *GetAI(Creature* creature) const
  742. {
  743. return new npc_summon_npcAI(creature);
  744. }
  745. };
  746.  
  747. class npc_creeps : public CreatureScript
  748. {
  749. public:
  750.  
  751. npc_creeps()
  752. : CreatureScript("npc_creeps")
  753. {
  754. }
  755.  
  756. struct npc_creepsAI : public npc_escortAI
  757. {
  758. npc_creepsAI(Creature* creature) : npc_escortAI(creature) { }
  759.  
  760. void WaypointReached(uint32 uiWP)
  761. {
  762. switch (uiWP)
  763. {
  764. case 1:
  765. break;
  766. }
  767. }
  768.  
  769. void Reset()
  770. {
  771. me->setActive(true);
  772. SetDespawnAtFar(false);
  773. npc_creepsAI* pEscortAI = CAST_AI(npc_creeps::npc_creepsAI, me->AI());
  774. if (pEscortAI)
  775. pEscortAI->Start(true,true);
  776. }
  777.  
  778. void UpdateEscortAI(const uint32 diff)
  779. {
  780. }
  781. };
  782.  
  783. CreatureAI* GetAI(Creature* creature) const
  784. {
  785. return new npc_creepsAI(creature);
  786. }
  787. };
  788.  
  789. #define GOSSIP_ITEM_1 "Îòïðàâèòñÿ íà Ïîëå áèòâû: Êðàòåð Àçøàðû"
  790. #define SPELL_VISUAL_TELEPORT 35517
  791.  
  792. class npc_tp_ca : public CreatureScript
  793. {
  794. public:
  795. npc_tp_ca() : CreatureScript("npc_tp_ca") { }
  796.  
  797. void Teleport(Player* const player, const uint16 &map, const float &X, const float &Y, const float &Z, const float &orient)
  798. {
  799. player->CastSpell(player, SPELL_VISUAL_TELEPORT, true);
  800. player->TeleportTo(map, X, Y, Z, orient);
  801. }
  802.  
  803. bool OnGossipHello(Player* player, Creature* creature)
  804. {
  805. player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  806. player->SEND_GOSSIP_MENU(3961,creature->GetGUID());
  807. return true;
  808. }
  809.  
  810. bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  811. {
  812. switch (action)
  813. {
  814. case GOSSIP_ACTION_INFO_DEF+1:
  815. if (player->getLevel() < 80)
  816. {
  817. creature->MonsterTextEmote("Äëÿ Îòïðàâëåíèÿ âû äîëæíû áûòü 80-îãî óðîâíÿ!", player->GetGUID(), true);
  818. player->CLOSE_GOSSIP_MENU();
  819. return false;
  820. }
  821.  
  822. if (player->GetHonorPoints() < 300)
  823. {
  824. creature->MonsterTextEmote("Äëÿ Îòïðàâëåíèÿ âàì ïîòðåáóåòñÿ 300 Î÷êîâ ×åñòè!", player->GetGUID(), true);
  825. player->CLOSE_GOSSIP_MENU();
  826. return false;
  827. }
  828.  
  829. if (player->GetTeamId() == TEAM_ALLIANCE)
  830. {
  831. Teleport(player, 37,1245.12f,248.638f,355.214f,3.1f);
  832. player->ModifyHonorPoints(-300);
  833. }
  834. else
  835. {
  836. Teleport(player, 37,39.38f,916.849f,339.394f,5.93f);
  837. player->ModifyHonorPoints(-300);
  838. }
  839. break;
  840. }
  841. return true;
  842. }
  843. };
  844.  
  845.  
  846. #define GOSSIP_ITEM_2 "Îêîí÷èòü áîé è îòïðàâèòüñÿ â ñòîëèöó"
  847.  
  848. class npc_tp_capital : public CreatureScript
  849. {
  850. public:
  851. npc_tp_capital() : CreatureScript("npc_tp_capital") { }
  852.  
  853. void Teleport(Player* const player, const uint16 &map, const float &X, const float &Y, const float &Z, const float &orient)
  854. {
  855. player->CastSpell(player, SPELL_VISUAL_TELEPORT, true);
  856. player->TeleportTo(map, X, Y, Z, orient);
  857. }
  858.  
  859. bool OnGossipHello(Player* player, Creature* creature)
  860. {
  861. player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, GOSSIP_ITEM_2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
  862. player->SEND_GOSSIP_MENU(3962,creature->GetGUID());
  863. return true;
  864. }
  865.  
  866. bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
  867. {
  868. switch (action)
  869. {
  870. case GOSSIP_ACTION_INFO_DEF+1:
  871. if (player->GetTeamId() == TEAM_ALLIANCE)
  872. Teleport(player, 0, -8830.62f, 622.80f, 93.85f, 3.9f);
  873. else
  874. Teleport(player, 1, 1629.35f, -4373.42f, 31.26f, 3.5f);
  875. break;
  876. }
  877. return true;
  878. }
  879. };
  880.  
  881. void AddSC_outdoorpvp_ca()
  882. {
  883. new OutdoorPvP_crater();
  884. new npc_control_tower;
  885. new npc_summon_npc;
  886. new npc_creeps;
  887. new npc_tp_ca;
  888. new npc_tp_capital;
  889. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement