@Byerne
Fiz as alteraçoes e editei o topico.
Tem como pegar o Looktype do monstro pelo nome?
Aparece um erro dizendo que a criatura nao existe quando eu tento usar o getCreatureOutfit(monstername)
getCreatureOutfit(monster.uid).lookType
No caso, monster.uid tem que ser um Creature ID.
EX:
1- cid
2- na funçao onKill: target
Edit --
Como pegar o outfit do monstro pelo nome?
Nao tinha lido o topico principal .. mas seria assim:
getMonsterInfo(monstername).lookType
Tenta e me fala .. =)
Desculpem o double post mas precisava criar outro pra nao confundir.
Eu fiz e testei o script aqui para voce:
Edit -- Ele juntou os posts de qualquer maneira ¬¬
local config = {
addMonsterSpeed = true,
addMonsterOutfit = true,
addMonsterSpells = true,
addItemDescription = true,
conditionTime = 60, -- in seconds
storageSpells = 23155,
storageOutfit = 23255
}
local spells = {
["Demon"] = {
[1] = {learn = "Demon Beam", name = "Great Energy Beam", words = "demon gran vis lux"},
[2] = {learn = "Demon Explo", name = "Hells Core", words = "demon mas flam"}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local text = ""
local mname = getCreatureName(itemEx.uid)
if isMonster(itemEx.uid) then
doItemSetAttribute(item.uid, "transname", mname)
doItemSetAttribute(item.uid, "description", "It is enchanted with the powers of the "..mname..".")
doItemSetAttribute(item.uid, config.storageOutfit, getCreatureOutfit(itemEx.uid).lookType)
doItemSetAttribute(item.uid, config.storageOutfit+1, getCreatureOutfit(itemEx.uid).lookHead)
doItemSetAttribute(item.uid, config.storageOutfit+2, getCreatureOutfit(itemEx.uid).lookAddons)
doItemSetAttribute(item.uid, config.storageOutfit+3, getCreatureOutfit(itemEx.uid).lookLegs)
doItemSetAttribute(item.uid, config.storageOutfit+4, getCreatureOutfit(itemEx.uid).lookBody)
doItemSetAttribute(item.uid, config.storageOutfit+5, getCreatureOutfit(itemEx.uid).lookFeet)
text = text.."Your crystal has been enchanted. It have now the power of the "..mname.."."
if spells[mname] ~= nil then
s = spells[mname]
text = text.."\nMonster\'s spells saved with the crystal:"
doItemSetAttribute(item.uid, config.storageSpells, 0)
for x=1,table.maxn(s) do
doItemSetAttribute(item.uid, config.storageSpells, getItemAttribute(item.uid, config.storageSpells)+1)
doItemSetAttribute(item.uid, config.storageSpells+x, s[x].learn)
text = text.."\n#"..x.." - Name: "..s[x].name.." / Words: "..s[x].words.."."
end
doItemSetAttribute(item.uid, "description", getItemAttribute(item.uid, "description").." It have "..table.maxn(s).." spells stored in it.")
end
doPlayerSendTextMessage(cid, 18, text)
elseif isPlayer(itemEx.uid) then
if itemEx.uid ~= cid then
doPlayerSendCancel(cid, "You can only transform yourself with the crystal.")
return TRUE
end
transname = getItemAttribute(item.uid, "transname")
if transname ~= nil then
info = getMonsterInfo(tostring(transname))
doPlayerSendTextMessage(cid, 18, "You are now using the powers of the "..transname..".")
outfit = {lookType = tonumber(getItemAttribute(item.uid, config.storageOutfit)), lookHead = tonumber(getItemAttribute(item.uid, config.storageOutfit)+1), lookAddons = tonumber(getItemAttribute(item.uid, config.storageOutfit)+2), lookLegs = tonumber(getItemAttribute(item.uid, config.storageOutfit)+3), lookBody = tonumber(getItemAttribute(item.uid, config.storageOutfit)+4), lookFeet = tonumber(getItemAttribute(item.uid, config.storageOutfit)+5)}
doSetCreatureOutfit(cid, outfit, config.conditionTime*1000)
if getItemAttribute(item.uid, config.storageSpells) ~= nil then
spls = getItemAttribute(item.uid, config.storageSpells)
text2 = "You\'ve learned "..spls.." spells from your crystal:"
s = spells[transname]
for x=1,spls do
text2 = text2.."\n#"..x.." - Name: "..s[x].name.." / Words: "..s[x].words.."."
doPlayerLearnInstantSpell(cid, s[x].learn)
end
doPlayerSendTextMessage(cid, 18, text2)
end
else
doPlayerSendTextMessage(cid, 18, "Your crystal don\'t have any power stored.")
end
end
return true
end
Ele eh todo em actions, voce soh precisa colocar um item QUE NAO SEJA STACKABLE (que nao se junte, tipo gold coin).
Como funciona?
Voce usa em um monstro e ele salva o nome do monstro, o outfit do monstro e as spells do monstro (se configurado) no Crystal.
Se voce usar em voce mesmo depois disso ele vai te transformar no monstro e te dar as spells que ele salvou, se salvou.
Como adicionar novos monstros e spells???
Esta table tem o nome do monstro e as spells que ele vai dar. Mude como desejar.
local spells = {
["Demon"] = {
[1] = {learn = "Demon Beam", name = "Great Energy Beam", words = "demon gran vis lux"},
[2] = {learn = "Demon Explo", name = "Hells Core", words = "demon mas flam"}
}
}
Exemplo:
local spells = {
["Demon"] = {
[1] = {learn = "Demon Beam", name = "Great Energy Beam", words = "demon gran vis lux"},
[2] = {learn = "Demon Explo", name = "Hells Core", words = "demon mas flam"}
},
["Orc Spearman"] = {
[1] = {learn = "Orc Spearman Spear", name = "Ethereal Spear", words = "orc spearman con"}
}
}
Learn = nome da spell que voce vai criar no spells.xml
name = nome da spell que vai aparecer para o player.
words = words que serao faladas para a spell sair.
Depois disso voce precisara criar uma spell no Spells.xml assim: (OBS: aconselho pegar a spell equivalente (EX: exori con para a do Orc Spearman, copiar e modificar))
<instant name="OQUE VOCE COLOCOU NO LEARN" words="OQUE VOCE COLOCOU NO WORDS" lvl="OQUE VOCE QUISER" mana="OQUE VOCE QUISER" prem="DEPENDE" selftarget="DEPENDE" exhaustion="DEPENDE" needlearn="1" event="script" value="SCRIPT DA SPELL.lua">
<vocation id="1-8"/>
</instant>
Lembrando que "DEPENDE" significa que depende da Spell.
NEED LEARN TEM QUE ESTAR COMO 1.
'VOCATION ID="1-8"' significa que todas as vocations poderao usar.