Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow gm fly command #558

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/game/Chat/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5448,12 +5448,11 @@ bool ChatHandler::HandleGMFlyCommand(char* args)
if (!target)
target = m_session->GetPlayer();

// [-ZERO] Need reimplement in another way
{
SendSysMessage(LANG_USE_BOL);
return false;
}
target->SetCanFly(value);

if (value)
SendSysMessage("WARNING: Do not jump or flying mode will be removed.");

PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, GetNameLink(target).c_str(), args);
return true;
}
Expand Down
14 changes: 14 additions & 0 deletions src/game/Entities/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18877,6 +18877,20 @@ void Player::ResurrectUsingRequestDataFinish()
SpawnCorpseBones();
}

void Player::SetCanFly(bool enable)
{
if (enable)
{
m_movementInfo.moveFlags = (MOVEFLAG_LEVITATING | MOVEFLAG_SWIMMING | MOVEFLAG_CAN_FLY | MOVEFLAG_FLYING);
}
else
{
m_movementInfo.moveFlags = (MOVEFLAG_NONE);
}

SendHeartBeat();
}

void Player::UpdateClientControl(Unit const* target, bool enabled, bool forced) const
{
if (target)
Expand Down
1 change: 1 addition & 0 deletions src/game/Entities/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,7 @@ class Player : public Unit
bool IsFlying() const override { return false; }
bool IsFreeFlying() const { return false; }
bool IsSwimming() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING); }
void SetCanFly(bool enable) override;

void UpdateClientControl(Unit const* target, bool enabled, bool forced = false) const;

Expand Down
11 changes: 10 additions & 1 deletion src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12259,7 +12259,16 @@ void Unit::SetSwim(bool enable)

void Unit::SetCanFly(bool enable)
{
// TBC+
if (enable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code can be now as a result be called for non player entities. Your PR aims to add it for GM players, for anyone else due to shenanigans of someone trying to debug this, this is not good to have. Amend it to only be strictly callable for player pls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gm fly on command is for target or self

{
m_movementInfo.AddMovementFlag(MOVEFLAG_CAN_FLY);
m_movementInfo.AddMovementFlag(MOVEFLAG_FLYING_OLD);
}
else
{
m_movementInfo.RemoveMovementFlag(MOVEFLAG_CAN_FLY);
m_movementInfo.RemoveMovementFlag(MOVEFLAG_FLYING_OLD);
}
}

void Unit::SetFeatherFall(bool enable)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@ class Unit : public WorldObject

void SetLevitate(bool enabled);
void SetSwim(bool enabled);
void SetCanFly(bool enabled);
virtual void SetCanFly(bool enabled);
void SetFeatherFall(bool enabled);
void SetHover(bool enabled);
void SetWaterWalk(bool enabled);
Expand Down