Advertisement
Kevick

exp.lua

Apr 28th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.05 KB | None | 0 0
  1. local function doPlayerAddPercentLevel(cid, percent)
  2. local player_lv, player_lv_1 = getExperienceForLevel(getPlayerLevel(cid)), getExperienceForLevel(getPlayerLevel(cid)+2)
  3. local percent_lv = ((player_lv_1 - player_lv) / 200) * percent
  4. doPlayerAddExperience(cid, percent_lv)
  5. end
  6.  
  7.  
  8. local combats = { --alterado v2.6 \/
  9. [PSYCHICDAMAGE] = {cor = COLOR_PSYCHIC},
  10. [GRASSDAMAGE] = {cor = COLOR_GRASS},
  11. [POISONEDDAMAGE] = {cor = COLOR_GRASS},
  12. [FIREDAMAGE] = {cor = COLOR_FIRE2},
  13. [BURNEDDAMAGE] = {cor = COLOR_BURN},
  14. [WATERDAMAGE] = {cor = COLOR_WATER},
  15. [ICEDAMAGE] = {cor = COLOR_ICE},
  16. [NORMALDAMAGE] = {cor = COLOR_NORMAL},
  17. [FLYDAMAGE] = {cor = COLOR_FLYING},
  18. [GHOSTDAMAGE] = {cor = COLOR_GHOST},
  19. [GROUNDDAMAGE] = {cor = COLOR_GROUND},
  20. [ELECTRICDAMAGE] = {cor = COLOR_ELECTRIC},
  21. [ROCKDAMAGE] = {cor = COLOR_ROCK},
  22. [BUGDAMAGE] = {cor = COLOR_BUG},
  23. [FIGHTDAMAGE] = {cor = COLOR_FIGHTING},
  24. [DRAGONDAMAGE] = {cor = COLOR_DRAGON},
  25. [POISONDAMAGE] = {cor = COLOR_POISON},
  26. [DARKDAMAGE] = {cor = COLOR_DARK},
  27. [STEELDAMAGE] = {cor = COLOR_STEEL},
  28. [MIRACLEDAMAGE] = {cor = COLOR_PSYCHIC},
  29. [DARK_EYEDAMAGE] = {cor = COLOR_GHOST},
  30. [SEED_BOMBDAMAGE] = {cor = COLOR_GRASS},
  31. [SACREDDAMAGE] = {cor = COLOR_FIRE2},
  32. }
  33. --alterado v2.5 tabelas agora estao em lib/configuration.lua
  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 ) 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.  
  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.  
  123. local damages = {GROUNDDAMAGE, ELECTRICDAMAGE, ROCKDAMAGE, FLYDAMAGE, BUGDAMAGE, FIGHTINGDAMAGE, DRAGONDAMAGE, POISONDAMAGE, DARKDAMAGE, STEELDAMAGE}
  124. local fixdmgs = {PSYCHICDAMAGE, COMBAT_PHYSICALDAMAGE, GRASSDAMAGE, FIREDAMAGE, WATERDAMAGE, ICEDAMAGE, NORMALDAMAGE, GHOSTDAMAGE}
  125. local ignored = {POISONEDDAMAGE, BURNEDDAMAGE} --alterado v2.6
  126. local cannotkill = {BURNEDDAMAGE, POISONEDDAMAGE}
  127.  
  128. function onStatsChange(cid, attacker, type, combat, value)
  129. local Premio = {
  130. [1] = 2160,
  131. [2] = 2160,
  132. [3] = 6569,
  133. [4] = 2152,
  134. [5] = 6569,
  135. [6] = 2152,
  136. }
  137.  
  138.  
  139.  
  140.  
  141. if combat == FLYSYSTEMDAMAGE then return false end
  142. if isPlayer(cid) and getCreatureOutfit(cid).lookType == 814 then return false end -- TV
  143.  
  144. local damageCombat = combat
  145.  
  146. if not isCreature(attacker) then --alterado v2.5 cid == attacker
  147. if not isInArray(fixdamages, combat) and combats[combat] then
  148. doSendAnimatedText(getThingPos(cid), value, combats[combat].cor)
  149. end
  150. return true
  151. end
  152.  
  153. --------------------------------------------------
  154. --alterado v2.6 retirado os combats sleep_powder e poison_powder daki!
  155. --------------------------------------------------
  156. if isMonster(cid) then
  157. local valor = value
  158. if not pokes[getCreatureName(cid)] and damageCombat == COMBAT_PHYSICALDAMAGE then
  159. valor = getOffense(attacker) * playerDamageReduction
  160. doCreatureAddHealth(cid, -math.abs(valor), 3, races[7].cor) --alterado v2.6 dano nos npcs
  161. return false
  162. elseif not pokes[getCreatureName(cid)] and damageCombat ~= COMBAT_PHYSICALDAMAGE then
  163. doCreatureAddHealth(cid, -math.abs(valor), 3, combats[damageCombat].cor)
  164. return false
  165. end
  166. end
  167. --------------------------------------------------
  168.  
  169. if isPlayer(attacker) then
  170.  
  171. local valor = value
  172. if valor > getCreatureHealth(cid) then
  173. valor = getCreatureHealth(cid)
  174. end
  175.  
  176. if combat == COMBAT_PHYSICALDAMAGE then
  177. return false
  178. end
  179.  
  180. if combat == PHYSICALDAMAGE then
  181. doSendMagicEffect(getThingPos(cid), 3)
  182. doSendAnimatedText(getThingPos(cid), valor, races[getMonsterInfo(getCreatureName(cid)).race].cor)
  183. end
  184.  
  185. if combats[damageCombat] and not isInArray(fixdmgs, damageCombat) then
  186. doSendAnimatedText(getThingPos(cid), valor, combats[damageCombat].cor)
  187. end
  188.  
  189. if #getCreatureSummons(attacker) >= 1 and not isInArray({POISONEDDAMAGE, BURNEDDAMAGE}, combat) then
  190. doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "Your "..getPokeName(getCreatureSummons(attacker)[1]).." dealt "..valor.." damage to "..getSomeoneDescription(cid)..".")
  191. end
  192.  
  193. return true
  194. end
  195. --------------------------------------------------
  196.  
  197. if isPlayer(cid) and #getCreatureSummons(cid) >= 1 and type == STATSCHANGE_HEALTHLOSS then
  198. return false
  199. end
  200. --------------------------------------------------
  201. if isPlayer(cid) and #getCreatureSummons(cid) <= 0 and type == STATSCHANGE_HEALTHLOSS then
  202.  
  203. if isSummon(attacker) or isPlayer(attacker) then
  204.  
  205. if canAttackOther(cid, attacker) == "Cant" then return false end
  206. end
  207.  
  208. local valor = 0
  209. if combat == COMBAT_PHYSICALDAMAGE then
  210. valor = getOffense(attacker)
  211. else
  212. valor = getSpecialAttack(attacker)
  213. end
  214.  
  215. valor = valor * playerDamageReduction
  216. valor = valor * math.random(83, 117) / 100
  217.  
  218. if valor >= getCreatureHealth(cid) then
  219. valor = getCreatureHealth(cid)
  220. end
  221.  
  222. valor = math.floor(valor)
  223.  
  224. if valor >= getCreatureHealth(cid) then
  225.  
  226. if getPlayerStorageValue(cid, 6598755) == 1 or getPlayerStorageValue(cid, 6598754) == 1 then
  227. setPlayerStorageValue(cid, 6598755, 0)
  228. setPlayerStorageValue(cid, 6598754, 0)
  229. doRemoveCondition(cid, CONDITION_OUTFIT)
  230. doPlayerAddSkill(cid, 4, 1)
  231. doSendAnimatedText(getCreaturePosition(cid),"LOOSE",math.random(1,255))
  232. setPlayerStorageValue(cid,19998,getPlayerStorageValue(cid,19998)+1)
  233. end
  234. if getPlayerStorageValue(cid,17778) == 1 then
  235. setGlobalStorageValue(17778,0)
  236. setPlayerStorageValue(cid,17778,0)
  237. doBroadcastMessage("O Jogador "..getCreatureName(cid).. " do time Azul morreu e perdeu a bandeira!",22)
  238. elseif getPlayerStorageValue(cid,17779) == 1 then
  239. setPlayerStorageValue(cid,17779,0)
  240. setGlobalStorageValue(17779,0)
  241. doBroadcastMessage("O Jogador "..getCreatureName(cid).. " do time Vermelho morreu e perdeu a bandeira!",22)
  242. end
  243.  
  244. if getPlayerStorageValue(getCreatureMaster(attacker), 6598755) == 1 then
  245. setPlayerStorageValue(getCreatureMaster(attacker),19999,getPlayerStorageValue(getCreatureMaster(attacker),19999)+1)
  246. doPlayerSendTextMessage(getCreatureMaster(attacker),MESSAGE_EVENT_ORANGE,"[Kill-Player] Voce Ganhou 5 HD + 10% EXP. E Agora tem "..(getPlayerStorageValue(getCreatureMaster(attacker),19999) + 1).." WIN SCORES.")
  247. doSendAnimatedText(getCreaturePosition(getCreatureMaster(attacker)),"WINN",math.random(1,255))
  248. --doPlayerAddItem(getCreatureMaster(attacker), 2152, 5)
  249. doPlayerAddPercentLevel(getCreatureMaster(attacker),10)
  250. setPlayerStorageValue(getCreatureMaster(attacker), 6598755,1)
  251. setGlobalStorageValue(5001, getGlobalStorageValue(5001) + 1)
  252. doPlayerAddSkill(cid, 3, 1)
  253. doBroadcastMessage("[Placar] : RedFrag [".. (getGlobalStorageValue(5001)+1).."] X ["..(getGlobalStorageValue(5002)+1).. "] BlueFrag",22)
  254.  
  255. elseif getPlayerStorageValue(getCreatureMaster(attacker), 6598754) == 1 then
  256. setPlayerStorageValue(getCreatureMaster(attacker),19999,getPlayerStorageValue(getCreatureMaster(attacker),19999)+1)
  257. doPlayerSendTextMessage(getCreatureMaster(attacker),MESSAGE_EVENT_ORANGE,"[Kill-Player] Voce Ganhou 5 HD + 10% EXP. E Agora tem "..(getPlayerStorageValue(getCreatureMaster(attacker),19999) + 1).." WIN SCORES.")
  258. doSendAnimatedText(getCreaturePosition(getCreatureMaster(attacker)),"WINN",math.random(1,255))
  259. --doPlayerAddItem(getCreatureMaster(attacker), 2152, 5)
  260. doPlayerAddPercentLevel(getCreatureMaster(attacker),10)
  261. setPlayerStorageValue(getCreatureMaster(attacker), 6598754,1)
  262. setGlobalStorageValue(5002, getGlobalStorageValue(5002) + 1)
  263.  
  264. doPlayerAddSkill(cid, 3, 1)
  265. doBroadcastMessage("[Placar] : RedFrag [".. (getGlobalStorageValue(5001)+1).."] X ["..(getGlobalStorageValue(5002)+1).. "] BlueFrag",22)
  266.  
  267.  
  268. end
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  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. if getPlayerStorageValue(cid, 22545) == 1 then
  292. if getGlobalStorageValue(22550) == 1 then
  293. doPlayerSendTextMessage(cid, 20, "You are the last survivor of the golden arena! Take your reward!")
  294. doPlayerAddItem(cid, 2152, getPlayerStorageValue(cid, 22551)*2)
  295. setPlayerStorageValue(cid, 22545, -1)
  296. doTeleportThing(cid, getClosestFreeTile(cid, getClosestFreeTile(cid, posBackGolden)), false)
  297. doCreatureAddHealth(cid, getCreatureMaxHealth(cid)-getCreatureHealth(cid))
  298. setPlayerRecordWaves(cid)
  299. endGoldenArena()
  300. return false
  301. else
  302. setGlobalStorageValue(22550, getGlobalStorageValue(22550)-1)
  303. setPlayerStorageValue(cid, 22545, -1)
  304. doTeleportThing(cid, getClosestFreeTile(cid, posBackGolden), false)
  305. doCreatureAddHealth(cid, getCreatureMaxHealth(cid)-getCreatureHealth(cid))
  306. setPlayerRecordWaves(cid)
  307. return false
  308. end
  309. end
  310.  
  311. local corpse = doCreateItem(3058, 1, getThingPos(cid))
  312. doDecayItem(corpse)
  313. doItemSetAttribute(corpse, "pName", getCreatureName(cid)) --alterado v2.7 coloca corpse quando o player morre!
  314. doItemSetAttribute(corpse, "attacker", getCreatureName(attacker))
  315. doItemSetAttribute(corpse, "article", getPlayerSex(cid) == 0 and "She" or "He")
  316.  
  317. if getPlayerStorageValue(cid, 98796) >= 1 then
  318. setPlayerStorageValue(cid, 98796, -1)
  319. setPlayerStorageValue(cid, 98797, -1) --alterado v2.8
  320. doTeleportThing(cid, SafariOut, false)
  321. doSendMagicEffect(getThingPos(cid), 21)
  322. doPlayerSendTextMessage(cid, 27, "You die in the saffari...")
  323. return false
  324. end
  325. if getPlayerStorageValue(cid, Agatha.stoIni) >= 1 and getPlayerStorageValue(cid, Agatha.stoIni) <= 10 then
  326. setPlayerStorageValue(cid, Agatha.stoIni, -1)
  327. setPlayerStorageValue(cid, Agatha.stoRec, -1)
  328. setPlayerStorageValue(cid, Agatha.stoPer, -1)
  329. setPlayerStorageValue(cid, Agatha.stoEni, -1) --alterado v2.9 agatha quest
  330. setPlayerStorageValue(cid, Agatha.stoRes, -1)
  331. end
  332. end
  333. doCreatureAddHealth(cid, -valor, 3, 180)
  334. if not isPlayer(cid) and valor > 0 then
  335. addEvent(sendPlayerDmgMsg, 5, cid, "You lost "..valor.." hitpoints due to an attack from "..getSomeoneDescription(attacker)..".")
  336. end
  337. return false
  338. end
  339. --------------------------------------------------
  340. if type == STATSCHANGE_HEALTHGAIN then
  341. if cid == attacker then
  342. return true
  343. end
  344. if isSummon(cid) and isSummon(attacker) and canAttackOther(cid, attacker) == "Cant" then
  345. return false
  346. end
  347. return true
  348. end
  349. --------------------------------------------------
  350. if isMonster(attacker) and getPlayerStorageValue(attacker, 201) ~= -1 then
  351. if isPlayer(cid) then
  352. return false
  353. end
  354. if getPlayerStorageValue(getCreatureMaster(cid), ginasios[getPlayerStorageValue(attacker, 201)].storage) ~= 1 then
  355. return false
  356. end
  357. end
  358. --------------------------------------------------
  359. if isMonster(cid) and getPlayerStorageValue(cid, 201) ~= -1 then
  360. if getPlayerStorageValue(getCreatureMaster(attacker), ginasios[getPlayerStorageValue(cid, 201)].storage) ~= 1 then
  361. return false
  362. end
  363. end
  364. --------------------------------------------------
  365. if ehMonstro(cid) and ehMonstro(attacker) then
  366. return false --edited monstro nao atacar monstro
  367. end
  368. ---------------------------------------------------
  369. --------------------REFLECT-----------------------
  370. if getPlayerStorageValue(cid, 21099) >= 1 and combat ~= COMBAT_PHYSICALDAMAGE then
  371. if not isInArray({"Team Claw", "Team Slice"}, getPlayerStorageValue(attacker, 21102)) then
  372. doSendMagicEffect(getThingPosWithDebug(cid), 135)
  373. doSendAnimatedText(getThingPosWithDebug(cid), "REFLECT", COLOR_GRASS)
  374. addEvent(docastspell, 100, cid, getPlayerStorageValue(attacker, 21102))
  375. if getCreatureName(cid) == "Wobbuffet" then
  376. doRemoveCondition(cid, CONDITION_OUTFIT)
  377. end
  378. setPlayerStorageValue(cid, 21099, -1) --alterado v2.6
  379. setPlayerStorageValue(cid, 21100, 1)
  380. setPlayerStorageValue(cid, 21101, attacker)
  381. setPlayerStorageValue(cid, 21103, getTableMove(attacker, getPlayerStorageValue(attacker, 21102)).f)
  382. setPlayerStorageValue(cid, 21104, getCreatureOutfit(attacker).lookType)
  383. return false
  384. end
  385. end
  386. -------------------------------------------------
  387.  
  388. local multiplier = 1
  389.  
  390. if isCreature(cid) then
  391. poketype1 = pokes[getCreatureName(cid)].type --alterado v2.6
  392. poketype2 = pokes[getCreatureName(cid)].type2
  393. end
  394. if not poketype1 or not poketype2 then return false end --alterado v2.6
  395.  
  396. if getCreatureCondition(cid, CONDITION_INVISIBLE) then
  397. return false
  398. end
  399.  
  400. if damageCombat ~= COMBAT_PHYSICALDAMAGE and not isInArray(ignored, damageCombat) then
  401. if isInArray(effectiveness[damageCombat].super, poketype1) then
  402. multiplier = multiplier + 0.5
  403. end
  404. if isInArray(effectiveness[damageCombat].super, poketype2) then
  405. multiplier = multiplier + 0.5
  406. end
  407. if isInArray(effectiveness[damageCombat].weak, poketype1) then
  408. multiplier = multiplier - 0.25 --alterado v2.3 efetividade q nem na pxg...
  409. end
  410. if isInArray(effectiveness[damageCombat].weak, poketype2) then
  411. multiplier = multiplier - 0.25
  412. end
  413. if isInArray(effectiveness[damageCombat].non, poketype1) or isInArray(effectiveness[damageCombat].non, poketype2) then
  414. if isInArray(specialabilities["foresight"], getCreatureName(attacker)) then --alterado v2.5
  415. multiplier = 0.5 --alterado v2.6
  416. end
  417. end
  418. elseif combat == COMBAT_PHYSICALDAMAGE then
  419. if isGhostPokemon(cid) then --alterado v2.3
  420.  
  421. if not isInArray(specialabilities["foresight"], getCreatureName(attacker)) then --alterado v2.5
  422. doSendMagicEffect(getThingPos(cid), 3)
  423. return false
  424. end
  425. end
  426.  
  427. local cd = getPlayerStorageValue(attacker, conds["Miss"])
  428. local cd2 = getPlayerStorageValue(attacker, conds["Confusion"]) --alterado v2.5
  429. local cd3 = getPlayerStorageValue(attacker, conds["Stun"])
  430. if cd >= 0 or cd2 >= 0 or cd3 >= 0 then
  431. if math.random(1, 100) > 50 then --50% chance de da miss no atk fisico
  432. doSendMagicEffect(getThingPos(cid), 211)
  433. doSendAnimatedText(getThingPos(attacker), "MISS", 215)
  434. return false
  435. end
  436. end
  437. end
  438. --------------------------------------------------
  439. local valor = value
  440.  
  441. if multiplier == 1.5 and poketype2 == "no type" then
  442. multiplier = 2 --alterado v2.6
  443. elseif multiplier == 1.5 and poketype2 ~= "no type" then
  444. multiplier = 1.75
  445. elseif multiplier == 1.25 then --edited effetivines = pxg
  446. multiplier = 1
  447. end
  448.  
  449. --------------------------------------------------
  450. if isSummon(cid) and isSummon(attacker) then
  451. if getCreatureMaster(cid) == getCreatureMaster(attacker) then
  452. return false
  453. end
  454. if canAttackOther(cid, attacker) == "Cant" then
  455. return false
  456. end
  457. end
  458.  
  459. local randomRange = math.random(83, 117) / 100
  460. local block = 1
  461.  
  462. if not isPlayer(cid) then
  463.  
  464. if combat == COMBAT_PHYSICALDAMAGE then
  465. block = 1 - (getDefense(cid) / (getOffense(attacker) + getDefense(cid)))
  466. if getPokemonGender(attacker) == SEX_MALE then
  467. block = block + 0.2
  468. end
  469. if getPokemonGender(cid) == SEX_FEMALE then
  470. block = block - 0.2
  471. end
  472. valor = getOffense(attacker) * block
  473.  
  474. if isInArray(specialabilities["counter"], getCreatureName(cid)) then
  475. if math.random(1, 100) <= 10 then
  476. doCreatureAddHealth(attacker, -valor, 3, 180) --alterado v2.5
  477. valor = 0
  478. doSendAnimatedText(getThingPosWithDebug(cid), "COUNTER", 215)
  479. end
  480. end
  481. else
  482. block = 1 - (getDefense(cid) / (getSpecialAttack(attacker) + getDefense(cid)))
  483. valor = valor * block * generalSpecialAttackReduction
  484. if isSummon(cid) then
  485. valor = valor * summonSpecialDamageReduction - getPokemonLevel(cid) / 2
  486. end
  487. end
  488. end
  489.  
  490. valor = valor * multiplier
  491. valor = valor * randomRange
  492.  
  493. if isSummon(attacker) then
  494. valor = valor * getHappinessRate(attacker)
  495. else
  496. valor = valor * summonReduction
  497. end
  498.  
  499. valor = math.floor(valor)
  500.  
  501. if combat == BURNEDDAMAGE then
  502. valor = value * getResistance(cid, FIREDAMAGE)
  503. elseif combat == POISONEDDAMAGE then
  504. valor = value * getResistance(cid, POISONDAMAGE)
  505. end
  506.  
  507. if math.random(1, 100) == 4 and not isInArray(ignorecritical, combat) then
  508. doSendAnimatedText(getThingPos(attacker), "CRITICAL", 215)
  509. valor = valor * 2
  510. end
  511.  
  512. -------------------------Edited CLAN SYSTEM-----------------------------------
  513. if isSummon(attacker) and getPlayerStorageValue(getCreatureMaster(attacker), 86228) >= 1 then
  514. valor = valor*getClanPorcent(getCreatureMaster(attacker), combat, "atk")
  515. elseif isSummon(cid) and getPlayerStorageValue(getCreatureMaster(cid), 86228) >= 1 then --alterado v2.3
  516. valor = valor - (valor*getClanPorcent(getCreatureMaster(cid), combat, "def", pokes[getCreatureName(cid)].type, pokes[getCreatureName(cid)].type2))
  517. end
  518. -----------------------------------------------------------------------
  519.  
  520. ---------------------- Edited Proteção --------------------------------
  521. if valor <= 10 then
  522. valor = math.random(15, 25)
  523. end
  524. -----------------------------------------------------------------------
  525. ---------------------- FEAR / ROAR ------------------------------------
  526. if getPlayerStorageValue(attacker, conds["Fear"]) >= 1 then --alterado v2.5!!
  527. return true
  528. end
  529. ---------------------------------------------------------------------------
  530. if damageCombat ~= COMBAT_PHYSICALDAMAGE and not isInArray(ignored, damageCombat) then
  531. if isInArray(effectiveness[damageCombat].non, poketype1) or isInArray(effectiveness[damageCombat].non, poketype2) then
  532. if not isInArray(specialabilities["foresight"], getCreatureName(attacker)) and getPlayerStorageValue(attacker, 999457) <= 0 then
  533. valor = valor * 0 --alterado v2.5
  534. end
  535. end
  536. end
  537.  
  538. if damageCombat == GROUNDDAMAGE then
  539. if isInArray(specialabilities["levitate"], getCreatureName(cid)) then
  540. valor = 0 --alterado v2.5
  541. end
  542. end
  543. -----------------------------------------------------------------------------
  544. local p = getThingPos(cid) --poke na pos backup
  545. if p.x == 1 and p.y == 1 and p.z == 10 then
  546. return false --alterado v2.2
  547. end
  548.  
  549. if getPlayerStorageValue(cid, 9658783) == 1 then
  550. return false --alterado v2.4 -- skill camuflage/future sight/acid armor e afins
  551. end
  552. -----------------------------------------------------------------------------
  553.  
  554. if valor >= getCreatureHealth(cid) then
  555. if isInArray(cannotKill, combat) and isPlayer(cid) then
  556. valor = getCreatureHealth(cid) - 1
  557. else
  558. valor = getCreatureHealth(cid)
  559. end
  560. end
  561. valor = math.floor(valor) --alterado v2.5
  562.  
  563. ------------------ SKILLs Q CURAM O ATTACKER ---------------------------------
  564. local function doHeal(cid, amount)
  565. if (getCreatureHealth(cid) + amount) >= getCreatureMaxHealth(cid) then
  566. amount = math.abs(getCreatureHealth(cid)-getCreatureMaxHealth(cid))
  567. end
  568. if getCreatureHealth(cid) ~= getCreatureMaxHealth(cid) then --alterado v2.6
  569. doCreatureAddHealth(cid, amount)
  570. doSendAnimatedText(getThingPosWithDebug(cid), "+"..amount.."", 65)
  571. end
  572. end
  573.  
  574. if damageCombat == PSYCHICDAMAGE or damageCombat == MIRACLEDAMAGE then
  575. if getPlayerStorageValue(attacker, 95487) >= 1 then
  576. doHeal(attacker, valor)
  577. setPlayerStorageValue(attacker, 95487, -1) --alterado v2.6
  578. end
  579. elseif damageCombat == SEED_BOMBDAMAGE then
  580. doHeal(attacker, valor)
  581. end
  582. --------------------------------------------
  583. ----------SACRED FIRE-----------------------
  584. if combat == SACREDDAMAGE and not ehNPC(cid) then --alterado v2.6
  585. local ret = {}
  586. ret.id = cid
  587. ret.cd = 9
  588. ret.check = getPlayerStorageValue(cid, conds["Silence"])
  589. ret.eff = 39
  590. ret.cond = "Silence"
  591.  
  592. doCondition2(ret)
  593. end
  594. --------------Passiva Lifesteal Clobat------------
  595. if combat == COMBAT_PHYSICALDAMAGE then
  596. if getCreatureName(attacker) == "Crobat" then --alterado v2.4
  597. doCreatureAddHealth(attacker, math.floor(valor))
  598. doSendAnimatedText(getThingPos(attacker), "+ "..math.floor(valor), 30)
  599. end
  600. end
  601. --------------------------------------------
  602.  
  603. if isSummon(attacker) then
  604.  
  605. local expstring = cid.."expEx"
  606.  
  607. if getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, expstring) == null then
  608. doItemSetAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, expstring, 0)
  609. end
  610.  
  611. local exp = valor / getCreatureMaxHealth(cid)
  612. local ball = getPlayerSlotItem(getCreatureMaster(attacker), 8).uid
  613. local xpp = tonumber(getItemAttribute(ball, expstring))
  614. local nxpp = xpp + exp
  615. doItemSetAttribute(ball, expstring, nxpp)
  616. if getItemAttribute(ball, expstring) > 1 then
  617. doItemSetAttribute(ball, expstring, 1)
  618. end
  619. end
  620.  
  621. if isSummon(attacker) then
  622. if combat == COMBAT_PHYSICALDAMAGE then
  623. doTargetCombatHealth(getCreatureMaster(attacker), cid, PHYSICALDAMAGE, -valor, -valor, 255)
  624. addEvent(doDoubleHit, 1000, attacker, cid, valor, races) --alterado v2.6 agility
  625. else
  626. doTargetCombatHealth(getCreatureMaster(attacker), cid, damageCombat, -valor, -valor, 255)
  627. end
  628.  
  629. if not isSummon(cid) and not isPlayer(cid) and math.random(1, wildEvolveChance) == math.random(1, wildEvolveChance) then
  630. addEvent(doEvolveWild, math.random(1, 2500), cid)
  631. end
  632. else
  633. if combat ~= COMBAT_PHYSICALDAMAGE then
  634.  
  635. doCreatureAddHealth(cid, -valor, 3,combats[damageCombat].cor)
  636.  
  637. else
  638. doCreatureAddHealth(cid, -math.abs(valor), 3, races[getMonsterInfo(getCreatureName(cid)).race].cor)
  639. addEvent(doDoubleHit, 1000, attacker, cid, valor, races) --alterado v2.6 agility
  640. end
  641.  
  642. if isSummon(cid) then
  643. addEvent(sendPlayerDmgMsg, 5, getCreatureMaster(cid), "Your "..getCreatureName(cid).." lost "..valor.." hitpoints due to an attack from "..getSomeoneDescription(attacker)..".")
  644. end
  645.  
  646. end
  647.  
  648. if damageCombat == FIREDAMAGE and not isBurning(cid) then
  649. local ret = {}
  650. ret.id = cid
  651. ret.cd = math.random(5, 12) --alterado v2.5
  652. ret.check = getPlayerStorageValue(cid, conds["Burn"])
  653. ret.damage = isSummon(attacker) and getMasterLevel(attacker)+getPokemonBoost(attacker) or getPokemonLevel(attacker)
  654. ret.cond = "Burn"
  655.  
  656. doCondition2(ret)
  657. elseif damageCombat == POISONDAMAGE and not isPoisoned(cid) then
  658. local ret = {}
  659. ret.id = cid
  660. ret.cd = math.random(6, 15) --alterado v2.5
  661. ret.check = getPlayerStorageValue(cid, conds["Poison"])
  662. local lvl = isSummon(attacker) and getMasterLevel(attacker) or getPokemonLevel(attacker)
  663. ret.damage = math.floor((getPokemonLevel(attacker)+lvl)/2)
  664. ret.cond = "Poison"
  665.  
  666. doCondition2(ret)
  667. end
  668. ------------------------------------POTIONS-------------------------------------------
  669. if isSummon(cid) and type == STATSCHANGE_HEALTHLOSS then
  670. if getPlayerStorageValue(cid, 173) >= 1 then
  671. if damageCombat ~= BURNEDDAMAGE and damageCombat ~= POISONEDDAMAGE then
  672. setPlayerStorageValue(cid, 173, -1) --alterado v2.6
  673. doSendAnimatedText(getThingPos(cid), "Lost Heal", 144)
  674. end
  675. end
  676. end
  677. ----------------------------------------PASSIVAS------------------------------------- --alterado v2.6 \/ todas as passivas agora estao em lib/pokemon moves.lua
  678. -------------------------------------------Counter Helix------------------------------------
  679. local helix = {"Scyther", "Scizor", "Shiny Scyther", "Hitmontop", "Shiny Hitmontop", "Pineco", "Forretress"}
  680.  
  681. if isInArray(helix, getCreatureName(cid)) and math.random(1, 100) <= 15 then
  682. docastspell(cid, "Counter Helix")
  683. end
  684. -------------------------------------------Lava Counter/Electricity----------------------------
  685. local Fire_Thunder = {"Magmar", "Electabuzz", "Shiny Electabuzz", "Magby", "Elekid"}
  686.  
  687. if isInArray(Fire_Thunder, getCreatureName(cid)) and math.random(1, 100) <= 15 then
  688. docastspell(cid, "Lava-Electricity")
  689. end
  690. -------------------------------------------Demon Kicker-------------------------------------
  691. --alterado v1.6 esta por ATK agora
  692. -------------------------------------------Demon Puncher-------------------------------------
  693. --alterado v1.6 esta por ATK agora
  694. ---------------------------------------Stunning Confusion-----------------------------------------
  695. local ducks = {"Golduck", "Psyduck","Shiny Psyduck", "Wobbuffet"} --alterado v1.6
  696.  
  697. if isInArray(ducks, getCreatureName(cid)) and math.random(1, 100) <= 20 then
  698. docastspell(cid, "Stunning Confusion")
  699. end
  700. -----------------------------------------Groundshock-----------------------------------
  701. if getCreatureName(cid) == "Kangaskhan" and math.random(1, 100) <= 20 then
  702. docastspell(cid, "Groundshock")
  703. end
  704. --------------------------------------Electric Charge---------------------------------------------
  705. local charge = {"Pikachu", "Raichu", "Shiny Raichu"}
  706.  
  707. if isInArray(charge, getCreatureName(cid)) and math.random(1, 100) <= 15 then
  708. docastspell(cid, "Electric Charge", 0, 0)
  709. end
  710. -------------------------------------Melody------------------------------------
  711. if getCreatureName(cid) == "Wigglytuff" and math.random(1, 100) <= 10 then
  712. docastspell(cid, "Melody")
  713. end
  714. ------------------------------------- Dragon Fury / Fury ---------------------------------------
  715. local DracoFury = {"Persian", "Raticate", "Shiny Raticate", "Gyarados", "Shiny Gyarados", "Dratini", "Shiny Dratini", "Dragonair", "Shiny Dragonair",
  716. "Dragonite", "Shiny Dragonite"} --alterado v1.6
  717.  
  718. if isInArray(DracoFury, getCreatureName(cid)) and math.random(1, 100) <= 10 then
  719. docastspell(cid, "Dragon Fury", 0, 0)
  720. end
  721. ------------------------------------- Mega Drain ---------------------------------------
  722. local mega = {"Oddish", "Gloom", "Vileplume", "Kabuto", "Kabutops", "Parasect", "Tangela", "Shiny Vileplume", "Shiny Tangela", "Shiny Parasect"}
  723.  
  724. if isInArray(mega, getCreatureName(cid)) and math.random(1, 100) <= 10 then
  725. docastspell(cid, "Mega Drain")
  726. end
  727. ------------------------------------- Spores Reaction ---------------------------------------
  728. local spores = {"Oddish", "Gloom", "Vileplume", "Shiny Vileplume"}
  729.  
  730. if isInArray(spores, getCreatureName(cid)) and math.random(1, 100) <= 10 then
  731. docastspell(cid, "Spores Reaction")
  732. end
  733. ------------------------------------ Amnesia ----------------------------------------
  734. local amnesia = {"Wooper", "Quagsire", "Swinub", "Piloswine"}
  735.  
  736. if isInArray(amnesia, getCreatureName(cid)) and math.random(1, 100) <= 10 then
  737. docastspell(cid, "Amnesia", 0, 0)
  738. end
  739. ----------------------------------- Zen Mind -----------------------------------------
  740. if getCreatureName(cid) == "Slowking" and math.random(1, 100) <= 10 and isWithCondition(cid) then
  741. docastspell(cid, "Zen Mind", 0, 0)
  742. end
  743. ---------------------------------- Mirror Coat ---------------------------------------
  744. if getCreatureName(cid) == "Wobbuffet" and math.random(1, 100) <= 30 then
  745. docastspell(cid, "Mirror Coat", 0, 0)
  746. end
  747. --------------------------------- Illusion -----------------------------------------
  748. return false
  749. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement