Ir para conteúdo
Entre para seguir isso  
jedian

[Magia] Sewing Straight

Recommended Posts

jedian    0
jedian

  • Nome: Sewing Straight
  • Autor: Jedian
  • Servidor Testado:The Forgotten Server 0.3.6 (8.54)
  • Descrição: Abaixo

A ideia seria uma magia que faz uma espada "costurar em linha reta"(como o nome diz, ou espero que diga :fist:) para frente do personagem de acordo com o tipo de arma usada, aí, se houver um target, ela vai até ele e dá "costuradas" conforme a distância que percorreu até chegar nele, quanto mais perto, mais "costuradas" e vice-versa.

Vamos instalar:

em data/spells/scripts copie um arquivo e cole-o, renomeie para algum nome, apague todo o conteúdo e cole isso dentro:

local function isWall(pos) -- by Jedian
local item = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})
return item.itemid > 1 and isInArray(string.explode(getItemName(item.uid), ' '), 'wall') or item.itemid > 1 and isInArray(string.explode(getItemName(item.uid), ' '), 'window') or false
end
local function getPosByLookDist(cid, quant) -- by Jedian
local pos = getPlayerPosition(cid)
if getPlayerLookDir(cid) == 0 then
  return {x = pos.x, y = pos.y - quant, z = pos.z}
elseif getPlayerLookDir(cid) == 1 then
  return {x = pos.x + quant, y = pos.y, z = pos.z}
elseif getPlayerLookDir(cid) == 2 then
  return {x = pos.x, y = pos.y + quant, z = pos.z}
elseif getPlayerLookDir(cid) == 3 then
  return {x = pos.x - quant, y = pos.y, z = pos.z}
end
end
local function getRetDirToPos(pos1, pos2)
local retdirs = {
 [0] = 0,
 [1] = 1,
 [2] = 2,
 [3] = 3,
 [4] = 2,
 [5] = 1,
 [6] = 3,
 [7] = 0}
return retdirs[getDirectionTo(pos1, pos2)]
end
local t = {
 [1] = {24, SKILL_SWORD},
 [2] = {26, SKILL_CLUB},
 [3] = {25, SKILL_AXE}
 }
function onCastSpell(cid, var) -- by Jedian 
if getPlayerWeapon(cid).uid ~= 0 then
  doSendAnimatedText(getThingPos(cid), 'Sewing', 144)
  addEvent(doSendAnimatedText, 350, getThingPos(cid), 'Straight!', 144)
  if isCreature(getCreatureTarget(cid)) then
     local function gotarget(cid, pos, n)
     if isCreature(getCreatureTarget(cid)) then
        local n = n or 0                                             
        local pos = pos or getCreaturePosition(cid)
        local topos = getThingPos(getCreatureTarget(cid))                                                                               
        local dir = getRetDirToPos(pos, topos)
     if n < 8 then
        if not(pos.x == topos.x and pos.y == topos.y) then
           pos = getPosByDir(pos, dir)
        end
        if isWall(pos) then
        return false
        else
        doAreaCombatHealth(cid, 1, pos, 0, -(getPlayerSkillLevel(cid, t[getItemWeaponType(getPlayerWeapon(cid).uid)][2])*1.6), -(getPlayerSkillLevel(cid, t[getItemWeaponType(getPlayerWeapon(cid).uid)][2])*2.3), 255)
        doSendDistanceShoot({x=pos.x-2,y=pos.y-2,z=pos.z}, pos, t[getItemWeaponType(getPlayerWeapon(cid).uid)][1])
        addEvent(gotarget, 80, cid, pos, n+1)
        end
     end
  end
  end
  gotarget(cid)
else
  n = 0 
  while n < 8 do 
     n = n + 1 
     local front = getPosByLookDist(cid, n) 
     if not getTilePzInfo(front) then
        if isWall(front) then
        return false
        end 
        addEvent(doSendDistanceShoot, n*80, {x=front.x-2, y=front.y-2, z=front.z},front, t[getItemWeaponType(getPlayerWeapon(cid).uid)][1])
        addEvent(doAreaCombatHealth, n*80, cid, 1, front, 0, -(getPlayerSkillLevel(cid, t[getItemWeaponType(getPlayerWeapon(cid).uid)][2])*1.6), -(getPlayerSkillLevel(cid, t[getItemWeaponType(getPlayerWeapon(cid).uid)][2])*2.3), 255)
     end
  end 
end
else
return doPlayerSendCancel(cid, 'You need a weapon to cast it.')
end
return true
end

salve e feche, agora em spells.xml adicione a seguinte tag:

<instant name="Sewing Straight" words="sewing straight" lvl="35" mana="0" prem="0" needweapon="1" exhaustion="2000" needlearn="0" event="script" value="nome.lua"></instant>

edite o nome do arquivo e o local, e altere o resto conforme preferir.

  • Screenshot:nLVda.png

é um pouco difícil entender o efeito pela SS, aconselho instalar e testar.

Editado por jedian
blockwalls adicionado

Compartilhar este post


Link para o post
Tio Gordo    8
Tio Gordo

Amigo, a ideia é boa, entretanto o tópico está mal formatado e a imagem está muito pequena.

Seja mais objetivo, idente o seu tópico.

Você tem 72 horas.

 

Edit: Aprovado e Movido.

 

Obrigado pela contribuição.

 

- Tio Gordo

 

 

 

 

Editado por Tio Gordo

Compartilhar este post


Link para o post
jedian    0
jedian

Obrigado por aprovar :)

 

Comentem pessoal D:

Criticando ou elogiando, só vai me ajudar, comentem aí o que acharam galera!

Compartilhar este post


Link para o post
IagoOTs    0
IagoOTs

Muito boa a spell, pena que ela atravessa as paredes :[

Compartilhar este post


Link para o post
jedian    0
jedian

improvisei uma função ali e consegui mudar, agora ela não atravessa paredes, MAS essa parede precisa ter no nome "wall" ou "window". Digamos que ela tenha o nome tipo "item of type 8238" aí ela atravessa, porque não é reconhecida como parede.

Compartilhar este post


Link para o post
IagoOTs    0
IagoOTs

só muda aqui ::

local function isWall(pos) -- by Jedianlocal

item = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})

 

para

 

local function isWall(pos) -- by Jedian

local item = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})

 

 

VALEU JEDIAN S2

Compartilhar este post


Link para o post
jedian    0
jedian

obrigado por reportar o erro, por comentar, e por reportar mais outro erro e comentar denovo :D

de nada :)

Compartilhar este post


Link para o post
xinguxdd    0
xinguxdd

como ajusta o dano dela?

Compartilhar este post


Link para o post
honorio    2
honorio

1 problema - magia atravessa parede quando você seleciona um target depois da parede.

Compartilhar este post


Link para o post
honorio    2
honorio

a sim agora que vi, esta certinho obrigada.

Compartilhar este post


Link para o post
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×