home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / optimus / agata / home.dir / 00002_coordinator.ls < prev    next >
Encoding:
Text File  |  1997-02-20  |  8.2 KB  |  247 lines

  1. property bolChanList, bolAvailList, bolActiveList, bolDelList, bubAvailList, bubActiveList, bubDelList, numBols, totNumBols, chansLeft, wilbur, crystal, layout, lastX, lastY, beenHelped, inHelp, autTimeOut, bathTimeOut, dontHumWinnie, cursorHidden, atmosDelay, frameAt
  2.  
  3. on birth me
  4.   global firstTime, visitList
  5.   set beenHelped to 0
  6.   set dontHumWinnie to 1
  7.   set autTimeOut to 40
  8.   set inHelp to 0
  9.   set bolChanList to [14, 15, 16, 17, 18]
  10.   sort(bolChanList)
  11.   set chansLeft to count(bolChanList)
  12.   if voidp(visitList) then
  13.     set visitList to []
  14.     set layout to [#kitchen: [237, 182], #bedroom: [98, 26], #crystalroom: [353, 55], #lounge: [412, 296], #bathroom: [98, 182], #projectorroom: [438, 182]]
  15.   else
  16.     set layout to switchRooms()
  17.   end if
  18.   set bolActiveList to []
  19.   set numBols to count(bolActiveList)
  20.   set sparkles to birth(script "sparkles", 14, 15, 16, 17, 18, layout, visitList)
  21.   append(bolActiveList, sparkles)
  22.   set wilbur to birth(script "wilbur", 34, 38, 39)
  23.   set crystal to birth(script "crystal", 21)
  24.   set loc to getProp(layout, #projectorroom)
  25.   set x to getAt(loc, 1)
  26.   set y to getAt(loc, 2)
  27.   append(bolActiveList, birth(script "projector", 19, 20, x, y))
  28.   append(bolActiveList, birth(script "chimney", 35, 36))
  29.   append(bolActiveList, birth(script "plant", 30, 31))
  30.   set bolAvailList to []
  31.   append(bolAvailList, birth(script "washing", 23))
  32.   append(bolAvailList, birth(script "winnie", 24, 25, 40))
  33.   append(bolAvailList, birth(script "bird1", 26))
  34.   append(bolAvailList, birth(script "bird2", 27, 28))
  35.   append(bolAvailList, birth(script "bird3", 29))
  36.   append(bolAvailList, birth(script "smoke", 37))
  37.   set totNumBols to count(bolAvailList)
  38.   set bolDelList to []
  39.   set lastX to the mouseH
  40.   set lastY to the mouseV
  41.   set atmosDelay to 0
  42.   return me
  43. end
  44.  
  45. on Animate me
  46.   global startTime, beenHelped, firstTime
  47.   Animate(wilbur)
  48.   Animate(crystal)
  49.   if not cursorHidden then
  50.     if rollOver(32) then
  51.       set the castNum of sprite 32 to 570
  52.     else
  53.       set the castNum of sprite 32 to 569
  54.     end if
  55.   end if
  56.   repeat with obj in bolActiveList
  57.     Animate(obj)
  58.   end repeat
  59.   repeat with obj in bolDelList
  60.     set tempPos to getPos(bolActiveList, obj)
  61.     if tempPos <> 0 then
  62.       deleteAt(bolActiveList, tempPos)
  63.       append(bolAvailList, obj)
  64.       set numBols to numBols - 1
  65.     end if
  66.   end repeat
  67.   set bolDelList to []
  68.   set helpTime to (the ticks / 60) - startTime
  69.   if not inHelp and firstTime then
  70.     if helpTime >= autTimeOut then
  71.       if 1 = 0 then
  72.         set frameAt to the frame
  73.         if (frameAt >= 47) and (frameAt <= 59) then
  74.           set the locH of sprite 42 to 505
  75.           set the locV of sprite 42 to 44
  76.           set the castNum of sprite 42 to 603
  77.           set the visible of sprite 42 to 1
  78.         end if
  79.         sound playFile 3, "HMahelp.aif"
  80.         set inHelp to 1
  81.         go("help")
  82.       end if
  83.     else
  84.     end if
  85.   else
  86.     if soundBusy(3) = 0 then
  87.       set inHelp to 0
  88.       set beenHelped to 1
  89.       set the mouseDownScript to EMPTY
  90.       set startTime to the ticks / 60
  91.     end if
  92.   end if
  93.   set t to the ticks
  94.   if (t - atmosDelay) > 120 then
  95.     if soundBusy(4) = 0 then
  96.       sound playFile 4, "HMatmos.aif"
  97.       set atmosDelay to the ticks
  98.     end if
  99.   end if
  100. end
  101.  
  102. on activateBol me
  103.   if numBols < totNumBols then
  104.     if chansLeft > 0 then
  105.       set rand to random(totNumBols - numBols)
  106.       set bolObj to getAt(bolAvailList, rand)
  107.       deleteAt(bolAvailList, rand)
  108.       set numBols to numBols + 1
  109.       startAnimation(bolObj)
  110.       append(bolActiveList, bolObj)
  111.     end if
  112.   end if
  113. end
  114.  
  115. on RemoveBOL me, bolObj
  116.   append(bolDelList, bolObj)
  117. end
  118.  
  119. on assignChan me
  120.   if chansLeft = 0 then
  121.     set ch to 0
  122.   else
  123.     set ch to getAt(bolChanList, 1)
  124.     set chansLeft to chansLeft - 1
  125.     deleteAt(bolChanList, 1)
  126.   end if
  127.   return ch
  128. end
  129.  
  130. on returnChan me, chan
  131.   add(bolChanList, chan)
  132.   set chansLeft to chansLeft + 1
  133. end
  134.  
  135. on notAvail me
  136.   sound playFile 3, "na.aif"
  137. end
  138.  
  139. on doQuit me
  140.   global gPath
  141.   sound stop 1
  142.   sound stop 2
  143.   sound stop 3
  144.   sound stop 4
  145.   repeat with i = 4 to 40
  146.     puppetSprite(i, 0)
  147.   end repeat
  148.   repeat with i = 1 to 47
  149.     set the visible of sprite i to 0
  150.   end repeat
  151.   go("toQuit")
  152. end
  153.  
  154. on doCreditsQuit
  155.   sound stop 1
  156.   sound stop 2
  157.   sound stop 3
  158.   sound stop 4
  159.   repeat with i = 4 to 40
  160.     puppetSprite(i, 0)
  161.   end repeat
  162.   go("cQuit")
  163. end
  164.  
  165. on switchRooms me
  166.   set A to [98, 26]
  167.   set A2 to [98, 104]
  168.   set B to [98, 182]
  169.   set C to [98, 260]
  170.   set D to [237, 182]
  171.   set D2 to [298, 182]
  172.   set E to [237, 260]
  173.   set F to [353, 55]
  174.   set G to [372, 182]
  175.   set i to [438, 182]
  176.   set J to [412, 296]
  177.   set J2 to [473, 296]
  178.   set K to [412, 374]
  179.   set K2 to [473, 374]
  180.   set L to [547, 296]
  181.   set M to [547, 374]
  182.   set variations to []
  183.   append(variations, [#kitchen: D, #bedroom: A, #crystalroom: F, #lounge: J, #spare: [B, C, i]])
  184.   append(variations, [#kitchen: D, #bedroom: A2, #crystalroom: F, #lounge: J, #spare: [A, C, i]])
  185.   append(variations, [#kitchen: D, #bedroom: B, #crystalroom: F, #lounge: J, #spare: [A, A2, i]])
  186.   append(variations, [#kitchen: E, #bedroom: A, #crystalroom: D, #lounge: J, #spare: [B, C, D2, i]])
  187.   append(variations, [#kitchen: E, #bedroom: A, #crystalroom: G, #lounge: J, #spare: [B, C, D, i]])
  188.   append(variations, [#kitchen: E, #bedroom: A2, #crystalroom: D, #lounge: J, #spare: [A, C, D2, i]])
  189.   append(variations, [#kitchen: E, #bedroom: A2, #crystalroom: G, #lounge: J, #spare: [A, C, D, i]])
  190.   append(variations, [#kitchen: E, #bedroom: B, #crystalroom: D, #lounge: J, #spare: [A, A2, D2, i]])
  191.   append(variations, [#kitchen: E, #bedroom: B, #crystalroom: G, #lounge: J, #spare: [A, A2, D, i]])
  192.   append(variations, [#lounge: D, #bedroom: A, #crystalroom: K, #kitchen: J, #spare: [B, C, i, K2]])
  193.   append(variations, [#lounge: D, #bedroom: A, #crystalroom: M, #kitchen: J, #spare: [B, C, i, K]])
  194.   append(variations, [#lounge: D, #bedroom: A2, #crystalroom: K, #kitchen: J, #spare: [A, C, i, K2]])
  195.   append(variations, [#lounge: D, #bedroom: A2, #crystalroom: M, #kitchen: J, #spare: [A, C, i, K]])
  196.   append(variations, [#lounge: D, #bedroom: B, #crystalroom: K, #kitchen: J, #spare: [A, A2, i, K2]])
  197.   append(variations, [#lounge: D, #bedroom: B, #crystalroom: M, #kitchen: J, #spare: [A, A2, i, K]])
  198.   append(variations, [#lounge: D, #bedroom: A, #crystalroom: J, #kitchen: K, #spare: [B, C, i, J2]])
  199.   append(variations, [#lounge: D, #bedroom: A, #crystalroom: L, #kitchen: K, #spare: [B, C, i, J]])
  200.   append(variations, [#lounge: D, #bedroom: A2, #crystalroom: J, #kitchen: K, #spare: [A, C, i, J2]])
  201.   append(variations, [#lounge: D, #bedroom: A2, #crystalroom: L, #kitchen: K, #spare: [A, C, i, J]])
  202.   append(variations, [#lounge: D, #bedroom: B, #crystalroom: J, #kitchen: K, #spare: [A, A2, i, J2]])
  203.   append(variations, [#lounge: D, #bedroom: B, #crystalroom: L, #kitchen: K, #spare: [A, A2, i, J]])
  204.   set var to getAt(variations, random(21))
  205.   repeat with i = 1 to 4
  206.     set theCast to EMPTY & getPropAt(var, i)
  207.     set theLoc to getAt(var, i)
  208.     set the locH of sprite (3 + i) to getAt(theLoc, 1)
  209.     set the locV of sprite (3 + i) to getAt(theLoc, 2)
  210.     set the castNum of sprite (3 + i) to cast theCast
  211.   end repeat
  212.   set spareSlots to getProp(var, #spare)
  213.   deleteProp(var, #spare)
  214.   set num to count(spareSlots)
  215.   if num = 4 then
  216.     set rnd to random(4)
  217.     set theLoc to getAt(spareSlots, rnd)
  218.     set the locH of sprite 11 to getAt(theLoc, 1)
  219.     set the locV of sprite 11 to getAt(theLoc, 2)
  220.     set the castNum of sprite 11 to cast "spare2"
  221.   else
  222.     set the castNum of sprite 11 to 0
  223.   end if
  224.   if num = 4 then
  225.     set rnd to (rnd mod 4) + 1
  226.   else
  227.     set rnd to random(3)
  228.   end if
  229.   set theLoc to getAt(spareSlots, rnd)
  230.   set the locH of sprite 10 to getAt(theLoc, 1)
  231.   set the locV of sprite 10 to getAt(theLoc, 2)
  232.   set the castNum of sprite 10 to cast "spare1"
  233.   set rnd to (rnd mod num) + 1
  234.   set theLoc to getAt(spareSlots, rnd)
  235.   addProp(var, #bathroom, theLoc)
  236.   set the locH of sprite 9 to getAt(theLoc, 1)
  237.   set the locV of sprite 9 to getAt(theLoc, 2)
  238.   set the castNum of sprite 9 to cast "bathroom"
  239.   set rnd to (rnd mod num) + 1
  240.   set theLoc to getAt(spareSlots, rnd)
  241.   addProp(var, #projectorroom, theLoc)
  242.   set the locH of sprite 8 to getAt(theLoc, 1)
  243.   set the locV of sprite 8 to getAt(theLoc, 2)
  244.   set the castNum of sprite 8 to cast "projectorroom"
  245.   return var
  246. end
  247.