Skip to content

Commit

Permalink
The trial should now fail when no players are alive or present in the…
Browse files Browse the repository at this point in the history
… arena.
  • Loading branch information
AnchyDev committed Oct 21, 2023
1 parent 8ece48c commit 8d514dd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/scripts/ToSInstanceScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,41 @@ bool ToSInstanceScript::AnyPlayerAlive()
return false;
}

bool ToSInstanceScript::AnyPlayerInArena(bool checkAlive)
{
Position arenaCenter(255.124, -99.910, 18.679, 0.0);

Map::PlayerList const& players = instance->GetPlayers();

for (const auto& it : players)
{
Player* player = it.GetSource();

if (!player)
continue;

auto distance = player->GetPosition().GetExactDist(arenaCenter);
if (distance < 30.0)
{
if (checkAlive)
{
if (!player->IsAlive())
{
return false;
}
}

return true;
}
}

return false;
}

bool ToSInstanceScript::CheckFailure()
{
// Check if all players are dead.
if (AnyPlayerAlive())
// Check if any alive in the arena.
if (AnyPlayerInArena(true))
{
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/scripts/ToSInstanceScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ToSInstanceScript : public InstanceScript
void RelocateArenaMaster(bool returning);

bool AnyPlayerAlive();
bool AnyPlayerInArena(bool checkAlive = false);

bool CheckFailure();

Expand Down

0 comments on commit 8d514dd

Please sign in to comment.