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:
EmosewaMC 2022-06-19 00:44:49 -07:00
parent c871aeef56
commit 968114199b
3 changed files with 25 additions and 6 deletions

View File

@ -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())

View File

@ -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) {

View File

@ -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;
} }