home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / MachineWar.dxr / 00004_AntScript.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  6.5 KB  |  267 lines

  1. property pAngle, pMovementSpeed, pAnimationSpeed, pPositionX, pPositionY, pSpriteName, pAntChannel, pHealth, pMaxHealth, pFakeChannel, pMaxFrameNumber, pDoDeath, pDoShooting, pPlayerDisabled, pEnergy, pDestPositionX, pDestPositionY, pState, pMoving, pTempX, pTempY, pACounter, pBCounter, pATimer, pReadyTaLaunch, pDaPath, pPathFind, pCurrentNode, pPray, pObjectif, pIsHoldingObject, pStundTime, pCurrentFrame, pCannonAngle, pMaxSpeed
  2. global gCurrentLevel, gPlayer1, gPlayer2, gPlayer3, gEnemy1, gEnemy2, gEnemy3, gBombList, gTotalHealth, gTotalScore, gFlagSeised
  3.  
  4. on new me, antDirection, antSpeed, animationSpeed, posX, posY, spriteName, antChannel
  5.   pMaxSpeed = 5
  6.   pCannonAngle = 0
  7.   pAngle = 0
  8.   pCurrentFrame = 1
  9.   pObjectif = 1
  10.   pIsHoldingObject = 0
  11.   pMoving = 0
  12.   pDirection = antDirection
  13.   pMovementSpeed = antSpeed
  14.   pAnimationSpeed = animationSpeed
  15.   pPositionX = posX
  16.   pPositionY = posY
  17.   pTempX = posX
  18.   pTempY = posY
  19.   pSpriteName = spriteName
  20.   pAntChannel = antChannel
  21.   pHealth = 50
  22.   pMaxHealth = 50
  23.   pFakeChannel = 15
  24.   pMaxFrameNumber = 1
  25.   pDoDeath = 0
  26.   pPlayerDisabled = 0
  27.   pEnergy = 0
  28.   pDestPositionX = posX
  29.   pDestPositionY = posY
  30.   pSelected = 0
  31.   pPray = 0
  32.   pState = 1
  33.   pATimer = the ticks
  34.   pReadyTaLaunch = 0
  35.   pPathFind = 0
  36.   sprite(pAntChannel).loc = point(pPositionX, pPositionY)
  37.   sprite(62).rotation = pCannonAngle
  38.   pACounter = 0
  39.   pBCounter = 0
  40.   return me
  41. end
  42.  
  43. on setSpeed me, theSpeed
  44.   pMovementSpeed = theSpeed
  45.   if pMovementSpeed > pMaxSpeed then
  46.     pMovementSpeed = pMaxSpeed
  47.   end if
  48.   if pMovementSpeed < 0 then
  49.     pMovementSpeed = 0
  50.   end if
  51. end
  52.  
  53. on setAngle me, theAngle
  54.   if pState = 6 then
  55.     exit
  56.   end if
  57.   if theAngle > 359 then
  58.     theAngle = 0
  59.   end if
  60.   if theAngle < 0 then
  61.     theAngle = 359
  62.   end if
  63.   pAngle = theAngle
  64.   sprite(pAntChannel).rotation = 360 - pAngle
  65. end
  66.  
  67. on getAntChannel me
  68.   return pAntChannel
  69. end
  70.  
  71. on moveAnt me
  72.   howDeep = spriteColision(sprite(pAntChannel).rect, 1)
  73.   if howDeep = 2 then
  74.     pMaxSpeed = 1
  75.   else
  76.     if howDeep = 1 then
  77.       pMaxSpeed = 3
  78.     else
  79.       pMaxSpeed = 5
  80.     end if
  81.   end if
  82.   if pMovementSpeed > pMaxSpeed then
  83.     pMovementSpeed = pMaxSpeed
  84.   end if
  85.   if pState = 6 then
  86.     pIsHoldingFlag = 0
  87.     gFlagSeized = 0
  88.     doStund()
  89.     exit
  90.   end if
  91.   if pIsHoldingObject = 1 then
  92.     sprite(20).loc = sprite(pAntChannel).loc
  93.   end if
  94.   if pState = 3 then
  95.     exit
  96.   end if
  97.   pTempX = pPositionX
  98.   pTempY = pPositionY
  99.   difX = float(sin(pAngle * 3.14000000000000012 / 180)) * pMovementSpeed
  100.   difY = float(cos(pAngle * 3.14000000000000012 / 180)) * pMovementSpeed
  101.   pPositionX = pPositionX - difX
  102.   pPositionY = pPositionY - difY
  103.   if pPositionX < 10 then
  104.     pPositionX = 10
  105.   end if
  106.   if pPositionX > 570 then
  107.     pPositionX = 570
  108.   end if
  109.   if pPositionY < 10 then
  110.     pPositionY = 10
  111.   end if
  112.   if pPositionY > 430 then
  113.     pPositionY = 430
  114.   end if
  115.   if the ticks > (pATimer + 1) then
  116.     pATimer = the ticks
  117.     pCurrentFrame = pCurrentFrame + 1
  118.     if pCurrentFrame > pMaxFrameNumber then
  119.       pCurrentFrame = 1
  120.     end if
  121.     sprite(pAntChannel).member = pSpriteName & "_" & string(pCurrentFrame)
  122.   end if
  123.   if (pAntChannel = 50) or (pAntChannel = 51) or (pAntChannel = 52) then
  124.     sprite(13).loc = point(pPositionX, pPositionY)
  125.     updateStage()
  126.     if (sprite(13).intersects(7) = 1) or (sprite(13).intersects(8) = 1) then
  127.       pPositionX = pPositionX + difX
  128.       sprite(13).loc = point(pPositionX, pPositionY)
  129.       updateStage()
  130.       if (sprite(13).intersects(7) = 1) or (sprite(13).intersects(8) = 1) then
  131.         pPositionX = pPositionX - difX
  132.         pPositionY = pPositionY + difY
  133.         sprite(13).loc = point(pPositionX, pPositionY)
  134.         updateStage()
  135.         if (sprite(13).intersects(7) = 1) or (sprite(13).intersects(8) = 1) then
  136.           pPositionX = pTempX
  137.           pPositionY = pTempY
  138.         end if
  139.       end if
  140.     end if
  141.   end if
  142.   sprite(pAntChannel).loc = point(pPositionX, pPositionY)
  143.   sprite(62).loc = point(pPositionX + (float(sin(pAngle * 3.14000000000000012 / 180)) * 9), pPositionY + (float(cos(pAngle * 3.14000000000000012 / 180)) * 9))
  144.   whatAngle = 360 - getAngle(pPositionX, pPositionY, mouseH(), mouseV())
  145.   difference = abs(pCannonAngle - whatAngle)
  146.   if difference > 180 then
  147.     difference = 360 - difference
  148.   end if
  149.   if difference > 10 then
  150.     if pCannonAngle <= 180 then
  151.       if (whatAngle > pCannonAngle) and (whatAngle < (pCannonAngle + 180)) then
  152.         pCannonAngle = pCannonAngle + 7
  153.       else
  154.         pCannonAngle = pCannonAngle - 7
  155.       end if
  156.     else
  157.       if (whatAngle < pCannonAngle) and (whatAngle > (pCannonAngle - 180)) then
  158.         pCannonAngle = pCannonAngle - 7
  159.       else
  160.         pCannonAngle = pCannonAngle + 7
  161.       end if
  162.     end if
  163.     if pCannonAngle < 0 then
  164.       pCannonAngle = 359
  165.     end if
  166.     if pCannonAngle >= 360 then
  167.       pCannonAngle = 0
  168.     end if
  169.   else
  170.     pCannonAngle = whatAngle
  171.   end if
  172.   sprite(62).rotation = pCannonAngle
  173. end
  174.  
  175. on setAntPosition me, posX, posY
  176.   if pState = 6 then
  177.     exit
  178.   end if
  179.   pPositionX = posX
  180.   pPositionY = posY
  181.   sprite(pAntChannel).locH = pPositionX
  182.   sprite(pAntChannel).locV = pPositionY
  183. end
  184.  
  185. on getAntPositionX me
  186.   return pPositionX
  187. end
  188.  
  189. on getAntPositionY me
  190.   return pPositionY
  191. end
  192.  
  193. on setEnergy me, theEnergy
  194.   pEnergy = theEnergy
  195.   if pEnergy > 48 then
  196.     pEnergy = 48
  197.   end if
  198.   if pEnergy < 0 then
  199.     pEnergy = 0
  200.   end if
  201.   sprite(282).right = sprite(282).left + pEnergy
  202. end
  203.  
  204. on getEnergy me
  205.   return pEnergy
  206. end
  207.  
  208. on doDyeSequence me
  209. end
  210.  
  211. on doGetsHurt me
  212. end
  213.  
  214. on setDaPath me, thePath
  215.   pDaPath = thePath
  216.   pPathFind = 1
  217.   pCurrentNode = 1
  218. end
  219.  
  220. on startBombThrow me
  221.   if pState = 6 then
  222.     exit
  223.   end if
  224.   if pState = 3 then
  225.     exit
  226.   end if
  227.   pReadyTaLaunch = 0
  228.   aChannel = 150
  229.   found = 0
  230.   repeat while found = 0
  231.     if sprite(aChannel).puppet = 1 then
  232.       aChannel = aChannel + 1
  233.       next repeat
  234.     end if
  235.     found = 1
  236.   end repeat
  237.   append(gBombList, new(script("BombScript"), pPositionX, pPositionY, 600, 10, 1, aChannel, pAntChannel))
  238.   aAngle = gBombList[count(gBombList)].getAngle()
  239.   sprite(pAntChannel).member = pSpriteName & "Throwing" & "_2"
  240.   pState = 2
  241.   pACounter = 0
  242.   repeat with counter = 1 to count(gBombList)
  243.     if gBombList[counter].pState = 3 then
  244.       deleteAt(gBombList, counter)
  245.     end if
  246.   end repeat
  247. end
  248.  
  249. on doAttackSequence me
  250.   if pState = 3 then
  251.     exit
  252.   end if
  253.   pACounter = pACounter + 1
  254.   if pACounter > 5 then
  255.     pACounter = 0
  256.     pState = 1
  257.     sprite(pAntChannel).member = pSpriteName & "_1"
  258.   end if
  259. end
  260.  
  261. on doStund
  262.   if (pStundTime + 150) < the ticks then
  263.     pState = 1
  264.     sprite(68).loc = point(800, 800)
  265.   end if
  266. end
  267.