Movementspeed

Hi I’m using this little code from Megabigboss (thanks to you Megabigboss) to increase the movementspeed to x2 but not in arena, battleground and instances.

Put this into player.cpp on line 23980

[CODE]void Player::SetMap(Map * map)

{

if(!map->Instanceable() && !map->IsBattlegroundOrArena() && !map->IsDungeon())

{

    this->SetSpeed(MOVE_RUN, 2,true);

}

Unit::SetMap(map);

m_mapRef.link(map, this);

}[/CODE]

The problem is it only checks for the speed when I log in to the game. So when I join a battleground I think it does not reload player.cpp so the speed still persits in the battleground. When I relog in a instance the speed is gone and when I leave the instance it correctly adds the movementspeed again.

Is there any better way to do that? So it always checks for the speed when map changes ore something like that?

Thank you for your time

greetings player321

Ps: Sorry for choosing wrong section

Moved to appropriate forum part since it is a custom patch /emoticons/default_smile.png

Because you only set the speed to 2x, but not back to normal if instance.

Btw, Instanceable() check is enough

Hi thanks your absolutely right. Pretty dumb of me not seeing this by myself ^^.

But it seems I’m still lost somewhere. I thought I could solve this like that:

[CODE]void Player::SetMap(Map * map)

{

if(!map->Instanceable())

{

    this->SetSpeed(MOVE_RUN, 2,true);

}

else

{

    this->SetSpeed(MOVE_RUN, 1,true);

}

Unit::SetMap(map);

m_mapRef.link(map, this);

}[/CODE]

But this crashes the server. Do I need to set (MOVE_RUN, 2,false) instead of set it to 1?

Thank you for your help

greeting player321

Edit: Ok solved it should have used Unit::SetMap(map);

m_mapRef.link(map, this);

first

I use the same as player321, but when a player gets stunned or something like that, movespeed has gone…

Could somebody please tell me where the code of the config is for “movespeed”?

I mean when you set movespeed = 2 in the config, which script does this use? player.cpp? didn’t found anything there…

Thanks

Hmm you’re right didn’t see that. Would be n1 if you could check for the speed on leaving combat or something like that.

Is it possible to change these lines:

[CODE]float baseMoveSpeed[MAX_MOVE_TYPE] =

{

2.5f,                  // MOVE_WALK

7.0f,                  // MOVE_RUN

2.5f,                  // MOVE_RUN_BACK

4.722222f,             // MOVE_SWIM

4.5f,                  // MOVE_SWIM_BACK

3.141594f,             // MOVE_TURN_RATE

7.0f,                  // MOVE_FLIGHT

4.5f,                  // MOVE_FLIGHT_BACK

3.14f                  // MOVE_PITCH_RATE

};

float playerBaseMoveSpeed[MAX_MOVE_TYPE] = {

2.5f,                  // MOVE_WALK

7.0f,                  // MOVE_RUN

2.5f,                  // MOVE_RUN_BACK

4.722222f,             // MOVE_SWIM

4.5f,                  // MOVE_SWIM_BACK

3.141594f,             // MOVE_TURN_RATE

7.0f,                  // MOVE_FLIGHT

4.5f,                  // MOVE_FLIGHT_BACK

3.14f                  // MOVE_PITCH_RATE

};[/CODE]

These are from: src/server/game/Entities/Unit/Unit.cpp at the top

I’m at work and can’t test this…

Can’t see the point in changing those, then I have the same problem againg that the speed is everywhere.

I think it would be better wenn you could call this function we did when you leave combat or something like thtat.

Greetings Player

[CODE]void Player::SetMap(Map * map)

{

Unit::SetMap(map);

m_mapRef.link(map, this);

if (!isInCombat())

    {

        if(!map->Instanceable())

        {

            this->SetSpeed(MOVE_RUN, 2,true);

        }

        else

        {

            this->SetSpeed(MOVE_RUN, 1,true);

        }

    }

}[/CODE]

don’t know if this works, just test it please.

Probably MOVE_WALK for the right speed?!

I think the problem is that the function void SetMap(Map * map) only get’s called when you change the map? I May be wrong but I think this doesn’t work.

hmm yeah you’re right… uhm I’ll try to make it, but I’m developing 2 months ago or something like this… /emoticons/default_wink.png

