Advertisement
Guest User

Untitled

a guest
Oct 18th, 2015
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.73 KB | None | 0 0
  1. BOMB_ITEMID = 10571
  2. BARREL_ITEMID = 9468
  3. POWERUP_ITEMID = {10571, 8304, 2195}
  4. PLAYER_SPEED = 100
  5. MAX_PLAYER_SPEED = 200
  6. SPAWN_POSITIONS = {
  7.     Position(1000, 1000, 7),
  8.     Position(1001, 1002, 7)
  9. }
  10.  
  11. local BOMB_CROSS1X1 = {
  12.     {0, 1, 0},
  13.     {1, 3, 1},
  14.     {0, 1, 0}
  15. }
  16.  
  17. local BOMB_CROSS2X2 = {
  18.     {0, 0, 1, 0, 0},
  19.     {0, 0, 1, 0, 0},
  20.     {1, 1, 3, 1, 1},
  21.     {0, 0, 1, 0, 0},
  22.     {0, 0, 1, 0, 0}
  23. }
  24.  
  25. local BOMB_CROSS3X3 = {
  26.     {0, 0, 0, 1, 0, 0, 0},
  27.     {0, 0, 0, 1, 0, 0, 0},
  28.     {0, 0, 0, 1, 0, 0, 0},
  29.     {1, 1, 1, 3, 1, 1, 1},
  30.     {0, 0, 0, 1, 0, 0, 0},
  31.     {0, 0, 0, 1, 0, 0, 0},
  32.     {0, 0, 0, 1, 0, 0, 0}
  33. }
  34.  
  35. function Player.resetVariables(self)
  36.     -- add back the speed
  37.     local changeSpeed = Self.changeSpeed
  38.     changeSpeed(self, -self:getSpeed())
  39.     changeSpeed(self, self:getBaseSpeed())
  40.  
  41.     -- remove mute condition
  42.     self:removeCondition(CONDITION_MUTED, CONDITIONID_DEFAULT)
  43.  
  44.     -- bomb level
  45.     self:setStorageValue(1000, -1)
  46.  
  47.     -- teleport
  48.     self:teleportTo(self:getTown():getTemplePosition())
  49. end
  50.  
  51. local condition = Condition(CONDITION_MUTED, CONDITIONID_DEFAULT)
  52. function Player.setVariables(self)
  53.     -- change speed
  54.     self:changeSpeed(-self:getSpeed() + PLAYER_SPEED)
  55.  
  56.     -- add mute
  57.     condition:setTicks(24 * 60 * 1000)
  58.     self:addCondition(condition)
  59.  
  60.     -- bomb level
  61.     self:setStorageValue(1000, 1)
  62. end
  63.  
  64. function Position.executeBomb(self)
  65.     local tile = Tile(self)
  66.     if not tile then
  67.         return false
  68.     end
  69.  
  70.     local barrelItem = tile:getItemById(BARREL_ITEMID)
  71.     if barrelItem then
  72.         self:sendMagicEffect(CONST_ME_HITBYFIRE)
  73.  
  74.         if math.random(100) >= 80 then
  75.             local powerItem = barrelItem:transform(POWERUP_ITEMID[math.random(#POWERUP_ITEMID)])
  76.             if powerItem then
  77.                 barrelItem:setAttribute(ITEM_ATTRIBUTE_ACTIONID, 7000)
  78.             end
  79.         else
  80.             barrelItem:remove()
  81.         end
  82.     end
  83.  
  84.     local topCreature = tile:getTopCreature()
  85.     if topCreature then
  86.         print("Dead: ".. topCreature:getName())
  87.     end
  88.  
  89.     return true
  90. end
  91.  
  92. function onTargetTile_bombOne(creature, position)
  93.     return position:executeBomb()
  94. end
  95.  
  96. function onTargetTile_bombTwo(creature, position)
  97.     return position:executeBomb()
  98. end
  99.  
  100. function onTargetTile_bombThree(creature, position)
  101.     return position:executeBomb()
  102. end
  103.  
  104. local bombOne = Combat()
  105. bombOne:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
  106. bombOne:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile_bombOne")
  107. bombOne:setArea(createCombatArea(BOMB_CROSS1X1))
  108.  
  109. local bombTwo = Combat()
  110. bombTwo:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
  111. bombTwo:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile_bombTwo")
  112. bombTwo:setArea(createCombatArea(BOMB_CROSS2X2))
  113.  
  114. local bombThree = Combat()
  115. bombThree:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
  116. bombThree:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile_bombThree")
  117. bombThree:setArea(createCombatArea(BOMB_CROSS3X3))
  118.  
  119. local function executeBomb(cid, position, time)
  120.     local player = Player(cid)
  121.     if not player then
  122.         return
  123.     end
  124.  
  125.     player:say((time == 0 and "BOOM!" or time), TALKTYPE_MONSTER_SAY, false, 0, position)
  126.     if time == 0 then
  127.         local bombItem = Tile(position):getItemById(BOMB_ITEMID)
  128.         if bombItem then
  129.             bombItem:remove()
  130.         end
  131.  
  132.         local bombLevel = player:getStorageValue(1000)
  133.         local bomb = bombOne:execute(player, positionToVariant(position))
  134.         if bomb == 2 then
  135.             bomb = bombTwo:execute(player, positionToVariant(position))
  136.         elseif bomb == 3 then
  137.             bomb = bombThree:execute(player, positionToVariant(position))
  138.         end
  139.  
  140.         return bomb
  141.     end
  142.  
  143.     addEvent(executeBomb, 1000, cid, position, time - 1)
  144. end
  145.  
  146. function onSay(player, words, param)
  147.     local playerPosition = player:getPosition()
  148.     local bomb = Game.createItem(BOMB_ITEMID, 1, playerPosition)
  149.     if bomb then
  150.         executeBomb(player:getId(), playerPosition, 3, 3, 3)
  151.     end
  152.  
  153.     return false
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement