Postado Abril 4, 2015 10 anos Boa tarde. Gostaria de um NPC que ataca-se os montros e players com skull. Eu tenho um NPC aqui, que era pra atacar os monstros mas não sei porque não está funcionando. Olhem abaixo local target = 0 local prevTarget = 0 local maxChaseDistance = 25 local origPos = 0 local lastAttack = 0 local followTimeout = 10 local function isSummon(cid) return (getCreatureMaster(cid) ~= 0 and true or false) end local function goToOrigPos() target = 0 lastAttack = 0 selfFollow(0) doTeleportThing(getNpcCid(), origPos) end local function updateTarget() if(not isMonster(target)) then goToOrigPos() elseif(not isSummon(target)) then selfSay("Now, behave in the future.") goToOrigPos() end if(target == 0) then local list = getSpectators(getNpcPos(), 9, 9, false) for i = 1, table.getn(list) do local _target = list if(_target ~= 0) then if(isMonster(_target) and not isSummon(_target)) then if(not getTilePzInfo(getCreaturePosition(_target))) then if(selfFollow(_target)) then target = _target if(target ~= prevTarget) then selfSay("Não suporto sua raça!") end prevTarget = target break end end end end end end end function onCreatureAppear(cid) if(cid == getNpcCid()) then origPos = getNpcPos() end end function onCreatureDisappear(cid) if(cid == target) then goToOrigPos() end end function onCreatureMove(creature, oldPos, newPos) -- end function onThink() updateTarget() if(target == 0) then return end local playerPos = getCreaturePosition(target) local myPos = getNpcPos() if(myPos.z ~= playerPos.z) then goToOrigPos() return end if(math.abs(myPos.x - origPos.x) > maxChaseDistance or math.abs(myPos.y - origPos.y) > maxChaseDistance) then selfSay("Eu vou te pegar da proxima vez.") goToOrigPos() return end if(lastAttack == 0) then lastAttack = os.clock() end if(os.clock() - lastAttack > followTimeout) then selfSay("Você pode fugir agora mas depois eu te pego.") goToOrigPos() return end if((math.abs(playerPos.x - myPos.x) <= 1) and (math.abs(playerPos.y - myPos.y) <= 1)) then doTargetCombatHealth(getNpcCid(), target, COMBAT_LIFEDRAIN, -100, -130, CONST_ME_BLOCKHIT) lastAttack = os.clock() end end Obrigado. No final da década de 20, quando Eurico Miranda ainda nem era nascido, fomos proibidos de disputar o Estadual por aceitarmos atletas negros e operários. Depois a desculpa era por não termos estádio. E demos a resposta construindo um. Na década de 40, quando Eurico era apenas uma criança, o jornalista mulambo Ary Barroso (na época, o principal jornalista esportivo do Rio) já era proibido de entrar em São Januário por só falar mal do Vasco. No final desta mesma década, quando São Januário seria reformado com verba pública para receber a Copa do Mundo (nada mais lógico, pois em troca iriamos ceder o nosso estádio), a mídia marrom arrotou sua pseudo-ética pública contra nós. E veio o Maracanã, cuja construção todos já conhecem o resultado, para depois ser dado de bandeja pro urubu e pro clube da série C. Em 1950, após a perda da Copa pro Uruguai, quando Eurico Miranda continuava sendo apenas uma criança, o jornalista Armando Nogueira AFIRMOU que o Brasil só perdeu a Copa pois tinha muitos atletas do Vasco, e que estes eram os grandes culpados pelo "Maracanazzo". Segundo ele, os jogadores vascaínos não eram brasileiros: "As equipes entram em campo.. Reconheço, um a um, os jogadores brasileiros: Barbosa; Augusto e Juvenal; Bauer, Danilo e Bigode; Friaça, Zizinho, Ademir, Jair e Chico. Aflora, outra vez em mim, a mágoa clubística. Lanço sobre a equipe um olhar de botafoguense ressentido. Vejo, em campo, apenas quatro autênticos brasileiros: Bauer, do São Paulo, Juvenal, da Portuguesa, Bigode, do Fluminense, e Zizinho, do Flamengo. Os outros sete são vascaínos. Velhos e mortais inimigos da pequena porém brava nação botafoguense… Quer saber de uma coisa? É melhor mesmo que ganhe o Uruguai. Eles são gringos, vão todos embora daqui amanhã. Ninguém vai encarnar em mim. (…)" O Vasco não criou inimigos através das ações de Eurico Miranda. O Vasco criou inimigos quando afrontou a elite da zona sul e se impôs como clube popular. O ranço contra a instituição de origem lusitana, mas alma brasileira, vem desde 1898. Saudações Vascaínas !
Postado Abril 4, 2015 10 anos O tópico foi movido para a área correta, preste mais atenção da próxima vez! Leia as regras do fórum: http://tibiaking.com/forum/topic/1281-regras-gerais/?p=7680 Este tópico foi movido: De: "OTServ → Suporte OTServ → Suporte de Spriting" Para: "OTServ → Suporte OTServ → Suporte de Scripts" Te ajudei?? REP + e ficamos quites... http://www.tibiaking.com/forum/uploads/emoticons/default_happyy.png' alt=';D'> Atenciosamente, Daniel. Abraços! Meus tutoriais: Programação: Resolvendo QUALQUER erro na data base. Scripts (system's, creaturescripts, mod's, NPC's, etc): (Sistema) GOD Ambient Light Full. Adicionando novas mounts ao servidor [NPC] Papai Noel que dá presente todo ano. Web-site: Resolvendo problema de caracteres especiais em PHP Formatando textos em PHP! Mudando a cor, tamanho, fonte, etc. Criando e configurando tabelas para paginas PHP
Postado Abril 4, 2015 10 anos Peguei na otland, testa aí: 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 Créditos: knekarn Editado Abril 4, 2015 10 anos por Rusherzin (veja o histórico de edições) Ajudei? De nada \o/ Att Rusherzin
Postado Abril 5, 2015 10 anos Autor Peguei na otland, testa aí: 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 Créditos: knekarn Amigo, esse da otland não segue o alvo e é bugado. Eu queria um baseado no meu mesmo. Pois esse da otland não segue o target! Editado Abril 6, 2015 10 anos por rizen (veja o histórico de edições) No final da década de 20, quando Eurico Miranda ainda nem era nascido, fomos proibidos de disputar o Estadual por aceitarmos atletas negros e operários. Depois a desculpa era por não termos estádio. E demos a resposta construindo um. Na década de 40, quando Eurico era apenas uma criança, o jornalista mulambo Ary Barroso (na época, o principal jornalista esportivo do Rio) já era proibido de entrar em São Januário por só falar mal do Vasco. No final desta mesma década, quando São Januário seria reformado com verba pública para receber a Copa do Mundo (nada mais lógico, pois em troca iriamos ceder o nosso estádio), a mídia marrom arrotou sua pseudo-ética pública contra nós. E veio o Maracanã, cuja construção todos já conhecem o resultado, para depois ser dado de bandeja pro urubu e pro clube da série C. Em 1950, após a perda da Copa pro Uruguai, quando Eurico Miranda continuava sendo apenas uma criança, o jornalista Armando Nogueira AFIRMOU que o Brasil só perdeu a Copa pois tinha muitos atletas do Vasco, e que estes eram os grandes culpados pelo "Maracanazzo". Segundo ele, os jogadores vascaínos não eram brasileiros: "As equipes entram em campo.. Reconheço, um a um, os jogadores brasileiros: Barbosa; Augusto e Juvenal; Bauer, Danilo e Bigode; Friaça, Zizinho, Ademir, Jair e Chico. Aflora, outra vez em mim, a mágoa clubística. Lanço sobre a equipe um olhar de botafoguense ressentido. Vejo, em campo, apenas quatro autênticos brasileiros: Bauer, do São Paulo, Juvenal, da Portuguesa, Bigode, do Fluminense, e Zizinho, do Flamengo. Os outros sete são vascaínos. Velhos e mortais inimigos da pequena porém brava nação botafoguense… Quer saber de uma coisa? É melhor mesmo que ganhe o Uruguai. Eles são gringos, vão todos embora daqui amanhã. Ninguém vai encarnar em mim. (…)" O Vasco não criou inimigos através das ações de Eurico Miranda. O Vasco criou inimigos quando afrontou a elite da zona sul e se impôs como clube popular. O ranço contra a instituição de origem lusitana, mas alma brasileira, vem desde 1898. Saudações Vascaínas !
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.