View Single Post
  #5  
Old 08-07-2001, 09:15 AM
LilNiglet LilNiglet is offline
Registered User
Join Date: Jun 2001
Posts: 3,178
LilNiglet is on a distinguished road
Quote:
Originally posted by LiquidIce00
POST UPDATE
engine ..
NPC Code:

//the engine part
function move() {
disabledefmovement; //disable movement
for (this.i=0;this.i<this.SpacesToMove;this.i=this.i+t his.PlayerSpeed) { //loop
playerdir=this.PlayerDirection; //set direction of player
setplayerprop #c,#s(playermsg); //display message
playery+=vecy(this.PlayerDirection)*this.PlayerSpe ed; //move y
playerx+=vecx(this.PlayerDirection)*this.PlayerSpe ed; //move x
setani walk,; //set animation to walk
sleep .05; // sleep
}
enabledefmovement; //re-enable movement
setani idle,; //idle player animation
}


thats the engine.. to use it u just call it .. ill show u an example

NPC Code:

if (playerenters) {
this.SpacesToMove=5; //how many steps?
this.PlayerSpeed=.5; //Speed
this.PlayerDirection=2; //Direction 0=up, 1=left, 2=down, 3=right
setstring playermsg,Message; //Message for player to say
move(); //call function
}



but if you want the player to go a direction then go another direction and so on you just do
NPC Code:

if (playerenters) {
this.PlayerSpeed=.5;
//first walking part
this.SpacesToMove=5;
this.PlayerDirection=2;
setstring playermsg,First Part;
move();
//second walking part
this.SpacesToMove=10;
this.PlayerDirection=0;
setstring playermsg,Second Part;
move();
//third walking part
this.PlayerSpeed=1;
this.SpacesToMove=10;
this.PlayerDirection=3;
setstring playermsg,Third Part;
move();
}


If you notice you dont always need to change the playerspeed..
but I changed in the last part to make him walk faster.
there you go
heheh
Reply With Quote