Since months i trying to make a Sprint script but ... :(

Can someone send me a working “Sprint” script to move faster whitout walking on walls like
(playerx =playerx+1) or something. I just want have a script which allows you to move faster.

Just take staff boot script and add an onwall check to it.

if (timeout || playerenters){
  if (keydown2(65,true)){//only try to sprint if we're holding down a
  for (i = 0; i < 4; i++){
      if (keydown(i)){
        if (!onwall(playerx + 1.5 + vecx(i)*2,playery + 2 + vecy(i)*2)){
          playerx += vecx(i)*speed;
          playery += vecy(i)*speed;
        }
      }
    }
  }
  timeout = 0.05;
}

Do note, this will check only one tile! I didn’t want to take away all the fun for you. So you can work out how you’ll do that.
I’d highly recommend looking at commands.rtf if you don’t understand any of the code I wrote.

You forgot to give a value to speed. Unless that was the test and I just did it for him.

The original intent was to write out partial pseudocode for him but it progressed a bit further than that.

Oh ok thanks.
Can you explain me the vecx/y?
And would this script work?
If ( keypressed blabla… onwall ){
playerx=-thespeed
playery=-thespeed
}

___Merged doublepost__________________

I did my best but it dont works… can you send me the fullscript whit boots?

Go look in the script showcase.

You won’t learn if people spoon-feed you.

For more alternate explanations, you can refer to this thread. http://forums.graalonline.com/forums/showthread.php?p=1649547

Also, if we gave you the entire working script, you’d have learnt nothing.
Go look for a staff boot script, see how that works and see what I changed. If you understand what each command does, you should have no problem building a similar script like this in the future.
But to progress you’ll need to help yourself, commands.rtf is your bible, use it.

You are a really good teahcer ;0…
But I don’t know many commands of this script you wrote.
I try to understand it but I can’t. I never used this vec. I don’t even know how or why to use it…

if (timeout || playerenters){ if (keydown2(65,true)){//only try to sprint if we're holding down a for (i = 0; i < 4; i++){ <- Dont understanding this too if (keydown(i)){ // if player clicks key i if (!onwall(playerx + 1.5 + vecx(i)*2,playery + 2 + vecy(i)*2)){ // maybe if player is not on wall and playerx +1.5 playerx += vecx(i)*speed; // then playerx let you move *speed more tiles playery += vecy(i)*speed;// then playery let you move *speed more tiles } } } } timeout = 5; }

Here’s the code people like you use since they don’t understand how to use vecx and vecy

if (playerenters || timeout){//if the player enters, or a timeout is triggered
  if (keydown(0)){
    playery -= 1;
  }
  else if (keydown(1)){
    playerx -= 1;
  }
  else if (keydown(2)){
    playery += 1;
  } 
  else if (keydown(3)){
    playerx += 1;
  }
  timeout = 0.05;//trigger a timeout after 0.05 seconds
}

Which can be compacted into

if (playerenters || timeout){
  for (i = 0; i < 4; i++){//count from numbers 0 to 3
    if (keydown(i)){
      playerx += vecx(i);
      playery += vecy(i);
    }
  }
  timeout = 0.05;
}

You now have more than enough information and examples to understand vecx and vecy. If you still can’t work it out, perhaps you’re doing things beyond your scope and should try more basic things first.

Because I’d really like to see more scripters succeed in this community I’ll give you one last example.

if (playerenters){
  showcharacter;
  setcharani walk,;
  this.speed = 0.4;
  timeout = 0.05;
}

if (timeout){
  if (this.timer <= 0){
    this.timer = 2;
    dir = (dir + 1)%4;
    message dir:#v(dir),vecx = #v(vecx(dir)), vecy = #v(vecy(dir));
  }
  else {
    this.timer -= 0.05;
  }

  x += vecx(dir)*this.speed;
  y += vecy(dir)*this.speed;

  timeout = 0.05;
}

Put that npc into a level, you’ll see that he’ll walk in a square pattern. This is to show you how the numbers correspond to the player and it’s an easier way to connect the two hopefully.

Also, I will not be replying to this thread from now on unless I can see you’re evidently trying.

vecx(dir) vecy(dir)

vecx and vecy will always return -1, 0, or 1. vecx looks at the x axis; vecy the y axis.

If dir = 0 (facing up), vecx will be 0 because up/down is the y axis. To understand the 1 and -1 think of a grid. Above and to the right of the origin is positive; below and left is negative. So, since the direction is 0 (up) vecy will be 1.

Can play with this line:

message (#v(playerx),#v(playery)), dir:#v(playerdir), vecx:#v(vecx(playerdir)), vecy:#v(vecy(playerdir));