-
Member
Player SetFacing
Gents,
Have been successful with progressing several bots but have never found a successful way of setting my players rotation. Is there a way of using SetFacing(), or another method, to directly set my characters rotation so that it is also updated server side?
As an example. Say I’m facing away from an enemy, can I set my rotation so that the server has updated my new rotation angle and allows me to cast without saying I am facing the wrong way? This is the only issue I have always struggled with.
Any suggestions would be much appreciated.
I write for 1.12, 2.4.3 and 3.3.5 clients.
Thanks
-
Contributor
What you could do is set a BP on the local players rotation and see what functions modify/read the value.
Just a thought.
-
Contributor
As far as I'm aware, there is no "face XYZ and update the server" function. There's a function that will send movement updates to the server if necessary, but I never bothered reversing it far enough to find out what triggers an update.
Here is how I do SetFacing in 1.12:
Code:
/* Movement */
#define A_Movement_F_SetFacing 0x7c6f30
#define A_Movement_F_SendMovementUpdate 0x600a30
/* Opcodes */
#define A_Opcode_MSG_MOVE_SET_FACING 0xda
typedef void (__thiscall *WoWFunc_SetFacing)(uintptr_t thisUnit, float angle);
typedef void (__thiscall *WoWFunc_SendMovementUpdate)(uintptr_t thisUnit, int currentTick, int opcode, int unk1,
int unk2);
void LocalMovement::SetFacing(const float angle)
{
const auto local_player = WoWObjectManager::GetLocalPlayer();
if (local_player == 0)
return;
WoWPlayer player(local_player);
WoWFunc_SetFacing(A_Movement_F_SetFacing)(player.GetMovementBase(), angle);
WoWFunc_SendMovementUpdate(A_Movement_F_SendMovementUpdate)(local_player, WoWFunctions::GetCurrentTick(),
A_Opcode_MSG_MOVE_SET_FACING, 0x0, 0x0);
}
-
Post Thanks / Like - 2 Thanks
-
I am doing it this way:
1. Get player and target cords
2. Calculate atan2
3. Write float to player rotation offset
Also keep in mind rotation in WoW is between 0 and 6.28, so if atan2 result is lower than 0 you have to add 2 * PI to it.
Last edited by vegoo; 08-12-2018 at 08:42 PM.
WoW TGC Loot & WoW Items
Selling EU & US WoW Gold
Buying EU & US WoW Gold
-
Post Thanks / Like - 1 Thanks
Picasopaya (1 members gave Thanks to vegoo for this useful post)
-
Originally Posted by
vegoo
3. Write float to player rotation offset
You still need to call update or move, or the server will not know.
-
Member
Great, thanks for the response guys! Will try the SendMovementUpdate function. I’m guessing I could skip the SetFacing and just write my rotation to my player offset and then call the SendMovementUpdate. Also, I guess the SendMovementUpdate is thread safe? Called from the main thread?
-
Originally Posted by
DarkLinux
You still need to call update or move, or the server will not know.
Yea I am using it to move around, don't know how it works if you only set it and then try to cast something without moving.
Last edited by vegoo; 08-13-2018 at 03:01 AM.
WoW TGC Loot & WoW Items
Selling EU & US WoW Gold
Buying EU & US WoW Gold
-
Contributor
Originally Posted by
vegoo
don't know how it works if you only set it and then try to cast something without moving.
It doesn't.