Postado Março 25, 2017 8 anos Fala pessoal do TibiaKing, Como faço um item que ao dar use, refina minha spell pra +1. Deixando ela 10% mais forte. Ex: Quando eu soltar um exori sem refino vai sair assim: Exori +0, com refino: Exori +1. Grato desde já!
Postado Março 25, 2017 8 anos Esta é a spell. local config = { seconds = 0, storage = 0, msg = "Você precisa aguardar %d segundos para usar essa magia novamente.", mana = 0, semMana = "Você não tem mana suficiente.", } local function useAgain(cid) setPlayerStorageValue(cid, config.storage, 2) return TRUE end local combat1 = createCombatObject() setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat1, COMBAT_PARAM_EFFECT, 9) setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -5, 0, -5, 0) local combat2 = createCombatObject() setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat2, COMBAT_PARAM_EFFECT, 9) setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -6, 0, -6, 0) area1 = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 3, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, } area2 = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 3, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, } local area1 = createCombatArea(area1) local area2 = createCombatArea(area2) setCombatArea(combat1, area1) setCombatArea(combat2, area2) function onUseWeapon(cid, var) if getPlayerStorageValue(cid, config.storage) == -1 then setPlayerStorageValue(cid, config.storage, os.time()-config.seconds) end if config.seconds-(os.time()-getPlayerStorageValue(cid, config.storage)) > 0 then doPlayerSendCancel(cid, string.format(config.msg, config.seconds-(os.time()-getPlayerStorageValue(cid, config.storage)))) return true end if getPlayerMana(cid) >= config.mana then doPlayerAddMana(cid, -config.mana) setPlayerStorageValue(cid, config.storage, os.time()) if getPlayerStorageValue(cid, 32150) - os.time() <= 0 then addEvent(doCombat, 000, cid, combat1, var) else addEvent(doCombat, 000, cid, combat2, var) end else doPlayerSendCancel(cid, config.semMana) end return true end Agora vamos explicar, 32150 é o storage da spell melhorada. Ou seja se o player não tiver o storage ele vai atacar com combat1 se ele tiver o storage ele vai atacar com combat2. Só é possível 2 níveis, porque seria 1 storage diferente para cada nível. Vá em data/action/scripts e crie 1 arquivo teste.lua dentro dele cole isto function onUse(cid, item) if getPlayerStorageValue(cid, 32150) < 0 then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Agora seu exori está evoluído.") setPlayerStorageValue(cid, 32150,1) doRemoveItem(item.uid, 1) else doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Voce ja evoluiu seu exori.") end return TRUE end Agora em actions.xml adicione esta tag <action itemid="ID-DO-ITEM" script="teste.lua"/> xD. Ajudei? REP+ Agora o porque de não poder evoluir ela mais que 1x é simples, o player sem a storage 32150, usa a spell normalmente, porém quando ele obtêm a storage, ele passa a usar a spell mais forte, se fosse pra evoluir 3x, ele precisaria de outro storage, porém o storage 32150 ainda vai estar nele, ou seja vai confundir o jogo se é para usar a spell nível 2 ou nível 3, anão ser que remova a storage 32150 do player. Editado Março 25, 2017 8 anos por Joaovettor (veja o histórico de edições)
Postado Março 25, 2017 8 anos Autor 6 horas atrás, Joaovettor disse: Primeiramente, muito obrigado por me ajudar! Eu usei a spell dentro do jogo e não funcionou, o nome da spell aparece no default como se não existisse. Outra coisa, se não for abusar, tem como criar essa spell até o nível +10? removendo a storage id do +1 quando evoluir pra +2, sucessivamente? Grato desde já! EDIT: Encontrei um spell upgrade system feito para TFS 1.0, 1.2 Não entendi muito bem o script mas parece que existe um tipo de ranking, Aprendiz, Journeyman, Adept... O action pelo que eu vi posso configurar um item que ao dar use a spell fica +1, +2 só que não existe nenhuma storage. Vou postar o script, veja se é possível adaptar pra TFS 0.4. Global.lua function upGradeSpells(player, words, tier, max) if player:getStorageValue(SPELL_WORDS[words]) < max then if player:getStorageValue(SPELL_WORDS[words]) < TIER[tier] then player:setStorageValue(SPELL_WORDS[words], TIER[tier]) player:getPosition():sendMagicEffect(CONST_ME_CONFETTI_HORIZONTAL) doCreatureSay(cid, tier, TALKTYPE_ORANGE_1, false, 0, player:getPosition()) elseif player:getStorageValue(SPELL_WORDS[words]) == TIER[tier] then player:sendCancelMessage("You've already scribed a this version of the spell.") player:getPosition():sendMagicEffect(CONST_ME_POFF) return false else player:sendCancelMessage("You already have a higher spell version scribed.") player:getPosition():sendMagicEffect(CONST_ME_POFF) return false end else player:sendCancelMessage("You've reached the maximum tier for this spell.") player:getPosition():sendMagicEffect(CONST_ME_POFF) return false end end --light, haste, single targets, area, single target heal, support spell, speed SPELL_WORDS = { ["exura dis"] = 1001, ["exevo dis flam hur"] = 1002, ["exiva"] = 1003, ["exori min flam"] = 1004, ["utevo lux"] = 1005, ["exura"] = 1006, ["exani tera"] = 1007, ["exura ico"] = 1008, ["exana pox"] = 1009, ["exani hur"] = 10010, ["exori vis"] = 10011, ["exori tera"] = 10012, ["exevo con"] = 10013, ["utevo gran lux"] = 10014, ["exori flam"] = 10015, ["exevo pan"] = 10016, ["adevo grav pox"] = 10017, ["utamo vita"] = 10018, ["utani hur"] = 10019, ["adevo grav flam"] = 10020, ["exori frigo"] = 10021, ["adori min vis"] = 10022, ["adana pox"] = 10023, ["adura gran"] = 10024, ["exori moe ico"] = 10025, ["exevo con pox"] = 10026, ["exori mort"] = 10027, ["exori ico"] = 10028, ["adeta sio"] = 10029, ["adito grav"] = 10030, ["exevo con mort"] = 10031, ["adevo grav vis"] = 10032, ["exevo flam hur"] = 10033, ["exura sio"] = 10034, ["exevo frigo hur"] = 10035, ["exura gran"] = 10036, ["utani gran hur"] = 10037, ["exeta res"] = 10038, ["adori blank"] = 10039, ["adito tera"] = 10040, ["exana vis"] = 10041, ["exevo vis lux"] = 10042, ["utevo res ina"] = 10043, ["exori con"] = 10044, ["exevo con hur"] = 10045, ["adori tera"] = 10046, ["adura vita"] = 10047, ["adevo mas pox"] = 10048, ["adori vis"] = 10049, ["exevo con flam"] = 10050, ["utani tempo hur"] = 10051, ["utevo res"] = 10052, ["utori flam"] = 10053, ["utevo vis lux"] = 10054, ["exana ina"] = 10055, ["adevo mas flam"] = 10056, ["adevo res flam"] = 10057, ["adori san"] = 10058, ["adori flam"] = 10059, ["adevo ina"] = 10060, ["adana mort"] = 10061, ["adevo grav vita"] = 10062, ["adori frigo"] = 10063, ["exori hur"] = 10064, ["adori mas vis"] = 10065, ["adori mas tera"] = 10066, ["exevo gran vis lux"] = 10067, ["adevo mas grav pox"] = 10068, ["exura vita"] = 10069, ["exana flam"] = 10070, ["adori mas frigo"] = 10071, ["adori mas flam"] = 10072, ["adevo mas hur"] = 10073, ["adevo grav tera"] = 10074, ["utura mas sio"] = 10075, ["utori mas sio"] = 10076, ["utito mas sio"] = 10077, ["utamo mas sio"] = 10078, ["adevo mas grav flam"] = 10079, ["exevo con grav"] = 10080, ["exori mas"] = 10081, ["utori vis"] = 10082, ["utana vid"] = 10083, ["exori"] = 10084, ["exura san"] = 10085, ["exura gran mas res"] = 10086, ["adevo mas vis"] = 10087, ["exevo vis hur"] = 10088, ["exevo tera hur"] = 10089, ["exori san"] = 10090, ["exevo gran frigo hur"] = 10091, ["utori kor"] = 10092, ["adevo mas grav vis"] = 10093, ["exeta vis"] = 10094, ["exeta con"] = 10095, ["exana kor"] = 10096, ["adori gran mort"] = 10097, ["utura"] = 10098, ["utori pox"] = 10099, ["exevo mas san"] = 100100, ["adana ani"] = 100101, ["utamo tempo san"] = 100102, ["exevo gran mas tera"] = 100103, ["utamo tempo"] = 100104, ["exevo gran mas vis"] = 100105, ["exori amp vis"] = 100106, ["exevo con vis"] = 100107, ["utito tempo san"] = 100108, ["exura gran san"] = 100109, ["exevo gran mas frigo"] = 100110, ["exevo gran mas flam"] = 100111, ["utito tempo"] = 100112, ["exori gran tera"] = 100113, ["exori gran flam"] = 100114, ["exori min"] = 100115, ["utori san"] = 100116, ["utori mort"] = 100117, ["exori gran vis"] = 100118, ["exana mort"] = 100119, ["exura gran ico"] = 100120, ["exori gran frigo"] = 100121, ["exori max flam"] = 100122, ["exori max tera"] = 100123, ["exori gran con"] = 100124, ["exori gran"] = 100125, ["exori max frigo"] = 100126, ["exori max vis"] = 100127, ["utura gran"] = 100128, ["exori gran ico"] = 100129 } TIER = { ["Apprentice"] = 0, ["Journeyman"] = 1, ["Adept"] = 2, ["Expert"] = 3, ["Master"] = 4, ["Grandmaster"] = 5 } data\chatchannels\chatchannels.xml <?xml version="1.0" encoding="UTF-8"?> <channels> <channel id="2" name="Tutor" script="tutor.lua" /> <channel id="3" name="World Chat" public="1" script="worldchat.lua" /> <channel id="4" name="Spells" public="1" script="spells.lua" /> <channel id="5" name="Trade" public="1" script="advertising.lua" /> <channel id="6" name="Advertising-Rookgaard" public="1" script="advertising-rook.lua" /> <channel id="7" name="Help" public="1" script="help.lua" /> <channel id="8" name="Gamemaster" script="gamemaster.lua" /> </channels> data\chatchannels\scripts\spells.lua local CHANNEL_CHARACTER = 4 local tier = { [0] = "[ Apprentice ]", [1] = "[ Journeyman ]", [2] = "[ Adept ]", [3] = "[ Expert ]", [4] = "[ Master ]", [5] = "[ Grandmaster ]" } local function listSpells(player) local count = getPlayerInstantSpellCount(player) local text = "" local t = {} for i = 0, count - 1 do local spell = getPlayerInstantSpellInfo(player, i) if spell.level ~= 0 then if spell.manapercent > 0 then spell.mana = spell.manapercent .. "%" end t[#t+1] = spell end end table.sort(t, function(a, b) return a.level < b.level end) local prevLevel = -1 for i, spell in ipairs(t) do local line = "" if prevLevel ~= spell.level then if i ~= 1 then line = "\n" end line = line .. "\nSpells for Level " .. spell.level .. "\n" prevLevel = spell.level player:sendChannelMessage(cid, line, TALKTYPE_CHANNEL_O, CHANNEL_CHARACTER) end if player:getStorageValue(SPELL_WORDS[spell.words]) > 0 then local index = player:getStorageValue(SPELL_WORDS[spell.words]) text = " " .. spell.words .. " " .. tier[index] .. " - " .. spell.name .. " : " .. spell.mana .. "\n" else text = " " .. spell.words .. " " .. tier[0] .. " - " .. spell.name .. " : " .. spell.mana .. "\n" end player:sendChannelMessage(cid, text, TALKTYPE_CHANNEL_Y, CHANNEL_CHARACTER) end end function onJoin(player) addEvent(listSpells, 100, player) return true end function onSpeak(player, type, message) player:sendCancelMessage("You may not speak in this chat.") return false end Exemplo: data\actions\scripts\spells.lua function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey) upGradeSpells(cid, "exevo pan", 1, item) return true end Exemplo na spell: local food = { 2666, -- meat 2671, -- ham 2681, -- grape 2674, -- apple 2689, -- bread 2690, -- roll 2696 -- cheese } function onCastSpell(creature, var) if not creature:isPlayer() then return false end if creature:getStorageValue(SPELL_WORDS["exevo pan"]) > 0 then -- if the tier is higher then apprentice increase the amount of food created creature:addItem(food[math.random(#food)], (creature:getStorageValue(SPELL_WORDS["exevo pan"]) + 1)) creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) else -- else give 1 piece of food creature:addItem(food[math.random(#food)], 1) creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) end return true end Editado Março 25, 2017 8 anos por Thayguroficial (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.