Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  6. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  7. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  8. function onThink() npcHandler:onThink() end
  9.  
  10.  
  11. --[[
  12. 0/40 Brilliance - Increases the rate at which experience is gained by 0.5% per point. - Rebirth 1 or higher, X gold per point
  13. 0/20 Prosperity - the loot rate from monsters by 0.5% per point. - Rebirth 5 or higher, X gold per point
  14. 0/10 Vigor - Increases maxhealth by 1% per point. - Rebirth 20 or higher, X gold per point
  15. 0/10 Vita - Increases maxmana by 1% per point. - Rebirth 20 or higher, X gold per point
  16. 0/10 Arcane - Increases 1 magic level per point. - Rebirth 40 or higher, X gold per point
  17. 0/10 Stragnosa - Increases 1 axe/sword/fist/club fighting per point - Rebirth 40 or higher, X gold per point
  18. ]]
  19.  
  20. local perks = {
  21. brilliance = {
  22. storage = 80051,
  23. gold = 10000,
  24. rebirth = 1,
  25. callback = function(cid) return doPlayerSetRate(cid, SKILL__LEVEL, getPlayerRates(cid)[SKILL__LEVEL] + 0.5) end
  26. description = "Increases the rate at which experience is gained by 0.5% per point."
  27. },
  28. vigor = {
  29. storage = 80052,
  30. gold = 10000,
  31. rebirth = 20,
  32. callback = function(cid, points)
  33. if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 1) then
  34. doRemoveCondition(cid, CONDITION_ATTRIBUTES, 1)
  35. end
  36. local c = createConditionObject(CONDITION_ATTRIBUTES)
  37. setConditionParam(c, CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, points)
  38. setConditionParam(c, CONDITION_PARAM_TICKS, -1)
  39. return doAddCondition(cid, c)
  40. end
  41. description = "Increases max health by 1% per point."
  42. },
  43. vita = {
  44. storage = 80053,
  45. gold = 10000,
  46. rebirth = 20,
  47. callback = function(cid, points)
  48. if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 2) then
  49. doRemoveCondition(cid, CONDITION_ATTRIBUTES, 2)
  50. end
  51. local c = createConditionObject(CONDITION_ATTRIBUTES)
  52. setConditionParam(c, CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, points)
  53. setConditionParam(c, CONDITION_PARAM_TICKS, -1)
  54. return doAddCondition(cid, c)
  55. end
  56. description = "Increases max mana by 1% per point."
  57. },
  58. arcane = {
  59. storage = 80054,
  60. gold = 10000,
  61. rebirth = 40,
  62. callback = function(cid, points)
  63. if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 3) then
  64. doRemoveCondition(cid, CONDITION_ATTRIBUTES, 3)
  65. end
  66. local c = createConditionObject(CONDITION_ATTRIBUTES)
  67. setConditionParam(c, CONDITION_PARAM_STAT_MAGLEVEL, points)
  68. setConditionParam(c, CONDITION_PARAM_TICKS, -1)
  69. return doAddCondition(cid, c)
  70. end
  71. description = "Increases magic level by 1 per point."
  72. },
  73. stragnosa = {
  74. storage = 80055,
  75. gold = 10000,
  76. rebirth = 40,
  77. callback = function(cid, points)
  78. if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 4) then
  79. doRemoveCondition(cid, CONDITION_ATTRIBUTES, 4)
  80. end
  81. local c = createConditionObject(CONDITION_ATTRIBUTES)
  82. setConditionParam(c, CONDITION_PARAM_SKILL_FIST, points)
  83. setConditionParam(c, CONDITION_PARAM_SKILL_CLUB, points)
  84. setConditionParam(c, CONDITION_PARAM_SKILL_SWORD, points)
  85. setConditionParam(c, CONDITION_PARAM_SKILL_AXE, points)
  86. setConditionParam(c, CONDITION_PARAM_TICKS, -1)
  87. return doAddCondition(cid, c)
  88. end
  89. description = "Increases axe/sword/fist/club fighting by 1 per point"
  90. }
  91. }
  92.  
  93. local helpMessage = {}
  94. for perk, data in pairs(perks) do
  95. helpMessage[#helpMessage+1] = ("%s - %s (Rebirth %d required) [%d gold per point]"):format(perk, data.description, data.rebirth, data.gold)
  96. end
  97. helpMessage = table.concat(helpMessage, "\n")
  98.  
  99. local function creatureSayCallback(cid, type, msg)
  100. if not npcHandler:isFocused(cid) then
  101. return false
  102. end
  103. msg = msg:lower()
  104. if msgcontains(msg, "buy") then
  105. local perk, points = msg:match("buy (%a*) (%d*)")
  106. if not perk then
  107. return selfSay("Please input a perk name.", cid)
  108. end
  109. local data = perks[perk]
  110. if not data then
  111. return selfSay("Please input a valid perk name.", cid)
  112. end
  113. local points = tonumber(points) or 1
  114. local cost = (points * data.gold)
  115. local rebirth = getPlayerRebirth(cid)
  116. if rebirth < data.rebirth then
  117. return selfSay("You do not have the required rebirth to buy this perk.", cid)
  118. end
  119. if doPlayerRemoveMoney(cid, cost) then
  120. return selfSay("You do not have enough money.", cid)
  121. end
  122. local storage = getPlayerStorageValue(cid, data.storge)
  123. if data.callback(cid, points) then
  124. doPlayerSetStorageValue(cid, data.storage, (storage == -1) and 1 or (storage + 1))
  125. return selfSay("Pleasure doing business with you.")
  126. end
  127. return doPlayerAddMoney(cid, cost) and selfSay("There was an error processing your perk. Please contact an administrator. [Perk: ".. perk .." | Points: ".. points .. "]")
  128. end
  129. if msgcontains(msg, "help") then
  130. return selfSay(helpMessage, cid)
  131. end
  132. return true
  133. end
  134.  
  135. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  136. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement