-
Question from Empathe on Warlock Pets
hi
i'm a old player world of warcraft,
i've already create a autobot-heal on vanilla server in 32bits.
i play now on official server but they have so many change about vanillia.
i'll create a bot for automatic dps on warlock, i've already created
but for the best way i'll need to use "Number of my pet alive"
i've already listed all entityList but i don't understand in Legion how to use "CreatedBy" ? or SummonedBy ?
The active pet for a warlock is listed in the entity list.
The CGGuid of the pet is stored in the Local Player UnitField.Summon descriptor.
So you traverse the entityList looking for a unit that has the CGGuid sorted in the descriptor referenced above.
Code:
public CGGuid128 Summon
{
get
{
return GetDescriptor<CGGuid128>((uint)UnitFields.Summon);
}
}
public CGUnit Pet
{
get
{
foreach (CGUnit unit in Wow.Units)
{
if (unit.CGGuid != Summon)
continue;
return unit;
}
return null;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CGGuid128
{
private UInt64 _low;
private UInt64 _high;
public CGGuid128(CGGuid128 g)
{
_low = g.Low;
_high = g.High;
}
public UInt64 Low { get { return _low; } }
public UInt64 High { get { return _high; } }
public UInt32 DW0
{
get
{
UInt32 result = (UInt32)(_low & 0xffffffff);
return result;
}
}
public UInt32 DW1
{
get
{
UInt32 result = (UInt32)(_low >> 32);
return result;
}
}
public UInt32 DW2
{
get
{
UInt32 result = (UInt32)(_high & 0xffffffff);
return result;
}
}
public UInt32 DW3
{
get
{
UInt32 result = (UInt32)(_high >> 32);
return result;
}
}
public static bool operator ==(CGGuid128 g1, CGGuid128 g2)
{
if (g1._high == g2._high)
{
if (g1._low == g2._low)
{
return true;
}
}
return false;
}
//public static bool operator !(CGGuid128 g1)
//{
// if (g1._high == 0)
// return true;
// if (g1._low == 0)
// return true;
// return false;
//}
public static bool operator !=(CGGuid128 g1, CGGuid128 g2)
{
if (g1._high != g2._high)
return true;
if (g1._low != g2._low)
return true;
return false;
}
public bool IsZero
{
get
{
if (_high != 0)
return false;
if (_low != 0)
return false;
return true;
}
}
public override string ToString()
{
return DW3.ToString("X") + " | " + DW2.ToString("X") + " | " + DW1.ToString("X") + " | " + DW0.ToString("X");
}
public CGObject ToObject
{
get
{
foreach(CGObject obj in Wow.Objects)
{
if (obj.CGGuid == this)
return obj;
}
return null;
}
}
}
Hope this helps.
-
Post Thanks / Like - 1 Thanks
empathe (1 members gave Thanks to counted for this useful post)
-
Member
oh good, i'hve create a schéma,
it's good ?
-
Contributor
GUID not int[16], is byte[16] (or int[4] or long[2]). U can write own struct as in sample counted.
-
Contributor
Originally Posted by
Zazazu
GUID not int[16], is byte[16] (or int[4] or long[2]). U can write own struct as in sample counted.
Come again please? What GUID not int[16]means? :confused:
Last edited by tutrakan; 01-15-2017 at 02:22 AM.
-
Originally Posted by
tutrakan
Come again please? What GUID not int[16]means? :confused:
Look at the struct i posted above.
CGGuid is a 128 bit [ (2) 64 bit ] unique identifier for objects in wow.