ID:143217
 
Code:
mob
Move()
var/sp=6-src.speed
sleep(sp) //Have also tried spawn here, neither work
..()


Problem description:
Supposedly, this should just slow the player down, which it does, but any time the player isnt moving in straight lines it causes the movement to jerk and bug out.
It's because of the spawn(). Make it sleep and that will fix it, I think.
That will not slow down anything. It will just impose a short delay before any movements (key here: any movements, including ones not initiated by a client).

Override client/Move() instead of mob/Move(). Declare mob/var/tmp/nextmovetime = 0. Ensure the world.time >= nextmovetime before moving. Then, set nextmovetime to world.time + 6-mob.speed.
In response to Kaiochao2536
No. Wrong. The two are effectively identical in this case (though spawn() will likely result in slightly more overhead).
In response to Kaiochao2536
Nah, sleep is what I tried first.
In response to Garthor
Oh yeah, right, maybe use a variable and if()s. Like "moving". Check if "moving" is false before moving. Change "moving" to 1 before the ..(), and to the sleep(), then change "moving" to 0.
In response to Garthor
Ah, muchas gracias.
That fixes it perfectly.
Your just telling it to sleep before initiating the movement. Your not telling it that it cant move again while its sleeping.

Try something more advanced like this:

mob/var/tmp/moving
mob/var/Speed=1 //Do not set this below 1.
mob/Move()
if(!moving)
moving=1
var/delay=100/Speed //(do not set this past 100, it serves no purpose, you just need to understand probability but Im guessing at your level you dont yet... But basically, probability is between 0% and 100%.
..()
if(prob(delay)) sleep(1)
if(prob(delay)) sleep(1)
if(prob(delay)) sleep(1) //3 lines gives you a depth between sleep(0) and sleep(3), you can add more lines to this to give you a slower movement rate, but sleep(3) is already pretty slow anything past sleep(5) would be kinda pointless.
moving=0

This will create levels of movement acuity and depth that are unreachable when using just sleep alone. Basically if you use the examples given below your ONLY options are full speed, sleep 2, or sleep 3, anything past that will be ridiculously slow. But if you use my system you can have much more levels of speed without as big of gaps in speed you have when just using sleep.

So if a mob's Speed is 1, that means they have 100% chance to have a delay each time they move. if their Speed is 2, they have a 50% chance for a delay. If speed is 3, its like 33% chance for delay. Speed=4 is 25% chance of delay. Speed=5 is 20% chance for delay. And you can do decimals too like 1.1, 1.5, 2.3, 3.9, 1.934523567, or whatever... So you see it gives you a lot more options.
In response to Dragonn
This is a pretty novel idea for movement delay, but... o_O Players would be speeding up and slowing down each step...
For fighting type games (at least) this would be highly undesireable as attack macros and movement macros would need a constant sort of timing.
In response to Dragonn
Pretty advanced movement thing, except I'm looking for consistent movement, and not movement based on probabilities.

Speaking of probabilities:
but Im guessing at your level you dont yet
At my level? Dude, I've been on BYOND longer than you have, and although I might not be the best at DM (never taken that long to really study it besides what I need it to do right then.)
This is the first time Ive had a code problem that needs posted in these forums, that wasnt because of a typo and that I wasnt shortly after able to figure out on my own, since 05.

Do me a favour, and do NOT pretend to know how intelligent I am. Everyone makes simple mistakes upon occasion. Especially when running nonstop for three days.
In response to Jamesburrow
Jamesburrow said:
but Im guessing at your level you dont yet
At my level? Dude, I've been on BYOND longer than you have,

Oh shut up. You think someone above your level cant easily gauge what your level is when they have already been there themselves?? Most people cant see past their own level, but people can easily see what level they have been at during other points of their lives, and I recognize your level as clearly as I recognize my own face. If any of the people beyond me still visited this forum they could clearly see MY level and YOUR level more easily than you could even comprehend. You obviously dont understand what the code I gave you even does, I can tell how basic your knowledge of it is just from the response you gave me, when you know code like I do it gets pretty annoying when an ignorant little prick starts talking about something without realizing at all the depth of the subject matter of which they speak. And now you turn on me for helping you? People like you are low-standard trash, if you talked to me like that in my physical proximity you would get your face caved in. Someone helps you then you stab them in the back, pathetic ungrateful piece of trash. No point saying any more on the internet though, I cant do anything to harm you here, and Im sure its going in one ear and out the other.

