One question (AI-Bot)

03/24/2010 16:52 .Kob#1
Hello, I have this code but not work well ... Someone could help me?

Here is the code:

Code:
 
Random XCoords = new Random();
int FinalX = XCoords.Next(40, 60);

Random YCoords = new Random();
int FinalY = YCoords.Next(40, 61);

Jump((ushort)FinalX, (ushort)FinalY);
And the problem is ... why my bot just jump in rect line like this photo?

[Only registered and activated users can see links. Click Here To Register...]

Thanks!
03/24/2010 17:03 Korvacs#2
When you initialize a random it uses a seed to determine what the next random number will be, this is based on the current time i think for the standard .net random class, so if you initialize them both at roughly the same time then they will both generate a random number which is identical, instead you should define a random number as a static for your entire server to use, that way whenever you use it it will always generate a different number.

Or if you insist on intializing it everytime you move its position just intialize one:

Code:
Random Rand = new Random();
Then

Code:
int X = Rand.Next(40, 60);
int Y = Rand.Next(40, 60);
03/24/2010 17:15 .Kob#3
very good explanation, thanks!
03/24/2010 23:28 .Kob#4
Sorry for double post but is just for bump,

i have another question and i don't want make another trhead.. =).
Is just make sit the bot. I know the Action is 250 but if just type "Action = 250;" he don't sit, i need send the packets really? Can you help me with this? =S Or tell me where is the site where when i press the Site button he work. I don't find that! =S. Sorry for my english >.<'

Thanks guys!
03/25/2010 01:28 Korvacs#5
You will need to send the action packet to everyone in the local area.
03/25/2010 01:33 .Kob#6
Quote:
Originally Posted by Korvacs View Post
You will need to send the action packet to everyone in the local area.
Ok and how i can do this? =S =S
03/25/2010 01:41 Korvacs#7
The same way your sending the jump packet locally.
03/25/2010 11:11 .Kob#8
Ok here is all jump packets:

Code:
GC.MyChar.Loc.Jump(BitConverter.ToUInt16(Data, 8), BitConverter.ToUInt16(Data, 10));
^This is just for jump, i don't need this one.


Code:
Game.World.Spawns(GC.MyChar, true);

^Maybe is this but, i tested with command and not work =S



Code:
Game.World.Action(GC.MyChar, Data);

^And here, i think this one is needed but don't work too.

I tested both in the same command too.
But, what is "Data" in the Action packet?

Thanks =]
03/25/2010 23:59 andyd123#9
Data should be "250" or rather the ID of the action you want your bot to express.
03/26/2010 12:27 .Kob#10
Thanks andy ... And now whats fail with this code? =S

Code:
byte[] BotAction = new byte[250];
Game.World.Action(MyClient.MyChar, BotAction);
When i use this my client crash.. (Conquer.exe)

I tested this with the bot and not working (client crash when i active that with a command) Then, i tested the code with another command, here is: And crash the client too ...

Code:
if (Cmd[0] == "@testsit")
{
     GC.MyChar.Action = 250;
     [COLOR="Red"]byte[] BotAction = new byte[250];[/COLOR]
     Game.World.Action(GC.MyChar, BotAction);
}
This don't give error in the C# but, i think is this conversion what make the error =S

What fail? o.0
03/26/2010 13:33 Korvacs#11
Nono, your sending a packet which is 250 bytes long, you dont want to do that at all....

You would need to send something like this i would think:

Code:
Game.World.Action(GC.MyChar, Packets.GeneralData(GC.MyChar.EntityID, 250, 0, 0, 81).Get);
03/26/2010 15:06 .Kob#12
LOL =D I need learn more :facepalm:

And your code work perfectly Korvacs! Thanks again guy! :handsdown:
03/26/2010 15:25 KraHen#13
Btw you shouldn`t just do random coords IMO. Read some articles on AI programming, a random bot is just... a random bot.
03/26/2010 15:53 .Kob#14
Is just the jump and just when the stamina is going up. Then the bot jump random and if is not in any rage with the enemy, then sit and up the stamina.
When is full stamina he start jump (random but followin the player) and launch FBs or SSs. With diferents dificulties, the bot can never fail a fb obviously ... then i'll maked dificulties and again i puted a random adding or subtracting coords, and the bot fail just for 1 - 4 coords range.
Soz i know my english fail, I'm Spanish :facepalm:
03/26/2010 16:18 KraHen#15
Quote:
Originally Posted by cakobu View Post
Is just the jump and just when the stamina is going up. Then the bot jump random and if is not in any rage with the enemy, then sit and up the stamina.
When is full stamina he start jump (random but followin the player) and launch FBs or SSs. With diferents dificulties, the bot can never fail a fb obviously ... then i'll maked dificulties and again i puted a random adding or subtracting coords, and the bot fail just for 1 - 4 coords range.
Soz i know my english fail, I'm Spanish :facepalm:
Don`t worr I have understood you :P It seems nice, I`d like to see it in action :P