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)
- local talkState = {}
- 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
- local fyi = {
- [5] = "Congratulations on reaching Tier 2!",
- [12] = "Congratulations on reaching Tier 3!",
- [25] = "Congratulations on reaching Tier 4!",
- [55] = "Congratulations on reaching Tier 5!",
- [90] = "Congratulations on reaching Tier 6!",
- [150] = "Congratulations on reaching Tier 7!",
- [240] = "Congratulations on reaching Tier 8!",
- [401] = "Congratulations on reaching Tier 9!",
- }
- local spells = {
- [5] = "death whip",
- [10] = {"thunderblast", "flame nova"},
- [25] = {"exevo gran mas candy", "poison plague"},
- [40] = "exevo gran mas love",
- [50] = "frost flash",
- [100] = "aguamenti",
- [150] = "energy volley",
- [200] = "alohomora",
- [250] = "frost arrow",
- [300] = "expecto patrinum",
- [350] = "shooting star",
- [400] = "avada kedavra",
- [450] = "void strike"
- }
- function creatureSayCallback(cid, type, msg)
- if (not npcHandler:isFocused(cid)) then
- return false
- end
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- local reb = getPlayerRebirth(cid)
- local c, current = getRebirthCost(reb + 1), getPlayerStorageValue(cid, REBIRTH_STORAGE_STAGE)
- local name, i, amount = "", 0, 0
- if (current > 0 or (current == -1 and REBIRTH_MISSIONS[reb] ~= nil and REBIRTH_MISSIONS[reb]["kill"] ~= nil)) then
- for k, v in pairs(REBIRTH_MISSIONS[reb]["kill"]) do
- i = i + 1
- if (current == i or current == -1) then
- name = k
- amount = v
- break
- end
- end
- end
- local str, nr = "", 0
- if (REBIRTH_MISSIONS[reb] ~= nil and REBIRTH_MISSIONS[reb]["collect"] ~= nil) then
- for _, v in pairs(REBIRTH_MISSIONS[reb]["collect"]) do
- nr = nr + 1
- str = str .. v[2] .. " " .. getItemNameById(v[1]) .. "s, "
- end
- end
- if (msgcontains(msg, 'mission')) then
- if (current == 0) then
- if (nr > 0) then
- selfSay('Your (final) mission for this rebirth is to bring me ' .. str .. ' and say {rebirth}.', cid)
- else
- selfSay('You have finished all your missions. Please ask me to {rebirth} you.', cid)
- end
- else
- if (amount == 0) then
- selfSay('I do not have any missions for your rebirth.', cid)
- else
- if (current == -1) then
- setPlayerStorageValue(cid, REBIRTH_STORAGE_STAGE, 1)
- setPlayerStorageValue(cid, REBIRTH_STORAGE_AMOUNT, 0)
- end
- selfSay('Your current mission is to kill ' .. amount .. ' ' .. name:lower() .. 's.', cid)
- end
- end
- elseif (msgcontains(msg, 'rebirth')) then
- if getPlayerLevel(cid) >= 717217 then
- if (reb <= 200) then
- selfSay('Are you ready for me to rebirth you!? You would have ' .. (getPlayerRebirth(cid) + 1) .. ' rebirths. But you have to give me ' .. (c > 1 and c or 'a') .. ' gold ingot' .. (c > 1 and 's' or '') .. ' OR finish my {missions} in return.', cid)
- else
- selfSay('Are you ready for me to rebirth you!? You would have ' .. (getPlayerRebirth(cid) + 1) .. ' rebirths. But you have to finish my {missions} in return.', cid)
- end
- talkState[talkUser] = 1
- else
- selfSay('Only characters of level 717 217 level or higher may rebirth.', cid)
- talkState[talkUser] = 0
- end
- elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
- if (getPlayerLevel(cid) >= 717217) then
- local hasIngots = (getPlayerItemCount(cid, 9971) >= c)
- local didMissions = (current == 0)
- if (didMissions) then
- if (nr > 0) then
- for _, v in pairs(REBIRTH_MISSIONS[reb]["collect"]) do
- if (getPlayerItemCount(cid, v[1]) < v[2]) then
- didMissions = false
- break
- end
- end
- end
- end
- if didMissions or hasIngots then
- if (didMissions) then
- if (nr > 0) then
- for _, v in pairs(REBIRTH_MISSIONS[reb]["collect"]) do
- doPlayerRemoveItem(cid, v[1], v[2])
- end
- end
- else
- doPlayerRemoveItem(cid, 9971, c)
- end
- local newRebirth = getPlayerRebirth(cid) + 1
- setPlayerRebirth(cid, newRebirth)
- doPlayerAddSkill(cid, SKILL__LEVEL, -717208, true)
- local text = {}
- local fyiData = fyi[newRebirth]
- local toLearn = spells[newRebirth]
- if fyiData then
- text[#text+1] = ("%s%s"):format(fyiData, (toLearn and "---------------\nSpells Learned\n---------------" or ""))
- end
- if toLearn then
- if type(toLearn) == "string" then
- doPlayerLearnInstantSpell(cid, toLearn)
- text[#text+1] = "\t-> ".. toLearn
- elseif type(toLearn) == "table" then
- for i = 1, #toLearn do
- doPlayerLearnInstantSpell(cid, toLearn[i])
- text[#text+1] = "\t-> ".. toLearn[i]
- end
- end
- end
- if #text > 0 then
- doPlayerPopupFYI(cid, table.concat(text, "\n"))
- end
- while (getPlayerLevel(cid) > 8) do
- doPlayerAddSkill(cid, SKILL__LEVEL, -100000, true)
- end
- doCreatureSetStorage(cid, REBIRTH_STORAGE_STAGE)
- doCreatureSetStorage(cid, REBIRTH_STORAGE_AMOUNT)
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK)
- updateStats(cid)
- else
- selfSay('You do not have enough gold ingots nor have you finished all your mission!', cid)
- doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
- end
- else
- selfSay('Only characters of level 717 217 level or higher may rebirth.', cid)
- talkState[talkUser] = 0
- end
- elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
- talkState[talkUser] = 0
- selfSay('Okey come back when you have some money you poor scum.', 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