Sistema de spellbook

Poccnn
Por Poccnn
em CreatureScripts e Movements

Poccnn

Enquanto houver armas no mundo, haverá guerra!
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 07/03/16Posts: 1418Gênero: Masculino

Hail Xtibianos.

 

Eu criei esse sistema para impedir que mages usem magias sem estarem usando o livro. 

Cada livro libera uma certa quantidade de magias, logo, os mages terão que ter o livro para usarem determinadas magias mesmo eles tendo o level requerido por ela.

 

Tu irás a precisar usar essa livraria para poder usar esse sistema:

 

Em movements.xml adicione:

Spoiler
	<movevent type="Equip" fromid="8905" toid="8909" slot="shield" level="100" event="function" value="onEquipItem">	</movevent>	<movevent type="DeEquip" fromid="8905" toid="8909" slot="shield" event="function" value="onDeEquipItem"/>	<movevent type="Equip" itemid="8190" slot="shield" level="8" event="script" value="spellbooks.lua">		<vocation id="1"/>		<vocation id="5"/>		<vocation id="2"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8190" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8900" slot="shield" level="30" event="script" value="spellbooks.lua">		<vocation id="1"/>		<vocation id="5"/>		<vocation id="2"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8900" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8901" slot="shield" level="40" event="script" value="spellbooks.lua">		<vocation id="1"/>		<vocation id="5"/>		<vocation id="2"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8901" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8902" slot="shield" level="50" event="script" value="spellbooks.lua">		<vocation id="1"/>		<vocation id="2"/>		<vocation id="5"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8902" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8903" slot="shield" level="60" event="script" value="spellbooks.lua">		<vocation id="1"/>		<vocation id="5"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8903" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8904" slot="shield" level="70" event="script" value="spellbooks.lua">		<vocation id="5"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8904" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8918" slot="shield" level="80" event="script" value="spellbooks.lua">		<vocation id="5"/>		<vocation id="6"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8918" slot="shield" event="script" value="spellbooks.lua"/>	<movevent type="Equip" itemid="8983" slot="shield" level="120" event="script" value="spellbooks.lua">		<vocation id="5"/>		<vocation id="9"/>		<vocation id="10"/>	</movevent>	<movevent type="DeEquip" itemid="8983" slot="shield" event="script" value="spellbooks.lua"/>

 

 

Em movements/scripts crie um arquivo lua chamado spellbooks e adicione:

Spoiler
local tab = {	[8190] = {		"Find Person","Ultimate Healing","Magic Shield","Strong Haste","Antidote pox","Antidote fire","antidote vis","Heal Friend","Cure Friend",		"Death Strike" ,"Flame Strike","Energy Strike","Ice Strike","Terra Strike","Fire Wave","Ice Wave","Energy Beam","Great Energy Beam","Creature Illusion",		"Ultimate Light","Cancel Invisibility","Invisibility","Summon Creature","Poison Field","Light Magic Missile","Fire Field","Fireball","Energy Field","Stalagmite",		"Heavy Magic Missile","Poison Bomb","Firebomb","Soulfire","Poison Wall","Antidote Rune","Ultimate Healing Rune","Animate Dead","Chameleon",		"Destroy Field","Desintegrate","Wild Growth","Icicle","Stone Shower","Thunderstorm" },	[8900] = {		"Energy Wave","Terra Wave","Mass Healing","Heal Party","Enchant Party","Great Fireball","Explosion","Fire Wall","Energybomb",		"Magic Wall","Avalanche","Enchant Tera","Enchant Ice","Enchant Flam","Enchant Vis"},--30	[8901] = {"Enchant Staff","Energy Wall","Sudden Death"},--40	[8902] = {"Rage of the Skies","Wrath of Nature","Paralyze"},--50	[8903] = {"Hells Core","Eternal Winter","Undead Legion","pocion"},--60	[8904] = {"Ultimate Mana Rune"},--70	[8918] = {"wave of fire"},--80	[8983] = {"Death Mort","Apocalypse","Death Wave"},}local ML1 = createConditionObject(CONDITION_ATTRIBUTES)local ML2 = createConditionObject(CONDITION_ATTRIBUTES)local ML3 = createConditionObject(CONDITION_ATTRIBUTES)local ML4 = createConditionObject(CONDITION_ATTRIBUTES)setConditionParam(ML1, CONDITION_PARAM_TICKS, 24 * 60 * 60 * 1000)setConditionParam(ML2, CONDITION_PARAM_TICKS, 24 * 60 * 60 * 1000)setConditionParam(ML3, CONDITION_PARAM_TICKS, 24 * 60 * 60 * 1000)setConditionParam(ML4, CONDITION_PARAM_TICKS, 24 * 60 * 60 * 1000)setConditionParam(ML1, CONDITION_PARAM_STAT_MAGICLEVEL, 1)setConditionParam(ML2, CONDITION_PARAM_STAT_MAGICLEVEL, 2)setConditionParam(ML3, CONDITION_PARAM_STAT_MAGICLEVEL, 3)setConditionParam(ML4, CONDITION_PARAM_STAT_MAGICLEVEL, 4)setConditionParam(ML1, CONDITION_PARAM_SKILL_SHIELD, -1)setConditionParam(ML2, CONDITION_PARAM_SKILL_SHIELD, -2)setConditionParam(ML3, CONDITION_PARAM_SKILL_SHIELD, -3)setConditionParam(ML4, CONDITION_PARAM_SKILL_SHIELD, -4)local function getItemAttrInFile(id,key) --[[( Marcryzius )]]--local tipo = (type(id) == 'number') and 'id' or 'name'local file = xml:load('data/items/items.xml')local lerfile = file:find("item",tipo,id)	for _,tab in pairs(lerfile) do		if(type(tab) == "table")then			if(tab.key == key)then				return tab.value			end		end	end	return falseendlocal function getBookRequirementLevelByVoc(id,voc) --[[( Marcryzius )]]--local file = xml:load('data/movements/movements.xml')local lerfile = file:find("movevent type=\"Equip\"","itemid",id)	for _,tab in pairs(lerfile) do		if(type(tab) == "table")then			if(tonumber(tab.id) == voc)then				return tonumber(lerfile.level)			end		end	end	return falseendfunction onEquip(cid, item, slot)local level = getBookRequirementLevelByVoc(item.itemid,getPlayerVocation(cid))	if not(level) or (getPlayerLevel(cid) < level)then		return false	else		for id,tab in pairs(tab) do			for _,name in pairs(tab) do				if(id <= item.itemid)then					playerLearnInstantSpell(cid,name)				end			end		end		local attr  = tonumber(getItemAttrInFile(item.itemid,"magiclevelpoints"))		doAddCondition(cid, (attr == 1) and ML1 or attr == 2 and ML2 or (attr == 3) and ML3 or (attr == 4) == ML4 or nil)	end	return trueendfunction onDeEquip(cid, item, slot)	for _, v in pairs(tab) do		for _,name in pairs(v) do			doPlayerUnlearnInstantSpell(cid,name)		end	end	doRemoveCondition(cid,CONDITION_ATTRIBUTES)	return trueend 

 

 

Aconselho substituir o código do spellbook em actions por esse:

Em actions.xml verifique se existe todos essas tags, caso não, adicione:

Spoiler
	<action itemid="2175" event="script" value="other/spellbook.lua"/>	<action itemid="6120" event="script" value="other/spellbook.lua"/>	<action itemid="8190" event="script" value="other/spellbook.lua"/>	<action fromid="8900" toid="8904" event="script" value="other/spellbook.lua"/>	<action itemid="8918" event="script" value="other/spellbook.lua"/>	<action itemid="8983" event="script" value="other/spellbook.lua"/>

 

Em actions/scripts/other/spellbooks.lua apague o seu conteúdo e adicione este:

Spoiler
function onUse(cid, item, fromPosition, itemEx, toPosition)	local count = getPlayerInstantSpellCount(cid)	local text,plvl = "",getPlayerLevel(cid)	local t = {}	local ope = xml:load("data/spells/spells.xml")			for i = 0, count-1 do		local spell = getPlayerInstantSpellInfo(cid, i)		local ler = ope:find("%a+","words", spell.words)		local check,prem = nil, tonumber(ler.prem) == 1 and true or false		for index,tab in pairs(ler) do			if(type(tab) == "table")then				if(tonumber(tab.id) == getPlayerVocation(cid))then					check = true;break				end			end		end		if spell.level ~= 0 and check then			if not(prem) or prem == isPremium(cid) then				if spell.manapercent > 0 then					spell.mana = spell.manapercent .. "%"				end				table.insert(t, spell)				check = nil				if(spell.level > plvl)then break end			end		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			if i == #t and spell.level > plvl then 		line = line.."Next spell > " end			line = line .. "Spells for Level " .. spell.level .. "\n"			prevLevel = spell.level		end		text = text .. line .. "  " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"	end	doShowTextDialog(cid, item.itemid, text)	return trueend

 

Mais realidade para o verdadeiro tibia.

Qualquer duvida, erro e etc, deixe nos comentários. 

"Deus é amor, mas matou 99,99999% de todos os seres viventes do mundo com o diluvio.

Deus é misericórdia, mas condena as pessoas ao tormento eterno do inferno.

Deus é pai, mas abandonou seus filhos a servidão.

Deus é vida, mas condenou a humanidade a morte.

Deus é o senhor. Senhor das guerras, da morte, do ódio.

 

Ninguém que ame a humanidade, mataria 99,99999% da população, não só de humanos, bem como dos demais animais, por amor. Isso não é amor, é doença, psicose de um sádico que gosta de ver sua 'criação' sofrer e ainda quer 'pagar' de misericordioso, de deus amor.

 

Não quero seu amor; não quero sua misericórdia, não quero ser seu filho, não quero sua vida, não quero que seja meu senhor.

Tu és um psicótico, doente, hipócrita, assassino; não me venha querer se passar por bondoso, amoroso, misericordioso."

Poccnn

Enquanto houver armas no mundo, haverá guerra!
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 07/03/16Posts: 1418Gênero: Masculino
10 minutos atrás, NelsonMaldonado disse:

TFS 0.4

 

Seu servidor é derivado? ou tem sources modificadas?

"Deus é amor, mas matou 99,99999% de todos os seres viventes do mundo com o diluvio.

Deus é misericórdia, mas condena as pessoas ao tormento eterno do inferno.

Deus é pai, mas abandonou seus filhos a servidão.

Deus é vida, mas condenou a humanidade a morte.

Deus é o senhor. Senhor das guerras, da morte, do ódio.

 

Ninguém que ame a humanidade, mataria 99,99999% da população, não só de humanos, bem como dos demais animais, por amor. Isso não é amor, é doença, psicose de um sádico que gosta de ver sua 'criação' sofrer e ainda quer 'pagar' de misericordioso, de deus amor.

 

Não quero seu amor; não quero sua misericórdia, não quero ser seu filho, não quero sua vida, não quero que seja meu senhor.

Tu és um psicótico, doente, hipócrita, assassino; não me venha querer se passar por bondoso, amoroso, misericordioso."

NelsonMaldonado

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/01/14Posts: 19

Sources limpias (rev 3884)

Eu usei outros executable  ://e erro ainda