What's new

NPC Celly

Status
Not open for further replies.

aquatter

User
Joined
Mar 22, 2009
Messages
30
Reaction score
0
Witajcie,
Jestem tu nowy, ale postanowi?em szybko wzi?? si? do roboty ;)
Dzi? zrobi?em mojego pierwszego NPC i postanowi?em zamie?ci? go tutaj, aby komu? kto poszukuje NPC u?atwi? ?ycie :) Ostrzegam, to m?j pierwszy NPC, a wi?c otwarty jestem na wszelkie propozycje poprawienia b??d?w.
A wi?c Celly.xml (Lekarz)
PHP:
<?xml version="1.0"?>
<npc name="Celly" script="data/npc/scripts/Celly.lua" access="5" lookdir="2" autowalk="0">
<look type="194" head="0" body="0" legs="0" feet="0"/>
</npc>
Celly.lua
PHP:
local focus = 0
local talk_start = 0
local target = 0
local days = 0
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Zegnaj...')
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
maxhealth = getCreatureMaxHealth(cid)
health = getCreatureHealth(cid)
if health < maxhealth then
selfSay(Sl?abo wygladasz ' .. getCreatureName(cid) .. ', Pozwol, ze Cie uzdrowie')
else
selfSay('Wszystko z toba OK. Nie zawracaj mi nastepnym razem glowy.')
focus = 0
talk_start = 0
end
elseif (msgcontains(msg, 'help') or msgcontains(msg, 'heal')) and getDistanceToCreature(cid) < 4 then
selfSay('Uleczyc?')
elseif (msgcontains(msg, 'tak') or msgcontains(msg, 'yes')) and getDistanceToCreature(cid) < 4 then
doCreatureAddHealth(cid,ammound)
selfSay('Zegnam.')
focus = 0
talk_start = 0
elseif (msgcontains(msg, 'bye') or msgcontains(msg, 'nie')) and getDistanceToCreature(cid) < 4 then
selfSay('Zegnajj')
focus = 0
talk_start = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus > 0 then
x, y, z = creatureGetPosition(focus)
myx, myy, myz = selfGetPosition()
if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
selfTurn(1)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(3)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(0)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(2)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(0)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(3)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(1)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(2)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(0)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(3)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(1)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(2)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(0)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(3)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(1)
end
end
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Jestem zajety, nastepnym razem mow szybciej...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Polecam sie na przyslosc.')
focus = 0
end
end
end
Mam nadziej?, ?e si? uda? :D
 

Micki

Advanced User
Joined
May 2, 2009
Messages
373
Reaction score
23
Odp: NPC Celly

Wyt?umacz na czym on polega ???
 

Paki2008

User
Joined
Oct 24, 2008
Messages
32
Reaction score
0
Odp: NPC Celly

Skrypt w sam raz na wyspe RookGaard, mysle ze nie jedna osoba z niego skorzysta, pewnie sam go zamieszcze, ale pierw sprawdze czy jakis bledow nie ma na nim. Jak narazie nie oceniam.
 

Deaven

Advanced User
Joined
Mar 25, 2009
Messages
422
Reaction score
77
Odp: NPC Celly

THX przyda? mi si? do mojego ots'a...
Haha, fajnie, szkoda, ?e go nawet nie zainstalowa?e?...

Niestety ten skrypt nie w??czy si?...
chodzi o t? linijk?:
PHP:
elseif (msgcontains(msg, help') or msgcontains(msg, 'heal')) and getDistanceToCreature(cid) < 4 then
nie zrobi?e? apostrofu. Tak wygl?da poprawnie:
PHP:
elseif (msgcontains(msg, 'help') or msgcontains(msg, 'heal')) and getDistanceToCreature(cid) < 4 then


Dodatkowo, skoro robisz NPC pod 8.42 to albo r?b z NPC channel.

No i mog?e? zrobi?, ?eby powy?ej okre?lonej liczby hp nie leczy?.

ocena: 4/10

Pozdrawiam
Deaven
 

Paki2008

User
Joined
Oct 24, 2008
Messages
32
Reaction score
0
Odp: NPC Celly

No wymaga lekkich poprawek ten skrypt, ja tam sobie juz go poprawilem dziala mi bez zarzutow :)
 

aquatter

User
Joined
Mar 22, 2009
Messages
30
Reaction score
0
Odp: NPC Celly

Dzi?ki za opinie. Ju? poprawi?em i powinien dzia?a?.
 
Status
Not open for further replies.
Top