1function onSay(player, words, param)
2 local split = param:splitTrimmed(" ")
3 local item_1, item_2, item_3, item_4, qnt_1, qnt_2, qnt_3, qnt_4, ext_1, ext_2, ext_3, ext_4, posb1, posb2, posb3, posb4 = false, false, false, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
4 local oriqnt_1, oriqnt_2, oriqnt_3, oriqnt_4 = 0, 0, 0, 0
5 if _DEBUG_MODE then
6 print("[TALK - UPGRADE] " ..player:getName().. " - ItemID: " .._ITEMS[tonumber(split[02])].NAME)
7 end
8
9 if split[01] == "00" then
10 local PlayerCoin = PlayerGoldCoins(player, 00)
11 local ITEM_ID = tonumber(split[02])
12 local BAG_ID = tonumber(split[03])
13 local EXT_ID = tonumber(split[04])
14 local SLOT_ID = tonumber(split[05])
15 local Temp_StarItem = tonumber(split[06])
16 local LevelItem = tonumber(split[07])
17 local IDENTIFICATION = tonumber(split[08])
18 local target = tonumber(split[09])
19 local sucessClick = tonumber(split[10])
20 local rareGun = tonumber(split[11])
21 for SearchItem = 01, 04 do
22 local ProcurarID = 00
23 local OriginQnt = 00
24 local slot = 03
25 local ext = 00
26 if IDENTIFICATION == 01 then
27 ProcurarID = _ITEMS[ITEM_ID].NUCLEO[01]
28 OriginQnt = _ITEMS[ITEM_ID].NUCLEO[02]
29 else
30 ProcurarID = _ITEMS[ITEM_ID].UPGRADE[SearchItem][01]
31 OriginQnt = _ITEMS[ITEM_ID].UPGRADE[SearchItem][02]
32 end
33
34 local RARE_UPGRADE = {
35 [-1] = 03,
36 [00] = 03,
37 [01] = 04,
38 [02] = 05,
39 [03] = 07,
40 [04] = 10,
41 }
42
43 doBackpack(player, 03, slot, ext, 01, ProcurarID) -- Procurar
44 local QntBag = doBackpack(player, 04)
45 local OrigTemp = 1
46 --if Temp_StarItem < 1 then Temp_StarItem = 1 end
47 --if LevelItem < 0 then LevelItem = 1 end
48 if IDENTIFICATION == 01 then
49 OrigTemp = OriginQnt--math.floor((OriginQnt * Temp_StarItem) / 2)
50 else
51 --print("((" ..OriginQnt.. " + 05) + " ..LevelItem.. ") * (" ..Temp_StarItem.. " + 01) + " ..RARE_UPGRADE[rareGun].. ")")
52 OrigTemp = ((OriginQnt + 05) + LevelItem + 01) * (Temp_StarItem + 01) + RARE_UPGRADE[rareGun]
53 --OrigTemp = math.floor((OriginQnt * (Temp_StarItem + 01) * (LevelItem + 01))) * 05
54 end
55 if OrigTemp < 1 then OrigTemp = 1 end
56 local PosBag = doBackpack(player, 05)
57 local ExtBag = doBackpack(player, 06)
58
59 if SearchItem == 01 then
60 oriqnt_1 = OrigTemp
61 elseif SearchItem == 02 then
62 oriqnt_2 = OrigTemp
63 elseif SearchItem == 03 then
64 oriqnt_3 = OrigTemp
65 elseif SearchItem == 04 then
66 oriqnt_4 = OrigTemp
67 end
68 if _CHEATS.UPGRADE_ITEM_FREE then
69 item_1 = true
70 item_2 = true
71 item_3 = true
72 item_4 = true
73 break
74 else
75 if ProcurarID > 0 then
76 if QntBag >= OrigTemp then
77 if SearchItem == 01 then
78 item_1 = true
79 qnt_1 = QntBag
80 ext_1 = ExtBag
81 posb1 = PosBag
82 if IDENTIFICATION == 01 then
83 item_2 = true
84 item_3 = true
85 item_4 = true
86 break
87 end
88 elseif SearchItem == 02 then
89 item_2 = true
90 qnt_2 = QntBag
91 ext_2 = ExtBag
92 posb2 = PosBag
93 elseif SearchItem == 03 then
94 item_3 = true
95 qnt_3 = QntBag
96 ext_3 = ExtBag
97 posb3 = PosBag
98 elseif SearchItem == 04 then
99 item_4 = true
100 qnt_4 = QntBag
101 ext_4 = ExtBag
102 posb4 = PosBag
103 end
104 end
105 else
106 if SearchItem == 01 then
107 item_1 = true
108 elseif SearchItem == 02 then
109 item_2 = true
110 elseif SearchItem == 03 then
111 item_3 = true
112 elseif SearchItem == 04 then
113 item_4 = true
114 end
115 end
116 end
117 end
118
119 if item_1 and item_2 and item_3 and item_4 then
120 local ItemPrice = _ITEMS[ITEM_ID].UPGRADE[00][01]
121 local YourChance = math.random(000, 100)
122 local UpgradeCoin = math.floor(((ItemPrice * (Temp_StarItem + 01) * (LevelItem + 01))) * 25) * (rareGun + 01)
123 local rateSucess = 95 - (((LevelItem + 02) * 02) + (Temp_StarItem * 20))
124 rateSucess = rateSucess + ((sucessClick - 01) * 02)
125 UpgradeCoin = UpgradeCoin * sucessClick
126
127 if _CHEATS.UPGRADE_COIN_FREE == false then
128 --local UpgradeCoin = math.floor((ItemPrice * (Temp_StarItem/2)) + (LevelItem * (LevelItem * Temp_StarItem)))
129 if PlayerCoin >= UpgradeCoin then
130 PlayerGoldCoins(player, 01, UpgradeCoin)
131 --player:setStorageValue(_SYSTEM.GOLD_COIN, (PlayerCoin - UpgradeCoin))
132 else
133
134 return false
135 end
136 end
137 if _CHEATS.UPGRADE_ITEM_FREE == false then
138 if qnt_1 > 0 then
139 if qnt_1 > oriqnt_1 then
140 player:setStorageValue(_BACKPACK[03][ext_1][posb1].UID_04, (qnt_1 - oriqnt_1))
141 else
142 doBackpack(player, 02, 03, ext_1, posb1)
143 end
144 end
145 if qnt_2 > 0 then
146 if qnt_2 > oriqnt_2 then
147 player:setStorageValue(_BACKPACK[03][ext_2][posb2].UID_04, (qnt_2 - oriqnt_2))
148 else
149 doBackpack(player, 02, 03, ext_2, posb2)
150 end
151 end
152 if qnt_3 > 0 then
153 if qnt_3 > oriqnt_3 then
154 player:setStorageValue(_BACKPACK[03][ext_3][posb3].UID_04, (qnt_3 - oriqnt_3))
155 else
156 doBackpack(player, 02, 03, ext_3, posb3)
157 end
158 end
159 if qnt_4 > 0 then
160 if qnt_4 > oriqnt_3 then
161 player:setStorageValue(_BACKPACK[03][ext_4][posb4].UID_04, (qnt_4 - oriqnt_4))
162 else
163 doBackpack(player, 02, 03, ext_4, posb4)
164 end
165 end
166 end
167
168 if YourChance <= rateSucess then
169 if rateSucess > 100 then rateSucess = 100 end
170 if IDENTIFICATION == 01 then -- STAR
171 if SLOT_ID == 04 then
172 if target == 00 then
173 if player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03) < 00 then
174 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03, (player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03) + 2))
175 else
176 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03, (player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03) + 1))
177 end
178 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_07, 0)
179 else
180 if player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03) < 00 then
181 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03, (player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03) + 2))
182 else
183 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03, (player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03) + 1))
184 end
185 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_07, 0)
186 end
187 else
188 if target == 00 then
189 if player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03) < 00 then
190 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03, (player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03) + 2))
191 else
192 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03, (player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_03) + 1))
193 end
194 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05, 0)
195 else
196 if player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03) < 00 then
197 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03, (player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03) + 2))
198 else
199 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03, (player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_03) + 1))
200 end
201 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05, 0)
202 end
203 if player:getStorageValue(_QUESTLOG[75].UID_01) == 02 then
204 player:setStorageValue(_QUESTLOG[75].UID_01, 100)
205
206 addEvent(function()
207 PlayerGoldCoins(player, 02, 1000)
208 player:addExperience(5000, true, true)
209 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
210 player:getPosition():sendMagicEffect(14)
211 player:sendCancelMessage("@LoadQuestWindows")
212 end, 4000)
213 end
214 if player:getStorageValue(_QUESTLOG[102].UID_01) == 01 then
215 if SLOT_ID == 01 then
216 player:setStorageValue(_QUESTLOG[102].UID_01, 100)
217
218 addEvent(function()
219 PlayerGoldCoins(player, 02, 10000)
220 player:addExperience(55000, true, true)
221 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
222 player:getPosition():sendMagicEffect(14)
223 player:sendCancelMessage("@LoadQuestWindows")
224 end, 3 * 1000)
225 end
226 end
227 end
228 player:popupFYI("Item aprimorado com sucesso.")
229 else -- LEVEL
230 local LevelItem = 0
231 if target == 00 then
232 LevelItem = player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05)
233 else
234 LevelItem = player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05)
235 end
236
237 if SLOT_ID == 04 then
238 if target == 00 then
239 LevelItem = player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_07)
240 else
241 LevelItem = player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_07)
242 end
243 end
244 if LevelItem < 0 then LevelItem = 0 end
245 if SLOT_ID == 04 then
246 if target == 00 then
247 if player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_07) < 00 then
248 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_07, 01)
249 else
250 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_07, (LevelItem + 1))
251 end
252 else
253 if player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_07) < 00 then
254 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_07, 01)
255 else
256 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_07, (LevelItem + 1))
257 end
258 end
259
260 -- DESAFIO
261 if player:getStorageValue(_DESAFIOS[00].DESAFIO_ID) > 00 then
262 if rareGun < 01 then
263 onPlayerDesafios(player, 86, 01)
264 elseif rareGun == 01 then
265 onPlayerDesafios(player, 87, 01)
266 elseif rareGun == 02 then
267 onPlayerDesafios(player, 88, 01)
268 elseif rareGun == 03 then
269 onPlayerDesafios(player, 89, 01)
270 elseif rareGun == 04 then
271 onPlayerDesafios(player, 90, 01)
272 end
273 end
274 else
275 if target == 00 then
276 if player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05) < 00 then
277 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05, 01)
278 else
279 player:setStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05, (LevelItem + 1))
280 end
281 else
282 if player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05) < 00 then
283 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05, 01)
284 else
285 player:setStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05, (LevelItem + 1))
286 end
287 end
288
289 -- DESAFIO
290 if player:getStorageValue(_DESAFIOS[00].DESAFIO_ID) > 00 then
291 if rareGun < 01 then
292 onPlayerDesafios(player, 81, 01)
293 elseif rareGun == 01 then
294 onPlayerDesafios(player, 82, 01)
295 elseif rareGun == 02 then
296 onPlayerDesafios(player, 83, 01)
297 elseif rareGun == 03 then
298 onPlayerDesafios(player, 84, 01)
299 elseif rareGun == 04 then
300 onPlayerDesafios(player, 85, 01)
301 end
302 end
303 end
304 if player:getStorageValue(_QUESTLOG[073].UID_01) == 03 then
305 if target == 00 then
306 player:setStorageValue(_QUESTLOG[73].UID_01, 100)
307 player:setStorageValue(_QUESTLOG[74].UID_01, 01)
308
309 addEvent(function()
310 player:addExperience(2000, true, true)
311 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
312 player:getPosition():sendMagicEffect(14)
313 player:sendCancelMessage("@LoadQuestWindows")
314 end, 3 * 1000)
315 else
316 player:setStorageValue(_QUESTLOG[73].UID_01, 100)
317 player:setStorageValue(_QUESTLOG[74].UID_01, 01)
318
319 addEvent(function()
320 player:addExperience(2000, true, true)
321 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
322 player:getPosition():sendMagicEffect(14)
323 player:sendCancelMessage("@LoadQuestWindows")
324 end, 3 * 1000)
325 end
326
327 player:sendCancelMessage("@LoadQuestWindows")
328 end
329 if player:getStorageValue(_QUESTLOG[074].UID_01) == 01 then
330 if target == 00 then
331 if player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05) == 05 then
332 player:setStorageValue(_QUESTLOG[74].UID_01, 100)
333 --player:setStorageValue(_QUESTLOG[75].UID_01, 01)
334
335 addEvent(function()
336 player:addExperience(10000, true, true)
337 PlayerGoldCoins(player, 02, 2000)
338 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
339 player:getPosition():sendMagicEffect(14)
340 player:sendCancelMessage("@LoadQuestWindows")
341 end, 3 * 1000)
342 end
343 else
344 if player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05) == 05 then
345 player:setStorageValue(_QUESTLOG[74].UID_01, 100)
346 --player:setStorageValue(_QUESTLOG[75].UID_01, 01)
347
348 addEvent(function()
349 player:addExperience(10000, true, true)
350 PlayerGoldCoins(player, 02, 2000)
351 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
352 player:getPosition():sendMagicEffect(14)
353 player:sendCancelMessage("@LoadQuestWindows")
354 end, 3 * 1000)
355 end
356 end
357
358 player:sendCancelMessage("@LoadQuestWindows")
359 end
360 if player:getStorageValue(_QUESTLOG[100].UID_01) == 01 then
361 if target == 00 then
362 if SLOT_ID == 01 then
363 if player:getStorageValue(_SYSTEM.INVENTARIO[SLOT_ID].UID_05) > 0 then
364 player:setStorageValue(_QUESTLOG[100].UID_01, 100)
365 player:setStorageValue(_QUESTLOG[101].UID_01, 01)
366 --player:setStorageValue(_QUESTLOG[102].UID_01, 01)
367
368 addEvent(function()
369 player:addExperience(20000, true, true)
370 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
371 player:getPosition():sendMagicEffect(14)
372 player:sendCancelMessage("@LoadQuestWindows")
373 end, 4000)
374 end
375 end
376 else
377 if SLOT_ID == 01 then
378 if player:getStorageValue(_BACKPACK[SLOT_ID][EXT_ID][BAG_ID].UID_05) > 0 then
379 player:setStorageValue(_QUESTLOG[100].UID_01, 100)
380 player:setStorageValue(_QUESTLOG[101].UID_01, 01)
381 --player:setStorageValue(_QUESTLOG[102].UID_01, 01)
382
383 addEvent(function()
384 player:addExperience(20000, true, true)
385 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
386 player:getPosition():sendMagicEffect(14)
387 player:sendCancelMessage("@LoadQuestWindows")
388 end, 4000)
389 end
390 end
391 end
392
393 player:sendCancelMessage("@LoadQuestWindows")
394 end
395 player:popupFYI("Tentativa de upgrade com " ..rateSucess.. "% de chance de sucesso.\n\nItem aprimorado com sucesso.")
396 end
397
398 player:sendCancelMessage("@AceptUpgrade")
399 if target == 00 then
400 doInventario(player, 00, SLOT_ID, EXT_ID)
401 else
402 doBackpack(player, 00, SLOT_ID, EXT_ID, 01)
403 end
404 if player:getStorageValue(_QUESTLOG[30].UID_01) == 2 then
405 player:setStorageValue(_QUESTLOG[30].UID_01, 03)
406
407 player:getPosition():sendMagicEffect(14)
408 player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
409 end
410 player:sendCancelMessage("@ReloadBackpack " ..SLOT_ID.. " 01")
411
412 doBackpack(player, 11)
413 player:sendCancelMessage("@LoadTooltipInv")
414 else
415 player:sendCancelMessage("@AceptUpgrade")
416
417 player:sendCancelMessage("@ReloadBackpack " ..SLOT_ID.. " 01")
418
419 doBackpack(player, 11)
420 player:sendCancelMessage("@LoadTooltipInv")
421 end
422 else
423
424 end
425 end
426
427 return false
428end
429