home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / emu-mess.swf / scripts / frame_3 / DoAction.as
Encoding:
Text File  |  2008-08-08  |  20.9 KB  |  625 lines

  1. function placeSophie()
  2. {
  3.    _root.sophieClip._y = _root["floor" + _root.sophie.targetFloor] - _root.sophieClip._height;
  4.    _root.sophie.myFloor = _root.sophie.targetFloor;
  5.    myXmax = _root["holeArray" + _root.sophie.myFloor][0].xMax;
  6.    myXmin = _root["holeArray" + _root.sophie.myFloor][0].xMin;
  7.    if(_root.sophie.targetX < myXmax)
  8.    {
  9.       _root.sophieClip._x = -20;
  10.    }
  11.    else
  12.    {
  13.       _root.sophieClip._x = Stage.width + 20;
  14.    }
  15.    _root.turnSophie();
  16. }
  17. function turnSophie()
  18. {
  19.    if(_root.sophieClip._x < _root.sophie.targetX)
  20.    {
  21.       _root.sophieClip.gotoAndStop("walkRight");
  22.       _root.sophie.xdir = 1;
  23.    }
  24.    else
  25.    {
  26.       _root.sophieClip.gotoAndStop("walkLeft");
  27.       _root.sophie.xdir = -1;
  28.    }
  29. }
  30. function turnToWalkOff()
  31. {
  32.    myXmax = _root["holeArray" + _root.sophie.myFloor][0].xMax;
  33.    myXmin = _root["holeArray" + _root.sophie.myFloor][0].xMin;
  34.    if(_root.sophieClip._x < myXmax && _root.sophie.xdir != -1)
  35.    {
  36.       if(_root.sophie.pecked)
  37.       {
  38.          _root.sophieClip.gotoAndStop("runLeft");
  39.       }
  40.       else
  41.       {
  42.          _root.sophieClip.gotoAndStop("walkLeft");
  43.       }
  44.       _root.sophie.xdir = -1;
  45.    }
  46.    else if(_root.sophieClip._x > myXmin && _root.sophie.xdir != 1)
  47.    {
  48.       if(_root.sophie.pecked)
  49.       {
  50.          _root.sophieClip.gotoAndStop("runRight");
  51.       }
  52.       else
  53.       {
  54.          _root.sophieClip.gotoAndStop("walkRight");
  55.       }
  56.       _root.sophie.xdir = 1;
  57.    }
  58.    else if(_root.sophie.xdir == -1)
  59.    {
  60.       if(_root.sophie.pecked)
  61.       {
  62.          _root.sophieClip.gotoAndStop("runLeft");
  63.       }
  64.       else
  65.       {
  66.          _root.sophieClip.gotoAndStop("walkLeft");
  67.       }
  68.    }
  69.    else if(_root.sophie.pecked)
  70.    {
  71.       _root.sophieClip.gotoAndStop("runRight");
  72.    }
  73.    else
  74.    {
  75.       _root.sophieClip.gotoAndStop("walkRight");
  76.    }
  77. }
  78. function getFloor(thisY)
  79. {
  80.    if(thisY < _root.floor1)
  81.    {
  82.       return 1;
  83.    }
  84.    if(thisY < _root.floor2)
  85.    {
  86.       return 2;
  87.    }
  88.    if(thisY < _root.floor3)
  89.    {
  90.       return 3;
  91.    }
  92.    return 4;
  93. }
  94. function chooseTarget(myStr)
  95. {
  96.    myToy = null;
  97.    i = 0;
  98.    while(i < _root.hiddenToys.length)
  99.    {
  100.       if(_root.toys[_root.hiddenToys[i].myClip]._visible)
  101.       {
  102.          if(random(10) > 8)
  103.          {
  104.             myToy = i;
  105.             break;
  106.          }
  107.       }
  108.       i++;
  109.    }
  110.    if(myToy != null)
  111.    {
  112.       _root.sophie.targetX = _root.hiddenToys[myToy].myX;
  113.       _root.sophie.targetY = _root.hiddenToys[myToy].myY;
  114.       _root.sophie.targetFloor = _root.getFloor(_root.sophie.targetY);
  115.    }
  116.    else if(random(10) < _root.sophie.homing && _root.hiddenToys.length > 0)
  117.    {
  118.       myToy = random(_root.hiddenToys.length);
  119.       _root.sophie.targetX = _root.hiddenToys[myToy].myX;
  120.       _root.sophie.targetY = _root.hiddenToys[myToy].myY;
  121.       _root.sophie.targetFloor = _root.getFloor(_root.sophie.targetY);
  122.    }
  123.    else
  124.    {
  125.       _root.sophie.targetFloor = random(3) + 1;
  126.       _root.sophie.myHideBlock = _root["floor" + _root.sophie.targetFloor + "Blocks"][random(_root["floor" + _root.sophie.targetFloor + "Blocks"].length)];
  127.       _root.sophie.myItemInBlock = random(_root[_root.sophie.myHideBlock].length);
  128.       if(!_root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].inspected && !_root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].hit)
  129.       {
  130.          _root.sophie.targetX = _root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].myX;
  131.          _root.sophie.targetY = _root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].myY;
  132.       }
  133.       else
  134.       {
  135.          _root.sophie.targetFloor = _root.sophie.myFloor;
  136.       }
  137.    }
  138. }
  139. function rightSideOfHole()
  140. {
  141.    myXmax = _root["holeArray" + _root.sophie.myFloor][0].xMax;
  142.    myXmin = _root["holeArray" + _root.sophie.myFloor][0].xMin;
  143.    if(_root.sophieClip._x < myXmin && _root.sophie.targetX < myXmin)
  144.    {
  145.       return 1;
  146.    }
  147.    if(_root.sophieClip._x > myXmax && _root.sophie.targetX > myXmax)
  148.    {
  149.       return 1;
  150.    }
  151.    return 0;
  152. }
  153. function sophieHeartBeat()
  154. {
  155.    if(_root.sophie.behaviour == "start")
  156.    {
  157.       if(_root.sophie.targetFloor != _root.sophie.myFloor || _root.sophie.myFloor < 4 && !_root.rightSideOfHole())
  158.       {
  159.          _root.sophie.behaviour = "walkOff";
  160.       }
  161.       else if(_root.sophie.targetFloor == _root.sophie.myFloor && _root.rightSideOfHole() || _root.sophie.targetFloor == _root.sophie.myFloor && _root.sophie.myFloor == 4)
  162.       {
  163.          _root.sophie.behaviour = "walkTo";
  164.       }
  165.    }
  166.    else if(_root.sophie.behaviour == "walkTo")
  167.    {
  168.       if(Math.abs(_root.sophieClip._x - _root.sophie.targetX) < _root.sophie.speed + 2)
  169.       {
  170.          _root.sophieClip._x = _root.sophie.targetX;
  171.          _root.sophie.behaviour = "action";
  172.       }
  173.       _root.sophieClip._x += _root.sophie.xdir * _root.sophie.speed;
  174.    }
  175.    else if(_root.sophie.behaviour == "action")
  176.    {
  177.       i = 0;
  178.       while(i < _root.hiddenToys.length)
  179.       {
  180.          if(Math.abs(_root.sophie.targetX - _root.hiddenToys[i].myX) < 5 && Math.abs(_root.sophie.targetY - _root.hiddenToys[i].myY) < 5)
  181.          {
  182.             _root.foundClip.myTextColour = "0xFF3333";
  183.             _root.foundClip.myFoundText = "Sophie Found The " + _root.hiddenToys[i].myToy;
  184.             _root.foundClip.myFace = 2;
  185.             _root.foundClip.gotoAndPlay(2);
  186.             _root.sophieFound.start(0,1);
  187.             _root.sophieToys.push(_root.hiddenToys[i]);
  188.             _root.toys[_root.hiddenToys[i].myClip]._visible = 1;
  189.             _root.toys[_root.hiddenToys[i].myClip]._xscale = 90;
  190.             _root.toys[_root.hiddenToys[i].myClip]._yscale = 90;
  191.             _root.toys[_root.hiddenToys[i].myClip].pulse.gotoAndStop("found");
  192.             _root.toys[_root.hiddenToys[i].myClip]._x = 404 + _root.sophieToys.length * 38;
  193.             _root.toys[_root.hiddenToys[i].myClip]._y = 495;
  194.             _root.hiddenToys.splice(i,1);
  195.             if(_root.sophieToys.length == 5)
  196.             {
  197.                _root.gameOver();
  198.             }
  199.             break;
  200.          }
  201.          i++;
  202.       }
  203.       _root.sophieClip.gotoAndStop("rummage");
  204.    }
  205.    else if(_root.sophie.behaviour == "actionDone")
  206.    {
  207.       _root[_root.sophie.myHideBlock][_root.sophie.myItemInBlock].inspected = 1;
  208.       _root.chooseTarget("actionDone");
  209.       if(_root.sophie.targetFloor == _root.sophie.myFloor && _root.rightSideOfHole())
  210.       {
  211.          _root.turnSophie();
  212.          _root.sophie.behaviour = "walkTo";
  213.       }
  214.       else
  215.       {
  216.          _root.turnToWalkOff();
  217.          _root.sophie.behaviour = "walkOff";
  218.       }
  219.    }
  220.    else if(_root.sophie.behaviour == "walkOff")
  221.    {
  222.       if(_root.sophie.xdir == -1 && _root.sophieClip._x < -20 || _root.sophie.xdir == 1 && _root.sophieClip._x > 630)
  223.       {
  224.          _root.sophie.pecked = 0;
  225.          if(_root.sophie.targetX == undefined)
  226.          {
  227.             _root.chooseTarget();
  228.             _root.sophie.behaviour = "actionDone";
  229.          }
  230.          else
  231.          {
  232.             _root.placeSophie();
  233.             _root.sophie.waitCounter = 0;
  234.             _root.sophie.behaviour = "wait";
  235.          }
  236.       }
  237.       else
  238.       {
  239.          _root.sophieClip._x += _root.sophie.xdir * _root.sophie.speed;
  240.       }
  241.    }
  242.    else if(_root.sophie.behaviour == "wait")
  243.    {
  244.       _root.sophie.waitCounter = _root.sophie.waitCounter + 1;
  245.       if(_root.sophie.waitCounter > _root.sophie.waitTime)
  246.       {
  247.          _root.sophie.waitCounter = 0;
  248.          _root.sophie.behaviour = "start";
  249.       }
  250.    }
  251.    else if(_root.sophie.behaviour == "pecked")
  252.    {
  253.    }
  254. }
  255. function hideToys()
  256. {
  257.    this.hiddenBlocks1 = new Object();
  258.    this.hiddenBlocks2 = new Object();
  259.    this.hiddenBlocks3 = new Object();
  260.    this.hiddenBlocks4 = new Object();
  261.    i = 0;
  262.    while(i < _root.toyArray.length)
  263.    {
  264.       if(i < 2)
  265.       {
  266.          myFloor = 1;
  267.       }
  268.       else if(i < 5)
  269.       {
  270.          myFloor = 2;
  271.       }
  272.       else if(i < 8)
  273.       {
  274.          myFloor = 3;
  275.       }
  276.       else
  277.       {
  278.          myFloor = 4;
  279.       }
  280.       myHideBlock = _root["floor" + myFloor + "Blocks"][random(_root["floor" + myFloor + "Blocks"].length)];
  281.       myItemInBlock = random(_root[myHideBlock].length);
  282.       if(this["hiddenBlocks" + myFloor][myHideBlock] != undefined || _root[myHideBlock][myItemInBlock]._name == "cupboardDoor")
  283.       {
  284.          i--;
  285.       }
  286.       else
  287.       {
  288.          this["hiddenBlocks" + myFloor][myHideBlock] = 1;
  289.          uid = _root.toys.getNextHighestDepth();
  290.          clipName = "toy" + uid;
  291.          _root.toys.attachMovie("toy",clipName,uid);
  292.          if(myHideBlock == "superBlocky3x3")
  293.          {
  294.             _root.toys[clipName].inCupboard = 1;
  295.          }
  296.          _root.toys[clipName]._visible = 0;
  297.          _root.toys[clipName].gotoAndStop(i + 1);
  298.          _root.toys[clipName]._x = _root[myHideBlock][myItemInBlock].myX;
  299.          _root.toys[clipName]._y = _root[myHideBlock][myItemInBlock].myY;
  300.          _root.hiddenToys.push({myToy:_root.toyArray[i],myClip:clipName,myX:_root[myHideBlock][myItemInBlock].myX,myY:_root[myHideBlock][myItemInBlock].myY});
  301.       }
  302.       i++;
  303.    }
  304. }
  305. function checkSophiesTarget(thisX, thisY)
  306. {
  307. }
  308. function gameOver()
  309. {
  310.    _root.gameFinished = 1;
  311.    if(_root.emuToys.length > _root.sophieToys.length)
  312.    {
  313.       _root.winner = "Emu";
  314.       _root.emuState = "win";
  315.       _root.sophieState = "lose";
  316.    }
  317.    else
  318.    {
  319.       _root.winner = "Sophie";
  320.       _root.emuState = "lose";
  321.       _root.sophieState = "win";
  322.    }
  323.    _root.endGameClip.play();
  324. }
  325. function peckDetector(peckHeight, peckFloor, peckSquare)
  326. {
  327.    mySuperBlock = "superBlocky" + peckFloor + "x" + peckSquare;
  328.    peckX = _root.emu._x + _root.emu.xdir * (_root.emu._width / 2);
  329.    i = 0;
  330.    while(i < _root.hiddenToys.length)
  331.    {
  332.       if(Math.abs(peckX - _root.hiddenToys[i].myX) < _root.proximity && Math.abs(_root.emu._y - peckHeight - _root.hiddenToys[i].myY) < _root.proximity * 2)
  333.       {
  334.          if(_root.toys[_root.hiddenToys[i].myClip]._visible)
  335.          {
  336.             _root.foundClip.myTextColour = "0x3366CC";
  337.             _root.foundClip.myFoundText = "You Found The " + _root.hiddenToys[i].myToy;
  338.             _root.foundClip.myFace = 1;
  339.             _root.foundClip.gotoAndPlay(2);
  340.             _root.toyCollected.start(0,1);
  341.             _root.emuToys.push(_root.hiddenToys[i]);
  342.             _root.checkSophiesTarget(_root.hiddenToys[i].myX,_root.hiddenToys[i].myY);
  343.             _root.toys[_root.hiddenToys[i].myClip]._xscale = 100;
  344.             _root.toys[_root.hiddenToys[i].myClip]._yscale = 100;
  345.             _root.toys[_root.hiddenToys[i].myClip].pulse.gotoAndStop("found");
  346.             _root.toys[_root.hiddenToys[i].myClip]._x = 82 + _root.emuToys.length * 38;
  347.             _root.toys[_root.hiddenToys[i].myClip]._y = 495;
  348.             _root.hiddenToys.splice(i,1);
  349.             if(_root.emuToys.length == 5)
  350.             {
  351.                _root.gameOver();
  352.             }
  353.             break;
  354.          }
  355.          if(_root.toys[_root.hiddenToys[i].myClip].inCupboard == 1 && _root.cupboardOpen)
  356.          {
  357.             _root.toys[_root.hiddenToys[i].myClip]._visible = 1;
  358.             _root.toyFound.start(0,1);
  359.          }
  360.          else if(_root.toys[_root.hiddenToys[i].myClip].inCupboard != 1)
  361.          {
  362.             _root.toys[_root.hiddenToys[i].myClip]._visible = 1;
  363.             _root.toyFound.start(0,1);
  364.          }
  365.       }
  366.       i++;
  367.    }
  368.    i = 0;
  369.    while(i < _root[mySuperBlock].length)
  370.    {
  371.       if(_root[mySuperBlock][i].hit == 0)
  372.       {
  373.          myItem = _root[mySuperBlock][i].myName;
  374.          myBounds = _root.blocks[myItem].getBounds(this);
  375.          if(peckX > myBounds.xMin - _root.peckProx / 2 && peckX < myBounds.xMax + _root.peckProx / 2 && _root.emu._y - peckHeight + _root.peckProx > myBounds.yMin && _root.emu._y - peckHeight - _root.peckProx < myBounds.yMax && _root.blocks[myItem].cupboardClosed != 1)
  376.          {
  377.             if(Math.random() >= 0.5)
  378.             {
  379.                _root.blocks[myItem].xdir = 1;
  380.             }
  381.             else
  382.             {
  383.                _root.blocks[myItem].xdir = -1;
  384.             }
  385.             _root.blocks[myItem].gotoAndStop(2);
  386.             _root.blocks[myItem].xmov = (random(8) + 4) * _root.blocks[myItem].xdir;
  387.             _root.blocks[myItem].bounce = 0;
  388.             _root.blocks[myItem].ymov = - (random(9) + 1);
  389.             _root.checkSophiesTarget(_root[mySuperBlock][i].myX,_root[mySuperBlock][i].myY);
  390.             _root[mySuperBlock][i].hit = 1;
  391.             _root.activeItems[myItem] = 1;
  392.          }
  393.       }
  394.       i++;
  395.    }
  396. }
  397. function collisionDetector(myItem)
  398. {
  399.    mySuperBlock = "superBlocky" + _root.blocks[myItem].myFloor + "x" + (Math.floor(_root.blocks[myItem]._x / 50) + 1);
  400.    i = 0;
  401.    while(i < _root[mySuperBlock].length)
  402.    {
  403.       if(!_root[mySuperBlock][i].hit)
  404.       {
  405.          targetItem = _root[mySuperBlock][i].myName;
  406.          if(_root.blocks[myItem].hitTest(_root.blocks[targetItem]) && Math.abs(_root.blocks[myItem].xmov) > _root.xCriticalWeight || _root.blocks[myItem].hitTest(_root.blocks[targetItem]) && Math.abs(_root.blocks[myItem].ymov) > _root.yCriticalWeight)
  407.          {
  408.             _root.checkForItem(mySuperBlock,targetItem,i);
  409.             _root.blocks[targetItem].gotoAndStop(2);
  410.             _root.blocks[targetItem].xdir = _root.blocks[myItem].xdir;
  411.             _root.blocks[targetItem].bounce = 0;
  412.             newX = Math.round(_root.blocks[myItem].xmov / 2);
  413.             if(_root.blocks[myItem].ymov < 0)
  414.             {
  415.                newY = Math.round(_root.blocks[myItem].ymov / 2);
  416.                _root.blocks[myItem].ymov = newY;
  417.                _root.blocks[targetItem].ymov = newY;
  418.             }
  419.             else
  420.             {
  421.                _root.blocks[targetItem].ymov = 0;
  422.             }
  423.             _root.blocks[myItem].xmov = newX;
  424.             _root.blocks[targetItem].xmov = newX;
  425.             n = 0;
  426.             while(n < _root.hiddenToys.length)
  427.             {
  428.                if(Math.abs(_root.blocks[targetItem]._x - _root.hiddenToys[n].myX) < _root.proximity && Math.abs(_root.blocks[targetItem]._y - _root.hiddenToys[n].myY) < _root.proximity)
  429.                {
  430.                   if(!_root[_root.hiddenToys[n].myClip]._visible)
  431.                   {
  432.                      _root[_root.hiddenToys[n].myClip]._visible = 1;
  433.                      _root.toyFound.start(0,1);
  434.                   }
  435.                }
  436.                n++;
  437.             }
  438.             _root.checkSophiesTarget(_root[mySuperBlock][i].myX,_root[mySuperBlock][i].myY);
  439.             _root[mySuperBlock][i].hit = 1;
  440.             _root.activeItems[targetItem] = 1;
  441.          }
  442.       }
  443.       i++;
  444.    }
  445. }
  446. function fallFoam(item)
  447. {
  448.    if(_root.foams[item].ymov < _root.terminal)
  449.    {
  450.       _root.foams[item].ymov += _root.accel;
  451.    }
  452.    if(Math.abs(_root.foams[item].xmov) / _root.foams[item].xmov == _root.foams[item].xdir)
  453.    {
  454.       _root.foams[item].xmov -= _root.foams[item].xdir * _root.resistance;
  455.       if(Math.abs(_root.foams[item].xmov) < 1)
  456.       {
  457.          _root.foams[item].xmov = 0;
  458.       }
  459.       _root.foams[item]._x += _root.foams[item].xmov;
  460.    }
  461.    if(_root.foams[item]._x > Stage.width)
  462.    {
  463.       _root.foams[item].xdir = -1;
  464.       _root.foams[item].xmov = Math.abs(_root.foams[item].xmov) * _root.foams[item].xdir;
  465.    }
  466.    else if(_root.foams[item]._x < 0)
  467.    {
  468.       _root.foams[item].xdir = 1;
  469.       _root.foams[item].xmov = Math.abs(_root.foams[item].xmov) * _root.foams[item].xdir;
  470.    }
  471.    if(_root.foams[item]._y + _root.foams[item]._height + _root.foams[item].ymov > _root["floor" + _root.foams[item].myFloor])
  472.    {
  473.       i = 0;
  474.       while(i < _root["holeArray" + _root.foams[item].myFloor].length)
  475.       {
  476.          if(_root.foams[item]._x > _root["holeArray" + _root.foams[item].myFloor][i].xMin && _root.foams[item]._x < _root["holeArray" + _root.foams[item].myFloor][i].xMax)
  477.          {
  478.             _root.foams[item].myFloor = _root.foams[item].myFloor + 1;
  479.          }
  480.          i++;
  481.       }
  482.    }
  483.    if(_root.foams[item]._y + _root.foams[item]._height + _root.foams[item].ymov >= _root["floor" + _root.foams[item].myFloor])
  484.    {
  485.       if(Math.abs(_root.foams[item].ymov) <= 2 || _root.foams[item].bounce > 8)
  486.       {
  487.          _root.foams[item]._y = _root["floor" + _root.foams[item].myFloor] - _root.foams[item]._height;
  488.          _root.foams[item].gotoAndStop(3);
  489.          _root.foams[item].ymov = 0;
  490.          delete _root.activeItems[item];
  491.       }
  492.       else
  493.       {
  494.          _root.foams[item].bounce = _root.foams[item].bounce + 1;
  495.          if(_root.foams[item]._y + _root.foams[item]._height + _root.foams[item].ymov - _root["floor" + _root.foams[item].myFloor] > 8)
  496.          {
  497.             _root.foams[item]._y = _root["floor" + _root.foams[item].myFloor] - _root.foams[item]._height - _root.foams[item].ymov;
  498.          }
  499.          else
  500.          {
  501.             _root.foams[item]._y = _root["floor" + _root.foams[item].myFloor] - _root.foams[item]._height;
  502.          }
  503.          _root.foams[item].ymov = - _root.foams[item].ymov * _root.restitution;
  504.       }
  505.    }
  506.    else
  507.    {
  508.       _root.foams[item]._y += _root.foams[item].ymov;
  509.    }
  510. }
  511. function fall(item)
  512. {
  513.    if(_root.blocks[item].ymov < _root.terminal)
  514.    {
  515.       _root.blocks[item].ymov += _root.accel;
  516.    }
  517.    if(Math.abs(_root.blocks[item].xmov) / _root.blocks[item].xmov == _root.blocks[item].xdir)
  518.    {
  519.       _root.blocks[item].xmov -= _root.blocks[item].xdir * _root.resistance;
  520.       if(Math.abs(_root.blocks[item].xmov) < 1)
  521.       {
  522.          _root.blocks[item].xmov = 0;
  523.       }
  524.       _root.blocks[item]._x += _root.blocks[item].xmov;
  525.    }
  526.    if(_root.blocks[item]._x > Stage.width)
  527.    {
  528.       _root.blocks[item].xdir = -1;
  529.       _root.blocks[item].xmov = Math.abs(_root.blocks[item].xmov) * _root.blocks[item].xdir;
  530.    }
  531.    else if(_root.blocks[item]._x < 0)
  532.    {
  533.       _root.blocks[item].xdir = 1;
  534.       _root.blocks[item].xmov = Math.abs(_root.blocks[item].xmov) * _root.blocks[item].xdir;
  535.    }
  536.    _root.collisionDetector(item);
  537.    if(_root.blocks[item]._y + _root.blocks[item]._height + _root.blocks[item].ymov > _root["floor" + _root.blocks[item].myFloor])
  538.    {
  539.       i = 0;
  540.       while(i < _root["holeArray" + _root.blocks[item].myFloor].length)
  541.       {
  542.          if(_root.blocks[item]._x > _root["holeArray" + _root.blocks[item].myFloor][i].xMin && _root.blocks[item]._x < _root["holeArray" + _root.blocks[item].myFloor][i].xMax)
  543.          {
  544.             _root.blocks[item].myFloor = _root.blocks[item].myFloor + 1;
  545.          }
  546.          i++;
  547.       }
  548.    }
  549.    if(_root.blocks[item]._y + _root.blocks[item]._height + _root.blocks[item].ymov >= _root["floor" + _root.blocks[item].myFloor])
  550.    {
  551.       if(Math.abs(_root.blocks[item].ymov) <= 2 || _root.blocks[item].bounce > 8)
  552.       {
  553.          _root.blocks[item]._y = _root["floor" + _root.blocks[item].myFloor] - _root.blocks[item]._height;
  554.          _root.blocks[item].gotoAndStop(3);
  555.          _root.blocks[item].ymov = 0;
  556.          delete _root.activeItems[item];
  557.       }
  558.       else
  559.       {
  560.          _root.blocks[item].bounce = _root.blocks[item].bounce + 1;
  561.          if(_root.blocks[item]._y + _root.blocks[item]._height + _root.blocks[item].ymov - _root["floor" + _root.blocks[item].myFloor] > 8)
  562.          {
  563.             _root.blocks[item]._y = _root["floor" + _root.blocks[item].myFloor] - _root.blocks[item]._height - _root.blocks[item].ymov;
  564.          }
  565.          else
  566.          {
  567.             _root.blocks[item]._y = _root["floor" + _root.blocks[item].myFloor] - _root.blocks[item]._height;
  568.          }
  569.          _root.blocks[item].ymov = - _root.blocks[item].ymov * _root.restitution;
  570.       }
  571.    }
  572.    else
  573.    {
  574.       _root.blocks[item]._y += _root.blocks[item].ymov;
  575.    }
  576. }
  577. _root.accel = 2;
  578. _root.terminal = 12;
  579. _root.restitution = 0.8;
  580. _root.resistance = 0.1;
  581. _root.emu.landing = 0;
  582. _root.emu.speed = 0;
  583. _root.proximity = 25;
  584. _root.peckProx = 20;
  585. _root.emu.peckPointer = 1;
  586. _root.peckReleased = 1;
  587. _root.emu.inLift = 0;
  588. _root.emu.emuHeight = 55;
  589. _root.xCriticalWeight = 40;
  590. _root.yCriticalWeight = 40;
  591. _root.activeItems = new Object();
  592. _root.activeFoams = new Object();
  593. _root.floor1 = 119;
  594. _root.floor2 = 239;
  595. _root.floor3 = 360;
  596. _root.floor4 = 479;
  597. _root.peckHeight1 = -30;
  598. _root.peckHeight2 = -15;
  599. _root.peckHeight3 = 0;
  600. _root.peckHeight4 = 18;
  601. _root.toyArray = new Array("Teddy","Rollerskate","Ball","Train","Glasses","Robot","Rattle","Horn","Ducky","Car","Boomerang");
  602. _root.hiddenToys = new Array();
  603. _root.emuToys = new Array();
  604. _root.sophieToys = new Array();
  605. _root.sophie = new Object();
  606. _root.sophie.homing = 0;
  607. _root.sophie.behaviour = "start";
  608. _root.sophie.targetX = 0;
  609. _root.sophie.targetY = 0;
  610. _root.sophie.counter = 0;
  611. _root.sophie.speed = 8;
  612. _root.sophie.xdir = -1;
  613. _root.sophie.pecked = 0;
  614. _root.sophie.waitCounter = 0;
  615. _root.sophie.waitTime = 10;
  616. _root.sophie.myFloor = 1;
  617. _root.sophie.pausedState = 0;
  618. _root.chooseTarget("initial");
  619. _root.placeSophie();
  620. _root.cupboardOpen = 0;
  621. _root.gameFinished = 0;
  622. _root.gameTimer = getTimer() + 15000;
  623. hideToys();
  624. stop();
  625.