Npc Deixando Com 1 De Life!

Myself
Por Myself
em NPCs, monsters e raids

Myself

Harder, better, faster, stronger.
avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 09/03/08Posts: 107

Olá pessoal. Em primeiro lugar, já adianto que o tópico não é meu. Créditos totais a Tio Gordo, do outro fórum.

 

Do que se trata

Se trata de um NPC igual ao rei Tibianus, Orc King, Queen Eloise, etc. que quando se fala por exemplo, "fuck", o NPC te dá um golpe e lhe deixa com 1 HP.

 

Vamos lá?

 

1° lugar: Em data/npc

 

Copie um arquivo .XML de um NPC qualquer, e renomeie para King Tibianus.XML. Abra-o no bloco de notas e substitua o que tem dentro por isso:

 

<?xml version="1.0"?>

 

<npc name="King Tibianus" script="data/npc/scripts/removelife.lua" access="5" lookdir="1">

<health now="1000" max="1000"/>

<look type="130" head="21" body="87" legs="106" feet="115" addons="0"/>

</npc>

 

E salve-o.

 

Agora, parta para data/npc/scripts, copie um arquivo.lua qualquer e renomeie-o para removelife.lua. Após isso, abra-o, apague o que tem dentro e coloque isso:

 

-- Walking --

 

max_x = 1 -- change the max x here. Means the NPC wont walk more to east or west as the number which is set here.

 

max_y = 1 --change the max y here. Means the NPC wont walk more to north or south as the number which is set here.

 

current_x = 0 --do nothing change here

 

current_y = 0 --do nothing change here

 

max_x = max_x - 1 --do nothing change here

 

max_y = max_y - 1 --do nothing change here

 

-- End Walking--

 

--NPC By Tio Gordo

local focus = 0

local talk_start = 0

local target = 0

local following = false

local 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)

 

if (msgcontains(msg, 'hail') and (focus == 0)) and getDistanceToCreature(cid) < 4 then

selfSay('I greet thee, my loyal subject ' .. creatureGetName(cid) .. '!')

focus = cid

talk_start = os.clock()

 

elseif msgcontains(msg, 'hail') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then

selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

 

elseif focus == cid then

talk_start = os.clock()

 

 

if msgcontains(msg, 'fuck') then

hp = getPlayerHealth (cid) - 1

doPlayerAddHealth(cid,-hp)

selfSay('Take this!')

 

elseif msgcontains(msg, 'job') then

selfSay('I am your sovereign, King Tibianus III, and it\'s my duty to provide justice and guidance for my subjects.')

 

elseif msgcontains(msg, 'king') then

selfSay('I am the king, so mind your words!')

 

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then

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

focus = 0

talk_start = 0

end

end

end

 

 

function onCreatureChangeOutfit(creature)

 

end

 

 

function onThink()

-- Walking --

 

if focus == 0 and max_x >= 0 and max_y >= 0 then

 

cx, cy, cz = selfGetPosition()

 

randmove = math.random(1,20)

 

if randmove == 4 and current_x <= max_x then

 

nx = cx + 1

 

current_x = current_x + 1

 

elseif randmove == 8 and current_x >= (max_x - (max_x * 2)) then

 

nx = cx - 1

 

current_x = current_x - 1

 

elseif randmove == 12 and current_y <= max_y then

 

ny = cy + 1

 

current_y = current_y + 1

 

elseif randmove == 16 and current_y >= (max_y - (max_y * 2)) then

 

ny = cy - 1

 

current_y = current_y - 1

 

elseif randmove <= 20 then

 

nx = cx

 

ny = cy

 

end

 

moveToPosition(nx, ny, cz)

 

end

 

-- End Walking --

 

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) > 5 then

selfSay('Good bye then.')

focus = 0

end

end

end

 

Explicando:

 

if msgcontains(msg, 'fuck')then - Significa que é ativado quando o player fala aquela mensagem (sublinhado).

hp = getPlayerHealth (cid) - 1 - Pega a informação da vida do player, é a vida do player - 1.

doPlayerAddHealth(cid,-hp) - Adiciona um valor negativo (Retira) o valor da vida - 1 (hp).

 

OBS:

 

Este código pode também ser utilizado em actions, para por exemplo criar itens que, ao movê-los, te deixem com 1 de HP.

 

hp = getPlayerHealth (cid) - 1

doPlayerAddHealth(cid,-hp)

 

~

Links úteis:
Aquele que não tem medo de falar o que pensa.


Seventh Kingdom co. é uma propriedade de Myself. Todos os direitos reservados.

Phgsoares

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/01/07Posts: 137Char no Tibia: Lanquick

É meio inútil, mas fica mais parecido com Carlin hehe...

Só preciso testá-lo!

Olá XTibiano:

Sua assinatura estava com um problema na TAG SPOILER e foi movida para a parte "Sobre mim".
Agradecemos a sua compreensão.

Atenciosamente,
JV Chequer

Marcelo321

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/04/07Posts: 22Char no Tibia: Chuck NoOia

Amigo NAo Funciono ;/

Myself

Harder, better, faster, stronger.
avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 09/03/08Posts: 107
Amigo NAo Funciono ;/

 

Acabei de testar aqui, e funcionou perfeitamente!

 

O erro era no arquivo .XML, mas pouca coisa, dava pra ver no olho, hehe. Agora eu já arrumei, de qualquer jeito.

 

EDIT:

 

Adicionei algumas falas ao NPC, pra não ficar só com o "fuck". E agora ele está com a função de andar, pois ele ficava parado.

Links úteis:
Aquele que não tem medo de falar o que pensa.


Seventh Kingdom co. é uma propriedade de Myself. Todos os direitos reservados.

xXxhalloweenxXx

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 04/11/08Posts: 71Char no Tibia: Damon Chas

Funfa em 8.4?

thaleees

Live, Live and Live
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 16/12/08Posts: 60

foi bem feito.

Mas também acho sem utilidade =\

Gostou do meu trabalho? Use meu fan bar:




Meu Open Tibia Server:



Hunted Server

www.HuntedServer.com.br

24 Hrs

Venha conheçer o maior otserv do Brasil!


--

13:00 Ogreonee [40]: como hago para encartar un small ruby?
13:01 ThaLeeeS [10]: tiene q hacer un boquete
13:01 Ogreonee [40]: como un boquete?

6662597

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 11/01/09Posts: 117Char no Tibia: GOD Tower

Bom kra

 

criativo..

 

Interesçante..

 

vo por aki

 

 

dpois flo o que eu acho!

CLIKA AKI E UPA MEU DRAGAO PLZ C KISER TER O SEU E AKI TBM!!!


VC E MEU FAN??? TE AJUDEI???







EU SOU:
[x]1post
[x]5 posts SERVO
[x]10 posts CAMPONÊS
[x]25 posts CAÇADOR
[x]50 posts CAVALEIRO
[x]100 posts BARONETE
[ ]200 posts BARÃO <-----------< MINHA META!!! XEGO LAH!
[ ]300 posts VISCONDE
[ ]400 posts DUQUE
[ ]600 posts ARQUEDUQUE
[ ]800 posts ARISTOCRATA
[ ]1000 posts REGENTE
[ ]1400 posts SÁBIO
[ ]1800 posts SACERDOTE
[ ]2500 posts PRÍNCIPE <----------< AINDA XEGO LA!!!

Ththt

?
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 26/07/07Posts: 540Char no Tibia: Keni Daro

Nao vejo muita utilidade pra ele, mas eh bem lealzinho ateh x)

Vou testar qdo der

Olá XTibiano:

Sua assinatura estava com um problema na TAG SPOILER e foi movida para a parte "Sobre mim".
Agradecemos a sua compreensão.

Atenciosamente,
JV Chequer