Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. local function isSummon(cid)
  2. if not isMonster(cid) then
  3. return false
  4. end
  5.  
  6. return getCreatureMaster(cid) ~= cid
  7. end
  8.  
  9. local function canAttack(cid, target, isFriend)
  10. if cid == target then
  11. return isFriend
  12. end
  13.  
  14. local _cid = {creature = isCreature(cid), player = isPlayer(cid), monster = isMonster(cid)}
  15. local _target = {creature = isCreature(target), player = isPlayer(target), monster = isMonster(target)}
  16. if not _target.creature or not _cid.creature then
  17. return isFriend
  18. end
  19.  
  20. if getCreatureCondition(target, CONDITION_ATTRIBUTES, 169) then
  21. return isFriend
  22. end
  23.  
  24. if _cid.monster and _target.monster then
  25. local master = getCreatureMaster(cid)
  26. if not isCreature(master) or master == getCreatureMaster(target) then
  27. return isFriend
  28. end
  29. end
  30.  
  31. if isSummon(target) and getCreatureMaster(target) == cid then
  32. return isFriend
  33. end
  34.  
  35. if getTilePzInfo(getThingPos(target)) or getTilePzInfo(getThingPos(cid)) then
  36. return isFriend
  37. end
  38.  
  39. if _cid.player and isInParty(cid) then
  40. local party = getPlayerParty(cid)
  41. if _target.player and party and party == getPlayerParty(target) then
  42. return isFriend
  43. end
  44.  
  45. if isSummon(target) then
  46. local master = getCreatureMaster(target)
  47. if isPlayer(master) and party == getPlayerParty(master) then
  48. return isFriend
  49. end
  50. end
  51. end
  52.  
  53. if _target.player and isPlayerGhost(target) then
  54. return isFriend
  55. end
  56.  
  57. if isSummon(cid) then
  58. local master = getCreatureMaster(cid)
  59. if master == target then
  60. return isFriend
  61. end
  62.  
  63. if isSummon(target) then
  64. target = getCreatureMaster(target)
  65. end
  66.  
  67. if isPlayer(master) and _target.player and isInParty(master) and getPlayerParty(master) == getPlayerParty(target) then
  68. return isFriend
  69. end
  70. end
  71.  
  72. return not isFriend
  73. end
  74.  
  75. local function stopCreature(cid, target, time)
  76. if canAttack(cid, target, true) then
  77. return false
  78. end
  79.  
  80. if isMonster(target) then
  81. doChangeSpeed(target, -getCreatureSpeed(target))
  82. addEvent(function()
  83. if isMonster(target) then
  84. doChangeSpeed(target, getCreatureBaseSpeed(target))
  85. end
  86. end, time * 1000)
  87. else
  88. doCreatureSetNoMove(target, true)
  89. addEvent(function()
  90. if isPlayer(target) then
  91. doCreatureSetNoMove(target, false)
  92. end
  93. end, time * 1000)
  94. end
  95. end
  96.  
  97. local combat = createCombatObject()
  98. setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
  99. setCombatParam(combat, COMBAT_PARAM_EFFECT, 80)
  100. setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -5.0, 0, -5.5, 0)
  101.  
  102. function onTargetCombat(cid, target)
  103. return stopCreature(cid, target, 2)
  104. end
  105.  
  106. arr = {
  107. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  108. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  109. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  110. {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
  111. {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  112. {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  113. {0, 0, 1, 1, 1, 2, 1, 1, 1, 0, 0},
  114. {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  115. {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
  116. {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
  117. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  118. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  119. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  120. }
  121.  
  122. local area = createCombatArea(arr)
  123. setCombatArea(combat, area)
  124. setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, 'onTargetCombat')
  125.  
  126. function onCastSpell(cid, var)
  127. if not isPlayer(cid) then
  128. return doCombat(cid, combat, var)
  129. end
  130.  
  131. return doCombat(cid, combat, var)
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement