Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server > CO2 PServer Guides & Releases
You last visited: Today at 23:26

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Small-Release] Re-written walk method.

Discussion on [Small-Release] Re-written walk method. within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
[Small-Release] Re-written walk method.

Im pretty sure everyone have seen the walk code in LOTF. Well I rewrote one because I was really really bored, so I decided to do this ****. Its probably the best walk code released so far and yeah, enjoy. Small release as I said, should work in any source with a small adjustment.

Edit : Removed the old one because it wasnt working as I thought ( didnt tested )
Heres one that works almost perfect:


Quote:
public void Walk(byte Dir)
{
sbyte x = 0, y = 0;
if (Dir == 0 || Dir == 1 || Dir == 5 || Dir == 7)
x = 1;
if (Dir >= 1 && Dir <= 3)
x = -1;
if (Dir == 1 || Dir == 6 || Dir == 7)
y = 1;
if (Dir >= 3 && Dir <= 5)
y = -1;
X = (ushort)(X + x); Y = (ushort)(Y + y);
}
_Emme_ is offline  
Old 02/04/2009, 21:25   #2
 
HellCo's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
yet you flame EVERYONE for using lotf, u idiot.
HellCo is offline  
Old 02/04/2009, 21:31   #3
 
taylor2846's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
um... i have never seen him flame peple for using lotf is seen him flame alot yes but not for using lotf.. or mabe im rong i dont no im just a noob having fun xD
taylor2846 is offline  
Old 02/04/2009, 21:42   #4
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Fyi the *lotf* one will run faster than yours. You also forget that the client does not send a pre-modulated direction, so unless the caller mods it in the argument, you've missed this as well.

Further more you can see several what I'd assume vital things done;
Code:
// notify other people to move? your function fails to do this
World.PlayerMoves(MyChar, Data);

// update the old location, your function fails to do this
MyChar.PrevX = MyChar.LocX;
MyChar.PrevY = MyChar.LocY;

// update the current location, your function *does* do this
MyChar.LocX = (ushort)(MyChar.LocX + AddX);
MyChar.LocY = (ushort)(MyChar.LocY + AddY);
Longer code, does not neccicarly mean slower code.
InfamousNoone is offline  
Old 02/04/2009, 21:45   #5
 
HellCo's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
Quote:
Originally Posted by InfamousNoone View Post
Fyi the *lotf* one will run faster than yours. You also forget that the client does not send a pre-modulated direction, so unless the caller mods it in the argument, you've missed this as well.

Further more you can see several what I'd assume vital things done;
Code:
// notify other people to move? your function fails to do this
World.PlayerMoves(MyChar, Data);

// update the old location, your function fails to do this
MyChar.PrevX = MyChar.LocX;
MyChar.PrevY = MyChar.LocY;

// update the current location, your function *does* do this
MyChar.LocX = (ushort)(MyChar.LocX + AddX);
MyChar.LocY = (ushort)(MyChar.LocY + AddY);
Longer code, does not neccicarly mean slower code.
True dat! Emme just released any random **** to get thanks, go look at he/she posts, EVERY post says press thanks, even though its already in the sig, just stupid ya kno.
HellCo is offline  
Old 02/05/2009, 00:24   #6


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
You also have a line of redundant code in your method, if you insist on using yours you should use this:

Code:
public void Walk(byte Dir)
        {
            sbyte x = 0, y = 0;
            if (Dir == 0 || Dir == 1 || Dir == 7) y = 1;
            if (Dir >= 1 && Dir <= 4) x = -1;
            if (Dir >= 3 && Dir <= 5) y = -1;
            X = (ushort)(X + x); Y = (ushort)(Y + y);
         }
I dont see why this was in their at all since its covered by the second if statement......

Code:
            if (Dir >= 1 && Dir <= 3) x = -1;
Edit: Also i just notice you dont ever handle moving in dir 6, so what...are you not allowed to move in that direction on your server?
Korvacs is offline  
Old 02/05/2009, 00:40   #7
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Quote:
Originally Posted by Korvacs View Post
Edit: Also i just notice you dont ever handle moving in dir 6, so what...are you not allowed to move in that direction on your server?
Yup, its against the law to move in that direction in Sweden =P
kinshi88 is offline  
Old 02/05/2009, 00:45   #8
 
zane203's Avatar
 
elite*gold: 0
Join Date: Jun 2008
Posts: 418
Received Thanks: 56
Quote:
Originally Posted by HellCo View Post
True dat! Emme just released any random **** to get thanks, go look at he/she posts, EVERY post says press thanks, even though its already in the sig, just stupid ya kno.
=] and what have you coded thats actually up to that level?

honestly i mean, the fact that hybrid helped the code, and even taught emme something is a good thing... the fact that you're being a "hater" and trying to laugh at "knowledge" is the blissful act of ignorance...

=] next time, think b4 you post
-Zane Blalock-
zane203 is offline  
Old 02/05/2009, 06:19   #9
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Quote:
Originally Posted by InfamousNoone View Post
Fyi the *lotf* one will run faster than yours. You also forget that the client does not send a pre-modulated direction, so unless the caller mods it in the argument, you've missed this as well.

Further more you can see several what I'd assume vital things done;
Code:
// notify other people to move? your function fails to do this
World.PlayerMoves(MyChar, Data);

// update the old location, your function fails to do this
MyChar.PrevX = MyChar.LocX;
MyChar.PrevY = MyChar.LocY;

