Advertisement
Guest User

Untitled

a guest
Mar 10th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.92 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. -- Buff Config beginning --
  11.  
  12. -- configs
  13. local config = {
  14.     storage = 77700,
  15.     value = 1,
  16. }
  17. money = 2000
  18. invisibleseconds = 600
  19. magicshieldseconds = 600
  20. regeseconds = 600
  21. speedseconds = 600
  22. skillsseconds = 600
  23. skillsupgrade = {}
  24. skillsupgrade['fist'] = 20
  25. skillsupgrade['club'] = 20
  26. skillsupgrade['sword'] = 20
  27. skillsupgrade['axe'] = 20
  28. skillsupgrade['distance'] = 20
  29. skillsupgrade['shield'] = 20
  30. skillsupgrade['ml'] = 10
  31. -- end configs
  32.  
  33. -- Configs of buffs
  34.  
  35. local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
  36. setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
  37. setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, skillsseconds * 1000)
  38. setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])
  39.  
  40. local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
  41. setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
  42. setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, invisibleseconds*1000)
  43.  
  44. local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
  45. setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
  46. setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, skillsseconds*1000)
  47. setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
  48. setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
  49. setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
  50. setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])
  51.  
  52. local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
  53. setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
  54. setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, skillsseconds*1000)
  55. setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])
  56.  
  57. local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
  58. setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
  59. setConditionParam(conditionShield, CONDITION_PARAM_TICKS, skillsseconds*1000)
  60. setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])
  61.  
  62. local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
  63. setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
  64. setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, magicshieldseconds*1000)
  65.  
  66. local conditionRege = createConditionObject(CONDITION_REGENERATION)
  67. setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
  68. setConditionParam(conditionRege, CONDITION_PARAM_TICKS, regeseconds*1000)
  69. setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
  70. setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)
  71.  
  72. local conditionspeed = createConditionObject(CONDITION_HASTE)
  73. setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
  74. setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, speedseconds*1000)
  75. setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)
  76.  
  77. -- Configs of buffs
  78.  
  79. function magicl(cid, message, keywords, parameters, node)
  80.     local guid = getPlayerGUID(cid)
  81.  
  82.     if not npcHandler:isFocused(cid) then
  83.         return false
  84.     end
  85.  
  86.     if (isDruid(cid) or isSorcerer(cid)) and getCreatureStorage(cid, config.storage) == -1 then
  87.         if getPlayerMoney(cid) >= 5000 then
  88.             doPlayerRemoveMoney(cid, 5000)
  89.             doAddCondition(cid, conditionMagic)
  90.             npcHandler:say('Your magic level has increased for 10 minutes!', cid)
  91.             setPlayerStorageValue(cid, config.storage, config.value)      
  92.             addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  93.         else
  94.             npcHandler:say('You don\'t have such money.', cid)
  95.         end
  96.     else
  97.         npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
  98.     end
  99. end
  100.  
  101. function invisible(cid, message, keywords, parameters, node)
  102.     local guid = getPlayerGUID(cid)
  103.  
  104.     if not npcHandler:isFocused(cid) then
  105.         return false
  106.     end
  107.  
  108.     if (isDruid(cid) or isSorcerer(cid)) and getCreatureStorage(cid, config.storage) == -1 then
  109.         if getPlayerMoney(cid) >= 5000 then
  110.             doPlayerRemoveMoney(cid, 5000)
  111.             npcHandler:say('You received invisibility for 10 minutes!', cid)
  112.              doAddCondition(cid, combatInvisible)
  113.             setPlayerStorageValue(cid, config.storage, config.value)      
  114.             addEvent(db.executeQuery, invisibleseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  115.         else
  116.             npcHandler:say('You don\'t have such money.', cid)
  117.         end
  118.     else
  119.         npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
  120.     end
  121. end
  122.  
  123. function melee(cid, message, keywords, parameters, node)
  124.     local guid = getPlayerGUID(cid)
  125.  
  126.     if not npcHandler:isFocused(cid) then
  127.         return false
  128.     end
  129.  
  130.     if isKnight(cid) and getCreatureStorage(cid, config.storage) == -1 then
  131.         if getPlayerMoney(cid) >= 5000 then
  132.             doPlayerRemoveMoney(cid, 5000)
  133.              doAddCondition(cid, conditionMelee)
  134.             npcHandler:say('Your Melee Skills has increased for 10 minutes!', cid)
  135.             setPlayerStorageValue(cid, config.storage, config.value)      
  136.             addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  137.         else
  138.             npcHandler:say('You don\'t have such money.', cid)
  139.         end
  140.     else
  141.         npcHandler:say('You must be a knight to receive this increment.', cid)
  142.     end
  143. end
  144.  
  145. function distance(cid, message, keywords, parameters, node)
  146.     local guid = getPlayerGUID(cid)
  147.  
  148.     if not npcHandler:isFocused(cid) then
  149.         return false
  150.     end
  151.  
  152.     if isPaladin(cid) and getCreatureStorage(cid, config.storage) == -1 then
  153.         if getPlayerMoney(cid) >= 5000 then
  154.             doPlayerRemoveMoney(cid, 5000)
  155.               doAddCondition(cid, conditionDistance)
  156.             npcHandler:say('Your Distance Skill has increased for 10 minutes!', cid)
  157.              setPlayerStorageValue(cid, config.storage, config.value)      
  158.             addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  159.         else
  160.             npcHandler:say('You don\'t have such money.', cid)
  161.         end
  162.     else
  163.         npcHandler:say('You must be a Paladin to receive this increment.', cid)
  164.     end
  165. end
  166.  
  167.  
  168. function shield(cid, message, keywords, parameters, node)
  169.     local guid = getPlayerGUID(cid)
  170.  
  171.     if not npcHandler:isFocused(cid) then
  172.         return false
  173.     end
  174.  
  175.     if (isPaladin(cid) or isKnight(cid)) and getCreatureStorage(cid, config.storage) == -1 then
  176.         if getPlayerMoney(cid) >= 5000 then
  177.             doPlayerRemoveMoney(cid, 5000)
  178.                 doAddCondition(cid, conditionShield)
  179.             npcHandler:say('Your Shielding Skill has increased for 10 minutes!', cid)
  180.              setPlayerStorageValue(cid, config.storage, config.value)      
  181.             addEvent(db.executeQuery, skillsseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  182.         else
  183.             npcHandler:say('You don\'t have such money.', cid)
  184.         end
  185.     else
  186.         npcHandler:say('You must be a Paladin or a Knight to receive this increment.', cid)
  187.     end
  188. end
  189.  
  190.  
  191. function magicshield(cid, message, keywords, parameters, node)
  192.     local guid = getPlayerGUID(cid)
  193.  
  194.     if not npcHandler:isFocused(cid) then
  195.         return false
  196.     end
  197.  
  198.     if (isPaladin(cid) or isDruid(cid) or isSorcerer(cid)) and getCreatureStorage(cid, config.storage) == -1 then
  199.         if getPlayerMoney(cid) >= 5000 then
  200.             doPlayerRemoveMoney(cid, 5000)
  201.                   doAddCondition(cid, combatUtamo)
  202.             npcHandler:say('You received a Magic Shield for 10 minutes!', cid)
  203.             setPlayerStorageValue(cid, config.storage, config.value)      
  204.             addEvent(db.executeQuery, magicshieldseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  205.         else
  206.             npcHandler:say('You don\'t have such money.', cid)
  207.         end
  208.     else
  209.         npcHandler:say('Knights can\'t receive this increment.', cid)
  210.     end
  211. end
  212.  
  213.  
  214. function regener(cid, message, keywords, parameters, node)
  215.     local guid = getPlayerGUID(cid)
  216.  
  217.     if not npcHandler:isFocused(cid) then
  218.         return false
  219.     end
  220.  
  221.     if isPlayer(cid) and getCreatureStorage(cid, config.storage) == -1 then
  222.         if getPlayerMoney(cid) >= 5000 then
  223.             doPlayerRemoveMoney(cid, 5000)
  224.                    doAddCondition(cid, conditionRege)
  225.             npcHandler:say('Your regeneration has increased for 10 minutes!', cid)
  226.             setPlayerStorageValue(cid, config.storage, config.value)      
  227.             addEvent(db.executeQuery, regeseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  228.         else
  229.             npcHandler:say('You don\'t have such money.', cid)
  230.         end
  231.     else
  232.         npcHandler:say('You can\'t receive more than two increases.', cid)
  233.     end
  234. end
  235.  
  236.  
  237. function speed(cid, message, keywords, parameters, node)
  238.     local guid = getPlayerGUID(cid)
  239.  
  240.     if not npcHandler:isFocused(cid) then
  241.         return false
  242.     end
  243.  
  244.     if isPlayer(cid) and getCreatureStorage(cid, config.storage) == -1 then
  245.         if getPlayerMoney(cid) >= 5000 then
  246.             doPlayerRemoveMoney(cid, 5000)
  247.                  doAddCondition(cid, conditionspeed)
  248.             npcHandler:say('Your speed has increased for 10 minutes!', cid)
  249.              setPlayerStorageValue(cid, config.storage, config.value)      
  250.             addEvent(db.executeQuery, speedseconds * 1000, "UPDATE `player_storage` SET `key` = " .. config.storage .. ", `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
  251.         else
  252.             npcHandler:say('You don\'t have such money.', cid)
  253.         end
  254.     else
  255.         npcHandler:say('You can\'t receive more than two increases.', cid)
  256.     end
  257. end
  258. -- Buff Config End --
  259.  
  260. keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can increase your {melee}, {distance}, {shielding}, {magic level}, {regeneration}, {invisibility}, {magic shield} and {speed}"})
  261.  
  262. local node1 = keywordHandler:addKeyword({'magic level'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your magic level for a certain time?'})
  263.     node1:addChildKeyword({'yes'}, magicl, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  264.     node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  265.  
  266. local node2 = keywordHandler:addKeyword({'invisibility'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be invisible for a certain time?'})
  267.     node2:addChildKeyword({'yes'}, invisible, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  268.     node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  269.  
  270. local node3 = keywordHandler:addKeyword({'melee'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your melee skills for a certain time?'})
  271.     node3:addChildKeyword({'yes'}, melee, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  272.     node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  273.  
  274. local node4 = keywordHandler:addKeyword({'distance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your distance skills for a certain time?'})
  275.     node4:addChildKeyword({'yes'}, distance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  276.     node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  277.  
  278. local node5 = keywordHandler:addKeyword({'shielding'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your shielding skill for a certain time?'})
  279.     node5:addChildKeyword({'yes'}, shield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  280.     node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  281.  
  282. local node6 = keywordHandler:addKeyword({'magic shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive a magic shield for a certain time?'})
  283.     node6:addChildKeyword({'yes'}, magicshield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  284.     node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  285.  
  286. local node7 = keywordHandler:addKeyword({'regeneration'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your regeneration for a certain time?'})
  287.     node7:addChildKeyword({'yes'}, regener, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  288.     node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  289.  
  290. local node8 = keywordHandler:addKeyword({'speed'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your speed for a certain time?'})
  291.     node8:addChildKeyword({'yes'}, speed, {npcHandler = npcHandler, onlyFocus = true, reset = true})
  292.     node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
  293.  
  294. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement