Quote:
Originally Posted by denominator
Nevermind I got it loaded up lol.
Is it just me or does Conquer have a problem loading up most of the time with this? I did something simple and now can lvl waterelf with watertaoists
I assume Distance is a bit of a giveaway? Regardless it gives an error "Cannot convert type 'uint' to 'AlchemyProxy.Mob'" I tried googling for that error as well but according to Google "uint" doesn`t seem to exist o.0
|
ushort, uint, ulong, short, int, long are all numeric types that do not contain decimals which can hold different ranges of numbers.
Mob is NOT a simple number. It's a class which holds all sorts of information on the monster. In order to compare distances you must run a calculation to find how far away the monster is... aka the 'distance' method which takes 4 parameters. Starting x/y and target x/y.
Keep in mind that the furthest you can jump/fatal strike is 18, furthest you can shift is 7 and normal melee attacks are 1-2 range.
Quote:
Originally Posted by janvier123
Reportet at 12.07.2010 - 2:50 PM
-multiple post (please use the "Edit-Button")
Please read the
and by a Guardian ... bad karma
|
As korv said to you in my pserver tracking thread, I'm allowed to make multiple posts if I want to seeing as they tend to contain large amounts of information/updates.
If you don't like the release then stop trolling and get out of my thread
<edit>
Added guide to first post on how to set up.. and seeing as I'm putting off studying, lets go over some BASICS of how to code in some minor bot functionality.
Lesson 1:
Think logically and break things down into their most basic steps!
-What methods do we need for our bot?
That depends on what we want it to do but the main actions we want to take are...
-Looting
-Attacking
-Moving
-Dropping
That covers 99 pct of botting functionality correct? Before we can code anything into the bot we need to be able to perform these actions in controlled circumstances... any logic behind WHEN to execute them comes much later.
Well for looting we already have a packet for it coded into the source!
Packets.PickItem(Client, GroundItem);
Ok so to call this we need to know who is looting what item... Well that's easy enough seeing as our client thread already has a client object calling it right? Well we need to know about the ground item we want to try to loot... We can only loot something when we are standing on top of it... which will always be the closest item would it not? So why don't we write a method to pull the closest item?
But wait! How do we know which is closest? Well... there's already a handy Distance method in the source: Handler.Distance(X1, Y1, X2, Y2)... ok well how can we use that to figure out which item is closest? How do we know where items are in the game? Easy! We already have a dicitonary being updated to add/remove local items to our client... This is contained as a dictionary known as GroundItems in the client object which holds a key of the item uid and a value of the item struct (which contains the x/y info!)
So... to determine which is the closest item we should be running through local items to determine which is lowest... correct?
Ok well we can easily run through each item in the collection using the foreach loop!
foreach(GroundItem I in Client.GroundItems.Values)//we use values because we are not concerned with the keyvalue pairing of uid/item struct!
{
//code
}
ok so that's all well and good but how do we properly write this and determine which is closest?
Well we are going to write a method which returns the closest item!
WOAH! A method?! that sounds hard!
No, not really. Think of it like a handy math equation which you can simply just enter in values and get a result from... in this case we are going to need an input value of our client and we want a return value of the closest item correct? well that means we want the return type to be a GroundItem object.
Code:
public static Items.GroundItem GetClosestItem(Client C)
{
Items.GroundItem I = null;
//code
return I;
}
This code will return a null reference exception if you try to actually use the object returned... because it has no value! I'm doing that for a reason. It means if there are no items in range it will return a null value and we can perform other actions (such as no items in range = kill shit!)
So now all we need to do is plug in our distance calculation and determine if the new item being checked is closer than the previous item right?
Code:
public static Items.GroundItem GetClosestItem(Client C)
{
Items.GroundItem I = null;
int Dist = 19;
foreach (Items.GroundItem Item in C.GroundItems.Values)
{
if (Distance(C.X, C.Y, Item.X, Item.Y) < Dist)
{
I = Item;
Dist = Distance(C.X, C.Y, I.X, I.Y);
}
}
return I;
}
WOAH! You added some new shit!! What does it mean?!
Well... all we are doing is setting an initial item distance. The furthest item we would like to pull is a distance of 18 (aka off screen). No such objects SHOULD be in the collection as we are calling the updatelocal method to remove anything offscreen any time we move but it's always better to be safe than sorry... besides we want a value to compare it against!
So now all we do is run our distance calculation and check if it's closer than the last item checked... If so we update the item to return and change the distance. If not we never update distance and the next item is checking distance vs the original 18 dist (so you won't actually receive the closest item)
And there you have.. a very simple method of finding the closest item to yourself and also an explanation of what many of the methods in the source do.
You could now modify it to return the... closest rare item... closest money... closest gear item or anything you like by adding 1 more check before you update distance/item to return.
This exact same idea can be applied to things like monsters as well!
It's all very simple stuff.. Hopefully this little guide/explanation will help some ppl get a start on it.