Frakjaw Battle instance fixes (#409)

* Update NjMonastryBossInstance.cpp

* Changed spawn position to be 1.

* Changed stored variable from vector to int

Added clarifying comments
This commit is contained in:
David Markowitz 2022-02-05 04:11:58 -08:00 committed by GitHub
parent 933cdee414
commit 84cf79906b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,9 +47,8 @@ void NjMonastryBossInstance::OnStartup(Entity *self) {
void NjMonastryBossInstance::OnPlayerLoaded(Entity *self, Entity *player) { void NjMonastryBossInstance::OnPlayerLoaded(Entity *self, Entity *player) {
ActivityTimerStop(self, WaitingForPlayersTimer); ActivityTimerStop(self, WaitingForPlayersTimer);
// Join the player in the activity and charge for joining // Join the player in the activity
UpdatePlayer(self, player->GetObjectID()); UpdatePlayer(self, player->GetObjectID());
TakeActivityCost(self, player->GetObjectID());
// Buff the player // Buff the player
auto* destroyableComponent = player->GetComponent<DestroyableComponent>(); auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
@ -59,23 +58,22 @@ void NjMonastryBossInstance::OnPlayerLoaded(Entity *self, Entity *player) {
destroyableComponent->SetImagination((int32_t) destroyableComponent->GetMaxImagination()); destroyableComponent->SetImagination((int32_t) destroyableComponent->GetMaxImagination());
} }
// Track the player ID // Add player ID to instance
auto totalPlayersLoaded = self->GetVar<std::vector<LWOOBJID>>(TotalPlayersLoadedVariable); auto totalPlayersLoaded = self->GetVar<std::vector<LWOOBJID>>(TotalPlayersLoadedVariable);
if (totalPlayersLoaded.empty() || std::find(totalPlayersLoaded.begin(), totalPlayersLoaded.end(), player->GetObjectID()) != totalPlayersLoaded.end()) {
totalPlayersLoaded.push_back(player->GetObjectID()); totalPlayersLoaded.push_back(player->GetObjectID());
}
// Properly position the player // Properly position the player
self->SetVar<std::vector<LWOOBJID>>(TotalPlayersLoadedVariable, totalPlayersLoaded); self->SetVar<std::vector<LWOOBJID>>(TotalPlayersLoadedVariable, totalPlayersLoaded);
TeleportPlayer(player, totalPlayersLoaded.size()); // This was always spawning all players at position one before and other values cause players to be invisible.
TeleportPlayer(player, 1);
// Large teams face a tougher challenge // Large teams face a tougher challenge
if (totalPlayersLoaded.size() > 2) if (totalPlayersLoaded.size() >= 3)
self->SetVar<bool>(LargeTeamVariable, true); self->SetVar<bool>(LargeTeamVariable, true);
// Start the game if all players in the team have loaded // Start the game if all players in the team have loaded
auto* team = TeamManager::Instance()->GetTeam(player->GetObjectID()); auto* team = TeamManager::Instance()->GetTeam(player->GetObjectID());
if (team == nullptr || totalPlayersLoaded.size() >= team->members.size()) { if (team == nullptr || totalPlayersLoaded.size() == team->members.size()) {
StartFight(self); StartFight(self);
return; return;
} }
@ -93,6 +91,7 @@ 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.
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlayerLeft", 0, 0, GameMessages::SendNotifyClientObject(self->GetObjectID(), u"PlayerLeft", 0, 0,
player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS); player->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
} }