• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Prevent Player movement/Stun Player

Status
Not open for further replies.

Kaev

Super Moderator
Hiho Emudevs,

I could fix my last problem, because Tommy helped me. (Thanks again!)
Now i've got another one.

I'm looking for a method to stun the player, that means the player shouldn't be allowed to move, autoattack, cast, use items etc.
While he's stunned, i want to play an emote, so i cant just stun him by a spell.
I've already tried following:
player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); (Or something like stunned, forgot the name)

UNIT_FLAG_DISABLE_MOVE = Player can still do everything (Am i using it wrong?)
UNIT_FLAG_STUNNED = Player cant walk to the sides, just forward and backwards (Wtf? Why?!)


I hope you guys can help me again.
~Kaev


EDIT:
I've fixxed it already.
I used the following Spell as a aura and cancelled it with an BasicEvent after some seconds: http://wotlk.openwow.com/spell=52165
 
Last edited:

Tommy

Founder
It would go something like this:

Code:
    player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
    player->AddUnitMovementFlag(MOVEMENTFLAG_ROOT);

    WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
    data.append(GetPackGUID());
    data << uint32(0);
    player->SendMessageToSet(&data, true);

I tested and it works fine. :p
 

Neth

BETA Tester
It would go something like this:

Code:
    player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
    player->AddUnitMovementFlag(MOVEMENTFLAG_ROOT);

    WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
    data.append(GetPackGUID());
    data << uint32(0);
    player->SendMessageToSet(&data, true);

I tested and it works fine. :p

forcing opcode is bad imo
 

Kaev

Super Moderator
If other people have the same problem, here is my (edited) solution:
Code:
enum IDs
{
    TIMER_STUN = 5000,
    ID_STUN = 52165
};

class StunEvent : public BasicEvent
{
    public:
        StunEvent(Player& player) : _player(player) { }

        bool Execute(uint64 time, uint32 diff)
        {
            _player.RemoveAura(ID_STUN);
            return true;
        }

    private:
        Player& _player;
};

class test_stunOnUseItem: public ItemScript
{
    public:

    test_stunOnUseItem() : ItemScript("test_stunOnUseItem") { }
    bool OnUse(Player* player, Item* item, SpellCastTargets const& targets) OVERRIDE
    {
        Aura::TryRefreshStackOrCreate(sSpellMgr->GetSpellInfo(ID_STUN), MAX_EFFECT_MASK, player, player);
        player->m_Events.AddEvent(new StunEvent(*player), player->m_Events.CalculateTime(TIMER_STUN));
        return true;
    }
};

void AddSC_test_stunOnUseItem()
{
    new test_stunOnUseItem();
}
 

Rochet2

Moderator / Eluna Dev
FFR:

Code:
    int SetPlayerLock(lua_State* L, Player* player)
    {
        bool apply = luaL_optbool(L, 1, true);

        if (apply)
        {
            player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED);
            player->SetClientControl(player, 0);
        }
        else
        {
            player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED);
            player->SetClientControl(player, 1);
        }
        return 0;
    }
^From mangos eluna

Originally from Arc:
https://github.com/arcemu/arcemu/bl...dge/object_functions/unit_functions.cpp#L2006
 
Status
Not open for further replies.
Top