mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +00:00
The shooting Gallery now properly ends when a player leaves the instance
The shooting Gallery now properly ends when a player leaves the instance Frakjaw player update Update the Frakjaw battle instance script to remove players when they leave the instance Simplify comparison Simplify comparison for entity pointer to be implicit
This commit is contained in:
parent
c871aeef56
commit
968114199b
@ -226,7 +226,7 @@ void EntityManager::UpdateEntities(const float deltaTime) {
|
|||||||
|
|
||||||
const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete);
|
const auto& ghostingToDelete = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entityToDelete);
|
||||||
|
|
||||||
if (entityToDelete != nullptr)
|
if (entityToDelete)
|
||||||
{
|
{
|
||||||
// If we are a player run through the player destructor.
|
// If we are a player run through the player destructor.
|
||||||
if (entityToDelete->IsPlayer())
|
if (entityToDelete->IsPlayer())
|
||||||
|
@ -91,9 +91,27 @@ void NjMonastryBossInstance::OnPlayerLoaded(Entity *self, Entity *player) {
|
|||||||
|
|
||||||
void NjMonastryBossInstance::OnPlayerExit(Entity *self, Entity *player) {
|
void NjMonastryBossInstance::OnPlayerExit(Entity *self, Entity *player) {
|
||||||
UpdatePlayer(self, player->GetObjectID(), true);
|
UpdatePlayer(self, player->GetObjectID(), true);
|
||||||
//TODO: Add functionality to dynamically turn off the large team variable when enough players leave.
|
// Fetch the total players loaded from the vars
|
||||||
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlayerLeft", 0, 0,
|
auto totalPlayersLoaded = self->GetVar<std::vector<LWOOBJID> >(TotalPlayersLoadedVariable);
|
||||||
player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
|
|
||||||
|
// Find the player to remove
|
||||||
|
auto playerToRemove = std::find(totalPlayersLoaded.begin(), totalPlayersLoaded.end(), player->GetObjectID());
|
||||||
|
|
||||||
|
// If we found the player remove them from out list of players
|
||||||
|
if (playerToRemove != totalPlayersLoaded.end()) {
|
||||||
|
totalPlayersLoaded.erase(playerToRemove);
|
||||||
|
} else {
|
||||||
|
Game::logger->Log("NjMonastryBossInstance", "Failed to remove player at exit.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the players loaded var back
|
||||||
|
self->SetVar<std::vector<LWOOBJID>>(TotalPlayersLoadedVariable, totalPlayersLoaded);
|
||||||
|
|
||||||
|
// Since this is an exit method, check if enough players have left. If enough have left
|
||||||
|
// resize the instance to account for such.
|
||||||
|
if (totalPlayersLoaded.size() <= 2) self->SetVar<bool>(LargeTeamVariable, false);
|
||||||
|
|
||||||
|
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlayerLeft", 0, 0, player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NjMonastryBossInstance::OnActivityTimerDone(Entity *self, const std::string &name) {
|
void NjMonastryBossInstance::OnActivityTimerDone(Entity *self, const std::string &name) {
|
||||||
|
@ -144,8 +144,9 @@ void SGCannon::OnMessageBoxResponse(Entity *self, Entity *sender, int32_t button
|
|||||||
if (player != nullptr) {
|
if (player != nullptr) {
|
||||||
if (button == 1 && identifier == u"Shooting_Gallery_Stop")
|
if (button == 1 && identifier == u"Shooting_Gallery_Stop")
|
||||||
{
|
{
|
||||||
static_cast<Player*>(player)->SendToZone(1300);
|
UpdatePlayer(self, player->GetObjectID(), true);
|
||||||
|
RemovePlayer(player->GetObjectID());
|
||||||
|
StopGame(self, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user