Advertisement
Guest User

Exp.lua

a guest
Aug 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.33 KB | None | 0 0
  1. local combats = {
  2. [PSYCHICDAMAGE] = {cor = COLOR_PSYCHIC, type = "psychic"},
  3. [GRASSDAMAGE] = {cor = COLOR_GRASS, type = "grass"},
  4. [POISONEDDAMAGE] = {cor = COLOR_GRASS, type = "poison"},
  5. [FIREDAMAGE] = {cor = COLOR_FIRE2, type = "fire"},
  6. [BURNEDDAMAGE] = {cor = COLOR_BURN, type = "fire"},
  7. [WATERDAMAGE] = {cor = COLOR_WATER, type = "water"},
  8. [ICEDAMAGE] = {cor = COLOR_ICE, type = "ice"},
  9. [NORMALDAMAGE] = {cor = COLOR_NORMAL, type = "normal"},
  10. [FLYDAMAGE] = {cor = COLOR_FLYING, type = "flying"},
  11. [GHOSTDAMAGE] = {cor = COLOR_GHOST, type = "ghost"},
  12. [GROUNDDAMAGE] = {cor = COLOR_GROUND, type = "ground"},
  13. [ELECTRICDAMAGE] = {cor = COLOR_ELECTRIC, type = "eletric"},
  14. [ROCKDAMAGE] = {cor = COLOR_ROCK, type = "rock"},
  15. [BUGDAMAGE] = {cor = COLOR_BUG, type = "bug"},
  16. [FIGHTDAMAGE] = {cor = COLOR_FIGHTING, type = "fight"},
  17. [DRAGONDAMAGE] = {cor = COLOR_DRAGON, type = "dragon"},
  18. [POISONDAMAGE] = {cor = COLOR_POISON, type = "poison"},
  19. [DARKDAMAGE] = {cor = COLOR_DARK, type = "dark"},
  20. [STEELDAMAGE] = {cor = COLOR_STEEL, type = "steel"},
  21. [MIRACLEDAMAGE] = {cor = COLOR_PSYCHIC, type = "ghost"},
  22. [DARK_EYEDAMAGE] = {cor = COLOR_GHOST, type = "dark"},
  23. [SEED_BOMBDAMAGE] = {cor = COLOR_GRASS, type = "grass"},
  24. [SACREDDAMAGE] = {cor = COLOR_FIRE2, type = "none"},
  25. [MUDBOMBDAMAGE] = {cor = COLOR_GROUND, type = "none"}, --alterado v1.9
  26. }
  27.  
  28. local races = {
  29. [4] = {cor = COLOR_FIRE2},
  30. [6] = {cor = COLOR_WATER},
  31. [7] = {cor = COLOR_NORMAL},
  32. [8] = {cor = COLOR_FIRE2},
  33. [9] = {cor = COLOR_FIGHTING},
  34. [10] = {cor = COLOR_FLYING},
  35. [11] = {cor = COLOR_GRASS},
  36. [12] = {cor = COLOR_POISON},
  37. [13] = {cor = COLOR_ELECTRIC},
  38. [14] = {cor = COLOR_GROUND},
  39. [15] = {cor = COLOR_PSYCHIC},
  40. [16] = {cor = COLOR_ROCK},
  41. [17] = {cor = COLOR_ICE},
  42. [18] = {cor = COLOR_BUG},
  43. [19] = {cor = COLOR_DRAGON},
  44. [20] = {cor = COLOR_GHOST},
  45. [21] = {cor = COLOR_STEEL},
  46. [22] = {cor = COLOR_DARK},
  47. [1] = {cor = 180},
  48. [2] = {cor = 180},
  49. [3] = {cor = 180},
  50. [5] = {cor = 180},
  51. }
  52.  
  53. local fixdmgs = {PSYCHICDAMAGE, COMBAT_PHYSICALDAMAGE, GRASSDAMAGE, FIREDAMAGE, WATERDAMAGE, ICEDAMAGE, NORMALDAMAGE, GHOSTDAMAGE}
  54.  
  55. local function doPlayerSendDamageText(cid, text)
  56. if not isCreature(cid) then return true end
  57. doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, text)
  58. end
  59.  
  60. function onCombat(cid, target)
  61. if isPlayer(target) and #getCreatureSummons(target) >= 1 then
  62. return false
  63. end
  64. return true
  65. end
  66.  
  67. function onStatsChange(cid, attacker, type, combat, value)
  68. local damageCombat = combat
  69. valor = value
  70.  
  71. if isSummon(attacker) then -- Summon não pode atacar master
  72. if cid == getCreatureMaster(attacker) then
  73. return false
  74. end
  75. end
  76.  
  77. if not isCreature(attacker) then -- Caso use algo tipo de dano, sem "master" atacante
  78. if not isInArray(fixdamages, combat) and combats[combat] then
  79. doSendAnimatedText(getThingPos(cid), -value, combats[combat].cor)
  80. end
  81. return true
  82. end
  83.  
  84. if isSummon(cid) and type == STATSCHANGE_HEALTHLOSS then -- Caso esteja healando, e leve dano o potion heal para de curar
  85. if getPlayerStorageValue(cid, 173) >= 1 then
  86. if combat ~= BURNEDDAMAGE and combat ~= POISONEDDAMAGE then
  87. setPlayerStorageValue(cid, 173, -1)
  88. doSendAnimatedText(getThingPos(cid), "Lost Heal", 144)
  89. end
  90. end
  91. end
  92.  
  93. if isPlayer(attacker) then
  94.  
  95. local valor = value
  96. if valor > getCreatureHealth(cid) then
  97. valor = getCreatureHealth(cid)
  98. end
  99.  
  100. if combat == COMBAT_PHYSICALDAMAGE then
  101. return false
  102. end
  103.  
  104. if combat == PHYSICALDAMAGE then
  105. doSendMagicEffect(getThingPos(cid), 3)
  106. doSendAnimatedText(getThingPos(cid), valor, races[getMonsterInfo(getCreatureName(cid)).race].cor)
  107. end
  108.  
  109. if combats[damageCombat] and not isInArray(fixdmgs, damageCombat) then
  110. doSendAnimatedText(getThingPos(cid), valor, combats[combat].cor)
  111. end
  112.  
  113. if #getCreatureSummons(attacker) >= 1 and not isInArray({POISONEDDAMAGE, BURNEDDAMAGE}, combat) then
  114. doPlayerSendTextMessage(attacker, MESSAGE_STATUS_DEFAULT, "Your "..getCreatureName(getCreatureSummons(attacker)[1]).." dealt "..valor.." damage to "..getCreatureName(cid)..".")
  115. end
  116.  
  117. return true
  118. end
  119.  
  120. if isPlayer(cid) and #getCreatureSummons(cid) <= 0 and type == STATSCHANGE_HEALTHLOSS then
  121. if isSummon(attacker) or isPlayer(attacker) then
  122. return canAttackOther(cid, attacker)
  123. end
  124.  
  125. local valor = 0
  126. if combat == COMBAT_PHYSICALDAMAGE then
  127. valor = math.random(getOffense(attacker), getOffense(attacker)+30)
  128. else
  129. valor = math.random(getSpecialAttack(attacker), getSpecialAttack(attacker)+30)
  130. end
  131. valor = valor * 0.32
  132. valor = valor * math.random(83, 117) / 100
  133.  
  134. if valor >= getCreatureHealth(cid) then
  135. valor = getCreatureHealth(cid)
  136. end
  137.  
  138. valor = math.floor(valor)
  139.  
  140.  
  141. if getPlayerStorageValue(cid, 98796) >= 1 then -- Safari
  142. setPlayerStorageValue(cid, 98796, -1)
  143. setPlayerStorageValue(cid, 98797, -1) --alterado v1.8
  144. doTeleportThing(cid, SafariOut, false)
  145. doSendMagicEffect(getThingPos(cid), 21)
  146. doPlayerSendTextMessage(cid, 27, "You die in the saffari... Best luck in the next time!")
  147. return false --alterado v1.8
  148. end
  149. if not isPlayer(cid) then
  150. doCreatureAddHealth(cid, -valor, 3, 180)
  151. addEvent(sendPlayerDmgMsg, 5, cid, "You lost "..valor.." hitpoints due to an attack from "..getCreatureName(attacker)..".")
  152. end
  153. return false
  154. end
  155.  
  156. if not isSummon(cid) and not isSummon(attacker) then
  157. return false
  158. end
  159.  
  160. if getCreatureCondition(cid, CONDITION_INVISIBLE) then
  161. return false
  162. end
  163.  
  164. if combat == COMBAT_PHYSICALDAMAGE then
  165. attr = getDefense(cid) - getOffense(attacker)
  166. if attr < 0 then
  167. attr = attr * -1
  168. nval = mathpercent(valor, attr)
  169. valor = math.ceil(valor+nval)
  170. else
  171. nval = mathpercent(valor, attr)
  172. valor = valor-nval
  173. end
  174. else
  175. attr = getSpecialDefense(cid) - getSpecialAttack(attacker)
  176. if attr < 0 then
  177. attr = attr * -1
  178. nval = mathpercent(valor, attr)
  179. valor = math.ceil(valor+nval)
  180. else
  181. nval = mathpercent(valor, attr)
  182. valor = valor-nval
  183. end
  184. end
  185.  
  186. if getPokemonGenderName(attacker) == "male" then -- Gender (Attack extra)
  187. valor = valor + (mathpercent(valor, 10)) -- 10% a mais de dano
  188. elseif getPokemonGenderName(attacker) == "genderless" then
  189. valor = valor + (mathpercent(valor, 5)) -- 5% a mais de dano
  190. end
  191.  
  192. if getPlayerStorageValue(cid, 21099) >= 1 and combat ~= COMBAT_PHYSICALDAMAGE then
  193. local spell = getPlayerStorageValue(attacker, 21102)
  194. if not isInArray({"Team Claw", "Team Slice"}, spell) then
  195. doSendMagicEffect(getThingPosWithDebug(cid), 135)
  196. doSendAnimatedText(getThingPosWithDebug(cid), "REFLECT", COLOR_GRASS)
  197. damage = getPokemonDamageBySpell(attacker, spell)
  198. addEvent(doPokemonUseSpell, 100, cid, spell, damage.min, damage.max)
  199. if getCreatureName(cid) == "Wobbuffet" then
  200. doRemoveCondition(cid, CONDITION_OUTFIT)
  201. end
  202. setPlayerStorageValue(cid, 21099, -1)
  203. return false
  204. end
  205. end
  206.  
  207. local attackername = doCorrectString(getCreatureName(attacker))
  208. local defensename = doCorrectString(getCreatureName(cid))
  209. local multiplier = 1
  210.  
  211. if combat ~= COMBAT_PHYSICALDAMAGE then -- Vantagem, desvantagem, imunidade
  212. if combats[combat].type == poke_status[defensename].type1 or combats[combat].type == poke_status[defensename].type2 then
  213. multiplier = 1
  214. elseif isInArray(getPokemonDisadvantage(defensename), combats[combat].type) then
  215. multiplier = 2
  216. msg = "2x"
  217. elseif isInArray(getPokemonAdvantage(defensename), combats[combat].type) then
  218. multiplier = 0.5
  219. msg = "0.5x"
  220. elseif isInArray(getPokemonImunity(defensename), combats[combat].type) then
  221. valor = 0
  222. msg = "0x"
  223. multiplier = 0
  224. end
  225. valor = valor * multiplier
  226. end
  227.  
  228. if isSummon(cid) and isSummon(attacker) then
  229. if getCreatureMaster(cid) == getCreatureMaster(attacker) then
  230. return false
  231. end
  232. if canAttackOther(cid, attacker) == false then
  233. return false
  234. end
  235. end
  236.  
  237. if msg and multiplier ~= 1 then
  238. doSendAnimatedText(getCreaturePosition(cid), msg, 171)
  239. end
  240.  
  241. if multiplier == 0 then
  242. return false
  243. end
  244.  
  245. local master = getCreatureMaster(attacker)
  246. if isPlayer(master) then
  247. if isDittoBall(master) then
  248. valor = valor * 0.75
  249. end
  250. end
  251.  
  252. if isSummon(attacker) then
  253. if multiplier ~= 0 then
  254. if combat == COMBAT_PHYSICALDAMAGE then
  255. doTargetCombatHealth(getCreatureMaster(attacker), cid, PHYSICALDAMAGE, -valor, -valor, 255)
  256. addEvent(doDoubleHit, 1000, attacker, cid, valor, races)
  257. else
  258. doTargetCombatHealth(getCreatureMaster(attacker), cid, damageCombat, -valor, -valor, 255)
  259. end
  260. end
  261. else
  262. if multiplier ~= 0 then
  263. if combat ~= COMBAT_PHYSICALDAMAGE then
  264. doCreatureAddHealth(cid, -valor, 3, combats[damageCombat].cor)
  265. else
  266. doCreatureAddHealth(cid, -valor, 3, races[getMonsterInfo(getCreatureName(cid)).race].cor)
  267. addEvent(function()
  268. doDoubleHit(attacker, cid, valor, races)
  269. end, 1000)
  270. end
  271. end
  272.  
  273. if isSummon(cid) then
  274. addEvent(doPlayerSendDamageText, 5, getCreatureMaster(cid), "Your "..getCreatureName(cid).." lost "..valor.." hitpoints due to an attack from "..getCreatureName(cid)..".")
  275. end
  276. end
  277.  
  278. --[[
  279. if passivesChances["PassiveName"][getCreatureName(cid)] and math.random(1, 100) <= passivesChances["PassiveName"][getCreatureName(cid)] then
  280. docastspell(cid, "Counter Helix")
  281. end
  282. ]]
  283.  
  284. return true
  285. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement