mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 21:43:35 +00:00
added tracking of Pet Excavator achievement (#213)
* added tracking of the Pet Excavator achievement * make Pet Extractor Progress Zone specific * added tracking of Pet Excavator Achievement using player flags
This commit is contained in:
parent
84cf79906b
commit
f7009b499b
@ -39,7 +39,7 @@ const std::map<LOT, DigInfo> PetDigServer::digInfoMap {
|
||||
{12192, DigInfo { 12192, -1, -1, true, false, false, false }},
|
||||
};
|
||||
|
||||
void PetDigServer::OnStartup(Entity* self)
|
||||
void PetDigServer::OnStartup(Entity* self)
|
||||
{
|
||||
treasures.push_back(self->GetObjectID());
|
||||
const auto digInfoIterator = digInfoMap.find(self->GetLOT());
|
||||
@ -64,7 +64,7 @@ void PetDigServer::OnStartup(Entity* self)
|
||||
}
|
||||
}
|
||||
|
||||
void PetDigServer::OnDie(Entity* self, Entity* killer)
|
||||
void PetDigServer::OnDie(Entity* self, Entity* killer)
|
||||
{
|
||||
const auto iterator = std::find(treasures.begin(), treasures.end(), self->GetObjectID());
|
||||
if (iterator != treasures.end())
|
||||
@ -91,7 +91,7 @@ void PetDigServer::OnDie(Entity* self, Entity* killer)
|
||||
PetDigServer::HandleBouncerDig(self, owner);
|
||||
}
|
||||
|
||||
PetDigServer::ProgressCanYouDigIt(owner);
|
||||
PetDigServer::ProgressPetDigMissions(owner, self);
|
||||
|
||||
self->SetNetworkVar<bool>(u"treasure_dug", true);
|
||||
// TODO: Reset other pets
|
||||
@ -157,19 +157,36 @@ void PetDigServer::HandleBouncerDig(const Entity *self, const Entity *owner) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Progresses the Can You Dig It mission if the player has never completed it yet
|
||||
* Progresses the Can You Dig It mission and the Pet Excavator Achievement if the player has never completed it yet
|
||||
* \param owner the owner that just made a pet dig something up
|
||||
*/
|
||||
void PetDigServer::ProgressCanYouDigIt(const Entity* owner) {
|
||||
void PetDigServer::ProgressPetDigMissions(const Entity* owner, const Entity* chest) {
|
||||
auto* missionComponent = owner->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent != nullptr)
|
||||
{
|
||||
// Can You Dig It progress
|
||||
const auto digMissionState = missionComponent->GetMissionState(843);
|
||||
if (digMissionState == MissionState::MISSION_STATE_ACTIVE)
|
||||
{
|
||||
missionComponent->ForceProgress(843, 1216, 1);
|
||||
}
|
||||
|
||||
// Pet Excavator progress
|
||||
const auto excavatorMissionState = missionComponent->GetMissionState(505);
|
||||
if (excavatorMissionState == MissionState::MISSION_STATE_ACTIVE)
|
||||
{
|
||||
if (chest->HasVar(u"PetDig")) {
|
||||
int32_t playerFlag = 1260 + chest->GetVarAs<int32_t>(u"PetDig");
|
||||
Character* player = owner->GetCharacter();
|
||||
|
||||
// check if player flag is set
|
||||
if (!player->GetPlayerFlag(playerFlag)) {
|
||||
missionComponent->ForceProgress(505, 767, 1);
|
||||
player->SetPlayerFlag(playerFlag, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +220,7 @@ void PetDigServer::SpawnPet(Entity* self, const Entity* owner, const DigInfo dig
|
||||
EntityManager::Instance()->ConstructEntity(spawnedPet);
|
||||
}
|
||||
|
||||
Entity* PetDigServer::GetClosestTresure(NiPoint3 position)
|
||||
Entity* PetDigServer::GetClosestTresure(NiPoint3 position)
|
||||
{
|
||||
float closestDistance = 0;
|
||||
Entity* closest = nullptr;
|
||||
@ -215,7 +232,7 @@ Entity* PetDigServer::GetClosestTresure(NiPoint3 position)
|
||||
if (tresure == nullptr) continue;
|
||||
|
||||
float distance = Vector3::DistanceSquared(tresure->GetPosition(), position);
|
||||
|
||||
|
||||
if (closest == nullptr || distance < closestDistance)
|
||||
{
|
||||
closestDistance = distance;
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
static Entity* GetClosestTresure(NiPoint3 position);
|
||||
|
||||
private:
|
||||
static void ProgressCanYouDigIt(const Entity* owner);
|
||||
static void ProgressPetDigMissions(const Entity* owner, const Entity* chest);
|
||||
static void SpawnPet(Entity* self, const Entity* owner, DigInfo digInfo);
|
||||
static void HandleXBuildDig(const Entity* self, Entity* owner, Entity* pet);
|
||||
static void HandleBouncerDig(const Entity* self, const Entity* owner);
|
||||
|
Loading…
Reference in New Issue
Block a user