mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 23:13:35 +00:00
initial dig functionality; need to clean up kruft
This commit is contained in:
parent
74047bcc9c
commit
119968a90c
18
dCommon/dEnums/ePetStatus.h
Normal file
18
dCommon/dEnums/ePetStatus.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __EPETSTATUS__H__
|
||||||
|
#define __EPETSTATUS__H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
enum ePetStatus : uint32_t {
|
||||||
|
NONE,
|
||||||
|
UNKNOWN1 = 0x1,
|
||||||
|
UNKNOWN2 = 0x2,
|
||||||
|
UNKNOWN3 = 0x4,
|
||||||
|
UNKNOWN4 = 0x8,
|
||||||
|
BEING_TAMED = 0x10,
|
||||||
|
IS_NOT_WAITING = 0x20, // Right name? - used to be decimal 20
|
||||||
|
PLAY_SPAWN_ANIM = 0x80,
|
||||||
|
TAMEABLE = 0x4000000
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //!__EPETSTATUS__H__
|
@ -19,6 +19,7 @@
|
|||||||
#include "ePetTamingNotifyType.h"
|
#include "ePetTamingNotifyType.h"
|
||||||
#include "eUseItemResponse.h"
|
#include "eUseItemResponse.h"
|
||||||
#include "ePlayerFlag.h"
|
#include "ePlayerFlag.h"
|
||||||
|
#include "ePetStatus.h"
|
||||||
|
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
@ -80,13 +81,16 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId): Component(pare
|
|||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
m_TimerAway = 0;
|
m_TimerAway = 0;
|
||||||
m_DatabaseId = LWOOBJID_EMPTY;
|
m_DatabaseId = LWOOBJID_EMPTY;
|
||||||
m_Status = 67108866; // Tamable
|
m_Status = ePetStatus::TAMEABLE; // Tameable
|
||||||
m_Ability = PetAbilityType::Invalid;
|
m_Ability = PetAbilityType::Invalid;
|
||||||
m_StartPosition = NiPoint3::ZERO;
|
m_StartPosition = NiPoint3::ZERO;
|
||||||
m_MovementAI = nullptr;
|
m_MovementAI = nullptr;
|
||||||
m_TresureTime = 0;
|
m_TresureTime = 0;
|
||||||
m_Preconditions = nullptr;
|
m_Preconditions = nullptr;
|
||||||
|
|
||||||
|
m_ReadyToDig = false;
|
||||||
|
m_InInteract = false;
|
||||||
|
|
||||||
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parent->GetVar<std::u16string>(u"CheckPrecondition"));
|
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parent->GetVar<std::u16string>(u"CheckPrecondition"));
|
||||||
|
|
||||||
if (!checkPreconditions.empty()) {
|
if (!checkPreconditions.empty()) {
|
||||||
@ -150,6 +154,15 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PetComponent::OnUse(Entity* originator) {
|
void PetComponent::OnUse(Entity* originator) {
|
||||||
|
LOG("PET USE!");
|
||||||
|
|
||||||
|
if(m_ReadyToDig) {
|
||||||
|
LOG("Dig initiated!");
|
||||||
|
m_TresureTime = 2.0f;
|
||||||
|
//m_ReadyToDig = false;
|
||||||
|
SetAbility(PetAbilityType::DigAtPosition);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_Owner != LWOOBJID_EMPTY) {
|
if (m_Owner != LWOOBJID_EMPTY) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -369,29 +382,8 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_TresureTime > 0) {
|
if (m_TresureTime > 0.0f) {
|
||||||
auto* tresure = Game::entityManager->GetEntity(m_Interaction);
|
InteractDig(deltaTime);
|
||||||
|
|
||||||
if (tresure == nullptr) {
|
|
||||||
m_TresureTime = 0;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_TresureTime -= deltaTime;
|
|
||||||
|
|
||||||
m_MovementAI->Stop();
|
|
||||||
|
|
||||||
if (m_TresureTime <= 0) {
|
|
||||||
m_Parent->SetOwnerOverride(m_Owner);
|
|
||||||
|
|
||||||
tresure->Smash(m_Parent->GetObjectID());
|
|
||||||
|
|
||||||
m_Interaction = LWOOBJID_EMPTY;
|
|
||||||
|
|
||||||
m_TresureTime = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,10 +432,9 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine if the "Lost Tags" mission has been completed and digging has been unlocked
|
||||||
auto* missionComponent = owner->GetComponent<MissionComponent>();
|
auto* missionComponent = owner->GetComponent<MissionComponent>();
|
||||||
if (!missionComponent) return;
|
if (!missionComponent) return;
|
||||||
|
|
||||||
// Determine if the "Lost Tags" mission has been completed and digging has been unlocked
|
|
||||||
const bool digUnlocked = missionComponent->GetMissionState(842) == eMissionState::COMPLETE;
|
const bool digUnlocked = missionComponent->GetMissionState(842) == eMissionState::COMPLETE;
|
||||||
|
|
||||||
Entity* closestTresure = PetDigServer::GetClosestTresure(position);
|
Entity* closestTresure = PetDigServer::GetClosestTresure(position);
|
||||||
@ -461,11 +452,14 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, 202, true);
|
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, 202, true);
|
||||||
|
|
||||||
m_TresureTime = 2;
|
SetIsReadyToDig(true);
|
||||||
|
|
||||||
} else if (distance < 10 * 10) {
|
} else if (distance < 10 * 10) {
|
||||||
haltDistance = 1;
|
haltDistance = 1;
|
||||||
|
|
||||||
destination = tresurePosition;
|
destination = tresurePosition;
|
||||||
|
|
||||||
|
SetIsReadyToDig(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,6 +474,49 @@ skipTresure:
|
|||||||
m_Timer = 1;
|
m_Timer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PetComponent::SetIsReadyToDig(bool isReady) {
|
||||||
|
if (isReady) {
|
||||||
|
LOG("Dig state reached!");
|
||||||
|
//m_Interaction = closestTresure->GetObjectID();
|
||||||
|
SetAbility(PetAbilityType::JumpOnObject);
|
||||||
|
SetStatus(ePetStatus::IS_NOT_WAITING); // Treasure dig status
|
||||||
|
m_ReadyToDig = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG("Dig state ended!");
|
||||||
|
//m_Interaction = LWOOBJID_EMPTY;
|
||||||
|
SetAbility(PetAbilityType::Invalid);
|
||||||
|
SetStatus(0); // TODO: Check status
|
||||||
|
m_ReadyToDig = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PetComponent::InteractDig(float deltaTime) { //Should I rename to InteractDig?
|
||||||
|
LOG("Pet digging!");
|
||||||
|
|
||||||
|
auto* tresure = Game::entityManager->GetEntity(m_Interaction);
|
||||||
|
|
||||||
|
if (tresure == nullptr) {
|
||||||
|
m_TresureTime = 0.0f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_TresureTime -= deltaTime;
|
||||||
|
|
||||||
|
m_MovementAI->Stop();
|
||||||
|
|
||||||
|
if (m_TresureTime <= 0.0f) {
|
||||||
|
m_Parent->SetOwnerOverride(m_Owner);
|
||||||
|
|
||||||
|
tresure->Smash(m_Parent->GetObjectID());
|
||||||
|
|
||||||
|
LOG("Pet dig completed!");
|
||||||
|
m_Interaction = LWOOBJID_EMPTY;
|
||||||
|
m_TresureTime = 0.0f;
|
||||||
|
SetIsReadyToDig(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||||
|
|
||||||
@ -736,7 +773,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
|||||||
|
|
||||||
currentActivities.erase(m_Tamer);
|
currentActivities.erase(m_Tamer);
|
||||||
|
|
||||||
SetStatus(67108866);
|
SetStatus(ePetStatus::TAMEABLE);
|
||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
|
|
||||||
@ -787,7 +824,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
|||||||
|
|
||||||
currentActivities.erase(m_Tamer);
|
currentActivities.erase(m_Tamer);
|
||||||
|
|
||||||
SetStatus(67108866);
|
SetStatus(ePetStatus::TAMEABLE);
|
||||||
m_Tamer = LWOOBJID_EMPTY;
|
m_Tamer = LWOOBJID_EMPTY;
|
||||||
m_Timer = 0;
|
m_Timer = 0;
|
||||||
|
|
||||||
|
@ -29,6 +29,12 @@ public:
|
|||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||||
void Update(float deltaTime) override;
|
void Update(float deltaTime) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the pet dig interaction
|
||||||
|
* @param deltaTime time elapsed
|
||||||
|
*/
|
||||||
|
void InteractDig(float deltaTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an OnUse event from another entity, initializing the pet taming minigame if this pet is untamed.
|
* Handles an OnUse event from another entity, initializing the pet taming minigame if this pet is untamed.
|
||||||
* @param originator the entity that triggered the event
|
* @param originator the entity that triggered the event
|
||||||
@ -172,6 +178,23 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetPreconditions(std::string& conditions);
|
void SetPreconditions(std::string& conditions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets if the pet is ready to dig
|
||||||
|
* @param isReady whether the pet is ready to dig (true) or not (false)
|
||||||
|
*/
|
||||||
|
void SetIsReadyToDig(bool isReady);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return is pet ready to dig
|
||||||
|
*/
|
||||||
|
bool GetIsReadyToDig() { return m_ReadyToDig; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets pet's treasure timer
|
||||||
|
* @param digTime float representing the treasure dig time in seconds
|
||||||
|
*/
|
||||||
|
void SetTreasureTime(float digTime) { m_TresureTime = digTime; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entity that this component belongs to
|
* Returns the entity that this component belongs to
|
||||||
* @return the entity that this component belongs to
|
* @return the entity that this component belongs to
|
||||||
@ -341,6 +364,16 @@ private:
|
|||||||
*/
|
*/
|
||||||
float m_TresureTime;
|
float m_TresureTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boolean that sets if a pet is ready to dig and display the interact prompt
|
||||||
|
*/
|
||||||
|
bool m_ReadyToDig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boolean that sets if a pet is in an interaction
|
||||||
|
*/
|
||||||
|
float m_InInteract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The position that this pet was spawned at
|
* The position that this pet was spawned at
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "dServer.h"
|
#include "dServer.h"
|
||||||
#include "MissionComponent.h"
|
#include "MissionComponent.h"
|
||||||
#include "Mail.h"
|
#include "Mail.h"
|
||||||
|
#include "PetComponent.h"
|
||||||
#include "dpWorld.h"
|
#include "dpWorld.h"
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "PropertyManagementComponent.h"
|
#include "PropertyManagementComponent.h"
|
||||||
@ -696,6 +697,32 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
entity->GetCharacter()->SetPlayerFlag(flagId, false);
|
entity->GetCharacter()->SetPlayerFlag(flagId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chatCommand == "setpetstatus" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
|
if (args.size() == 0) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Too few arguments!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t petStatus;
|
||||||
|
if (!GeneralUtils::TryParse(args[0], petStatus)) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid pet status!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if player has a pet summoned
|
||||||
|
auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID());
|
||||||
|
if (!petComponent) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"No active pet found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
petComponent->SetStatus(petStatus);
|
||||||
|
//Game::entityManager->SerializeEntity(petComponent->GetParentEntity());
|
||||||
|
|
||||||
|
std::u16string msg = u"Set pet status to " + (GeneralUtils::to_u16string(petStatus));
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, msg);
|
||||||
|
}
|
||||||
|
|
||||||
if (chatCommand == "resetmission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "resetmission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
if (args.size() == 0) return;
|
if (args.size() == 0) return;
|
||||||
|
|
||||||
|
@ -101,6 +101,17 @@ void PetDigServer::OnDie(Entity* self, Entity* killer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PetDigServer::OnUse(Entity* self, Entity* user) {
|
||||||
|
LOG("Treasure used!");
|
||||||
|
|
||||||
|
auto* petComponent = PetComponent::GetActivePet(user->GetObjectID());
|
||||||
|
if (!petComponent) return;
|
||||||
|
|
||||||
|
if(petComponent->GetIsReadyToDig()) {
|
||||||
|
petComponent->SetTreasureTime(2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pet) {
|
void PetDigServer::HandleXBuildDig(const Entity* self, Entity* owner, Entity* pet) {
|
||||||
auto playerID = self->GetVar<LWOOBJID>(u"builder");
|
auto playerID = self->GetVar<LWOOBJID>(u"builder");
|
||||||
if (playerID == LWOOBJID_EMPTY || playerID != owner->GetObjectID())
|
if (playerID == LWOOBJID_EMPTY || playerID != owner->GetObjectID())
|
||||||
|
@ -17,6 +17,13 @@ public:
|
|||||||
void OnStartup(Entity* self) override;
|
void OnStartup(Entity* self) override;
|
||||||
void OnDie(Entity* self, Entity* killer) override;
|
void OnDie(Entity* self, Entity* killer) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoked when a player interacts with treasure.
|
||||||
|
* @param self the entity the script belongs to
|
||||||
|
* @param user the entity that used the treasure
|
||||||
|
*/
|
||||||
|
void OnUse(Entity* self, Entity* user) override;
|
||||||
|
|
||||||
static Entity* GetClosestTresure(NiPoint3 position);
|
static Entity* GetClosestTresure(NiPoint3 position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user