Advertisement
Guest User

Untitled

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