Thanks for pointing that silly mistake out Robske, I'll fix it in the upcoming revision.
I used to read the Type that way, but in the habit of using the descriptors I blatantly wrote that out, without double checking it (or even thinking about it) at all.
Same stuff with the int.MinValue, for some reason I assumed the min value of an int is 0, but I think I mixed it up with uint.MinValue (which actually is 0, int.MinValue is something like -2 million?). Thanks for pointing out the sloppy (and often noobish) mistakes.
Last edited by Seifer; 04-18-2010 at 04:14 PM.
Yay!
(filler)
BlackRain updated to 04192010. The objects are now properly loaded and handled, so you should be able to find all objects and their respective types.
I noticed only now that I haven't added X,Y,Z to units yet, so that's on the to-do list for the next revision. I should manage my shit a bit more properly, honestly.
I am not sure why, but I love your naming conventions.
:O
Except for WowDynamicObject.
lol.
Updated to 1.0a, 04222010. This is the first release where I'm confident enough to say it's stable. At least, the majority of it, but more on that later on.
Anyway, changelog:
The object searching is based on Apoc's method, which works like a charm. The only thing is that, with the introduction of C# 4.0, we're now able to take optional parameters instead of overloads, so I'll be working on getting the object searching to work with C# 4.0 standards, rather than using overloads.04222010 - Revision 9
- Added X,Y,Z to WowObject and an override on WowGameObject.
- Rough functionality for Object searching introduced, unstable, and needs testing/fixing.
Stuff like:
Is way too sloppy and poor written to call it stable, therefore this is an "alpha" release, if you will. I'm also working on making the entire DoSearch() method use LINQ rather than a foreach statement in the end, but that hasn't worked out too well either.Code:/// <summary> /// Refreshes the Object Search. /// </summary> /// <param name="parameters"></param> public void Refresh([Optional, DefaultParameterValue(null)]SearchParams @parameters) { List<T> list = (@parameters == null) ? _objectList = DoSearch<T>(ObjectManager.Objects, Parameters) : _objectList = DoSearch<T>(ObjectManager.Objects, parameters); }
Anyway, it (finally) has X,Y,Z working now, for WowObject in general, and an override for GameObject (since they're different), so you should be able to get some sort of tool going with it now.
Oh and Apoc, in your post regarding Object Searching, you search for object specific stuff in WowObject, such as level, health (IsDead) etc. do you actually keep these values in WowObject, or do you pass it - for example - WowUnit? Can't imagine the latter, since you'd end up with null results in the LINQ statement for several objects. Can you clarify this? (Couldn't post in that thread because of necro protection)
Updated binaries and SVN.
Last edited by Seifer; 04-22-2010 at 11:17 AM.
I actually ditched the entire 'object searching' method, in favor of (faster) LINQ queries.
Eg:
Makes it easier to do very fast, easy to understand, searches.Code:possibleTargets = (from o in OnyxWoW.ObjectList where o is WoWUnit && o != OnyxWoW.Me && o.Distance <= AreaManager.CurrentArea.TargetingRange && o.Position.Distance(AreaManager.CurrentHotspot.Position) <= AreaManager.CurrentHotspot.Range let u = o.ToUnit() where !u.Dead && !u.PvpFlagged && u.Relation != WoWUnitRelation.Friendly && u.CreatureType != WoWCreatureType.Critter && !u.Tapped && u.Level >= MinLevel && u.Level <= MaxLevel && !u.OnTaxi && u.Attackable && !AreaManager.CurrentArea.IgnoreFactions.Contains(u.Faction.Id) orderby o.Distance ascending select u).ToList();
Also; as a design pattern, nothing in our WoW library returns null unless specifically stated. (99% of the stuff has an 'IsValid' boolean, so you can always be sure whether or not the object is a valid reference or not.)
And our main ObjectList never contains invalid objects. (They are persistent though)
Last edited by Apoc; 04-22-2010 at 11:23 AM.
isnt blackrain the crack in iphone? D:
That's exactly what I was shooting for - Thanks!
So, for example; if I'm using the above LINQ statement, or the statement you had posted in the ObjectSearching post, where you were searching WoWObjects, and had a check for "bool IsDead" in the LINQ statement, you kept the IsDead property in your WowObject class? That got me a bit confused, as IsDead is not a valid property for all objects that inherit from WowObject, I believe.
It is. Hence the "original naming"
I felt like this stuff is - in some way, shape or form - similar to jailbraking an iphone, as we allow our own code to run on the WoW baseline (long shot, I know).
"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
Walkthrough: Writing Queries in C# (LINQ) - let keyword
edit: damn, too slowpossibleTargets = (from o in OnyxWoW.ObjectList
where o is WoWUnit &&
o != OnyxWoW.Me &&
o.Distance <= AreaManager.CurrentArea.TargetingRange &&
o.Position.Distance(AreaManager.CurrentHotspot.Position) <= AreaManager.CurrentHotspot.Range
let u = o.ToUnit()
where !u.Dead &&
!u.PvpFlagged &&
u.Relation != WoWUnitRelation.Friendly &&
u.CreatureType != WoWCreatureType.Critter &&
!u.Tapped &&
u.Level >= MinLevel &&
u.Level <= MaxLevel &&
!u.OnTaxi &&
u.Attackable &&
!AreaManager.CurrentArea.IgnoreFactions.Contains(u.Faction.Id)
orderby o.Distance ascending
select u).ToList();
Yes, I noted that in this post, but in the post over at:
http://www.mmowned.com/forums/progra...ml#post1596536
He has shown us a method like:
And call me a knob, but I can't see how it's converted to a unit there.Code:IEnumerable<WoWObject> filtered = from o in objects where Compare.Equal(searchParams.Name, o.Name) && Compare.Equal(searchParams.CanAttack, o.CanAttack) && Compare.Equal(searchParams.Dead, o.IsDead) &&
Which got me to believing that IsDead is actually a property of WowObject, unless I'm missing something obvious. (Which I probably am)
I've copied and pasted your code exactly (apart from readonly, for somereason it won't compile with that there), yet am getting NullReferenceException errors when reading health, wow is open and logged in etc. Any chance of a heads up?
Code:Process[] _wowProc = Process.GetProcessesByName("Wow"); int pid = _wowProc[0].Id; // Will grab the first WoW process found. (0th element) ObjectManager.Initialize(pid); int playerHealth = ObjectManager.Me.Health;
Last edited by Jackedy129; 04-22-2010 at 12:28 PM.
...
From the post:
First things first, lets create some quick wrapper stuff to feed our searcher.
Again, nothing really functional. That's up to you as the bot writer to implement!Code:namespace ObjectSearcher { public class WoWObject { public double Distance; public ulong Guid; public bool IsDead; public bool IsInLineOfSight; public string Name; public virtual int Type { get { return 1; } } public bool CanAttack; public int Level; public bool IsMe; } public class WoWUnit : WoWObject { public override int Type { get { return 2; } } } }
"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