Vim postar o Gem System como meu 4º tópico do XTibia!
Vi em alguns tópicos tutoriais do Gem System, mas nenhum funcionava, todos estavam bugados e errados, então, finalmente consegui achar o bendito mapa Foxworld escondido la nos cafundó e veio junto o Gem System ^^
Então, vim aqui trazer ele, tentei por em um otserver 8.4 e pegou!
SS:
O Que é Gem System? Já jogou Foxworld? É aqueles cristais que quando você clica poderá usar alguns poderes e aparece uns riscos do lado de seu char.
Mãos a obra, primeiramente vá em data/actions/scripts, copie um arquivo.lua e cole, renomeie-o para gems e dentro cole:
function onUse(cid, item, fromPosition, itemEx, toPosition)
gem = gems.id[getPlayerVocation(cid)]
if item.itemid == gem then
doUseGem(cid, item, getPlayerVocation(cid))
end
return TRUE
end
Agora vá em data/actions/actions.xml e ponha em alguma linha:
<action itemid="2156" script="gems.lua"/>
<action itemid="2155" script="gems.lua"/>
<action itemid="2158" script="gems.lua"/>
<action itemid="2153" script="gems.lua"/>
Depois de feito isto, vá em data/lib, copie dois arquivos.lua e em um ponha Pivi, neste Pivi cole:
function doUseGem(cid, item)
local voc = getPlayerVocation(cid)
local interval = gems.interval[voc]
if item.itemid ~= gems.id[voc] or getPlayerStorageValue(cid, gems.storage[voc]) > 0 then
return FALSE
end
setPlayerStorageValue(cid, gems.storage[voc], 1)
sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
doRemoveItem(item.uid, 1)
return TRUE
end
function sendGemEffect(cid, storage, interval)
local pos = getThingPos(cid)
local voc = getPlayerVocation(cid)
local color = 1
if voc == 1 then
color = gemMsg.colorDruid[math.random(1,#gemMsg.colorDruid)]
elseif voc == 2 then
color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorSorcerer)]
elseif voc == 3 then
color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorPaladin)]
elseif voc == 4 then
color = gemMsg.colorKnight[math.random(1,#gemMsg.colorKnight)]
elseif voc == 5 then
color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
elseif voc == 6 then
color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 7 then
color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 8 then
color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
end
doSendAnimatedText(pos, gemMsg.rnd[math.random(1,#gemMsg.rnd)], color)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) >= 1 then
addEvent(sendGemEffect, interval, cid, storage, interval)
end
end
function doRemoveGemEffect(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) < 1 then
return FALSE
end
setPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)], 0)
return TRUE
end
function doRemoveAllGemEffect(cid)
for i = 1, table.maxn(gms.storage) do
setPlayerStorageValue(cid, gems.storage, 0)
end
return TRUE
end
function isGemActivated(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
return TRUE
end
return FALSE
end
Agora no outro arquivo.lua renomeie para Pivi_const e cole:
gems = {
id = {2156, 2155, 2158, 2153, 2156, 2155, 2158, 2156},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {600, 600, 600, 600, 600, 600, 600}, -- Intervalo dos efeitos
}
gemMsg = {
rnd = {"´ . ,", ". ´ ,", "` . ,", ", ´ ."},
colorDruid = {182,213},
colorSorcerer = {215,215},
colorPaladin = {89,89},
colorKnight = {210,210},
colorElderDruid = {182,213},
colorMasterSorcerer = {215,215},
colorRoyalPaladin = {89,89},
colorEliteKnight = {210,210}
}
Hora de ir em data/item/items.xml e Procurar as IDS:
2155 - Gema de Druid
2156 - Gema de Sorcerer e Knight
2158 - Gema de Paladin
Feito isto é só mudar o nome das gemas, entrar em seu servidor com a vocação da gema, usá-la e pronto. Agora postarei as magias que poderão usar com gemas:
Poder 1:
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}
local combat = createCombatObject()
local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(meteor, COMBAT_PARAM_EFFECT, CONST_ME_BIGPLANTS)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
local stun = createConditionObject(CONDITION_POISON)
setConditionParam(stun, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
addDamageCondition(stun, 1, 3000, -700)
setCombatCondition(meteor, stun)
local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(meteor_water, COMBAT_PARAM_EFFECT, CONST_ME_BIGPLANTS)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
combat_arr = {
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}
local combat_area = createCombatArea(combat_arr)
setCombatArea(combat, combat_area)
local function meteorCast(p)
doCombat(p.cid, p.combat, positionToVariant(p.pos))
end
local function stunEffect(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end
function onTargetTile(cid, pos)
if (math.random(0, 1) == 1) then
local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
if (isInArray(water, ground.itemid) == TRUE) then
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_EARTH)
addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
else
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos,CONST_ANI_EARTH)
addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
end
end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
function onCastSpell(cid, var)
local mana = 2400
local cmana = getCreatureMana(cid)
if cmana >= mana then
if isGemActivated(cid) == TRUE then
doCreatureAddMana(cid, mana * -1)
doPlayerAddSpentMana(cid, mana)
doPlayerSendCancel(cid, doRemoveGemEffect(cid))
return doCombat(cid, combat, var)
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce nao usou o Crystal de sua vocacao ainda!")
return FALSE
end
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Você não possui mana suficiente.")
return FALSE
end
end
Esta é a magia de Druid!
Agora vamos para a de Sorcerer:
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}
local combat = createCombatObject()
local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(meteor, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
local stun = createConditionObject(CONDITION_PARALYZE)
setConditionParam(stun, CONDITION_PARAM_TICKS, 5000)
setConditionFormula(stun, -0.8, 0, -0.9, 0)
setCombatCondition(meteor, stun)
local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(meteor_water, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
combat_arr = {
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}
}
local combat_area = createCombatArea(combat_arr)
setCombatArea(combat, combat_area)
local function meteorCast(p)
doCombat(p.cid, p.combat, positionToVariant(p.pos))
end
local function stunEffect(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end
function onTargetTile(cid, pos)
if (math.random(0, 1) == 1) then
local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
if (isInArray(water, ground.itemid) == TRUE) then
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_SUDDENDEATH)
addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
else
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_SUDDENDEATH)
addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
end
end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
function onCastSpell(cid, var)
local mana = 3200
local cmana = getCreatureMana(cid)
if cmana >= mana then
if isGemActivated(cid) == TRUE then
doCreatureAddMana(cid, mana * -1)
doPlayerAddSpentMana(cid, mana)
doPlayerSendCancel(cid, doRemoveGemEffect(cid))
return doCombat(cid, combat, var)
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce nao usou o Crystal de sua vocacao ainda!")
return FALSE
end
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Você não possui mana suficiente.")
return FALSE
end
end
Agora de paladin:
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625}
local combat = createCombatObject()
local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(meteor, COMBAT_PARAM_EFFECT, 39)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
local stun = createConditionObject(CONDITION_ENERGY)
setConditionParam(stun, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
addDamageCondition(stun, 1, 3000, -400)
setCombatCondition(meteor, stun)
local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(meteor_water, COMBAT_PARAM_EFFECT, 39)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
combat_arr = {
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}
}
local combat_area = createCombatArea(combat_arr)
setCombatArea(combat, combat_area)
local function meteorCast(p)
doCombat(p.cid, p.combat, positionToVariant(p.pos))
end
local function stunEffect(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end
function onTargetTile(cid, pos)
if (math.random(0, 1) == 1) then
local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
if (isInArray(water, ground.itemid) == TRUE) then
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_HOLY)
addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
else
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_HOLY)
addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
end
end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
function onCastSpell(cid, var)
local mana = 1750
local cmana = getCreatureMana(cid)
if cmana >= mana then
if isGemActivated(cid) == TRUE then
doCreatureAddMana(cid, mana * -1)
doPlayerAddSpentMana(cid, mana)
doPlayerSendCancel(cid, doRemoveGemEffect(cid))
return doCombat(cid, combat, var)
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce nao usou o Crystal de sua vocacao ainda!")
return FALSE
end
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Você não possui mana suficiente.")
return FALSE
end
end
E a última, de knight:
local water = {490, 491, 492, 493, 4608, 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625,4626,4627,4628,4629,4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,46424643,4644,4645,4646,4647,4648,4649,4650}
local combat = createCombatObject()
local meteor = createCombatObject()
setCombatParam(meteor, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 44)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
local stun = createConditionObject(CONDITION_PARALYZE)
setConditionParam(stun, CONDITION_PARAM_TICKS, 5000)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
setCombatCondition(meteor, stun)
local meteor_water = createCombatObject()
setCombatParam(meteor_water, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(meteor_water, COMBAT_PARAM_USECHARGES, TRUE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 44)
setCombatFormula(meteor, COMBAT_FORMULA_LEVELMAGIC, -99.5, -99975, -99.5, -99975)
combat_arr = {
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}
local combat_area = createCombatArea(combat_arr)
setCombatArea(combat, combat_area)
local function meteorCast(p)
doCombat(p.cid, p.combat, positionToVariant(p.pos))
end
local function stunEffect(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_STUN)
end
function onTargetTile(cid, pos)
if (math.random(0, 1) == 1) then
local ground = getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
if (isInArray(water, ground.itemid) == TRUE) then
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_LARGEROCK)
addEvent(meteorCast, 200, {cid = cid, pos = pos, combat = meteor_water})
else
local newpos = {x = pos.x - 7, y = pos.y - 6, z = pos.z}
doSendDistanceShoot(newpos, pos, CONST_ANI_LARGEROCK)
addEvent(meteorCast, 200, {cid = cid,pos = pos, combat = meteor})
end
end
end
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
function onCastSpell(cid, var)
local mana = 1350
local cmana = getCreatureMana(cid)
if cmana >= mana then
if isGemActivated(cid) == TRUE then
doCreatureAddMana(cid, mana * -1)
doPlayerAddSpentMana(cid, mana)
doPlayerSendCancel(cid, doRemoveGemEffect(cid))
return doCombat(cid, combat, var)
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Voce nao usou o Crystal de sua vocacao ainda!")
return FALSE
end
else
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doPlayerSendCancel(cid, "Você não possui mana suficiente.")
return FALSE
end
end
Eu apelei muito essas magias, pois estava testando, para diminuir é só trocar os numeros do LEVELMAGIC para menores!
Script não é meu, é do Foxworld OT, eu apenas procurei, procurei e procurei e acabei achando!
Qualquer erro postem ai!
Obrigado!