Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
BattlegroundIC.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Battleground.h"
7#include "BattlegroundIC.h"
8#include "GameObject.h"
9#include "Language.h"
10#include "ObjectMgr.h"
11#include "Player.h"
12#include "Transport.h"
13#include "Vehicle.h"
14#include "WorldPacket.h"
15#include "WorldSession.h"
16
46
48
57
59{
61 return;
62
64 return;
65
67 if (!player)
68 return;
69
71
75 player->m_movementInfo.transport.guid = (player->GetTeamId() == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->GetGUID();
76
77 if (player->TeleportTo(GetMapId(), TeleportToTransportPosition.GetPositionX(),
78 TeleportToTransportPosition.GetPositionY(),
79 TeleportToTransportPosition.GetPositionZ(),
80 TeleportToTransportPosition.GetOrientation(),
82 {
83 player->CastSpell(player, SPELL_PARACHUTE, true); // this must be changed, there is a trigger in each transport that casts the spell.
84 player->CastSpell(player, SPELL_SLOW_FALL, true);
85 }
86}
87
89{
91 return;
92
93 if (!doorsClosed)
94 {
95 if (closeFortressDoorsTimer <= diff)
96 {
99
102
103 doorsClosed = true;
104 }
105 else closeFortressDoorsTimer -= diff;
106 }
107
108 for (uint8 i = NODE_TYPE_REFINERY; i < MAX_NODE_TYPES; ++i)
109 {
110 if (nodePoint[i].nodeType == NODE_TYPE_DOCKS)
111 {
112 if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
113 nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
114 {
115 if (docksTimer <= diff)
116 {
117 // we need to confirm this, i am not sure if this every 3 minutes
119 {
120 if (Creature* catapult = GetBGCreature(u))
121 {
122 if (!catapult->IsAlive())
123 catapult->Respawn(true);
124 }
125 }
126
127 // we need to confirm this is blizzlike, not sure if it is every 3 minutes
129 {
130 if (Creature* glaiveThrower = GetBGCreature(u))
131 {
132 if (!glaiveThrower->IsAlive())
133 glaiveThrower->Respawn(true);
134 }
135 }
136
138 }
139 else docksTimer -= diff;
140 }
141 }
142
143 if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP)
144 {
145 if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
146 nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
147 {
148 if (siegeEngineWorkshopTimer <= diff)
149 {
151
152 if (Creature* siege = GetBGCreature(siegeType)) // this always should be true
153 {
154 if (siege->IsAlive())
155 {
157 // following sniffs the vehicle always has UNIT_FLAG_UNK_14
159 else
160 siege->SetHealth(siege->GetMaxHealth());
161 }
162 else
163 siege->Respawn(true);
164 }
165
166 // we need to confirm if it is every 3 minutes
168 {
169 if (Creature* demolisher = GetBGCreature(u))
170 {
171 if (!demolisher->IsAlive())
172 demolisher->Respawn(true);
173 }
174 }
176 }
177 else siegeEngineWorkshopTimer -= diff;
178 }
179 }
180
181 // the point is waiting for a change on its banner
182 if (nodePoint[i].needChange)
183 {
184 if (nodePoint[i].timer <= diff)
185 {
186 uint32 nextBanner = GetNextBanner(&nodePoint[i], nodePoint[i].faction, true);
187
188 nodePoint[i].last_entry = nodePoint[i].gameobject_entry;
189 nodePoint[i].gameobject_entry = nextBanner;
190 // nodePoint[i].faction = the faction should be the same one...
191
192 GameObject* banner = GetBGObject(nodePoint[i].gameobject_type);
193
194 if (!banner) // this should never happen
195 return;
196
197 float cords[4] = { banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() };
198
199 DelObject(nodePoint[i].gameobject_type);
200 AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY);
201
203
205 HandleCapturedNodes(&nodePoint[i], false);
206
208
209 nodePoint[i].needChange = false;
211 }
212 else nodePoint[i].timer -= diff;
213 }
214 }
215
216 if (resourceTimer <= diff)
217 {
218 for (uint8 i = 0; i < NODE_TYPE_DOCKS; ++i)
219 {
220 if (nodePoint[i].nodeState == NODE_STATE_CONTROLLED_A ||
221 nodePoint[i].nodeState == NODE_STATE_CONTROLLED_H)
222 {
223 factionReinforcements[nodePoint[i].faction] += 1;
226 }
227 }
229 }
230 else resourceTimer -= diff;
231}
232
241
243{
244 //after 20 seconds they should be despawned
247
252
253 for (uint8 i = 0; i < MAX_FORTRESS_TELEPORTERS_SPAWNS; ++i)
254 {
255 if (!AddObject(BG_IC_Teleporters[i].type, BG_IC_Teleporters[i].entry,
258 0, 0, 0, 0, RESPAWN_ONE_DAY))
259 {
260 SF_LOG_ERROR("bg.battleground", "Isle of Conquest | Starting Event Open Doors: There was an error spawning gameobject %u", BG_IC_Teleporters[i].entry);
261 }
262 }
263}
264
266{
269
271 player->CastSpell(player, SPELL_QUARRY, true);
272
274 player->CastSpell(player, SPELL_OIL_REFINERY, true);
275}
276
277void BattlegroundIC::RemovePlayer(Player* player, uint64 /*guid*/, uint32 /*team*/)
278{
279 if (player)
280 {
281 player->RemoveAura(SPELL_QUARRY);
283 }
284}
285
287{
288 // this is wrong way to implement these things. On official it done by gameobject spell cast.
290 return;
291
293 if (trigger == 5555 && player->GetTeamId() == TEAM_HORDE)
294 {
298 player->CastSpell(player, SPELL_BACK_DOOR_JOB_ACHIEVEMENT, true);
299 }
300 else if (trigger == 5535 && player->GetTeamId() == TEAM_ALLIANCE)
301 {
305 player->CastSpell(player, SPELL_BACK_DOOR_JOB_ACHIEVEMENT, true);
306 }
307}
308
309void BattlegroundIC::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
310{
311 std::map<uint64, BattlegroundScore*>::iterator itr = PlayerScores.find(player->GetGUID());
312
313 if (itr == PlayerScores.end()) // player not found...
314 return;
315
316 switch (type)
317 {
319 ((BattlegroundICScore*)itr->second)->BasesAssaulted += value;
320 break;
322 ((BattlegroundICScore*)itr->second)->BasesDefended += value;
323 break;
324 default:
325 Battleground::UpdatePlayerScore(player, type, value, doAddHonor);
326 break;
327 }
328}
329
331{
336
337 for (uint8 i = 0; i < MAX_FORTRESS_GATES_SPAWNS; ++i)
338 {
340 builder.AppendState(uws, 1);
341 }
342
343 for (uint8 i = 0; i < MAX_NODE_TYPES; ++i)
344 builder.AppendState(nodePoint[i].worldStates[nodePoint[i].nodeState], 1);
345}
346
348{
349 for (uint8 i = 0; i < MAX_NORMAL_GAMEOBJECTS_SPAWNS; ++i)
350 {
351 if (!AddObject(BG_IC_ObjSpawnlocs[i].type, BG_IC_ObjSpawnlocs[i].entry,
354 0, 0, 0, 0, RESPAWN_ONE_DAY))
355 {
356 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning gameobject %u", BG_IC_ObjSpawnlocs[i].entry);
357 return false;
358 }
359 }
360
361 for (uint8 i = 2; i < MAX_NORMAL_NPCS_SPAWNS; ++i)
362 {
367 {
368 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning creature %u", BG_IC_NpcSpawnlocs[i].entry);
369 return false;
370 }
371 }
372
377 {
378 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: Failed to spawn initial spirit guide!");
379 return false;
380 }
381
382 gunshipHorde = sTransportMgr->CreateTransport(GO_HORDE_GUNSHIP, 0, GetBgMap());
384
386 {
387 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error creating gunships!");
388 return false;
389 }
390
391 //Send transport init packet to all player in map
392 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
393 if (Player* player = ObjectAccessor::FindPlayer(itr->first))
394 GetBgMap()->SendInitTransports(player);
395
396 // setting correct factions for Keep Cannons
401
402 // correcting spawn time for keeps bombs
405
406 return true;
407}
408
410{
412 return;
413
414 uint32 entry = unit->GetEntry();
416 {
419 }
420 else if (entry == NPC_OVERLORD_AGMAR)
421 {
424 }
425
426 //Achievement Mowed Down
427 // TO-DO: This should be done on the script of each vehicle of the BG.
428 if (unit->IsVehicle())
429 killer->CastSpell(killer, SPELL_DESTROYED_VEHICLE_ACHIEVEMENT, true);
430}
431
433{
435 return;
436
437 Battleground::HandleKillPlayer(player, killer);
438
439 factionReinforcements[player->GetTeamId()] -= 1;
440
442
443 // we must end the battleground
444 if (factionReinforcements[player->GetTeamId()] < 1)
445 EndBattleground(killer->GetTeam());
446}
447
454
456{
458 return;
459
460 // All the node points are iterated to find the clicked one
461 for (uint8 i = 0; i < MAX_NODE_TYPES; ++i)
462 {
463 if (nodePoint[i].gameobject_entry == target_obj->GetEntry())
464 {
465 // THIS SHOULD NEEVEER HAPPEN
466 if (nodePoint[i].faction == player->GetTeamId())
467 return;
468
469 uint32 nextBanner = GetNextBanner(&nodePoint[i], player->GetTeamId(), false);
470
471 // we set the new settings of the nodePoint
472 nodePoint[i].faction = player->GetTeamId();
473 nodePoint[i].last_entry = nodePoint[i].gameobject_entry;
474 nodePoint[i].gameobject_entry = nextBanner;
475
476 // this is just needed if the next banner is grey
477 if (nodePoint[i].banners[BANNER_A_CONTESTED] == nextBanner ||
478 nodePoint[i].banners[BANNER_H_CONTESTED] == nextBanner)
479 {
480 nodePoint[i].timer = BANNER_STATE_CHANGE_TIME; // 1 minute for last change (real faction banner)
481 nodePoint[i].needChange = true;
482
484
485 // if we are here means that the point has been lost, or it is the first capture
486
487 if (nodePoint[i].nodeType != NODE_TYPE_REFINERY && nodePoint[i].nodeType != NODE_TYPE_QUARRY)
488 if (BgCreatures[BG_IC_NPC_SPIRIT_GUIDE_1 + (nodePoint[i].nodeType) - 2])
490
492
496 }
497 else if (nextBanner == nodePoint[i].banners[BANNER_A_CONTROLLED] ||
498 nextBanner == nodePoint[i].banners[BANNER_H_CONTROLLED])
499 // if we are going to spawn the definitve faction banner, we dont need the timer anymore
500 {
502 nodePoint[i].needChange = false;
506 }
507
508 GameObject* banner = GetBGObject(nodePoint[i].gameobject_type);
509
510 if (!banner) // this should never happen
511 return;
512
513 float cords[4] = { banner->GetPositionX(), banner->GetPositionY(), banner->GetPositionZ(), banner->GetOrientation() };
514
515 DelObject(nodePoint[i].gameobject_type);
516 if (!AddObject(nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry, cords[0], cords[1], cords[2], cords[3], 0, 0, 0, 0, RESPAWN_ONE_DAY))
517 {
518 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning a banner (type: %u, entry: %u). Isle of Conquest BG cancelled.", nodePoint[i].gameobject_type, nodePoint[i].gameobject_entry);
520 }
521
523
524 if (nodePoint[i].nodeType == NODE_TYPE_WORKSHOP)
525 {
528 }
529
531 // we dont need iterating if we are here
532 // If the needChange bool was set true, we will handle the rest in the Update Map function.
533 return;
534 }
535 }
536}
537
539{
540 //updating worldstate
541 if (nodePoint->gameobject_entry == nodePoint->banners[BANNER_A_CONTROLLED])
543 else if (nodePoint->gameobject_entry == nodePoint->banners[BANNER_A_CONTESTED])
544 nodePoint->nodeState = NODE_STATE_CONFLICT_A;
545 else if (nodePoint->gameobject_entry == nodePoint->banners[BANNER_H_CONTROLLED])
547 else if (nodePoint->gameobject_entry == nodePoint->banners[BANNER_H_CONTESTED])
548 nodePoint->nodeState = NODE_STATE_CONFLICT_H;
549
550 uint32 worldstate = nodePoint->worldStates[nodePoint->nodeState];
551
552 // with this we are sure we dont bug the client
553 for (uint8 i = 0; i < 4; ++i)
554 UpdateWorldState(nodePoint->worldStates[i], 0);
555
556 UpdateWorldState(worldstate, 1);
557}
558
560{
561 // this is only used in the update map function
562 if (returnDefinitve)
563 // here is a special case, here we must return the definitve faction banner after the grey banner was spawned 1 minute
564 return nodePoint->banners[(team == TEAM_ALLIANCE ? BANNER_A_CONTROLLED : BANNER_H_CONTROLLED)];
565
566 // there were no changes, this point has never been captured by any faction or at least clicked
567 if (nodePoint->last_entry == 0)
568 // 1 returns the CONTESTED ALLIANCE BANNER, 3 returns the HORDE one
569 return nodePoint->banners[(team == TEAM_ALLIANCE ? BANNER_A_CONTESTED : BANNER_H_CONTESTED)];
570
571 // If the actual banner is the definitive faction banner, we must return the grey banner of the player's faction
572 if (nodePoint->gameobject_entry == nodePoint->banners[BANNER_A_CONTROLLED] || nodePoint->gameobject_entry == nodePoint->banners[BANNER_H_CONTROLLED])
573 return nodePoint->banners[(team == TEAM_ALLIANCE ? BANNER_A_CONTESTED : BANNER_H_CONTESTED)];
574
575 // If the actual banner is the grey faction banner, we must return the previous banner
576 if (nodePoint->gameobject_entry == nodePoint->banners[BANNER_A_CONTESTED] || nodePoint->banners[BANNER_H_CONTESTED])
577 return nodePoint->last_entry;
578
579 // we should never be here...
580 SF_LOG_ERROR("bg.battleground", "Isle Of Conquest: Unexpected return in GetNextBanner function");
581 return 0;
582}
583
585{
586 if (nodePoint->nodeType == NODE_TYPE_HANGAR)
587 {
589 (nodePoint->faction == TEAM_ALLIANCE ? gunshipHorde : gunshipAlliance)->EnableMovement(false);
590
592 DelObject(u);
593 }
594}
595
597{
598 if (nodePoint->nodeType != NODE_TYPE_REFINERY && nodePoint->nodeType != NODE_TYPE_QUARRY)
599 {
603 (nodePoint->faction == TEAM_ALLIANCE ? ALLIANCE : HORDE)))
604 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: Failed to spawn spirit guide! point: %u, team: %u, ", nodePoint->nodeType, nodePoint->faction);
605 }
606
607 switch (nodePoint->gameobject_type)
608 {
610 // all the players on the stopped transport should be teleported out
612 break;
613
614 for (uint8 u = 0; u < MAX_HANGAR_TELEPORTERS_SPAWNS; ++u)
615 {
618 BG_IC_HangarTeleporters[u].GetPositionX(), BG_IC_HangarTeleporters[u].GetPositionY(),
619 BG_IC_HangarTeleporters[u].GetPositionZ(), BG_IC_HangarTeleporters[u].GetOrientation(),
620 0, 0, 0, 0, RESPAWN_ONE_DAY))
621 {
622 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning a gunship portal. Type: %u", BG_IC_GO_HANGAR_TELEPORTER_1 + u);
623 }
624 }
625
626 //SF_LOG_ERROR("bg.battleground", "BG_IC_GO_HANGAR_BANNER CAPTURED Faction: %u", nodePoint->faction);
627
628 (nodePoint->faction == TEAM_ALLIANCE ? gunshipAlliance : gunshipHorde)->EnableMovement(true);
629 (nodePoint->faction == TEAM_ALLIANCE ? gunshipHorde : gunshipAlliance)->EnableMovement(false);
630 // we should spawn teleporters
631 break;
635 break;
639 break;
641
642 if (recapture)
643 break;
644
647
648 // we must del opposing faction vehicles when the node is captured (unused ones)
650 {
651 if (Creature* glaiveThrower = GetBGCreature(i))
652 {
653 if (Vehicle* vehicleGlaive = glaiveThrower->GetVehicleKit())
654 {
655 if (!vehicleGlaive->GetPassenger(0))
656 DelCreature(i);
657 }
658 }
659 }
660
662 {
663 if (Creature* catapult = GetBGCreature(i))
664 {
665 if (Vehicle* vehicleGlaive = catapult->GetVehicleKit())
666 {
667 if (!vehicleGlaive->GetPassenger(0))
668 DelCreature(i);
669 }
670 }
671 }
672
673 // spawning glaive throwers
675 {
677
678 if (GetBGCreature(type) && GetBGCreature(type)->IsAlive())
679 continue;
680
682 BG_IC_DocksVehiclesGlaives[i].GetPositionX(), BG_IC_DocksVehiclesGlaives[i].GetPositionY(),
683 BG_IC_DocksVehiclesGlaives[i].GetPositionZ(), BG_IC_DocksVehiclesGlaives[i].GetOrientation(),
685 GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
686 }
687
688 // spawning catapults
689 for (uint8 i = 0; i < MAX_CATAPULTS_SPAWNS_PER_FACTION; ++i)
690 {
692
693 if (GetBGCreature(type) && GetBGCreature(type)->IsAlive())
694 continue;
695
696 if (AddCreature(NPC_CATAPULT, type, nodePoint->faction,
697 BG_IC_DocksVehiclesCatapults[i].GetPositionX(), BG_IC_DocksVehiclesCatapults[i].GetPositionY(),
698 BG_IC_DocksVehiclesCatapults[i].GetPositionZ(), BG_IC_DocksVehiclesCatapults[i].GetOrientation(),
700 GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
701 }
702 break;
704 {
707
708 if (!recapture)
709 {
710 // we must del opposing faction vehicles when the node is captured (unused ones)
712 {
713 if (Creature* demolisher = GetBGCreature(i))
714 {
715 if (Vehicle* vehicleDemolisher = demolisher->GetVehicleKit())
716 {
717 // is IsVehicleInUse working as expected?
718 if (!vehicleDemolisher->IsVehicleInUse())
719 DelCreature(i);
720 }
721 }
722 }
723
724 for (uint8 i = 0; i < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; ++i)
725 {
727
728 if (GetBGCreature(type) && GetBGCreature(type)->IsAlive())
729 continue;
730
731 if (AddCreature(NPC_DEMOLISHER, type, nodePoint->faction,
732 BG_IC_WorkshopVehicles[i].GetPositionX(), BG_IC_WorkshopVehicles[i].GetPositionY(),
733 BG_IC_WorkshopVehicles[i].GetPositionZ(), BG_IC_WorkshopVehicles[i].GetOrientation(),
735 GetBGCreature(type)->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
736 }
737
738 // we check if the opossing siege engine is in use
740
741 if (Creature* siegeEngine = GetBGCreature(enemySiege))
742 {
743 if (Vehicle* vehicleSiege = siegeEngine->GetVehicleKit())
744 {
745 // is VehicleInUse working as expected ?
746 if (!vehicleSiege->IsVehicleInUse())
747 DelCreature(enemySiege);
748 }
749 }
750
752 if (!GetBGCreature(siegeType) || !GetBGCreature(siegeType)->IsAlive())
753 {
755 BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(),
756 BG_IC_WorkshopVehicles[4].GetPositionZ(), BG_IC_WorkshopVehicles[4].GetOrientation(),
758
759 if (Creature* siegeEngine = GetBGCreature(siegeType))
760 {
762 siegeEngine->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
763 }
764 }
765 }
766
767 for (uint8 i = 0; i < MAX_WORKSHOP_BOMBS_SPAWNS_PER_FACTION; ++i)
768 {
770 workshopBombs[i].GetPositionX(), workshopBombs[i].GetPositionY(),
771 workshopBombs[i].GetPositionZ(), workshopBombs[i].GetOrientation(),
772 0, 0, 0, 0, 10);
773
774 if (GameObject* seaforiumBombs = GetBGObject(BG_IC_GO_SEAFORIUM_BOMBS_1 + i))
775 {
776 seaforiumBombs->SetRespawnTime(10);
777 seaforiumBombs->SetUInt32Value(GAMEOBJECT_FIELD_FACTION_TEMPLATE, BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]);
778 }
779 }
780 break;
781 }
782 default:
783 break;
784 }
785}
786
788{
790 uint32 uws_open = GetWorldStateFromGateEntry(go->GetEntry(), true);
791 uint32 uws_close = GetWorldStateFromGateEntry(go->GetEntry(), false);
792 if (uws_open)
793 {
794 UpdateWorldState(uws_close, 0);
795 UpdateWorldState(uws_open, 1);
796 }
798
799 uint32 lang_entry = 0;
800
801 switch (go->GetEntry())
802 {
803 case GO_HORDE_GATE_1:
805 break;
806 case GO_HORDE_GATE_2:
809 break;
810 case GO_HORDE_GATE_3:
813 break;
816 break;
817 default:
818 break;
819 }
820
821 if (go->GetEntry() == GO_HORDE_GATE_1 || go->GetEntry() == GO_HORDE_GATE_2 || go->GetEntry() == GO_HORDE_GATE_3)
822 {
824 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning creature %u", BG_IC_NpcSpawnlocs[BG_IC_NPC_OVERLORD_AGMAR].entry);
825 }
826 else if (go->GetEntry() == GO_ALLIANCE_GATE_1 || go->GetEntry() == GO_ALLIANCE_GATE_2 || go->GetEntry() == GO_ALLIANCE_GATE_3)
827 {
829 SF_LOG_ERROR("bg.battleground", "Isle of Conquest: There was an error spawning creature %u", BG_IC_NpcSpawnlocs[BG_IC_NPC_HIGH_COMMANDER_HALFORD_WYRMBANE].entry);
830 }
831
833}
834
835void BattlegroundIC::EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/, uint32 /*eventType*/) { }
836
838{
839 TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
840
841 // Is there any occupied node for this team?
842 std::vector<uint8> nodes;
843 for (uint8 i = 0; i < MAX_NODE_TYPES; ++i)
844 if (nodePoint[i].faction == player->GetTeamId())
845 nodes.push_back(i);
846
847 WorldSafeLocsEntry const* good_entry = NULL;
848 // If so, select the closest node to place ghost on
849 if (!nodes.empty())
850 {
851 float player_x = player->GetPositionX();
852 float player_y = player->GetPositionY();
853
854 float mindist = 999999.0f;
855 for (uint8 i = 0; i < nodes.size(); ++i)
856 {
857 WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_IC_GraveyardIds[nodes[i]]);
858 if (!entry)
859 continue;
860 float dist = (entry->x - player_x) * (entry->x - player_x) + (entry->y - player_y) * (entry->y - player_y);
861 if (mindist > dist)
862 {
863 mindist = dist;
864 good_entry = entry;
865 }
866 }
867 nodes.clear();
868 }
869 // If not, place ghost on starting location
870 if (!good_entry)
871 good_entry = sWorldSafeLocsStore.LookupEntry(BG_IC_GraveyardIds[teamIndex + MAX_NODE_TYPES]);
872
873 return good_entry;
874}
875
877{
878 uint32 count = 0;
880 for (int i = 0; i < NODE_TYPE_WORKSHOP; ++i)
881 {
882 if (nodePoint[i].nodeState == controlledState)
883 ++count;
884 }
885
886 return count == NODE_TYPE_WORKSHOP;
887}
888
889bool BattlegroundIC::IsSpellAllowed(uint32 spellId, Player const* player) const
890{
891 switch (spellId)
892 {
894 case SPELL_QUARRY:
895 {
896 uint32 team = player->GetTeamId();
899 return GetNodeState(nodeType) == nodeState;
900 }
901 default:
902 break;
903 }
904
905 return true;
906}
@ WINNER_NONE
@ RESPAWN_ONE_DAY
@ SCORE_BASES_ASSAULTED
@ SCORE_BASES_DEFENDED
@ STATUS_IN_PROGRESS
@ BG_STARTING_EVENT_THIRD
@ BG_STARTING_EVENT_SECOND
@ BG_STARTING_EVENT_FIRST
@ BG_STARTING_EVENT_FOURTH
const uint32 BG_IC_GraveyardIds[MAX_NODE_TYPES+2]
@ RESOURCE_HONOR_AMOUNT
@ WINNER_HONOR_AMOUNT
@ ACTION_TELEPORT_PLAYER_TO_TRANSPORT
@ NODE_TYPE_REFINERY
@ NODE_TYPE_DOCKS
@ NODE_TYPE_HANGAR
@ NODE_TYPE_QUARRY
@ MAX_NODE_TYPES
@ NODE_TYPE_WORKSHOP
@ NPC_SIEGE_ENGINE_H
@ NPC_SIEGE_ENGINE_A
@ NPC_HIGH_COMMANDER_HALFORD_WYRMBANE
@ NPC_GLAIVE_THROWER_A
@ NPC_GLAIVE_THROWER_H
@ NPC_OVERLORD_AGMAR
@ NPC_DEMOLISHER
@ NPC_CATAPULT
@ DOCKS_UPDATE_TIME
@ CLOSE_DOORS_TIME
@ IC_RESOURCE_TIME
@ BANNER_STATE_CHANGE_TIME
@ WORKSHOP_UPDATE_TIME
@ BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR01
@ BG_IC_GO_HORDE_GATE_3
@ BG_IC_GO_HANGAR_BANNER
@ BG_IC_GO_HORDE_GATE_2
@ BG_IC_GO_ALLIANCE_GATE_3
@ BG_IC_GO_DOODAD_PORTCULLISACTIVE02
@ BG_IC_GO_HANGAR_TELEPORTER_3
@ BG_IC_GO_WORKSHOP_BANNER
@ BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR01
@ BG_IC_GO_HANGAR_TELEPORTER_1
@ BG_IC_GO_ALLIANCE_GATE_1
@ BG_IC_GO_REFINERY_BANNER
@ BG_IC_GO_SEAFORIUM_BOMBS_1
@ BG_IC_GO_QUARRY_BANNER
@ BG_IC_GO_DOODAD_VR_PORTCULLIS01_2
@ BG_IC_GO_SEAFORIUM_BOMBS_2
@ BG_IC_GO_DOODAD_HU_PORTCULLIS01_1
@ BG_IC_GO_DOCKS_BANNER
@ BG_IC_GO_HORDE_KEEP_PORTCULLIS
@ BG_IC_GO_DOODAD_VR_PORTCULLIS01_1
@ BG_IC_GO_HORDE_GATE_1
@ BG_IC_GO_HUGE_SEAFORIUM_BOMBS_A_1
@ BG_IC_GO_ALLIANCE_GATE_2
@ BG_IC_GO_DOODAD_HU_PORTCULLIS01_2
@ BG_IC_GO_HUGE_SEAFORIUM_BOMBS_H_4
const Position BG_IC_WorkshopVehicles[5]
@ BG_IC_H_FRONT
@ BG_IC_A_WEST
@ BG_IC_H_WEST
@ BG_IC_A_FRONT
@ BG_IC_MAXDOOR
@ BG_IC_A_EAST
@ BG_IC_H_EAST
const Position TeleportToTransportPosition
@ SPELL_PARACHUTE
@ SPELL_QUARRY
@ SPELL_SLOW_FALL
@ SPELL_BACK_DOOR_JOB_ACHIEVEMENT
@ SPELL_DESTROYED_VEHICLE_ACHIEVEMENT
@ SPELL_OIL_REFINERY
@ MAX_WORKSHOP_SPAWNS
@ MAX_SPIRIT_GUIDES_SPAWNS
@ MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION
@ MAX_NORMAL_GAMEOBJECTS_SPAWNS
@ MAX_AIRSHIPS_SPAWNS
@ MAX_WORKSHOP_BOMBS_SPAWNS_PER_FACTION
@ MAX_DOCKS_SPAWNS
@ MAX_NORMAL_NPCS_SPAWNS
@ MAX_CATAPULTS_SPAWNS_PER_FACTION
@ MAX_DEMOLISHERS_SPAWNS_PER_FACTION
@ MAX_FORTRESS_TELEPORTERS_SPAWNS
@ MAX_FORTRESS_GATES_SPAWNS
@ MAX_HANGAR_TELEPORTERS_SPAWNS
const uint32 BG_IC_Factions[2]
@ BG_IC_HORDE_RENFORT
@ BG_IC_HORDE_RENFORT_SET
@ BG_IC_ALLIANCE_RENFORT_SET
@ BG_IC_ALLIANCE_RENFORT
#define MAX_REINFORCEMENTS
const float BG_IC_SpiritGuidePos[MAX_NODE_TYPES+2][4]
@ BG_IC_GATE_DESTROYED
@ BG_IC_GATE_OK
const Position TransportMovementInfo
const ICGo BG_IC_ObjSpawnlocs[MAX_NORMAL_GAMEOBJECTS_SPAWNS]
const Position BG_IC_HangarTeleporters[3]
const ICNodePoint nodePointInitial[7]
const ICNpc BG_IC_NpcSpawnlocs[MAX_NORMAL_NPCS_SPAWNS]
@ BANNER_A_CONTROLLED
@ BANNER_H_CONTESTED
@ BANNER_H_CONTROLLED
@ BANNER_A_CONTESTED
const Position workshopBombs[2]
ICNodeState
@ NODE_STATE_CONFLICT_H
@ NODE_STATE_CONTROLLED_A
@ NODE_STATE_CONTROLLED_H
@ NODE_STATE_CONFLICT_A
const Position BG_IC_DocksVehiclesGlaives[2]
const Position BG_IC_DocksVehiclesCatapults[4]
@ GO_ALLIANCE_GATE_3
@ GO_HORDE_GATE_2
@ GO_HORDE_GUNSHIP
@ GO_HORDE_GATE_1
@ GO_SEAFORIUM_BOMBS
@ GO_ALLIANCE_GUNSHIP_PORTAL
@ GO_ALLIANCE_GUNSHIP
@ GO_HORDE_GATE_3
@ GO_ALLIANCE_GATE_2
@ GO_ALLIANCE_GATE_1
@ GO_HORDE_GUNSHIP_PORTAL
@ BG_IC_NPC_GLAIVE_THROWER_1_H
@ BG_IC_NPC_KEEP_CANNON_13
@ BG_IC_NPC_SIEGE_ENGINE_H
@ BG_IC_NPC_CATAPULT_4_H
@ BG_IC_NPC_DEMOLISHER_1_H
@ BG_IC_NPC_CATAPULT_1_A
@ BG_IC_NPC_CATAPULT_1_H
@ BG_IC_NPC_DEMOLISHER_1_A
@ BG_IC_NPC_KEEP_CANNON_25
@ BG_IC_NPC_OVERLORD_AGMAR
@ BG_IC_NPC_SIEGE_ENGINE_A
@ BG_IC_NPC_DEMOLISHER_4_A
@ BG_IC_NPC_KEEP_CANNON_12
@ BG_IC_NPC_KEEP_CANNON_1
@ BG_IC_NPC_CATAPULT_4_A
@ BG_IC_NPC_GLAIVE_THROWER_1_A
@ BG_IC_NPC_SPIRIT_GUIDE_1
@ BG_IC_NPC_GLAIVE_THROWER_2_A
@ BG_IC_NPC_HIGH_COMMANDER_HALFORD_WYRMBANE
@ BG_IC_NPC_GLAIVE_THROWER_2_H
@ BG_IC_NPC_DEMOLISHER_4_H
const ICGo BG_IC_Teleporters[MAX_FORTRESS_TELEPORTERS_SPAWNS]
DBCStorage< WorldSafeLocsEntry > sWorldSafeLocsStore(WorldSafeLocsEntryfmt)
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
std::uint64_t uint64
Definition Define.h:76
@ LANG_BG_IC_HAS_BEGUN
Definition Language.h:961
@ LANG_BG_IC_TEAM_HAS_TAKEN_NODE
Definition Language.h:972
@ LANG_BG_IC_WEST_GATE_DESTROYED
Definition Language.h:965
@ LANG_BG_IC_EAST_GATE_DESTROYED
Definition Language.h:966
@ LANG_BG_IC_TEAM_DEFENDED_NODE
Definition Language.h:970
@ LANG_BG_IC_TEAM_WINS
Definition Language.h:964
@ LANG_BG_IC_START_HALF_MINUTE
Definition Language.h:960
@ LANG_BG_IC_HORDE_KEEP
Definition Language.h:963
@ LANG_BG_IC_ALLIANCE_KEEP
Definition Language.h:962
@ LANG_BG_IC_TEAM_ASSAULTED_NODE_2
Definition Language.h:971
@ LANG_BG_IC_SOUTH_GATE_DESTROYED
Definition Language.h:967
@ LANG_BG_IC_START_TWO_MINUTES
Definition Language.h:958
@ LANG_BG_IC_ALLIANCE
Definition Language.h:978
@ LANG_BG_IC_START_ONE_MINUTE
Definition Language.h:959
@ LANG_BG_IC_TEAM_ASSAULTED_NODE_1
Definition Language.h:969
@ LANG_BG_IC_NORTH_GATE_DESTROYED
Definition Language.h:968
@ LANG_BG_IC_HORDE
Definition Language.h:979
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:830
@ CHAT_MSG_BG_SYSTEM_NEUTRAL
TeamId
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ ALLIANCE
@ HORDE
@ GO_FLAG_DAMAGED
#define sTransportMgr
@ UNIT_FLAG_NOT_SELECTABLE
Definition Unit.h:650
@ UNIT_FLAG_IMMUNE_TO_PC
Definition Unit.h:633
@ UNIT_FLAG_UNK_14
Definition Unit.h:639
@ UNIT_FIELD_FLAGS
@ GAMEOBJECT_FIELD_FACTION_TEMPLATE
@ GAMEOBJECT_FIELD_FLAGS
virtual void AddPlayer(Player *player)
uint32 GetMapId() const
void EndBattleground(uint32 winner)
void CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
virtual void HandleKillPlayer(Player *player, Player *killer)
static TeamId GetTeamIndexByTeamId(uint32 Team)
void DoorOpen(uint32 type)
bool DelCreature(uint32 type)
BattlegroundMap * GetBgMap() const
void RemoveAuraOnTeam(uint32 SpellID, uint32 TeamID)
void RelocateDeadPlayers(uint64 queueIndex)
Relocate all players in ReviveQueue to the closest graveyard.
BGObjects BgObjects
void UpdateWorldState(uint32 Field, uint32 Value)
bool DelObject(uint32 type)
BattlegroundPlayerMap const & GetPlayers() const
BattlegroundScoreMap PlayerScores
void RewardHonorToTeam(uint32 Honor, uint32 TeamID)
bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team)
BattlegroundStatus GetStatus() const
BGCreatures BgCreatures
GameObject * GetBGObject(uint32 type)
void SendMessage2ToAll(int32 entry, ChatMsg type, Player const *source, int32 strId1=0, int32 strId2=0)
virtual void UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Creature * AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime=0)
Creature * GetBGCreature(uint32 type)
bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0)
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
void EventPlayerClickedOnFlag(Player *source, GameObject *) OVERRIDE
void UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true) OVERRIDE
void HandleKillPlayer(Player *player, Player *killer) OVERRIDE
void StartingEventOpenDoors() OVERRIDE
uint32 GetNextBanner(ICNodePoint *nodePoint, uint32 team, bool returnDefinitve)
void RemovePlayer(Player *player, uint64 guid, uint32 team) OVERRIDE
bool IsAllNodesControlledByTeam(uint32 team) const OVERRIDE
void EventPlayerDamagedGO(Player *, GameObject *go, uint32 eventType) OVERRIDE
uint32 GetNodeState(uint8 nodeType) const
Transport * gunshipHorde
BG_IC_GateState GateStatus[6]
void EndBattleground(uint32 winner)
void AddPlayer(Player *player) OVERRIDE
uint32 GetGateIDFromEntry(uint32 id)
void FillInitialWorldStates(WorldStateBuilder &builder) OVERRIDE
Transport * gunshipAlliance
void DoAction(uint32 action, uint64 var) OVERRIDE
void DestroyGate(Player *player, GameObject *go) OVERRIDE
bool IsSpellAllowed(uint32 spellId, Player const *player) const OVERRIDE
void HandleAreaTrigger(Player *player, uint32 trigger) OVERRIDE
uint16 factionReinforcements[2]
void HandleContestedNodes(ICNodePoint *nodePoint)
void PostUpdateImpl(uint32 diff) OVERRIDE
Post-update hook.
ICNodePoint nodePoint[7]
void HandleCapturedNodes(ICNodePoint *nodePoint, bool recapture)
uint32 closeFortressDoorsTimer
uint32 siegeEngineWorkshopTimer
void HandlePlayerResurrect(Player *player) OVERRIDE
uint32 GetWorldStateFromGateEntry(uint32 id, bool open)
WorldSafeLocsEntry const * GetClosestGraveYard(Player *player) OVERRIDE
void StartingEventCloseDoors() OVERRIDE
bool SetupBattleground() OVERRIDE
void UpdateNodeWorldState(ICNodePoint *nodePoint)
void HandleKillUnit(Creature *unit, Player *killer) OVERRIDE
void RemoveFromWorld() OVERRIDE
void SetRespawnTime(int32 respawn)
Definition GameObject.h:699
void SendInitTransports(Player *player)
Definition Map.cpp:2344
static Player * FindPlayer(uint64)
uint64 GetGUID() const
Definition Object.h:119
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:1261
uint32 GetEntry() const
Definition Object.h:125
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:1038
uint32 GetTeam() const
Definition Player.h:2527
TeamId GetTeamId() const
Definition Player.h:2531
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
Definition Player.cpp:2090
bool IsVehicle() const
Definition Unit.h:1523
void setFaction(uint32 faction)
Definition Unit.h:1699
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, uint64 originalCaster=0)
void SetTransport(Transport *t)
Definition Object.h:805
MovementInfo m_movementInfo
Definition Object.h:807
void AppendState(uint32 worldstate, uint32 value)
struct MovementInfo::TransportInfo transport
float m_positionZ
Definition Object.h:289
float m_positionX
Definition Object.h:287
float GetPositionZ() const
Definition Object.h:330
float m_positionY
Definition Object.h:288
float GetOrientation() const
Definition Object.h:331
float GetPositionX() const
Definition Object.h:328
float GetPositionY() const
Definition Object.h:329
float x
float y