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)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfLook(cid)
selfSay('Witam ' .. creatureGetName(cid) .. '! Sprzedaje armors, legi, helmets, shields, boots.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! Ale jestem teraz zajety.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'armors') then
selfSay('Sprzedaje: crown armor (40k), knight armor (25k), plate armor (1k), brass armor (500gp), chain armor (200gp)')
elseif msgcontains(msg, 'legi') then
selfSay('Sprzedaje: knight legs (22k), plate legs (1,2k), brass legs (500gp)')
elseif msgcontains(msg, 'helmets') then
selfSay('Sprzedaje: warrior helmet (6k), crown helmet (2,5k), devil helmet (3k).')
elseif msgcontains(msg, 'shields') then
selfSay('Sprzedaje: medusa shield (25k), tower shield (15k), dragon shield (6k), dwarven shield (200gp), guardian shield (3k).')
elseif msgcontains(msg, 'boots') then
selfSay('Sprzedaje: crocodile boots (1,5k), boot of haste (45k).')
elseif msgcontains(msg, 'crown armor') then
buy(cid,2487,1,40000)
elseif msgcontains(msg, 'knight armor') then
buy(cid,2476,1,25000)
elseif msgcontains(msg, 'plate armor') then
buy(cid,2463,1,1000)
elseif msgcontains(msg, 'brass armor') then
buy(cid,2465,1,500)
elseif msgcontains(msg, 'chain armor') then
buy(cid,2464,1,200)
elseif msgcontains(msg, 'knight legs') then
buy(cid,2477,1,22000)
elseif msgcontains(msg, 'plate legs') then
buy(cid,2647,1,1200)
elseif msgcontains(msg, 'brass legs') then
buy(cid,2478,1,500)
elseif msgcontains(msg, 'warrior helmet') then
buy(cid,2475,1,6000)
elseif msgcontains(msg, 'crown helmet') then
buy(cid,2491,1,2500)
elseif msgcontains(msg, 'devil helmet') then
buy(cid,2462,1,3000)
elseif msgcontains(msg, 'medusa shield') then
buy(cid,2536,1,25000)
elseif msgcontains(msg, 'tower shield') then
buy(cid,2528,1,15000)
elseif msgcontains(msg, 'dragon shield') then
buy(cid,2516,1,6000)
elseif msgcontains(msg, 'dwarven shield') then
buy(cid,2525,1,200)
elseif msgcontains(msg, 'guardian shield') then
buy(cid,2515,1,3000)
elseif msgcontains(msg, 'crocodile boots') then
buy(cid,3982,1,1500)
elseif msgcontains(msg, 'boh') or msgcontains(msg, 'boots of haste') then
buy(cid,2195,1,45000)
elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Dowidzenia, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 15 then
if focus > 0 then
selfSay('Nastepny prosze...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 3 then
selfSay('Dowidzenia.')
focus = 0
end
end
if focus == 0 then
cx, cy, cz = selfGetPosition()
randmove = math.random(1,10)
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)
--summons = 30
--summons2 = 30
end
end