How do you grab your local player? I'm using the same way that you use for GetObjByGuid, but it seems like the guids from the descriptors and the one at [objmgr + 0xC0] are different. Any help?
Since I use EnumObjects instead of doind the iterations myself, I face a little problem: I have to make sure I already entered the world or EnumObjects will cause an access violation.
What is the best way to check if I am ingame? Currently I try to retrieve the objectmanagers address, if I fail doing so (NULL-pointers) I can be pretty sure I am not ingame. That looks kinda bad style to me, but I haven't found a better solution yet.
@Lanman:
This is how I do it.activePlayer_ = getObjectByGuid(getGuidByKeyword("player"));
Hey, it compiles! Ship it!
Problem is I moved it out of process. Same structure, just changed way it enumerates. Any ideas?
EDIT: I looked at the function you mentioned, and it takes the same guid that I'm using, yet still not finding the right object.
Maybe I'm just doing something wrong?
Code:GameObject v = new GameObject(); RealObjects.TryGetValue(_magic.ReadUInt64(s_curMgr + 0xC0), out v); return new WoWPlayer(v.ObjPtr) ?? new WoWPlayer(0);
Last edited by lanman92; 11-21-2009 at 04:52 PM.
As far as I remember the GUID is stored at offset 0x6C of the object manager.
Yeah, but internally it does the same with the added overhead of reading the guid.That's one way, or you can use ClntObjMgrGetActivePlayer which will return 0 if no active player, or the GUID of the active player if there is one.
I was more looking for a static address. But I think its not really important, I ll continue to check pointerresults.
Hey, it compiles! Ship it!
Not sure why, but it's throwing a null reference exception when I use GetObjByGuid or my function posted above. That's most likely the issue. Can't see why it's being thrown though. That's the reason why I changed it from WoWObject v to WoWObject v = new WoWObject(0). Still no love with the 0x6C offset either.
EDIT: Figured I'd share my solution. Here's what I did.
I just added the RawObject member to wowobject so I could check it to the one in the object manager. Works like a charm.Code:public static GameObject Me { get { foreach (GameObject o in RealObjects.Values) { if (o.Type == WoWObjectType.Player) { if (o.RawGuid == _magic.ReadUInt64(s_curMgr + 0xC0)) return o; } } return new GameObject(0); } }
Last edited by lanman92; 11-21-2009 at 08:54 PM.
I hate to bump an old thread, but does anyone else get the exception that the List was modified during an enumeration, and it stops working correctly? I know the problem is coming from removing Invalid entries in the list, but the way it's done here doesn't seem like it should throw this error. Any help?
EDIT: Nevermind. Fixed.
Code:if (_framecount % 30 == 0) { IEnumerable<GameObject> remove = (from o in RealObjects where !o.Value.IsValid select o.Value); foreach (var pair in remove) { RealObjects.Remove(pair.Guid); } }
Last edited by lanman92; 12-21-2009 at 02:44 PM.
You dick, you just invalidated a crapton of work that I did (tracking PLAYER_ENTERING_WORLD, etc.) trying to figure out how to know if I'm "in the game" or not. You mean I could have just been checking a ulong against 0 the whole time?
*bonk* *goes back to delete about 100 lines of fragile, buggy-ass code*
Don't believe everything you think.
Simple enough.
Just tack on .ToList() to your query, to make sure you COPY the list, instead of use the actual reference from within the list. .NET doesn't like when you try to remove stuff from a currently-iterating-collection. This way; you copy the GUIDs and then try to remove them from the main object list.Code:var guids = (from o in RealObjects where !o.Value.IsValid select o.Key).ToList();
Yeah, I looked up the error and fixed it on my own. Of course, that was after I posted in the thread. From the looks of it, I really helped amadmonk out by bumping it though xD On the topic of game state tracking, is there a simple way to tell if you are logged in to the character select screen?
Hmm this clears some things up, trying to write a radar thingy for my own use, this helps to understand some things. Thanks Apoc
" Spy sappin mah sentry! "
Sorry for injecting something useless here. But I felt I just had to say... FREAKING BRILLIANT!!!