Skip to content

Commit

Permalink
Core/Arena: Add Dalaran Sewers and Ring of Valor to the arena system.…
Browse files Browse the repository at this point in the history
… Also implement the DynLoS system for both battlegrounds.

Thanks for:
- @kerhong : For the first version of DynLoS.
- @kapoeira : For first version of Dalaran Sewers event handling.
  • Loading branch information
Souler authored and fredimachado committed Oct 27, 2011
1 parent 73fbf13 commit a2858f8
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 30 deletions.
4 changes: 4 additions & 0 deletions sql/custom/world_arenas.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DELETE FROM spell_script_names WHERE ScriptName='spell_warl_demonic_circle_summon';
INSERT INTO spell_script_names VALUES (48018, 'spell_warl_demonic_circle_summon');

DELETE FROM disables WHERE sourceType=3 AND entry IN (10,11);
90 changes: 75 additions & 15 deletions src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,81 @@ BattlegroundDS::~BattlegroundDS()

void BattlegroundDS::PostUpdateImpl(uint32 diff)
{
if (getWaterFallTimer() < diff)
if (m_knockback)
{
if (isWaterFallActive())
if (m_knockback <= diff)
{
setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
SpawnBGObject(i, getWaterFallTimer());
setWaterFallActive(false);
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
Player *plr = ObjectAccessor::FindPlayer(itr->first);
if (!plr)
continue;

if (plr->GetDistance2d(1214.0f, 765.0f) <= 50.0f && plr->GetPositionZ() > 13.0f)
plr->KnockBackWithAngle(0.0f, 55.0f, 9.0f);
else if (plr->GetDistance2d(1369.0f, 817.0f) <= 50.0f && plr->GetPositionZ() > 13.0f)
plr->KnockBackWithAngle(M_PI, 55.0f, 9.0f);
}
m_knockback = 0;
}
else
m_knockback -= diff;
}

if (!m_knockback && m_teleport)
{
if (m_teleport <= diff)
{
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
Player* plr = ObjectAccessor::FindPlayer(itr->first);
if (!plr)
continue;

if (plr->GetPositionZ() > 13.0f)
HandlePlayerUnderMap(plr);
}
m_teleport = 5 * IN_MILLISECONDS;
}
else
m_teleport -= diff;
}

if (m_waterFall <= diff)
{
if (m_waterFallStatus == 0) // Add the water
{
DoorClose(BG_DS_OBJECT_WATER_2);
m_waterFall = 7 * IN_MILLISECONDS;
m_waterFallStatus = 1;
}
else if (m_waterFallStatus == 1) // Knockback, spawn the LOS object
{
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
Player *plr = ObjectAccessor::FindPlayer(itr->first);
if (!plr)
continue;

if (plr->GetDistance2d(1291.56f, 790.837f) <= BG_DS_WATERFALL_RADIUS)
plr->KnockbackFrom(1291.56f, 790.837f, 20.0f, 7.0f);
}
SpawnBGObject(BG_DS_OBJECT_WATER_1, RESPAWN_IMMEDIATELY);
GetBgMap()->SetDynLOSObjectState(m_dynamicLOSid, true);
m_waterFall = BG_DS_WATERFALL_DURATION;
m_waterFallStatus = 2;
}
else // remove LOS and water
{
setWaterFallTimer(BG_DS_WATERFALL_DURATION);
for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
SpawnBGObject(i, RESPAWN_IMMEDIATELY);
setWaterFallActive(true);
DoorOpen(BG_DS_OBJECT_WATER_2);
SpawnBGObject(BG_DS_OBJECT_WATER_1, RESPAWN_ONE_DAY);
GetBgMap()->SetDynLOSObjectState(m_dynamicLOSid, false);
m_waterFall = urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX);
m_waterFallStatus = 0;
}
}
else
setWaterFallTimer(getWaterFallTimer() - diff);
m_waterFall -= diff;
}

void BattlegroundDS::StartingEventCloseDoors()
Expand All @@ -81,11 +137,15 @@ void BattlegroundDS::StartingEventOpenDoors()
for (uint32 i = BG_DS_OBJECT_BUFF_1; i <= BG_DS_OBJECT_BUFF_2; ++i)
SpawnBGObject(i, 60);

setWaterFallTimer(urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX));
setWaterFallActive(false);
SpawnBGObject(BG_DS_OBJECT_WATER_1, RESPAWN_ONE_DAY);
SpawnBGObject(BG_DS_OBJECT_WATER_2, RESPAWN_IMMEDIATELY);
DoorOpen(BG_DS_OBJECT_WATER_2);

for (uint32 i = BG_DS_OBJECT_WATER_1; i <= BG_DS_OBJECT_WATER_2; ++i)
SpawnBGObject(i, getWaterFallTimer());
m_knockback = 15 * IN_MILLISECONDS;
m_teleport = 5 * IN_MILLISECONDS;
m_waterFallStatus = 0;
m_waterFall = urand(BG_DS_WATERFALL_TIMER_MIN, BG_DS_WATERFALL_TIMER_MAX);
m_dynamicLOSid = GetBgMap()->AddDynLOSObject(1291.56f, 790.837f, BG_DS_WATERFALL_RADIUS);
}

