Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function randomWalkUpdate() : void
- {
- var _loc1_:Boolean = false;
- var _loc2_:Boolean = false;
- var _loc3_:Boolean = false;
- var _loc4_:Array = null;
- var _loc5_:Tile = null;
- var _loc6_:Number = NaN;
- if(this.randomWalk)
- {
- if(lastDirection == 0)
- {
- lastDirection = 1;
- }
- if(moveDirection == 0)
- {
- if(lastDirection == LEFT)
- {
- addr86:
- _loc3_ = this.freeAtTile(tileX,tileY + 1);
- §§push(true);
- }
- else if(lastDirection == RIGHT)
- {
- _loc1_ = this.freeAtTile(tileX + 1,tileY);
- _loc2_ = this.freeAtTile(tileX,tileY - 1);
- §§goto(addr86);
- }
- else if(lastDirection == UP)
- {
- _loc1_ = this.freeAtTile(tileX,tileY - 1);
- _loc2_ = this.freeAtTile(tileX - 1,tileY);
- _loc3_ = this.freeAtTile(tileX + 1,tileY);
- }
- else if(lastDirection == DOWN)
- {
- _loc1_ = this.freeAtTile(tileX,tileY + 1);
- _loc2_ = this.freeAtTile(tileX + 1,tileY);
- _loc3_ = this.freeAtTile(tileX - 1,tileY);
- }
- _loc4_ = this.getNewDirection(lastDirection);
- if(!_loc2_)
- {
- this.leftTileHit = true;
- }
- else if(!_loc3_)
- {
- this.rightTileHit = true;
- }
- §§push(Boolean(this.leftTileHit));
- if(§§dup(Boolean(this.leftTileHit)))
- {
- §§push(true);
- }
- if(this.takeChance())
- {
- lastDirection = _loc4_[LEFT];
- }
- this.leftTileHit = false;
- this.rightTileHit = false;
- if(!_loc1_ && _loc2_ && _loc3_)
- {
- lastDirection = _loc4_[!!this.takeChance()?LEFT:RIGHT];
- }
- else
- {
- if(!_loc1_ && _loc2_ && !_loc3_)
- {
- lastDirection = _loc4_[LEFT];
- §§push(true);
- }
- else if(!_loc1_ && !_loc2_ && _loc3_)
- {
- lastDirection = _loc4_[RIGHT];
- addr415:
- this.randomTurnTimer = Math.floor(Math.random() * 10 + 5);
- §§push(true);
- §§push(true);
- }
- else if(!_loc1_ && !_loc2_ && !_loc3_)
- {
- lastDirection = _loc4_[UP];
- }
- addr453:
- _loc5_ = Controller.level.tileGrid.getTile(tileX,tileY);
- }
- if(this.randomTurnTimer <= 0)
- {
- _loc6_ = Math.floor(Math.random() * 2 + 1);
- §§goto(addr415);
- §§push(_loc6_ == 1 && true);
- }
- else
- {
- this.randomTurnTimer--;
- if(this.checkWalkable(lastDirection))
- {
- this.walk(lastDirection);
- }
- }
- §§goto(addr453);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement