home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / FishingHole.dxr / 00008_FishScript.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  6.6 KB  |  235 lines

  1. property pPattern, pOriginalPoint, pCurrentPoint, pFishSize, pBaitAttraction, pDestPoint, pNumPoints, pAngle, spriteNum, pAverageSpeed, pSpeed, pRestTime, pRestCount, pRestTicks, pCaught, pState, pStruggleLeft, pDifference, pFrame, pFishName, pFrameTimer, pFishDead
  2. global pLaunchHook, gPattern, gFishCaught, gSpriteCaught, gFishFollowingBait
  3.  
  4. on beginSprite me
  5.   gFishFollowingBait = 0
  6.   gFishCaught = 0
  7.   pFrameTimer = the ticks
  8.   pFrame = 1
  9.   pDifference = 0
  10.   pStruggleLeft = 1
  11.   pCaught = 0
  12.   pRestTime = 0
  13.   pRestCount = 0
  14.   pPattern = duplicate(gPattern)
  15.   pAverageSpeed = 2
  16.   pSpeed = pAverageSpeed
  17.   pNumPoints = count(gPattern)
  18.   pDestPoint = random(pNumPoints)
  19.   pOriginalPoint = point(sprite(spriteNum).locH, sprite(spriteNum).locV)
  20.   pCurrentPoint = point(pOriginalPoint[1], pOriginalPoint[2])
  21.   relocatePattern()
  22.   pAngle = getAngle(pCurrentPoint, pPattern[pDestPoint])
  23.   sprite(spriteNum).rotation = 360 - pAngle
  24.   pRestTicks = the ticks
  25.   if random(4) = 1 then
  26.     pRestTime = random(10) + 5
  27.     pRestCount = 0
  28.   end if
  29.   pState = 1
  30. end
  31.  
  32. on reinitFish me
  33.   sprite(spriteNum).member = "fish_2"
  34.   sprite(spriteNum).loc = pOriginalPoint
  35.   pCurrentPoint = pOriginalPoint
  36.   sprite(spriteNum).blend = 40
  37.   updateStage()
  38.   gFishFollowingBait = 0
  39.   gFishCaught = 0
  40.   pDifference = 0
  41.   pStruggleLeft = 1
  42.   pCaught = 0
  43.   pRestTime = 0
  44.   pRestCount = 0
  45.   pPattern = duplicate(gPattern)
  46.   pAverageSpeed = 2
  47.   pSpeed = pAverageSpeed
  48.   pNumPoints = count(gPattern)
  49.   pDestPoint = random(pNumPoints)
  50.   relocatePattern()
  51.   pAngle = getAngle(pCurrentPoint, pPattern[pDestPoint])
  52.   sprite(spriteNum).rotation = 360 - pAngle
  53.   if random(4) = 1 then
  54.     pRestTime = random(10) + 5
  55.     pRestCount = 0
  56.   end if
  57.   pState = 1
  58. end
  59.  
  60. on exitFrame me
  61.   if the frame > 2 then
  62.     exit
  63.   end if
  64.   if pFishDead = 1 then
  65.     sprite(spriteNum).loc = point(800, 800)
  66.     sprite(spriteNum).member = "fish_2"
  67.     exit
  68.   end if
  69.   if sprite(spriteNum).blend = 0 then
  70.     gFishCaught = 0
  71.     pCaught = 0
  72.     pFishDead = 1
  73.   end if
  74.   case pState of
  75.     1:
  76.       goAboutNormalBusiness()
  77.     2:
  78.       followBait()
  79.     3:
  80.       eatBait()
  81.     4:
  82.       goBackToOrinalPos()
  83.   end case
  84. end
  85.  
  86. on followBait me
  87.   if pLaunchHook = 1 then
  88.     exit
  89.   end if
  90.   if getDistance(pCurrentPoint, point(sprite(25).locH, sprite(25).locV)) < 50 then
  91.     pSpeed = pSpeed - 0.29999999999999999
  92.     if pSpeed < 0 then
  93.       pSpeed = 0
  94.     end if
  95.   else
  96.     if (pFrameTimer + 5) < the ticks then
  97.       pFrameTimer = the ticks
  98.       pFrame = pFrame + 1
  99.       if pFrame > 4 then
  100.         pFrame = 1
  101.       end if
  102.       sprite(spriteNum).member = "fish_" & string(pFrame)
  103.     end if
  104.     if pSpeed < pAverageSpeed then
  105.       pSpeed = pSpeed + 0.29999999999999999
  106.     end if
  107.     pAngle = getAngle(pCurrentPoint, point(sprite(25).locH, sprite(25).locV))
  108.     sprite(spriteNum).rotation = 360 - pAngle
  109.   end if
  110.   pCurrentPoint[1] = pCurrentPoint[1] - (float(sin(pAngle * 3.14000000000000012 / 180.0)) * pSpeed)
  111.   pCurrentPoint[2] = pCurrentPoint[2] - (float(cos(pAngle * 3.14000000000000012 / 180.0)) * pSpeed)
  112.   sprite(spriteNum).loc = pCurrentPoint
  113.   if (getDistance(pCurrentPoint, point(sprite(25).locH, sprite(25).locV)) > 100) or (sprite(25).blend = 0) then
  114.     if pCaught = 0 then
  115.       gFishFollowingBait = gFishFollowingBait - 1
  116.       if gFishFollowingBait < 0 then
  117.         gFishFollowingBait = 0
  118.       end if
  119.       pState = 1
  120.       pAngle = getAngle(pCurrentPoint, pPattern[pDestPoint])
  121.       sprite(spriteNum).rotation = 360 - pAngle
  122.     end if
  123.   end if
  124.   if (getDistance(pCurrentPoint, pOriginalPoint) > 200) and (sprite(25).blend > 0) and (pLaunchHook = 0) then
  125.     sprite(spriteNum).member = "FishCaught1"
  126.     gFishCaught = 1
  127.     gSpriteCaught = spriteNum
  128.     pAngle = getAngle(pCurrentPoint, point(sprite(60).locH, sprite(60).locV))
  129.     pCaught = 1
  130.     pState = 3
  131.     pCurrentPoint = point(sprite(25).locH, sprite(25).locV)
  132.     sprite(25).blend = 0
  133.   end if
  134. end
  135.  
  136. on eatBait me
  137.   sprite(spriteNum).loc = sprite(25).loc
  138.   if (pFrameTimer + 5) < the ticks then
  139.     pFrameTimer = the ticks
  140.     pFrame = pFrame + 1
  141.     if pFrame > 4 then
  142.       pFrame = 1
  143.     end if
  144.     sprite(spriteNum).member = "FishCaught" & string(pFrame)
  145.   end if
  146.   if pStruggleLeft = 1 then
  147.     pAngle = pAngle - 10
  148.     if pAngle < 0 then
  149.       pAngle = 359
  150.     end if
  151.     pDifference = pDifference + 10
  152.     if pDifference > (random(20) + 20) then
  153.       pStruggleLeft = 0
  154.       pDifference = 0
  155.     end if
  156.   else
  157.     pAngle = pAngle + 10
  158.     if pAngle > 360 then
  159.       pAngle = 0
  160.     end if
  161.     pDifference = pDifference + 10
  162.     if pDifference > (random(20) + 20) then
  163.       pStruggleLeft = 1
  164.       pDifference = 0
  165.     end if
  166.   end if
  167.   sprite(spriteNum).rotation = 360 - pAngle
  168. end
  169.  
  170. on goBackToOrinalPos me
  171. end
  172.  
  173. on goAboutNormalBusiness me
  174.   if getDistance(pCurrentPoint, point(sprite(25).locH, sprite(25).locV)) < 60 then
  175.     if gFishFollowingBait <= 1 then
  176.       if sprite(25).blend > 0 then
  177.         gFishFollowingBait = gFishFollowingBait + 1
  178.         pState = 2
  179.         exit
  180.       end if
  181.     end if
  182.   end if
  183.   if pRestTime > 0 then
  184.     pSpeed = pSpeed - 0.10000000000000001
  185.     if pSpeed < 0 then
  186.       pSpeed = 0
  187.     end if
  188.     if (pRestTicks + 60) < the ticks then
  189.       pRestTicks = the ticks
  190.       pRestCount = pRestCount + 1
  191.     end if
  192.     if pRestCount >= pRestTime then
  193.       pRestTime = 0
  194.       pRestCount = 0
  195.     end if
  196.   else
  197.     if (pFrameTimer + 5) < the ticks then
  198.       pFrameTimer = the ticks
  199.       pFrame = pFrame + 1
  200.       if pFrame > 4 then
  201.         pFrame = 1
  202.       end if
  203.       sprite(spriteNum).member = "fish_" & string(pFrame)
  204.     end if
  205.     pSpeed = pSpeed + 0.29999999999999999
  206.     if pSpeed > pAverageSpeed then
  207.       pSpeed = pAverageSpeed
  208.     end if
  209.   end if
  210.   pCurrentPoint[1] = pCurrentPoint[1] - (float(sin(pAngle * 3.14000000000000012 / 180.0)) * pSpeed)
  211.   pCurrentPoint[2] = pCurrentPoint[2] - (float(cos(pAngle * 3.14000000000000012 / 180.0)) * pSpeed)
  212.   if (pCurrentPoint[1] > (pPattern[pDestPoint][1] - 7)) and (pCurrentPoint[1] < (pPattern[pDestPoint][1] + 7)) and (pCurrentPoint[2] > (pPattern[pDestPoint][2] - 7)) and (pCurrentPoint[2] < (pPattern[pDestPoint][2] + 7)) then
  213.     if random(4) = 1 then
  214.       pFrame = 2
  215.       sprite(spriteNum).member = "fish_" & string(pFrame)
  216.       pRestTime = random(10) + 5
  217.       pRestCount = 0
  218.     end if
  219.     pDestPoint = pDestPoint + 1
  220.     if pDestPoint > pNumPoints then
  221.       pDestPoint = 1
  222.     end if
  223.     pAngle = getAngle(pCurrentPoint, pPattern[pDestPoint])
  224.     sprite(spriteNum).rotation = 360 - pAngle
  225.   end if
  226.   sprite(spriteNum).loc = pCurrentPoint
  227. end
  228.  
  229. on relocatePattern me
  230.   repeat with counter = 1 to count(pPattern)
  231.     pPattern[counter][1] = pPattern[counter][1] + pOriginalPoint[1] - 92
  232.     pPattern[counter][2] = pPattern[counter][2] + pOriginalPoint[2] - 74
  233.   end repeat
  234. end
  235.