more merge

This commit is contained in:
jadebenn 2024-02-13 20:59:35 -06:00
parent d6321a63d9
commit 70e0cd6f93
2 changed files with 34 additions and 48 deletions

View File

@ -767,7 +767,7 @@ void PetComponent::Wander() {
void PetComponent::OnSpawn() { void PetComponent::OnSpawn() {
m_MovementAI = m_Parent->GetComponent<MovementAIComponent>(); m_MovementAI = m_Parent->GetComponent<MovementAIComponent>();
if (m_StartPosition == NiPoint3::ZERO) { if (m_StartPosition == NiPoint3Constant::ZERO) {
m_StartPosition = m_Parent->GetPosition(); m_StartPosition = m_Parent->GetPosition();
} }
@ -982,7 +982,7 @@ void PetComponent::HandleInteractBouncer() {
const auto bouncerId = bouncerComp->GetParentEntity()->GetObjectID(); const auto bouncerId = bouncerComp->GetParentEntity()->GetObjectID();
bouncerComp->SetPetBouncerEnabled(true); bouncerComp->SetPetBouncerEnabled(true);
GameMessages::SendRequestClientBounce(bouncerId, this->GetOwnerId(), NiPoint3::ZERO, NiPoint3::ZERO, bouncerId, true, false, UNASSIGNED_SYSTEM_ADDRESS); //TODO: Check packet captures!! GameMessages::SendRequestClientBounce(bouncerId, this->GetOwnerId(), NiPoint3Constant::ZERO, NiPoint3Constant::ZERO, bouncerId, true, false, UNASSIGNED_SYSTEM_ADDRESS); //TODO: Check packet captures!!
bouncerComp->SetPetBouncerEnabled(false); bouncerComp->SetPetBouncerEnabled(false);
RenderComponent::PlayAnimation(petSwitchEntity, u"up"); RenderComponent::PlayAnimation(petSwitchEntity, u"up");
}); });
@ -990,7 +990,7 @@ void PetComponent::HandleInteractBouncer() {
RenderComponent::PlayAnimation(petSwitchEntity, u"launch"); //u"engaged"); //TODO: Check if the timing on this is right RenderComponent::PlayAnimation(petSwitchEntity, u"launch"); //u"engaged"); //TODO: Check if the timing on this is right
// TODO: Need to freeze player movement until the bounce begins! // TODO: Need to freeze player movement until the bounce begins!
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::ActivateSwitch, true); // Plays 'jump on switch' animation Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 1, PetEmote::ActivateSwitch, true); // Plays 'jump on switch' animation
StopInteract(); StopInteract();
} }
m_Timer += 0.5f; m_Timer += 0.5f;
@ -1043,7 +1043,7 @@ void PetComponent::StartInteractTreasureDig() {
LOG_DEBUG("StartInteractTreasureDig() m_Flags = %d", m_Flags); LOG_DEBUG("StartInteractTreasureDig() m_Flags = %d", m_Flags);
Game::entityManager->SerializeEntity(m_Parent); Game::entityManager->SerializeEntity(m_Parent);
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::DigTreasure, true); // Plays 'dig' animation Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 1, PetEmote::DigTreasure, true); // Plays 'dig' animation
m_Timer = 2.0f; m_Timer = 2.0f;
} }
@ -1064,7 +1064,7 @@ void PetComponent::HandleInteractTreasureDig() {
} }
if (m_TimerBounce <= 0.0f) { if (m_TimerBounce <= 0.0f) {
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, PetEmote::Bounce, true); // Plays 'bounce' animation Command(NiPoint3Constant::ZERO, LWOOBJID_EMPTY, 1, PetEmote::Bounce, true); // Plays 'bounce' animation
m_TimerBounce = 1.0f; m_TimerBounce = 1.0f;
} }
@ -1153,7 +1153,6 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
if (!fromTaming) playerDestroyableComponent->Imagine(-1); if (!fromTaming) playerDestroyableComponent->Imagine(-1);
// Set this to a variable so when this is called back from the player the timer doesn't fire off. // Set this to a variable so when this is called back from the player the timer doesn't fire off.
m_Parent->AddCallbackTimer(m_PetInfo.imaginationDrainRate, [playerDestroyableComponent, this, item]() {
m_Parent->AddCallbackTimer(m_PetInfo.imaginationDrainRate, [playerDestroyableComponent, this, item]() { m_Parent->AddCallbackTimer(m_PetInfo.imaginationDrainRate, [playerDestroyableComponent, this, item]() {
if (!playerDestroyableComponent) { if (!playerDestroyableComponent) {
LOG("No petComponent and/or no playerDestroyableComponent"); LOG("No petComponent and/or no playerDestroyableComponent");
@ -1230,7 +1229,7 @@ void PetComponent::Command(const NiPoint3& position, const LWOOBJID source, cons
} }
// Add movement functionality // Add movement functionality
if (position != NiPoint3::ZERO) { if (position != NiPoint3Constant::ZERO) {
m_MovementAI->SetDestination(position); m_MovementAI->SetDestination(position);
} }
} }

View File

@ -716,8 +716,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
uint32_t petStatus; const auto petStatus = GeneralUtils::TryParse<uint32_t>(args[0]);
if (!GeneralUtils::TryParse(args[0], petStatus)) { if (!petStatus) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid pet status!"); ChatPackets::SendSystemMessage(sysAddr, u"Invalid pet status!");
return; return;
} }
@ -729,10 +729,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
petComponent->SetStatus(petStatus); petComponent->SetStatus(petStatus.value());
//Game::entityManager->SerializeEntity(petComponent->GetParentEntity()); //Game::entityManager->SerializeEntity(petComponent->GetParentEntity());
std::u16string msg = u"Set pet status to " + (GeneralUtils::to_u16string(petStatus)); std::u16string msg = u"Set pet status to " + (GeneralUtils::to_u16string(petStatus.value()));
ChatPackets::SendSystemMessage(sysAddr, msg); ChatPackets::SendSystemMessage(sysAddr, msg);
} }
@ -743,14 +743,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
int32_t commandType; const auto commandType = GeneralUtils::TryParse<int32_t>(args[0+3]);
if (!GeneralUtils::TryParse(args[0+3], commandType)) { if (!commandType) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid command type!"); ChatPackets::SendSystemMessage(sysAddr, u"Invalid command type!");
return; return;
} }
int32_t typeId; const auto typeId = GeneralUtils::TryParse<int32_t>(args[1+3]);
if (!GeneralUtils::TryParse(args[1+3], typeId)) { if (!typeId) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid command type id!"); ChatPackets::SendSystemMessage(sysAddr, u"Invalid command type id!");
return; return;
} }
@ -763,29 +763,16 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
} }
//Determine the positional coordinates //Determine the positional coordinates
NiPoint3 commandPos{}; //NiPoint3 commandPos{};
float x, y, z; //float x, y, z;
if (!GeneralUtils::TryParse(args[0], x)) { const auto commandPos = GeneralUtils::TryParse<NiPoint3>(args[0], args[1], args[2]);
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x."); if (!commandPos) {
return; ChatPackets::SendSystemMessage(sysAddr, u"Invalid position.");
}
if (!GeneralUtils::TryParse(args[1], y)) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid y.");
return;
}
if (!GeneralUtils::TryParse(args[2], z)) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
return; return;
} }
// Set command position // Set command position
commandPos.SetX(x); petComponent->Command(commandPos.value(), entity->GetObjectID(), commandType.value(), typeId.value(), true);
commandPos.SetY(y);
commandPos.SetZ(z);
petComponent->Command(commandPos, entity->GetObjectID(), commandType, typeId, true);
} }
// Pet speed utility // Pet speed utility
@ -795,8 +782,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
float petMaxSpeed; const auto petMaxSpeed = GeneralUtils::TryParse<float>(args[0]);
if (!GeneralUtils::TryParse(args[0], petMaxSpeed)) { if (!petMaxSpeed) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid speed!"); ChatPackets::SendSystemMessage(sysAddr, u"Invalid speed!");
return; return;
} }
@ -811,9 +798,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
auto* movementAIComponent = petComponent->GetParentEntity()->GetComponent<MovementAIComponent>(); auto* movementAIComponent = petComponent->GetParentEntity()->GetComponent<MovementAIComponent>();
if (!movementAIComponent) return; if (!movementAIComponent) return;
movementAIComponent->SetMaxSpeed(petMaxSpeed); movementAIComponent->SetMaxSpeed(petMaxSpeed.value());
std::u16string msg = u"Set pet max speed to " + (GeneralUtils::to_u16string(petMaxSpeed)); std::u16string msg = u"Set pet max speed to " + (GeneralUtils::to_u16string(petMaxSpeed.value()));
ChatPackets::SendSystemMessage(sysAddr, msg); ChatPackets::SendSystemMessage(sysAddr, msg);
} }
@ -824,25 +811,25 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
float petAccel; const auto petAccel = GeneralUtils::TryParse<float>(args[0]);
if (!GeneralUtils::TryParse(args[0], petAccel)) { if (!petAccel) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid acceleration!"); ChatPackets::SendSystemMessage(sysAddr, u"Invalid acceleration!");
return; return;
} }
// Determine if player has a pet summoned // Determine if player has a pet summoned
auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID()); auto* const petComponent = PetComponent::GetActivePet(entity->GetObjectID());
if (!petComponent) { if (!petComponent) {
ChatPackets::SendSystemMessage(sysAddr, u"No active pet found!"); ChatPackets::SendSystemMessage(sysAddr, u"No active pet found!");
return; return;
} }
auto* movementAIComponent = petComponent->GetParentEntity()->GetComponent<MovementAIComponent>(); auto* const movementAIComponent = petComponent->GetParentEntity()->GetComponent<MovementAIComponent>();
if (!movementAIComponent) return; if (!movementAIComponent) return;
movementAIComponent->SetAcceleration(petAccel); movementAIComponent->SetAcceleration(petAccel.value());
std::u16string msg = u"Set pet acceleration to " + (GeneralUtils::to_u16string(petAccel)); std::u16string msg = u"Set pet acceleration to " + GeneralUtils::to_u16string(petAccel.value());
ChatPackets::SendSystemMessage(sysAddr, msg); ChatPackets::SendSystemMessage(sysAddr, msg);
} }
@ -853,8 +840,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
return; return;
} }
float petHaltDistance; const auto petHaltDistance = GeneralUtils::TryParse<float>(args[0]);
if (!GeneralUtils::TryParse(args[0], petHaltDistance)) { if (!petHaltDistance) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid halt distance!"); ChatPackets::SendSystemMessage(sysAddr, u"Invalid halt distance!");
return; return;
} }
@ -869,9 +856,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
auto* movementAIComponent = petComponent->GetParentEntity()->GetComponent<MovementAIComponent>(); auto* movementAIComponent = petComponent->GetParentEntity()->GetComponent<MovementAIComponent>();
if (!movementAIComponent) return; if (!movementAIComponent) return;
movementAIComponent->SetHaltDistance(petHaltDistance); movementAIComponent->SetHaltDistance(petHaltDistance.value());
std::u16string msg = u"Set pet halt distance to " + (GeneralUtils::to_u16string(petHaltDistance)); std::u16string msg = u"Set pet halt distance to " + GeneralUtils::to_u16string(petHaltDistance.value());
ChatPackets::SendSystemMessage(sysAddr, msg); ChatPackets::SendSystemMessage(sysAddr, msg);
} }