Lwkass 1 #1 Posted August 19, 2011 (edited) ┌──────────────────────────────────────────────────┐ │Nome: Sign of Zodiac │Versão do script: 1.0.0 │Tipo do script: Sistema (Creature Script, Talkaction e Lib) │Servidor Testado: The Forgotten Server 0.4.0 Doomed Elderberry │Autor: Lwkass └──────────────────────────────────────────────────┘ Por mais que o feedback do meu ultimo post (Lib para criar Spell) tenha sido pouco, vou postar mais um script... É um sistema de Signo do Zodíaco, onde cada signo da um bônus (por enquanto apenas 2), a ideia está bem inicial, mas pretende continua-lo. - Características: ~ Bônus em experiencia (Todos recebem 10% a mais)~ Bônus na defesa contra elemento (Todos absorvem 5%) ~ Cada signo possui um elemento (Fire, Ice, Lighting ou Earth) ~ Signos de Fogo: Aries, Leo e Sagittarius ~ Signos da Terra: Taurus, Virgo e Capricorn ~ Signos da Eletricidade (Ar): Gemini, Libra e Aquarius ~ Signos de Agua: Cancer, Scorpio e Pisces - Explicando: Para escolher o signo o player deve colocar o dia e o mês do aniversário e o sistema automaticamente coloca o signo, comando: !zodiac dia/mês Só para deixar claro como o sistema funciona, usando de exemplo o signo de Leão (Leo) que é do elemento Fire: * Se receber um dano do elemento Fire, absorve 5% (modificável) do dano total, ou seja, o dano seria igual a 95% do que seria (dano absorvido indicado por animatedText). * Se matar um monstro que tenha uma defesa contra Fire maior que 0% ganha bônus de 10% (modificável) da exp total, ou seja, ganha-se 110% (exp extra indicada por animatedText). Se o signo fosse do elemento Earth, então seria a mesma coisa só que com o elemento Earth, se fosse Ice ou Lighting a mesma coisa. Pode-se usar o comando !zodiac info para informações. - Script: Primeiro, na pasta data/lib (caso a pasta não exista, crie) do seu servidor crie um arquivo Lua com o nome zodiac-Lib.lua (Lib com maiúscula) e salve com isso dentro: --[[ Sign of Zodiac System v1.0.0 by: Lwkass ([email protected]) ]] Zodiac = { constant = { OPTION_PERCENT_BLOCK = 5, -- In Percent OPTION_EXTRA_EXP_RATE = 10, -- In Percent STORAGE_SIGN = 16161, elements = { ["Fire"] = { combat = COMBAT_FIREDAMAGE, color = COLOR_ORANGE }, ["Earth"] = { combat = COMBAT_EARTHDAMAGE, color = COLOR_LIGHTGREEN }, ["Lighting"] = { combat = COMBAT_ENERGYDAMAGE, color = COLOR_TEAL }, ["Ice"] = { combat = COMBAT_ICEDAMAGE, color = COLOR_LIGHTBLUE } } }, signs = { ["Aries"] = { date = {"21/03", "20/04"}, element = "Fire" }, ["Taurus"] = { date = {"21/04", "20/05"}, element = "Earth" }, ["Gemini"] = { date = {"21/05", "20/06"}, element = "Lighting" }, ["Cancer"] = { date = {"21/06", "21/07"}, element = "Ice" }, ["Leo"] = { date = {"22/07", "22/08"}, element = "Fire" }, ["Virgo"] = { date = {"23/08", "22/09"}, element = "Earth" }, ["Libra"] = { date = {"23/09", "22/10"}, element = "Lighting" }, ["Scorpio"] = { date = {"23/10", "21/11"}, element = "Ice" }, ["Sagittarius"] = { date = {"22/11", "21/12"}, element = "Fire" }, ["Capricorn"] = { date = {"22/12", "20/01"}, element = "Earth" }, ["Aquarius"] = { date = {"21/01", "19/02"}, element = "Lighting" }, ["Pisces"] = { date = {"20/02", "20/03"}, element = "Ice" } }, getSignInfo = function (signName) return Zodiac.signs[signName] end, set = function (cid, signName) setPlayerStorageValue(cid, Zodiac.constant.STORAGE_SIGN, signName) end, get = function (cid) return getPlayerStorageValue(cid, Zodiac.constant.STORAGE_SIGN), Zodiac.getSignInfo(getPlayerStorageValue(cid, Zodiac.constant.STORAGE_SIGN)) or 0 end, getElement = function (cid) return Zodiac.getSignInfo(getPlayerStorageValue(cid, Zodiac.constant.STORAGE_SIGN)).element end, getSign = function (cid, day, month) for sign, info in pairs(Zodiac.signs) do _, _, beginDay, beginMonth = info.date[1]:find("(%d+)/(%d+)") _, _, endDay, endMonth = info.date[2]:find("(%d+)/(%d+)") beginDay, beginMonth, endDay, endMonth = tonumber(beginDay), tonumber(beginMonth), tonumber(endDay), tonumber(endMonth) if ((month == beginMonth and day >= beginDay) or (month == endMonth and day <= endDay)) then return sign, info end end end } Agora na pasta data/creaturescripts/scripts: No arquivo login.lua adicione isso antes do return: -- Zodiac registerCreatureEvent(cid, "zodiacKill") registerCreatureEvent(cid, "zodiacStats") if (getPlayerLastLogin(cid) <= 0 or getPlayerStorageValue(cid, 16160) == 1) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Please, when is your birthday date ? (Example: !zodiac day/month = !zodiac 1/2, !zodiac 23/7,...)") setPlayerStorageValue(cid, 16160, 1) -- Talk state else doPlayerSetSpecialDescription(cid, ", sign of " .. getPlayerStorageValue(cid, 16161)) end E crie esses arquivos: zodiacKill.lua dofile('data/lib/zodiac-Lib.lua') function getMonsterPath(monstername) f = io.open ("data/monster/monsters.xml", 'r') for line in f:lines() do _, _, name, path, file_name = string.find(line, '<monster name="(.+)" file="(.+)/(.+).xml"/>') if (name and path and file_name and name:lower() == monstername:lower()) then f:close() return path .. "/" .. file_name .. ".xml" end end end function getMonsterElementDefense(monstername, element) f = io.open ("data/monster/" .. getMonsterPath(monstername), 'r') for line in f:lines() do if (string.find(line, '</elements>')) then break end _, _, n = string.find(line, '<element '.. element:lower() ..'Percent="([-%d]+)"/>') if (n) then f:close() return tonumber(n) end end f:close() return 0 end ------- function onKill(cid, target, lastHit) if (isMonster(target) and getMonsterElementDefense(getCreatureName(target), (Zodiac.getElement(cid) == "Lighting" and "Energy" or Zodiac.getElement(cid))) > 0) then local exp_bonus = math.ceil(getMonsterInfo(getCreatureName(target)).experience * (Zodiac.constant.OPTION_EXTRA_EXP_RATE/100)) doSendAnimatedText(getThingPos(cid), exp_bonus, COLOR_GREY) doPlayerAddExperience(cid, exp_bonus) end return true end zodiacStats.lua dofile('data/lib/zodiac-Lib.lua') function onStatsChange(cid, attacker, type, combat, value) playerSign = Zodiac.get(cid) if (combat == Zodiac.constant.elements[Zodiac.getElement(cid)].combat) then valuem = math.ceil(value*(Zodiac.constant.OPTION_PERCENT_BLOCK/100)) doCreatureAddHealth(cid, valuem) doSendAnimatedText(getThingPos(cid), "+"..valuem, Zodiac.constant.elements[Zodiac.getElement(cid)].color) end return true end Certo, agora no arquivo data/creaturescripts/creaturescripts.xml, adicione isso: <event type="statschange" name="zodiacStats" event="script" value="zodiacStats.lua"/> <event type="kill" name="zodiacKill" event="script" value="zodiacKill.lua"/> Na pasta data/talkactions/scripts, adicione um arquivo Lua com o nome de zodiacTalk.lua: dofile('data/lib/zodiac-Lib.lua') function onSay(cid, words, param, channel) if (param:len() == 0) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can use '!zodiac day/month' or '!zodiac info'") return true end playerSign, Info = Zodiac.get(cid) if (type(playerSign) == "string" and param:lower() == "info") then doPlayerPopupFYI(cid, [[ Zodiac Informations ~ ------------------------------- * Sign: ]] .. playerSign .. [[ * Element: ]] .. Info.element .. [[ * Bonus: +]] .. Zodiac.constant.OPTION_EXTRA_EXP_RATE .. [[% experience of ]] .. Zodiac.getElement(cid) .. [[ monsters +]] .. Zodiac.constant.OPTION_PERCENT_BLOCK .. [[% of defense in attacks with ]] .. Zodiac.getElement(cid) .. [[ element ]]) elseif (getPlayerStorageValue(cid, 16160) == 1) then _, _, day, month = string.find(param, "(%d+)/(%d+)") day, month = tonumber(day), tonumber(month) if (day and month and day > 0 and day <= 31 and month > 0 and month <= 12) then Zodiac.set(cid, Zodiac.getSign(cid, day, month)) playerSign = Zodiac.get(cid) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, param) doSendMagicEffect(getThingPos(cid), math.random(28, 30)) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sign of zodiac is " .. playerSign .. " which is of element " .. Zodiac.getElement(cid) .. " !") doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can see more information saying '!zodiac info', remember this...") setPlayerStorageValue(cid, 16160, -1) else doPlayerSendCancel(cid, "You put a invalid date.") end end return true end Coloque essa tag no arquivo data/talkactions/talkactions.xml <talkaction words="!zodiac" event="script" value="zodiacTalk.lua"/> ChangeLog: 22/10/11: - Correção de um erro. E é isso !Qualquer dúvida, sugestão, critica só dizer ^^ Edited October 22, 2011 by Lwkass Share this post Link to post
Asould Acalaylaa 5 #2 Posted August 22, 2011 Que doidera, script maneiro. Deve ter sido dificil fazer ele, mas a idéia foi bem legal. Parabéns =) Share this post Link to post
iuniX 4 #3 Posted August 22, 2011 Um script realmente MUITO bem feito. Code impecável, ideia muito original e utilidade alta. Parabéns. Share this post Link to post
olealex 0 #4 Posted August 22, 2011 GZ! Finalmente algo de novo neste forum ... e bom! Share this post Link to post
dalvorsn 46 #5 Posted August 22, 2011 Idéia excelente, código impecável, o que posso dizer?! como sempre parabéns Ahh e parabéns pelo cargo também, você merece (Y) Share this post Link to post
dav9shal 1 #6 Posted August 22, 2011 Quais os signos que tem? Leo e qual otro? Achei mto bomk o script E principalmente ele ve qual é por data ^^ Share this post Link to post
xS0NYx 15 #7 Posted August 23, 2011 Achei muito bom, mas o problema é que as pessoas vão ficar criando várias contas com os signos, para ver qual ganha mais e vão escolher o que for mais conveniente ;/, mas o script mesmo está muito bom, parabéns ^^ Share this post Link to post
Lwkass 1 #8 Posted August 23, 2011 (edited) Então, eu fiquei sabendo que todas os signos tem elementos tipo, Leão é fogo, Peixe é agua, isso não fui eu que inventei, isso é segundo a astrologia Mas adicionei ao tópico qual o elemento de cada signo @xS0NYx: Todos os signos recebem a mesma quantidade de bônus, a unica coisa que muda é que são 4 elementos para 12 signos, ainda vou pensar melhor nisso e talvez criar algo mais bem bolado, mas valeu ai o/ Edited August 23, 2011 by Lwkass Share this post Link to post
Lyon 3 #9 Posted August 23, 2011 Esse Lwkass arrasa nos scripts,parabéns ficou show!! Share this post Link to post
Gorgulf 0 #10 Posted August 24, 2011 caraipo... ficou foda vey, queria ter um pouco dessa criatividade, kk Share this post Link to post
Iago Felipe 5 #11 Posted August 27, 2011 Seria legal se você fosse de um signo que pertence ao elemento fire, você iria hitar + quando atacasse com esse elemento. Seria bom também se o signo aparecesse na descrição do player quando desse look. Seria legal também, caso você pudesse entrar em quests específicas dependendo do seu signo, ou em cidades e/ou lugares específicos dependendo do seu signo, uma guerra entre os 4 elementos (os signos de fogo contra os signos de eletricidade, etc). Share this post Link to post
Chrisbp 0 #12 Posted August 27, 2011 Eu sou novo no negocio ainda e fiquei impressionado com esse script, olha tá de parabéns. Eu acho que em um servidor bem complexo esse script seria ideal, mas uma pergunta, o signo escolhido uma vez, não pode ser trocado? Certo? Share this post Link to post
tigerx2 1 #13 Posted August 28, 2011 O legal mesmo seria integrar com o website, bem melhor Sistemas em geral como este, ou o pet system são muito desvalorizados pelo fato de serem usados como talkaction. Mas o código está bem legal e organizado. Ideia criativa Share this post Link to post
Lwkass 1 #14 Posted August 28, 2011 #Iago Felipe: Mas o signo que o player possui aparece na descrição, mas por enquanto só funciona em servers que tem a função doPlayerSetSpecialDescription E vou levar todas as suas ideias em consideração quando fizer uma nova versão, obrigado ! #Chrisbp: Sim, o signo só é escolhido uma vez e não pode ser trocado #tigerx2: Sim sim, integrar com website é uma ótima ideia, pena que não mexo com web há tempos :x Share this post Link to post
Vittu 5 #15 Posted August 31, 2011 O sistema é muito criativo, seria melhor se fosse por NPC como o tygerx2 disse talkactions desvalorizam o script, mas mesmo assim esta muito bom. Share this post Link to post
Kekezito_LHP 1 #16 Posted October 21, 2011 Caraca Maravilhoso o script e uma coisa nova por forum e os otservs muito legal... Share this post Link to post
Lwkass 1 #17 Posted October 21, 2011 #Kekezito_LHP: Evite reviver tópicos com apenas comentário ! Aviso verbal Share this post Link to post
Biozard 0 #18 Posted October 21, 2011 Quando vou falar a data.. [Error - TalkAction Interface]data/talkactions/scripts/zodiacTalk.lua:onSay Description: data/lib/zodiac-Lib.lua:86: attempt to index a nil value stack traceback: data/lib/zodiac-Lib.lua:86: in function 'getElement' data/talkactions/scripts/zodiacTalk.lua:31: in function <data/talkaction s/scripts/zodiacTalk.lua:3> Share this post Link to post
Lwkass 1 #19 Posted October 21, 2011 #Biozard: Você disse a data usando !zodiac dia/mês ? (exemplo: !zodiac 3/11) Share this post Link to post