Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Gente, estou com uma dúvida, tem como colocar um script de um npc para um monstro?

 Segue a baixo o script que era de um npc, que eu queria que funcionasse em um monstro...  Resumindo o script ele ataca apenas players com skull, mas isso é para um npc, no caso a gente coloca esse script, na pasta de script do npc lá e funciona... mas eu precisava isso para um monstro, tipo o monstro executa esse script ai.

alguém consegue me ajudar?

 

local level = 10  ----- change this to make the npc hit more/less---------------------|damage_min = (level * 2 + maglevel * 3) * min_multiplier | 
 local maglevel = 10  ----- change this to make the npc hit more/less -----------------|damage_max = (level * 2 + maglevel * 3) * max_multiplier | 
 local min_multiplier = 2.1  ----- change this to make the npc hit more/less ----------|damage_formula = math.random(damage_min,damage_max)      | 
 local max_multiplier = 4.2  ----- change this to make the npc hit more/less --------------------------------------------------------------------- 
 local check_interval = 5  ----- change this to the time between checks for a creature (the less time the more it will probably lag :S)   
 local radiusx = 7  ----- change this to the amount of squares left/right the NPC checks (default 7 so he checks 7 squares left of him and 7 squares right (the hole screen)   
 local radiusy = 5  ----- change this to the amount of squares left/right the NPC checks (default 5 so he checks 5 squares up of him and 5 squares down (the hole screen)   
 local Attack_message = "An Invader, ATTACK!!!"  ----- change this to what the NPC says when he sees a monster(s)   
 local town_name = "Archgard"  ----- the name of the town the NPC says when you say "hi"  
 local Attack_monsters = TRUE  ----- set to TRUE for the npc to attack monsters in his area or FALSE if he doesnt  
 local Attack_swearers = TRUE  ----- set to TRUE for the npc to attack players that swear near him or FALSE if he doesnt  
 local Attack_pkers = TRUE  ----- set to TRUE for the npc to attack players with white and red skulls or FALSE if he doesnt  
 local health_left = 10  ----- set to the amount of health the npc will leave a player with if they swear at him (ie at 10 he will hit the player to 10 health left)  
 local swear_message = "Take this!!!"  ----- change this to what you want the NPC to say when he attackes a swearer  
 local swear_words = {"shit", "fuck", "dick", "cunt"}  ----- if "Attack_swearers" is set to TRUE then the NPC will attack anyone who says a word in here. Remember to put "" around each word and seperate each word with a comma (,)  
 local hit_effect = CONST_ME_MORTAREA  ----- set this to the magic effect the creature will be hit with, see global.lua for more effects 
 local shoot_effect = CONST_ANI_SUDDENDEATH  ----- set this to the magic effect that will be shot at the creature, see global.lua for more effects 
 local damage_colour = TEXTCOLOR_RED  ----- set this to the colour of the text that shows the damage when the creature gets hit 
 ------------------end of config------------------  
 local check_clock = os.clock()  ----- leave this  
 local focus = 0  ----- leave this   
  
 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)  
 health = getCreatureHealth(cid) - health_left  
    if ((string.find(msg, '(%a*)hi(%a*)'))) and getDistanceToCreature(cid) < 4 then   
        selfSay('Hello ' .. creatureGetName(cid) .. '! I am a defender of '..town_name..'.')   
        doNpcSetCreatureFocus(cid)   
        focus = 0  
    end  
  
    if msgcontains(msg, 'time') then 
        selfSay('The time is ' .. getWorldTime() .. '.') 
    end 
  
    if messageIsInArray(swear_words, msg) then  
        if Attack_swearers == TRUE then  
            selfSay('' .. swear_message ..' ')   
            doCreatureAddHealth(cid,-health)  
            doSendMagicEffect(getThingPos(cid),17)   
            doSendAnimatedText(getThingPos(cid),health,180)  
            doNpcSetCreatureFocus(cid)   
            focus = 0   
        end  
    end  
 end   
  
 function getMonstersfromArea(pos, radiusx, radiusy, stack)  
 local monsters = { }   
 local starting = {x = (pos.x - radiusx), y = (pos.y - radiusy), z = pos.z, stackpos = stack}   
 local ending = {x = (pos.x + radiusx), y = (pos.y + radiusy), z = pos.z, stackpos = stack}   
 local checking = {x = starting.x, y = starting.y, z = starting.z, stackpos = starting.stackpos}   
    repeat   
        creature = getThingfromPos(checking)   
            if creature.itemid > 0 then   
                if isCreature(creature.uid) == TRUE then  
                    if isPlayer(creature.uid) == FALSE then 
                        if Attack_monsters == TRUE then                             
                            table.insert (monsters, creature.uid)   
                            check_clock = os.clock()                          
                        end 
                    elseif isPlayer(creature.uid) == TRUE then   
                        if Attack_pkers == TRUE then  
                            if getPlayerSkullType(creature.uid) > 0 then  
                                table.insert (monsters, creature.uid)   
                                check_clock = os.clock()       
                            end  
                        end  
                    end   
                end   
            end   
        if checking.x == pos.x-1 and checking.y == pos.y then   
            checking.x = checking.x+2   
        else    
            checking.x = checking.x+1   
        end   
        if checking.x > ending.x then   
            checking.x = starting.x   
            checking.y = checking.y+1   
        end   
    until checking.y > ending.y   
        return monsters   
 end   
  
 function onThink()   
 if (Attack_monsters == TRUE and Attack_pkers == TRUE) or (Attack_monsters == TRUE and Attack_pkers == FALSE) or (Attack_monsters == FALSE and Attack_pkers == TRUE) then  
    if (os.clock() - check_clock) > check_interval then       
        monster_table = getMonstersfromArea(getCreaturePosition(getNpcCid(  )), radiusx, radiusy, 253)   
            if #monster_table >= 1 then  
                selfSay('' .. Attack_message ..' ')   
                    for i = 1, #monster_table do   
                        doNpcSetCreatureFocus(monster_table[i])   
                        local damage_min = (level * 2 + maglevel * 3) * min_multiplier   
                        local damage_max = (level * 2 + maglevel * 3) * max_multiplier   
                        local damage_formula = math.random(damage_min,damage_max) 
                        doSendDistanceShoot(getCreaturePosition(getNpcCid(  )), getThingPos(monster_table[i]), shoot_effect) 
                        doSendMagicEffect(getThingPos(monster_table[i]),hit_effect)   
                        doSendAnimatedText(getThingPos(monster_table[i]),damage_formula,damage_colour)   
                        doCreatureAddHealth(monster_table[i],-damage_formula)   
                        check_clock = os.clock()   
                        focus = 0   
                    end   
            elseif table.getn(monster_table) < 1 then   
                focus = 0   
                check_clock = os.clock()   
            end     
    end  
 end  
    focus = 0  
 end

Scriptszinhos:

 

Não abandone seu tópico, quando você tiver a dúvida resolvida sozinho tente ensinar aos outros como resolve-la (você pode não ser o único com o problema) e quando ela for resolvida por outra pessoa não se esqueça de marcar como melhor resposta e deixar o gostei.

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Jaurez
      .
    • Por sannn
      --[[ /////////////////////////////////////////////////////////////////////////////////////////////////////// Discord: San#7791 -- Loja System 2.0 -- TFS 0.3.6 -- para adicionar qualquer item na loja: basta adicionar na tabelinha, seguindo o exemplo do vip! valor = quantidade de DIAMOND a ser cobrada; itemID = item a ser recebido; quantidade = quantidade de itens a ser recebidos; msg = mensagem que o player vai receber após comprar! Feito por San Discord: San#7791 exemplo de como comprar: !loja vip podendo ser adicionado a modules também. tag talkactions.xml // <talkaction words="!loja" case-sensitive="no" event="script" value="Loja System 2.0.lua"/> ////////////////////////////////////////////////////////////////////////////////////////////////////// depois de tantos sistemas com mil elseifs, vim trazer esta contribuição simples, para facilitar a vida de muitos adms! Contribuição pra comunidade =D ]]-- LOJA_CANCEL = "Você não possui diamantes o suficiente." LOJA_INVALID = "Não temos este item a venda na loja!" INVALID = "Comando incorreto" DIAMOND = 2145 -- item que será cobrado; tabelinha = { ["vip"] = {valor = 5, itemID = 2160, quantidade = 1, msg = "Obrigado por comprar um VIP em nossa loja!"}, -- coloque sempre minusculo o nome ! ["vip"]... etc } function onSay(cid, words, param, channel) local msg = string.lower(param) -- Não mexa! if msg == "" then doPlayerSendTextMessage(cid, 22, INVALID) return true end -- verificação if tabelinha[msg] == nil then doPlayerSendTextMessage(cid, 22, INVALID) return true end -- verificação if tabelinha[msg].valor then if getPlayerItemCount(cid, DIAMOND) >= tabelinha[msg].valor then doPlayerRemoveItem(cid, DIAMOND, tabelinha[msg].valor) doPlayerAddItem(cid, tabelinha[msg].itemID, tabelinha[msg].quantidade) doPlayerSendTextMessage(cid, 20, tabelinha[msg].msg) else doPlayerSendTextMessage(cid, 22, LOJA_CANCEL) return true end else doPlayerSendTextMessage(cid, 22, LOJA_INVALID) end return true end  
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por tataboy67
      Opa galera beleza?
      Meu amigo esses dias pediu um sistema basicamente assim:
      sistema:
      !quests charizard (você é teleportado para hunt ou quest por "x" tempo, e após esse tempo, você é teleportado para 1 posição "y" (cp/templo)) !quest time (o jogador recebe uma msg de quanto tempo ainda resta para ele ficar nessa hunt/quest) !quest (abre uma janela aonde fala as informações dessa hunt/quest)
      bom eu tentei usar o "for" para fazer com que tenha varios tipos de hunts dentro (criando uma tabela), mas como ainda estou estudando lua e esse é meu 1º script, eu não consegui fazer, então eu to usando o "param" E eu fui pesquisar aqui no forum e em outro forums tbm esse sistema, e vi que ninguem nunca postou  
      então resolvi cria-lo.
       
      Em Talkactions.xml, adicione a linha:

      Em Talkactions, crie um arquivo com o nome de quest_time.lua, e adicione:

      Creditos:
      Eu: Pelo script

      Desculpa se o script ficou ruim, é que é meu primeiro script, tenham pena de mim.  
      Eu farei melhoras nesse script mais pra frente.
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo