mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Implement flying command (#713)
* Implement flying command * Add documentation.
This commit is contained in:
parent
ea86988521
commit
6c97ea8208
@ -425,6 +425,18 @@ public:
|
||||
*/
|
||||
const std::vector<LOT>& GetEquippedItems() const { return m_EquippedItems; }
|
||||
|
||||
/**
|
||||
* @brief Get the flying state
|
||||
* @return value of the flying state
|
||||
*/
|
||||
bool GetIsFlying() { return m_IsFlying; }
|
||||
|
||||
/**
|
||||
* @brief Set the value of the flying state
|
||||
* @param isFlying the flying state
|
||||
*/
|
||||
void SetIsFlying(bool isFlying) { m_IsFlying = isFlying; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* The ID of this character. First 32 bits of the ObjectID.
|
||||
@ -621,6 +633,11 @@ private:
|
||||
*/
|
||||
std::string m_TargetScene;
|
||||
|
||||
/**
|
||||
* Bool that tracks the flying state of the user.
|
||||
*/
|
||||
bool m_IsFlying = false;
|
||||
|
||||
/**
|
||||
* Queries the character XML and updates all the fields of this object
|
||||
* NOTE: quick as there's no DB lookups
|
||||
|
@ -3,16 +3,34 @@
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
#include "Character.h"
|
||||
|
||||
void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
GameMessages::SendSetJetPackMode(entity, true, this->m_BypassChecks, this->m_EnableHover, this->m_effectId, this->m_Airspeed, this->m_MaxAirspeed, this->m_VerticalVelocity, this->m_WarningEffectID);
|
||||
|
||||
if (entity->IsPlayer()) {
|
||||
auto* character = entity->GetCharacter();
|
||||
|
||||
if (character) {
|
||||
character->SetIsFlying(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JetPackBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
GameMessages::SendSetJetPackMode(entity, false);
|
||||
|
||||
if (entity->IsPlayer()) {
|
||||
auto* character = entity->GetCharacter();
|
||||
|
||||
if (character) {
|
||||
character->SetIsFlying(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||
|
@ -942,6 +942,40 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
}
|
||||
|
||||
if (chatCommand == "fly" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_JUNIOR_DEVELOPER) {
|
||||
auto* character = entity->GetCharacter();
|
||||
|
||||
if (character) {
|
||||
bool isFlying = character->GetIsFlying();
|
||||
|
||||
if (isFlying) {
|
||||
GameMessages::SendSetJetPackMode(entity, false);
|
||||
|
||||
character->SetIsFlying(false);
|
||||
} else {
|
||||
float speedScale = 1.0f;
|
||||
|
||||
if (args.size() >= 1) {
|
||||
float tempScaleStore;
|
||||
|
||||
if (GeneralUtils::TryParse<float>(args[0], tempScaleStore)) {
|
||||
speedScale = tempScaleStore;
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Failed to parse speed scale argument.");
|
||||
}
|
||||
}
|
||||
|
||||
float airSpeed = 20 * speedScale;
|
||||
float maxAirSpeed = 30 * speedScale;
|
||||
float verticalVelocity = 1.5 * speedScale;
|
||||
|
||||
GameMessages::SendSetJetPackMode(entity, true, true, false, 167, airSpeed, maxAirSpeed, verticalVelocity);
|
||||
|
||||
character->SetIsFlying(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------- GM COMMANDS TO ACTUALLY MODERATE --------
|
||||
|
||||
if (chatCommand == "mute" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_JUNIOR_DEVELOPER) {
|
||||
|
@ -32,6 +32,7 @@ Here is a summary of the commands available in-game. All commands are prefixed b
|
||||
|gminvis|`/gminvis`|Toggles invisibility for the character, though it's currently a bit buggy. Requires nonzero GM Level for the character, but the account must have a GM level of 8.|8|
|
||||
|setname|`/setname <name>`|Sets a temporary name for your player. The name resets when you log out.|8|
|
||||
|title|`/title <title>`|Temporarily appends your player's name with " - <title>". This resets when you log out.|8|
|
||||
|fly|`/fly <speed>`|This toggles your flying state with an optional parameter for the speed scale.|4|
|
||||
|
||||
## Server Operation Commands
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user