Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. local config = {
  2. -------------------------------------------
  3. -- None
  4. -------------------------------------------
  5. [0] = {
  6. numberOfSummons = 2,
  7. specficSummons = {},
  8. },
  9. -------------------------------------------
  10. -- Sorcerer
  11. -------------------------------------------
  12. [1] = {
  13. numberOfSummons = 2,
  14. specficSummons = {},
  15. },
  16. -------------------------------------------
  17. -- Maser Sorcerer
  18. -------------------------------------------
  19. [5] = {
  20. numberOfSummons = 2,
  21. specficSummons = {},
  22. },
  23. -------------------------------------------
  24. -- Necromancer
  25. -------------------------------------------
  26. [9] = {
  27. numberOfSummons = 3,
  28. specficSummons = {'undertanker'},
  29. },
  30. -------------------------------------------
  31. -- Wizard
  32. -------------------------------------------
  33. [10] = {
  34. numberOfSummons = 2,
  35. specficSummons = {},
  36. },
  37. -------------------------------------------
  38. -- Druid
  39. -------------------------------------------
  40. [2] = {
  41. numberOfSummons = 2,
  42. specficSummons = {},
  43. },
  44. -------------------------------------------
  45. -- Elder Druid
  46. -------------------------------------------
  47. [6] = {
  48. numberOfSummons = 2,
  49. specficSummons = {},
  50. },
  51. -------------------------------------------
  52. -- Frost Mage
  53. -------------------------------------------
  54. [13] = {
  55. numberOfSummons = 2,
  56. specficSummons = {},
  57. },
  58. -------------------------------------------
  59. -- Sage
  60. -------------------------------------------
  61. [14] = {
  62. numberOfSummons = 2,
  63. specficSummons = {},
  64. },
  65. -------------------------------------------
  66. -- Paladin
  67. -------------------------------------------
  68. [3] = {
  69. numberOfSummons = 2,
  70. specficSummons = {},
  71. },
  72. -------------------------------------------
  73. -- Royal Paladin
  74. -------------------------------------------
  75. [7] = {
  76. numberOfSummons = 2,
  77. specficSummons = {},
  78. },
  79. -------------------------------------------
  80. -- Assassin
  81. -------------------------------------------
  82. [15] = {
  83. numberOfSummons = 2,
  84. specficSummons = {},
  85. },
  86. -------------------------------------------
  87. -- Defender
  88. -------------------------------------------
  89. [16] = {
  90. numberOfSummons = 2,
  91. specficSummons = {},
  92. },
  93. -------------------------------------------
  94. -- Knight
  95. -------------------------------------------
  96. [4] = {
  97. numberOfSummons = 2,
  98. specficSummons = {},
  99. },
  100. -------------------------------------------
  101. -- Elite Knight
  102. -------------------------------------------
  103. [8] = {
  104. numberOfSummons = 2,
  105. specficSummons = {},
  106. },
  107. -------------------------------------------
  108. -- Barbarian
  109. -------------------------------------------
  110. [11] = {
  111. numberOfSummons = 2,
  112. specficSummons = {},
  113. },
  114. -------------------------------------------
  115. -- Templet
  116. -------------------------------------------
  117. [12] = {
  118. numberOfSummons = 2,
  119. specficSummons = {},
  120. },
  121. },
  122.  
  123.  
  124. function onCastSpell(creature, variant)
  125. local monsterName = variant:getString()
  126. local monsterType = MonsterType(monsterName)
  127. local vocation = creature:getVocation():getId())
  128.  
  129. if not monsterType then
  130. creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
  131. creature:getPosition():sendMagicEffect(CONST_ME_POFF)
  132. return false
  133. end
  134.  
  135. if not getPlayerFlagValue(creature, PlayerFlag_CanSummonAll) then
  136. if not monsterType:isSummonable() then
  137. creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
  138. creature:getPosition():sendMagicEffect(CONST_ME_POFF)
  139. return false
  140. end
  141.  
  142. if #creature:getSummons() >= config[vocation].numberOfSummons then
  143. creature:sendCancelMessage("You cannot summon more creatures.")
  144. creature:getPosition():sendMagicEffect(CONST_ME_POFF)
  145. return false
  146. end
  147. end
  148.  
  149. local manaCost = monsterType:getManaCost()
  150. if creature:getMana() < manaCost and not getPlayerFlagValue(creature, PlayerFlag_HasInfiniteMana) then
  151. creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
  152. creature:getPosition():sendMagicEffect(CONST_ME_POFF)
  153. return false
  154. end
  155.  
  156. for k,v in pairs(config) do
  157. if isInArray(v.specficSummons, monsterName) then
  158. if k ~= vocation then
  159. creature:sendCancelMessage("You cannot summon this creature.")
  160. creature:getPosition():sendMagicEffect(CONST_ME_POFF)
  161. return false
  162. end
  163. end
  164. end
  165.  
  166. local position = creature:getPosition()
  167. local summon = Game.createMonster(monsterName, position, true)
  168. if not summon then
  169. creature:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM)
  170. position:sendMagicEffect(CONST_ME_POFF)
  171. return false
  172. end
  173.  
  174. creature:addMana(-manaCost)
  175. creature:addManaSpent(manaCost)
  176. creature:addSummon(summon)
  177. position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
  178. summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  179. return true
  180. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement