|
somebody to love
|
Join Date: Jun 2001
Location: bat country.
Posts: 3,446
|
|
*blinks* You ripped that from the New World bunnies. You didn't even take the time to change the setgifparts to fit this guys squirrel.gif image correctly...
Quote:
Originally posted by IcePick_2001
NPC Code:
timereverywhere;
if (created){
// Sets a few values
// this.csquirrelalive=1 means the squirrel is "alive" and free to move
// this.csquirrelalive=0 means it's dead
// this.csquirrelspeed the squirrel's speed (*this.cincreasespeed when running from player)
// this.ccloseness is how close the player gets before the player runs
this.csquirrelalive=1;
this.ncurdist=64;
this.csquirrelspeed=.6;
this.ccloseness=10;
this.cincreasespeed=1.5;
setgifpart squirrel.gif,0,0,22,23;
timeout=.05;
hearts=1;
}
if (timeout){
if (this.csquirrelalive==1){
// Basic tile check is below.
iputx = int(x/2)*2;
iputy = int(y/2)*2;
for (i=0; i<2; i++) for (j=0; j<2; j++) {
ib = board[iputx+i+64*(iputy+j)];
ibx = ib % 16;
iby = int(ib / 16);
}
// Checks to see of all the players on, which is closest.
this.ncurdist=64;
for (ipindex=0;ipindex<playerscount;ipindex++){
if (players[ipindex].id>=0){
this.nnewdist=((players[ipindex].x-x)^2+(players[ipindex].y-y)^2)^.5;
// If the newly tested distance is less than the old distance, then make it the current distance
if (this.nnewdist<=this.ncurdist){
this.ncurdist=this.nnewdist;
this.iplayer=ipindex;
}
}
}
// Tells what to do when the closest player is less than 10 spaces away
if (this.iplayer==0){
if (this.ncurdist<=this.ccloseness){
// When this.count reaches 5 it does the following to determine which random direction the squirrel will run.
if (this.icount>=5){
this.icount=0;
this.nxdist=abs(players[this.player].x-x);
this.nydist=abs(players[this.player].y-y);
// Based on the x and y distance from the player, only 3 directions may be selected.
if (this.nxdist>this.nydist){
if (players[this.iplayer].x<x){
this.itemp=(int(random(1,4)));
if (this.itemp==1) this.cdir=0;
if (this.itemp==2) this.cdir=2;
if (this.itemp==3) this.cdir=3;
}
if (players[this.iplayer].x>x){
this.itemp=(int(random(1,4)));
if (this.itemp==1) this.cdir=0;
if (this.itemp==2) this.cdir=1;
if (this.itemp==3) this.cdir=2;
}
}
if (this.nxdist<this.nydist){
if (players[this.iplayer].y<y){
this.itemp=(int(random(1,4)));
if (this.itemp==1) this.cdir=1;
if (this.itemp==2) this.cdir=2;
if (this.itemp==3) this.cdir=3;
}
if (players[this.iplayer].y>y){
this.itemp=(int(random(1,4)));
if (this.itemp==1) this.cdir=0;
if (this.itemp==2) this.cdir=1;
if (this.itemp==3) this.cdir=3;
}
}
}
this.icount++;
// Different things to do if the squirrel is under bramble.
if ((ibx==5&&iby==48)||(ibx==5&&iby==49)||(ibx==6&&ib y==48)||(ibx==6&&iby==49)){
setgifpart squirrel.gif,94,0,32,14;
if (this.cdir==0&&!onwall(x,y-(this.csquirrelspeed*this.cincreasespeed))&&!onwat er(x,y-(this.csquirrelspeed*this.cincreasespeed))) y-=this.csquirrelspeed*this.cincreasespeed;
if (this.cdir==1&&!onwall(x-(this.csquirrelspeed*this.cincreasespeed),y)&&!onw ater(x-(this.csquirrelspeed*this.cincreasespeed),y)) x-=this.csquirrelspeed*this.cincreasespeed;
if (this.cdir==2&&!onwall(x,y+(this.csquirrelspeed*th is.cincreasespeed))&&!onwater(x,y+(this.csquirrels peed*this.cincreasespeed))) y+=this.csquirrelspeed*this.cincreasespeed;
if (this.cdir==3&&!onwall(x+(this.csquirrelspeed*this .cincreasespeed),y)&&!onwater(x+(this.csquirrelspe ed*this.cincreasespeed),y)) x+=this.csquirrelspeed*this.cincreasespeed;
if (this.cdir==0&&y-5<=5) this.cdir=2;
if (this.cdir==1&&x-5<=5) this.cdir=3;
if (this.cdir==2&&y+5>=59) this.cdir=0;
if (this.cdir==3&&x+5>=59) this.cdir=1;
sleep .05;
setgifpart squirrel.gif,94,29,32,16;
}else{
// Tells where to move, and what image to show based on direction.
if (this.cdir==0){
setgifpart squirrel.gif,72,27,22,19;
if (!onwall(x,y-(this.csquirrelspeed*this.cincreasespeed))&&!onwat er(x,y-(this.csquirrelspeed*this.cincreasespeed))){
y-=this.csquirrelspeed*this.cincreasespeed;
} else {
this.icount=10;
}
sleep .05;
setgifpart squirrel.gif,72,0,22,23;
}
if (this.cdir==1){
setgifpart squirrel.gif,22,23,25,23;
if (!onwall(x-(this.csquirrelspeed*this.cincreasespeed),y)&&!onw ater(x-(this.csquirrelspeed*this.cincreasespeed),y)){
x-=this.csquirrelspeed*this.cincreasespeed;
} else {
this.icount=10;
}
sleep .05;
setgifpart squirrel.gif,21,0,24,23;
}
if (this.cdir==2){
setgifpart squirrel.gif,0,24,22,22;
if (!onwall(x,y+(this.csquirrelspeed*this.cincreasesp eed)+1)&&!onwater(x,y+(this.csquirrelspeed*this.ci ncreasespeed)+1)){
y+=this.csquirrelspeed*this.cincreasespeed;
} else {
this.icount=10;
}
sleep .05;
setgifpart squirrel.gif,0,0,22,23;
}
if (this.cdir==3){
setgifpart squirrel.gif,47,23,25,23;
if (!onwall(x+(this.csquirrelspeed*this.cincreasespee d)+1,y)&&!onwater(x+(this.csquirrelspeed*this.cinc reasespeed)+1,y)){
x+=this.csquirrelspeed*this.cincreasespeed;
} else {
this.icount=10;
}
sleep .05;
setgifpart squirrel.gif,47,0,24,23;
}
if (this.cdir==0&&y-5<=5) this.cdir=2;
if (this.cdir==1&&x-5<=5) this.cdir=3;
if (this.cdir==2&&y+5>=59) this.cdir=0;
if (this.cdir==3&&x+5>=59) this.cdir=1;
}
}else{
// What to do when the player is farther than 10 spaces.
this.icount=10;
// Sets the squirrel's "mode" every .5 seconds (1=moving)
if (this.icount2==5){
this.imode=(int(random(1,3)));
this.cdir=(int(random(0,4)));
this.icount2=0;
}
// When the squirrel is supposed to move, here's what to do.
if (this.imode==1){
// What to do when the squirrel is under bramble.
if ((ibx==5&&iby==48)||(ibx==5&&iby==49)||(ibx==6&&ib y==48)||(ibx==6&&iby==49)){
setgifpart squirrel.gif,94,0,32,14;
if (this.cdir==0&&!onwall(x,y-this.csquirrelspeed)&&!onwater(x,y-this.csquirrelspeed)) y-=this.csquirrelspeed;
if (this.cdir==1&&!onwall(x-this.csquirrelspeed,y)&&!onwater(x-this.csquirrelspeed,y)) x-=this.csquirrelspeed;
if (this.cdir==2&&!onwall(x,y+this.csquirrelspeed)&&! onwater(x,y+this.csquirrelspeed)) y+=this.csquirrelspeed;
if (this.cdir==3&&!onwall(x+this.csquirrelspeed,y)&&! onwater(x+this.csquirrelspeed,y)) x+=this.csquirrelspeed;
if (this.cdir==0&&y-5<=5) this.cdir=2;
if (this.cdir==1&&x-5<=5) this.cdir=3;
if (this.cdir==2&&y+5>=59) this.cdir=0;
if (this.cdir==3&&x+5>=59) this.cdir=1;
sleep .05;
setgifpart squirrel.gif,94,29,32,16;
}else{
// Tells where to move, and what image to show based on direction.
if (this.cdir==0){
setgifpart squirrel.gif,72,27,22,19;
if (!onwall(x,y-this.csquirrelspeed)&&!onwater(x,y-this.csquirrelspeed)){
y-=this.csquirrelspeed;
}else{
this.cdir=(int(random(0,4)));
}
sleep .05;
setgifpart squirrel.gif,72,0,22,23;
}
if (this.cdir==1){
setgifpart squirrel.gif,22,23,25,23;
if (!onwall(x-this.csquirrelspeed,y)&&!onwater(x-this.csquirrelspeed,y)){
x-=this.csquirrelspeed;
}else{
this.cdir=(int(random(0,4)));
}
sleep .05;
setgifpart squirrel.gif,21,0,24,23;
}
if (this.cdir==2){
setgifpart squirrel.gif,0,24,22,22;
if (!onwall(x,y+this.csquirrelspeed+1)&&!onwater(x,y+ this.csquirrelspeed+1)){
y+=this.csquirrelspeed;
}else{
this.cdir=(int(random(0,4)));
}
sleep .05;
setgifpart squirrel.gif,0,0,22,23;
}
if (this.cdir==3){
setgifpart squirrel.gif,47,23,25,23;
if (!onwall(x+this.csquirrelpeed+1,y)&&!onwater(x+thi s.csquirrelspeed+1,y)){
x+=this.csquirrelspeed;
}else{
this.cdir=(int(random(0,4)));
}
sleep .05;
setgifpart squirrel.gif,47,0,24,23;
}
if (this.cdir==0&&y-5<=5) this.cdir=2;
if (this.cdir==1&&x-5<=5) this.cdir=3;
if (this.cdir==2&&y+5>=59) this.cdir=0;
if (this.cdir==3&&x+5>=59) this.cdir=1;
}
}
this.icount2++;
}
}
}
timeout=.05;
}
// How to kill the squirrel.
if (washit || wasshot || waspelt){
hearts--;
setgifpart squirrel.gif,130,0,27,21;
timeout=.05;
this.csquirrelalive=0;
timeout=.10;
this.csquirrelalive=1;
}
|
|
__________________
the sky is falling
|
Last edited by SkooL; 08-01-2001 at 08:45 AM..
|