// EDIT: I don’t find a good function to implement this, I need to know where the worldserver.conf writes the “movespeed” in the core…

so when you set the movespeed in the conf to 2, what is changing in the core…

and there we have to implement this if / else…

yeah that’s what I thought to. But I searched for this function over an hour and could not find any clue where this could be.

I think that would help a lot to look at that code. Because it’s almost the same as setting the speed to 2 with the config file. Anyway I can’t find it maybe someone else can.

I’m german to btw if you want to write me a pm ^^.

[CODE] rate_values[RATE_MOVESPEED] = sConfig->GetFloatDefault(“Rate.MoveSpeed”,1.0f);

if (rate_values[RATE_MOVESPEED] < 0)

{

    sLog->outError("Rate.MoveSpeed (%f) must be > 0. Using 1 instead.",rate_values[RATE_MOVESPEED]);

    rate_values[RATE_MOVESPEED] = 1.0f;

}

for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i) playerBaseMoveSpeed[i] = baseMoveSpeed[i] * rate_values[RATE_MOVESPEED];

rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig->GetFloatDefault("Rate.Corpse.Decay.Looted",0.5f);

[/CODE]

/src/server/game/World/World.cpp

but where MOVESPEED is defined is the clue ^^

Could somebody help us? probably you know where I have to look at /emoticons/default_smile.png

[CODE] for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)

    m_forced_speed_changes[i] = 0;[/CODE]

→ src/server/game/Entities/Player/Player.cpp

→ Line 756 → the same MAX_MOVE_TYPE as in the config above

Unit.cpp Movespeed /emoticons/default_smile.png

[SPOILER]

[CODE]

void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)