void BattlegroundDS::AddPlayer(Player* plr)
Expand Down
18 changes: 8 additions & 10 deletions src/server/game/Battlegrounds/Zones/BattlegroundDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ enum BattlegroundDSObjects
{
BG_DS_OBJECT_TYPE_DOOR_1 = 192642,
BG_DS_OBJECT_TYPE_DOOR_2 = 192643,
BG_DS_OBJECT_TYPE_WATER_1 = 194395,
BG_DS_OBJECT_TYPE_WATER_2 = 191877,
BG_DS_OBJECT_TYPE_WATER_1 = 194395, // LoS checker
BG_DS_OBJECT_TYPE_WATER_2 = 191877, // Visual
BG_DS_OBJECT_TYPE_BUFF_1 = 184663,
BG_DS_OBJECT_TYPE_BUFF_2 = 184664
};
Expand All @@ -47,6 +47,7 @@ enum BattlegroundDSData
BG_DS_WATERFALL_TIMER_MIN = 30000,
BG_DS_WATERFALL_TIMER_MAX = 60000,
BG_DS_WATERFALL_DURATION = 10000,
BG_DS_WATERFALL_RADIUS = 4,
};

class BattlegroundDSScore : public BattlegroundScore
Expand Down Expand Up @@ -76,14 +77,11 @@ class BattlegroundDS : public Battleground
void HandleKillPlayer(Player* player, Player* killer);
bool HandlePlayerUnderMap(Player* plr);
private:
uint32 m_waterTimer;
bool m_waterfallActive;

virtual void PostUpdateImpl(uint32 diff);
protected:
bool isWaterFallActive() { return m_waterfallActive; };
void setWaterFallActive(bool active) { m_waterfallActive = active; };
void setWaterFallTimer(uint32 timer) { m_waterTimer = timer; };
uint32 getWaterFallTimer() { return m_waterTimer; };
uint8 m_waterFallStatus;
uint32 m_waterFall;
uint32 m_teleport;
uint32 m_knockback;
uint32 m_dynamicLOSid;
};
#endif
43 changes: 43 additions & 0 deletions src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ BattlegroundRV::~BattlegroundRV()

void BattlegroundRV::PostUpdateImpl(uint32 diff)
{
if(GetStatus() != STATUS_IN_PROGRESS)
return;

if (getTimer() < diff)
{
switch (getState())
Expand All @@ -65,6 +68,7 @@ void BattlegroundRV::PostUpdateImpl(uint32 diff)
DoorOpen(i);
setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
setState(BG_RV_STATE_OPEN_FIRE);
SwitchDynLos();
break;
case BG_RV_STATE_OPEN_FIRE:
// FIXME: after 3.2.0 it's only decorative and should be opened only one time at battle start
Expand All @@ -78,6 +82,7 @@ void BattlegroundRV::PostUpdateImpl(uint32 diff)
DoorOpen(i);
setTimer(BG_RV_PILAR_TO_FIRE_TIMER);
setState(BG_RV_STATE_CLOSE_FIRE);
SwitchDynLos();
break;
}
}
Expand All @@ -100,6 +105,16 @@ void BattlegroundRV::StartingEventOpenDoors()

setState(BG_RV_STATE_OPEN_FENCES);
setTimer(BG_RV_FIRST_TIMER);

// Add all DynLoS to the map
m_DynLos[0] = GetBgMap()->AddDynLOSObject(763.632385f, -306.162384f, 25.909504f, BG_RV_PILLAR_SMALL_RADIUS, BG_RV_PILLAR_SMALL_HEIGHT);
m_DynLos[1] = GetBgMap()->AddDynLOSObject(763.611145f, -261.856750f, 25.909504f, BG_RV_PILLAR_SMALL_RADIUS, BG_RV_PILLAR_SMALL_HEIGHT);
m_DynLos[2] = GetBgMap()->AddDynLOSObject(723.644287f, -284.493256f, 24.648525f, BG_RV_PILLAR_BIG_RADIUS, BG_RV_PILLAR_BIG_RADIUS);
m_DynLos[3] = GetBgMap()->AddDynLOSObject(802.211609f, -284.493256f, 24.648525f, BG_RV_PILLAR_BIG_RADIUS, BG_RV_PILLAR_BIG_HEIGHT);

// Activate the small ones
for (uint8 i = 0; i <= 1; i++)
GetBgMap()->SetDynLOSObjectState(m_DynLos[i], true);
}

void BattlegroundRV::AddPlayer(Player* plr)
Expand Down Expand Up @@ -146,6 +161,10 @@ void BattlegroundRV::HandleKillPlayer(Player* player, Player* killer)

