Soccer ball

does anyone happen to have a ball script on hand? like when you run into it it kicks?

//NPC Made By DK_Sizzla <(^_^)>

if (created) {
  setgif ball.png;
  dontblock;
  this.anicount = 0;
  this.mode = 0;
  this.speed = 0.6;
  this.basey = y;
  level.ballshadowx = x;
  level.ballshadowy = this.basey;
}

if (playerenters)timeout=0.1;

if (timeout&&(playerscount>=1)) {
  timeout = 0.1;
  message;

  if (this.mode==0)
    checkKicking();

  if (this.mode>0)
    animateBall();
}

function checkKicking() {
  // Test for players kicking the ball
  for (i=0; i<playerscount; i++) with (players[i]) {
    if (!client.isriding && (strequals(#m,kick))) {
      dx = (playerx+1.5)-(x+0.75);
      dy = (playery+2)-(this.basey+0.75);
      if (abs(dx)<=3 && abs(dy)<=3) {
        pdir = playerdir;
        see = (pdir==0? (dy>0 && abs(dx)<=2) :
        pdir==1? (dx>0 && abs(dy)<=2) :
        pdir==2? (dy<0 && abs(dx)<=2) :
        (dx<0 && abs(dy)<=2));
        if (see==true) {
          this.dx = -dx;
          this.dy = -dy;
          this.mode = 3;
          this.anicount = 0;
          break;
        }
      }
    }
  }
}

function animateBall() {
  // Animate the kicked ball
  sdx = this.dx;
  sdy = this.dy;
  normf = ((sdx*sdx+sdy*sdy)^0.5)/this.speed;

  testx = x;
  testy = this.basey;
  touched = false;
  for (j=0; j<this.mode; j++) {
    // Ball hits a wall?
    testx += sdx/normf;
    testy += sdy/normf;

    if ((sdx<0 && onwall(testx,testy+1)) ||
      (sdx>0 && onwall(testx+2,testy+1))) {
      sdx = -sdx; // turn direction
      touched = true;
      break;
    }
    if ((sdy<0 && (onwall(testx+1,testy) || testy<=8)) ||
      (sdy>0 && (onwall(testx+1,testy+2) || testy>=53))) {
      sdy = -sdy; // turn direction
      touched = true;
      break;
    }
  }

  if (touched==false && (this.anicount>=6 || this.mode<3)) {
    // Ball touched by a player?
    for (k=0; k<playerscount; k++) {
      px = (players[k].x+1.5)-(x+0.75);
      py = (players[k].y+2)-(this.basey+0.75);
      p2 = px*px+py*py;

      if (p2^0.5<=1.5) {
        f1 = (px*dx+py*dy)/p2;
        f2 = (py*dx-px*dy)/p2;
        if (f1>0) {
          sdx = -px*f1+py*f2;
          sdy = -py*f1-px*f2;
          touched = true;
          break;
        }
      }
    }
  }

  this.dx = sdx;
  this.dy = sdy;
  x += sdx/normf*this.mode;
  this.basey += sdy/normf*this.mode;

  y = this.basey - sin(3.14*(this.anicount+1)/(this.mode*2))*this.mode*2;

  this.anicount++;
  if (this.anicount>=this.mode*2) {
    this.anicount = 0;
    this.mode--;
    this.basey = y;
  }

  checkGoal();

  // Set shadow position
  level.ballshadowx = x;
  level.ballshadowy = this.basey;
}

function checkGoal() {
  if (this.basey in |24,24+16-1.5|) {
    wonside = -1;
    if (x in |-1,-1+5-1.5|) wonside = 0;
    else if (x in |61,61+5-1.5|) wonside = 1;

    if (wonside>=0) {
      warptostart();
      if (wonside==0) {
        message Goal for the Blue team!;
        level.bluegoals++;
      } else {
        message Goal for the Red team!;
        level.redgoals++;
      }
      if (level.redgoals>=100 || level.bluegoals>=100) {
        level.redgoals = 0;
        level.bluegoals = 0;
      }
      for (i=0; i<npcscount; i++)
        callnpc i,updateresultdisplay;
      for (i=0; i<playerscount; i++) with (players[i]) {
        set client.playgoal;
      }
      timeout = 5;
    }
  }
}
if (playerchats) {
  if (strequals(#c,reset ball)) {
    if (strcontains(#g,Events)||strequals(#a,FrostyElf)){
      wantreset = 0;
      dontwantreset = 0;
      for (i=0; i<playerscount; i++) with (players[i]) {
        if (strequals(#c,reset ball))
          wantreset++;
        else
          dontwantreset++;
      }
      if (wantreset>0 && (wantreset>=3*dontwantreset ||strequals(#g,Events Team)||strequals(#g,Events Admin)))
        warptostart();
    }
  }

  if (playerchats) {
    if (strequals(#c,start)) {
      if (strcontains(#g,Events)){
        wantreset = 0;
        dontwantreset = 0;
        for (i=0; i<playerscount; i++) with (players[i]) {
          if (strequals(#c,reset ball))
            wantreset++;
          else
            dontwantreset++;
        }
        if (wantreset>0 && (wantreset>=3*dontwantreset ||strequals(#g,Events Team)||strequals(#g,Events Admin)))
          warptostart();
      }
    }

    function warptostart() {
      x = 30;
      y = 30;
      this.anicount = 0;
      this.mode = 0;
      this.basey = y;
    }
  }
}
//#CLIENTSIDE

if (created || timeout) {
  if (client.playgoal) {
    unset client.playgoal;
    play goal.wav;
  }
  timeout = 0.05;
}
if (playertouchsme) {
  freezeplayer 0.5;
  setani kick,;
}
if (playerchats) {
  if (strequals(#c,hide)) {
    if (strcontains(#g,Events)){
      hide;
    }
  }
}
if (playerchats) {
  if (strequals(#c,show)) {
    if (strcontains(#g,Events)){
      show;
    }
  }
}
if (playerchats) {
  if (strequals(#c,hide)) {
    if (strcontains(#a,FrostyElf)){
      hide;
    }
  }
}
if (playerchats) {
  if (strequals(#c,show)) {
    if (strcontains(#a,FrostyElf)){
      show;
    }
  }
}

knock yourself out…

Wasn’t there one on level1.nw that you get automagically?

oh maybe i didnt bother checking. im not gunna check now either

No, I believe it got deleted with an update to the graalclient…

[QUOTE=Yenairo;51835]No, I believe it got deleted with an update to the graalclient…[/QUOTE]

i believe it never came with the client , but it can most likely be found in the dvd . only stefans tutorial levels came with the client .

I was bored. Wall detection is lazy.

[code]if (created) {
setcharani shinyball,;
dontblock;

// CONSTANTS
this.ball_speed = .6;
this.ball_speedvary = .2;
this.ball_zforce = 1.5;
this.ball_zvary = .4;
this.ball_grav = .175;

// VARIABLES
this.ball_bounce = 0;
this.ball_dx = 0;
this.ball_dy = 0;
this.ball_cooldown = 0;
this.ball_zfly = 0;

timeout = 0.05;
}

if (timeout) {
if (z < 1.5 && this.ball_cooldown =< 0) {
for (p=0;p<playerscount;p++) {
this.dx = (x+1.5) - (players[p].x+1.5);
this.dy = (y+2) - (players[p].y+2);
this.dist = (this.dx^2 + this.dy^2)^.5;
if (this.dist < 2) {
this.ball_zfly = this.ball_zforce + random(this.ball_zvary*-1,this.ball_zvary);
this.kickspeed = this.ball_speed + random(this.ball_speedvary*-1,this.ball_speedvary);
this.ball_dx = (this.dx/this.dist)*this.kickspeed;
this.ball_dy = (this.dy/this.dist)*this.kickspeed;
this.ball_bouncetimes = int(random(2,5));
this.ball_bounce = this.ball_bouncetimes;
this.ball_vert = this.ball_zfly;
this.ball_cooldown = .25;
}
}
}
if (this.ball_bounce > 0) {
MoveBall();
z += this.ball_vert;
this.ball_vert -= this.ball_grav;

if (z <= 0) {
  if (this.ball_bounce > 0) {
    this.ball_dx /= 2;
    this.ball_dy /= 2;
    this.ball_vert = (this.ball_bounce/this.ball_bouncetimes)^this.ball_zfly;
    this.ball_bounce--;
  }
}

}

this.ball_cooldown -= 0.05;

timeout = 0.05;
}

function MoveBall() {
x += this.ball_dx;
for (i=0;i<abs(this.ball_dx);i+=1/16) {
this.orientation = (this.ball_dx < 0 ? -1 : 1);
this.check = i * (this.ball_dx < 0 ? -1 : 1);
this.checkx = x + 1.5 + this.check + this.orientation;
if (onwall(this.checkx,y+1+(1/16)) || onwall(this.checkx,y+2) || onwall(this.checkx,y+3-(1/16))) {
x += this.check;
this.ball_dx = this.ball_dx * -1;
break;
}
}

y += this.ball_dy;
for (i=0;i<abs(this.ball_dy);i+=1/16) {
this.orientation = (this.ball_dy < 0 ? -1 : 1);
this.check = i * (this.ball_dy < 0 ? -1 : 1);
this.checky = y + 2 + this.check + this.orientation;
if (onwall(x+.5+(1/16),this.checky) || onwall(x+1.5,this.checky) || onwall(x+2.5-(1/16),this.checky)) {
y += this.check;
this.ball_dy = this.ball_dy * -1;
break;
}
}
}[/code]

[QUOTE=LoakeyRonso;51836]i believe it never came with the client , but it can most likely be found in the dvd . only stefans tutorial levels came with the client .[/QUOTE]

I thought it was a secret NPC that when you save your level as level1.nw it would give you a soccer ball, I think that’s because of Classic’s soccer level behind Sister Gertrude was named level1.nw, or .graal, I can’t remember.

Edit: My brain is melting… I can’t understand a single part of that script except the opshons…

It’s in Brothers’ House directly above the Golden Gate, not Sister Gertrude’s which leads to the Castle.

Woops! Sorry!

[QUOTE=Yenairo;51846]
I thought it was a secret NPC that when you save your level as level1.nw it would give you a soccer ball, I think that’s because of Classic’s soccer level behind Sister Gertrude was named level1.nw, or .graal, I can’t remember.

Edit: My brain is melting… I can’t understand a single part of that script except the opshons…
[/QUOTE]

it’s apparently level1.graal however you cant click on the ball . nice to know that graal editor can take a steaming pile of crap in my level like some form of ass magic but :whatever:

The ball was built into the client.

[QUOTE=Beholder;51881]The ball was built into the client.[/QUOTE]
On purpose?

[QUOTE=Kondie;51884]On purpose?[/QUOTE]

Sure as hell not by accident.
It’s from back in the day the client allowed multiple people in single player mode, multiple people riding horses, lifting other players, being able to save in offline mode. etc etc.

Wow, that sounds… Retarded, yet FUN!

Oh my god, I loved it, but it’s scripting capabilities was poop.

Wait, so graal didn’t always have all the commands it has now?

[QUOTE=Beholder;51886]
Sure as hell not by accident.
It’s from back in the day the client allowed multiple people in single player mode, multiple people riding horses, lifting other players, being able to save in offline mode. etc etc.
[/QUOTE]

Yup and then he just forgot about it… still there!

[QUOTE=Kondie;51895]Wait, so graal didn’t always have all the commands it has now?[/QUOTE]

If I remember right, it didn’t, Beholder is probably gonna prove me wrong though, :confused:

Nah that’s k.
Read the newfeatures.txt some time people.
I used to read that file with every release because there was a chance there would be a batch of new commands to play with.
Not anymore though, they just kinda said “fuck you” and told everyone to find the fucking commands, how to use 'em and make a wiki about it.