home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / devglry / ingenius / shockwav / quest.dcr / 00004.ls < prev    next >
Encoding:
Text File  |  1996-05-10  |  4.0 KB  |  170 lines

  1. on init
  2.   global pillarname, olds, guyX, guyY, gActText, lastset
  3.   set pillarname to "pillar"
  4.   cleanText()
  5.   initWords()
  6.   set olds to 0
  7.   set guyX to 3
  8.   set guyY to 0
  9. end
  10.  
  11. on ReturnFromWhereEver
  12.   halt()
  13. end
  14.  
  15. on getPart lin, group, part
  16.   global gActText
  17.   set result to line lin of gActText
  18.   set the itemDelimiter to "|"
  19.   set result to item group of result
  20.   set the itemDelimiter to ","
  21.   set result to item part of result
  22.   return result
  23. end
  24.  
  25. on cleanText
  26.   global gActText
  27.   repeat with i = length(gActText) down to 1
  28.     if charToNum(char i of gActText) < 32 then
  29.       if char i of gActText <> RETURN then
  30.         delete char i of gActText
  31.       end if
  32.     end if
  33.   end repeat
  34. end
  35.  
  36. on initWords
  37.   global gActText, wordList, checkList
  38.   set wordList to []
  39.   set checkList to []
  40.   set the itemDelimiter to ","
  41.   set goodWords to line 6 of gActText
  42.   set badWords to line 7 of gActText
  43.   put line 5 of gActText into field "instr"
  44.   put line 5 of gActText into field "instr2"
  45.   set n1 to the number of items in goodWords
  46.   set n2 to the number of items in badWords
  47.   repeat with x = 1 to 5
  48.     repeat with y = 1 to 7
  49.       set w to item random(n2) of badWords
  50.       if (y = 1) and ((x = 1) or (x = 5)) then
  51.         set w to EMPTY
  52.       end if
  53.       addAt(wordList, ((x - 1) * 7) + y, w)
  54.       addAt(checkList, ((x - 1) * 7) + y, 0)
  55.     end repeat
  56.   end repeat
  57.   set x to 3
  58.   set y to 0
  59.   repeat while y < 7
  60.     set w to EMPTY
  61.     if the number of items in goodWords > length(goodWords) then
  62.       set goodWords to line 6 of gActText
  63.     end if
  64.     repeat while w = EMPTY
  65.       set r to random(n1)
  66.       set w to item r of goodWords
  67.       put EMPTY into item r of goodWords
  68.     end repeat
  69.     if x = 1 then
  70.       set r to min(max(random(3) - 1, -1), 1)
  71.     else
  72.       if x = 5 then
  73.         set r to min(max(random(3) - 3, -1), 1)
  74.       else
  75.         set r to min(max(random(5) - 3, -1), 1)
  76.       end if
  77.     end if
  78.     if (r = 0) or (y = 0) or (random(5) > 1) then
  79.       set y to y + 1
  80.     end if
  81.     set x to x + r
  82.     if (y = 1) and (x = 1) then
  83.       set x to 2
  84.     end if
  85.     if (y = 1) and (x = 5) then
  86.       set x to 4
  87.     end if
  88.     setAt(wordList, ((x - 1) * 7) + y, w)
  89.     setAt(checkList, ((x - 1) * 7) + y, 1)
  90.   end repeat
  91. end
  92.  
  93. on getWord x, y
  94.   global wordList
  95.   return getAt(wordList, ((x - 1) * 7) + y)
  96. end
  97.  
  98. on getCheck x, y
  99.   global checkList
  100.   return getAt(checkList, ((x - 1) * 7) + y)
  101. end
  102.  
  103. on spreadem
  104.   global pillarname
  105.   repeat with n = 4 to 38
  106.     puppetSprite(n, 1)
  107.     set the stretch of sprite n to 1
  108.   end repeat
  109.   set the stretch of sprite 41 to 1
  110.   repeat with i = 0 to 6
  111.     repeat with j = 0 to 4
  112.       set n to 38 - (i * 5) - j
  113.       if getWord(j + 1, i + 1) <> EMPTY then
  114.         set the castNum of sprite n to the number of cast (pillarname & string(random(2)))
  115.         placeit(n, j + 1, i + 1)
  116.         set the locH of sprite n to the locH of sprite n - 3 + random(7)
  117.         set the locV of sprite n to the locV of sprite n - 3 + random(7)
  118.         next repeat
  119.       end if
  120.       set the castNum of sprite n to 0
  121.     end repeat
  122.     puppetTransition(4, 1, 10, 1)
  123.     puppetSound("slam.wav")
  124.     updateStage()
  125.   end repeat
  126.   puppetTransition(0)
  127. end
  128.  
  129. on placeit n, x, y
  130.   set the rect of sprite n to getcoord(n, x, y)
  131. end
  132.  
  133. on getcoord n, x, y
  134.   set cn to the castNum of sprite n
  135.   set w to the width of cast cn
  136.   set h to the height of cast cn
  137.   set rx to the locH of the regPoint of cast cn
  138.   set ry to the locV of the regPoint of cast cn
  139.   set x to x - 3
  140.   set s to (100 - (y * 6.5)) * 0.01
  141.   set s2 to (100 - (y * 4)) * 0.01
  142.   set rx to rx * s
  143.   set ry to ry * s
  144.   set x1 to integer(200 + (x * (85 * s)) - rx)
  145.   set x2 to integer(x1 + (w * s))
  146.   set y1 to 250 - (y * 33 * s2) - ry
  147.   set y2 to y1 + (h * s)
  148.   return rect(x1, y1, x2, y2)
  149. end
  150.  
  151. on placeguy x, y
  152.   placeit(41, x, y)
  153.   updateStage()
  154. end
  155.  
  156. on chart
  157.   set text to RETURN
  158.   repeat with y = 1 to 7
  159.     repeat with x = 1 to 5
  160.       if getCheck(x, 8 - y) then
  161.         put char 1 of getWord(x, 8 - y) after text
  162.         next repeat
  163.       end if
  164.       put "-" after text
  165.     end repeat
  166.     put RETURN after text
  167.   end repeat
  168.   put text
  169. end
  170.