defense.lua

main 807 lines · 32.4 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1local PASSIVE_LEVEL = 00
2local COMBAT_TYPES = {
3 [COMBAT_ENERGYDAMAGE] = COMBAT_ENERGYDAMAGE,
4 [COMBAT_EARTHDAMAGE] = COMBAT_EARTHDAMAGE,
5 [COMBAT_FIREDAMAGE] = COMBAT_FIREDAMAGE,
6 [COMBAT_ICEDAMAGE] = COMBAT_ICEDAMAGE,
7 [COMBAT_HOLYDAMAGE] = COMBAT_HOLYDAMAGE,
8 [COMBAT_DEATHDAMAGE] = COMBAT_DEATHDAMAGE
9}
10local function isWalkable(item)
11 if item then
12 if item.uid > 0 and item.uid <= 65535 then
13 return false
14 end
15 end
16 return true
17end
18local function onGetPassivas(player, id)
19 if player:getStorageValue(_SYSTEM.POINTS_ATR[01]) == id then
20 PASSIVE_LEVEL = player:getStorageValue(_SYSTEM.POINTS_ATR[08])
21 return true
22 elseif player:getStorageValue(_SYSTEM.POINTS_ATR[02]) == id then
23 PASSIVE_LEVEL = player:getStorageValue(_SYSTEM.POINTS_ATR[09])
24 return true
25 elseif player:getStorageValue(_SYSTEM.POINTS_ATR[03]) == id then
26 PASSIVE_LEVEL = player:getStorageValue(_SYSTEM.POINTS_ATR[10])
27 return true
28 elseif player:getStorageValue(_SYSTEM.POINTS_ATR[04]) == id then
29 PASSIVE_LEVEL = player:getStorageValue(_SYSTEM.POINTS_ATR[11])
30 return true
31 elseif player:getStorageValue(_SYSTEM.POINTS_ATR[05]) == id then
32 PASSIVE_LEVEL = player:getStorageValue(_SYSTEM.POINTS_ATR[12])
33 return true
34 elseif player:getStorageValue(_SYSTEM.POINTS_ATR[06]) == id then
35 PASSIVE_LEVEL = player:getStorageValue(_SYSTEM.POINTS_ATR[13])
36 return true
37 else
38 PASSIVE_LEVEL = 00
39 return false
40 end
41end
42function BombAround(cid, attacker, effect, combat)
43 local creature = Player(cid)
44 local min = creature:getLevel() / 3
45 local max = creature:getLevel() / 2
46
47 creature:setStorageValue(_PLAYER_INFO.DELAY, _PLAYER_INFO.SECONDS_DELAY)
48 local POS = creature:getPosition()
49 local POS1 = Position(POS.x, POS.y + 1, POS.z)
50 POS1:sendMagicEffect(effect)
51 local tile_1 = Tile(POS.x, POS.y + 1, POS.z)
52 if tile_1 then
53 if isWalkable(tile_1.uid) then
54 local Target_1 = tile_1:getTopCreature()
55 if Target_1 then
56 if Target_1:isPlayer() then
57 if creature:hasSecureMode() == true or Tile(Target_1:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
58 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_1:getStorageValue(_PVP_ROOM[00].TIME_ID) then
59
60 else
61 doTargetCombat(creature, Target_1, combat, -min, -max, effect)
62 end
63 else
64 doTargetCombat(creature, Target_1, combat, -min, -max, effect)
65 end
66 end
67 end
68 end
69
70 local POS2 = Position(POS.x - 1, POS.y + 1, POS.z)
71 POS2:sendMagicEffect(effect)
72 local tile_2 = Tile(POS.x - 1, POS.y + 1, POS.z)
73 if tile_2 then
74 if isWalkable(tile_2.uid) then
75 local Target_2 = tile_2:getTopCreature()
76 if Target_2 then
77 if Target_2:isPlayer() then
78 if creature:hasSecureMode() == true or Tile(Target_2:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
79 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_2:getStorageValue(_PVP_ROOM[00].TIME_ID) then
80
81 else
82 doTargetCombat(creature, Target_2, combat, -min, -max, effect)
83 end
84 else
85 doTargetCombat(creature, Target_2, combat, -min, -max, effect)
86 end
87 end
88 end
89 end
90
91 local POS3 = Position(POS.x - 1, POS.y, POS.z)
92 POS3:sendMagicEffect(effect)
93 local tile_3 = Tile(POS.x - 1, POS.y, POS.z)
94 if tile_3 then
95 if isWalkable(tile_3.uid) then
96 local Target_3 = tile_3:getTopCreature()
97 if Target_3 then
98 if Target_3:isPlayer() then
99 if creature:hasSecureMode() == true or Tile(Target_3:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
100 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_3:getStorageValue(_PVP_ROOM[00].TIME_ID) then
101
102 else
103 doTargetCombat(creature, Target_3, combat, -min, -max, effect)
104 end
105 else
106 doTargetCombat(creature, Target_3, combat, -min, -max, effect)
107 end
108 end
109 end
110 end
111
112 local POS4 = Position(POS.x - 1, POS.y - 1, POS.z)
113 POS4:sendMagicEffect(effect)
114 local tile_4 = Tile(POS.x - 1, POS.y - 1, POS.z)
115 if tile_4 then
116 if isWalkable(tile_4.uid) then
117 local Target_4 = tile_4:getTopCreature()
118 if Target_4 then
119 if Target_4:isPlayer() then
120 if creature:hasSecureMode() == true or Tile(Target_4:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
121 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_4:getStorageValue(_PVP_ROOM[00].TIME_ID) then
122
123 else
124 doTargetCombat(creature, Target_4, combat, -min, -max, effect)
125 end
126 else
127 doTargetCombat(creature, Target_4, combat, -min, -max, effect)
128 end
129 end
130 end
131 end
132
133 local POS5 = Position(POS.x, POS.y - 1, POS.z)
134 POS5:sendMagicEffect(effect)
135 local tile_5 = Tile(POS.x, POS.y - 1, POS.z)
136 if tile_5 then
137 if isWalkable(tile_5.uid) then
138 local Target_5 = tile_5:getTopCreature()
139 if Target_5 then
140 if Target_5:isPlayer() then
141 if creature:hasSecureMode() == true or Tile(Target_5:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
142 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_5:getStorageValue(_PVP_ROOM[00].TIME_ID) then
143
144 else
145 doTargetCombat(creature, Target_5, combat, -min, -max, effect)
146 end
147 else
148 doTargetCombat(creature, Target_5, combat, -min, -max, effect)
149 end
150 end
151 end
152 end
153
154 local POS6 = Position(POS.x + 1, POS.y - 1, POS.z)
155 POS6:sendMagicEffect(effect)
156 local tile_6 = Tile(POS.x + 1, POS.y - 1, POS.z)
157 if tile_6 then
158 if isWalkable(tile_6.uid) then
159 local Target_6 = tile_6:getTopCreature()
160 if Target_6 then
161 if Target_6:isPlayer() then
162 if creature:hasSecureMode() == true or Tile(Target_6:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
163 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_6:getStorageValue(_PVP_ROOM[00].TIME_ID) then
164
165 else
166 doTargetCombat(creature, Target_6, combat, -min, -max, effect)
167 end
168 else
169 doTargetCombat(creature, Target_6, combat, -min, -max, effect)
170 end
171 end
172 end
173 end
174
175 local POS7 = Position(POS.x + 1, POS.y, POS.z)
176 POS7:sendMagicEffect(effect)
177 local tile_7 = Tile(POS.x + 1, POS.y, POS.z)
178 if tile_7 then
179 if isWalkable(tile_7.uid) then
180 local Target_7 = tile_7:getTopCreature()
181 if Target_7 then
182 if Target_7:isPlayer() then
183 if creature:hasSecureMode() == true or Tile(Target_7:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
184 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_7:getStorageValue(_PVP_ROOM[00].TIME_ID) then
185
186 else
187 doTargetCombat(creature, Target_7, combat, -min, -max, effect)
188 end
189 else
190 doTargetCombat(creature, Target_7, combat, -min, -max, effect)
191 end
192 end
193 end
194 end
195
196 local POS8 = Position(POS.x + 1, POS.y + 1, POS.z)
197 POS8:sendMagicEffect(effect)
198 local tile_8 = Tile(POS.x + 1, POS.y + 1, POS.z)
199 if tile_8 then
200 if isWalkable(tile_8.uid) then
201 local Target_8 = tile_8:getTopCreature()
202 if Target_8 then
203 if Target_8:isPlayer() then
204 if creature:hasSecureMode() == true or Tile(Target_8:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
205 or creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) > 00 and creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == Target_8:getStorageValue(_PVP_ROOM[00].TIME_ID) then
206
207 else
208 doTargetCombat(creature, Target_8, combat, -min, -max, effect)
209 end
210 else
211 doTargetCombat(creature, Target_8, combat, -min, -max, effect)
212 end
213 end
214 end
215 end
216end
217function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
218 if _CHEATS.IMORTAL_MODE then
219 creature:getPosition():sendMagicEffect(03)
220 return false
221 end
222 if creature:getStorageValue(_SYSTEM.MAESTRIA[01]) == 02 then
223 if creature:getStorageValue(_SYSTEM.MAESTRIA[04]) > 0 then
224 if primaryType ~= 128 then
225 if creature:isPlayer() then
226 --local position = Position(creature:getPosition().x + 1, creature:getPosition().y + 1, creature:getPosition().z)
227 creature:getPosition():sendMagicEffect(195)
228 return false
229 end
230 end
231 end
232 end
233 if creature:isPlayer() then
234 if primaryType ~= 128 then -- Ignore health potions
235 local DEF = creature:getStorageValue(_PLAYER_INFO.DEF) or 0
236 local ESQ = creature:getStorageValue(_PLAYER_INFO.ESQ) or 0
237 local FIRE = creature:getStorageValue(_PLAYER_INFO.FIRE) or 0
238 local ICE = creature:getStorageValue(_PLAYER_INFO.ICE) or 0
239 local ENERGY = creature:getStorageValue(_PLAYER_INFO.ENERGY) or 0
240 local EARTH = creature:getStorageValue(_PLAYER_INFO.EARTH) or 0
241 local DEATH = creature:getStorageValue(_PLAYER_INFO.DEATH) or 0
242 local ResPlayer = creature:getStorageValue(_PLAYER_INFO.RES_PLAYER) or 0
243 local ExtraDef = creature:getStorageValue(_PLAYER_INFO.EXTRA_DEF) or 0
244 local ExtraESQ = creature:getStorageValue(_PLAYER_INFO.EXTRA_ESQ) or 0
245 local ExtraMAG = creature:getStorageValue(_PLAYER_INFO.EXTRA_MAG) or 0
246 local CuraESQ = creature:getStorageValue(_PLAYER_INFO.CURA_ESQ) or 0
247 local FearPara = creature:getStorageValue(_PLAYER_INFO.FEAR_PARA) or 0
248 local BombFire = creature:getStorageValue(_PLAYER_INFO.BOMB_FIRE) or 0
249 local BombEnergy = creature:getStorageValue(_PLAYER_INFO.BOMB_ENERGY) or 0
250 local BombIce = creature:getStorageValue(_PLAYER_INFO.BOMB_ICE) or 0
251 local BombEarth = creature:getStorageValue(_PLAYER_INFO.BOMB_EARTH) or 0
252 local BombDeath = creature:getStorageValue(_PLAYER_INFO.BOMB_DEATH) or 0
253 local BombHoly = creature:getStorageValue(_PLAYER_INFO.BOMB_HOLY) or 0
254 local BombPhysical = creature:getStorageValue(_PLAYER_INFO.BOMB_PHYSICAL) or 0
255 local CancelInv = creature:getStorageValue(_PLAYER_INFO.CANCEL_INV) or 0
256 local CanPara = creature:getStorageValue(_PLAYER_INFO.CAN_PARA) or 0
257 local DmgHalf = creature:getStorageValue(_PLAYER_INFO.DMG_HALF) or 0
258 local ProtectPercent = 0
259
260 if onGetPassivas(creature, 62) then
261 local HP_HIGH = 70 * (creature:getBaseMaxHealth() / 100)
262 if creature:getHealth() > HP_HIGH then
263 local Percent = _PASSIVES[62].POWER_BASE + (_PASSIVES[62].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
264 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
265 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[62].CATEGORY then
266 Percent = Percent + _PASSIVES[62].BOOST
267 end
268 end
269 DEF = DEF + Percent
270 end
271 end
272 if onGetPassivas(creature, 50) then
273 local HP_HIGH = 70 * (creature:getBaseMaxHealth() / 100)
274 if creature:getHealth() > HP_HIGH then
275 local Percent = _PASSIVES[50].POWER_BASE + (_PASSIVES[50].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
276 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
277 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[50].CATEGORY then
278 Percent = Percent + _PASSIVES[50].BOOST
279 end
280 end
281 ESQ = ESQ + Percent
282 end
283 end
284 if creature:getStorageValue(_SYSTEM.PASSIVA[01]) > 00 then
285 if onGetPassivas(creature, 09) then
286 local Percent = _PASSIVES[09].POWER_BASE + (_PASSIVES[09].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
287 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
288 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[09].CATEGORY then
289 Percent = Percent + _PASSIVES[09].BOOST
290 end
291 end
292 ESQ = ESQ + Percent
293 end
294 end
295 if creature:getStorageValue(_SYSTEM.PASSIVA[02]) > 00 then
296 if onGetPassivas(creature, 19) then
297 local Percent = _PASSIVES[19].POWER_BASE + (_PASSIVES[19].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
298 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
299 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[19].CATEGORY then
300 Percent = Percent + _PASSIVES[19].BOOST
301 end
302 end
303 DEF = DEF + Percent
304 end
305 end
306 if creature:getStorageValue(_PLAYER_INFO.DELAY) <= 0 then
307 if BombFire > 0 then
308 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
309 if attacker then
310 if math.random(00, 150) <= BombFire then
311 BombAround(creature, attacker, 16, COMBAT_FIREDAMAGE)
312 end
313 end
314 end
315 end
316 if BombEnergy > 0 then
317 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
318 if attacker then
319 if math.random(00, 150) <= BombEnergy then
320 BombAround(creature, attacker, 12, COMBAT_ENERGYDAMAGE)
321 end
322 end
323 end
324 end
325 if BombIce > 0 then
326 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
327 if attacker then
328 if math.random(00, 150) <= BombIce then
329 BombAround(creature, attacker, 43, COMBAT_ICEDAMAGE)
330 end
331 end
332 end
333 end
334 if BombDeath > 0 then
335 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
336 if attacker then
337 if math.random(00, 150) <= BombDeath then
338 BombAround(creature, attacker, 18, COMBAT_DEATHDAMAGE)
339 end
340 end
341 end
342 end
343 if BombEarth > 0 then
344 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
345 if attacker then
346 if math.random(00, 150) <= BombEarth then
347 BombAround(creature, attacker, 46, COMBAT_EARTHDAMAGE)
348 end
349 end
350 end
351 end
352 if BombHoly > 0 then
353 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
354 if attacker then
355 if math.random(00, 150) <= BombHoly then
356 BombAround(creature, attacker, 40, COMBAT_HOLYDAMAGE)
357 end
358 end
359 end
360 end
361 if BombPhysical > 0 then
362 if not Tile(creature:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
363 if attacker then
364 if math.random(00, 150) <= BombPhysical then
365 BombAround(creature, attacker, 10, COMBAT_PHYSICALDAMAGE)
366 end
367 end
368 end
369 end
370 if CanPara > 0 then
371 if creature:getCondition(CONDITION_PARALYZE) then
372 creature:setStorageValue(_PLAYER_INFO.DELAY, _PLAYER_INFO.SECONDS_DELAY)
373 creature:removeCondition(CONDITION_PARALYZE)
374 end
375 end
376 if CancelInv > 0 then
377 if attacker then
378 if attacker:getCondition(CONDITION_INVISIBLE) then
379 creature:setStorageValue(_PLAYER_INFO.DELAY, _PLAYER_INFO.SECONDS_DELAY)
380 attacker:removeCondition(CONDITION_INVISIBLE)
381 end
382 end
383 end
384 end
385
386 local cid = creature:getId()
387 if _BONUS_EXTRA_TABLE[cid] then
388 local ID_BONUS = 32
389 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
390 DEF = DEF + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
391 end
392 ID_BONUS = 34
393 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
394 FIRE = FIRE + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
395 end
396 ID_BONUS = 35
397 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
398 ICE = ICE + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
399 end
400 ID_BONUS = 36
401 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
402 EARTH = EARTH + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
403 end
404 ID_BONUS = 37
405 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
406 ENERGY = ENERGY + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
407 end
408 ID_BONUS = 38
409 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
410 DEATH = DEATH + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
411 end
412 ID_BONUS = 44
413 if _BONUS_EXTRA_TABLE[cid][ID_BONUS] > 00 then
414 ESQ = ESQ + _BONUS_EXTRA_TABLE[cid][ID_BONUS]
415 end
416 end
417
418 -- POWER MONSTER DG
419 if attacker then
420 if attacker:isMonster() then
421 if attacker:getStorageValue(29937) > 00 then
422 primaryDamage = primaryDamage * attacker:getStorageValue(29937)
423 end
424 end
425 end
426 -- POWER PLAYER VS PLAYER
427 if attacker then
428 if attacker:isPlayer() then
429 DEF = 00
430 ESQ = ESQ / 02
431 end
432 end
433 -- CALCULANDO ESQUIVA
434 local chanceESQ = math.random(1, 1000)
435 if chanceESQ <= ESQ and primaryDamage > 0 and primaryType == 1 and creature:getStorageValue(_PLAYER_INFO.DELAY) <= 0 then
436 if attacker then
437 creature:getPosition():sendMagicEffect(4)
438 creature:say("MISS", TALKTYPE_MONSTER_SAY)
439 creature:setStorageValue(_SYSTEM.ATR_VALUES[01], 01)
440 creature:setStorageValue(_PLAYER_INFO.DELAY, _PLAYER_INFO.SECONDS_DELAY)
441
442 if CuraESQ > 0 then
443 local HPCrit = math.floor(CuraESQ * (creature:getBaseMaxHealth() / 100))
444 doTargetCombat(0, creature, COMBAT_HEALING, HPCrit, HPCrit)
445 end
446 return false
447 end
448 else
449 if attacker then
450 if attacker:isMonster() then
451 local master = attacker:getMaster()
452 if master and master:isPlayer() then
453 return false
454 end
455 end
456 end
457 -- ABSORVENDO DANO PHYSICAL
458 if primaryType == 1 then
459 if attacker then
460 if attacker:isPlayer() then
461 if creature:getStorageValue(_SYSTEM.POINTS_ATR[04]) > 0 then
462 ResPlayer = ResPlayer + math.floor(creature:getStorageValue(_SYSTEM.POINTS_ATR[04]) / 5)
463 end
464 if primaryDamage <= ResPlayer then
465 primaryDamage = 0
466 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
467 else
468 primaryDamage = primaryDamage - ResPlayer
469 end
470 end
471 end
472 if primaryDamage <= DEF then
473 primaryDamage = 0
474 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
475 else
476 -- Passiva Menor Dano [Monster Classe] & Refletir
477 if attacker then
478 if attacker:isMonster() then
479 if onGetPassivas(creature, 03) then
480 local Percent = _PASSIVES[03].POWER_BASE + (_PASSIVES[03].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
481 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
482 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[03].CATEGORY then
483 Percent = Percent + _PASSIVES[03].BOOST
484 end
485 end
486 local Reflect = math.floor(Percent * (primaryDamage / 100))
487 if Reflect < 01 then Reflect = 01 end
488 doTargetCombat(creature, attacker, 01, -Reflect, -Reflect, 01)
489 end
490 if _MONSTER_LOOT[attacker:getName()] then
491 if _MONSTER_LOOT[attacker:getName()][00].Type == "Constructos" then
492 local PID = 18
493 if onGetPassivas(creature, PID) then
494 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
495 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
496 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
497 Percent = Percent + _PASSIVES[PID].BOOST
498 end
499 end
500 ProtectPercent = ProtectPercent + Percent
501 end
502 end
503 if _MONSTER_LOOT[attacker:getName()][00].Type == "Dimensionais" then
504 local PID = 47
505 if onGetPassivas(creature, PID) then
506 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
507 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
508 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
509 Percent = Percent + _PASSIVES[PID].BOOST
510 end
511 end
512 ProtectPercent = ProtectPercent + Percent
513 end
514 end
515 if _MONSTER_LOOT[attacker:getName()][00].Type == "Gigantes" then
516 local PID = 33
517 if onGetPassivas(creature, PID) then
518 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
519 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
520 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
521 Percent = Percent + _PASSIVES[PID].BOOST
522 end
523 end
524 ProtectPercent = ProtectPercent + Percent
525 end
526 end
527 if _MONSTER_LOOT[attacker:getName()][00].Type == "Dragon" then
528 local PID = 34
529 if onGetPassivas(creature, PID) then
530 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
531 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
532 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
533 Percent = Percent + _PASSIVES[PID].BOOST
534 end
535 end
536 ProtectPercent = ProtectPercent + Percent
537 end
538 end
539 if _MONSTER_LOOT[attacker:getName()][00].Type == "Demon" then
540 local PID = 15
541 if onGetPassivas(creature, PID) then
542 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
543 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
544 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
545 Percent = Percent + _PASSIVES[PID].BOOST
546 end
547 end
548 ProtectPercent = ProtectPercent + Percent
549 end
550 end
551 if _MONSTER_LOOT[attacker:getName()][00].Type == "Humanoide" then
552 local PID = 06
553 if onGetPassivas(creature, PID) then
554 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
555 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
556 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
557 Percent = Percent + _PASSIVES[PID].BOOST
558 end
559 end
560 ProtectPercent = ProtectPercent + Percent
561 end
562 end
563 if _MONSTER_LOOT[attacker:getName()][00].Type == "Magica" then
564 local PID = 27
565 if onGetPassivas(creature, PID) then
566 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
567 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
568 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
569 Percent = Percent + _PASSIVES[PID].BOOST
570 end
571 end
572 ProtectPercent = ProtectPercent + Percent
573 end
574 end
575 if _MONSTER_LOOT[attacker:getName()][00].Type == "Repteis" then
576 local PID = 36
577 if onGetPassivas(creature, PID) then
578 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
579 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
580 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
581 Percent = Percent + _PASSIVES[PID].BOOST
582 end
583 end
584 ProtectPercent = ProtectPercent + Percent
585 end
586 end
587 if _MONSTER_LOOT[attacker:getName()][00].Type == "Vermes" then
588 local PID = 21
589 if onGetPassivas(creature, PID) then
590 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
591 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
592 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
593 Percent = Percent + _PASSIVES[PID].BOOST
594 end
595 end
596 ProtectPercent = ProtectPercent + Percent
597 end
598 end
599 if _MONSTER_LOOT[attacker:getName()][00].Type == "Boss" then
600 local PID = 43
601 if onGetPassivas(creature, PID) then
602 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
603 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
604 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
605 Percent = Percent + _PASSIVES[PID].BOOST
606 end
607 end
608 ProtectPercent = ProtectPercent + Percent
609 end
610 end
611 if _MONSTER_LOOT[attacker:getName()][00].Type == "Aquaticos" then
612 local PID = 14
613 if onGetPassivas(creature, PID) then
614 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
615 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
616 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
617 Percent = Percent + _PASSIVES[PID].BOOST
618 end
619 end
620 ProtectPercent = ProtectPercent + Percent
621 end
622 end
623 if _MONSTER_LOOT[attacker:getName()][00].Type == "Morto-Vivo" then
624 local PID = 28
625 if onGetPassivas(creature, PID) then
626 local Percent = _PASSIVES[PID].POWER_BASE + (_PASSIVES[PID].POWER_FOR_LEVEL * (PASSIVE_LEVEL - 01))
627 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 02 then -- PASSIVA DAS CORES
628 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.PASSIVE) == _PASSIVES[PID].CATEGORY then
629 Percent = Percent + _PASSIVES[PID].BOOST
630 end
631 end
632 ProtectPercent = ProtectPercent + Percent
633 end
634 end
635 end
636 end
637 end
638 -- ATR: Paralizia do Medo (12)
639 if FearPara > 0 then
640 if attacker then
641 local CriticalHealth = 80 * (creature:getBaseMaxHealth() / 100)
642 if creature:getHealth() <= CriticalHealth then
643 local ChanceParalyze = math.random(00, 100)
644 if ChanceParalyze <= FearPara then
645 local condition = Condition(CONDITION_PARALYZE)
646 condition:setParameter(CONDITION_PARAM_TICKS, 10000)
647 condition:setFormula(-5, 100, -5, 150)
648 attacker:addCondition(condition)
649 attacker:getPosition():sendMagicEffect(11)
650 end
651 end
652 end
653 end
654 -- Amuletos
655 if creature:getStorageValue(_SYSTEM.INVENTARIO[01].UID_01) > 0 and creature:getStorageValue(_PLAYER_INFO.DELAY) <= 0 then
656 if creature:getStorageValue(_SYSTEM.AMULET_VALUES[00][01]) < 1 then
657 local AmuletID = creature:getStorageValue(_SYSTEM.INVENTARIO[01].UID_01)
658 local Effect = _SYSTEM.AMULET_VALUES[AmuletID]
659 local RareAmulet = creature:getStorageValue(_SYSTEM.INVENTARIO[01].UID_02)
660 local StarAmulet = creature:getStorageValue(_SYSTEM.INVENTARIO[01].UID_03)
661 local LevelAmulet = creature:getStorageValue(_SYSTEM.INVENTARIO[01].UID_05)
662 local BUFF_TIME = 0
663 local ChanceRandom = math.random(200)
664 if RareAmulet < 0 then RareAmulet = 0 end
665 if StarAmulet < 0 then StarAmulet = 0 end
666 if LevelAmulet < 0 then LevelAmulet = 0 end
667
668 if creature:getStorageValue(_SYSTEM.MAESTRIA[01]) == 05 then
669 if creature:getStorageValue(_SYSTEM.MAESTRIA[04]) > 0 then
670 ChanceRandom = 00
671 end
672 end
673 if ChanceRandom <= _AMULET_CHANCE_MODE[RareAmulet] then
674 local Timer_Left = (LevelAmulet + (StarAmulet * 10) + 5)
675 if Effect ~= 10 then
676 if Effect == 01 then
677 local CritValue = creature:getStorageValue(_SYSTEM.CRITICAL_VALUES[02])
678 if CritValue < 0 then CritValue = 0 end
679 creature:setStorageValue(_SYSTEM.CRITICAL_VALUES[02], (CritValue + 05))
680 elseif Effect == 04 then
681 local CritValue = creature:getStorageValue(_SYSTEM.CRITICAL_VALUES[01])
682 if CritValue < 0 then CritValue = 0 end
683 creature:setStorageValue(_SYSTEM.CRITICAL_VALUES[01], (CritValue + 50))
684 elseif Effect == 05 or Effect == 06 or Effect == 08 then
685 creature:setStorageValue(_SYSTEM.AMULET_VALUES[00][03], 25)
686 elseif Effect == 07 then
687 creature:setStorageValue(_SYSTEM.AMULET_VALUES[00][03], 15)
688 elseif Effect == 09 then
689 local condition = Condition(CONDITION_INVISIBLE)
690 condition:setParameter(CONDITION_PARAM_TICKS, (Timer_Left + StarAmulet) * 1000)
691 creature:addCondition(condition)
692 elseif Effect == 17 then
693 creature:setStorageValue(_SYSTEM.AMULET_VALUES[00][03], 30)
694 elseif Effect == 18 or Effect == 19 or Effect == 20 or Effect == 21 or Effect == 22 then
695 creature:setStorageValue(_SYSTEM.AMULET_VALUES[00][03], 20)
696 end
697
698 -- DESAFIO
699 if creature:getStorageValue(_DESAFIOS[00].DESAFIO_ID) > 00 then
700 onPlayerDesafios(creature, 20, 01)
701 end
702 creature:getPosition():sendMagicEffect(13)
703 creature:setStorageValue(_PLAYER_INFO.DELAY, _PLAYER_INFO.SECONDS_DELAY)
704 creature:setStorageValue(_SYSTEM.AMULET_VALUES[00][02], Effect)
705 creature:setStorageValue(_SYSTEM.AMULET_VALUES[00][01], Timer_Left)
706 if creature:getStorageValue(_QUESTLOG[101].UID_01) == 01 then
707 if creature:getStorageValue(10919) == 04 then
708 creature:setStorageValue(_QUESTLOG[101].UID_01, 100)
709 creature:setStorageValue(10919, nil)
710 creature:sendCancelMessage("@LoadQuestWindows")
711
712 creature:addExperience(20000, true, true)
713 creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
714 else
715 if creature:getStorageValue(10919) < 00 then
716 creature:setStorageValue(10919, 01)
717 else
718 creature:setStorageValue(10919, (creature:getStorageValue(10919) + 01))
719 end
720 doBackpack(creature, 12)
721 end
722 end
723 end
724 end
725 end
726 end
727
728 if ProtectPercent > 00 then
729 local NewDmgProtect = math.floor(ProtectPercent * (primaryDamage / 100))
730 primaryDamage = primaryDamage - NewDmgProtect
731 end
732 primaryDamage = primaryDamage - DEF
733 -- ATR: Resistencia a Combate (14)
734 if DmgHalf > 0 then
735 if attacker then
736 if primaryDamage <= _ATRIBUTOS[14].PERCENT then
737 doTargetCombat(attacker, attacker, primaryType, -primaryDamage, -primaryDamage, 01)
738 end
739 end
740 end
741 end
742 end
743 if COMBAT_TYPES[primaryType] then
744 if COMBAT_TYPES[primaryType] == 08 then
745 local PercentFire = math.floor(FIRE * (primaryDamage / 100))
746 if FIRE >= primaryDamage then
747 primaryDamage = 0
748 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
749 elseif primaryDamage <= PercentFire then
750 primaryDamage = 0
751 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
752 else
753 primaryDamage = primaryDamage - PercentFire
754 end
755 elseif COMBAT_TYPES[primaryType] == 512 then
756 local PercentIce = math.floor(ICE * (primaryDamage / 100))
757 if ICE >= primaryDamage then
758 primaryDamage = 0
759 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
760 elseif primaryDamage <= PercentIce then
761 primaryDamage = 0
762 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
763 else
764 primaryDamage = primaryDamage - PercentIce
765 end
766 elseif COMBAT_TYPES[primaryType] == 02 then
767 local PercentEnergy = math.floor(ENERGY * (primaryDamage / 100))
768 if ENERGY >= primaryDamage then
769 primaryDamage = 0
770 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
771 elseif primaryDamage <= PercentEnergy then
772 primaryDamage = 0
773 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
774 else
775 primaryDamage = primaryDamage - PercentEnergy
776 end
777 elseif COMBAT_TYPES[primaryType] == 04 then
778 local PercentEarth = math.floor(EARTH * (primaryDamage / 100))
779 if EARTH >= primaryDamage then
780 primaryDamage = 0
781 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
782 elseif primaryDamage <= PercentEarth then
783 primaryDamage = 0
784 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
785 else
786 primaryDamage = primaryDamage - PercentEarth
787 end
788 elseif COMBAT_TYPES[primaryType] == 2048 then
789 local PercentDeath = math.floor(DEATH * (primaryDamage / 100))
790 if DEATH >= primaryDamage then
791 primaryDamage = 0
792 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
793 elseif primaryDamage <= PercentDeath then
794 primaryDamage = 0
795 creature:getPosition():sendMagicEffect(CONST_ME_POFF)
796 else
797 primaryDamage = primaryDamage - PercentDeath
798 end
799 end
800 end
801 end
802 end
803 end
804
805 return primaryDamage, primaryType, secondaryDamage, secondaryType, origin
806end
807
Top