Ir para conteúdo
Entre para seguir isso  
Convidado DuD

Tutorial sobre "Data" - Parte 2

Gostou do tutorial?  

7 votos

  1. 1. Gostou do tutorial?

    • Excelente
    • Muito bom
    • Bom
    • Regular
      0
    • Ruim
      0
    • Horrível


Recommended Posts

Convidado DuD   
Convidado DuD

Aee galeraa!! Estou aqui de novo. :D Infortunamente, já tinha feito grande parte deste tutorial ( e ainda não tinha salvado ¬¬) quando cai a luz aqui. Perdi tudo. sauhsaeuhuheauhuahause :(

 

1º Tutorial: http://forum.otserv.com.br/viewtopic.php?t=4553

 

Bem, vamos continuar nosso tutorial. Hoje vamos falar sobre Action, NPCs e Spells.

 

[center:2e3e745896]1.3) Actions[/center:2e3e745896]

 

Actions podem ser encontradas na pasta Data > Actions.

Todas estão relacionadas no arquivo "actions.xml".

 

Um tutorial muito bom sobre Action: <a href=\'http://forum.otserv.com.br/viewtopic.php?t=42\' target=\'_blank\'>http://forum.otserv.com.br/viewtopic.php?t=42</a>

 

Função:

 

Actions servem para editar certas funções do server, criar quests, alavancas, tudo com diversas funções. :D

 

Listão de comandos ( são quase todos. Vou explicar os mais importantes xD ):

 


-doChangeTypeItem

 

-doCreateItem - Cria um item no chão. E.x.: doCreateItem(topos,id-item)



-doDecayItem 



-doPlayerAddHealth - Adiciona um tanto de life ao player. E.x.:doPlayerAddHealth(cid,100)



-doPlayerAddItem - Adiciona um item ao inventory do player. E.x.: doPlayerAddItem(cid,id-item,1)



-doPlayerAddMana - Adiciona um tanto de mana ao player. E.x.: doPlayerAddMana(cid,100)



-doPlayerAddSkillTry 



-doPlayerFeed - "Alimenta" o player por determinado tempo. E.x.: doPlayerFeed(cid,170)



-doPlayerRemoveItem - Retira um item do inventory do player. E.x.: doPlayerRemoveItem(cid,2090,1)



-doPlayerRemoveMoney - Reitra um tanto de money do player. E.x.: doPlayerRemoveMoney(cid,2000)