// update the current location, your function *does* do this
MyChar.LocX = (ushort)(MyChar.LocX + AddX);
MyChar.LocY = (ushort)(MyChar.LocY + AddY);
Longer code, does not neccicarly mean slower code.

Yeah, it will move, im calling the method at case 1005, with the players facing as a direction. Oh well I might have missed / done something wrong, but as I said adjust it a little and it should work, and it is better than LOTF one. And no; I do NOT use LOTF, I used LOTF as a reference to show you the difference, to show people LOTF is actually **** coded. Anyone who planning on quitting LOTF, I respect and advice you to Hybrids source.

No, I do not expect thanks for this, as I said its a small release and only to show people.
_Emme_ is offline  
Old 02/05/2009, 06:23   #10
 
felipeboladao's Avatar
 
elite*gold: 0
Join Date: Jul 2007
Posts: 255
Received Thanks: 273
you have codes of Npc says of extremely Basic Source?
felipeboladao is offline  
Old 02/05/2009, 06:38   #11
 
unknownone's Avatar
 
elite*gold: 20
Join Date: Jun 2005
Posts: 1,013
Received Thanks: 381
The original LOTF one is fine. There's really no need to change it.

There are several reasons it performs better:
Switches can be optimised at compile-time, allowing a direct jump to the relevant case for known values, and a break will exit the selection altogether.
If statements however, all need to be executed each time. On top of that, you have calculations within your selection statmenets (logical OR) which creates additional instructions that must also be executed.

As inf said. Short code doesn't mean fast code.

You're also missing a vital calculation. That being, a mod 8. This is necessary because directions are random powers of 8 added onto the correct value.

And, final complaint: Your code isn't self descriptive. You'd need to comment if for some outsider to understand what it's doing. With previous one, it's obvious.

If you're going to change anything, the only improvement you could make on it would be an enum, which would make it even more readable, descriptive and maintainable

Code:
enum Direction : byte
{
    South, SouthWest, West, NorthWest, North, NorthEast, East, SouthEast,
};

case Direction.South:
    {
        AddY = 1;
        break;
    }
...etc.
unknownone is offline  
Old 02/05/2009, 12:14   #12
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
Thank you all for your view of this. Mark, if I would do something like that, I would probably do:
switch (Dir)
{
case Dir.South: y = 1; break;
case Dir.West: x = -1; y = -1; break;
etc..
}

Well just that I like small codes and I understand them more easily, well thanks I'll look into it.

I call the thread closed, no need for more opinions
_Emme_ is offline  
Old 02/05/2009, 21:44   #13
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
Quote:
Originally Posted by EmmeTheCoder View Post
Yeah, it will move, im calling the method at case 1005, with the players facing as a direction. Oh well I might have missed / done something wrong, but as I said adjust it a little and it should work, and it is better than LOTF one. no it's not, C# is *smart* enough to convert a case statement to an if-else statement believes the if-else will run faster than if it was ran in a case environment if it And no; I do NOT use LOTF, I used LOTF as a reference to show you the difference, to show people LOTF is actually **** coded. Anyone who planning on quitting LOTF, I respect and advice you to Hybrids source.

No, I do not expect thanks for this, as I said its a small release and only to show people.
that is if your compiling with "optimize my code" which everyone obviously needs to have on, lol.
InfamousNoone is offline  
Reply


Similar Threads Similar Threads
[RELEASE]Walk/Jump with ArrowKeys
08/13/2020 - EO Exploits, Hacks, Tools & Macros - 5 Replies
Its Cynic. Im releasing this bot which allows you to control your character from the arrow keys. There are 2 functions; walking and jumping. Running will be added very soon - this bot is for those who are lazy/wanting to test out arrow keys with this game. Enjoy this release. *Added v0.2 does the same just jumps instead of walk. *Added v0.2 with WASD keys. w-up s-down a-left d-right Remember to scan the files!
Release New Method of Wallhack Bypasser by sQuare02 [No Need ISO Method]
08/05/2010 - Soldier Front Philippines - 5 Replies
100% Working sa Window XP Wallhack pero FREE.. Nakuha ko lng to sa ka shop ko at eto yung gamit nya na wall... and it's 100% working in PSF... Ito ang ginagamit nmin ngayon sa cafe.. Eto nga pala yng Download Link.. sQuare02 Wallhack Bypasser.rar sQuare02 Wallhack Bypasser.rar sQuare02 Wallhack Bypasser.rar Eto rin yng Proof..
[DB-BOT]maybe method for looping with small monitor ;) i want u to test it ;p
05/07/2010 - SRO Private Server - 11 Replies
Try to do that: 1. open ur silkroad using dbBOT. 2. config for botting, record script etc. 3. exit ur silk. 4. download this small file: Download SROptionSet.dat from Sendspace.com - send big files the easy way 5. this file is form folder named Settings in ur silkroad folder. U should overwrite it using my SROptionSet.dat 6. open ur silkroad using dbBOT again. now u should have ur silkroad in resolution 1280x1024. I hope it works ;) try
A small method to earn money
05/02/2009 - Metin2 - 1 Replies
:)I am a Partisan warrior, the equipment is so bad when upgrading above 70 level. It is hard to combat with the high stone, and there will be no money, if you train skills with using skill book. But I find it is not bad that hit the small metin stone in village two. And when you train a 35 level Partisan warrior, you can use battle horse, and only add combat ecstasy and aura of sword into skill. You can attack two metin stone in one minute, and also can attack much more partisan warrior books...



All times are GMT +1. The time now is 23:29.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.