home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / SnowFight.dxr / 00006_BombScript.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  6.1 KB  |  211 lines

  1. property pPositionX, pPositionY, pDestPositionX, pDestPositionY, pDestDistance, pDistance, pSpeed, pBType, pChannel, pState, pAngle, pStupidIncrement, pTheStupidKid
  2. global gPlayer1, gPlayer2, gPlayer3, gEnemy1, gEnemy2, gEnemy3, gTotalScore, gTotalHealth
  3.  
  4. on new me, posX, posY, aDistance, speed, bType, channel, theStupidKid, destPositionX, destPositionY
  5.   pPositionX = posX
  6.   pPositionY = posY
  7.   pDestDistance = aDistance
  8.   pTheStupidKid = theStupidKid
  9.   if bType = 1 then
  10.     pSpeed = 10
  11.   else
  12.     pSpeed = 5
  13.   end if
  14.   pBType = bType
  15.   pChannel = channel
  16.   if voidp(destPositionX) then
  17.     pDestPositionX = mouseH()
  18.   else
  19.     pDestPositionX = destPositionX
  20.   end if
  21.   if voidp(destPositionY) then
  22.     pDestPositionY = mouseV()
  23.   else
  24.     pDestPositionY = destPositionY
  25.   end if
  26.   pState = 1
  27.   pDistance = 0
  28.   pStupidIncrement = 0
  29.   pAngle = comeGetSome(pPositionX, pPositionY, pDestPositionX, pDestPositionY)
  30.   sprite(channel).puppet = 1
  31.   sprite(channel).member = "snowBall1"
  32.   sprite(channel).ink = 36
  33.   sprite(channel).loc = point(pPositionX, pPositionY)
  34.   return me
  35. end
  36.  
  37. on getAngle me
  38.   return pAngle
  39. end
  40.  
  41. on updateBomb me
  42.   case pState of
  43.     1:
  44.       moveBomb()
  45.     2:
  46.       fadeBomb()
  47.     3:
  48.   end case
  49. end
  50.  
  51. on getChannel me
  52.   return pChannel
  53. end
  54.  
  55. on moveBomb me
  56.   if ((sprite(pChannel).width < 13) or (pBType = 1)) and (pDistance > 10) then
  57.     fBool = 0
  58.     if sprite(pChannel).intersects(7) then
  59.       sprite(pChannel + 30).puppet = 0
  60.       pState = 2
  61.       sprite(pChannel).member = "snowBall2"
  62.     else
  63.       if sprite(pChannel).intersects(8) then
  64.         sprite(pChannel + 30).puppet = 0
  65.         pState = 2
  66.         sprite(pChannel).member = "snowBall2"
  67.       end if
  68.     end if
  69.     if sprite(pChannel).intersects(50) and not (pTheStupidKid = 50) then
  70.       puppetSound(3, "hit by snowball")
  71.       if not (gPlayer1.pState = 3) then
  72.         fBool = 1
  73.       end if
  74.       sprite(pChannel + 30).puppet = 0
  75.       pState = 2
  76.       sprite(pChannel).member = "snowBall2"
  77.       gPlayer1.setHealth(gPlayer1.getHealth() - 10)
  78.     end if
  79.     if sprite(pChannel).intersects(51) and not (pTheStupidKid = 51) then
  80.       puppetSound(3, "hit by snowball")
  81.       if not (gPlayer2.pState = 3) then
  82.         fBool = 1
  83.       end if
  84.       sprite(pChannel + 30).puppet = 0
  85.       pState = 2
  86.       sprite(pChannel).member = "snowBall2"
  87.       gPlayer2.setHealth(gPlayer2.getHealth() - 10)
  88.     end if
  89.     if sprite(pChannel).intersects(52) and not (pTheStupidKid = 52) then
  90.       puppetSound(3, "hit by snowball")
  91.       if not (gPlayer3.pState = 3) then
  92.         fBool = 1
  93.       end if
  94.       sprite(pChannel + 30).puppet = 0
  95.       pState = 2
  96.       sprite(pChannel).member = "snowBall2"
  97.       gPlayer3.setHealth(gPlayer3.getHealth() - 10)
  98.     end if
  99.     if sprite(pChannel).intersects(54) and not ((pTheStupidKid = 54) or (pTheStupidKid = 55) or (pTheStupidKid = 56)) then
  100.       puppetSound(3, "hit by snowball")
  101.       if not (gEnemy1.pState = 3) then
  102.         fBool = 1
  103.       end if
  104.       gTotalScore = gTotalScore + 10
  105.       sprite(pChannel + 30).puppet = 0
  106.       pState = 2
  107.       sprite(pChannel).member = "snowBall2"
  108.       gEnemy1.setHealth(gEnemy1.getHealth() - 10)
  109.     end if
  110.     if sprite(pChannel).intersects(55) and not ((pTheStupidKid = 54) or (pTheStupidKid = 55) or (pTheStupidKid = 56)) then
  111.       puppetSound(3, "hit by snowball")
  112.       gTotalScore = gTotalScore + 10
  113.       if not (gEnemy2.pState = 3) then
  114.         fBool = 1
  115.       end if
  116.       sprite(pChannel + 30).puppet = 0
  117.       pState = 2
  118.       sprite(pChannel).member = "snowBall2"
  119.       gEnemy2.setHealth(gEnemy2.getHealth() - 10)
  120.     end if
  121.     if sprite(pChannel).intersects(56) and not ((pTheStupidKid = 54) or (pTheStupidKid = 55) or (pTheStupidKid = 56)) then
  122.       puppetSound(3, "hit by snowball")
  123.       gTotalScore = gTotalScore + 10
  124.       if not (gEnemy3.pState = 3) then
  125.         fBool = 1
  126.       end if
  127.       sprite(pChannel + 30).puppet = 0
  128.       pState = 2
  129.       sprite(pChannel).member = "snowBall2"
  130.       gEnemy3.setHealth(gEnemy3.getHealth() - 10)
  131.     end if
  132.     if fBool = 1 then
  133.       gTotalHealth = gPlayer1.pHealth + gPlayer2.pHealth + gPlayer3.pHealth
  134.       member("HealthDisplay").text = string(gTotalHealth)
  135.       member("ScoreDisplay").text = string(gTotalScore)
  136.     end if
  137.   else
  138.     if sprite(pChannel).intersects(14) then
  139.       sprite(pChannel + 30).puppet = 0
  140.       pState = 2
  141.       sprite(pChannel).member = "snowBall2"
  142.     end if
  143.   end if
  144.   pPositionX = pPositionX - (float(sin(pAngle * 3.14000000000000012 / 180)) * pSpeed)
  145.   pPositionY = pPositionY - (float(cos(pAngle * 3.14000000000000012 / 180)) * pSpeed)
  146.   sprite(pChannel).loc = point(pPositionX, pPositionY)
  147.   sprite(pChannel + 30).loc = sprite(pChannel).loc + 1
  148.   pDistance = pDistance + pSpeed
  149.   if pDistance > pDestDistance then
  150.     pState = 2
  151.     sprite(pChannel + 30).puppet = 0
  152.     sprite(pChannel).member = "snowBall2"
  153.   end if
  154.   if pBType = 2 then
  155.     if pDistance > (pDestDistance / 2) then
  156.       pStupidIncrement = pStupidIncrement - 1
  157.       sprite(pChannel).width = 12 + pStupidIncrement
  158.       sprite(pChannel).height = 12 + pStupidIncrement
  159.     else
  160.       pStupidIncrement = pStupidIncrement + 1
  161.       sprite(pChannel).width = 12 + pStupidIncrement
  162.       sprite(pChannel).height = 12 + pStupidIncrement
  163.     end if
  164.   end if
  165. end
  166.  
  167. on fadeBomb me
  168.   sprite(pChannel).blend = sprite(pChannel).blend - 5
  169.   if sprite(pChannel).blend < 6 then
  170.     sprite(pChannel).blend = 6
  171.     pState = 3
  172.     sprite(pChannel).puppet = 0
  173.   end if
  174. end
  175.  
  176. on comeGetSome x1, y1, x2, y2
  177.   loc1 = [x1, y1]
  178.   loc2 = [x2, y2]
  179.   deltaX = loc2[1] - loc1[1]
  180.   deltaY = -1 * (loc2[2] - loc1[2])
  181.   if deltaY = 0 then
  182.     if deltaX > 0 then
  183.       return 0
  184.     end if
  185.     if deltaX < 0 then
  186.       return 180
  187.     end if
  188.   end if
  189.   if deltaX = 0 then
  190.     deltaX = 0.01
  191.   end if
  192.   theAngle = atan(float(deltaY) / float(deltaX))
  193.   theAngle = theAngle * 180 / PI
  194.   if (deltaX < 0) and (deltaY > 0) then
  195.     theAngle = 180 + theAngle
  196.   else
  197.     if (deltaX < 0) and (deltaY < 0) then
  198.       theAngle = 180 + theAngle
  199.     else
  200.       if (deltaX > 0) and (deltaY < 0) then
  201.         theAngle = 360 + theAngle
  202.       end if
  203.     end if
  204.   end if
  205.   theAngle = theAngle - 90
  206.   if theAngle < 0 then
  207.     theAngle = 360 + theAngle
  208.   end if
  209.   return theAngle
  210. end
  211.