Don't like ads? PRO users don't see any ads ;-)
Guest

exp.lua

By: a guest on Jul 6th, 2012  |  syntax: None  |  size: 39.24 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. local combats = {
  2.     [PSYCHICDAMAGE] = {cor = COLOR_PSYCHIC},
  3.     [GRASSDAMAGE] = {cor = COLOR_GRASS},
  4.     [POISONEDDAMAGE] = {cor = COLOR_GRASS},
  5.     [MORTALGASDAMAGE] = {cor = COLOR_POISON},
  6.     [FIREDAMAGE] = {cor = COLOR_FIRE2},
  7.     [BURNEDDAMAGE] = {cor = COLOR_BURN},
  8.     [WATERDAMAGE] = {cor = COLOR_WATER},
  9.     [ICEDAMAGE] = {cor = COLOR_ICE},
  10.     [NORMALDAMAGE] = {cor = COLOR_NORMAL},
  11.     [GUILLOTINEDAMAGE] = {cor = COLOR_NORMAL},
  12.     [FLYDAMAGE] = {cor = COLOR_FLYING},
  13.     [GHOSTDAMAGE] = {cor = COLOR_GHOST},
  14.     [NIGHTMAREDAMAGE] = {cor = COLOR_GHOST},
  15.     [GROUNDDAMAGE] = {cor = COLOR_GROUND},
  16.     [ELECTRICDAMAGE] = {cor = COLOR_ELECTRIC},
  17.     [THUNDERWAVEDAMAGE] = {cor = COLOR_ELECTRIC},
  18.     [ROCKDAMAGE] = {cor = COLOR_ROCK},
  19.     [BUGDAMAGE] = {cor = COLOR_BUG},
  20.     [FIGHTDAMAGE] = {cor = COLOR_FIGHTING},
  21.     [SEISMICTOSSDAMAGE] = {cor = COLOR_FIGHTING},
  22.     [DRAGONDAMAGE] = {cor = COLOR_DRAGON},
  23.     [POISONDAMAGE] = {cor = COLOR_POISON},
  24.     [DARKDAMAGE] = {cor = COLOR_DARK},
  25.     [STEELDAMAGE] = {cor = COLOR_STEEL},
  26.     }
  27.      
  28.     local function doHeal(cid, amount)
  29.     doCreatureAddHealth(cid, amount)
  30.     doSendMagicEffect(getThingPos(cid), 12)
  31.     doSendAnimatedText(getThingPos(cid), "+"..amount.."", 65)
  32.     end
  33.      
  34.     local function sendPlayerDmgMsg(cid, text)
  35.     if not isCreature(cid) then return true end
  36.     doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, text)
  37.     end
  38.      
  39.     local spcevo = {
  40.     ["Poliwhirl"] = {"Poliwrath", "Politoed"},
  41.     ["Gloom"] = {"Bellossom", "Vileplume"},
  42.     ["Tyrogue"] = {"Hitmonchan", "Hitmontop", "Hitmonlee"}}
  43.      
  44.     local function doEvolveWild(cid)
  45.     if not isCreature(cid) or getCreatureHealth(cid) <= 0 then return true end
  46.     local name = getCreatureName(cid)
  47.     local evolution = "none"
  48.     if spcevo[name] then
  49.     evolution = spcevo[name][math.random(1, #spcevo[name])]
  50.     elseif poevo[name] then
  51.     evolution = poevo[name].evolution
  52.     end
  53.     local a = getPokemonStatus(name)
  54.     if not a or evolution == "none" then return true end
  55.     local pk = {}
  56.     local players = getSpectators(getThingPos(cid), 7, 7)
  57.     if players then
  58.     for pp = 1, #players do
  59.     local this = players[pp]
  60.     if isCreature(this) and isPlayer(this) and (getCreatureTarget(this) == cid or getDamageMapPercent(this, cid) > 0) then
  61.     doSendMagicEffect(getThingPos(this), 173)
  62.     local expstring = cid.."expEx"
  63.     pk[this] = getItemAttribute(getPlayerSlotItem(this, 8).uid, expstring)
  64.     doItemSetAttribute(getPlayerSlotItem(this, 8).uid, expstring, 0)
  65.     end
  66.     end
  67.     end
  68.     local level = getPokemonLevel(cid)
  69.     local pos = getThingPos(cid)
  70.     local gender = getCreatureSkull(cid)
  71.     local lifepercentage = 1 - ((getCreatureHealth(cid) * 1.3) / getCreatureMaxHealth(cid))
  72.     local lookdir = getCreatureLookDir(cid)
  73.     local status = {}
  74.     status.offense = getOffense(cid) + a.off * 8
  75.     status.defense = getDefense(cid) + a.def * 8
  76.     status.agi = getSpeed(cid) + a.agi * 8
  77.     status.spatk = getSpecialAttack(cid) + a.spatk * 8
  78.     status.vit = getVitality(cid) + a.vit * 4
  79.     doRemoveCreature(cid)
  80.     local evo = doCreateMonster(evolution, pos)
  81.     setWildPokemonLevel(evo, level, status)
  82.     doCreatureSetLookDir(evo, lookdir)
  83.     doCreatureSetSkullType(evo, gender)
  84.     doCreatureAddHealth(evo, -getCreatureMaxHealth(evo) * lifepercentage)
  85.     doSendMagicEffect(getThingPos(evo), 18)
  86.     for attacker, experience in pairs (pk) do
  87.     doWildAttackPlayer(evo, attacker)
  88.     local expstring = evo.."expEx"
  89.     local exp = experience or 0
  90.     doItemSetAttribute(getPlayerSlotItem(attacker, 8).uid, expstring, exp)
  91.     end
  92.     sendFinishEvolutionEffect(evo, true)
  93.     addEvent(sendFinishEvolutionEffect, 550, evo, true)
  94.     addEvent(sendFinishEvolutionEffect, 1050, evo)
  95.     end
  96.      
  97.     local races = {
  98.     [4] = {cor = COLOR_FIRE2},
  99.     [6] = {cor = COLOR_WATER},
  100.     [7] = {cor = COLOR_NORMAL},
  101.     [8] = {cor = COLOR_FIRE2},
  102.     [9] = {cor = COLOR_FIGHTING},
  103.     [10] = {cor = COLOR_FLYING},
  104.     [11] = {cor = COLOR_GRASS},
  105.     [12] = {cor = COLOR_POISON},
  106.     [13] = {cor = COLOR_ELECTRIC},
  107.     [14] = {cor = COLOR_GROUND},
  108.     [15] = {cor = COLOR_PSYCHIC},
  109.     [16] = {cor = COLOR_ROCK},
  110.     [17] = {cor = COLOR_ICE},
  111.     [18] = {cor = COLOR_BUG},
  112.     [19] = {cor = COLOR_DRAGON},
  113.     [20] = {cor = COLOR_GHOST},
  114.     [21] = {cor = COLOR_STEEL},
  115.     [22] = {cor = COLOR_DARK},
  116.     [1] = {cor = 180},
  117.     [2] = {cor = 180},
  118.     [3] = {cor = 180},
  119.     [5] = {cor = 180},
  120.     }
  121.      
  122.     local damages = {MORTALGASDAMAGE, GROUNDDAMAGE, ELECTRICDAMAGE, ROCKDAMAGE, FLYDAMAGE, BUGDAMAGE, FIGHTINGDAMAGE, DRAGONDAMAGE, POISONDAMAGE, DARKDAMAGE, STEELDAMAGE, NIGHTMAREDAMAGE, GUILLOTINEDAMAGE, SEISMICTOSSDAMAGE}
  123.     local fixdmgs = {PSYCHICDAMAGE, COMBAT_PHYSICALDAMAGE, GRASSDAMAGE, FIREDAMAGE, WATERDAMAGE, ICEDAMAGE, NORMALDAMAGE, GHOSTDAMAGE}
  124.     local ignored = {NIGHTMAREDAMAGE, GUILLOTINEDAMAGE, MORTALGASDAMAGE, SEISMICTOSSDAMAGE, PSYCHOSHIFTDAMAGE, POISONEDDAMAGE, BURNEDDAMAGE}
  125.     local ignoremiss = {NIGHTMAREDAMAGE, MORTALGASDAMAGE, BURNEDDAMAGE, POISONEDDAMAGE}
  126.     local ignorecritical = {MORTALGASDAMAGE, BURNEDDAMAGE, POISONEDDAMAGE, NIGHTMAREDAMAGE}
  127.     local cannotkill = {MORTALGASDAMAGE, BURNEDDAMAGE, POISONEDDAMAGE, NIGHTMAREDAMAGE}
  128.      
  129.     function onStatsChange(cid, attacker, type, combat, value)
  130.      
  131.     if combat == FLYSYSTEMDAMAGE then return false end
  132.     if isPlayer(cid) and getCreatureOutfit(cid).lookType == 814 then return false end -- TV
  133.      
  134.     local damageCombat = combat
  135.     if damageCombat == THUNDERWAVEDAMAGE then
  136.     damageCombat = ELECTRICDAMAGE
  137.     elseif damageCombat == PSYCHOSHIFTDAMAGE then
  138.     damageCombat = PSYCHICDAMAGE
  139.     end
  140.      
  141.     if getPlayerStorageValue(cid, 33) >= 1 then -- funcionamento do self destruction
  142.     if isCreature(attacker) then
  143.     return false
  144.     end
  145.     return true
  146.     end
  147.      
  148.     if not isCreature(attacker) or cid == attacker then
  149.     if not isInArray(fixdamages, combat) and combats[combat] then
  150.     doSendAnimatedText(getThingPos(cid), value, combats[combat].cor)
  151.     end
  152.     return true
  153.     end
  154.      
  155.     --------------------------------------------------
  156.     if combat == SLEEP_POWDERDAMAGE then
  157.     if not isSummon(cid) and not isSummon(attacker) and not isPlayer(attacker) then
  158.     return false
  159.     end
  160.     if isPlayer(cid) then
  161.     return false
  162.     end
  163.     if isNpcSummon(cid) and getCreatureTarget(cid) ~= attacker then
  164.     return false
  165.     end
  166.     if isSummon(cid) and isSummon(attacker) then
  167.     if not isInParty(getCreatureMaster(cid)) or not isInParty(getCreatureMaster(attacker)) then
  168.     return false
  169.     end
  170.     if not getPlayerParty(getCreatureMaster(cid)) == getPlayerParty(getCreatureMaster(attacker)) then
  171.     return false
  172.     end
  173.     end
  174.     doSleep(cid, value, true)
  175.     return false
  176.     end
  177.     --------------------------------------------------
  178.     if combat == HEALINGDAMAGE then
  179.      
  180.     local healing = math.abs(value)
  181.      
  182.     if not isSummon(cid) and not isSummon(attacker) and not isPlayer(attacker) then
  183.     doHeal(cid, healing)
  184.     return false
  185.     end
  186.     if isSummon(cid) and isSummon(attacker) then
  187.     if getPlayerStorageValue(getCreatureMaster(cid), 990) >= 1 then
  188.     return false
  189.     end
  190.     if not isInParty(getCreatureMaster(cid)) or not isInParty(getCreatureMaster(attacker)) then
  191.     doHeal(cid, healing)
  192.     return false
  193.     end
  194.     if not getPlayerParty(getCreatureMaster(cid)) == getPlayerParty(getCreatureMaster(attacker)) then
  195.     doHeal(cid, healing)
  196.     return false
  197.     end
  198.     end
  199.     return false
  200.     end
  201.     --------------------------------------------------
  202.     if combat == POISON_POWDERDAMAGE then
  203.     if not isSummon(cid) and not isSummon(attacker) and not isPlayer(attacker) then
  204.     return false
  205.     end
  206.     if isNpcSummon(cid) and getCreatureTarget(cid) ~= attacker then
  207.     return false
  208.     end
  209.     if isSummon(cid) and isSummon(attacker) then
  210.     if not isInParty(getCreatureMaster(cid)) or not isInParty(getCreatureMaster(attacker)) then
  211.     return false
  212.     end
  213.     if not getPlayerParty(getCreatureMaster(cid)) == getPlayerParty(getCreatureMaster(attacker)) then
  214.     return false
  215.     end
  216.     end
  217.      
  218.     local master = attacker
  219.     if isSummon(attacker) then master = getCreatureMaster(attacker) end
  220.      
  221.     addEvent(doAdvancedPoison, 2500, attacker, master, cid, getPlayerStorageValue(attacker, 919231), value, getPlayerStorageValue(cid, 3893))
  222.      
  223.     return false
  224.     end
  225.     --------------------------------------------------
  226.     if isPlayer(attacker) then
  227.      
  228.     local valor = value
  229.     if valor > getCreatureHealth(cid) then
  230.     valor = getCreatureHealth(cid)
  231.     end
  232.      
  233.     if combat == COMBAT_PHYSICALDAMAGE then
  234.     return false
  235.     end
  236.      
  237.     if combat == PHYSICALDAMAGE then
  238.     doSendMagicEffect(getThingPos(cid), 3)
  239.     doSendAnimatedText(getThingPos(cid), valor, races[getMonsterInfo(getCreatureName(cid)).race].cor)
  240.     end
  241.      
  242.     if combats[damageCombat] and not isInArray(fixdmgs, damageCombat) then
  243.     doSendAnimatedText(getThingPos(cid), valor, combats[damageCombat].cor)
  244.     end
  245.      
  246.     if #getCreatureSummons(attacker) >= 1 and not isInArray({POISONEDDAMAGE, BURNEDDAMAGE}, combat) then
  247.     doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "Your "..getPokeName(getCreatureSummons(attacker)[1]).." dealt "..valor.." damage to "..getSomeoneDescription(cid)..".")
  248.     end
  249.      
  250.     return true
  251.     end
  252.     --------------------------------------------------
  253.     if isPlayer(cid) and #getCreatureSummons(cid) >= 1 and type == STATSCHANGE_HEALTHLOSS then
  254.     return false
  255.     end
  256.     --------------------------------------------------
  257.     if isPlayer(cid) and #getCreatureSummons(cid) <= 0 and type == STATSCHANGE_HEALTHLOSS then
  258.      
  259.     local valor = 0
  260.     if combat == COMBAT_PHYSICALDAMAGE then
  261.     valor = getOffense(attacker)
  262.     else
  263.     valor = getSpecialAttack(attacker)
  264.     end
  265.      
  266.     valor = valor * playerDamageReduction
  267.     valor = valor * math.random(83, 117) / 100
  268.      
  269.     if valor >= getCreatureHealth(cid) then
  270.     valor = getCreatureHealth(cid)
  271.     end
  272.      
  273.     valor = math.floor(valor)
  274.      
  275.     if valor >= getCreatureHealth(cid) then
  276.                if getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then
  277.                       doRemoveCondition(cid, CONDITION_OUTFIT)
  278.                       setPlayerStorageValue(cid, 17000, 0)
  279.                       setPlayerStorageValue(cid, 17001, 0)
  280.                       setPlayerStorageValue(cid, 63215, -1)
  281.                       doChangeSpeed(cid, PlayerSpeed)
  282.     local item = getPlayerSlotItem(cid, 8)
  283.     local btype = getPokeballType(item.itemid)
  284.               if #getCreatureSummons(cid) <= 0 then
  285.             if isInArray(pokeballs[btype].all, item.itemid) then
  286.                 doTransformItem(item.uid, pokeballs[btype].off)
  287.                 doItemSetAttribute(item.uid, "hp", 0)
  288.             end
  289.               end
  290.               end
  291.         end
  292.      
  293.     if valor >= getCreatureHealth(cid) then
  294.     if getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then
  295.     doRemoveCondition(cid, CONDITION_OUTFIT)
  296.     setPlayerStorageValue(cid, 17000, 0)
  297.     setPlayerStorageValue(cid, 17001, 0)
  298.     setPlayerStorageValue(cid, 63215, -1)
  299.     doChangeSpeed(cid, PlayerSpeed)
  300.     local item = getPlayerSlotItem(cid, 8)
  301.     local btype = getPokeballType(item.itemid)
  302.     if #getCreatureSummons(cid) <= 0 then
  303.     if isInArray(pokeballs[btype].all, item.itemid) then
  304.     doTransformItem(item.uid, pokeballs[btype].off)
  305.     doItemSetAttribute(item.uid, "hp", 0)
  306.     end
  307.     end
  308.     end
  309.     end
  310.     doCreatureAddHealth(cid, -valor, 3, 180)
  311.     if not isPlayer(cid) then
  312.     addEvent(sendPlayerDmgMsg, 5, cid, "You lost "..valor.." hitpoints due to an attack from "..getSomeoneDescription(attacker)..".")
  313.     end
  314.     return false
  315.     end
  316.     --------------------------------------------------
  317.     if type == STATSCHANGE_HEALTHGAIN then
  318.     if cid == attacker then
  319.     return true
  320.     end
  321.     if not isSummon(cid) and isSummon(attacker) then
  322.     return false
  323.     end
  324.     if isSummon(cid) and isSummon(attacker) and getPlayerParty(getCreatureMaster(cid)) == getPlayerParty(getCreatureMaster(attacker)) then
  325.     return false
  326.     end
  327.     return true
  328.     end
  329.     --------------------------------------------------
  330.     if isMonster(attacker) and getPlayerStorageValue(attacker, 201) ~= -1 then
  331.     if isPlayer(cid) then
  332.     return false
  333.     end
  334.     if getPlayerStorageValue(getCreatureMaster(cid), ginasios[getPlayerStorageValue(attacker, 201)].storage) ~= 1 then
  335.     return false
  336.     end
  337.     end
  338.     --------------------------------------------------
  339.     if isMonster(cid) and getPlayerStorageValue(cid, 201) ~= -1 then
  340.     if getPlayerStorageValue(getCreatureMaster(attacker), ginasios[getPlayerStorageValue(cid, 201)].storage) ~= 1 then
  341.     return false
  342.     end
  343.     end
  344.     --------------------------------------------------
  345.     --------------------------------------------------
  346.      
  347.     local multiplier = 1
  348.     local s = getSpeed(attacker)
  349.     local c = getSpeed(cid)
  350.     local miss = ((c - s) * 26)/100
  351.      
  352.     local poketype1 = pokes[getCreatureName(cid)].type
  353.     local poketype2 = pokes[getCreatureName(cid)].type2
  354.      
  355.     if getCreatureCondition(cid, CONDITION_INVISIBLE) then
  356.     return false
  357.     end
  358.      
  359.     if damageCombat ~= COMBAT_PHYSICALDAMAGE and not isInArray(ignored, damageCombat) then
  360.     if isInArray(effectiveness[damageCombat].super, poketype1) then
  361.     multiplier = multiplier * 2
  362.     end
  363.     if isInArray(effectiveness[damageCombat].super, poketype2) then
  364.     multiplier = multiplier * 2
  365.     end
  366.     if isInArray(effectiveness[damageCombat].weak, poketype1) then
  367.     multiplier = multiplier * 0.5
  368.     end
  369.     if isInArray(effectiveness[damageCombat].weak, poketype2) then
  370.     multiplier = multiplier * 0.5
  371.     end
  372.     if isInArray(effectiveness[damageCombat].non, poketype1) or isInArray(effectiveness[damageCombat].non, poketype2) then
  373.     multiplier = multiplier * 0
  374.     end
  375.     elseif combat == COMBAT_PHYSICALDAMAGE then
  376.     if isGhostPokemon(cid) and not isGhostPokemon(attacker) then
  377.     doSendMagicEffect(getThingPos(cid), 3)
  378.     return false
  379.     end
  380.     if getCreatureCondition(attacker, CONDITION_INVISIBLE) and not isGhostPokemon(attacker) then
  381.     if not isInArray({"Clefable", "Wigglytuff"}, getCreatureName(attacker)) then
  382.     return false
  383.     end
  384.     end
  385.     if miss > 0 and math.random(1, 100) <= miss and not isSleeping(cid) and not getCreatureCondition(cid, CONDITION_PARALYZE) then
  386.     doSendMagicEffect(getThingPos(cid), 211)
  387.     doSendAnimatedText(getThingPos(cid), "MISS", 215)
  388.     return false
  389.     end
  390.     end
  391.     --------------------------------------------------
  392.     local valor = value
  393.      
  394.     if multiplier > 2 then
  395.     multiplier = 2
  396.     elseif multiplier == 0.25 then
  397.     multiplier = 0.5
  398.     end
  399.      
  400.     --------------------------------------------------
  401.      
  402.      
  403.     local function resetMiss(cid)
  404.     if not isCreature(cid) then return true end
  405.     setPlayerStorageValue(cid, 88726, -1)
  406.     end
  407.      
  408.     if getPlayerStorageValue(cid, 88726) ~= 1 and miss > 0 and math.random(1, 100) <= miss and damageCombat ~= COMBAT_PHYSICALDAMAGE and not isInArray(ignoremiss, combat) and not isSleeping(cid) and not getCreatureCondition(cid, CONDITION_PARALYZE) then
  409.     doSendMagicEffect(getThingPos(cid), 211)
  410.     doSendAnimatedText(getThingPos(cid), "MISS", 215)
  411.     doTeleportThing(cid, getClosestFreeTile(cid, getThingPos(cid)), false)
  412.     doSendMagicEffect(getThingPos(cid), 211)
  413.     doFaceCreature(cid, getThingPos(attacker))
  414.     setPlayerStorageValue(cid, 88726, 1)
  415.     addEvent(resetMiss, 2200, cid)
  416.     return false
  417.     end
  418.      
  419.     if not isSummon(attacker) and not isSummon(cid) then
  420.     return false
  421.     end
  422.      
  423.     if isSummon(cid) and isSummon(attacker) then
  424.     if not isInParty(getCreatureMaster(cid)) or not isInParty(getCreatureMaster(attacker)) then
  425.     return false
  426.     end
  427.     if not getPlayerParty(getCreatureMaster(cid)) == getPlayerParty(getCreatureMaster(attacker)) then
  428.     return false
  429.     end
  430.     end
  431.      
  432.     if isSleeping(attacker) then
  433.     return false
  434.     end
  435.      
  436.     local randomRange = math.random(83, 117) / 100
  437.     local block = 0
  438.     if combat == COMBAT_PHYSICALDAMAGE then
  439.     block = 1 - (getDefense(cid) / (getOffense(attacker) + getDefense(cid)))
  440.     if getPokemonGender(attacker) == SEX_MALE then
  441.     block = block + 0.2
  442.     end
  443.     if getPokemonGender(cid) == SEX_FEMALE then
  444.     block = block - 0.2
  445.     end
  446.     valor = getOffense(attacker) * block
  447.     else
  448.     if (getSpecialAttack(attacker) + getSpecialDefense(cid))== 0 then
  449.     block = .5
  450.     else
  451.     block = 1 - (getSpecialDefense(cid) / (getSpecialAttack(attacker) + getSpecialDefense(cid)))
  452.     end
  453.     valor = valor * block * generalSpecialAttackReduction
  454.     if isSummon(cid) then
  455.     valor = valor * summonSpecialDamageReduction - getPokemonLevel(cid) / 2
  456.     end
  457.     end
  458.      
  459.     valor = valor * multiplier
  460.     valor = valor * randomRange
  461.      
  462.     if isSummon(attacker) then
  463.     valor = valor * getHappinessRate(attacker)
  464.     else
  465.     valor = valor * summonReduction
  466.     end
  467.      
  468.     valor = math.floor(valor)
  469.      
  470.     if combat == NIGHTMAREDAMAGE then
  471.     local div = 8
  472.     if isSummon(attacker) and not isSummon(cid) then
  473.     div = 4
  474.     end
  475.     valor = math.floor(getCreatureMaxHealth(cid)/div)
  476.     elseif combat == GUILLOTINEDAMAGE then
  477.     if isGhostPokemon(cid) then
  478.     doSendMagicEffect(getThingPos(cid), 3)
  479.     return false
  480.     end
  481.     local gDmg = 0.5
  482.     if isSummon(attacker) and not isSummon(cid) then
  483.     gDmg = 0.7
  484.     end
  485.     valor = getCreatureMaxHealth(cid) * gDmg
  486.     elseif combat == SEISMICTOSSDAMAGE then
  487.     valor = getPokemonLevel(attacker) * 10
  488.     elseif combat == BURNEDDAMAGE then
  489.     valor = value * getResistance(cid, FIREDAMAGE)
  490.     elseif combat == POISONEDDAMAGE then
  491.     valor = value * getResistance(cid, POISONDAMAGE)
  492.     end
  493.      
  494.     if valor <= 0 then
  495.     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
  496.     return false
  497.     end
  498.      
  499.     if math.random(1, 100) == 4 and not isInArray(ignorecritical, combat) then
  500.     doSendAnimatedText(getThingPos(attacker), "CRITICAL", 215)
  501.     valor = valor * 2
  502.     end
  503.      
  504.     if combat == PSYCHOSHIFTDAMAGE and isCreature(cid) then
  505.      
  506.     if not isPlayer(cid) then
  507.      
  508.     local pos = getThingPos(cid)
  509.     pos.x = pos.x + math.random(-4,4)
  510.     pos.y = pos.y + math.random(-4,4)
  511.     for a = 1, 6 do
  512.     if not canWalkOnPos(pos, true, true, true, true, false) or not isSightClear(getThingPos(cid), pos, false) then
  513.     pos = getThingPos(cid)
  514.     pos.x = pos.x + math.random(-4,4)
  515.     pos.y = pos.y + math.random(-4,4)
  516.     end
  517.     end
  518.      
  519.     if not canWalkOnPos(pos, true, true, true, true, false) then
  520.     pos = getClosestFreeTile(cid, getThingPos(cid))
  521.     end
  522.      
  523.     if not canWalkOnPos(pos, true, true, true, true, false) then
  524.     pos = getThingPos(cid)
  525.     end
  526.      
  527.     doTeleportThing(cid, pos, false)
  528.      
  529.     end
  530.      
  531.     doSendMagicEffect(getThingPos(cid), math.random(12, 14))
  532.     end
  533.      
  534.     if combat == THUNDERWAVEDAMAGE then
  535.     doCreatureAddCondition(cid, thunderwavecondition)
  536.     end
  537.      
  538.     if valor >= getCreatureHealth(cid) then
  539.     if isInArray(cannotKill, combat) and isPlayer(cid) then
  540.     valor = getCreatureHealth(cid) - 1
  541.     else
  542.     valor = getCreatureHealth(cid)
  543.     end
  544.     end
  545.      
  546.     --- REFLECT --------------------------------
  547.     if not isPlayer(cid) and getPlayerStorageValue(cid, 34) >= 1 and combat ~= COMBAT_PHYSICALDAMAGE then
  548.     doSendMagicEffect(getThingPos(cid), 135)
  549.     doSendAnimatedText(getThingPos(cid), "REFLECT", COLOR_GRASS)
  550.     setPlayerStorageValue(cid, 34, -1)
  551.     return false
  552.     end
  553.     --------------------------------------------
  554.      
  555.     if hasMimicWall(cid) then
  556.     doSendMagicEffect(getThingPos(cid), 135)
  557.     local dmgText = ""..valor..""
  558.     local a = getPlayerStorageValue(cid, 878)
  559.     setPlayerStorageValue(cid, 878, a - valor)
  560.     local k = getPlayerStorageValue(cid, 878)
  561.     if k <= 0 then
  562.     local b = getTileItemById(getThingPos(cid), 11440)
  563.     if b.uid > 1 then doRemoveItem(b.uid, 1) end
  564.     local c = getTileItemById(getThingPos(cid), 11439)
  565.     if c.uid > 1 then doRemoveItem(c.uid, 1) end
  566.     dmgText = ""..a..""
  567.     doSendMagicEffect(getThingPos(cid), 3)
  568.     end
  569.     doSendAnimatedText(getThingPos(cid), dmgText, 215)
  570.     return false
  571.     end
  572.      
  573.     if isSummon(attacker) and not isSummon(cid) and not isPlayer(cid) then
  574.      
  575.     local expstring = cid.."expEx"
  576.      
  577.     if getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, expstring) == null then
  578.     doItemSetAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, expstring, 0)
  579.     end
  580.      
  581.     local exp = valor / getCreatureMaxHealth(cid)
  582.     local ball = getPlayerSlotItem(getCreatureMaster(attacker), 8).uid
  583.      
  584.     doItemSetAttribute(ball, expstring, getItemAttribute(ball, expstring) + exp)
  585.     if getItemAttribute(ball, expstring) > 1 then
  586.     doItemSetAttribute(ball, expstring, 1)
  587.     end
  588.     end
  589.      
  590.     if isSummon(cid) and getCreatureHealth(cid) <= (getCreatureMaxHealth(cid)*0.08) and not exhaustion.get(getCreatureMaster(cid), 88726) then
  591.     exhaustion.set(getCreatureMaster(cid), 88726, 11)
  592.     doSendMagicEffect(getThingPos(cid), 178)
  593.     end
  594.      
  595.     if isSummon(attacker) then
  596.     if combat == COMBAT_PHYSICALDAMAGE then
  597.     doTargetCombatHealth(getCreatureMaster(attacker), cid, PHYSICALDAMAGE, -valor, -valor, 255)
  598.     else
  599.     doTargetCombatHealth(getCreatureMaster(attacker), cid, damageCombat, -valor, -valor, 255)
  600.     end
  601.      
  602.     if not isSummon(cid) and not isPlayer(cid) and math.random(1, wildEvolveChance) == math.random(1, wildEvolveChance) then
  603.     addEvent(doEvolveWild, math.random(1, 2500), cid)
  604.     end
  605.     else
  606.     if combat ~= COMBAT_PHYSICALDAMAGE then
  607.     doCreatureAddHealth(cid, -math.abs(valor), 3, combats[damageCombat].cor)
  608.     else
  609.     doCreatureAddHealth(cid, -math.abs(valor), 3, races[getMonsterInfo(getCreatureName(cid)).race].cor)
  610.     end
  611.      
  612.     if isSummon(cid) then
  613.     addEvent(sendPlayerDmgMsg, 5, getCreatureMaster(cid), "Your "..getCreatureName(cid).." lost "..valor.." hitpoints due to an attack from "..getSomeoneDescription(attacker)..".")
  614.     end
  615.      
  616.     end
  617.      
  618.     local percent = 8 + math.ceil(valor / getCreatureMaxHealth(cid) * 100)
  619.     if getCreatureHealth(cid) == 0 or percent <= 0 then return false end
  620.     local runCond = false
  621.      
  622.     if math.random(100) <= percent then
  623.     runCond = true
  624.     end
  625.      
  626.     if runCond then
  627.      
  628.     local condPos = getThingPos(cid)
  629.     local color = 215
  630.     local text = ""
  631.     local effect = 2
  632.      
  633.     if damageCombat == FIREDAMAGE and not isBurning(cid) then
  634.     doAdvancedBurn(attacker, isPlayer(getCreatureMaster(attacker)) and getCreatureMaster(attacker) or 0, cid, getPokemonLevel(attacker) * 2, math.random(5, 12))
  635.     color = COLOR_FIRE2
  636.     text = "BURNING"
  637.     effect = 15
  638.     elseif damageCombat == POISONDAMAGE and not isPoisoned(cid) and randomCond == checkCond then
  639.     doAdvancedPoison(attacker, isPlayer(getCreatureMaster(attacker)) and getCreatureMaster(attacker) or 0, cid, getPokemonLevel(attacker) * 2, math.random(4, 20))
  640.     color = COLOR_GRASS
  641.     text = "POISONED"
  642.     effect = 8
  643.     end
  644.      
  645.     doSendMagicEffect(getThingPos(cid), effect)
  646.     addEvent(doSendAnimatedText, 5, condPos, text, color)
  647.     end
  648.     ----------------------------------------PASSIVAS-----------------------------------------
  649.     ------------------------------"Counter Helix" - "Giro Ball"------------------------------
  650.     -- [outfit normal] = {out = outfit girando, efeitos}
  651.     local OutFit = {
  652.     [366] = {out = 496, cima = 128, direita = 129, esquerda = 130, baixo = 131}, --scyther
  653.     [912] = {out = 918, cima = 128, direita = 129, esquerda = 130, baixo = 131}, --Scizor
  654.     [1317] = {out = 849, cima = 128, direita = 129, esquerda = 130, baixo = 131}, --Shiny Scyther
  655.     [952] = {out = 1193, cima = 128, direita = 129, esquerda = 130, baixo = 131}, --Hitmontop
  656.     [909] = {out = 1194, cima = 128, direita = 129, esquerda = 130, baixo = 131}, --pineco
  657.     [910] = {out = 1192, cima = 128, direita = 129, esquerda = 130, baixo = 131}, --Forretress
  658.     }
  659.      
  660.     --acima do efeito 255 n aparece -pelo menos aki- entao fica esse por enquanto... ;x
  661.     --efeito vermelho => {cima = 261, direita = 263, esquerda = 264, baixo = 262}
  662.      
  663.     if isSummon(cid) then
  664.     if OutFit[getCreatureOutfit(cid).lookType] then
  665.     if math.random(1, 100) <= 20 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  666.      
  667.     if getPlayerStorageValue(cid, 32623) == 1 then --proteçao pra n usar a spell 2x seguidas...
  668.     return false
  669.     end
  670.      
  671.     local outfitt = OutFit[getCreatureOutfit(cid).lookType]
  672.     local function doWingAttack(cid, a, damage, min, max)
  673.     local damagearea = {}
  674.     local effectpos = getThingPosWithDebug(cid)
  675.     local effect = 255
  676.     if a == 0 then
  677.     effect = outfitt.cima
  678.     effectpos.x = effectpos.x + 1
  679.     effectpos.y = effectpos.y - 1
  680.     damagearea = wingdn
  681.     elseif a == 1 then
  682.     effect = outfitt.direita
  683.     effectpos.x = effectpos.x + 2
  684.     effectpos.y = effectpos.y + 1
  685.     damagearea = wingde
  686.     elseif a == 2 then
  687.     effect = outfitt.baixo
  688.     effectpos.x = effectpos.x + 1
  689.     effectpos.y = effectpos.y + 2
  690.     damagearea = wingds
  691.     elseif a == 3 then
  692.     effect = outfitt.esquerda
  693.     effectpos.x = effectpos.x - 1
  694.     effectpos.y = effectpos.y + 1
  695.     damagearea = wingdw
  696.     end
  697.     doSendMagicEffect(effectpos, effect)
  698.     if damage then
  699.     local look = getCreatureOutfit(cid).lookType
  700.     if look == 366 or look == 1317 then --scyther e shiny scyther
  701.     doAreaCombatHealth(cid, BUGDAMAGE, getThingPosWithDebug(cid), damagearea, -min, -max, CONST_ME_NONE)
  702.     elseif look == 952 then --hitmontop
  703.     doAreaCombatHealth(cid, FIGHTINGDAMAGE, getThingPosWithDebug(cid), damagearea, -min, -max, CONST_ME_NONE)
  704.     else --resto
  705.     doAreaCombatHealth(cid, STEELDAMAGE, getThingPosWithDebug(cid), damagearea, -min, -max, CONST_ME_NONE)
  706.     end
  707.     end
  708.     end
  709.      
  710.     local dire = getCreatureLookDir(cid)
  711.     local cpos = getThingPosWithDebug(cid)
  712.     local min = getWildPokemonLevel(cid)*15 --nao sei como funciona o sistema de dano...
  713.     local max = getWildPokemonLevel(cid)*20 --nao sei como funciona o sistema de dano...
  714.      
  715.     setPlayerStorageValue(cid, 32623, 1) --proteçao
  716.     doSetCreatureOutfit(cid, {lookType = OutFit[getCreatureOutfit(cid).lookType].out}, -1)
  717.      
  718.     local function doDance(cid, dir, damage, min, max)
  719.     if not isCreature(cid) then return true end
  720.     doCreatureSetLookDir(cid, dir)
  721.     doWingAttack(cid, dir, damage, min, max)
  722.     end
  723.      
  724.     for times = 0, 2 do
  725.     for directions = 0, 3 do
  726.     addEvent(doDance, times * 300, cid, directions, true, min, max)
  727.     end
  728.     end
  729.      
  730.     local function doChangeO(cid, dir, pos)
  731.     if not isCreature(cid) then return true end
  732.     setPlayerStorageValue(cid, 32623, 0) --proteçao
  733.     doRemoveCondition(cid, CONDITION_OUTFIT)
  734.     if getThingPosWithDebug(cid).x == pos.x and getThingPosWithDebug(cid).y == pos.y then
  735.     doCreatureSetLookDir(cid, dir)
  736.     end
  737.     end
  738.      
  739.     addEvent(doChangeO, 2 * 300 + 10, cid, dire, cpos)
  740.     end
  741.     end
  742.     end
  743.     -------------------------------------------Passiva de fogo e trovao-------------------------------------
  744.     local Fire_Thunder = {"Magmar", "Shiny Magmar", "Electabuzz", "Shiny Electabuzz"}
  745.      
  746.     --["Nome"] = {effeito, damage}
  747.     local eff = {
  748.     ["Magmar"] = {15, FIREDAMAGE},
  749.     ["Shiny Magmar"] = {15, FIREDAMAGE},
  750.     ["Electabuzz"] = {207, ELECTRICDAMAGE},
  751.     ["Shiny Electabuzz"] = {207, ELECTRICDAMAGE},
  752.     }
  753.      
  754.     if isSummon(cid) then
  755.     local e = getCreatureMaster(cid)
  756.     if isInArray(Fire_Thunder, getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")) then
  757.     if math.random(1, 100) <= 20 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  758.      
  759.     if getPlayerStorageValue(cid, 32623) == 1 then --proteçao pra n usar a spell 2x seguidas...
  760.     return false
  761.     end
  762.      
  763.     local min = getWildPokemonLevel(cid)*15 --nao sei como funciona o sistema de dano...
  764.     local max = getWildPokemonLevel(cid)*20 --nao sei como funciona o sistema de dano...
  765.      
  766.     local function sendFireEff(cid, dir, eff, damage)
  767.     if not isCreature(cid) then return true end
  768.     doAreaCombatHealth(cid, damage, getPosByDir(getThingPosWithDebug(cid), dir), 0, -min, -max, eff)
  769.     end
  770.      
  771.     local function doSpinFire(cid)
  772.     if not isCreature(cid) then return true end
  773.     local t = {
  774.     [1] = SOUTHWEST,
  775.     [2] = SOUTH,
  776.     [3] = SOUTHEAST,
  777.     [4] = EAST,
  778.     [5] = NORTHEAST,
  779.     [6] = NORTH,
  780.     [7] = NORTHWEST,
  781.     [8] = WEST,
  782.     [9] = SOUTHWEST,
  783.     }
  784.     for a = 1, 17 do
  785.     if not t[a] then
  786.     addEvent(sendFireEff, a * 140, cid, t[a-8], eff[getCreatureName(cid)][1], eff[getCreatureName(cid)][2])
  787.     else
  788.     addEvent(sendFireEff, a * 140, cid, t[a], eff[getCreatureName(cid)][1], eff[getCreatureName(cid)][2])
  789.     end
  790.     end
  791.     setPlayerStorageValue(cid, 32623, 0) --proteçao
  792.     end
  793.      
  794.     setPlayerStorageValue(cid, 32623, 1) --proteçao
  795.     doSpinFire(cid, false, cid)
  796.     end
  797.     end
  798.     end
  799.     ---------------------------------------------passiva Hitmonlee----------------------------------
  800.     --[outfit] = outfit chutando,
  801.     local hitmonlees = {
  802.     [371] = 652, --hitmonlee
  803.     [1300] = 652, --shiny hitmonlee
  804.     [877] = 878, --elite hitmonlee PxG
  805.     }
  806.      
  807.     --DETALHE: shiny hitmonlee n tem a sprite dele chutando.. pelo menos eu n achei..
  808.     --entao deixei a sprite do hitmonlee normal atacando...
  809.      
  810.     if isSummon(cid) then
  811.     local e = getCreatureMaster(cid)
  812.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  813.     if name == "Shiny Hitmonlee" or name == "Hitmonlee" then
  814.     if isCreature(getCreatureTarget(getCreatureMaster(cid))) then
  815.     if math.random(1, 100) <= 20 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  816.      
  817.     if isSleeping(cid) then return true end
  818.      
  819.     if getDistanceBetween(getThingPos(cid), getThingPos(getMasterTarget(cid))) > 1 then
  820.     return false
  821.     end
  822.     if getPlayerStorageValue(cid, 32623) == 1 then --proteçao pra n usar a spell 2x seguidas...
  823.     return false
  824.     end
  825.      
  826.     local function doChangeHitmon(cid)
  827.     if not isCreature(cid) then return true end
  828.     setPlayerStorageValue(cid, 32623, 0) --proteçao
  829.     doRemoveCondition(cid, CONDITION_OUTFIT)
  830.     end
  831.      
  832.     local min = getWildPokemonLevel(cid)*15 --nao sei como funciona o sistema de dano...
  833.     local max = getWildPokemonLevel(cid)*20 --nao sei como funciona o sistema de dano...
  834.      
  835.      
  836.     setPlayerStorageValue(cid, 32623, 1) --proteçao
  837.     doSetCreatureOutfit(cid, {lookType = hitmonlees[getCreatureOutfit(cid).lookType]}, -1)
  838.     doTargetCombatHealth(cid, getMasterTarget(cid), FIGHTINGDAMAGE, -min, -max, 255)
  839.      
  840.     addEvent(doChangeHitmon, 700, cid)
  841.     end
  842.     end
  843.     end
  844.     end
  845.     -------------------------------------------Passiva Hitmonchan-------------------------------------
  846.     local hitmonchans = {
  847.     ["Hitmonchan"] = {
  848.     [0] = {out = 559, eff = 112, type = FIGHTINGDAMAGE}, --outfit normal
  849.     [1] = {out = 1075, eff = 35, type = FIREDAMAGE}, --outfit fogo
  850.     [2] = {out = 1077, eff = 48, type = ELECTRICDAMAGE}, --outfit raio
  851.     [3] = {out = 1078, eff = 43, type = ICEDAMAGE}, --outfit gelo
  852.     [4] = {out = 1076, eff = 140, type = GHOSTDAMAGE} --outfit ghost
  853.     },
  854.      
  855.     ["Shiny Hitmonchan"] = {
  856.     --aconcelho trocar a outfit do shiny hitmonchan pela do elite hitmonchan do PO...
  857.     [0] = {out = 837, eff = 112, type = FIGHTINGDAMAGE}, --outfit normal
  858.     [1] = {out = 1080, eff = 35, type = FIREDAMAGE}, --outfit fogo
  859.     [2] = {out = 1081, eff = 48, type = ELECTRICDAMAGE}, --outfit raio
  860.     [3] = {out = 1082, eff = 43, type = ICEDAMAGE}, --outfit gelo
  861.     [4] = {out = 1079, eff = 140, type = GHOSTDAMAGE} --outfit ghost
  862.     }
  863.     }
  864.     local monchanOUT = {837, 1080, 1081, 1082, 1079}
  865.      
  866.     if isSummon(cid) then
  867.     local e = getCreatureMaster(cid)
  868.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  869.     if name == "Shiny Hitmonchan" or name == "Hitmonchan" then
  870.     if isCreature(getCreatureTarget(getCreatureMaster(cid))) then
  871.     if math.random(1, 100) <= 20 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  872.      
  873.     if isSleeping(cid) then return true end
  874.      
  875.     if getDistanceBetween(getThingPos(cid), getThingPos(getMasterTarget(cid))) > 1 then
  876.     return false
  877.     end
  878.     if name == "Shiny Hitmonchan" and not isInArray(monchanOUT, getCreatureOutfit(cid).lookType) then
  879.     return false --proteçao pro script n funcionar com o shiny monchan com outfit diferente da do elite...
  880.     end --script soh funciona com outfit do elite hirmonchan do PO...
  881.      
  882.      
  883.     local min = getWildPokemonLevel(cid)*15 --nao sei como funciona o sistema de dano...
  884.     local max = getWildPokemonLevel(cid)*20 --nao sei como funciona o sistema de dano...
  885.      
  886.     local hands = getItemAttribute(getPlayerSlotItem(e, 8).uid, "hands")
  887.      
  888.      
  889.     doSendDistanceShoot(getThingPos(cid), getThingPos(getMasterTarget(cid)), 39)
  890.     doTargetCombatHealth(cid, getMasterTarget(cid), hitmonchans[name].type, -min, -max, 255)
  891.      
  892.      
  893.     local target = getThingPos(getMasterTarget(cid))
  894.     target.x = target.x + 1
  895.      
  896.     if hands == 4 then
  897.     doSendMagicEffect(target, hitmonchans[name][hands].eff)
  898.     else
  899.     doSendMagicEffect(getThingPos(getMasterTarget(cid)), hitmonchans[name].eff)
  900.     end
  901.      
  902.     end
  903.     end
  904.     end
  905.     end
  906.     -------------------------------------------passiva psyduck e golcuck------------------------------------------
  907.     local ducks = {"Golduck", "Psyduck", "Shiny Golduck", "Shiny Psyduck"}
  908.      
  909.     if isSummon(cid) then
  910.     local e = getCreatureMaster(cid)
  911.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  912.     if isInArray(ducks, name) then
  913.     if math.random(1, 100) <= 20 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  914.      
  915.     if getPlayerStorageValue(cid, 32623) == 1 then --proteçao pra n usar a spell 2x seguidas...
  916.     return false
  917.     end
  918.      
  919.     local min = getWildPokemonLevel(cid)*5 --nao sei como funciona o sistema de dano...
  920.     local max = getWildPokemonLevel(cid)*10 --nao sei como funciona o sistema de dano...
  921.      
  922.     local function damage(cid)
  923.     if isCreature(cid) then
  924.     setPlayerStorageValue(cid, 32623, 1) --proteçao
  925.     doAreaCombatHealth(cid, PSYCHICDAMAGE, getThingPosWithDebug(cid), confusion, -min, -max, 136)
  926.     end
  927.     end
  928.      
  929.     for i = 1, 7 do
  930.     addEvent(damage, i*500, cid)
  931.     end
  932.     setPlayerStorageValue(cid, 32623, 0) --proteçao
  933.     end
  934.     end
  935.     end
  936.     -----------------------------------------passiva kangaskhan-----------------------------------
  937.     if isSummon(cid) then
  938.     local e = getCreatureMaster(cid)
  939.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  940.     if name == "Kangaskhan" or name == "Shiny Kangaskhan" then
  941.     if math.random(1, 100) <= 20 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  942.      
  943.     local min = getWildPokemonLevel(cid)*10 --nao sei como funciona o sistema de dano...
  944.     local max = getWildPokemonLevel(cid)*15 --nao sei como funciona o sistema de dano...
  945.      
  946.     doAreaCombatHealth(cid, NORMALDAMAGE, getThingPosWithDebug(cid), eshock, -min, -max, 255)
  947.      
  948.     local sps = getThingPosWithDebug(cid)
  949.     sps.x = sps.x+1
  950.     sps.y = sps.y+1
  951.     doSendMagicEffect(sps, 127)
  952.     end
  953.     end
  954.     end
  955.     --passive raichu--
  956.     --[[arr = {
  957.     {1, 1, 1, 1, 1},
  958.     {1, 1, 1, 1, 1},
  959.     {1, 1, 2, 1, 1},
  960.     {1, 1, 1, 1, 1},
  961.     {1, 1, 1, 1, 1}
  962.     }
  963.     if isSummon(cid) then
  964.     local e = getCreatureMaster(cid)
  965.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  966.     local target = 0
  967.     if name == "Raichu" or name == "Shiny Raichu" then
  968.     if getPlayerStorageValue(cid, 253) >= 0 then
  969.     return true
  970.     end
  971.     local uid = checkAreauid(getCreaturePosition(cid), arr, 1, 1)
  972.     for _,pid in pairs(uid) do
  973.     if isCreature(pid) then
  974.     if getCreatureTarget(pid) == cid then
  975.     target = target+1
  976.     end
  977.     end
  978.     end
  979.     if target == 0 then
  980.     return true
  981.     end
  982.     if target == (1 or 2) then
  983.     chance = 15 --15%
  984.     elseif target == (3 or 4) then
  985.     chance = 20 --20%
  986.     elseif target == (5 or 6) then
  987.     chance = 30 --30%
  988.     end
  989.     if math.random(1, 100) <= chance then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  990.     setPlayerStorageValue(cid, 253, 1)
  991.     doSendAnimatedText(getThingPos(cid), "FOCUS", 144)
  992.     end
  993.     end
  994.     end
  995.     ]]
  996.     -------------------------------------passiva wiggly------------------------------------
  997.     if isSummon(cid) then
  998.     local e = getCreatureMaster(cid)
  999.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  1000.     if name == "Wigglytuff" or name == "Shiny Wigglytuff" then
  1001.     if math.random(1, 100) <= 10 then -- Porcentagem de chance pro poke usar a passiva... 10 = 10% +/-
  1002.     doAreaCombatHealth(cid, SLEEP_POWDERDAMAGE, getThingPosWithDebug(cid), powders, -6, -10, 33)
  1003.     end
  1004.     end
  1005.     end
  1006.     ------------------------------------- /PASS DRAGON ---------------------------------------
  1007.     local DracoFury = {"Gyarados", "Shiny Gyarados", "Dratini", "Shiny Dratini", "Dragonair", "Shiny Dragonair", "Dragonite", "Shiny Dragonite"}
  1008.     if isSummon(cid) then
  1009.     local e = getCreatureMaster(cid)
  1010.     local name = getItemAttribute(getPlayerSlotItem(e, 8).uid, "poke")
  1011.     if isInArray(DracoFury, name) then
  1012.     if math.random(1, 100) <= 10 then --Chance 4 = 4% Acho, Mais Fica A Sua Escolha
  1013.     if getPlayerStorageValue(cid, 32623) == 1 then
  1014.     return false
  1015.     end
  1016.      
  1017.     local function effect(params)
  1018.     if isCreature(params.cid) then
  1019.     doSendMagicEffect(getThingPos(params.cid), 12)
  1020.     end
  1021.     end
  1022.      
  1023.     setPlayerStorageValue(cid, 32623, 1)
  1024.      
  1025.     local function doReduceOffenseDefense(cid, qnt)
  1026.     if not isCreature(cid) then return true end
  1027.     local a = getDefense(cid)
  1028.     local A = getOffense(cid)
  1029.     setPlayerStorageValue(cid, 1002, a - qnt)
  1030.     setPlayerStorageValue(cid, 1001, A - qnt)
  1031.     end
  1032.      
  1033.     local function doDoubleOffenseDefense(cid)
  1034.     if not isCreature(cid) then return true end
  1035.     local a = getDefense(cid)
  1036.     local A = getOffense(cid)
  1037.     setPlayerStorageValue(cid, 1002, a * 2)
  1038.     setPlayerStorageValue(cid, 1001, A * 1.5)
  1039.     local b = getDefense(cid)
  1040.     local c = b - a
  1041.     local B = getOffense(cid)
  1042.     local C = B - A
  1043.     addEvent(doReduceOffenseDefense, 15 * 1500 + 40, cid, c)
  1044.     addEvent(doReduceOffenseDefense, 15 * 1500 + 40, cid, C)
  1045.     end
  1046.      
  1047.     setPlayerStorageValue(cid, 32623, 0)
  1048.     doDoubleOffenseDefense(cid)
  1049.     for times = 0, 15 do
  1050.     addEvent(effect, 1500 * times + 40, {cid = cid})
  1051.     end
  1052.     setPlayerStorageValue(cid, 32623, 1)
  1053.     end
  1054.     end
  1055.     end
  1056.      
  1057.     return false
  1058.     end