home *** CD-ROM | disk | FTP | other *** search
/ Oz - The Magical Adventure / Adventure.iso / pc / dkdata / toadstools.dxr / Internal_20_MakeToadStoolField.ls < prev    next >
Encoding:
Text File  |  2000-06-01  |  8.4 KB  |  232 lines

  1. on makeToadStoolField
  2.   global gDifficultyLevel, gGameSol, gNodeMap, gMasterMoves, gNumberOfMovesLeft, gFrogList, gGameState, gFrogNode
  3.   gNodeMap = field("nodes")
  4.   if gDifficultyLevel = 1 then
  5.     baseColour = random(6)
  6.   end if
  7.   gMasterMoves = "24,21,25,22,26,23,27,29,30,31,32,36,33,37,34,38,35,39"
  8.   myChoices = the number of items in gGameState
  9.   whichItem = random(myChoices)
  10.   whichPath = value(item whichItem of gGameState)
  11.   if myChoices > 1 then
  12.     delete item whichItem of gGameState
  13.   else
  14.     repeat with i = 1 to the number of lines in field "mazePaths"
  15.       put i into item i of gGameState
  16.     end repeat
  17.   end if
  18.   gGameSol = line whichPath of field "mazePaths"
  19.   FrogColour = value(item gNumberOfMovesLeft of gFrogList)
  20.   sprite(41).member = string(FrogColour) & "_frog_04.01"
  21.   sprite(50 + gNumberOfMovesLeft).locH = -200
  22.   puppetSound("splash")
  23.   case gDifficultyLevel of
  24.     1:
  25.       topColour = FrogColour
  26.       baseColour = random(6)
  27.       repeat while topColour = baseColour
  28.         baseColour = random(6)
  29.       end repeat
  30.       pathLength = the number of items in gGameSol
  31.       prevColour = FrogColour
  32.       repeat with i = 1 to pathLength
  33.         baseColour = random(6)
  34.         repeat while (baseColour = topColour) or (baseColour = prevColour)
  35.           baseColour = random(6)
  36.         end repeat
  37.         prevColour = baseColour
  38.         newStool = string(baseColour) & string(topColour) & "_stool"
  39.         whichSprite = value(item value(item i of gGameSol) of gMasterMoves)
  40.         sprite(whichSprite).myNextName = newStool
  41.       end repeat
  42.       theColour = topColour
  43.     2:
  44.       theColour = FrogColour
  45.       pathLength = the number of items in gGameSol
  46.       prevColour = FrogColour
  47.       repeat with i = 1 to pathLength
  48.         if random(20) > 5 then
  49.           topColour = FrogColour
  50.           baseColour = random(6)
  51.           repeat while (baseColour = topColour) or (baseColour = prevColour)
  52.             baseColour = random(6)
  53.           end repeat
  54.           prevColour = baseColour
  55.         else
  56.           baseColour = FrogColour
  57.           topColour = random(6)
  58.           repeat while (baseColour = topColour) or (topColour = prevColour)
  59.             topColour = random(6)
  60.           end repeat
  61.           prevColour = topColour
  62.         end if
  63.         newStool = string(baseColour) & string(topColour) & "_stool"
  64.         whichSprite = value(item value(item i of gGameSol) of gMasterMoves)
  65.         sprite(whichSprite).myNextName = newStool
  66.       end repeat
  67.       AllSpots = 1
  68.       repeat with i = 1 to pathLength
  69.         whichSprite = value(item value(item i of gGameSol) of gMasterMoves)
  70.         spotColour = char 2 of the myNextName of sprite(whichSprite)
  71.         if spotColour <> FrogColour then
  72.           AllSpots = 0
  73.           exit repeat
  74.         end if
  75.       end repeat
  76.       if AllSpots then
  77.         repeat with i = 1 to 2
  78.           whichStool = random(pathLength)
  79.           targetSprite = value(item value(item whichStool of gGameSol) of gMasterMoves)
  80.           newStool = sprite(targetSprite).myNextName
  81.           TEMP = char 2 of newStool
  82.           put char 1 of newStool into char 2 of newStool
  83.           put TEMP into char 1 of newStool
  84.           sprite(targetSprite).myNextName = newStool
  85.         end repeat
  86.       end if
  87.       AllBases = 1
  88.       repeat with i = 1 to pathLength
  89.         whichSprite = value(item value(item i of gGameSol) of gMasterMoves)
  90.         baseColour = char 1 of the myNextName of sprite(whichSprite)
  91.         if baseColour <> FrogColour then
  92.           AllBases = 0
  93.           exit repeat
  94.         end if
  95.       end repeat
  96.       if AllBases then
  97.         repeat with i = 1 to 2
  98.           whichStool = random(pathLength)
  99.           targetSprite = value(item value(item whichStool of gGameSol) of gMasterMoves)
  100.           newStool = sprite(targetSprite).myNextName
  101.           TEMP = char 2 of newStool
  102.           put char 1 of newStool into char 2 of newStool
  103.           put TEMP into char 1 of newStool
  104.           sprite(targetSprite).myNextName = newStool
  105.         end repeat
  106.       end if
  107.     3:
  108.       pathLength = the number of items in gGameSol
  109.       firstToadStoolSprite = value(item value(item 1 of gGameSol) of gMasterMoves)
  110.       FirstStool = char 1 to 2 of the name of the member of sprite(firstToadStoolSprite)
  111.       if not (FirstStool contains string(FrogColour)) then
  112.         if random(10) > 5 then
  113.           put string(FrogColour) into char 1 of FirstStool
  114.         else
  115.           put string(FrogColour) into char 2 of FirstStool
  116.         end if
  117.         sprite(firstToadStoolSprite).myNextName = FirstStool & "_stool"
  118.       end if
  119.       repeat with i = 2 to pathLength
  120.         thePrevSprite = value(item value(item i - 1 of gGameSol) of gMasterMoves)
  121.         if random(10) > 5 then
  122.           theCommonColour = char 1 of the myNextName of sprite(thePrevSprite)
  123.           theotherColour = char 2 of the myNextName of sprite(thePrevSprite)
  124.         else
  125.           theCommonColour = char 2 of the myNextName of sprite(thePrevSprite)
  126.           theotherColour = char 1 of the myNextName of sprite(thePrevSprite)
  127.         end if
  128.         if random(10) > 5 then
  129.           topColour = theCommonColour
  130.           baseColour = random(6)
  131.           repeat while (baseColour = topColour) or (baseColour = theotherColour)
  132.             baseColour = random(6)
  133.           end repeat
  134.         else
  135.           baseColour = theCommonColour
  136.           topColour = random(6)
  137.           repeat while (baseColour = topColour) or (topColour = theotherColour)
  138.             topColour = random(6)
  139.           end repeat
  140.         end if
  141.         newStool = string(baseColour) & string(topColour) & "_stool"
  142.         whichSprite = value(item value(item i of gGameSol) of gMasterMoves)
  143.         sprite(whichSprite).myNextName = newStool
  144.       end repeat
  145.   end case
  146.   repeat with i = 21 to 38
  147.     if not (i = 28) then
  148.       notOnthePath = 1
  149.       repeat with j = 1 to the number of items in gGameSol
  150.         if string(i) = item value(item j of gGameSol) of gMasterMoves then
  151.           notOnthePath = 0
  152.           exit repeat
  153.         end if
  154.       end repeat
  155.       if notOnthePath then
  156.         oddTColour = random(6)
  157.         repeat while oddTColour = theColour
  158.           oddTColour = random(6)
  159.         end repeat
  160.         oddBColour = random(6)
  161.         repeat while (oddBColour = theColour) or (oddBColour = oddTColour)
  162.           oddBColour = random(6)
  163.         end repeat
  164.         newStool = string(oddBColour) & string(oddTColour) & "_stool"
  165.         sprite(i).myNextName = newStool
  166.         updateStage()
  167.       end if
  168.     end if
  169.   end repeat
  170.   startNodeList = "1,8,11"
  171.   startNode = item 1 of gGameSol
  172.   repeat with i = 1 to 3
  173.     if item i of startNodeList <> startNode then
  174.       whichNodeSprite = value(item value(item i of startNodeList) of gMasterMoves)
  175.       theStoolColours = char 1 to 2 of the myNextName of sprite(whichNodeSprite)
  176.       if theStoolColours contains string(FrogColour) then
  177.         choices = "123456"
  178.         delete char FrogColour of choices
  179.         whichBase = random(5)
  180.         baseColour = char whichBase of choices
  181.         delete char whichBase of choices
  182.         topColour = char random(4) of choices
  183.         sprite(whichNodeSprite).myNextName = baseColour & topColour & "_stool"
  184.       end if
  185.     end if
  186.   end repeat
  187.   gFrogNode = 0
  188.   repeat with i = 20 to 40
  189.     set the cursor of sprite i to 0
  190.   end repeat
  191.   if the frame < label("glinda_demo") then
  192.     set the cursor of sprite 24 to 280
  193.     set the cursor of sprite 29 to 280
  194.     set the cursor of sprite 32 to 280
  195.   end if
  196.   sprite(41).startH = sprite(28).locH - 85
  197.   sprite(41).startV = sprite(28).locV - 5
  198.   sprite(41).finH = sprite(28).locH - 8
  199.   sprite(41).finV = sprite(41).startV - 15
  200.   sprite(41).stepNo = 1
  201. end
  202.  
  203. on changeFrog
  204.   global gFrogNode, gGameSol, gMasterMoves, gFrameCounter
  205.   if gFrogNode = 0 then
  206.     whichSprite = value(item value(item 1 of gGameSol) of gMasterMoves)
  207.     colourSet = char 1 to 2 of the myNextName of sprite(whichSprite)
  208.   else
  209.     whichSprite = value(item gFrogNode of gMasterMoves)
  210.     colourSet = char 1 to 2 of the name of the member of sprite(whichSprite)
  211.   end if
  212.   FrogColour = char 1 of the name of the member of sprite(41)
  213.   if FrogColour = char 1 of colourSet then
  214.     FrogColour = char 2 of colourSet
  215.   else
  216.     FrogColour = char 1 of colourSet
  217.   end if
  218.   theFrog = sprite(41).member.name
  219.   put FrogColour into char 1 of theFrog
  220.   sprite(41).member = theFrog
  221.   gFrameCounter = 0
  222. end
  223.  
  224. on CheckFrog
  225.   global gFrameCounter, gDifficultyLevel, gFrogNode
  226.   if gFrogNode > 0 then
  227.     if (gDifficultyLevel = 3) and (gFrameCounter > 80) then
  228.       changeFrog()
  229.     end if
  230.   end if
  231. end
  232.