home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Labyrinth.dxr / 00005_EnemyScript.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  9.0 KB  |  278 lines

  1. property pDirection, pMovementSpeed, pFrameNumber, pAnimationSpeed, pEnemyAlert, pPositionX, pPositionY, pEnemyChannel, pDestDirection, pAlertTime, pInalertTime, pYDelta, pXDelta, pDefaultSpeed, pCounter, pCheckTurn, pCharacterName, pState, pMaxFrameNumer, pDoDeath, pTeleport, pBiggerBomb, pDoingTeleport, pJustABool, pHealth, pEneRect, pFakeHalfWidth, pFakeHalfHeight, pSpriteHalfWidth, pSpriteHalfHeight
  2. global gMapChannel, pEneBombList, gCurrentLevel
  3.  
  4. on new me, enemyDirection, enemySpeed, animationSpeed, posX, posY, characterName, enemyChannel
  5.   pFakeHalfWidth = sprite(12).width / 2
  6.   pFakeHalfHeight = sprite(12).height / 2
  7.   pDoingTeleport = 0
  8.   pJustABool = 1
  9.   pCharacterName = characterName
  10.   pCounter = 0
  11.   pYDelta = 0
  12.   pXDelta = 0
  13.   pAlertTime = 0
  14.   pInalertTime = 0
  15.   pDirection = enemyDirection
  16.   pEneBombList = [0, 0]
  17.   pMovementSpeed = enemySpeed
  18.   pDoDeath = 0
  19.   pAnimationSpeed = animationSpeed
  20.   pEnemyChannel = enemyChannel
  21.   pEnemyAlert = 1
  22.   pPositionX = posX
  23.   pPositionY = posY
  24.   pFrameNumber = 1
  25.   sprite(pEnemyChannel).puppet = 1
  26.   sprite(pEnemyChannel).member = "Enemy"
  27.   sprite(pEnemyChannel).locH = pPositionX
  28.   sprite(pEnemyChannel).locV = pPositionY
  29.   sprite(pEnemyChannel).ink = 36
  30.   sprite(pEnemyChannel).blend = 100
  31.   setEnemyDirection(me, pDirection)
  32.   pMaxFrameNumer = 4
  33.   pHealth = 48
  34.   updateStage()
  35.   pSpriteHalfWidth = sprite(12).width / 2
  36.   pSpriteHalfHeight = sprite(12).height / 2
  37.   return me
  38. end
  39.  
  40. on setEnemyChannel enemyChannel
  41.   sprite(pEnemyChannel).puppet = 0
  42.   sprite(enemyChannel).puppet = 1
  43.   sprite(enemyChannel).member = "Enemy"
  44.   sprite(enemyChannel).locH = pPositionX
  45.   sprite(enemyChannel).locV = pPositionY
  46.   sprite(enemyChannel).backColor = 6
  47.   sprite(enemyChannel).ink = 36
  48.   pEnemyChannel = enemyChannel
  49. end
  50.  
  51. on getEnemyChannel me
  52.   return pEnemyChannel
  53. end
  54.  
  55. on nextAnimation me
  56. end
  57.  
  58. on moveEnemy me
  59.   case pDirection of
  60.     1:
  61.       pPositionY = pPositionY - pMovementSpeed
  62.       pYDelta = pYDelta + pMovementSpeed
  63.     2:
  64.       pPositionX = pPositionX + pMovementSpeed
  65.       pXDelta = pXDelta + pMovementSpeed
  66.     3:
  67.       pPositionY = pPositionY + pMovementSpeed
  68.       pYDelta = pYDelta + pMovementSpeed
  69.     4:
  70.       pPositionX = pPositionX - pMovementSpeed
  71.       pXDelta = pXDelta + pMovementSpeed
  72.   end case
  73.   pEneRect = rect(pPositionX - pSpriteHalfWidth, pPositionY - pSpriteHalfHeight, pPositionX + pSpriteHalfWidth, pPositionY + pSpriteHalfHeight)
  74.   if thisIsMYIntersectionFunctionBitch(pEneRect, 7) = 1 then
  75.     case pDirection of
  76.       1:
  77.         pPositionY = pPositionY + pMovementSpeed
  78.         pYDelta = pYDelta - pMovementSpeed
  79.       2:
  80.         pPositionX = pPositionX - pMovementSpeed
  81.         pXDelta = pXDelta - pMovementSpeed
  82.       3:
  83.         pPositionY = pPositionY - pMovementSpeed
  84.         pYDelta = pXDelta - pMovementSpeed
  85.       4:
  86.         pPositionX = pPositionX + pMovementSpeed
  87.         pXDelta = pXDelta - pMovementSpeed
  88.     end case
  89.   end if
  90.   if thisIsMYIntersectionFunctionBitch(pEneRect, 7) = 1 then
  91.     switchDirection()
  92.   end if
  93.   sprite(pEnemyChannel).loc = point(pPositionX, pPositionY)
  94. end
  95.  
  96. on setEnemyPosition me, posX, posY
  97.   pPositionX = posX
  98.   pPositionY = posY
  99.   sprite(pEnemyChannel).locH = pPositionX
  100.   sprite(pEnemyChannel).locV = pPositionY
  101. end
  102.  
  103. on getEnemyPositionX me
  104.   return pPositionX
  105. end
  106.  
  107. on getEnemyPositionY me
  108.   return pPositionY
  109. end
  110.  
  111. on setEnemyDirection me, enemyDirection
  112.   pDirection = enemyDirection
  113. end
  114.  
  115. on getEnemyDirection me
  116.   return pDirection
  117. end
  118.  
  119. on switchDirection me
  120.   orgX = sprite(pEnemyChannel).locH
  121.   orgY = sprite(pEnemyChannel).locV
  122.   aPosX = orgX
  123.   aPosY = orgY
  124.   theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  125.   case pDirection of
  126.     1:
  127.       if random(2) = 1 then
  128.         aPosX = aPosX + 10
  129.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  130.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  131.           aPosX = orgX
  132.           aPosY = orgY
  133.           aPosX = aPosX - 10
  134.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  135.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  136.             directionNum = 3
  137.           else
  138.             directionNum = 4
  139.           end if
  140.         else
  141.           directionNum = 2
  142.         end if
  143.       else
  144.         aPosX = aPosX - 10
  145.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  146.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  147.           aPosX = orgX
  148.           aPosY = orgY
  149.           aPosX = aPosX + 10
  150.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  151.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  152.             directionNum = 3
  153.           else
  154.             directionNum = 2
  155.           end if
  156.         else
  157.           directionNum = 4
  158.         end if
  159.       end if
  160.     2:
  161.       if random(2) = 1 then
  162.         aPosY = aPosY + 10
  163.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  164.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  165.           aPosX = orgX
  166.           aPosY = orgY
  167.           aPosY = aPosY - 10
  168.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  169.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  170.             directionNum = 4
  171.           else
  172.             directionNum = 1
  173.           end if
  174.         else
  175.           directionNum = 3
  176.         end if
  177.       else
  178.         aPosY = aPosY - 10
  179.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  180.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  181.           aPosX = orgX
  182.           aPosY = orgY
  183.           aPosY = aPosY + 10
  184.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  185.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  186.             directionNum = 4
  187.           else
  188.             directionNum = 3
  189.           end if
  190.         else
  191.           directionNum = 1
  192.         end if
  193.       end if
  194.     3:
  195.       if random(2) = 1 then
  196.         aPosX = aPosX + 10
  197.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  198.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  199.           aPosX = orgX
  200.           aPosY = orgY
  201.           aPosX = aPosX - 10
  202.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  203.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  204.             directionNum = 1
  205.           else
  206.             directionNum = 4
  207.           end if
  208.         else
  209.           directionNum = 2
  210.         end if
  211.       else
  212.         aPosX = aPosX - 10
  213.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  214.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  215.           aPosX = orgX
  216.           aPosY = orgY
  217.           aPosX = aPosX + 10
  218.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  219.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  220.             directionNum = 1
  221.           else
  222.             directionNum = 2
  223.           end if
  224.         else
  225.           directionNum = 4
  226.         end if
  227.       end if
  228.     4:
  229.       if random(2) = 1 then
  230.         aPosY = aPosY + 10
  231.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  232.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  233.           aPosX = orgX
  234.           aPosY = orgY
  235.           aPosY = aPosY - 10
  236.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  237.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  238.             directionNum = 2
  239.           else
  240.             directionNum = 1
  241.           end if
  242.         else
  243.           directionNum = 3
  244.         end if
  245.       else
  246.         aPosY = aPosY - 10
  247.         theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  248.         if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  249.           aPosX = orgX
  250.           aPosY = orgY
  251.           aPosY = aPosY + 10
  252.           theRect = rect(aPosX - pFakeHalfWidth, aPosY - pFakeHalfHeight, aPosX + pFakeHalfWidth, aPosY - pFakeHalfHeight)
  253.           if thisIsMYIntersectionFunctionBitch(theRect, 7) then
  254.             directionNum = 2
  255.           else
  256.             directionNum = 3
  257.           end if
  258.         else
  259.           directionNum = 1
  260.         end if
  261.       end if
  262.   end case
  263.   setEnemyDirection(me, directionNum)
  264. end
  265.  
  266. on doDeathAnimation me
  267.   if sprite(pEnemyChannel).blend < 5 then
  268.     if gCurrentLevel >= 4 then
  269.       puppetSound(3, "win10")
  270.       go(24)
  271.     else
  272.       go(44)
  273.       exit
  274.     end if
  275.   end if
  276.   sprite(pEnemyChannel).blend = sprite(pEnemyChannel).blend - 2
  277. end
  278.