Postado Maio 20, 2015 10 anos Eu queria uma magia q trapasse em área exatamente igual a essa imagem: Bom e que em area pz, paredes etc ela não atravessasse. Aqui vai uma base de uma magia de trap no target que eu quero q seja exatamente igual o script só que em a trap em área exatamente como mostra a imagem. No script tem 30% de chance de dar Fail e se der fail abaixa o cooldown da spell para 10 se a magia funcionar perfeitamente o cooldown é 20 segundos, e após 5 segundos todas as barreiras que foram criadas desaparecerão , então é isso ai vai o script base da trap em target. local remove_time = 5 -- tempo em segundos para remover as magic wall local item_id = 1480 -- id da magic wall function onCastSpell(cid, var) if math.random(0, 100) <= 30 then if (getPlayerStorageValue(cid, 2343) - os.time()) < 0 then setPlayerStorageValue(cid, 2343, (os.time() + 10)) addEvent(doSendAnimatedText, 1, getCreaturePosition(cid), "FAIL", 180) end doPlayerSendCancel(cid, "You are exhausted in Doton Doryu Heki for: "..(getPlayerStorageValue(cid, 2343) - os.time() ).." seconds.") return false end if (getPlayerStorageValue(cid, 2343) - os.time()) > 0 then doPlayerSendCancel(cid, "You are exhausted in Doton Doryu Heki for: "..(getPlayerStorageValue(cid, 2343) - os.time() ).." seconds.") return false end setPlayerStorageValue(cid, 2343, (os.time() + 20)) local pos = getThingPosition(getCreatureTarget(cid)) posTile1 = {x=pos.x+1,y=pos.y+1,z=pos.z,stackpos=1} posTile2 = {x=pos.x+1,y=pos.y,z=pos.z,stackpos=1} posTile3 = {x=pos.x+1,y=pos.y-1,z=pos.z,stackpos=1} posTile4 = {x=pos.x,y=pos.y-1,z=pos.z,stackpos=1} posTile5 = {x=pos.x-1,y=pos.y-1,z=pos.z,stackpos=1} posTile6 = {x=pos.x-1,y=pos.y,z=pos.z,stackpos=1} posTile7 = {x=pos.x-1,y=pos.y+1,z=pos.z,stackpos=1} posTile8 = {x=pos.x,y=pos.y+1,z=pos.z,stackpos=1} posAll = {posTile1,posTile2,posTile3,posTile4,posTile5,posTile6,posTile7,posTile8} addEvent(doSendMagicEffect, 100, {x = pos.x+1, y = pos.y+1, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x+1, y = pos.y, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x+1, y = pos.y-1, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x, y = pos.y-1, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x-1, y = pos.y-1, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x-1, y = pos.y, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x-1, y = pos.y+1, z = pos.z}, 111) addEvent(doSendMagicEffect, 100, {x = pos.x, y = pos.y+1, z = pos.z}, 111) for i=1, #posAll do if isWalkable(posAll[i]) then doCreateItem(item_id, 1, posAll[i]) end end addEvent(removeItem, remove_time*1000, posAll) return true end function isWalkable(pos, creature, pz, proj) if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end local creature = getTopCreature(pos) if creature.type > 0 then return false end if getTilePzInfo(pos) and not pz then return false end local n = not proj and 3 or 2 for i = 0, 255 do pos.stackpos = i local tile = getTileThingByPos(pos) if tile.itemid ~= 0 and not isCreature(tile.uid) then if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then return false end end end return true end function removeItem(posAll) for i=1, #posAll do for j=0, 255 do pos_stack = {x=posAll[i].x,y=posAll[i].y,z=posAll[i].z,stackpos=j} removeTile = getThingfromPos(pos_stack) if removeTile.itemid == item_id then doRemoveItem(removeTile.uid) end end end end Sera que alguém pode me ajudar ? obrigado e abraços.
Postado Maio 20, 2015 10 anos Este é um post popular. local config = { wallArea = { {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, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 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}, }, effect = xxx, --Efeito. wallId = xxx, --ID da parede. time = 5, --Duração da parede. cooldown = {20, 10}, --{sucessCooldown, failCooldown}, chance = 30, --Chance da spell funcionar. storage = 9571, } function isWalkable(pos, creature, proj, pz)-- by Nord if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end if getTopCreature(pos).uid > 0 and creature then return false end if getTileInfo(pos).protection and pz then return false, true end local n = not proj and 3 or 2 for i = 0, 255 do pos.stackpos = i local tile = getTileThingByPos(pos) if tile.itemid ~= 0 and not isCreature(tile.uid) then if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then return false end end end return true end function getPosfromArea(cid, area) --by Dokmos icenter = math.floor(table.getn(area)/2)+1 jcenter = math.floor(table.getn(area[1])/2)+1 center = area[icenter] ivar = table.getn(area) jvar = table.getn(area[1]) i = table.getn(area)^2 j = table.getn(area[1])^2 local mydir = isCreature(getCreatureTarget(cid)) and getCreatureDirectionToTarget(cid, getCreatureTarget(cid)) or getCreatureLookDir(cid) setPlayerStorageValue(cid, 21101, -1) if center[jcenter] == 3 then if mydir == 0 then signal = {-1,1,1,2} elseif mydir == 1 then signal = {1,-1,2,1} elseif mydir == 2 then signal = {1,-1,1,2} elseif mydir == 3 then signal = {-1,1,2,1} end else signal = {-1,1,1,2} end POSITIONS = {} P = 0 repeat pvar = {0,0} I = area[ivar] J = I[jvar] i = i-1 j = j-1 if J == 1 then if jvar < jcenter then pvar[signal[3]] = signal[1]*math.abs((jcenter-jvar)) elseif jvar > jcenter then pvar[signal[3]] = signal[2]*math.abs((jcenter-jvar)) end if ivar < icenter then pvar[signal[4]] = signal[1]*math.abs((icenter-ivar)) elseif ivar > icenter then pvar[signal[4]] = signal[2]*math.abs((icenter-ivar)) end end if jvar > 1 then jvar = (jvar-1) elseif ivar > 1 then jvar = table.getn(area[1]) ivar = (ivar-1) end local pos = getThingPos(cid) local areapos = {x=pos.x+(pvar[1]),y=pos.y+(pvar[2]),z=pos.z} if pos.x ~= areapos.x or pos.y ~= areapos.y then P = P+1 POSITIONS[P] = areapos end until i <= 0 and j <= 0 return POSITIONS end function onCastSpell(cid) if getPlayerStorageValue(cid, config.storage) > os.time() then doPlayerSendCancel(cid, "Wait "..getPlayerStorageValue(cid, config.storage) - os.time().." second(s).") else if math.random(1, 100) > config.chance then doPlayerSendCancel(cid, "Your spell failed.") doSendAnimatedText(getThingPos(cid), "FAIL!", 215) setPlayerStorageValue(cid, config.storage, os.time() + config.cooldown[2]) else local positions = {} setPlayerStorageValue(cid, config.storage, os.time() + config.cooldown[1]) for _, pos in pairs(getPosfromArea(cid, config.wallArea)) do if isWalkable(pos) and not getTileInfo(pos).protection then doCreateItem(config.wallId, 1, pos) doSendMagicEffect(pos, config.effect) table.insert(positions, pos) end end if #positions > 0 then addEvent(function() for i = 1, #positions do local item = getTileItemById(positions[i], config.wallId).uid if item > 0 then doRemoveItem(item) end end end, config.time * 1000) end end end return true end Editado Maio 22, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Maio 21, 2015 10 anos Autor Deu erro: Editado Maio 21, 2015 10 anos por leonardobo (veja o histórico de edições)
Postado Maio 21, 2015 10 anos Ops. Corrigido. Editado Maio 21, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
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.