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

Allow gm fly command #558

wants to merge 2 commits into from

Conversation

davidonete
Copy link
Contributor

🍰 Pullrequest

Allow gm fly command, I believe it is very useful for debugging purposes.

@cpevors
Copy link

cpevors commented May 20, 2024

Classic doesn't have .gm fly on? TBC does. Further, in TBC, "jumping" doesn't cancel or remove the effect, i.e. Space/"jump" just causes the player to ascend in the air.

Should we not implement something analogous to TBC's command?

bool ChatHandler::HandleGMFlyCommand(char* args)
{
    bool value;
    if (!ExtractOnOff(&args, value))
    {
        SendSysMessage(LANG_USE_BOL);
        SetSentErrorMessage(true);
        return false;
    }

    Player* target = getSelectedPlayer();
    if (!target)
        target = m_session->GetPlayer();

    target->SetCanFly(value);
    PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, GetNameLink(target).c_str(), args);
    return true;
}

@killerwife
Copy link
Contributor

Client doesnt fly in vanilla afaik. The packet doesnt exist. Have you actually tried this? :D

@davidonete
Copy link
Contributor Author

davidonete commented May 20, 2024

yes I have, the only issue is if you jump, that's why I put that warning message. We do have it working in SPP

@insunaa
Copy link
Contributor

insunaa commented May 20, 2024

@cpevors Vanilla has no concept of flying, that was a brand-new addition with TBC. Vanilla has swimming, which is analogous to flying, but in vanilla swimming you could jump underwater. They hadn't remapped jumping to "ascend" yet.
Jumping changes the character's moveflags to jumping/falling and so cancels the swimming moveflag. underwater that's fine, because when you land you land in water, which re-enables the swimming moveflag, but in air you just keep falling.

@cpevors
Copy link

cpevors commented May 20, 2024

The more you know. Appreciate the insights, everyone!

@celguar
Copy link
Contributor

celguar commented May 20, 2024

Vmangos has flying for ages, ofc it works

@celguar
Copy link
Contributor

celguar commented May 20, 2024

But not sure if changed here are enough for it

@cpevors
Copy link

cpevors commented May 20, 2024

In hindsight, I think VMaNGOS has a version of flying that also cancels on 'jump,' though.

From VMaNGOS:

bool ChatHandler::HandleCheatFlyCommand(char* args)
{
    bool value;
    if (!ExtractOnOff(&args, value))
    {
        SendSysMessage(LANG_USE_BOL);
        SetSentErrorMessage(true);
        return false;
    }

    Player* target = GetSelectedPlayer();
    if (!target)
        target = m_session->GetPlayer();

    target->SetCheatFly(value, true);

    PSendSysMessage(LANG_YOU_SET_FLY, value ? "on" : "off", GetNameLink(target).c_str());
    if (needReportToTarget(target))
        ChatHandler(target).PSendSysMessage(LANG_YOUR_FLY_SET, value ? "on" : "off", GetNameLink().c_str());

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

    return true;
}

@davidonete
Copy link
Contributor Author

davidonete commented May 20, 2024

ouch, I missed some extra code, should be fine now

@ImmortalusDev
Copy link

In order to make it work you need to do more changes

@@ -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

@killerwife
Copy link
Contributor

If I understand it correctly and has a similar issue like knockback in tbc, you would have to actually check jump packet and re-add flying moveflag forcibly every time that happens for this to work. Anyone can feel free to correct me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants