Créditos: 100% Draky Lucas
O que é?
Cada level que você upa, você ganha uma quantidade de pontos configuráveis, que pode ser trocados por skills, vida e mana, porem sendo controlado o que pode ser trocado por vocação (assim. um knight, por exemplo, nao compraria ML)
PS: configurem vcs mesmos tudo na LIB
Funcionamento: Só colocar e ver oO
Video:
comandos:
/atributos
/atributos add, club
/atributos add, axe
/atributos add, sword
/atributos add, fist
/atributos add, shielding
/atributos add, distance
/atributos add, mana
/atributos add, vitality
/atributos reset
/atributos build
instalação:
em data/lib crie um arquivo chamado atributos.lua e nele adicione isso:
vocationPoints = { [0] = 3, [1] = 3, [2] = 3, [3] = 3, [4] = 3, [5] = 5, [6] = 5, [7] = 5, [8] = 5, } skills = { ["fist"] = {id = 0,neededPoints = 20,quantoGanha = 1,vocationNeeded={3,4,7,8}}, ["club"] = {id = 1,neededPoints = 30,quantoGanha = 1,vocationNeeded={4,8}}, ["sword"] = {id = 2,neededPoints = 30,quantoGanha = 1,vocationNeeded={4,8}}, ["axe"] = {id = 3,neededPoints = 30,quantoGanha = 1,vocationNeeded={4,8}}, ["distance"] = {id = 4,neededPoints = 30,quantoGanha = 1,vocationNeeded={3,7}}, ["shielding"] = {id = 5,neededPoints = 30,quantoGanha = 1,vocationNeeded={0,1,2,3,4,5,6,7,8}}, ["magic"] = {id = 7, neededPoints = 30,quantoGanha = 1,vocationNeeded={0,1,2,5,6}}, ["vitality"] = {id = 30,neededPoints = 3,quantoGanha = 5, vocationNeeded={0,1,2,3,4,5,6,7,8}}, ["mana"] = {id = 35,neededPoints = 3,quantoGanha = 5, vocationNeeded={0,1,2,3,4,5,6,7,8}}, } resetPreco = 100 storagesUtilizadas = { storageLevelJaPego = 12448, storagePontos = 12449, storageFistPoints = 12450, storageClubPoints = 12451, storageSwordPoints = 12452, storageAxePoints = 12453, storageDistancePoints = 12454, storageShieldingPoints = 12455, storageMagicPoints = 12456, storageVitalityPoints = 12457, storageManaPoints = 12458, storageFist = 12459, storageClub = 12460, storageSword = 12461, storageAxe = 12462, storageDistance = 12463, storageShielding = 12464, storageMagic = 12465, storageVitality = 12466, storageMana = 12467, } function getPontos(cid) return (getPlayerStorageValue(cid,storagesUtilizadas.storagePontos)) end function addPontos(cid,qtd) setPlayerStorageValue(cid,storagesUtilizadas.storagePontos,getPontos(cid) + qtd) end function addSkill(cid,id,pontosUsados,quantoGanha,vocationNeeded) if not isInArray(vocationNeeded,getPlayerVocation(cid)) then return "Sua vocacao nao pode adicionar esse atributo!" end if getPontos(cid) < pontosUsados then return "Voce nao tem pontos o suficiente para adicionar esse atributo!" end local storage = { [0] = {st1 = storagesUtilizadas.storageFist,st2 = storagesUtilizadas.storageFistPoints}, [1] = {st1 = storagesUtilizadas.storageClub,st2 = storagesUtilizadas.storageClubPoints}, [2] = {st1 = storagesUtilizadas.storageSword,st2 = storagesUtilizadas.storageSwordPoints}, [3] = {st1 = storagesUtilizadas.storageAxe,st2 = storagesUtilizadas.storageAxePoints}, [4] = {st1 = storagesUtilizadas.storageDistance,st2 = storagesUtilizadas.storageDistancePoints}, [5] = {st1 = storagesUtilizadas.storageShielding,st2 = storagesUtilizadas.storageShieldingPoints}, [7] = {st1 = storagesUtilizadas.storageMagic,st2 = storagesUtilizadas.storageMagicPoints}, [30] = {st1 = storagesUtilizadas.storageVitality,st2 = storagesUtilizadas.storageVitalityPoints}, [35] = {st1 = storagesUtilizadas.storageMana,st2 = storagesUtilizadas.storageManaPoints}, } if id == 30 then setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + quantoGanha) doCreatureAddHealth(cid, quantoGanha) elseif id == 35 then setCreatureMaxMana(cid, getCreatureMaxMana(cid) + quantoGanha) doCreatureAddMana(cid, quantoGanha) else if id == 7 then doPlayerAddMagLevel(cid, quantoGanha) else doPlayerAddSkillTry(cid, id, getPlayerRequiredSkillTries(cid, id, getPlayerSkillLevel(cid, id) + quantoGanha),false) end end setPlayerStorageValue(cid,storage[id].st1,getPlayerStorageValue(cid,storage[id].st1) + quantoGanha) setPlayerStorageValue(cid,storage[id].st2,getPlayerStorageValue(cid,storage[id].st2) + pontosUsados) addPontos(cid,- pontosUsados) doSendMagicEffect(getCreaturePosition(cid), 30) return "Atributo adicionado!" end function resetPontos(cid) for i = storagesUtilizadas.storageFistPoints,storagesUtilizadas.storageManaPoints do addPontos(cid,getPlayerStorageValue(cid,i)) setPlayerStorageValue(cid,i,0) end local guid = getPlayerGUID(cid) local atuais = { hp = getCreatureMaxHealth(cid) - (getPlayerStorageValue(cid,storagesUtilizadas.storageVitality)), mp = getPlayerMaxMana(cid) - (getPlayerStorageValue(cid,storagesUtilizadas.storageMana)), magic = getPlayerMagLevel(cid) - (getPlayerStorageValue(cid,storagesUtilizadas.storageMagic)), fist = getPlayerSkillLevel(cid, 0) - (getPlayerStorageValue(cid,storagesUtilizadas.storageFist)), club = getPlayerSkillLevel(cid, 1) - (getPlayerStorageValue(cid,storagesUtilizadas.storageClub)), sword = getPlayerSkillLevel(cid, 2) - (getPlayerStorageValue(cid,storagesUtilizadas.storageSword)), axe = getPlayerSkillLevel(cid, 3) - (getPlayerStorageValue(cid,storagesUtilizadas.storageAxe)), dist = getPlayerSkillLevel(cid, 4) - (getPlayerStorageValue(cid,storagesUtilizadas.storageDistance)), shield = getPlayerSkillLevel(cid, 5) - (getPlayerStorageValue(cid,storagesUtilizadas.storageShielding)), } doRemoveCreature(cid) db.executeQuery("UPDATE `players` SET `maglevel` = " .. atuais.magic .. " WHERE `id` = "..guid) db.executeQuery("UPDATE `players` SET `health` = " .. atuais.hp .. " WHERE `id` = "..guid) db.executeQuery("UPDATE `players` SET `healthmax` = " .. atuais.hp .. " WHERE `id` = "..guid) db.executeQuery("UPDATE `players` SET `mana` = " .. atuais.mp .. " WHERE `id` = "..guid) db.executeQuery("UPDATE `players` SET `manamax` = " .. atuais.mp .. " WHERE `id` = "..guid) db.executeQuery("UPDATE `player_skills` SET `value` = " .. atuais.fist .. " WHERE `player_id` = "..guid .. " AND `skillid` = 0") db.executeQuery("UPDATE `player_skills` SET `value` = " .. atuais.club .. " WHERE `player_id` = "..guid .. " AND `skillid` = 1") db.executeQuery("UPDATE `player_skills` SET `value` = " .. atuais.sword .. " WHERE `player_id` = "..guid .. " AND `skillid` = 2") db.executeQuery("UPDATE `player_skills` SET `value` = " .. atuais.axe .. " WHERE `player_id` = "..guid .. " AND `skillid` = 3") db.executeQuery("UPDATE `player_skills` SET `value` = " .. atuais.dist .. " WHERE `player_id` = "..guid .. " AND `skillid` = 4") db.executeQuery("UPDATE `player_skills` SET `value` = " .. atuais.shield .. " WHERE `player_id` = "..guid .. " AND `skillid` = 5") for i = storagesUtilizadas.storageFist, storagesUtilizadas.storageMana do db.executeQuery("UPDATE `player_storage` SET `value` = 0 WHERE `key` = "..i .. " and `player_id` = " ..guid) end return true end
agora em data/talkactions/scripts crie uma pasta chamada drakylucas e nela crie um arquivo chamado atributos.lua , colocando isso nele:
function onSay(cid, words, param) local param = param:lower() local op = string.explode(param, ",") local text = "" if param == nil or (op[1] ~= "reset" and op[1] ~= "add" and op[1] ~= "build") then text = text .. "Pontos: " .. getPontos(cid) .. "\nSua vocação ganha: " .. vocationPoints[getPlayerVocation(cid)] .. " pontos por level" .. "\n\nNome - Precisa - Ganha -- Para sua voc" for i, x in pairs(skills) do if isInArray(x.vocationNeeded,getPlayerVocation(cid)) then text = text .. "\n"..i.. " - " ..x.neededPoints.. " - " .. x.quantoGanha .. "" end end text = text .. "\n\nExemplos:\n/atributos add,mana\n/atributos add,vitality" text = text .. "\nVoce pode resetar seus atributos: Digite /atributos reset (custa " .. resetPreco.."k)\nVeja sua build: /atributos build" return doShowTextDialog(cid, 1976, text) end if op[1] == "reset" then if getCreatureCondition(cid, CONDITION_INFIGHT) == true then return doPlayerSendCancel(cid,"Voce tem que estar sem battle para resetar seus atributos") end if getPlayerMoney(cid) < (resetPreco*1000) then return doPlayerSendCancel(cid,"Voce nao tem dinheiro suficiente para resetar seus atributos!") end doPlayerRemoveMoney(cid, resetPreco*1000) return resetPontos(cid) end if op[1] == "add" then if skills[op[2]] == nil then return doPlayerSendTextMessage(cid,19,"atributo nao existente. Verifique sua ortografia!") end doPlayerSendTextMessage(cid,19,addSkill(cid,skills[op[2]].id,skills[op[2]].neededPoints,skills[op[2]].quantoGanha,skills[op[2]].vocationNeeded)) return true end if op[1] == "build" then local atuais = { hp = (getPlayerStorageValue(cid,storagesUtilizadas.storageVitality)), mp = (getPlayerStorageValue(cid,storagesUtilizadas.storageMana)), magic = (getPlayerStorageValue(cid,storagesUtilizadas.storageMagic)), fist = (getPlayerStorageValue(cid,storagesUtilizadas.storageFist)), club = (getPlayerStorageValue(cid,storagesUtilizadas.storageClub)), sword = (getPlayerStorageValue(cid,storagesUtilizadas.storageSword)), axe = (getPlayerStorageValue(cid,storagesUtilizadas.storageAxe)), dist = (getPlayerStorageValue(cid,storagesUtilizadas.storageDistance)), shield = (getPlayerStorageValue(cid,storagesUtilizadas.storageShielding)), } text = "Quantidades de atributos ja recebidos: \n" .. "Vitality: "..atuais.hp.." \n" .. "Mana: "..atuais.mp.." \n" .. "Magic: "..atuais.magic.." \n" .. "Fist: "..atuais.fist.." \n" .. "Club: "..atuais.club.." \n" .. "Sword: "..atuais.sword.." \n" .. "Axe: "..atuais.axe.." \n" .. "Distance: "..atuais.dist.." \n" .. "Shielding: "..atuais.shield.." \n" .. "Pontos restantes: " .. getPontos(cid) doShowTextDialog(cid, 1976, text) return true end return true end
agora em data/creaturescripts/scripts crie uma pasta chamada drakylucas e nela crie um arquivo chamado atributos.lua (sim, todos arquivos tem o mesmo nome.. cuidado nas pastas) e coloque isso:
function onAdvance(cid, skill, oldLevel, newLevel) if not (vocationPoints[getPlayerVocation(cid)]) then return true end if skill == 8 then if getPlayerStorageValue(cid, storagesUtilizadas.storageLevelJaPego) < newLevel then local pts = (newLevel - (1 + getPlayerStorageValue(cid, storagesUtilizadas.storageLevelJaPego))) * vocationPoints[getPlayerVocation(cid)] addPontos(cid,pts) setPlayerStorageValue(cid,storagesUtilizadas.storageLevelJaPego,newLevel -1) doSendAnimatedText(getCreaturePosition(cid), "+"..pts, math.random(1,200)) end end return true end
agora em data/creaturescripts/scripts, abre o login.lua e coloque isso ANTES do último return true:
-- attribute system by draky lucas if getPlayerStorageValue(cid,storagesUtilizadas.storageLevelJaPego) == -1 then for i = storagesUtilizadas.storageLevelJaPego,storagesUtilizadas.storageMana do setPlayerStorageValue(cid,i,0) end end registerCreatureEvent(cid,"avancarGanharPontos") --
agora em data/talkactions/talkactions.xml coloque isso:
<talkaction words="/atributos" event="script" value="drakylucas/atributos.lua"/>
agora em data/creaturescripts/creaturescripts.xml coloque isso:
<event type="advance" name="avancarGanharPontos" event="script" value="drakylucas/atributos.lua"/>
reinicie o servidor e divirta-se.
PS: não sei se funciona com sqlite.. eu uso MYSQL como banco de dados.
Testado com TFS 0.4 Rev 3887 8.60
Por favor, nao deixem de comentar, desanima criar coisas e a cada 100 visitas, apenas um comentario.
EDIT: Arrumado bug do magiclevel!