OTS Fans

Witamy Na OTS Fans, Przeczytaj Regulamin lub Zarejestruj się.

  • Nie jesteś zalogowany.
  • Polecamy: Gry

#1 2011-04-17 07:09:30

Xelemeleque

I User

Zarejestrowany: 2011-04-14
Posty: 17
Punktów :   

Friendly Dog - Czyli nietypowy NPC

Autorem Jest Cassius
Oryginalny Temat


Skrypt mojego autorstwa.

1. Stwórz plik Friendly Dog.xml a do niego wklej:

Kod:

<?xml version="1.0"?>
<npc name="Friendly Dog" script="data/npc/scripts/fd.lua" access="0" monster="1" speed="220" level="10" maglevel="1" exp="0" pushable="0" lookdir="0">
    <health now="100" max="100"/>
    <mana now="100" max="100"/>
    <look type="32" head="78" body="61" legs="52" feet="114" corpse="2839"/>  
</npc>

2. Następnie stwórz plik fd.lua a w nim:

Kod:

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
      sx, sy, sz = selfGetPosition()
          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
        selfSay('How How!')
        focus = cid
        talk_start = os.clock()

    elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
        selfSay('Grrrrrrrrr!')

    elseif focus == cid then
        talk_start = os.clock()

        if msgcontains(msg, 'a') then
            sx, sy, sz = selfGetPosition()
            selfMoveTo(sx-1, sy, sz)

        elseif msgcontains(msg, 'd') then
            sx, sy, sz = selfGetPosition()
            selfMoveTo(sx+1, sy, sz)

        elseif msgcontains(msg, 's') then
            sx, sy, sz = selfGetPosition()
            selfMoveTo(sx, sy+1, sz)

        elseif msgcontains(msg, 'w') then
            sx, sy, sz = selfGetPosition()
            selfMoveTo(sx, sy-1, sz)

        elseif msgcontains(msg, 'z') then
        selfSay('exori mort')

        elseif msgcontains(msg, 'x') then
        selfSay('exura')

        elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
            selfSay('Mhmmmuu... Mhmuuu... !!!')
            focus = 0
            talk_start = 0
        end
    end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
    if (os.clock() - talk_start) > 3600 then
        if focus > 0 then
            selfSay('Wuff! Wuff?')
        end
            focus = 0
    end
    if focus ~= 0 then
        if getDistanceToCreature(focus) > 1000 then
            selfSay('Wuff! Wuff!!! Wuuuuffff!!!!')
            focus = 0
        end
    end
end

Użycie:
Napisz hi.
Od teraz możesz nim sterować za pomocą:

w a s d (Jak strzałki - chodzenie)
z - atak
x - leczenie się

/// Nie wiem po co to komu, ale rozrywka przednia

Offline

 

Stopka forum

RSS
Powered by PunBB 1.2.23
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi

[ Generated in 0.009 seconds, 7 queries executed ]


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.h2osok.pun.pl www.k800icentrum.pun.pl www.agh1rokis.pun.pl www.zrom.pun.pl www.ricoe.pun.pl