-doPlayerSay - Faz o player falar algo. E.x.: doPlayerSay(cid,\'Lol!\')



-doPlayerSendCancel - Manda uma mensagem de "erro" ao player. E.x.: doPlayerSendCancel(cid,\'Sorry!\')



-doPlayerSendTextMessage - Manda uma mensagem ao player. E.x.: doPlayerSendTextMessage(cid,22,\'xD\') 



-doPlayerSetMasterPos - Determina o templo do player. E.x.: doPlayerSetMasterPos(cid,100,100,7)



-doPlayerSetVocation - Determina a vocação do player. E.x.: doPlayerSetVocation(cid,4)



-doRemoveItem - retira um item de algum lugar. E.x.: doRemoveItem(holepos,450)



-doSendMagicEffect - "Manda" um efeito mágico. E.x.: doSendMagicEffect(holepos,10)



-doSetItemActionId 



-doSetItemSpecialDescription 



-doSetItemText 



-doShowTextWindow - Mostra a tela para escrever algo em algum item.



-doSendAnimatedText 



-doSummonCreature - Sumona uma criatura em algum lugar. E.x.: doSummonCreature("Behemoth",holepos)



-doTeleportThing - Teleporta algo para algum lugar. E.x.: doTeleportThing(cid,holepos)



-doTransformItem - Transforma um item em outro. E.x.: doTransformItem(item.uid,2570)



-getItemRWInfo 



-getPlayerAccess - Consegue o acesso do player. E.x.: getPlayerAcces(cid)

 

-getPlayerFood 



-getPlayerGuildId - Descobre o rank do player em uma guild. 



-getPlayerHealth - Descobre o total de Life que o player tem no momento. E.x.: getPlayerHealth(cid)



-getPlayerLevel - Descobre o level do player. E.x.: getPlayerLevel(cid)



-getPlayerMagLevel - Descobre o magic level do player. E.x.: getPlayerMagLevel(cid)



-getPlayerMana - Descobre o total de Mana que o player tem no momento. E.x.: getPlayerMana(cid)



-getPlayerMasterPos - Descobre onde é o templo do player. E.x.: getPlayerMasterPos(cid)



-getPlayerName - Descobre o nome do player. E.x.: getPlayerName(cid)



-getPlayerPosition - Descobre a posição do player. E.x.: getPlayerPosition(cid) 



-getPlayerSkill 



-getPlayerStorageValue - Descobre seo player já fez determinada quest, por exemplo. E.x.:getPlayerStorageValue(cid) 



-getPlayerVocation - Descobre a vocação do player. E.x.: getPlayerVocation(cid)



-getThingfromPos - Retira algo de uma posição. E.x.: getThingFromPos(holepos)



-getTilePzInfo 



-setPlayerStorageValue - Determina se o player fez uma quest, por exemplo. E.x.: setPlayerStorageValue(cid,2050,1)

Agora colocarei aqui uma action bem simples e explicar-la-ei, para treinar. :P

 

Exemplo de Action - Simples:

 


function onUse(cid, item, frompos, item2, topos)



playerpos = getPlayerPosition(cid)

player2pos = {x=100, y=60, z=7}



if item.uid == 1947 then

getThingFromPos(playerpos)

doTeleportThing(cid,player2pos)

end

return1

end

Agora as Explicações :D:

 


function onUse(cid, item, frompos, item2, topos)

Isto sempre deverá estar SEMPRE no início das action. Isto representa as funções q serão usadas na action.

 


playerpos = getPlayerPosition(cid)

player2pos = {x=100, y=60, z=7}

Isto são posições pré-determinadas para serem usadas posteriormente na action.

 


if item.uid == 1947 then

Isto significa : se o Unique ID do item usado for igual a 1947, então acontecerá alguma coisa.

 


getThingFromPos(playerpos)

doTeleportThing(cid,player2pos)

Isto é o que acontecerá : O player será teleportado para "playerpos".

 


end

return1

end

Isto se encontra no final das actions. Sempre coloque isso. :P

 

Agora vou colocar aqui um Exemplo de Action um pouco mais complicada... com alavanca:

 

Exemplo de Action um pouco mais complicada... com alavanca:

 


function onUse(cid, item, frompos, item2, topos) 





   if item.uid == 1002 and item.itemid == 1945 then 



      player1pos = {x=69, y=104, z=7, stackpos=253} 

      player1 = getThingfromPos(player1pos) 



      item1pos = {x=69, y=105, z=7, stackpos=1} 

      item1 = getThingfromPos(item1pos) 



      if player1.itemid > 0 then 

         queststatus1 = getPlayerStorageValue(player1.uid,1002) 

       

      if queststatus1 == -1 and item1.itemid == 1990 then 



      doRemoveItem(item1.uid,1) 

      doSendMagicEffect(item1,2) 



      nplayer1pos = {x=139, y=118, z=7} 

      doSendMagicEffect(player1pos,2) 

      doTeleportThing(player1.uid,nplayer1pos) 

      doSendMagicEffect(nplayer1pos,10) 

      doTransformItem(item.uid,item.itemid+1) 

      setPlayerStorageValue(cid,1002,1) 

       

      else 

      doPlayerSendCancel(cid,"Sorry, not possible.") 

      end 

      else 

      doPlayerSendCancel(cid,"Sorry, not possible.") 

      end 



      elseif item.uid == 1002 and item.itemid == 1946 then 

      if getPlayerAccess(cid) < 1 then 

         doTransformItem(item.uid,item.itemid-1) 

      else 

         doPlayerSendCancel(cid,"Sorry, not possible.") 

      end 

   else 

      return 0 

   end 



   return 1 

end

Esta é uma action postada pelo Alokk. Ela é bem mais difícil do que a anterior.

Essa action faz o seguinte: o player coloca o item em cima de um balcão, usa a alavanca e é teleportado para outro lugar.

 

Explicação:

 


if item.uid == 1002 and item.itemid == 1945 then

Isto significa: se o Unique ID do item usado for igual a 1002 e o ID do item em cima do balcão for igual a 1945, então acontecerá alguma coisa.

 


player1pos = {x=69, y=104, z=7, stackpos=253} 

      player1 = getThingfromPos(player1pos) 



      item1pos = {x=69, y=105, z=7, stackpos=1} 

      item1 = getThingfromPos(item1pos) 

Estas são posições pré-determinadas (player1pos e item1pos). "player1" e "item1" servem para remover o que está em "player1pos e "item1pos". Masi tarde, todas serão usadas.

 


queststatus1 = getPlayerStorageValue(player1.uid,1002) 

       

      if queststatus1 == -1 and item1.itemid == 1990 then

Verifica o Storage value do player, onde estão as informações sobre quests, etc. Se o player não tiver feito essa "quest", que não é bem uma quest o.O, vai acontecer alguma coisa. Não sei explicar isso. xD

 


doRemoveItem(item1.uid,1) 

      doSendMagicEffect(item1,2) 



      nplayer1pos = {x=139, y=118, z=7} ---- futura posição do player

      doSendMagicEffect(player1pos,2) ---- usado magic effect na posição do player

      doTeleportThing(player1.uid,nplayer1pos) --- player será teleportado

      doSendMagicEffect(nplayer1pos,10) ---- usado magic effect na futura posição do player

      doTransformItem(item.uid,item.itemid+1) 

      setPlayerStorageValue(cid,1002,1) --- adicionado ao StorageValue do player a "quest"

Isto é o que vai acontecer: será removido o item, e o player será teleportado e será usado um efeito mágico.

 


else 

      doPlayerSendCancel(cid,"Sorry, not possible.") 

      end 

      else 

      doPlayerSendCancel(cid,"Sorry, not possible.") 

      end

Caso as primeiras condições sejam falsas, será mandada ao player, uma mensagem de erro.

 

Explicada uma grande Action!!! Entederam??

Fácil não? :P

 

Agora vou explicar uma quest:

 

Quest:

 


function onUse(cid, item, frompos, item2, topos)

if item.uid == 1007 then

queststatus = getPlayerStorageValue(cid, 1007)

if queststatus == -1 or queststatus == 0 then

doPlayerSendTextMessage(cid, 22, "You have found a dragon scale mail.")

doPlayerAddItem(cid, 2492, 1)

setPlayerStorageValue(cid, 1007, 1)

else

doPlayerSendTextMessage(cid, 22, "The chest is empty.")

end

else

return 0

end

return 1

end

Essa é uma quest fácil. Vamos explicar-la:

 


if item.uid == 1007 then

Se o Unique ID do baú usado for igual a 1007, acontecerá alguma coisa.

 


queststatus = getPlayerStorageValue(cid, 1007)

if queststatus == -1 or queststatus == 0 then

Verifica se o player já fez a quest. Se não, acontecerá alguma coisa.

 


doPlayerSendTextMessage(cid, 22, "You have found a dragon scale mail.") --- Mensagem Recebida

doPlayerAddItem(cid, 2492, 1) --- É adicionada a DSM.

setPlayerStorageValue(cid, 1007, 1) --- É adicionado ao Storage Value a quest.

O player receberá uma mensagem, um item, e será adicionado ao seu Storage Value a quest.

 


else

doPlayerSendTextMessage(cid, 22, "The chest is empty.")

Caso o player já tenha feito a quest, ele receberá uma mensagem que o baú está vazio.

 


end

else

return 0

end

return 1

end

É o final da action.

 

Partes importantes da Action:

 


do --- Sempre vai indicar que a Action vai fazer algo.

cid --- Player que usa/começa a Action.

if --- Significa "se".

else --- Significa "caso seja contrário" ( mais ou menos isso ).

elseif --- Significa "mas se".

item --- É o item usado na quest.

item.itemid --- ID do Item.

item.uid --- Unique ID do item.

item2.itemid --- ID do item que será usado após o uso do 1º Item.

item2.uid --- Unique ID do item que será usado após o uso do 1º Item.

Bem, finalmente, terminei a explicação sobre Actions !!!!!!!!!!!

 

Agora vamos à explicação sobre NPCs:

 

[center:2e3e745896]1.4)NPCs[/center:2e3e745896]

 

Os NPCs dos OTs se encontram na pasta Data > NPC.

 

Os NPCs são mais ou menos como players, já que possuem um arquivo ".xml" próprio.

 

Aqui está um arquivo XML de um NPC, apenas para demonstração:

 

NPC - Arquivo XML

 


<?xml version="1.0"?> 

<npc name="Ben" script="data/npc/scripts/runes.lua" access="3" speed="60"> 

    <look type="132" head="25" body="77" legs="10" feet="20"/> 

</npc>

Explicação:

 


<npc name="Ben"

Mostra o nome do NPC.

 


script="data/npc/scripts/runes.lua"

Mostra o script que o NPC "usará", onde estão suas configurações.

 


access="3" speed="60"

Mostra o acess do NPC ( é melhor sempre colocar "3", para executar comandos de Game Master :P).

Mostra a velocidade do NPC.

 


<look type="132" head="25" body="77" legs="10" feet="20"/> 

Mostra o Looktype e as cores do outfit do NPC. Podemos adicionar Addons aos NPCs, adicionando depois de "feet="20":

 

Addons para NPC:

 


addon="3" know="3"

Addon mostra quais addons o NPC está usando.

Know são os que ele possue.

 

Scripts de NPC

 

Agora, para vocês, um exemplo de script de NPC:

 

Exemplo de Script de NPC:


focus = 0

talk_start = 0

target = 0

following = false

attacking = false



function onThingMove(creature, thing, oldpos, oldstackpos)



end





function onCreatureAppear(creature)



end





function onCreatureDisappear(cid, pos)

  	if focus == cid then

          selfSay(\'Good bye then.\')

          focus = 0

          talk_start = 0

  	end

end





function onCreatureTurn(creature)



end





function msgcontains(txt, str)

  	return (string.find(txt, str) and not string.find(txt, \'(%w+)\' .. str) and not string.find(txt, str .. \'(%w+)\'))

end





function onCreatureSay(cid, type, msg)

  	msg = string.lower(msg)



  	-- greeting phrase 

if string.find(msg, \'(%a*)hi(%a*)\') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then

    selfSay(\'Hello \' .. creatureGetName(cid) .. \'! I sell runes, bps of runes, wands and rods.\')

    focus = cid

    selfLook(cid)

  talk_start = os.clock()



	elseif focus == cid then

  talk_start = os.clock()



  if msgcontains(msg, \'runes\') then

  	selfSay(\'I sell hmm (100gps), uh (300gps), desintegrate (90gps), destroyfield (90gps), gfb (200gps), firebomb (100gps), magicwall (100gps), energybomb (100gps), explosion (250gps), sd (400gps) and blank runes (5gps). To buy more runes say "20 uh" or "20 sd".\')

  elseif msgcontains(msg, \'wands\') then

  	selfSay(\'I sell wand of inferno (15k), plague (5k), cosmic energy (10k), vortex (500gp) and dragonbreath (1k).\')

  elseif msgcontains(msg, \'rods\') then

  	selfSay(\'I sell quagmire (10k), snakebite (500gp), tempest (15k), volcanic (5k) and moonlight rod (1k).\')

  

  elseif msgcontains(msg, \'inferno\') then

  	buy(cid,2187,1,15000)

  elseif msgcontains(msg, \'plague\') then

  	buy(cid,2188,1,5000)

  elseif msgcontains(msg, \'cosmic energy\') then

  	buy(cid,2189,1,10000)

  elseif msgcontains(msg, \'vortex\') then

  	buy(cid,2190,1,500)

  elseif msgcontains(msg, \'dragonbreath\') then

  	buy(cid,2191,1,1000)



  elseif msgcontains(msg, \'quagmire\') then

  	buy(cid,2181,1,10000)

  elseif msgcontains(msg, \'snakebite\') then

  	buy(cid,2182,1,500)

  elseif msgcontains(msg, \'tempest\') then

  	buy(cid,2183,1,15000)

  elseif msgcontains(msg, \'volcanic\') then

  	buy(cid,2185,1,5000)

  elseif msgcontains(msg, \'moonlight\') then

  	buy(cid,2186,1,1000)



  elseif msgcontains(msg, \'20 hmm\') then

  	buy(cid,2311,50,800)

  elseif msgcontains(msg, \'hmm\') then

  	buy(cid,2311,10,100)



  elseif msgcontains(msg, \'20 uh\') then

  	buy(cid,2273,20,2000)

  elseif msgcontains(msg, \'uh\') then

  	buy(cid,2273,3,300)



  

  elseif msgcontains(msg, \'20 gfb\') then

  	buy(cid,2304,20,1000)

  elseif msgcontains(msg, \'gfb\') then

  	buy(cid,2304,3,200)



  

  elseif msgcontains(msg, \'20 explosion\') then

  	buy(cid,2313,20,1700)

  elseif msgcontains(msg, \'explosion\') then

  	buy(cid,2313,3,250)



  

  elseif msgcontains(msg, \'10 sd\') then

  	buy(cid,2268,20,2500)

  elseif msgcontains(msg, \'sd\') then

  	buy(cid,2268,2,400)



  elseif msgcontains(msg, \'20 firebomb\') then

  	buy(cid,2305,20,900)

  elseif msgcontains(msg, \'firebomb\') then

  	buy(cid,2305,3,100)  

  

  

  elseif msgcontains(msg, \'20 energybomb\') then

  	buy(cid,2262,20,900)

  elseif msgcontains(msg, \'energybomb\') then

  	buy(cid,2262,3,100)  

  

  elseif msgcontains(msg, \'20 magicwall\') then

  	buy(cid,2293,20,1000)

  elseif msgcontains(msg, \'magicwall\') then

  	buy(cid,2293,4,200)  

  

  elseif msgcontains(msg, \'20 destroyfield\') then

  	buy(cid,2261,20,500)

  elseif msgcontains(msg, \'destroyfield\') then

  	buy(cid,2261,3,90)  

  

  elseif msgcontains(msg, \'20 desintegrate\') then

  	buy(cid,2310,20,400)

  elseif msgcontains(msg, \'desintegrate\') then

  	buy(cid,2310,3,90)  

  

  elseif msgcontains(msg, \'paralyze\') then

  	buy(cid,2278,2,2000)

  	

  elseif msgcontains(msg, \'blank\') then

  	buy(cid,2260,1,5)

  

  elseif msgcontains(msg, \'bp blanks\') then

  	sellcontainer(cid,1988,2260,1,200)

  

  elseif msgcontains(msg, \'bp uhs\') then

  	sellcontainer(cid,2002,2273,1,3000)

	

  elseif msgcontains(msg, \'bp hmms\') then

  	sellcontainer(cid,2001,2311,5,1500)

  

  elseif msgcontains(msg, \'bp sds\') then

  	sellcontainer(cid,2003,2268,1,5000)

  

  elseif msgcontains(msg, \'bp explosions\') then

  	sellcontainer(cid,2001,2313,20,20000)

  

  elseif msgcontains(msg, \'bp gfbs\') then

  	sellcontainer(cid,2000,2304,20,15000)



  elseif msgcontains(msg, \'bp firebombs\') then

  	sellcontainer(cid,2000,2305,20,12000)



  elseif msgcontains(msg, \'bp energybombs\') then

  	sellcontainer(cid,2002,2262,20,12000)



  elseif msgcontains(msg, \'bp magicwalls\') then

  	sellcontainer(cid,1999,2293,20,16000)



  elseif msgcontains(msg, \'bp destroyfields\') then

  	sellcontainer(cid,2003,2261,20,8000)

  

  elseif msgcontains(msg, \'bp desintegrates\') then

  	sellcontainer(cid,2001,2310,20,8000)



  elseif msgcontains(msg, \'bp paralyzes\') then

  	sellcontainer(cid,1988,2278,2,30000)



                          elseif msgcontains(msg, \'bp mfs\') then

  	sellcontainer(cid,1988,2006,7,1100)

  

  

  elseif string.find(msg, \'(%a*)bye(%a*)\') and getDistanceToCreature(cid) < 4 then

  	selfSay(\'Good bye, \' .. creatureGetName(cid) .. \'!\')

  	focus = 0

  	talk_start = 0

  end

	end

end





function onCreatureChangeOutfit(creature)



end





function onThink() 

   



if (os.clock() - talk_start) > 30 then

  	if focus > 0 then

    selfSay(\'Next Please...\')

  	end

  focus = 0

  end

	if focus ~= 0 then

  if getDistanceToCreature(focus) > 4 then

  	selfSay(\'Good bye then.\')

  	focus = 0

  end

	end

 --nothing special has happened -------- Para o NPC Andar   \/

--but perhaps we want to walk around a bit?

if focus == 0 then

 cx, cy, cz = selfGetPosition()

 randmove = math.random(1,50)

 if randmove == 1 then

  nx = cx + 1

 end

 if randmove == 2 then

  nx = cx - 1

 end

 if randmove == 3 then

  ny = cy + 1

 end

 if randmove == 4 then

  ny = cy - 1

 end

 if randmove >= 5 then

  nx = cx

  ny = cy

 end

 moveToPosition(nx, ny, cz)

 

end 



end

Agora, a explicação parte a parte.

 

Explicação sobre Script de NPC:

 


focus = 0

talk_start = 0

target = 0

following = false

attacking = false



function onThingMove(creature, thing, oldpos, oldstackpos)



end





function onCreatureAppear(creature) --- Quando o player aparecer



end





function onCreatureDisappear(cid, pos) --- Caso o player saia da "tela" do NPC, ele dirá isso.

  	if focus == cid then

          selfSay(\'Good bye then.\')

          focus = 0

          talk_start = 0

  	end

end





function onCreatureTurn(creature)



end





function msgcontains(txt, str)

  	return (string.find(txt, str) and not string.find(txt, \'(%w+)\' .. str) and not string.find(txt, str .. \'(%w+)\'))

end





function onCreatureSay(cid, type, msg)

  	msg = string.lower(msg)

Isto, praticamente, está em todos os NPCs. Portanto, sempre coloque isto no início de um NPC.

 


if string.find(msg, \'(%a*)hi(%a*)\') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then

    selfSay(\'Hello \' .. creatureGetName(cid) .. \'! I sell runes, bps of runes, wands and rods.\')

    focus = cid

    selfLook(cid)

  talk_start = os.clock()

Caso o player fale "hi" ao NPC, ele se virará para o player e começará a conversa.

 


if msgcontains(msg, \'runes\') then

  	selfSay(\'I sell hmm (100gps), uh (300gps), desintegrate (90gps), destroyfield (90gps), gfb (200gps), firebomb (100gps), magicwall (100gps), energybomb (100gps), explosion (250gps), sd (400gps) and blank runes (5gps). To buy more runes say "20 uh" or "20 sd".\')

  elseif msgcontains(msg, \'wands\') then

  	selfSay(\'I sell wand of inferno (15k), plague (5k), cosmic energy (10k), vortex (500gp) and dragonbreath (1k).\')

  elseif msgcontains(msg, \'rods\') then

  	selfSay(\'I sell quagmire (10k), snakebite (500gp), tempest (15k), volcanic (5k) and moonlight rod (1k).\')



  elseif msgcontains(msg, \'inferno\') then 

  	buy(cid,2187,1,15000) --- Venderá para cid(player) um item de ID 2187, quantidade 1, por 15000 gold.

  elseif msgcontains(msg, \'plague\') then

  	buy(cid,2188,1,5000)

  elseif msgcontains(msg, \'cosmic energy\') then

  	buy(cid,2189,1,10000)

  elseif msgcontains(msg, \'vortex\') then

  	buy(cid,2190,1,500)

  elseif msgcontains(msg, \'dragonbreath\') then

  	buy(cid,2191,1,1000)



  elseif msgcontains(msg, \'quagmire\') then

  	buy(cid,2181,1,10000)

  elseif msgcontains(msg, \'snakebite\') then

  	buy(cid,2182,1,500)

  elseif msgcontains(msg, \'tempest\') then

  	buy(cid,2183,1,15000)

  elseif msgcontains(msg, \'volcanic\') then

  	buy(cid,2185,1,5000)

  elseif msgcontains(msg, \'moonlight\') then

  	buy(cid,2186,1,1000)



  elseif msgcontains(msg, \'20 hmm\') then

  	buy(cid,2311,50,800)

  elseif msgcontains(msg, \'hmm\') then

  	buy(cid,2311,10,100)



  elseif msgcontains(msg, \'20 uh\') then

  	buy(cid,2273,20,2000)

  elseif msgcontains(msg, \'uh\') then

  	buy(cid,2273,3,300)



  

  elseif msgcontains(msg, \'20 gfb\') then

  	buy(cid,2304,20,1000)

  elseif msgcontains(msg, \'gfb\') then

  	buy(cid,2304,3,200)



  

  elseif msgcontains(msg, \'20 explosion\') then

  	buy(cid,2313,20,1700)

  elseif msgcontains(msg, \'explosion\') then

  	buy(cid,2313,3,250)



  

  elseif msgcontains(msg, \'10 sd\') then

  	buy(cid,2268,20,2500)

  elseif msgcontains(msg, \'sd\') then

  	buy(cid,2268,2,400)



  elseif msgcontains(msg, \'20 firebomb\') then

  	buy(cid,2305,20,900)

  elseif msgcontains(msg, \'firebomb\') then

  	buy(cid,2305,3,100)  

  

  

  elseif msgcontains(msg, \'20 energybomb\') then

  	buy(cid,2262,20,900)

  elseif msgcontains(msg, \'energybomb\') then

  	buy(cid,2262,3,100)  

  

  elseif msgcontains(msg, \'20 magicwall\') then

  	buy(cid,2293,20,1000)

  elseif msgcontains(msg, \'magicwall\') then

  	buy(cid,2293,4,200)  

  

  elseif msgcontains(msg, \'20 destroyfield\') then

  	buy(cid,2261,20,500)

  elseif msgcontains(msg, \'destroyfield\') then

  	buy(cid,2261,3,90)  

  

  elseif msgcontains(msg, \'20 desintegrate\') then

  	buy(cid,2310,20,400)

  elseif msgcontains(msg, \'desintegrate\') then

  	buy(cid,2310,3,90)  

  

  elseif msgcontains(msg, \'paralyze\') then

  	buy(cid,2278,2,2000)

  	

  elseif msgcontains(msg, \'blank\') then

  	buy(cid,2260,1,5)

  

  elseif msgcontains(msg, \'bp blanks\') then

  	sellcontainer(cid,1988,2260,1,200) ---- Venderá para cid(player) um container(bp,parcel,bag,etc) de ID 1988, completo com items de ID 2260, 1 carga, por 200 gold.

  

  elseif msgcontains(msg, \'bp uhs\') then

  	sellcontainer(cid,2002,2273,1,3000)

	

  elseif msgcontains(msg, \'bp hmms\') then

  	sellcontainer(cid,2001,2311,5,1500)

  

  elseif msgcontains(msg, \'bp sds\') then

  	sellcontainer(cid,2003,2268,1,5000)

  

  elseif msgcontains(msg, \'bp explosions\') then

  	sellcontainer(cid,2001,2313,20,20000)

  

  elseif msgcontains(msg, \'bp gfbs\') then

  	sellcontainer(cid,2000,2304,20,15000)



  elseif msgcontains(msg, \'bp firebombs\') then

  	sellcontainer(cid,2000,2305,20,12000)



  elseif msgcontains(msg, \'bp energybombs\') then

  	sellcontainer(cid,2002,2262,20,12000)



  elseif msgcontains(msg, \'bp magicwalls\') then

  	sellcontainer(cid,1999,2293,20,16000)



  elseif msgcontains(msg, \'bp destroyfields\') then

  	sellcontainer(cid,2003,2261,20,8000)

  

  elseif msgcontains(msg, \'bp desintegrates\') then

  	sellcontainer(cid,2001,2310,20,8000)



  elseif msgcontains(msg, \'bp paralyzes\') then

  	sellcontainer(cid,1988,2278,2,30000)



                          elseif msgcontains(msg, \'bp mfs\') then

  	sellcontainer(cid,1988,2006,7,1100)

Caso o player fale alguma dessas falas, o NPC venderá os items, como já explicado dentro do script (veja code acima).

 

Comandos de NPC</span>

 

Existem alguns comandos para NPC, como:

 




sell(cid,x,x,x) ---- Compra do player(cid) algum item por tanto de dinheiro.

buy(cid,x,x,x) ---- Vende para o player(cid) algum item por algum preço.

sellcontainer(cid,x,x,x,x,x) ---- Vende um container para o player(cid) completo por determinado item de                                           certo ID, com determinadas cargas.

doPlayerRemoveItem(cid,x,x) ---- Retira do player uma quantidade de um certo item.

creatureGetName(cid) ---- Identifica o nome do player.

addon(cid,x) ---- Adiciona certo addon ao player.

travel(cid,x,x,x) --- Transporta o player(cid) para algum lugar por certo preço.



Também podem ser usados em NPCs, comandos de Game Master, como:

 

Comandos de Game Master para NPC:

 


/send \'. . creatureGetName . .\' x, y, z ---- Manda o player para certas coordenadas

/premmy \'. . creatureGetName . .\' ---- Dá premium account para o player.

Bom... acredito que isso a explicar sobre NPCs... xD

 

Vo explicar agora sobre Spells...

 

[center:2e3e745896]1.4) Spells[/center:2e3e745896]

 

As spells podem ser Instant (para monstros e players) e Runes (para fazer runas e para usá-las).

Elas se encontram na pasta Data > Spells.

Todas estão relacionadasno arquivo "spells.xml".

 

Instant Spells:

 

Se encontram na pasta Data > Spells > Instant

 

Player Spells:

 

Bom... não existe muito o que explicar sobre spells.

Para fazer spells, aconselho o Colex Spells Maker (pode ser encontrado na Seção Download de Utilitários).

Mas, vou explicá-las mesmo assim xD.

 

Aqui está um exemplo de Player Instant Spell:

 

Exemplo de Player Instant Spell:

 






    area = {



        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 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, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}



    }

 

    attackType = ATTACK_PHYSICAL

    needDirection = true

    areaEffect = NM_ME_MORT_AREA

    animationEffect = NM_ANI_SUDDENDEATH

 

    hitEffect = NM_ME_MORT_AREA

    damageEffect = NM_ME_MORT_AREA

    animationColor = RED

    offensive = true

    drawblood = true

 

    GreatEnergyBeamObject = MagicDamageObject(attackType, animationEffect, hitEffect, damageEffect, animationColor, offensive, drawblood, 0, 0)

 

    function onCast(cid, creaturePos, level, maglv, var)

    centerpos = {x=creaturePos.x, y=creaturePos.y, z=creaturePos.z}

    GreatEnergyBeamObject.minDmg = (level * 1 + maglv *1) * 0.9

    GreatEnergyBeamObject.maxDmg = (level * 1 + maglv *1) * 1.2

 

    return doAreaMagic(cid, centerpos, needDirection, areaEffect, area, GreatEnergyBeamObject:ordered())

    end

Explicação:

 


area = {



        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 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, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}



    }

Está é a área de ataque da spell, que no caso é a Spell "Exori mort".

"1", "2", "3", "4" representam as direções do ataque.

"0" representa que não haverá ataque naquele sqm.

 


attackType = ATTACK_PHYSICAL --- É o tipo de ataque da spell.

needDirection = true --- Verifica se o Ataque precsia de direção.

areaEffect = NM_ME_MORT_AREA --- Efeito ocorrido na área de ataque.

animationEffect = NM_ANI_SUDDENDEATH --- É a animação que aparecerá na direção do ataque.


hitEffect = NM_ME_MORT_AREA --- Efeito do ataque.

damageEffect = NM_ME_MORT_AREA --- Efeito do dano.

animationColor = RED --- Cor da animação. ??? (não sei o que é isso)

offensive = true --- Verifica se a spell é ofensiva.

drawblood = true --- Verifica se a spell causa sangue no chão.


GreatEnergyBeamObject = MagicDamageObject(attackType, animationEffect, hitEffect, damageEffect, animationColor, offensive, drawblood, 0, 0)

É o resumo da spell.

 


function onCast(cid, creaturePos, level, maglv, var)

centerpos = {x=creaturePos.x, y=creaturePos.y, z=creaturePos.z} --- Posição central da spell.

GreatEnergyBeamObject.minDmg = (level * 1 + maglv *1) * 0.9 --- Cálculo para determinar o menor dano                                                                                                 possível da spell.

GreatEnergyBeamObject.maxDmg = (level * 1 + maglv *1) * 1.2 --- Cálculo para determinar o maior dano                                                                                            possível da spell.


return doAreaMagic(cid, centerpos, needDirection, areaEffect, area, GreatEnergyBeamObject:ordered())

end

É o final da spell.

 

A tag da spell é :

 

TAG:

 


<spell name="Force Strike"  words="exori mort"  maglv="2"	mana="20"	enabled="1"><vocation id="1" /><vocation id="2" /></spell>

As Instant Spells de Players e Monsters são praticamente iguais, quase a mesma coisa.

 

Runes Spells:

As runes spells se encontram na pasta Data > Spells > Runes.

 

Exemplo de Rune Spell:

 

Colocarei aqui agora um exemplo de Rune Spell:

 


-- doTargetMagic

 -- attackType: Type of attack

 -- cid: creature id.

 -- Targetpos: Target position.

 -- animationEffect: Projectile animation.

 -- damageEffect: Effect to show when spell hits a player.

 -- animationColor: Color of the text that is shown above the player when hit.

 -- offensive: Indicates if the spell is a healing/attack spell.

 -- drawblood: Determines if the spell causes blood splash.

 -- minDmg: Minimal damage.

 -- maxDmg: Maximum damage.

 -- returns true if the spell was casted.

 

 attackType = ATTACK_PHYSICAL --- Tipo de ataque.

 animationEffect = NM_ANI_SUDDENDEATH --- Efeito da Animação.

 

 hitEffect = NM_ME_MORT_AREA --- Efeito do Ataque.

 damageEffect = NM_ME_DRAW_BLOOD --- Efeito do Dano.

 animationColor = RED --- Cor da Animação.

 offensive = true --- Verifica se a spell é ofensiva.

 drawblood = true --- Verifica se a spell causa sangue no chão.

 

 SuddenDeathObject = MagicDamageObject(attackType, animationEffect, hitEffect, damageEffect, animationColor, offensive, drawblood, 0, 0) --- Resumo da Spell

 

 function onCast(cid, creaturePos, level, maglv, var)

 centerpos = {x=creaturePos.x, y=creaturePos.y, z=creaturePos.z} --- Centro da spell (onde o player está).

 

 SuddenDeathObject.minDmg = (level * 2 + maglv *3) * 1.2 - 30 --- Cálculo para definir o mínimo dano                                                                                              possível da spell.

 SuddenDeathObject.maxDmg = (level * 2 + maglv *3) * 1.6 --- Cálculo para definir o máximo dano                                                                                                     possível da spell.

 return doTargetMagic(cid, centerpos, SuddenDeathObject:ordered())

 end --- Final da Spell

A tag da spell é :

 

<span style=\'color:olive\'>TAG:

 




<rune name="Sudden Death" id="2268"	charges="1" maglv="15" mana="0"	enabled="1"></rune>



Já coloquei a explicação da spell no próprio script.

 

Bem... Galera, acho q já terminei a explicação sobre Actions, NPCs e Spells.

 

Logo estarei postando o 3º tutorial: MapEditor, Monsters e Items.

 

Flw... Qualquer dúvida/sugestão, postem aqui :D.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Convidado Guispfilho   
Convidado Guispfilho

esse é sweu segundo tutorial e acho q esta muito bom, realmente exelente, só falta, como ja comentaram no seu topico anterior um pouco mais de cor para a orcanização, mas tirando isso esta realmente nota 10, continue assim!!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites
rag    0
rag

fala dods \o

demoro mt pra faze mas fico cool

otra coisa..

hyrul~ rula td

Compartilhar este post


Link para o post
Compartilhar em outros sites
Convidado Guispfilho   
Convidado Guispfilho

aguradando parte 3 !!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites
Skoll    0
Skoll

Tutorial muito bom, gostei de ver, e obrigado por citar o meu tutorial no seu tópico.

 

Ta de parabéns!

Aprovado.

 

 

 

 

Prêmio:

↘ + 35 OT$.

Compartilhar este post


Link para o post
Compartilhar em outros sites
Fozz    0
Fozz

@DuD

To amando seus tutos sobre data

tão mt bem explicados

//Fozz

Compartilhar este post


Link para o post
Compartilhar em outros sites
Convidado DuD   
Convidado DuD

Vlw galera pelos elogios :P. Faço tudo que posso xD. :)

A, e postem na enquete, queria ver meu trabalho reconhecido. x)

Compartilhar este post


Link para o post
Compartilhar em outros sites
Dexpant    0
Dexpant

PERFEITO!!!

MUITO BOM!!!

VC EH FODA!!!

CARA MUITO BOM!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites
Kakaher    1
Kakaher

bahhh

tu disse td tah perfect o.O

kra vlw... kra

tah mt bom

explikado direitinho...

tah mt bom mermu kra

Aprovado

Compartilhar este post


Link para o post
Compartilhar em outros sites
mauninja    0
mauninja

bacana, mas tem q explicar melhor a parte dos npcs, eu intendi, mas tem algumas pessoas q me perguntaram sobre issu pq naum intenderam o tuto!!! :)

 

bem eras issu...

fui!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites
Jack Bauer Returns    0
Jack Bauer Returns

A parte dos NPCs fico ruim pq o script do npc q vc uso eh mt grande...

nao tem nessesidade

Compartilhar este post


Link para o post
Compartilhar em outros sites
Jack Bauer Returns    0
Jack Bauer Returns

A parte dos NPCs fico ruim pq o script do npc q vc uso eh mt grande...

nao tem nessesidade ...mt bom

mal pelo spam... net discada deu moh lag aki...

Compartilhar este post


Link para o post
Compartilhar em outros sites
Convidado Digo Loco   
Convidado Digo Loco

Vlw cara tava precisando muito disso vlww mesmo!!!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites
Caneco    0
Caneco

muito bom rapaz

adoro post interesantes como esse :wink:

+ nk vi um q ensina a fazer npc tpw postman

akeles q vc tem q fala com o npc, dps faze alguma

coisa, fala com o npc,etc,etc pra pega o premio da quest

Compartilhar este post


Link para o post
Compartilhar em outros sites
DuDz    0
DuDz

@Caneco

 

Quer que eu te venda um NPC para a Postman? ;P Eu sou o "DuD"..

 

@topic

 

Valeu, galera, pelos elogios. ;P

 

Espero ter ajudado a todos. ;D

 

Abraços,

 

//DuD

Compartilhar este post


Link para o post
Compartilhar em outros sites
Convidado sepito   
Convidado sepito

kra o tuto tah bom mais nao axei o q eu procurava =/ eu kero um npc de barco q teletransporta somente premmy players... tem jeito?? eu compro esse npc pra kem fizer pra mim... meu msn eh [email protected]

Compartilhar este post


Link para o post
Compartilhar em outros sites
DuDz    0
DuDz

@sepito

 

Amigo, eu faço sim. Vou te adicionar no MSN.

 

Espero que tenham gostado do tuto.

 

Abraços,

 

//DuD

Compartilhar este post


Link para o post
Compartilhar em outros sites
Dave Glorft    0
Dave Glorft

Foi bótimo, o Tuto =D DuDz é bom ;D

Compartilhar este post


Link para o post
Compartilhar em outros sites
Samurai    0
Samurai

bom tuto garndao..

devi ter dado trabalho mas fiko muito bom..

 

aprovado!

Compartilhar este post


Link para o post
Compartilhar em outros sites
Muadogib    0
Muadogib

ja falei no primeiro tuto, e vou falar de volta:

tutorial excelente, apesar de ser mto ruim ler essas letras ae, da p entender de boa.

valeu, e gogogo tuto parte 3 biggrin.gif

Compartilhar este post


Link para o post
Compartilhar em outros sites

Faça login para comentar

Você vai ser capaz de deixar um comentário após fazer o login



Entrar Agora
Entre para seguir isso  

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×