What's new

Skrypty & Kody NPC Handlarz i Zasi?g interakcji

Status
Not open for further replies.

Wirox

User
Joined
Apr 29, 2009
Messages
31
Reaction score
0
Witam.
Kiedy ju? upora?em si? z tym jak poprawnie zrobi? interakcj?, chcia?em p?j?? krok dalej i zrobi?, aby NPC sprzedawa? r??ne przedmioty. Niestety zn?w nie wiem jak mam to zrobi?. Najpierw pr?bowa?em zrobi? sklep na wz?r istniej?cych ju? NPC, potem pr?bowa?em poszuka? informacji w internecie - na moje nieszcz??cie nie uda?o si?. Je?li kto? wie jak zrobi? NPC handlarza, bardzo prosi?bym o informacje.
Mam te? drugi problem. Chcia?em zwi?kszy? zasi?g interakcji NPC i my?la?em, ?e wystarczy fragment kodu interaction range="3" zmieni? po prostu na wy?sz? warto??. Niestety nic si? nie zmieni?o. Wie kto? dlaczego tak si? dzieje?
Z g?ry dzi?kuj? za wszelkie pr?by pomocy.
 

My Vision

User
Joined
Jan 8, 2012
Messages
12
Reaction score
0
Odp: NPC Handlarz i Zasi?g interakcji

Nic si? nie zmieni poniewa? zakres interaction jest w?a?nie do 3.
 

Wirox

User
Joined
Apr 29, 2009
Messages
31
Reaction score
0
Odp: NPC Handlarz i Zasi?g interakcji

Nie ma ?adnego innego sposobu na zwi?kszenie tego zasi?gu? W moim przypadku NPC'a i gracza dziel? a? dwie kratki, wi?c bardzo trudno jest z nim rozmawia? (tym bardziej, ?e NPC chodzi po "sklepie").
 

TenTypSwir

NNSTORY.EU Developer
Joined
Jun 8, 2010
Messages
1,657
Reaction score
117
Odp: NPC Handlarz i Zasi?g interakcji

A wi?c jak masz
and getDistanceToCreature(cid) < 4 then
to zmien 4 na ile kratek odstepu ma odpisywac ;d :p
Pomog?o??
+ Tu masz NPC gotowego (tylko pozmieniaj id przedmiot?w i nazwy :p)
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)
local msg = string.lower(msg)
if msgcontains(msg, 'hi') and focus == 0 and getDistanceToCreature(cid) < 4 then
selfSay('Hello ' .. creatureGetName(cid) .. '! I ,Cece, and ,Cyce,.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') 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, 'runes') then
selfSay('I ,Cece, and ,Cc,.')
elseif msgcontains(msg, 'cece') then
selfSay('I Cc and Cece.')
elseif msgcontains(msg, 'cc') then
selfSay('I Cece and Cc.')
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif msgcontains(msg, 'cece') then
buy(cid,2160,getCount(msg),90)
elseif msgcontains(msg, 'cc') then
buy(cid,2160,getCount(msg),50)
elseif string.find(msg, '(%a*)bye(%a*)') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
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
PODKRE?LONA cyfra oznacza ?e je?li odejdziemy od npc o tyle kratek on nas ?egna :]
 
Last edited:

Wirox

User
Joined
Apr 29, 2009
Messages
31
Reaction score
0
Odp: NPC Handlarz i Zasi?g interakcji

Niestety w kodzie NPC nie znalaz?em takiego fragmentu, poniewa? u mnie wygl?da to nieco inaczej. Mam po prostu s?owa na jakie reaguje, i co si? wtedy dzieje. W przypadku 'hi' jest to zmiana focus na 1 i odpowied? NPC. A ?adnych warunk?w nie mam. Wygl?da to tak:

Code:
	<[color=darkblue]interaction range="3"[/color] idletime="30" defaultpublic="0">

		<interact keywords="hi" focus="1">
			<!--These are the alternative keywords-->
			<keywords>hello</keywords>
			<response text="Welcome |NAME|! Do you want to buy something to eat? I have fresh bread and fruit for sale."/>
		</interact>

Edit: Wiesz mo?e jak zrobi?, aby NPC sprzedawa? itemy? Jest mi to potrzebne w?a?nie do tego NPC, bo jak na razie tylko m?wi o swoim imieniu i pracy (o ile jakim? cudem uda ci si? wej?? w zasi?g interakcji...)
 
Last edited:

TenTypSwir

NNSTORY.EU Developer
Joined
Jun 8, 2010
Messages
1,657
Reaction score
117
Odp: NPC Handlarz i Zasi?g interakcji

<?xml version="1.0"?>
<npc name="Handler" script="data/npc/scripts/selled.lua" access="3" lookdir="3" autowalk="1">
<health now="1000" max="1000"/>
<look type="142" head="114" body="0" legs="95" feet="114"/>
</npc>
^ wklej to do data/npc i tego npc "Handler"

W folderze npc utw?rz folder "scripts"
Utworz plik "selled.lua" i wklej do folderu "scripts" ,do pliku selled.lua wklej to co podalem w poprzednim poscie i pozmieniaj tam ;p
 
Last edited:

Wirox

User
Joined
Apr 29, 2009
Messages
31
Reaction score
0
Odp: NPC Handlarz i Zasi?g interakcji

Ach, bo tobie chodzi?o o plik LUA, kt?ry jest wczytywany przez plik NPC w XML'u, tak? Bo akurat m?j NPC ma w?asne teksty i wszystko jest napisane w XML'u (poza g??wnymi odruchami, kt?re si? tycz? wszystkich NPC). Da?oby si? zrobi? te rzeczy, o kt?rych pisa?em bez tworzenia dodatkowego pliku LUA, kt?ry ten NPC musia?by wczytywa?? Mo?na to wszystko zrobi? w pliku XML NPC'a?
 

TenTypSwir

NNSTORY.EU Developer
Joined
Jun 8, 2010
Messages
1,657
Reaction score
117
Odp: NPC Handlarz i Zasi?g interakcji

Nwmm... na wersji od 8.4+ sie nie znam tak dobrze xD ja preferuje moj sposob ;p mi dziala
 

Wirox

User
Joined
Apr 29, 2009
Messages
31
Reaction score
0
Odp: NPC Handlarz i Zasi?g interakcji

Dzi?ki za pomoc! Reput ju? polecia?.
Dobra, jak na razie sklep i zasi?g interakcji zrobi? w oddzielnym pliku. P??niej pomy?l? nad tym jak to wszystko zrobi? w XML'u. B?d? musia? tylko usun?? wszystkie teskty powitania, po?egnania itp, bo zawar?em ju? to w pliku NPC'a.
Temat mo?na ju? zamkn??.
 
Status
Not open for further replies.
Top