Hello,
when i have the baseaddress of a wow unit, i can easily read the unit hp,mana and so on by using the wowUnit enums or structs.
My question is how can i do that for a player, because the enums or structs don't include fields for hp and so on?
Hello,
when i have the baseaddress of a wow unit, i can easily read the unit hp,mana and so on by using the wowUnit enums or structs.
My question is how can i do that for a player, because the enums or structs don't include fields for hp and so on?
you use the same which you use on units..
read from (pStorage + UNIT_FIELD_HEALTH * 4)
Look up inheritance.
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
"I cried a little earlier when I had to poop" - Sku
As Robske pointed out, use class inheritance for this:
Inheritance (C# Programming Guide)
What Evieh said is also true, the health field and so on are shared between units and players (because players are effectively units).
If you like to learn by looking at code; there are many object manager threads around the forums which demonstrate this perfectly:
And WowUnit on its turn:Code:public class WowPlayer : WowUnit { public WowPlayer(uint baseAddress) : base(baseAddress) { }
So basically, WowPlayer inherits all the properties from WowUnit, and its constructor. WowUnit on its turn inherits WowObject, which means WowUnit inherits all properties and methods defined in WowObject.Code:public class WowUnit : WowObject { public WowUnit(uint baseAddress) : base(baseAddress) { }
The idea behind this is that WowPlayer is a Unit, and a Unit is an Object (Player -> Unit -> Object is the inheritance hierarchy)
This is covered in C# here:
trunk - blackrainobjects - Project Hosting on Google Code
If you need info on how a class tree looks like in memory: Reversing Microsoft Visual C++ Part II: Classes, Methods