-
Member
RETAIL How to use Spell_C_HandleTerrainClick
Code:
char __fastcall sub_140ED5A70(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax
LOBYTE(a2) = 1;
v2 = a1;
if ( !(unsigned int)sub_140ED5AE0(a1, a2) )
return sub_140ED5600(v2, v2 + 0x10, 0i64);
if ( xmmword_142E9C530 != 0 )
{
v3 = sub_140F0E3E0(&xmmword_142E9C530);
if ( v3 )
sub_140EE0BB0(v3);
}
return 0;
}
I read the previous one and tried to pass the struct TerrainClick
{
uint64_t guid;
Location pos;
int32_t click_type;
};
Will crash directly
-
Contributor
Use CGGameUI::OnTerrainClick, it's further up in the calls to this function you posted.
GUID is mover GUID (think local player transports like an elevator) There's a dungeon in shadowlands that needs this to be set properly, necrotic wake I think.
That function you have there looks like
The struct looks right tho.
```
struct ClickData
{
GUID mover;
Vector3 location;
unsigned int click_type;
char ClickLocation();
} __attribute__((packed));
```
Else you see that the call is
(__int64 a1, __int64 a2)
(ClickData, ClickData.Location)
Also make sure you're not calling CGPetInfo::HandleTerrainClick or CGPetInfo::HandleMoveTo,
But `CGGameUI::OnTerrainClick` can do all of the clicks itself, PetMove, ClickSpell, Click to move
-
Member
Originally Posted by
ChrisIsMe
There's a dungeon in shadowlands that needs this to be set properly, necrotic wake I think.
Yes, in this dungeon last 2 bosses located on the vehicle (all room is a vehicle).
To calculate the position for ground cast properly you need to get Vehicle for LocalPlayer,
then you get the matrix of the vehicle and transform LocalPlayer position:
Code:
Matrix4x4 m = vehicle.GetMatrix();
var loc = LocalPlayer.Location;
var x = loc.X * m.M11 + loc.Y * m.M21 + loc.Z * m.M31 + m.M41;
var y = loc.X * m.M12 + loc.Y * m.M22 + loc.Z * m.M32 + m.M42;
var z = loc.X * m.M13 + loc.Y * m.M23 + loc.Z * m.M33 + m.M43;
var result = new Vector3(x, y, z);
for proper rotation you just need to add vehicle rotation to the player:
Code:
var rotation = Localplayer.Rotation + vehicle.Rotation;
-
Member
Originally Posted by
ChrisIsMe
Use CGGameUI::OnTerrainClick, it's further up in the calls to this function you posted.
GUID is mover GUID (think local player transports like an elevator) There's a dungeon in shadowlands that needs this to be set properly, necrotic wake I think.
That function you have there looks like
The struct looks right tho.
```
struct ClickData
{
GUID mover;
Vector3 location;
unsigned int click_type;
char ClickLocation();
} __attribute__((packed));
```
Else you see that the call is
(__int64 a1, __int64 a2)
(ClickData, ClickData.Location)
Also make sure you're not calling CGPetInfo::HandleTerrainClick or CGPetInfo::HandleMoveTo,
But `CGGameUI::OnTerrainClick` can do all of the clicks itself, PetMove, ClickSpell, Click to move
Thank you for your help. I will try to click outside the dungeon first. 36949 CGGameUI__OnTerrainClick Should be 0x14EB8A0
Code:
v2 = *(_DWORD *)(a1 + 0x1C);
v3 = a1;
if ( v2 == 4 || dword_142F58108 )
{
CGGameUI__ClearCursor(1i64);
v2 = *(_DWORD *)(v3 + 0x1C);
}
{
GUID mover; //0x0
Vector3 location;//0x10 -0x14 -0x18
unsigned int click_type;//0x1c
}
0x1C is clicktype
Exactly clicktype 0x4 should be rightbutton click
TerrainClick testData{ {0, 0}, ActivePlayer->GetObjectPosition(), 0x1 };
func::OnTerrainClick(&testData);
yes it worked THANKS
Spell_C_HandleTerrainClick should work normally too. I forgot to assign a value to Location so crashed.
Last edited by 34D; 01-06-2021 at 01:42 AM.
-
Member
Originally Posted by
Alisha
Yes, in this dungeon last 2 bosses located on the vehicle (all room is a vehicle).
To calculate the position for ground cast properly you need to get Vehicle for LocalPlayer,
then you get the matrix of the vehicle and transform LocalPlayer position:
Code:
Matrix4x4 m = vehicle.GetMatrix();
var loc = LocalPlayer.Location;
var x = loc.X * m.M11 + loc.Y * m.M21 + loc.Z * m.M31 + m.M41;
var y = loc.X * m.M12 + loc.Y * m.M22 + loc.Z * m.M32 + m.M42;
var z = loc.X * m.M13 + loc.Y * m.M23 + loc.Z * m.M33 + m.M43;
var result = new Vector3(x, y, z);
for proper rotation you just need to add vehicle rotation to the player:
Code:
var rotation = Localplayer.Rotation + vehicle.Rotation;
Does it mean to convert it to a relative position and then calculate the coordinates?
-
Post Thanks / Like - 1 Thanks
fancy (1 members gave Thanks to 34D for this useful post)
-
Contributor
Originally Posted by
34D
Does it mean to convert it to a relative position and then calculate the coordinates?
I haven't seen a need for code with matrices, I just add the position of the Mover, and the Unit itself... Sometmes this is a few levels deep though, if a mover has a mover.
-
Member
Originally Posted by
34D
Does it mean to convert it to a relative position and then calculate the coordinates?
LocalPlayer position when on Vehicle will be relative to the vehicle, so it will be something like
Code:
new Vector3(0.5f, 0.7f, 0.3f)
after you got the world matrix of the vehicle - it will hold data about the position of the Vehicle model within current real space coordinates.
so you then calculate LocalPlayer real coordinate, using this matrix and your relative position on this vehicle.
Last edited by Alisha; 01-06-2021 at 09:07 PM.
-
Member
Originally Posted by
Alisha
LocalPlayer position when on Vehicle will be relative to the vehicle, so it will be something like
Code:
new Vector3(0.5f, 0.7f, 0.3f)
after you got the world matrix of the vehicle - it will be absolute coordinates of the Vehicle model transformed to current real space coordinates.
so you then calculate LocalPlayer real coordinate, using this matrix and your relative position on this vehicle.
thanks i'll try. by the way Is there a way to directly find localplayer's target ptr? not target guid.
-
Member
Originally Posted by
34D
thanks i'll try. by the way Is there a way to directly find localplayer's target ptr? not target guid.
from offset within LocalPlayer BaseAdress? No
But after you got TargetGuid, you just get object from ObjectManager, something like:
Code:
private ConcurrentDictionary<WoWGuid, IWoWObject> _objects { get; } = new ConcurrentDictionary<WoWGuid, IWoWObject>();
public IWoWObject GetObjectByGuid(WoWGuid guid)
{
_objects.TryGetValue(guid, out var value);
return value;
}
I assume you would anyway have access to objects at this point
Last edited by Alisha; 01-06-2021 at 09:14 PM.
-
Contributor
Originally Posted by
Alisha
from offset within LocalPlayer BaseAdress? No
But after you got TargetGuid, you just get object from ObjectManager, something like:
Code:
private ConcurrentDictionary<WoWGuid, IWoWObject> _objects { get; } = new ConcurrentDictionary<WoWGuid, IWoWObject>();
public IWoWObject GetObjectByGuid(WoWGuid guid)
{
_objects.TryGetValue(guid, out var value);
return value;
}
I assume you would anyway have access to objects at this point
Yup, and if you're using the hashmap object manager it should be pretty much O(n+n), the. game gets pointers to objects by GUID everywhere.
-
Member
Ohh, my current approach is to get the guid in lua and then use the obj manager of lua to convert the guid to the corresponding ptr and then transfer the ptr to c++ and click.
I thought player baseptr + 0x1c40 was the target’s ptr
-
Member
Originally Posted by
Alisha
from offset within LocalPlayer BaseAdress? No
But after you got TargetGuid, you just get object from ObjectManager, something like:
Code:
private ConcurrentDictionary<WoWGuid, IWoWObject> _objects { get; } = new ConcurrentDictionary<WoWGuid, IWoWObject>();
public IWoWObject GetObjectByGuid(WoWGuid guid)
{
_objects.TryGetValue(guid, out var value);
return value;
}
I assume you would anyway have access to objects at this point
Hello. When I use HandleTerrainClick, I found that the AOE will be casted onto the Unit model head, maybe the height of the unit will be added.
Of course, it will not be when using CTM.
How to get UnitHeight and Z - UnitHeight is the correct floor height?
-
Member
Originally Posted by
34D
Hello. When I use HandleTerrainClick, I found that the AOE will be casted onto the Unit model head, maybe the height of the unit will be added.
Of course, it will not be when using CTM.
How to get UnitHeight and Z - UnitHeight is the correct floor height?
Hello.Could u plz tell me HandleTerrainClick offset of v37474 ?
-
Active Member
Originally Posted by
hfc
Hello.Could u plz tell me HandleTerrainClick offset of v37474 ?
00000001414EC550, rebased to 0000000140000000
I wonder if anyone know how to properly call ClickToMove at 0x000000014109CD50 .... my attempts to call it with exactly same arguments which used by game itself - cause the crash.
Last edited by ostapus; 02-23-2021 at 07:28 PM.
-
Established Member
Originally Posted by
ostapus
00000001414EC550, rebased to 0000000140000000
I wonder if anyone know how to properly call ClickToMove at 0x000000014109CD50 .... my attempts to call it with exactly same arguments which used by game itself - cause the crash.
I am working on classic, and I too have this same problem. Do you get a divide by zero error? I'm still learning about native reversing, but I'm under the assumption the crash might be due to checking the call stack.
So it throws an error when not called from the game's actual address space. Thus why I can call the wrapper functions without an issue, but trying to directly call the function from my injected dll will flag the call stack check and crash.