@@ -60,187 +60,281 @@ local function creatureSayCallback(npc, creature, type, message)
6060 return false
6161 end
6262
63- -- uth'lokr (Bast Skirts)
64- if MsgContains (message , " uth'lokr" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) < 1 then
65- npcHandler :say (" Firy steel it is. Need green ones' breath to melt. Or red even better. Me can make from shield. Lil' one want to trade?" , npc , creature )
66- npcHandler :setTopic (playerId , 1 )
67- elseif MsgContains (message , " yes" ) then
68- if npcHandler :getTopic (playerId ) == 1 then
69- npcHandler :say (" Wait. Me work no cheap is. Do favour for me first, yes?" , npc , creature )
70- npcHandler :setTopic (playerId , 2 )
71- elseif npcHandler :getTopic (playerId ) == 2 then
72- npcHandler :say (" Me need gift for woman. We dance, so me want to give her bast skirt. But she big is. So I need many to make big one. Bring three okay? Me wait." , npc , creature )
73- if player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .DefaultStart ) ~= 1 then
74- player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .DefaultStart , 1 )
75- end
76- player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops , 1 )
77- npcHandler :setTopic (playerId , 3 )
78- elseif npcHandler :getTopic (playerId ) == 4 then
79- if player :removeItem (3560 , 3 ) then
80- npcHandler :say (" Good good! Woman happy will be. Now me happy too and help you." , npc , creature )
81- player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops , 2 )
82- npcHandler :setTopic (playerId , 0 )
83- else
84- npcHandler :say (" Lil' one bring three bast skirts." , npc , creature )
85- npcHandler :setTopic (playerId , 3 )
86- end
63+ local msg = string.lower (message )
64+ local isYes = (msg == " yes" )
65+
66+ -- uth'lokr
67+ if MsgContains (msg , " uth'lokr" ) then
68+ local stor = player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops )
69+
70+ -- step 1 - deal with A Sweaty Cyclops
71+ if stor < 1 then
72+ npcHandler :say (" Firy steel it is. Need green ones' breath to melt. Or red even better. Me can make from shield. Lil' one want to trade?" , npc , creature )
73+ npcHandler :setTopic (playerId , 1 )
74+ return true
8775 end
88- elseif MsgContains (message , " bast skirt" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 1 then
89- if npcHandler :getTopic (playerId ) == 3 then
90- npcHandler :say (" Lil' one bring three bast skirts?" , npc , creature )
76+
77+ -- bast skirt delivery (storage == 1)
78+ if stor == 1 then
79+ npcHandler :say (" Lil' one bring three bast skirts." , npc , creature )
9180 npcHandler :setTopic (playerId , 4 )
81+ return true
82+ end
83+
84+ -- dragon shield trade (storage == 2)
85+ if stor == 2 then
86+ npcHandler :say (" Firy steel it is. Need green ones' breath to melt. Or red even better. Me can make from shield. Lil' one want to trade?" , npc , creature )
87+ npcHandler :setTopic (playerId , 6 )
88+ return true
9289 end
9390 end
94- -- uth'lokr (Bast Skirts)
95- if MsgContains (message , " uth'lokr" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) < 1 then
96- npcHandler :say (" Firy steel it is. Need green ones' breath to melt. Or red even better. Me can make from shield. Lil' one want to trade?" , npc , creature )
97- npcHandler :setTopic (playerId , 1 )
98- elseif MsgContains (message , " yes" ) then
99- if npcHandler :getTopic (playerId ) == 1 then
100- npcHandler :say (" Wait. Me work no cheap is. Do favour for me first, yes?" , npc , creature )
101- npcHandler :setTopic (playerId , 2 )
102- elseif npcHandler :getTopic (playerId ) == 2 then
103- npcHandler :say (" Me need gift for woman. We dance, so me want to give her bast skirt. But she big is. So I need many to make big one. Bring three okay? Me wait." , npc , creature )
104- if player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .DefaultStart ) ~= 1 then
105- player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .DefaultStart , 1 )
106- end
107- player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops , 1 )
91+
92+ -- yes handlers (uth'lokr (bast skirts))
93+ -- uth'lokr - step 1
94+ if isYes and npcHandler :getTopic (playerId ) == 1 then
95+ npcHandler :say (" Wait. Me work no cheap is. Do favour for me first, yes?" , npc , creature )
96+ npcHandler :setTopic (playerId , 2 )
97+ return true
98+ end
99+
100+ -- uth'lokr - step 2
101+ if isYes and npcHandler :getTopic (playerId ) == 2 then
102+ npcHandler :say (" Me need gift for woman. We dance, so me want to give her bast skirt. But she big is. So I need many to make big one. Bring three okay? Me wait." , npc , creature )
103+ player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .DefaultStart , 1 )
104+ player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops , 1 )
105+ npcHandler :setTopic (playerId , 3 )
106+ return true
107+ end
108+
109+ -- bast skirt delivery
110+ if isYes and npcHandler :getTopic (playerId ) == 4 then
111+ if player :removeItem (3560 , 3 ) then
112+ npcHandler :say (" Good good! Woman happy will be. Now me happy too and help you." , npc , creature )
113+ player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops , 2 )
114+ npcHandler :setTopic (playerId , 0 )
115+ else
116+ npcHandler :say (" Lil' one bring three bast skirts." , npc , creature )
108117 npcHandler :setTopic (playerId , 3 )
109- elseif npcHandler :getTopic (playerId ) == 4 then
110- if player :removeItem (3560 , 3 ) then
111- npcHandler :say (" Good good! Woman happy will be. Now me happy too and help you." , npc , creature )
112- player :setStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops , 2 )
113- npcHandler :setTopic (playerId , 0 )
114- else
115- npcHandler :say (" Lil' one bring three bast skirts." , npc , creature )
116- npcHandler :setTopic (playerId , 3 )
117- end
118- end
119- elseif MsgContains (message , " bast skirt" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 1 then
120- if npcHandler :getTopic (playerId ) == 3 then
121- npcHandler :say (" Lil' one bring three bast skirts?" , npc , creature )
122- npcHandler :setTopic (playerId , 4 )
123118 end
119+ return true
124120 end
125121
126- -- Uth'kean (Crown Armor - Piece of Royal Steel)
127- if MsgContains (message , " uth'kean" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
128- npcHandler :say (" Very noble. Shiny. Me like. But breaks so fast. Me can make from shiny armour. Lil' one want to trade?" , npc , creature )
129- npcHandler :setTopic (playerId , 5 )
130- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 5 then
122+ ---- ------------------------------------------------------------------------
123+ -- uth'kean (crown armor -> piece of royal stell)
124+ if MsgContains (msg , " uth'kean" ) then
125+ if player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
126+ npcHandler :say (" Very noble. Shiny. Me like. But breaks so fast. Me can make from shiny armour. Lil' one want to trade?" , npc , creature )
127+ npcHandler :setTopic (playerId , 5 )
128+ return true
129+ end
130+ end
131+
132+ if isYes and npcHandler :getTopic (playerId ) == 5 then
131133 if player :removeItem (3381 , 1 ) then
132134 npcHandler :say (" Cling clang!" , npc , creature )
133135 player :addItem (5887 , 1 )
134136 npcHandler :setTopic (playerId , 0 )
135137 end
138+ return true
136139 end
137140
138- -- uth'lokr (Dragon Shield - Piece of Draconian Steel)
139- if MsgContains (message , " uth'lokr" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
140- npcHandler :say (" Firy steel it is. Need green ones' breath to melt. Or red even better. Me can make from shield. Lil' one want to trade?" , npc , creature )
141- npcHandler :setTopic (playerId , 6 )
142- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 6 then
141+ -- uth'lokr (dragon shield -> piece of draconian steel)
142+ if isYes and npcHandler :getTopic (playerId ) == 6 then
143143 if player :removeItem (3416 , 1 ) then
144144 npcHandler :say (" Cling clang!" , npc , creature )
145145 player :addItem (5889 , 1 )
146146 npcHandler :setTopic (playerId , 0 )
147147 end
148+ return true
148149 end
149150
150- -- za'ralator (Devil Helmet - Piece of Hell Steel)
151- if MsgContains (message , " za'ralator" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
152- npcHandler :say (" Hellsteel is. Cursed and evil. Dangerous to work with. Me can make from evil helmet. Lil' one want to trade?" , npc , creature )
153- npcHandler :setTopic (playerId , 7 )
154- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 7 then
151+ -- za'ralator (devil helmet -> piece of hell steal)
152+ if MsgContains (msg , " za'ralator" ) then
153+ if player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
154+ npcHandler :say (" Hellsteel is. Cursed and evil. Dangerous to work with. Me can make from evil helmet. Lil' one want to trade?" , npc , creature )
155+ npcHandler :setTopic (playerId , 7 )
156+ return true
157+ end
158+ end
159+
160+ if isYes and npcHandler :getTopic (playerId ) == 7 then
155161 if player :removeItem (3356 , 1 ) then
156162 npcHandler :say (" Cling clang!" , npc , creature )
157163 player :addItem (5888 , 1 )
158164 npcHandler :setTopic (playerId , 0 )
159165 end
166+ return true
160167 end
161168
162- -- uth'prta (Giant Sword - Huge Chunk of Crude Iron)
163- if MsgContains (message , " uth'prta" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
164- npcHandler :say (" Good iron is. Me friends use it much for fight. Me can make from weapon. Lil' one want to trade?" , npc , creature )
165- npcHandler :setTopic (playerId , 8 )
166- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 8 then
169+ -- uth'prta (giant sword -> huge chunk of crude iron)
170+ if MsgContains (msg , " uth'prta" ) then
171+ if player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
172+ npcHandler :say (" Good iron is. Me friends use it much for fight. Me can make from weapon. Lil' one want to trade?" , npc , creature )
173+ npcHandler :setTopic (playerId , 8 )
174+ return true
175+ end
176+ end
177+
178+ if isYes and npcHandler :getTopic (playerId ) == 8 then
167179 if player :removeItem (3281 , 1 ) then
168180 npcHandler :say (" Cling clang!" , npc , creature )
169181 player :addItem (5892 , 1 )
170182 npcHandler :setTopic (playerId , 0 )
171183 end
184+ return true
185+ end
186+
187+ -- soul orb -> infernal bolt
188+ if MsgContains (msg , " soul orb" ) then
189+ if player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
190+ npcHandler :say (" Me can make nasty bolt from soul orbs. Trade all?" , npc , creature )
191+ npcHandler :setTopic (playerId , 9 )
192+ return true
193+ end
172194 end
173195
174- -- soul orb (soul orb - Infernal Bolts)
175- if MsgContains (message , " soul orb" ) and player :getStorageValue (Storage .Quest .U7_8 .FriendsAndTraders .TheSweatyCyclops ) == 2 then
176- npcHandler :say (" Uh. Me can make some nasty lil' bolt from soul orbs. Lil' one want to trade all?" , npc , creature )
177- npcHandler :setTopic (playerId , 9 )
178- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 9 then
179- if player :getItemCount (5944 ) > 0 then
180- local count = player :getItemCount (5944 )
196+ if isYes and npcHandler :getTopic (playerId ) == 9 then
197+ local count = player :getItemCount (5944 )
198+ if count > 0 then
199+ player :removeItem (5944 , count )
200+
201+ local total = 0
181202 for i = 1 , count do
182203 if math.random (100 ) <= 1 then
183- player :addItem (6528 , 200 )
184- player :removeItem (5944 , 1 )
185- npcHandler :say (" Cling clang! Me done good work today! Li'l one gets double bolts!" , npc , creature )
204+ total = total + 200
186205 else
187- player :addItem (6528 , 100 )
188- player :removeItem (5944 , 1 )
189- npcHandler :say (" Cling clang!" , npc , creature )
206+ total = total + 100
190207 end
191208 end
192- npcHandler :setTopic (playerId , 0 )
209+
210+ player :addItem (6528 , total )
211+ npcHandler :say (" Cling clang!" , npc , creature )
193212 end
213+ npcHandler :setTopic (playerId , 0 )
214+ return true
194215 end
195216
196- -- cup of molten gold
197- if MsgContains (message , " melt" ) then
217+ -- melt (gold ingot -> cup of molten gold
218+ if MsgContains (msg , " melt" ) then
198219 npcHandler :say (" Can melt gold ingot for li'l one. You want?" , npc , creature )
199220 npcHandler :setTopic (playerId , 10 )
200- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 10 then
221+ return true
222+ end
223+
224+ if isYes and npcHandler :getTopic (playerId ) == 10 then
201225 if player :removeItem (9058 , 1 ) then
202- npcHandler :say (" Whoooosh There!" , npc , creature )
203226 player :addItem (12804 , 1 )
227+ npcHandler :say (" Whoooosh There!" , npc , creature )
204228 npcHandler :setTopic (playerId , 0 )
205229 end
230+ npcHandler :setTopic (playerId , 0 )
231+ return true
206232 end
207233
208- -- gear wheel
209- if MsgContains (message , " gear wheel" ) then
210- npcHandler :say (" Want to make gear wheel from an iron ore li'l one ?" , npc , creature )
234+ -- iron ore -> gear wheel
235+ if MsgContains (msg , " gear wheel" ) then
236+ npcHandler :say (" Want to make gear wheel from iron ore?" , npc , creature )
211237 npcHandler :setTopic (playerId , 11 )
212- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 11 then
238+ return true
239+ end
240+
241+ if isYes and npcHandler :getTopic (playerId ) == 11 then
213242 if player :removeItem (5880 , 1 ) then
214- npcHandler :say (" Cling clang!" , npc , creature )
215243 player :addItem (8775 , 1 )
216- npcHandler :setTopic ( playerId , 0 )
244+ npcHandler :say ( " Cling clang! " , npc , creature )
217245 end
246+ npcHandler :setTopic (playerId , 0 )
247+ return true
218248 end
219249
220- -- Broken Amulet Pieces Quest
221- if MsgContains (message , " amulet" ) then
222- npcHandler :say (" Me can do unbroken but Big Ben want gold 5000 and Big Ben need all four pieces. {Yes}?" , npc , creature )
250+ ---- ------------------------------------------------------------------------
251+ -- Koshei Amulet Quest
252+
253+ if MsgContains (msg , " amulet" ) then
254+ -- quest already done
255+ if player :kv ():get (" koshei-amulet-done" ) then
256+ npcHandler :say (" Lil' one already has mighty amulet. Big Ben no make another!" , npc , creature )
257+ npcHandler :setTopic (playerId , 0 )
258+ return true
259+ end
260+
261+ -- check timer
262+ if player :kv ():get (" koshei-amulet-timer" ) then
263+ local finishTime = player :kv ():get (" koshei-amulet-timer" )
264+
265+ -- amulet still not done
266+ if finishTime > os.time () then
267+ local remaining = finishTime - os.time ()
268+
269+ -- time conversion
270+ local hours = math.floor (remaining / 3600 )
271+ local minutes = math.floor ((remaining % 3600 ) / 60 )
272+ local timeStr = " "
273+
274+ if hours > 0 then
275+ timeStr = hours .. " hour" .. (hours > 1 and " s" or " " )
276+ end
277+ if minutes > 0 then
278+ if timeStr ~= " " then timeStr = timeStr .. " and " end
279+ timeStr = timeStr .. minutes .. " minute" .. (minutes > 1 and " s" or " " )
280+ end
281+ if timeStr == " " then
282+ timeStr = " less than a minute"
283+ end
284+
285+ npcHandler :say (" Big Ben still hammering! Come back in " .. timeStr .. " !" , npc , creature )
286+ return true
287+ end
288+
289+ -- amulet done
290+ if finishTime <= os.time () then
291+ player :addItem (7532 , 1 )
292+ npcHandler :say (" Ahh, li'l one wants amulet. Here! Have it! Mighty, mighty amulet li'l one has. Don't know what but mighty, mighty it is!!!" , npc , creature )
293+ player :kv ():set (" koshei-amulet-done" , true )
294+ npcHandler :setTopic (playerId , 0 )
295+ return true
296+ end
297+ end
298+
299+ -- step 1
300+ npcHandler :say (" Me can do unbroken but Big Ben want gold 5000 and all four pieces. Yes?" , npc , creature )
223301 npcHandler :setTopic (playerId , 12 )
224- elseif MsgContains (message , " yes" ) and npcHandler :getTopic (playerId ) == 12 then
302+ return true
303+ end
304+
305+ -- yes confirmations
306+ if isYes and npcHandler :getTopic (playerId ) == 12 then
307+ -- quest already done
308+ if player :kv ():get (" koshei-amulet-done" ) then
309+ npcHandler :say (" Lil' one already did this! Big Ben no make again!" , npc , creature )
310+ npcHandler :setTopic (playerId , 0 )
311+ return true
312+ end
313+ -- if not done yet
314+ if player :kv ():get (" koshei-amulet-timer" ) then
315+ npcHandler :say (" Big Ben already working! Come back later!" , npc , creature )
316+ npcHandler :setTopic (playerId , 0 )
317+ return true
318+ end
319+ -- remove gold and check itens
225320 if player :removeMoneyBank (5000 ) then
226321 if player :getItemCount (7528 ) > 0 and player :getItemCount (7529 ) > 0 and player :getItemCount (7530 ) > 0 and player :getItemCount (7531 ) > 0 then
227322 player :removeItem (7528 , 1 )
228323 player :removeItem (7529 , 1 )
229324 player :removeItem (7530 , 1 )
230325 player :removeItem (7531 , 1 )
231- player : addItem ( 7532 , 1 )
232- npcHandler : say ( " Well, well, I do that! Big Ben unbroken amulet with big Hammer big hands! No worry! Here! Have it! Mighty, mighty amulet lil'one has. Don't know what but mighty, mighty it is!!! " , npc , creature )
233- npcHandler :setTopic ( playerId , 0 )
326+ -- timer 24h
327+ player : kv (): set ( " koshei- amulet-timer " , os.time () + 24 * 60 * 60 )
328+ npcHandler :say ( " Well, well. I do that! Big Ben makes li'l amulet unbroken with big hammer in big hands! No worry! Come back after sun hits the horizon 24 times and ask me for amulet. " , npc , creature )
234329 else
235- npcHandler :say (" Lil' one not have all pieces! Bring all four pieces." , npc , creature )
236- npcHandler :setTopic (playerId , 0 )
330+ npcHandler :say (" Lil' one not have all pieces." , npc , creature )
237331 end
238332 else
239- npcHandler :say (" Lil'one has not enough money." , npc , creature )
240- npcHandler :setTopic (playerId , 0 )
333+ npcHandler :say (" Lil' one has not enough money." , npc , creature )
241334 end
335+ npcHandler :setTopic (playerId , 0 )
336+ return true
242337 end
243- return true
244338end
245339
246340keywordHandler :addKeyword ({ " job" }, StdModule .say , { npcHandler = npcHandler , text = " I am smith." })
@@ -277,4 +371,4 @@ npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye lil' one.")
277371npcHandler :addModule (FocusModule :new (), npcConfig .name , true , true , true )
278372
279373-- npcType registering the npcConfig table
280- npcType :register (npcConfig )
374+ npcType :register (npcConfig )
0 commit comments