| LiquidIce00 |
07-27-2001 09:08 AM |
here is a follow code
Not the best, but something I just made quickly for the people who have been asking how to make an online follow player.
I still like the way that bomies follow (always stay behind the player)
this one just moves up/down/left/right according to the player.
Also , why is it that when I set array it doesnt work ? Am I doing something wrong or is Graal array just weird?
NPC Code:
// NPC made by LiquidIce - Buzy liek always
//Following Orb
//this sets how fast the timeout goes
this.speed=.15;
if (playertouchsme) {
toweapons Pet Orb;
}
if (weaponfired) {
//setarray orbx,7;
//setarray orby,7;
this.a=0;
while (this.a<7) {
this.a++;
orbx[this.a]=playerx+1.5-(vecx(playerdir)*2);
orby[this.a]=playery+2-(vecy(playerdir)*2);
}
timeout=this.speed;
}
if (timeout) {
follow();
movearray();
setarray();
timeout=this.speed;
}
function setarray() {
if (playerx>orbx[6]&&playerx-orbx[6]>2) {
orbx[7]=orbx[6]+.5;
}
if (playerx<orbx[6]&&orbx[6]-playerx>2) {
orbx[7]=orbx[6]-.5;
}
if (playery<orby[6]&&orby[6]-playery>2) {
orby[7]=orby[6]-.5;
}
if (playery>orby[6]&&playery-orby[6]>2) {
orby[7]=orby[6]+.5;
}
}
function follow() {
showimg 100,shadoworb.gif,orbx[1],orby[1];
}
function movearray() {
this.i=0;
while (this.i<6) {
this.i++;
this.test=this.i+1;
orbx[this.i]=orbx[this.test];
orby[this.i]=orby[this.test];
}
}
|