Advertisement
Guest User

attack/freez.lua

a guest
Nov 30th, 2015
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.16 KB | None | 0 0
  1. --[[
  2.     As I said you should have freez system to prevent player from moving L:D when you summon this :D
  3.  
  4. #Slavi
  5. ]]
  6.  
  7. local config = {
  8.     onlyPlayer = false, -- only works on player?
  9.     monsterName = "dragon", -- example monster ...
  10.     monsterCount = 4, -- how much monsters should be made?
  11.     waves = 1, -- not done yet.
  12.    
  13.     effect = 50, -- effect on target
  14.     effect2 = 69, -- effect on each pet you summon.
  15.    
  16.     dEffect = 28, --CONST_ANI_TARSALARROW -- you must have seen gif image :D
  17.    
  18.     interval = 5, -- interval to remove pets in seconds
  19.    
  20.     extraDamage = true,
  21.     safePercent = 20, -- in extra hit damage it low the damage if player's mana or health percent(depend on Magicshield active..) lower than this damage become half
  22.     storageSummon = 1988455, -- Don't wanna use of storage? use spell time in spells.xml
  23.     minDmg = 70,
  24.     maxDmg = 120,
  25. }
  26.  
  27.  
  28. --[[
  29. I already provided every configurable thing up.
  30.  
  31.  
  32. so don't go down.
  33.  
  34. ]]
  35. function onCastSpell(cid, var)
  36.     local player = Player(cid)
  37.     local c = config
  38.         if player:getTarget() then
  39.             if player:getStorageValue(c.storageSummon) > 0 then player:say("You can't summon now..", TALKTYPE_MONSTER_SAY); return false end
  40.             local target = player:getTarget()
  41.             if(not isPlayer(target))and(c.onlyPlayer)then
  42.                 player:say("You can only summon on players", TALKTYPE_MONSTER_SAY)
  43.                 return false
  44.             end
  45.             local pos = target:getPosition()
  46.             for i = 1, c.waves do
  47.                 for s = 1, c.monsterCount do
  48.                     local creatureId = Game.createMonster(c.monsterName, pos)
  49.                     local monster = Monster(creatureId) or creatureId
  50.                     monster:setMaster(player)
  51.                     monster:getPosition():sendMagicEffect(c.effect)
  52.                     addEvent(removeSummon, config.interval * 1000, target.uid, creatureId.uid, c.extraDamage)
  53.                     player:getPosition():sendDistanceEffect(target:getPosition(), config.dEffect)
  54.                 end
  55.             end
  56.             if target:isPlayer() then
  57.                 activeFreez(target.uid, c.interval)
  58.             end
  59.             player:setStorageValue(c.storageSummon, 1)
  60.             addEvent(backStorage, (c.interval+10) * 1000, player.uid)
  61.             return true
  62.         else
  63.             player:getPosition():sendMagicEffect(3)
  64.             player:say("No Target.", TALKTYPE_MONSTER_SAY) -- no target
  65.         end
  66. end
  67. function backStorage(cid)
  68.     if not Player(cid) then return false end
  69.     Player(cid):setStorageValue(config.storageSummon, 0)
  70.     return true
  71. end
  72. function activeFreez(cid, interval)
  73.     if Player(cid) then
  74.         doSetFreezed(cid, true)
  75.         Player(cid):say("Freezed", TALKTYPE_MONSTER_SAY)
  76.         addEvent(doSetFreezed, interval*1000, cid, false)
  77.     end
  78.     return true
  79. end
  80. function doSetFreezed(cid, bool)
  81.     if not Player(cid) then return false end
  82.     Player(cid):setFreezed(bool)
  83.     player:say("Melted", TALKTYPE_MONSTER_SAY)
  84.     return true
  85. end
  86. function removeSummon(pid, tid, boolExtraAtk)
  87.     if Creature(pid) then  
  88.         if Creature(tid) then
  89.             tid = Creature(tid)
  90.             pid = Creature(pid)
  91.             local c = tid:getPosition()
  92.             if tid:remove() then
  93.                 local p = pid:getPosition()
  94.                 p:sendMagicEffect(config.effect2)
  95.                 c:sendMagicEffect(config.effect)           
  96.                 if Creature(pid):isPlayer() then
  97.                     c:sendDistanceEffect(p, config.dEffect, Player(pid))
  98.                 else
  99.                     c:sendDistanceEffect(p, config.dEffect)
  100.                 end
  101.                 if boolExtraAtk then
  102.                     if not pid then return true end
  103.                     local hp, maxHp, mp, maxMp = pid:getHealth(), pid:getMaxHealth(), pid:getMana(), pid:getMaxMana()
  104.                     local pHp, pMp = (hp/maxHp)*100, (mp/maxMp)*100
  105.                     local sF, max, min = config.safePercent, config.maxDmg, config.minDmg
  106.                     if pid:isPlayer() then
  107.                         if getCreatureCondition(creature, CONDITION_MANASHIELD) == true then
  108.                             if pMp > sF then
  109.                                 doTargetCombatMana(0, pid, -min, -max, 1)
  110.                             else
  111.                                 doTargetCombatMana(0, pid, -(min/2), -(max/2), 1)
  112.                             end
  113.                         else
  114.                             if pHp > sF then
  115.                             doTargetCombatHealth(0, pid, COMBAT_PHYSICALDAMAGE, min, max, 1)
  116.                             else
  117.                                 doTargetCombatHealth(0, pid, COMBAT_PHYSICALDAMAGE, (min/2), (max/2), 1)
  118.                             end
  119.                         end
  120.                     else
  121.                         if pHp > sF then
  122.                             doTargetCombatHealth(0, pid, COMBAT_PHYSICALDAMAGE, min, max, 1)
  123.                         else
  124.                             doTargetCombatHealth(0, pid, COMBAT_PHYSICALDAMAGE, (min/2), (max/2), 1)
  125.                         end
  126.                     end
  127.                 end
  128.             end
  129.         end
  130.     end
  131. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement