Graal Forums  

Go Back   Graal Forums > PlayerWorlds > Classic Main Forum
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 03-30-2001, 08:27 PM
grim_squeaker_x grim_squeaker_x is offline
Retired Oldbie
grim_squeaker_x's Avatar
Join Date: Mar 2001
Posts: 3,084
grim_squeaker_x will become famous soon enough
Heh.

It's actually a very small change to the script I made which made it walk in 4 ways :
NPC Code:
  for (i=0; i<4; i++) if (this.key[i]==true) {
playermoved = true;
this.dir = i;
newx = this.x + this.dirgo[i*2]*this.speed;
newy = this.y + this.dirgo[i*2+1]*this.speed;

// Check for walls
setarray wall,6;
for (j=0; j<6; j++)
wall[j] = onwall(newx+this.Cwalltest[i*12+j*2],
newy+this.Cwalltest[i*12+j*2+1]);

// Test for walls in front;
if (wall[0]==true || wall[1]==true || wall[2]==true || wall[3]==true) {

// Move the player outside of the wall
if (i==0) this.y = int(this.y);
else if (i==1) this.x = int(this.x+0.5)-0.5;
else if (i==2) {
if (this.y!=int(this.y)) this.y = int(this.y+1);
} else if (i==3) {
if (this.x+0.5!=int(this.x+0.5)) this.x = int(this.x+1.5)-0.5;
}

} else {
// Apply new position
this.x = newx;
this.y = newy;
}

// Test 'sidemoves'
if (wall[0]==true && wall[2]==false && wall[3]==false && wall[4]==false) {
this.x += this.sidemove[i*4];
this.y += this.sidemove[i*4+1];
} else if (wall[0]==false && wall[1]==false && wall[3]==true && wall[5]==false) {
this.x += this.sidemove[i*4+2];
this.y += this.sidemove[i*4+3];
}
i=4;
}



Note that I added an i=4 to the end of the thing to prevent diagonal movement.
__________________

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.