You may not realize you dont know what your talking about, but you dont know what your talking about. No point trying to convince you though because your too ignorant to understand where my point of view is even coming from. And you may say Im being arrogant, but I am just stating a fact, a fact you cant realize at your current level of coding experience. I have been where you are and I can tell what level your at, you may think thats bull but you would at your level, I have predicted all of it because I have already been there and know it very well. Now bye.
In response to Saucepan Man
No. Sorry to say but your wrong. The movement comes out fairly consistent. I -did- test this code thoroughly before posting it here, in fact I use a variation of this in most of my games so its time-tested. I can see someone as ignorant and unappreciative as James cant see the true effects that this code would actually have, he only sees a slight glimmer of the main effect it would cause to his movement without seeing at all the overall effect, which currently is beyond his comprehension and I would have to explain every little detail which I will not. Now surely he will think he sees the full effect, but there is still more that he wont see yet, he will think that is bull but once again that is because his experience is at a level I can predict very easily, because I have already been there. Most people wont understand what Im talking about but thats because they dont consider for a second that their view might be coming from their inexperience, sure, they might -think- they are experienced, and considering coders as a whole they may be, but there is always someone more experienced with a more evolved view on the effects that certain code will have. And like I read somewhere once: "Its easy to tell when someone is beneath you, but it can be sometimes hard to tell when someone is above you.", now he may also dispute the second half of that quote, but once again the truth of that quote only comes at a higher level of experience than he currently has, and as I said his level of experience is something I understand very well already because I have been there. And I can easily tell James' experience is beneath mine in this occasion while quite clearly he cannot tell that my experience exceeds his, which I stated in that quote above, although he will again dispute this but that is only because at his level he only sees this statement as arrogance and not for what it truly is, and the truth of something like this can only be seen a few levels beyond where he is. I have only met 2 other people on byond who will understand this, and the ones beyond my level who used to speak on the dev forums do not even communicate on here anymore. They have left altogether to do more important things, BUT if they -were- here they would atleast tell you something similar to what I have just told you, or something more advanced altogether. Just a lesson for him before he goes running his mouth after someone tries to help him, although I can already tell he will dispute what I have just said but eventually, maybe years later, he will eventually gain something from it. And again, he will dispute that he will not take anything from it because what I have just said is pointless, but once again, I have predicted this, and can also predict that at some point he will change his mind even though he doesnt realize it yet.
In response to Dragonn
Dude. Probability has to do with math. I am currently in AP Calculus, AP Physics, and AP Statistics.
I am part of the Mathletes team and I have won every single competition I have been in.

Now, as for programming, I also take programming classes at school and my current grade is a 109 because not only am I able to breeze past anything we do in that class, but I also go above and beyond what is required.

I might not be perfect with the DM language just because I really have not put that much effort into it, but you can NOT use that to say I am at a level below you, and that by being at a level below you I do not understand simple probability and statistics.
You have seen one little scrap of code, a scrap put together at midnight and was only a half-hearted attempt to put a system together for a friend.

I have worked too hard and too long to get where I am today - SECOND in my class with a full-ride scholarship waiting for me after I graduate - to let any thinks-he-knows-more idiot condescend to me because he thinks he knows what I want to do with my code. If I had wanted to use probability, I would have, but I didn't want to use probability, so I didn't.
Now, if you would have taken the time to read through this thread rather than bull-heading your way through thinking you know what I want to do with my code, you would have realized this problem has already been solved.


Now, I know there are coders above me, and you may very well be one of them, but do not assume that just because you see what you think is a better way of doing things that I must be way below your level for not seeing it.


And yes, your code will come out fairly consistent (sometimes), but your code does not do things the way I want them to be done.
If you really are above him, act appropriately. Telling him you are superior to him? You might as well ask him to brush your shoes and kiss your hand.
In response to Dragonn
Stop spreading this stupid thing. You do not need to use prob() to slow down movement, for any reason. I'll post this again, a good system for giving finer control over movement speed:

mob
//time at which this mob may next move
var/tmp/nextmove = 0
//leftover move delay, in ticks
var/tmp/movefraction = 0
//delay (in ticks) between each move
var/movedelay = 2.5 //4 moves per second
proc
//sets a mob's move speed (in moves per second)
setMoveSpeed(var/N)
movedelay = 10/N

verb
setMoveVerb(var/N as num)
set name = "set move speed"
set desc = "set your move speed in moves per second"
setMoveSpeed(N)

client
Move()
//block premature attempts to move
if(world.time < mob.nextmove) return 0
//move the mob
.=..()
//calculate our delay for this movement
var/delay = round(mob.movedelay)
if(mob.movefraction >= 1)
mob.movefraction--
delay++
//add the fractional component of movedelay to movefraction
mob.movefraction += mob.movedelay - round(mob.movedelay)
//set nextmove
mob.nextmove = world.time + delay


