What's new

NPC [NPC] [8.54 & 8.60] Task System [WYJA?NIENIE]

Kenor

Senior User
Joined
May 23, 2009
Messages
967
Reaction score
21
Siemaneczko! Zapraszam do zapoznania si? z moim nowym poradnikiem dotycz?cym NPC Task, no to jedziemy!

UWAGA! Zaznaczam ?e nie jestem autorem danego skryptu, skrypt znaleziony w datapacku Podhalanskiego OTS (Edycja ju? niedost?pna - Moon OTS 3.0), autor nie jest znany.

I. Folder Creaturescripts:

1. Tworzymy plik counter.lua w data/creaturescripts/scripts. A w nim:

[LUA]
local monsters = { --name = storage
["mouse"] = 35001,
["rat"] = 35002,
["giant manta"] = 35003,
["fly"] = 35076,
}


function onKill(cid, target)
if(isPlayer(target) ~= TRUE) then
local name = getCreatureName(target)
local monster = monsters[string.lower(name)]
if(monster) then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters == -1) then
killedMonsters = 1
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed for now " .. killedMonsters .. " " .. name .. "'s.")
setPlayerStorageValue(cid, monster, killedMonsters + 1)
end
end
return TRUE
end
[/LUA]

2. Nastepnie w creaturescripts.xml dodajemy linijk?:
[XML]
<event type="kill" name="KilledMonstersCounter" event="script" value="counter.lua"/>
[/XML]

3. I kolejn? w data/creaturescripts/scripts/login.lua gdzie? na ko?cu pliku:
[LUA] registerCreatureEvent(cid, "KilledMonstersCounter")
[/LUA]

II. Folder NPCs:

1. W data/npc/ tworzymy plik Guard.xml, a w nim:

[XML]
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Guard" script="data/npc/scripts/shiptasker.lua" floorchange="0" access="5" level="1" maglevel="1">
<health now="150" max="150"/>
<look type="134" head="95" body="94" legs="92" feet="93" addons="2" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Hi! Welcome to our ship! We are sailing a lot of time, and have never meet the pirate bay. All in all we are sailing the same way, and its safe. If you search {work}? I think I can help you." />
<parameter key="message_farewall" value="Bye bye!"/>
<parameter key="message_walkaway" value="Cya!"/>
</parameters>
</npc>
[/XML]

2. Tworzymy plik w data/npc/scripts/ o nazwie: shiptasker.lua, i tworzymy przyk?adowy skrypt:
[LUA]
------STORAGE-------
------100 do 104-------
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'work')) then
setPlayerStorageValue(cid,39002,1)
selfSay('I have a good job for you. You must {clean} up my room. A lot of flies fly in my room. Please kill for me 5 flies.', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'clean')) then
selfSay('You must have some experience to kill these small ugly monsters. If you end your cleaning please say me you have {done}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'done') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,800) > 0) then
selfSay('You already help me, thank you so much.', cid)
else
if (getPlayerStorageValue(cid,35076) > 4) then
setPlayerStorageValue(cid,800,1)
doPlayerAddExperience(cid,1000)
selfSay('Thanks! For now you can go to the Ship Guard. Its all I can you give. {(given 1000 experience points)}', cid)
else
selfSay('You forget make your work? I remember everything boy, you should clean my room from flies, if you have done say {done}.', cid)
end
end
return true
end
----------------------------------------------------------
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
[/LUA]

3. Wyja?nienie:
[LUA]
if(msgcontains(msg, 'work')) then
setPlayerStorageValue(cid,39002,1)
selfSay('I have a good job for you. You must {clean} up my room. A lot of flies fly in my room. Please kill for me 5 flies.', cid)
end
[/LUA]

Je?eli napiszemy "WORK" napisze wiadomo?? kluczow? dla misji, przypisuj?c storage -> 39002, co jest storage globalnym dla danego skryptu.

Nast?pnie:
[LUA]
if(msgcontains(msg, 'clean')) thenselfSay('You must have some experience to kill these small ugly monsters. If you end your cleaning please say me you have {done}.', cid)
talkState[talkUser] = 1
[/LUA]

Je?li napiszemy s?owo zawarte, kt?re oznaczyli?my klamr?, zwr?ci dan? uwag? - konwersacja misji rozpocz?ta.

P??niej:
[LUA]
elseif(msgcontains(msg, 'done') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,800) > 0) then
selfSay('You already help me, thank you so much.', cid)
[/LUA]

Je?li napiszemy done, i wewn?trzny storage sprawdzi nam ?e ju? robili?my t? misj? zwr?ci nam komunikat 0, rozmowa wraca do poprzedniej wersji.

Nast?pnie:
[LUA]
if (getPlayerStorageValue(cid,35076) > 4) then
setPlayerStorageValue(cid,800,1)
doPlayerAddExperience(cid,1000)
selfSay('Thanks! For now you can go to the Ship Guard. Its all I can you give. {(given 1000 experience points)}', cid)
else
selfSay('You forget make your work? I remember everything boy, you should clean my room from flies, if you have done say {done}.', cid)
end
end
[/LUA]

Je?eli zabili?my storage "FLY" z pliku counter.lua wi?ksze od 4 czyli 5, otrzymujemy wewn?trzny storage wi?kszy od zera w naszym przypadku jest to 800. Daje nam 1000 expa.

W przeciwnym wypadku ko?czy rozmow? i wraca do poprzedniej wersji rozmowy.

Przypisali?my storage dla potwora o nazwie "FLY" - (getPlayerStorageValue(cid,35076) > 4) , POWY?EJ 4 CZYLI 5 SZTUK. TYLE MUSIMY ZABI? WA?EK.

III. ZASTOSOWANIE W QUEST LOGU LUB NA STRONIE WWW:

1. W pliku quests.xml w folderze data/XML :

[XML]
<quest name="In the swimming ship" startstorageid="39002" startstoragevalue="1">
<mission name="Cleaning up sailing team helper room" storageid="800" startvalue="1" endvalue="1">
<missionstate id="1" description="You gained now your first task on this sailing ship. You stand up with good dream, and you are exhaused and feel terrible."/>
</mission>
</quest>
[/XML]

storageid="800" --> ustalamy storage wewn?trzny

startstorageid="39002"
--> ustalamy storage z pliku NPC daj?cego misje (global storage dla pliku)

questname / missionname --> nazwa nag??wka misji oraz misji

2. Analogicznie na stronce WWW w accmakerze podajemy storage 39002



--- PORADNIK Z DEDYKACJ? DLA PXGAME & 4 FAME. ---

IV. Filmik instrukta?owy:
[video=youtube;vW7-jKCPGxg]https://www.youtube.com/watch?v=vW7-jKCPGxg[/video]


Zach?cam do subskrypcji powi?zanego kana?u na YT!

 
Joined
Apr 7, 2016
Messages
37
Reaction score
1
Odp: [NPC] [8.54 & 8.60] Task System [WYJA?NIENIE]

Przerobi?em ten skrypt ?e daje itemki i na 3 potwory.
Walczy?em ca?y dzie?.

Rada na przysz?o??.
W grze potwory sa z du?ej litery ale trupy z ma?ej. W pliki nale?y wprowadzi? je z ma?ej.

Pozdrawiam
 

Kenor

Senior User
Joined
May 23, 2009
Messages
967
Reaction score
21
Odp: [NPC] [8.54 & 8.60] Task System [WYJA?NIENIE]

Przerobi?em ten skrypt ?e daje itemki i na 3 potwory.
Walczy?em ca?y dzie?.

Rada na przysz?o??.
W grze potwory sa z du?ej litery ale trupy z ma?ej. W pliki nale?y wprowadzi? je z ma?ej.

Pozdrawiam


No tylko z ma?ej litery, przyk?ad skryptu chyba da??em jak to ma wygl?da?, ale dzi?ki ?e wspomnia?e? na pewno pomo?e to graczom.

Wkr?tce nowe tutoriale! Jako weteran Open Tibia zapowiadam, ?e ruszamy z projektem ZR?B W?ASNEGO RPGka Wkr?tce!
 

kaka492

User
Joined
May 4, 2015
Messages
47
Reaction score
0
Odp: [NPC] [8.54 & 8.60] Task System [WYJA?NIENIE]

Gra muzyka, przydalo sie :D
 
Top