KamuiHunt2 43 Postado Agosto 25, 2010 Share Postado Agosto 25, 2010 (editado) Bom Dia Galera do TibiaX! Estou aqui novamente como havia dito, com mais alguns pedidos, um por tópico para não haver confusão rs. Vamos lá! Dessa vez estou pedindo um npc guarda PARA TIBIA 8.1 que ataque apenas pk's, e que não tenha qualquer interação com os players, a não ser ataca-los caso estejam pk's rs. Sim, ja olhei por ai, diversos scripts, alguns são falhos, alguns tem falas de ofensas, alguns tem a hora certa do server, ou do jogo não sei ao certo, cada um diz uma coisa.. Apropósito, se puderem me dizer como arrumar a hora do jogo, para a hora correta do relógio (Clock Watch) do tibia, ficarei grato (Ou até uma mensagem automatica de um NPC, dizendo: A horá certa é de " xx:xxAM ou PM " Voltando ao foco do tópico: Quero um npc que mate apenas pk's, e que não tenha qualquer tipo de interação com os players, se possível com hora global. Detalhe: Não quero um npc "Knight", e sim um que ataque SD, e que de preferencia não se movimente! Obs: O Npc que eu tenho, e se quiserem podem se basear é esse: ------------------------------------------------------------------------------------------------------------------------------------------------- local level = 100 ----- change this to make the npc hit more/less---------------------|damage_min = (level * 2 + maglevel * 3) * min_multiplier | local maglevel = 100 ----- change this to make the npc hit more/less -----------------|damage_max = (level * 2 + maglevel * 3) * max_multiplier | local min_multiplier = 10.1 ----- change this to make the npc hit more/less ----------|damage_formula = math.random(damage_min,damage_max) | local max_multiplier = 20.2 ----- change this to make the npc hit more/less --------------------------------------------------------------------- local check_interval = 3 ----- change this to the time between checks for a creature (the less time the more it will probably lag :S) local radiusx = 5 ----- 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 = 7 ----- 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 = "Um Pk? Acho Que Não! Down!" ----- change this to what the NPC says when he sees a monster(s) local town_name = "Sphere Town!" ----- 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 = FALSE ----- 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 -- NOTE: Set this to FALSE if you are using TFS as there is no way to tell if a player is skulled on TFS, you will only get errors local health_left = 1 ----- 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 = "Um Pk? Acho Que Não! Down!" ----- change this to what you want the NPC to say when he attackes a swearer local swear_words = {"######", "######", "######", "#####", "fdp", "Filho da ######", "FDP"} ----- 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 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 = getPlayerHealth(cid) - health_left if ((string.find(msg, '(%a*)hi(%a*)'))) and getDistanceToCreature(cid) < 4 then selfSay('Olá ' .. creatureGetName(cid) .. '! Sou o Defensor de '..town_name..'! Diga Hora Para Saber A Hora Atual.') doNpcSetCreatureFocus(cid) focus = 0 end if msgcontains(msg, 'hora') then selfSay('A Hora Certa É ' .. getWorldTime() .. '.') end if messageIsInArray(swear_words, msg) then if Attack_swearers == TRUE then selfSay('' .. swear_message ..' ') doPlayerAddHealth(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 getPlayerSkull(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) local damage_min = (level * 3 + maglevel * 5) * min_multiplier local damage_max = (level * 7 + maglevel * 9) * max_multiplier local damage_formula = math.random(damage_min,damage_max) doSendMagicEffect(getThingPos(monster_table),17) doCreatureAddHealth(monster_table,-damage_formula) doSendMagicEffect(getThingPos(monster_table),hit_effect) doSendAnimatedText(getThingPos(monster_table),damage_formula,damage_colour) 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 ------------------------------------------------------------------------------------------------------------------------------------------------- Obs²: Se forem se basear por ele, por favor não esqueçam de retirar a interação de "hi(oi", e arrumar a hora correta no máximo). Se preferirem, façam sem o horário, e mandem uma script com a horá certa "global" (Global que eu digo é o npc dizendo /B A Hora certa é de: " xx:xx ". Obs³: Da um erro absurdo: --> Lua Script Error: [Npc interface] data/npc/scripts/guard.lua:onThink luaGetThingfromPos<>. Tile not found <-- Ou seja, tradução: Há um erro no script.lua, na interface do npc "Local" | Função: Pensando/Pensar/Pensativo Pegando a posição.. | Não foi possível achar o chão (Em termos técnicos). Gostaria que isso fosse resolvido também.. Se conseguirem isso, ficarei eternamente grato, agradeço desde ja, e novamente obrigado! Editado Agosto 25, 2010 por KamuiHunt2 Link para o comentário https://xtibia.com/forum/topic/140052-script-npc-guarda-que-ataca-apenas-pks-sem-chat-para-tibia-81/ Compartilhar em outros sites More sharing options...
DevilMoon 125 Postado Agosto 25, 2010 Share Postado Agosto 25, 2010 Cara tenhu um Aqui , Nao tem Interaçao com os Players ele ve um Pk e Sai Corrento para matar... Se quiser!! Data>Npc crie uma pasta.xml chamada Policial do Ot e coloque isso dentro: <?xml version="1.0" encoding="UTF-8"?> <npc name="Policial do Ot" script="data/npc/scripts/policial.lua" walkinterval="2000" speed="2000" floorchange="0"> <health now="100" max="100"/> <look type="134" head="79" body="86" legs="114" feet="0" addons="3"/> </npc> Agora vá em Data>Npc>Scripts crie uma pasta.lua chamada policial e coloque isso: local target = 0 local prevTarget = 0 local maxChaseDistance = 20 local origPos = 0 local lastAttack = 0 local followTimeout = 1000 local function isSkulled(cid) if(getPlayerSkullType(cid) >= 3 and isPlayerPzLocked(cid) == TRUE) then return true end return false end local function goToOrigPos() target = 0 lastAttack = 0 selfFollow(0) doTeleportThing(getNpcCid(), origPos) end local function updateTarget() if(isPlayer(target) == FALSE) then goToOrigPos() elseif(not isSkulled(target)) then selfSay("Vou te Pegar!! Algum Dia...") goToOrigPos() end if(target == 0) then local list = getSpectators(getNpcPos(), 9, 9, false) for i = 1, table.getn(list) do local _target = list[i] if(_target ~= 0) then if(isPlayer(_target) == TRUE and isSkulled(_target)) then if(getTilePzInfo(getCreaturePosition(_target)) == FALSE) then if(selfFollow(_target)) then target = _target if(target ~= prevTarget) then selfSay("Hahahah Seu Verme Noob , é Hora de Morrer!") 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("I'll catch you next time.") goToOrigPos() return end if(lastAttack == 0) then lastAttack = os.clock() end if(os.clock() - lastAttack > followTimeout) then selfSay("Voce Esta Esgotando Meu Tempo Voce Vai Morrer!") 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, -500000, -1000000, 9) lastAttack = os.clock() end end Depois Edite ao Seu Gosto!!! Se nao Souber editar o Atack, as Falas e o Efeito do Atack do Policial Posta no Topico que te ajudo!! Abraços.. Link para o comentário https://xtibia.com/forum/topic/140052-script-npc-guarda-que-ataca-apenas-pks-sem-chat-para-tibia-81/#findComment-924350 Compartilhar em outros sites More sharing options...
KamuiHunt2 43 Postado Agosto 25, 2010 Autor Share Postado Agosto 25, 2010 (editado) Boa Tarde. Cara, agradeço pelo script, mas infelizmente não deu certo. Creio que talves não seja próprio para 8.1. Vou estar postando um SS (Screen Shot) para lhe mostrar: Como podem ver, o guarda não ataca. --> <-- Sem contar que deu um erro similar ao que eu ja tinha (Que na verdade é a checagem): --> Lua Script Error: [Npc interface] data/npc/scripts/guard.lua:onThink data/npc/scripts/guard.lua:19: attempt to call global 'selfFollow' <a nil value> <-- Lembrando que: não editei nada, apenas coloquei a script la. OBS: Independente de ser guard.lua, e o seu ser policial.lua, não afeta nada, pois ja mudei previamente na pasta npc/scrips, então ja aviso de antemão que não é isso. Peço humildimente, que edite o npc que eu postei aqui encima, retirando a interação de ' Hi (Oi) ', e que esse erro fosse resolvido: --> Lua Script Error: [Npc interface] data/npc/scripts/guard.lua:onThink luaGetThingfromPos<>. Tile not found <-- Até onde eu sei, ele diz que tem um erro de checagem de posição, dizendo que o 'Tile'(Chão) não foi encontrado. A linha de erro é essa: --> creature = getThingfromPos(checking) /* A falha está realmente na checagem, onde ele ve se há algum buraco ou não onde o NPC possa cair. */ <-- Obs²: Gostaria que o npc não se movesse. (Motivo: Ele taca SD de longe rs). Obrigado pela ajuda desde ja, e fico no aguardo novamente. Obs³: Andei checando seus trabalhos feitos DevilMoon, e tenho gostado até agora, está de parabens. Abraços. Editado Agosto 26, 2010 por KamuiHunt2 Link para o comentário https://xtibia.com/forum/topic/140052-script-npc-guarda-que-ataca-apenas-pks-sem-chat-para-tibia-81/#findComment-924435 Compartilhar em outros sites More sharing options...
Posts Recomendados