Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1.  
  2. Save New Duplicate & Edit Just Text Twitter
  3. 1
  4. 2
  5. 3
  6. 4
  7. 5
  8. 6
  9. 7
  10. 8
  11. 9
  12. 10
  13. 11
  14. 12
  15. 13
  16. 14
  17. 15
  18. 16
  19. 17
  20. 18
  21. 19
  22. 20
  23. 21
  24. 22
  25. 23
  26. 24
  27. 25
  28. 26
  29. 27
  30. 28
  31. 29
  32. 30
  33. 31
  34. 32
  35. 33
  36. 34
  37. 35
  38. 36
  39. 37
  40. 38
  41. 39
  42. 40
  43. 41
  44. 42
  45. 43
  46. 44
  47. 45
  48. 46
  49. 47
  50. 48
  51. 49
  52. 50
  53. 51
  54. 52
  55. 53
  56. 54
  57. 55
  58. 56
  59. 57
  60. 58
  61. 59
  62. 60
  63. 61
  64. 62
  65. 63
  66. 64
  67. 65
  68. 66
  69. 67
  70. 68
  71. 69
  72. 70
  73. 71
  74. 72
  75. 73
  76. 74
  77. 75
  78. 76
  79. 77
  80. 78
  81. 79
  82. 80
  83. 81
  84. 82
  85. 83
  86. 84
  87. 85
  88. 86
  89. 87
  90. 88
  91. 89
  92. 90
  93. 91
  94. 92
  95. 93
  96. 94
  97. 95
  98. 96
  99. 97
  100. 98
  101. 99
  102. 100
  103. 101
  104. 102
  105. 103
  106. 104
  107. 105
  108. 106
  109. 107
  110. 108
  111. 109
  112. 110
  113. 111
  114. 112
  115. 113
  116. 114
  117. 115
  118. 116
  119. 117
  120. 118
  121. 119
  122. 120
  123. 121
  124. 122
  125. 123
  126. 124
  127. 125
  128. 126
  129. 127
  130. 128
  131. 129
  132. 130
  133. if not globalBosses then
  134. globalBosses = {}
  135. end
  136.  
  137. function Monster.setReward(self, enable)
  138. if enable then
  139. if not self:getType():isRewardBoss() then
  140. error("Rewards can only be enabled to rewards bosses.")
  141. return false
  142. end
  143. globalBosses[self:getId()] = {}
  144. self:registerEvent("BossDeath")
  145. self:registerEvent("BossThink")
  146. else
  147. globalBosses[self:getId()] = nil
  148. self:unregisterEvent("BossDeath")
  149. self:unregisterEvent("BossThink")
  150. end
  151. return true
  152. end
  153.  
  154. local function pushValues(buffer, sep, ...)
  155. local argv = {...}
  156. local argc = #argv
  157. for k, v in ipairs(argv) do
  158. table.insert(buffer, v)
  159. if k < argc and sep then
  160. table.insert(buffer, sep)
  161. end
  162. end
  163. end
  164.  
  165. function Item.getNameDescription(self)
  166. local subType = self:getSubType()
  167. local itemType = self:getType()
  168.  
  169. local buffer = {}
  170.  
  171. local name = self:getName() or ''
  172. if(#name ~= 0) then
  173. if(itemType:isStackable() and subType > 1) then
  174. pushValues(buffer, ' ', subType, self:getPluralName())
  175. else
  176. local article = self:getArticle() or ''
  177. pushValues(buffer, ' ', select(#article ~= 0 and 1 or 2, article, name))
  178. end
  179. else
  180. pushValues(buffer, ' ', 'an item of type', self:getId())
  181. end
  182.  
  183. return table.concat(buffer)
  184. end
  185.  
  186. function Container.getContentDescription(self, outputBuffer)
  187. local firstItem = true
  188. local buffer = outputBuffer or {}
  189. for i = 1, self:getSize() do
  190. local item = self:getItem(i - 1)
  191.  
  192. if(firstItem) then
  193. firstItem = false
  194. else
  195. table.insert(buffer, ", ")
  196. end
  197.  
  198. table.insert(buffer, item:getNameDescription())
  199. end
  200.  
  201. if firstItem then
  202. table.insert(buffer, "nothing")
  203. end
  204.  
  205. if not outputBuffer then
  206. return table.concat(buffer)
  207. end
  208. end
  209.  
  210. function Player.getRewardChest(self, autocreate)
  211. return self:getDepotChest(99, autocreate)
  212. end
  213.  
  214. function Player.inBossFight(self)
  215. if not next(globalBosses) then
  216. return false
  217. end
  218. local playerGuid = self:getGuid()
  219.  
  220. for _, info in pairs(globalBosses) do
  221. local stats = info[playerGuid]
  222. if stats and stats.active then
  223. return stats
  224. end
  225. end
  226. return false
  227. end
  228.  
  229. -- by https://otland.net/members/cbrm.25752/ with some modifications
  230. function MonsterType.createLootItem(self, lootBlock, chance, lootTable)
  231. local lootTable, itemCount = lootTable or {}, 0
  232. local randvalue = math.random(0, 100000) / (getConfigInfo("rateLoot") * chance)
  233. if randvalue < lootBlock.chance then
  234. if (ItemType(lootBlock.itemId):isStackable()) then
  235. itemCount = randvalue % lootBlock.maxCount + 1
  236. else
  237. itemCount = 1
  238. end
  239. end
  240.  
  241. while itemCount > 0 do
  242. local n = math.min(itemCount, 100)
  243. itemCount = itemCount - n
  244. table.insert(lootTable, {lootBlock.itemId, n})
  245. end
  246.  
  247. return lootTable
  248. end
  249.  
  250. function MonsterType.getBossReward(self, lootFactor, topScore)
  251. local result = {}
  252. local giveUnique = 0
  253. if getConfigInfo("rateLoot") > 0 then
  254. for _, lootBlock in pairs(self:getLoot()) do
  255. if lootBlock.unique and not topScore then
  256. --continue
  257. else
  258. if(lootBlock.unique==1 and giveUnique == 0)then
  259. self:createLootItem(lootBlock, lootFactor, result)
  260. giveUnique=1
  261. elseif(lootBlock.unique~=1)then
  262. self:createLootItem(lootBlock, lootFactor, result)
  263. end
  264.  
  265. end
  266. end
  267. end
  268. return result
  269. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement