Advertisement
Jhynjhiruu

Untitled

May 4th, 2019
2,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       public function randomWalkUpdate() : void
  2.       {
  3.          var _loc1_:Boolean = false;
  4.          var _loc2_:Boolean = false;
  5.          var _loc3_:Boolean = false;
  6.          var _loc4_:Array = null;
  7.          var _loc5_:Tile = null;
  8.          var _loc6_:Number = NaN;
  9.          if(this.randomWalk)
  10.          {
  11.             if(lastDirection == 0)
  12.             {
  13.                lastDirection = 1;
  14.             }
  15.             if(moveDirection == 0)
  16.             {
  17.                if(lastDirection == LEFT)
  18.                {
  19.                   addr86:
  20.                   _loc3_ = this.freeAtTile(tileX,tileY + 1);
  21.                   §§push(true);
  22.                }
  23.                else if(lastDirection == RIGHT)
  24.                {
  25.                   _loc1_ = this.freeAtTile(tileX + 1,tileY);
  26.                   _loc2_ = this.freeAtTile(tileX,tileY - 1);
  27.                   §§goto(addr86);
  28.                }
  29.                else if(lastDirection == UP)
  30.                {
  31.                   _loc1_ = this.freeAtTile(tileX,tileY - 1);
  32.                   _loc2_ = this.freeAtTile(tileX - 1,tileY);
  33.                   _loc3_ = this.freeAtTile(tileX + 1,tileY);
  34.                }
  35.                else if(lastDirection == DOWN)
  36.                {
  37.                   _loc1_ = this.freeAtTile(tileX,tileY + 1);
  38.                   _loc2_ = this.freeAtTile(tileX + 1,tileY);
  39.                   _loc3_ = this.freeAtTile(tileX - 1,tileY);
  40.                }
  41.                _loc4_ = this.getNewDirection(lastDirection);
  42.                if(!_loc2_)
  43.                {
  44.                   this.leftTileHit = true;
  45.                }
  46.                else if(!_loc3_)
  47.                {
  48.                   this.rightTileHit = true;
  49.                }
  50.                §§push(Boolean(this.leftTileHit));
  51.                if(§§dup(Boolean(this.leftTileHit)))
  52.                {
  53.                   §§push(true);
  54.                }
  55.                if(this.takeChance())
  56.                {
  57.                   lastDirection = _loc4_[LEFT];
  58.                }
  59.                this.leftTileHit = false;
  60.                this.rightTileHit = false;
  61.                if(!_loc1_ && _loc2_ && _loc3_)
  62.                {
  63.                   lastDirection = _loc4_[!!this.takeChance()?LEFT:RIGHT];
  64.                }
  65.                else
  66.                {
  67.                   if(!_loc1_ && _loc2_ && !_loc3_)
  68.                   {
  69.                      lastDirection = _loc4_[LEFT];
  70.                      §§push(true);
  71.                   }
  72.                   else if(!_loc1_ && !_loc2_ && _loc3_)
  73.                   {
  74.                      lastDirection = _loc4_[RIGHT];
  75.                      addr415:
  76.                      this.randomTurnTimer = Math.floor(Math.random() * 10 + 5);
  77.                      §§push(true);
  78.                      §§push(true);
  79.                   }
  80.                   else if(!_loc1_ && !_loc2_ && !_loc3_)
  81.                   {
  82.                      lastDirection = _loc4_[UP];
  83.                   }
  84.                   addr453:
  85.                   _loc5_ = Controller.level.tileGrid.getTile(tileX,tileY);
  86.                }
  87.                if(this.randomTurnTimer <= 0)
  88.                {
  89.                   _loc6_ = Math.floor(Math.random() * 2 + 1);
  90.                   §§goto(addr415);
  91.                   §§push(_loc6_ == 1 && true);
  92.                }
  93.                else
  94.                {
  95.                   this.randomTurnTimer--;
  96.                   if(this.checkWalkable(lastDirection))
  97.                   {
  98.                      this.walk(lastDirection);
  99.                   }
  100.                }
  101.                §§goto(addr453);
  102.             }
  103.          }
  104.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement