hi, I am trying to add random npc movement. I have created something but it's kind of a joke lol.
Here is the code.
I think the npc appears to be on crack and is looking for a piece it may have dropped.Code:onClipEvent (load) { npc01 = setInterval(function () { ranmove(); }, 50); i = 0; function ranmove() { if (dontrun != true) { trace(ran1); ran1 = Math.floor(Math.random()*6); trace(ran1); ran2 = Math.floor(Math.random()*100); ran0 = Math.floor(Math.random()*25); trace(ran2); x2 = this._x-ran2; y2 = this._y-ran2; x3 = this._x+ran2; y3 = this._y+ran2; dontrun = true; } trace(ran1); if (ran1 == 0) { if (this._x<=x2) { trace("Pick new 0"); dontrun = false; } else { trace("move 0"); this.gotoAndStop(8); this._x -= 3; } } if (ran1 == 1) { if (this._y<=y2) { trace("Pick new 1"); dontrun = false; } else { this.gotoAndStop(5); trace("move 1"); this._y -= 3; } } if (ran1 == 2) { if (this._x>=x3) { trace("Pick new 2"); dontrun = false; } else { trace("move 2"); this.gotoAndStop(6); this._x += 3; } } if (ran1 == 3) { if (this._y>=y3) { trace("Pick new 3"); dontrun = false; } else { trace("move 3"); this.gotoAndStop(7); this._y += 3; } } if (ran1 == 4 || ran1 == 5) { if (i>=ran0 +8) { trace("finish waiting"); i = 0; ran2 = 0; dontrun = false; ran3 = Math.floor(Math.random()*4); } else { trace("waiting"); i++; if (ran3 == 0) { this.gotoAndStop(1); } if (ran3 == 1) { this.gotoAndStop(2); } if (ran3 == 2) { this.gotoAndStop(3); } if (ran3 == 3) { this.gotoAndStop(4); } } } } }
any suggestions..
http://www.swfcabin.com/open/1267070582




Reply With Quote
