Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
- function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
- function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
- function onThink() npcHandler:onThink() end
- --[[
- 0/40 Brilliance - Increases the rate at which experience is gained by 0.5% per point. - Rebirth 1 or higher, X gold per point
- 0/20 Prosperity - the loot rate from monsters by 0.5% per point. - Rebirth 5 or higher, X gold per point
- 0/10 Vigor - Increases maxhealth by 1% per point. - Rebirth 20 or higher, X gold per point
- 0/10 Vita - Increases maxmana by 1% per point. - Rebirth 20 or higher, X gold per point
- 0/10 Arcane - Increases 1 magic level per point. - Rebirth 40 or higher, X gold per point
- 0/10 Stragnosa - Increases 1 axe/sword/fist/club fighting per point - Rebirth 40 or higher, X gold per point
- ]]
- local perks = {
- brilliance = {
- storage = 80051,
- gold = 10000,
- rebirth = 1,
- callback = function(cid) return doPlayerSetRate(cid, SKILL__LEVEL, getPlayerRates(cid)[SKILL__LEVEL] + 0.5) end
- description = "Increases the rate at which experience is gained by 0.5% per point."
- },
- vigor = {
- storage = 80052,
- gold = 10000,
- rebirth = 20,
- callback = function(cid, points)
- if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 1) then
- doRemoveCondition(cid, CONDITION_ATTRIBUTES, 1)
- end
- local c = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(c, CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, points)
- setConditionParam(c, CONDITION_PARAM_TICKS, -1)
- return doAddCondition(cid, c)
- end
- description = "Increases max health by 1% per point."
- },
- vita = {
- storage = 80053,
- gold = 10000,
- rebirth = 20,
- callback = function(cid, points)
- if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 2) then
- doRemoveCondition(cid, CONDITION_ATTRIBUTES, 2)
- end
- local c = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(c, CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, points)
- setConditionParam(c, CONDITION_PARAM_TICKS, -1)
- return doAddCondition(cid, c)
- end
- description = "Increases max mana by 1% per point."
- },
- arcane = {
- storage = 80054,
- gold = 10000,
- rebirth = 40,
- callback = function(cid, points)
- if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 3) then
- doRemoveCondition(cid, CONDITION_ATTRIBUTES, 3)
- end
- local c = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(c, CONDITION_PARAM_STAT_MAGLEVEL, points)
- setConditionParam(c, CONDITION_PARAM_TICKS, -1)
- return doAddCondition(cid, c)
- end
- description = "Increases magic level by 1 per point."
- },
- stragnosa = {
- storage = 80055,
- gold = 10000,
- rebirth = 40,
- callback = function(cid, points)
- if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 4) then
- doRemoveCondition(cid, CONDITION_ATTRIBUTES, 4)
- end
- local c = createConditionObject(CONDITION_ATTRIBUTES)
- setConditionParam(c, CONDITION_PARAM_SKILL_FIST, points)
- setConditionParam(c, CONDITION_PARAM_SKILL_CLUB, points)
- setConditionParam(c, CONDITION_PARAM_SKILL_SWORD, points)
- setConditionParam(c, CONDITION_PARAM_SKILL_AXE, points)
- setConditionParam(c, CONDITION_PARAM_TICKS, -1)
- return doAddCondition(cid, c)
- end
- description = "Increases axe/sword/fist/club fighting by 1 per point"
- }
- }
- local helpMessage = {}
- for perk, data in pairs(perks) do
- helpMessage[#helpMessage+1] = ("%s - %s (Rebirth %d required) [%d gold per point]"):format(perk, data.description, data.rebirth, data.gold)
- end
- helpMessage = table.concat(helpMessage, "\n")
- local function creatureSayCallback(cid, type, msg)
- if not npcHandler:isFocused(cid) then
- return false
- end
- msg = msg:lower()
- if msgcontains(msg, "buy") then
- local perk, points = msg:match("buy (%a*) (%d*)")
- if not perk then
- return selfSay("Please input a perk name.", cid)
- end
- local data = perks[perk]
- if not data then
- return selfSay("Please input a valid perk name.", cid)
- end
- local points = tonumber(points) or 1
- local cost = (points * data.gold)
- local rebirth = getPlayerRebirth(cid)
- if rebirth < data.rebirth then
- return selfSay("You do not have the required rebirth to buy this perk.", cid)
- end
- if doPlayerRemoveMoney(cid, cost) then
- return selfSay("You do not have enough money.", cid)
- end
- local storage = getPlayerStorageValue(cid, data.storge)
- if data.callback(cid, points) then
- doPlayerSetStorageValue(cid, data.storage, (storage == -1) and 1 or (storage + 1))
- return selfSay("Pleasure doing business with you.")
- end
- return doPlayerAddMoney(cid, cost) and selfSay("There was an error processing your perk. Please contact an administrator. [Perk: ".. perk .." | Points: ".. points .. "]")
- end
- if msgcontains(msg, "help") then
- return selfSay(helpMessage, cid)
- end
- return true
- end
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement