Strona Główna Belxena 8.4 RPG

Forum poświęcone powstawaniu Belxena OTS


#1 2009-05-02 10:07:01

Wiesiu

Administrator

Zarejestrowany: 2009-04-03
Posty: 59
Punktów :   

Quest na addon

Pisałem że napisze skrypt podobny do tego "npc do sagi"
postanowiłem zrobić quest na addon piracki. Zadanie utrzymane jest w klimacie rpg. Może krótko opisze: znajdujemy się na wyspie piratów podchodzimy do npc imieniem Joe i rozpoczynamy rozmowę. Stary wilk morski opowiada nam o braku żywności i prosi nas o pomoc, mamy zdobyć dla niego 20 plastrów szynki. Gdy je zdobędziemy zaproponuje nam dołączenie do piratów. Aby otrzymać strój musimy udać się do Gorona.

Tworzymy plik w data\npc Joe.xml

Kod:

<?xml version="1.0"?>
<npc name="Joe" script="data/npc/scripts/joe.lua" access="5" lookdir="2" autowalk="25">
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
<look type="151" head="38" body="115" legs="76" feet="114" addons="2"/>
</npc>

następnie w data/npc/scripts plik joe.lua

Kod:

--------------------------------------------------------------------------------------------
------------------------------------ Pirate addon by Sharky ------------------------------------
--------------------------- Script made by Svira(szkielet by uFi) --------------------------
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
addon_need_premium = 'Sorry, you need a premium account to get addons.'
addon_have_already = 'Sorry, you already have this addon.'
addon_have_not_items = 'Sorry, you don\'t have these items.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'pomoc') then
selfSay('Witaj znajdujesz sie na wyspie piratow. Ohh duzej nie wytrzymam tego glodu...."glod"')
elseif msgcontains(msg, 'glod') then
selfSay('Czy bylbys tak dobry i zdobyl dla mnie jakies jedzenie?')
------------------------------------------------jedzenie------------------------------------------------
elseif msgcontains(msg, 'jedzenie') then
if isPremium(cid) then
if getPlayerItemCount(cid,2671) >= 20 then
selfSay('Czy masz dla mnie 20 szynek?')
talk_state = 1
else
selfSay('potrzebuje 20 plastrow szynki.')
talk_state = 0
end
else
selfSay('musisz miec konto premium')
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,2671) >= 20 then
quest = getPlayerStorageValue(cid,5012)
if quest == -1 then
if doPlayerTakeItem(cid,2671,20) == 0 then
selfSay('Dzieki, jezeli chcesz sie do nas przylaczyc idz do Garona a otrzymasz piracki stroj.')
setPlayerStorageValue(cid,5012,1)
end
else
selfSay('Dzieki za jedzenie narazie nie potrzeba mi nic wiecej.')
end
else
selfSay('Nie przyniosles jedzenia.')
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
selfSay('Dzieki zegnaj.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

potem w data/npc Garon.xml

Kod:

<?xml version="1.0"?>
<npc name="Garon" script="data/npc/scripts/garon.lua" access="5" lookdir="2" autowalk="25">
    <mana now="800" max="800"/>
    <health now="200" max="200"/>
<look type="151" head="51" body="115" legs="76" feet="114" addons="3"/>
</npc>

i w data/npc/scripts garon.lua

Kod:

--------------------------------------------------------------------------------------------
------------------------------------ Pirate addon by Sharky ------------------------------------
--------------------------- Script made by Svira(szkielet by uFi) --------------------------
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
addon_need_premium = 'Sorry, you need a premium account to get addons.'
addon_have_already = 'Sorry, you already have this addon.'
addon_have_not_items = 'Sorry, you don\'t have these items.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'stroj') then
selfSay('Czy jestes pewien ze chcesz zostac piratem i otrzymac stroj?.')
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') then
quest = getPlayerStorageValue(cid,5012)
if quest == 1 then
selfSay('Oto twoj stroj.')
setPlayerStorageValue(cid,5012,2)
doPlayerAddAddon(cid, 151, 2)
doPlayerAddAddon(cid, 155, 2)
else
selfSay('Juz dostales stroj.')
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
selfSay('Ok than.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Mam nadzieję że się podoba. Jeżeli czas na to pozwoli mogę dodawać nowe elementy do tego questy i powstanie bardzo ciekawy event dla OTS-ów bądź ciś w rodzaju misji.
Pozdrawiam
Sharky

Edit oczywiście zdobycie addonu możliwe jest tylko po wykonaniu questu co pewnie bardziej doświadczeni skrypterzy zauważyli. Jeżeli ktoś chciałby aby uczynić ten quest bardziej trudny przez stworzenie trudniejszych wymagań (czyt. więcej przedmiotów, bardziej kosztownych itp) to proszę napisać a wytłumaczę jak to zrobić.


http://images.net.pl/file/u6iur6fo6sojbxta16uv.jpg

Offline

 

Stopka forum

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


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.promotyle.pun.pl www.zspjasliska.pun.pl www.realnet.pun.pl www.msg.pun.pl www.vspolmiedztrans.pun.pl