{

if (rate < 0)

    rate = 0.0f;


// Update speed only on change

if (m_speed_rate[mtype] == rate)

    return;


m_speed_rate[mtype] = rate;


propagateSpeedChange();


WorldPacket data;

if (!forced)

{

    switch(mtype)

    {

        case MOVE_WALK:

            data.Initialize(MSG_MOVE_SET_WALK_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_RUN:

            data.Initialize(MSG_MOVE_SET_RUN_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_RUN_BACK:

            data.Initialize(MSG_MOVE_SET_RUN_BACK_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_SWIM:

            data.Initialize(MSG_MOVE_SET_SWIM_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_SWIM_BACK:

            data.Initialize(MSG_MOVE_SET_SWIM_BACK_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_TURN_RATE:

            data.Initialize(MSG_MOVE_SET_TURN_RATE, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_FLIGHT:

            data.Initialize(MSG_MOVE_SET_FLIGHT_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_FLIGHT_BACK:

            data.Initialize(MSG_MOVE_SET_FLIGHT_BACK_SPEED, 8+4+2+4+4+4+4+4+4+4);

            break;

        case MOVE_PITCH_RATE:

            data.Initialize(MSG_MOVE_SET_PITCH_RATE, 8+4+2+4+4+4+4+4+4+4);

            break;

        default:

            sLog->outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype);

            return;

    }


    data.append(GetPackGUID());

    data << uint32(0);                                  // movement flags

    data << uint16(0);                                  // unk flags

    data << uint32(getMSTime());

    data << float(GetPositionX());

    data << float(GetPositionY());

    data << float(GetPositionZ());

    data << float(GetOrientation());

    data << uint32(0);                                  // fall time

    data << float(GetSpeed(mtype));

    SendMessageToSet(&data, true);

}

else

{

    if (GetTypeId() == TYPEID_PLAYER)

    {

        // register forced speed changes for WorldSession::HandleForceSpeedChangeAck

        // and do it only for real sent packets and use run for run/mounted as client expected

        ++this->ToPlayer()->m_forced_speed_changes[mtype];


        if (!isInCombat())

            if (Pet* pet = this->ToPlayer()->GetPet())

                pet->SetSpeed(mtype, m_speed_rate[mtype], forced);

    }


    switch(mtype)

    {

        case MOVE_WALK:

            data.Initialize(SMSG_FORCE_WALK_SPEED_CHANGE, 16);

            break;

        case MOVE_RUN:

            data.Initialize(SMSG_FORCE_RUN_SPEED_CHANGE, 17);

            break;

        case MOVE_RUN_BACK:

            data.Initialize(SMSG_FORCE_RUN_BACK_SPEED_CHANGE, 16);

            break;

        case MOVE_SWIM:

            data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, 16);

            break;

        case MOVE_SWIM_BACK:

            data.Initialize(SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, 16);

            break;

        case MOVE_TURN_RATE:

            data.Initialize(SMSG_FORCE_TURN_RATE_CHANGE, 16);

            break;

        case MOVE_FLIGHT:

            data.Initialize(SMSG_FORCE_FLIGHT_SPEED_CHANGE, 16);

            break;

        case MOVE_FLIGHT_BACK:

            data.Initialize(SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE, 16);

            break;

        case MOVE_PITCH_RATE:

            data.Initialize(SMSG_FORCE_PITCH_RATE_CHANGE, 16);

            break;

        default:

            sLog->outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype);

            return;

    }

    data.append(GetPackGUID());

    data << (uint32)0;                                  // moveEvent, NUM_PMOVE_EVTS = 0x39

    if (mtype == MOVE_RUN)

        data << uint8(0);                               // new 2.1.0

    data << float(GetSpeed(mtype));

    SendMessageToSet(&data, true);

}

}[/CODE][/SPOILER]

how can I change that when somebody is in bg the movespeed is set to 1?

[CODE] else

{

    if (GetTypeId() == TYPEID_PLAYER)

    {

        // register forced speed changes for WorldSession::HandleForceSpeedChangeAck

        // and do it only for real sent packets and use run for run/mounted as client expected

        ++this->ToPlayer()->m_forced_speed_changes[mtype];


        if (!isInCombat())

            if (Pet* pet = this->ToPlayer()->GetPet())

                pet->SetSpeed(mtype, m_speed_rate[mtype], forced);

    }


    switch(mtype)

    {

        case MOVE_WALK:

            data.Initialize(SMSG_FORCE_WALK_SPEED_CHANGE, 16);

            break;

        case MOVE_RUN:

            data.Initialize(SMSG_FORCE_RUN_SPEED_CHANGE, 17);

            break;

        case MOVE_RUN_BACK:

            data.Initialize(SMSG_FORCE_RUN_BACK_SPEED_CHANGE, 16);

            break;

        case MOVE_SWIM:

            data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, 16);

            break;

        case MOVE_SWIM_BACK:

            data.Initialize(SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, 16);

            break;

        case MOVE_TURN_RATE:

            data.Initialize(SMSG_FORCE_TURN_RATE_CHANGE, 16);

            break;

        case MOVE_FLIGHT:

            data.Initialize(SMSG_FORCE_FLIGHT_SPEED_CHANGE, 16);

            break;

        case MOVE_FLIGHT_BACK:

            data.Initialize(SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE, 16);

            break;

        case MOVE_PITCH_RATE:

            data.Initialize(SMSG_FORCE_PITCH_RATE_CHANGE, 16);

            break;

        default:

            sLog->outError("Unit::SetSpeed: Unsupported move type (%d), data not sent to client.",mtype);

            return;

    }

    data.append(GetPackGUID());

    data << (uint32)0;                                  // moveEvent, NUM_PMOVE_EVTS = 0x39

    if (mtype == MOVE_RUN)

        data << uint8(0);                               // new 2.1.0

    data << float(GetSpeed(mtype));

    SendMessageToSet(&data, true);

}

}[/CODE]

would be great when somebody help me /emoticons/default_wink.png

Works fine till you get mounted/stunnde or slowed…cant find the point to set this.

— Canned message start —

You smell that? It was this thread rotting.

You just played:

http://img227.imageshack.us/img227/8899/threadnecromancerji6.jpg

Just kidding /emoticons/default_smile.png but seriously if you need help and search shows no relevant results please make your own topic so it can get the attention it deserves.

— Canned message end —

This is the code for Walk speed x1 in Instance, bg and Arena and at the world x 2 ?

void Player::SetMap(Map * map)
{
if(!map->Instanceable() && !map->IsBattlegroundOrArena() && !map->IsDungeon())
{
this->SetSpeed(MOVE_RUN, 1,true);
}
Unit::SetMap(map);
m_mapRef.link(map, this);

I want in world movment speed x2 but in Arena, Battleground, instance/Dungeons and Duell x 1 how does it Functunally?

push