bool BattlegroundRV::HandlePlayerUnderMap(Player* player)
{
// Wait for elevators to Go up, before start checking for UnderMaped players
if(GetStartTime() < uint32(m_StartDelayTimes[BG_STARTING_EVENT_FIRST] + 20*IN_MILLISECONDS))
return true;

player->TeleportTo(GetMapId(), 763.5f, -284, 28.276f, 2.422f, false);
return true;
}
Expand Down Expand Up @@ -221,3 +240,27 @@ bool BattlegroundRV::SetupBattleground()
}
return true;
}

void BattlegroundRV::SwitchDynLos()
{
// switch all DynLos to the opposite state
for (uint8 i = 0; i <= 3; i++)
GetBgMap()->SetDynLOSObjectState(m_DynLos[i], !GetBgMap()->GetDynLOSObjectState(m_DynLos[i]));

// Force every pillar to update their status to players
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
{
Player *player = ObjectAccessor::FindPlayer(itr->first);
if (!player)
continue;

if(GameObject* pilar = GetBGObject(BG_RV_OBJECT_PILAR_1))
pilar->SendUpdateToPlayer(player);
if(GameObject* pilar = GetBGObject(BG_RV_OBJECT_PILAR_2))
pilar->SendUpdateToPlayer(player);
if(GameObject* pilar = GetBGObject(BG_RV_OBJECT_PILAR_3))
pilar->SendUpdateToPlayer(player);
if(GameObject* pilar = GetBGObject(BG_RV_OBJECT_PILAR_4))
pilar->SendUpdateToPlayer(player);
}
}
7 changes: 7 additions & 0 deletions src/server/game/Battlegrounds/Zones/BattlegroundRV.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ enum BattlegroundRVData
BG_RV_WORLD_STATE = 0xe1a,
};

#define BG_RV_PILLAR_SMALL_RADIUS 2.0f
#define BG_RV_PILLAR_SMALL_HEIGHT 5.0f
#define BG_RV_PILLAR_BIG_RADIUS 4.0f
#define BG_RV_PILLAR_BIG_HEIGHT 8.25f

class BattlegroundRVScore : public BattlegroundScore
{
public:
Expand Down Expand Up @@ -122,8 +127,10 @@ class BattlegroundRV : public Battleground
uint32 State;

virtual void PostUpdateImpl(uint32 diff);
virtual void SwitchDynLos();

protected:
uint32 m_DynLos[4];
uint32 getTimer() { return Timer; };
void setTimer(uint32 timer) { Timer = timer; };

Expand Down
15 changes: 12 additions & 3 deletions src/server/game/Entities/Object/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,15 +1347,15 @@ bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const

float ox, oy, oz;
obj->GetPosition(ox, oy, oz);
return(IsWithinLOS(ox, oy, oz));
return (IsWithinLOS(ox, oy, oz) && GetMap()->IsInDynLOS(GetPositionX(), GetPositionY(), GetPositionZ(), ox, oy, oz));
}

bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
{
float x, y, z;
GetPosition(x, y, z);
VMAP::IVMapManager* vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
return vMapManager->isInLineOfSight(GetMapId(), x, y, z+2.0f, ox, oy, oz+2.0f);
return (vMapManager->isInLineOfSight(GetMapId(), x, y, z+2.0f, ox, oy, oz+2.0f) && GetMap()->IsInDynLOS(GetPositionX(), GetPositionY(), GetPositionZ(), ox, oy, oz));
}

bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const
Expand Down Expand Up @@ -2653,9 +2653,18 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
// move back a bit
destx -= CONTACT_DISTANCE * cos(angle);
desty -= CONTACT_DISTANCE * sin(angle);
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));
}

while (!GetMap()->IsInDynLOS(pos.m_positionX, pos.m_positionY, pos.m_positionZ, destx, desty, destz))
{
destx -= 2.0f * cos(angle);
desty -= 2.0f * sin(angle);
col = true;
}

if (col)
dist = sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty)*(pos.m_positionY - desty));

float step = dist/10.0f;

for (uint8 j = 0; j < 10; ++j)
Expand Down
16 changes: 16 additions & 0 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,22 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
return true;
}

void Player::KnockBackWithAngle(float angle, float horizontalSpeed, float verticalSpeed)
{
float vsin = sin(angle);
float vcos = cos(angle);

// Effect propertly implemented only for players
WorldPacket data(SMSG_MOVE_KNOCK_BACK, 8+4+4+4+4+4);
data.append(GetPackGUID());
data << uint32(0); // Sequence
data << float(vcos); // x direction
data << float(vsin); // y direction
data << float(horizontalSpeed); // Horizontal speed
data << float(-verticalSpeed); // Z Movement speed (vertical)
GetSession()->SendPacket(&data);
}

bool Player::TeleportToBGEntryPoint()
{
if (m_bgData.joinPos.m_mapId == MAPID_INVALID)
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ class Player : public Unit, public GridObject<Player>

bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
void TeleportOutOfMap(Map* oldMap);

void KnockBackWithAngle(float angle, float horizontalSpeed, float verticalSpeed);
bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
{
return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options);
Expand Down

0 comments on commit a2858f8

Please sign in to comment.