Now, you talked a whole lot about being "so good" and Jamesburrow being "so bad" he "couldn't even see" how good you were... that's just crap. From where I'm standing, you're just a little brat who thinks he understands things, but really doesn't. Looking through your previous posts, I would put you somewhere between a newbie and somebody who has the experience necessary to make their first real game. That's nowhere for somebody acting all high-and-mighty to be.

So, in short: cram it until you get a clue, yourself.
In response to Dragonn
Wow. You've got a pretty ugly attitude you know? And a really big ego as well!

Anyway. Your code WOULD make movement speed rather inconsistent.
With your code suppose you set speed to 2 there would be a 12.5% chance of there being no movement delay, a 12.5% chance of there being a 0.3s delay, and a 37.5% chance of there being either a 0.1s or 0.2s delay.
If you ask me that is pretty silly, and much to inconsistent for a decent movement delay. There are better, easier and a lot more consistent methods out there, and you don't need to be level 50 million or whatever to realize that.

Anyway. I am curious. You keep claiming that no one understands your code and that people lack the experience and insight to even understand it. And you posted a block of text just to say that same thing over and over again as if it some how makes everything you say correct.
Yet you never explained your code, nor do you even try to make any attempt at doing so.
Not only that, but you like talking about yourself and this "level" of yours a lot! You constantly talk about it and how much higher it is than everyone elses, but that is all you do. You give no explanation as to why it is higher, nor do you prove it in any way at all.
The only thing you have to your name is a Dragonball Z game, which looks and feels like every other DBZ game I have ever played, and is nothing special at all. Not only that, but after maybe 10 minutes into the game I'd run into several bugs, one of which made playing the game impossible and required a restart of the game and a new character. Despite being stupidly obvious. (But don't feel too bad. I am pretty awesome at finding and abusing bugs in more or less any game I do play, haha. It is like my special talent)
Anyway, you really do have a horrible attitude and ego. And maybe from now on you should stop trying to use "I AM RIGHT, YOU ARE WRONG" with every one of your posts and you know... Actually back up what you are saying with some sort of proof. Because to be honest, you're annoying, and I doubt anyone here takes you seriously at all.
In response to DivineO'peanut
Erm <_< I will assume you placed that reply wrong and was actually replying to Dragonn <_<
In response to Dragonn
Posts of this nature have absolutely no place on these forums. Continuation of said form of post (flamebait, personal attacks, etc) will result in a longer ban being applied.

Alathon
In response to Dragonn
Dragonn wrote:
No. Sorry to say but your wrong. The movement comes out fairly consistent. I -did- test this code thoroughly before posting it here, in fact I use a variation of this in most of my games so its time-tested.

Then you would know how incredibly stupid your approach is. No one is going to want all of that jumpy movement your procedure is likely to cause, not to mention the small, but still more overhead the inefficiency of your procedure causes.

I can see someone as ignorant and unappreciative as James cant see the true effects that this code would actually have, he only sees a slight glimmer of the main effect it would cause to his movement without seeing at all the overall effect, which currently is beyond his comprehension and I would have to explain every little detail which I will not.

Because... you can't? Too complicated for you, hmm?

Now surely he will think he sees the full effect, but there is still more that he wont see yet, he will think that is bull but once again that is because his experience is at a level I can predict very easily, because I have already been there. Most people wont understand what Im talking about but thats because they dont consider for a second that their view might be coming from their inexperience, sure, they might -think- they are experienced, and considering coders as a whole they may be, but there is always someone more experienced with a more evolved view on the effects that certain code will have.

Try redundancy--and reread this paragraph. Notice how little logical sense it makes?


I have only met 2 other people on byond who will understand this, and the ones beyond my level who used to speak on the dev forums do not even communicate on here anymore. They have left altogether to do more important things, BUT if they -were- here they would atleast tell you something similar to what I have just told you, or something more advanced altogether.

Then you hang around with a bunch of inexperienced programmers. Have you noticed how primitive and inconsistent your code was? Hmm?

I think you should get some English lessons so that the next set of long rants of text you make are comprehendable, less redundant, and actually make sense. I also think you should consider counseling, because you seem to be quite angry for really no reason. Your judgement also seems to be impaired, but that could be from your "lack of experience."

There is no reason to be insulting this guy. James did reject your work, but he did it in a polite manner. From what I've seen, it doesn't seem like you understand his point or where he was coming from because if you did, you'd see that these arguments you've been posting make little impact or sense against what James said. Of course, you could have misinterpreted your own code (and you must have--seeing as how what everyone said about it's inconsistency was very correct and true, yet you argued otherwise) and now you just look like a fool.

Be nice.

PS: Jamesburrow is a better programmer than you.
In response to Garthor
Interesting approach. I wish I'd come up with that. :O