Raposa filha da mãe...
Ótimo script, cara. Sua criatividade excede qualquer limite. Poste seu sistema de climas orientado a objetos e aquele seu tutorial de servidores de vários mundos \o/
Raposa filha da mãe...
Ótimo script, cara. Sua criatividade excede qualquer limite. Poste seu sistema de climas orientado a objetos e aquele seu tutorial de servidores de vários mundos \o/
Editado Janeiro 5 por Oneshot
info
Registrado: 31/12/69
Posts: 0
Reputação: 0
Vou postar alguns scripts meus que estiveram engavetados. Faz algum tempo que fiz estes scripts, então não vou postar screenshots ou como configurar, mas as configurações são fáceis de entender, então divirtam-se.
Um dos scripts que eu mais me diverti fazendo é, por incrível que pareça (fazer NPC é muito chato), esse aqui. É um bardo que, de tempo em tempo, começa a cantar músicas (que você pode configurar e colocar as suas próprias músicas, quantas você quiser!).
Os players podem até mesmo pedir para o NPC tocar uma música por apenas 10 moedas de ouro!
Ótimo para colocar em castelos e tavernas.
/data/npc/scripts/bard.lua
-- This script is part of The Bard -- Copyright (C) 2011 Skyen Hasus -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. dofile(getDataDir() .. "/npc/scripts/songs.lua") local price = 10 local min_delay = 300 local max_delay = 1000 local min_random_delay = 30 local max_random_delay = 300 local max_distance = 4 local talk_duration = 180 local keywords = { greet = {"hi", "hello", "hey", "greetings"}, farewell = {"bye", "goodbye", "farewell", "cya"}, refuse = {"no", "not"}, song = {"song", "songs", "list", "yes", "ok"}, play = {"play", "yes", "ok"}, } local songs = BARD_SONGS local notes = {18, 19, 21, 22, 23, 24} local song_lyrics = false local song_line = 1 local next_line = 0 local next_random_song = os.time() + math.random(min_random_delay, max_random_delay) local talk = {} function is_talking(cid) for i, v in pairs(talk) do if i == cid then return true end end return false end function get_state(cid) if not is_talking(cid) then return false end return talk[cid].state end function get_last(cid) if not is_talking(cid) then return false end return talk[cid].last end function get_request(cid) if not is_talking(cid) then return false end return talk[cid].request end function set_request(cid, song) if not is_talking(cid) then return false end talk[cid].request = song end function start_talk(cid) if is_talking(cid) then return false end talk[cid] = {} talk[cid].state = "start" talk[cid].last = os.time() return true end function update_talk(cid, state) if not is_talking(cid) then return false end if state then talk[cid].state = state end talk[cid].last = os.time() return true end function stop_talk(cid) if not is_talking(cid) then return false end talk[cid] = nil return true end function say(cid, msg) addEvent(selfSay, math.random(min_delay, max_delay), msg, cid) return true end function start_song(song) song_lyrics = song song_line = 1 next_line = os.time() end function stop_song() song_lyrics = nil song_line = 1 next_line = 0 next_random_song = os.time() + math.random(min_random_delay, max_random_delay) end function msgcontains(message, keyword) if type(keyword) == "table" then for i, v in ipairs(keyword) do if msgcontains(message, v) then return v end end return false end local message = (" " .. message .. " "):lower() local keyword = ("[%s%p]+" .. keyword .. "[%s%p]+"):lower() local a, b = message:find(keyword) if a ~= nil and b ~= nil then return keyword end return false end function onCreatureAppear(cid) return true end function onCreatureDisappear(cid) return true end local song_list = {} local song_list_str = "" for i, v in ipairs(songs) do if v.title then table.insert(song_list, v.title) song_list_str = song_list_str .. "{" .. v.title .. "}" if i < #songs - 1 then song_list_str = song_list_str .. ", " elseif i == #songs - 1 then song_list_str = song_list_str .. " and " end end end function onCreatureSay(cid, type, msg) if getNpcDistanceTo(cid) > max_distance then return true end if msgcontains(msg, keywords.greet) then if song_lyrics then say(cid, "Sorry, I'm singing now. Wait a moment...") elseif not is_talking(cid) then say(cid, "Hello there, friend. Would you like to hear a {song}?") start_talk(cid) else say(cid, "I'm already talking with you.") update_talk(cid) end elseif msgcontains(msg, keywords.song) and get_state(cid) == "start" then if song_lyrics then say(cid, "Sorry, I'm singing now. Wait a moment...") else say(cid, "Very well, " .. getCreatureName(cid) .. ". For a small fee of 10 gold coins I can sing you " .. song_list_str .. ".") update_talk(cid) end elseif msgcontains(msg, song_list) and get_state(cid) == "start" then if song_lyrics then say(cid, "Sorry, I'm singing now. Wait a moment...") else local song = msgcontains(msg, song_list) for i, v in ipairs(songs) do if v.title == song then song = v break end end say(cid, song.title .. (song.artist and (" by " .. song.artist) or "") .. ", huh? Okay, that will cost you " .. price .. " gold coins. Would you like me to play that song?") set_request(cid, song) update_talk(cid, "play") end elseif msgcontains(msg, keywords.play) and get_state(cid) == "play" then if song_lyrics then say(cid, "Sorry, I'm singing now. Wait a moment...") else local song = get_request(cid) if getPlayerMoney(cid) > price then say(cid, "Then " .. song.title .. (song.artist and (" by " .. song.artist) or "") .. " it is!") doPlayerRemoveMoney(cid, price) start_song(song) else say(cid, "Sorry, you don't have enough money...") end update_talk(cid, "start") end elseif msgcontains(msg, keywords.refuse) then if song_lyrics then say(cid, "Sorry, I'm singing now. Wait a moment...") else say(cid, "Well, maybe later then, huh?") update_talk(cid, "start") end elseif msgcontains(msg, keywords.farewell) and is_talking(cid) then say(cid, "Goodbye, " .. getCreatureName(cid) .. "!") stop_talk(cid) end return true end function onThink() selfFocus(0) for cid, v in pairs(talk) do if not isPlayer(cid) or os.time() > v.last + talk_duration or getNpcDistanceTo(cid) > max_distance then if isPlayer(cid) then say(cid, "Goodbye, then...") end stop_talk(cid) else selfFocus(cid) end end if os.time() > next_random_song and not song_lyrics then local song = song_list[math.random(1, #song_list)] for i, v in ipairs(songs) do if v.title == song then song = v break end end start_song(song) end if song_lyrics then selfFocus(getNpcId()) if os.time() >= next_line then local line = song_lyrics[song_line] if type(line) == "string" then selfSay(line) next_line = os.time() elseif type(line) == "number" then if line == 0 then doSendMagicEffect(getThingPosition(getNpcId()), notes[math.random(1, #notes)]) next_line = os.time() else next_line = os.time() + line end end song_line = song_line + 1 end if song_line > #song_lyrics then stop_song() end end return true end/data/npc/scripts/songs.lua
-- This script is part of The Bard -- Copyright (C) 2011 Skyen Hasus -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. BARD_SEND_NOTE = 0 BARD_PAUSE_TINY = 1 BARD_PAUSE_SMLL = 3 BARD_PAUSE_NORM = 5 BARD_PAUSE_LONG = 6 BARD_SONGS = { { title = "Ragnar the red", artist = "Bethesda, from Skyrim", BARD_PAUSE_LONG, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Oh there once was a hero named Ragnar the Red", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Who came riding to Whiterun from ole Rorikstead", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And the braggart did swagger and brandish his blade", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "As he told of bold battles and gold he had made", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "But then he went quiet, did Ragnar the Red", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "When he met the shieldmaiden Matilda who said;", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "\"Oh, you talk and you lie and you drink all our mead", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Now I think that its time that you lie down and bleed\"", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And so then came clashing and slashing of steel", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "As the brave lass Matilda charged in full of zeal", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And the braggart named Ragnar was boastful no more", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "When his ugly red head rolled around on the floor", BARD_PAUSE_SMLL, }, { title = "My love is like a red rose", artist = "Robert Burns", BARD_PAUSE_LONG, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Oh, my love's like a red, red rose", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "That's newly sprung in June;", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Oh, my love's like the melodie", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "That's sweetly play'd in tune.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "As fair art thou, my bonnie lass,", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "So deep in love am I:", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And I will love thee still, my dear,", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Till a' the seas gang dry:", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Till a' the seas gang dry, my dear,", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And the rocks melt wi' the sun:", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I will love thee still, my dear,", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "While the sands o' life shall run.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And fare thee well, my only love", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And fare thee well, a while!", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And I will come again, my love,", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Tho' it were ten thousand mile.", BARD_PAUSE_SMLL, }, { title = "Begging I will go", BARD_PAUSE_LONG, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Of all the trades in England, a beggin' is the best", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "For when a beggar's tired, You can lay him down to rest.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And a begging I will go, a begging I will go.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I got a pocket for me oatmeal, and another for me rye.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I got a bottle by me side to drink when I am dry.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And a begging I will go, a begging I will go.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I got patches on me cloak, and black patch on me knee.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "When you come to take me home, I'll drink as well as thee.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And a begging I will go, a begging I will go.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I got a pocket for me ... and another for me malt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I got a pair of little crutches, you should see how I can halt.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And a begging I will go, a begging I will go.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I sleep beneath an open tree, and there I pay no rent.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Providence provides for me, and I am well content.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And a begging I will go, a begging I will go.", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I fear no plots against me. I live an open cell.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Who would be a king then when beggars live so well.", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And a begging I will go, a begging I will go.", BARD_PAUSE_SMLL, }, { title = "Greybeard Halt", artist = "Will Treaty, from Rangers Apprentice", BARD_PAUSE_LONG, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Greybeard Halt is a friend of mine", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "He lives on Redmont's hill", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Greybeard Halt never took a bath", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "And they say he never will!", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, greybeard Halt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, I say", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, greybeard Halt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I'll see you on your way", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Greybeard Halt, he lives with goats that's what I've heard tell", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "He hasn't changed his socks for years", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "But the goats doesn't mind the smell!", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, greybeard Halt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, I say", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, greybeard Halt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I'll see you on your way", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Greybeard Halt is a fighting man", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I've heard common talk", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "That greybeard Halt, he cuts his hair", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "With a carving knife and fork!", BARD_PAUSE_NORM, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, greybeard Halt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, I say", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "Fare thee well, greybeard Halt", BARD_PAUSE_SMLL, BARD_SEND_NOTE, BARD_PAUSE_TINY, "I'll see you on your way", BARD_PAUSE_SMLL, }, }/data/npc/will.xml