Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 170.88 KB | None | 0 0
  1. repeat wait() until game.Players.LocalPlayer.PlayerGui and _G.ready and _G.MovesReady and _G.SpritesReady and _G.TablesReady and _G.EvolutionReady and _G.GUIsLoaded and _G.StatsReady
  2. wait(2)
  3. local REvents = game.ReplicatedStorage.REvents
  4.  
  5. --[[===========================================
  6. ALL require() modules go here
  7. --============================================]]
  8. local Battle = require(game.ReplicatedStorage.Functions.Battle)
  9. local Pokedex = require(game.ReplicatedStorage.Functions.Pokedex)
  10. local ExpTables = require(game.ReplicatedStorage.Information.ExpTables)
  11. local ItemList = require(game.ReplicatedStorage.Information.Items)
  12. local natureStats = require(game.ReplicatedStorage.Information.NatureStats)
  13. local Math = require(game.ReplicatedStorage.Functions.Math)
  14.  
  15. --
  16.  
  17.  
  18. modifierstat = {
  19. [-7] = .25,
  20. [-6] = .25,
  21. [-5] = .285,
  22. [-4] = .33,
  23. [-3] = .4,
  24. [-2] = .5,
  25. [-1] = .66,
  26. [0] = 1,
  27. [1] = 1.5,
  28. [2] = 2,
  29. [3] = 2.5,
  30. [4] = 3,
  31. [5] = 3.5,
  32. [6] = 4,
  33. [7] = 4
  34. }
  35. accstat = {
  36. [-7] = .33,
  37. [-6] = .33,
  38. [-5] = .375,
  39. [-4] = .428,
  40. [-3] = .5,
  41. [-2] = .6,
  42. [-1] = .75,
  43. [0] = 1,
  44. [1] = 1.33,
  45. [2] = 1.66,
  46. [3] = 2,
  47. [4] = 2.33,
  48. [5] = 2.66,
  49. [6] = 3,
  50. [7] = 3
  51. }
  52. evadestat = {
  53. [-7] = 3,
  54. [-6] = 3,
  55. [-5] = 2.66,
  56. [-4] = 2.33,
  57. [-3] = 2,
  58. [-2] = 1.66,
  59. [-1] = 1.33,
  60. [0] = 1,
  61. [1] = .75,
  62. [2] = .6,
  63. [3] = .5,
  64. [4] = .428,
  65. [5] = .375,
  66. [6] = .33,
  67. [7] = .33
  68. }
  69.  
  70. fullnamestats = {
  71. ["Atk"] = "Attack",
  72. ["Def"] = "Defense",
  73. ["SpA"] = "Special Attack",
  74. ["SpD"] = "Special Defense",
  75. ["Speed"] = "Speed",
  76. ["Acc"] = "Accuracy",
  77. ["Evade"] = "Evasion"
  78. }
  79. buffstrings = {
  80. [-2] = " harshly fell!",
  81. [-1] = " fell!",
  82. [1] = " rose!",
  83. [2] = " sharply rose!"
  84. }
  85. statusstrings = {
  86. ["Paralysis"] = " was paralyzed!",
  87. ["Sleep"] = " fell asleep!",
  88. ["Burn"] = " was burned!",
  89. ["Faint"] = " fainted!",
  90. ["Poison"] = " was poisoned!",
  91. ["BadlyPoison"] = " was badly poisoned!",
  92. ["Freeze"] = " was frozen!"
  93. }
  94. immunestatus = {
  95. ["Burn"] = "Fire",
  96. ["Paralysis"] = "Electric",
  97. ["Poison"] = "Poison",
  98. ["BadlyPoison"] = "Poison",
  99. ["Freeze"] = "Ice"
  100. }
  101. partyb = {
  102. ["Empty"] = "http://www.roblox.com/asset/?id=125060330",
  103. ["Status"] = "http://www.roblox.com/asset/?id=125060479",
  104. ["Faint"] = "http://www.roblox.com/asset/?id=125060436",
  105. ["Healthy"] = "http://www.roblox.com/asset/?id=125060370",
  106. }
  107.  
  108. local HiddenPowerTypes = {
  109. [0] = "Fighting",
  110. [1] = "Flying",
  111. [2] = "Poison",
  112. [3] = "Ground",
  113. [4] = "Rock",
  114. [5] = "Bug",
  115. [6] = "Ghost",
  116. [7] = "Steel",
  117. [8] = "Fire",
  118. [9] = "Water",
  119. [10] = "Grass",
  120. [11] = "Electric",
  121. [12] = "Psychic",
  122. [13] = "Ice",
  123. [14] = "Dragon",
  124. [15] = "Dark",
  125. }
  126.  
  127. function getHiddenPower(poke)
  128. local val = poke.IV
  129. local Hp = val["HPIV"].Value%2==1 and 1 or 0
  130. local Atk = val["AtkIV"].Value%2==1 and 2 or 0
  131. local Def = val["DefIV"].Value%2==1 and 4 or 0
  132. local Speed = val["SpeedIV"].Value%2==1 and 8 or 0
  133. local SpA = val["SpAIV"].Value%2==1 and 16 or 0
  134. local SpD = val["SpDIV"].Value%2==1 and 32 or 0
  135. local Num = math.floor((Hp+Atk+Def+SpA+SpD+Speed)*15/63)
  136. return (HiddenPowerTypes[Num]) or "Dark"
  137. end
  138.  
  139. local wildBattle = {168915768,143994596,187444019,240170817,166121206,148177300}
  140. local trainerBattle = {157252674,315131709,163191259,281643103,143564131,197819173}
  141. --[[==================================
  142. Typewriter Effect Function
  143. ==================================
  144. --]]
  145. pressedq = nil
  146. scrollytext = nil
  147. function scrolltext(gui,text,thing)
  148. scrollytext = true
  149. for i = 1, #text,2 do
  150. gui.Text = string.sub(text,1,i)
  151.  
  152. if gui.Name ~= "Speak" then
  153. dropshadowdialog.Text = gui.Text
  154. else
  155. dropShaDia.Text = gui.Text
  156. end
  157. if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Q) then
  158. gui.Text = text
  159. if gui.Name ~= "Speak" then
  160. dropshadowdialog.Text = text
  161. else
  162. dropShaDia.Text = text
  163. end
  164. pressedq = nil
  165. scrollytext = nil
  166. break
  167. end
  168. wait(.04)
  169. end
  170. gui.Text = text
  171. if gui.Name ~= "Speak" then
  172. dropshadowdialog.Text = text
  173. else
  174. dropShaDia.Text = text
  175. end
  176. scrollytext = nil
  177. if thing==nil and not game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Q) then
  178. wait(.35)
  179. elseif thing == nil and game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.Q) then
  180. wait(.45)
  181. end
  182. end
  183. --[[
  184. ==================================
  185. Find Pokemon in the Party
  186. ==================================
  187. --]]
  188. function healafterbattle()
  189. local d = Battle:Heal()
  190. repeat wait() until d
  191. end
  192.  
  193.  
  194. function findlead(config)
  195. leadpokecom = nil
  196. for i,v in ipairs(config:GetChildren()) do
  197. for duh = 1, 6 do
  198. if duh == v.PartyPosition.Value and v.Status.Value ~= "Faint" then
  199. if leadpokecom == nil then
  200. leadpokecom = v
  201. elseif v.PartyPosition.Value < leadpokecom.PartyPosition.Value then
  202. leadpokecom = v
  203. end
  204. end
  205. end
  206. end
  207. if leadpokecom ~= nil then
  208. return leadpokecom
  209. else
  210. healafterbattle()
  211. return findlead(p.PokemonParty)
  212. end
  213. end
  214.  
  215. --[[Return party to "original" state]]--
  216. function originalparties(encode)
  217. if encode == true then
  218. for i,v in pairs (userteam:GetChildren()) do
  219. originalbattle[v] = v.PartyPosition.Value
  220. end
  221. elseif encode == false then
  222. for poke,banana in pairs(originalbattle) do
  223. Math:SwapPC(poke,banana)
  224. end
  225. end
  226. end
  227. --[[
  228. ==================================
  229. Reorganize Party for Battle
  230. ==================================
  231. --]]
  232. function reorganize(config,poke)
  233. for i,v in ipairs(config:GetChildren()) do
  234. for duh = 1, 6 do
  235. if v.PartyPosition.Value == 1 and v.Status.Value == "Faint" then
  236. Math:SwapPC(v,poke.PartyPosition.Value)
  237. Math:SwapPC(poke,1)
  238. break
  239. end
  240. end
  241. end
  242. end
  243.  
  244. local PC = require(game.ReplicatedStorage.Functions.PC)
  245.  
  246. function clearpokemon(p)
  247. for i,v in ipairs(p.OppPokemon:GetChildren()) do
  248. PC:Release(v)
  249. end
  250. end
  251. --[[
  252. ==================================
  253. Check for PP
  254. ==================================
  255. --]]
  256. function ppchecker(moves)
  257. for i,v in ipairs(moves:GetChildren()) do
  258. if v.PP.Value > 0 then
  259. return false
  260. end
  261. end
  262. return true
  263. end
  264. --[[
  265. ==================================
  266. Experience Bar Size Finder
  267. ==================================
  268. --]]
  269. function findexpbarsize(curlvl,nextlvl)
  270. local multi = 1/nextlvl
  271. return (multi*curlvl)
  272. end
  273. --[[
  274. ==================================
  275. Health Bar Size Finder
  276. ==================================
  277. --]]
  278. --hash
  279. function hash(num)
  280. return (num+4)*8
  281. end
  282. function dehash(num)
  283. return (num-32)/8
  284. end
  285.  
  286. function findhealthbarsize(curhealth,maxhealth) --size is 109
  287. local multi = curhealth/maxhealth
  288. return multi
  289. end
  290. --[[
  291. ================================
  292. Status
  293. ================================
  294. --]]
  295. function statusupdate(poke,foe)
  296. if poke.Status.Value ~= nil then
  297. if foe == true then
  298. scrolltext(dialog,"The "..prefix.." "..poke.Name..statusstrings[poke.Status.Value])
  299. tbox.Status.Text = _G.Tables["Status"][poke.Status.Value][1]
  300. tbox.Status.BackgroundColor3 = _G.Tables["Status"][poke.Status.Value][2]
  301. tbox.Status.Visible = true
  302. if prefix ~= "wild" then
  303. partycheck(theirparty)
  304. end
  305. else
  306. scrolltext(dialog,nickname(poke)..statusstrings[poke.Status.Value])
  307. ybox.Status.Text = _G.Tables["Status"][poke.Status.Value][1]
  308. ybox.Status.BackgroundColor3 = _G.Tables["Status"][poke.Status.Value][2]
  309. ybox.Status.Visible = true
  310. partycheck(yourparty)
  311. end
  312. end
  313. end
  314. --[[
  315. ===============================
  316. Do they have Enough Pokemon Left?
  317. ===============================
  318. --]]
  319. function checkalive(cfg)
  320. for i,v in ipairs(cfg:GetChildren()) do
  321. if v.CurrentHP.Value > 0 and v.Status.Value ~= "Faint" then
  322. return true
  323. end
  324. end
  325. return false
  326.  
  327. end
  328. --[[
  329. ===================================
  330. Do they have more than 1 Pokemon alive?
  331. ====================================
  332. --]]
  333. function checknumber(cfg)
  334. local number = 0
  335. for i,v in ipairs(cfg:GetChildren()) do
  336. if v.CurrentHP.Value > 0 or v.Status.Value ~= "Faint" then
  337. number = number + 1
  338. end
  339. end
  340. return number
  341. end
  342.  
  343. --if game.CreatorId ~= 2210737 then
  344. -- p:Kick()
  345. -- end
  346. --[[
  347. ==================================
  348. Change Visibility of a group of objects
  349. ==================================
  350. --]]
  351. function changevisible(thing,isa,bool)
  352. for i,v in ipairs(thing:GetChildren()) do
  353. if v:IsA(isa) and v.Name ~= "Back" and v.Name ~= "MegaEvolve" then
  354. v.Visible = bool
  355. end
  356. end
  357. end
  358. --[[
  359. ==================================
  360. Party Bar Stuff
  361. ==================================
  362. --]]
  363. function partycheck(bar)
  364. local partycheck2
  365. if bar.Name == "TheirParty" then
  366. partycheck2 = p.OppPokemon
  367. else
  368. partycheck2 = p.PokemonParty
  369. end
  370. for i = 1, 6 do
  371. bar["Ball"..i].Image = partyb["Empty"]
  372. end
  373. for _,v in ipairs(partycheck2:GetChildren()) do
  374.  
  375. for i = 1, 6 do
  376. if i == v.PartyPosition.Value then
  377. if v.Status.Value == "Faint" then
  378. bar["Ball"..i].Image = partyb["Faint"]
  379. elseif v.Status.Value ~= "" then
  380. bar["Ball"..i].Image = partyb["Status"]
  381. else
  382. bar["Ball"..i].Image = partyb["Healthy"]
  383. end
  384. end
  385. end
  386. end
  387. bar.Visible = true
  388. end
  389.  
  390. --function findexploits
  391.  
  392. function findexploiters(poek)
  393. local staz = {"Atk","Def","SpA","SpD","Speed", "HP"}
  394. local HPChanged = false
  395. if poek.Lvl.Value > 100 or dehash(poek.Experience.Value) < ExpTables[_G.Pokemon[poek.Name]["ExpType"].."Exp"](poek.Lvl.Value) then
  396. Math:ResetLevel(poek)
  397.  
  398.  
  399. HPChanged = true
  400. end
  401. if HPChanged == true then
  402. Math:StatChange(poek)
  403. end
  404. if poek.CurrentHP.Value > math.floor(HPcalc(poek.Lvl.Value,poek.IV["HPIV"].Value,poek.EV["HPEV"].Value,poek)) and poek.CurrentHP.Value > math.ceil(HPcalc(poek.Lvl.Value,poek.IV["HPIV"].Value,poek.EV["HPEV"].Value,poek)) then
  405. Math:Faint(poek)
  406. else
  407.  
  408. for i,v in ipairs(staz) do
  409. if poek.IV[v.."IV"].Value > 31 then Math:ResetEV(poek.IV[v.."IV"]) end
  410. if poek.EV[v.."EV"].Value > 255 then Math:ResetEV(poek.EV[v.."IV"]) end
  411.  
  412. end
  413. Math:StatChange(poek)
  414. end
  415. end
  416. --[[
  417. ==================================
  418. Update Pokemon Boxes
  419. ==================================
  420. --]]
  421. function boxupdate(config, box,your,transform)
  422. if your and config.Lvl.Value > 100 then
  423. Math:ResetLevel(config)
  424. end
  425. box.Level.Text = "Lv. "..config.Lvl.Value
  426. box.Level.Shadow.Text = box.Level.Text
  427. box.Gender.Image = _G.Sprites["Symbols"][config.Gender.Value]
  428. box.PokemonName.Text = nickname(config)
  429. box.PokemonName.Shadow.Text = box.PokemonName.Text
  430. box.HealthBG.Health.Size = UDim2.new(findhealthbarsize(config.CurrentHP.Value,config.Stats.HPStat.Value),-2,1,-2)
  431. box.Visible = true
  432. if your == true then
  433. if config.Name:reverse() ~= config.Reverse.Value then
  434. game.ReplicatedStorage.GoogleAnalytics:FireServer("Hack","NameHack",p.Name,1)
  435. p:Kick()
  436. end
  437. if transform ~= true then
  438. findexploiters(config)
  439. end
  440. box.HPLabel.Text = config.CurrentHP.Value.." / "..config.Stats.HPStat.Value
  441. box.HPLabel.Shadow.Text = box.HPLabel.Text
  442. local value1 = ExpTables[_G.Pokemon[config.Name]["ExpType"].."Exp"](config.Lvl.Value)
  443. local value2 = ExpTables[_G.Pokemon[config.Name]["ExpType"].."Exp"](config.Lvl.Value + 1)
  444. local lvlblah = value2 - value1
  445. local nextlvl = value2 - dehash(config.Experience.Value)
  446. local expbar = lvlblah - nextlvl
  447. box.ExpBG.Exp.Size = UDim2.new(findexpbarsize(expbar,lvlblah),0,1,0)
  448. end
  449.  
  450. if config.Status.Value ~= "" then
  451. box.Status.Text = _G.Tables["Status"][config.Status.Value][1]
  452. box.Status.BackgroundColor3 = _G.Tables["Status"][config.Status.Value][2]
  453. box.Status.Visible = true
  454. else
  455. box.Status.Visible = false
  456. end
  457. end
  458. --[[
  459. BallShake Animation
  460. --]]
  461. function shakeball(gui)
  462. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476420"
  463. for i = 0,-45,-5 do
  464. gui.Rotation = i
  465. wait()
  466. end
  467.  
  468. for i = -45,0,5 do
  469. gui.Rotation = i
  470. wait()
  471. end
  472. for i = 0,45,5 do
  473. gui.Rotation = i
  474. wait()
  475. end
  476. for i = 45,0,-5 do
  477. gui.Rotation = i
  478. wait()
  479. end
  480. p.PlayerGui.SoundEffect:Play()
  481. wait(.5)
  482. end
  483. function findbox()
  484. local numbers = {}
  485. for i,v in ipairs(p.PC:GetChildren()) do
  486. if #v:GetChildren() == 0 then
  487. return v.Name,1
  488. elseif #v:GetChildren() < 60 then
  489. for _,po in ipairs(v:GetChildren()) do
  490. numbers[po.PartyPosition.Value] = true
  491. end
  492. for swag = 1, 60 do
  493. if numbers[swag] == nil then
  494. return v.Name,swag
  495. end
  496. end
  497. end
  498. end
  499. end
  500. --creates pokedex entry (if they don't have one for their current pokemon)
  501.  
  502.  
  503. function capturedpokemon(item)
  504. local prisoner = game.ReplicatedStorage.REvents.Pokemon.catchPokemon:InvokeServer(theirpokeout,item)
  505. if #userteam:GetChildren() < 6 then
  506. PC:ParentChange(prisoner,userteam)
  507. Math:SwapParty(prisoner,#userteam:GetChildren())
  508. scrolltext(dialog,prisoner.Name.." was added to the Party.")
  509. else
  510. local newbox,number = findbox()
  511. scrolltext(dialog,prisoner.Name.." was sent to "..newbox..".")
  512. PC:ParentChange(prisoner, p.PC[newbox])
  513. Math:SwapParty(prisoner,number)
  514.  
  515. end
  516. --game.ReplicatedStorage.GoogleAnalytics:FireServer("PokemonCatch",prisoner.Name,p.Name,1)
  517. Pokedex:Caught(prisoner.Name)
  518. Math:Caughter(prisoner,item)
  519.  
  520. end
  521. --[[
  522. Throwing Pokeball Animation
  523. --]]
  524. thrownmsgs = {
  525. [-1] = "Oh no! The Pokemon broke free!",
  526. [0] = "Oh no! The Pokemon broke free!",
  527. [1] = "Aww! It appeared to be caught!",
  528. [2] = "Aargh! Almost had it!"
  529. }
  530.  
  531. function throwingball(item)
  532. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476515"
  533. pokeballanim.Position = UDim2.new(0,0,0.5,-95)
  534. p.PlayerGui.SoundEffect:Play()
  535. pokeballanim.Image = _G.Sprites["Pokeball"][item]["Open"]
  536. pokeballanim.Visible = true
  537. pokeballanim:TweenPosition(UDim2.new(0.75, -30,0.5, -25),"Out","Quad",.75)
  538. wait(.75)
  539. flash.Visible = true
  540. pokeballanim.Image = _G.Sprites["Pokeball"][item]["Closed"]
  541. wait(.1)
  542. theirpokemon.Visible = false
  543. flash.Visible = false
  544. pokeballanim:TweenPosition(UDim2.new(0.75, -30,0.5, 0),"Out","Quad",.6)
  545. if _G.Shakes == 0 then
  546. shakeball(pokeballanim)
  547. else
  548. for i = 1, _G.Shakes do
  549. shakeball(pokeballanim)
  550. end
  551.  
  552. end
  553. if _G.ShakeCheck == "Success" then
  554. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=202021887"
  555. p.PlayerGui.SoundEffect:Play()
  556. scrolltext(dialog,"Gotcha! "..theirpokeout.Name.." was caught!")
  557. wait(.25)
  558. pokeballanim.Visible = false
  559. elseif _G.ShakeCheck == "Fail" then
  560. flash.Visible = true
  561. wait(.1)
  562. theirpokemon.Visible = true
  563. pokeballanim.Visible = false
  564. flash.Visible = false
  565. scrolltext(dialog,thrownmsgs[_G.Shakes-1])
  566. end
  567. end
  568. --[[
  569. lame function
  570. --]]
  571. function findexp(poke)
  572. for i,v in ipairs(pokemonexpsplit) do
  573. if poke == v then
  574. return false
  575. end
  576. end
  577. return true
  578. end
  579.  
  580. function isType(poke,type)
  581. for i,v in pairs(_G.Pokemon[poke.Name]["Type"]) do
  582. if v == type then
  583. return true
  584. end
  585. end
  586. return false
  587. end
  588.  
  589. function isLevitating(pokemon)
  590. if isType(pokemon,"Flying") then
  591. return true
  592. end
  593. if _G.Pokemon[pokemon.Name]["Ability"] and _G.Pokemon[pokemon.Name]["Ability"] == "Levitate" then
  594. return true
  595. end
  596. return false
  597. end
  598.  
  599.  
  600. function poisonEntryHazard(pokemon,box)
  601. local TSpikes
  602. if box == "YourBox" then
  603. TSpikes = TSpikesFoe
  604. else
  605. TSpikes = TSpikesUser
  606. end
  607. if TSpikes > 0 then
  608. if not isLevitating(pokemon) then
  609. if not isType(pokemon,"Poison") and not isType(pokemon,"Steel") and pokemon.Status.Value == "" then
  610. if TSpikes == 1 then
  611. scrolltext(dialog,nickname(pokemon).." was poisoned by Toxic Spikes!")
  612. pokemon.Status.Value = "Poison"
  613. elseif TSpikes == 2 then
  614. scrolltext(dialog,nickname(pokemon).." was badly poisoned by Toxic Spikes!")
  615. pokemon.Status.Value = "BadlyPoison"
  616. end
  617. elseif isType(pokemon,"Poison") then
  618. scrolltext(dialog,nickname(pokemon).." absorbed the Toxic Spikes!")
  619. if box == "YourBox" then
  620. TSpikesFoe = 0
  621. else
  622. TSpikes = 0
  623. end
  624. end
  625. else
  626. end
  627. end
  628. --nothing...
  629. end
  630. --[[
  631. =============================
  632. Send Out
  633. =============================
  634. ]]--
  635. function pokemonout(pokeball,pokemon,box,pokeout)
  636. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476390"
  637. p.PlayerGui.SoundEffect:Play()
  638. pokeball.Image = _G.Sprites["Pokeball"][pokeout.Pokeball.Value]["Closed"]
  639. pokeball.Visible = true
  640. wait(.3)
  641. pokeball.Image = _G.Sprites["Pokeball"][pokeout.Pokeball.Value]["Open"]
  642. wait(.3)
  643. flash.Visible = true
  644. pokeball.Visible = false
  645.  
  646. if box.Name == "YourBox" then
  647. leechseeduser = false
  648. badpoisonUser = 0.0625
  649. poisonEntryHazard(pokeout,box)
  650. returnstats()
  651.  
  652. _G.getBackSprite(pokemon,pokeout)
  653. boxupdate(pokeout,box,true)
  654. wait(.1)
  655. flash.Visible = false
  656. poisonEntryHazard(pokeout,box)
  657. boxupdate(pokeout,box,true)
  658. for i,v in pairs(originalstats) do
  659. if i.Parent and i.Parent.Name == "PokemonParty" then
  660. originalstats[i] = nil
  661. end
  662. end
  663. if not Pokedex:Check(pokeout.Name,p) then
  664. Pokedex:Create(pokeout.Name,true)
  665. else
  666. Pokedex:Caught(pokeout.Name)
  667. end
  668. urconfusion = false
  669. confusion1 = nil
  670. usermod = {
  671. ["Atk"] = 0,
  672. ["Def"] = 0,
  673. ["SpA"] = 0,
  674. ["SpD"] = 0,
  675. ["Speed"] = 0,
  676. ["Acc"] = 0,
  677. ["Evade"] = 0
  678. }
  679. --print(pokeout.Name)
  680. if findexp(pokeout) then
  681. table.insert(pokemonexpsplit,pokeout)
  682. end
  683. flash.Visible = false
  684. else
  685. badpoisonOpp = 0.0625
  686. leechseedopp = false
  687. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476390"
  688. p.PlayerGui.SoundEffect:Play()
  689. pokemonexpsplit = {}
  690. table.insert(pokemonexpsplit,yourpokeout)
  691. theirconfusion = false
  692. confusion2 = nil
  693. oppmod = {
  694. ["Atk"] = 0,
  695. ["Def"] = 0,
  696. ["SpA"] = 0,
  697. ["SpD"] = 0,
  698. ["Speed"] = 0,
  699. ["Acc"] = 0,
  700. ["Evade"] = 0
  701. }
  702. leechseedopp = false
  703. --print(pokeout.Name)
  704. _G.getFrontSprite(pokemon,pokeout)
  705.  
  706. boxupdate(pokeout,box,false)
  707. if not Pokedex:Check(pokeout.Name,p,zol) and zol == nil then
  708. Pokedex:Create(pokeout.Name)
  709. end
  710. end
  711.  
  712. pokemon.Visible = true
  713. trainer.Visible = false
  714. wait(.1)
  715. flash.Visible = false
  716. poisonEntryHazard(pokeout,box)
  717. boxupdate(pokeout,box,false)
  718. wait(.3)
  719. if _G.Pokemon[pokeout.Name]["Ability"] then
  720. if _G.Pokemon[pokeout.Name]["Ability"] == "Pressure" then
  721. scrolltext(dialog,nickname(pokeout).." exerts its Pressure!")
  722. elseif _G.Pokemon[pokeout.Name]["Ability"] == "Intimidate" then
  723. scrolltext(dialog,nickname(pokeout).." is very intimdating!")
  724.  
  725. if box.Name == "YourBox" then
  726. oppmod["Atk"] = math.max(-6,oppmod["Atk"] - 1)
  727. if yourpokeout ~= nil then
  728. scrolltext(dialog,nickname(theirpokeout).."'s attack fell!")
  729. end
  730. else
  731. usermod["Atk"] = math.max(-6,usermod["Atk"] - 1)
  732. if yourpokeout ~= nil then
  733. scrolltext(dialog,nickname(yourpokeout).."'s attack fell!")
  734. end
  735. end
  736.  
  737. end
  738. end
  739. end
  740. --[[
  741. ===============================
  742. Foe Send Out Pokemon
  743. ===============================
  744. ]]--
  745.  
  746. function foereturnpokemon(pokeball,pokemonsprite,box,pokemon,sprite,name)
  747. scrolltext(dialog,sprite.." "..name.." sent out "..nickname(pokemon).."!")
  748. --theirparty.Visible = false
  749. pokemonout(pokeball,pokemonsprite,box,pokemon)
  750. return pokemon
  751. end
  752. --[[=============================
  753. Return Pokemon Animation
  754. =============================]]--
  755. function returnpokemon(pokeball,pokemonsprite,box,pokemon)
  756. changevisible(buttonholder,"TextButton",false)
  757. unactive = false
  758. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476390"
  759. p.PlayerGui.SoundEffect:Play()
  760. local msgs = {"Return, ","You did well, ","Good job, "}
  761. scrolltext(dialog,msgs[math.random(1,#msgs)]..nickname(yourpokeout).."!")
  762. flash.Visible = true
  763. pokemonsprite.Visible = false
  764. box.Visible = false
  765. wait(.1)
  766. flash.Visible = false
  767. scrolltext(dialog,"Go! "..nickname(pokemon).."!")
  768. DBuse = false
  769. if yourpokeout.Status.Value ~= "Faint" and _G.Pokemon[yourpokeout.Name]["Ability"] and _G.Pokemon[yourpokeout.Name]["Ability"] == "Natural Cure" then
  770. Math:StatusChange(yourpokeout,"")
  771. -- elseif yourpokeout.Status.Value ~= "Faint" and _G.Pokemon[yourpokeout.Name]["Ability"] and _G.Pokemon[yourpokeout.Name]["Ability"] == "Regenerator" then
  772. -- Math:hange(yourpokeout.CurrentHP, math.min(yourpokeout.Stats.HPStat.Value,yourpokeout.CurrentHP.Value+(math.floor(yourpokeout.Stats.HPStat.Value)/3)))
  773. end
  774. pokemonout(pokeball,pokemonsprite,box,pokemon)
  775. partycheck(yourparty)
  776. return pokemon
  777. end
  778. --[[
  779. ===================================
  780. Function: Update Health
  781. ===================================
  782. --]]
  783. local
  784. function updatehealth(box,poke,hpbefore,numanim) --set users to true to update HP Label
  785.  
  786. local timeWait = (poke.CurrentHP.Value/poke.Stats.HPStat.Value)
  787. box.HealthBG.Health:TweenSize(UDim2.new(findhealthbarsize(poke.CurrentHP.Value,poke.Stats.HPStat.Value),-2,1,-2),"Out","Quad",1,true)
  788. if box.Name == "YourBox" and numanim == nil then
  789. for hp = hpbefore, poke.CurrentHP.Value, -2 do
  790. box.HPLabel.Text = math.floor(hp).." / "..poke.Stats.HPStat.Value
  791. box.HPLabel.Shadow.Text = box.HPLabel.Text
  792. wait()
  793. end
  794. box.HPLabel.Text = poke.CurrentHP.Value.." / "..poke.Stats.HPStat.Value
  795. box.HPLabel.Shadow.Text = box.HPLabel.Text
  796. end
  797.  
  798. end
  799. --[[
  800. =========================
  801. UsedItem
  802. =========================
  803. --]]
  804. function useditem(item,pokemon)
  805. scrolltext(dialog,"You used "..item.." on ".. _G.nickname(pokemon).."!")
  806. if pokemon == yourpokeout then
  807. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476366"
  808. p.PlayerGui.SoundEffect:Play()
  809. updatehealth(ybox,pokemon,pokemon.CurrentHP.Value)
  810. boxupdate(pokemon,ybox,true)
  811. --else
  812. --itemhealth(pokemon,pokemon.CurrentHP.Value)
  813. end
  814. end
  815.  
  816. local EVItems = {
  817. ["Power Weight"] = "HP",
  818. ["Power Bracer"] = "Atk",
  819. ["Power Belt"] = "Def",
  820. ["Power Lens"] = "SpA",
  821. ["Power Band"] = "SpD",
  822. ["Power Anklet"] = "Speed",}
  823.  
  824. --[[
  825. function findlevel
  826. --]]
  827. --[[
  828. ======================
  829. Experience Bar
  830. ======================]]--
  831. --formula: a(wild = 1, trainer = 1.5) * baseexp * lvloffaint / 7*s(pokemon to have participated)
  832. function expupdate(PokeOut,timearound,ExpShare)
  833. local Share
  834. if ExpShare then
  835. Share = true
  836. end
  837. local ex = ybox.ExpBG.Exp --I'm lazy
  838. local experience = 32
  839. if PokeOut.Lvl.Value < 100 and zol == nil then
  840. if timearound == nil then
  841. experience = game.ReplicatedStorage.REvents.Internal.expValueGet:InvokeServer(
  842. {
  843. ["ExpShare"] = Share,
  844. ["Prefix"] = prefix,
  845. ["TheirPoke"] = theirpokeout.Name,
  846. ["Level"] = theirpokeout.Lvl.Value,
  847. ["InBattle"] = findexp(PokeOut)
  848. }
  849. )
  850. --ev calculation yo
  851. local totalev = 0
  852. for i,v in ipairs(PokeOut.EV:GetChildren()) do
  853. totalev = totalev + v.Value
  854. end
  855. if totalev >= 510 then
  856. else
  857.  
  858. for name,stat in pairs(_G.Pokemon[theirpokeout.Name]["EVYield"]) do
  859. for i,v in ipairs(PokeOut.EV:GetChildren()) do
  860. if (name.."EV") == v.Name then
  861. local statmod = stat
  862. if p.PokeBooster:FindFirstChild("EVs") and p.PokeBooster:FindFirstChild("EVs").Value > 0 then
  863. statmod = statmod*2
  864. end
  865. if totalev + statmod > 510 then
  866. statmod = 510-totalev
  867. end
  868. if v.Value + statmod >= 252 then
  869. Math:EVChanger(v,252)
  870. elseif v.Value + statmod < 252 then
  871. Math:EVChanger(v,v.Value + statmod)
  872. end
  873. end
  874. end
  875. end
  876. --Lazy.
  877. if PokeOut.HeldItem.Value ~= "" and EVItems[PokeOut.HeldItem.Value] ~= nil then
  878. local statmod = 4
  879. local v = PokeOut.EV[EVItems[PokeOut.HeldItem.Value].."EV"]
  880. if p.PokeBooster:FindFirstChild("EVs") and p.PokeBooster:FindFirstChild("EVs").Value > 0 then
  881. statmod = statmod*2
  882. end
  883. if totalev + statmod > 510 then
  884. statmod = 510-totalev
  885. end
  886. if v.Value + statmod >= 252 then
  887. Math:EVChanger(v,252)
  888. elseif v.Value + statmod < 252 then
  889. Math:EVChanger(v,v.Value + statmod)
  890. end
  891. end
  892. end
  893. --end ev calculation
  894. if type(experience) == "number" and experience > 0 then
  895. scrolltext(dialog, _G.nickname(PokeOut).." has gained "..dehash(experience).." exp!")
  896. end
  897. else
  898. experience = timearound
  899. end
  900. local expbefore = dehash(game.ReplicatedStorage.REvents.Internal.iopzx:InvokeServer(PokeOut))
  901. if expbefore + dehash(experience) > ExpTables[_G.Pokemon[PokeOut.Name]["ExpType"].."Exp"](PokeOut.Lvl.Value +1 ) then
  902.  
  903. game.ReplicatedStorage.REvents.Internal.fiaj:InvokeServer(PokeOut,hash(ExpTables[_G.Pokemon[PokeOut.Name]["ExpType"].."Exp"](PokeOut.Lvl.Value + 1)))
  904.  
  905. if yourpokeout == PokeOut then
  906. ex:TweenSize(UDim2.new(1,0,1,0),"Out","Quad",1.25)
  907. wait(1.65)
  908. ex.Size = UDim2.new(0,0,1,0)
  909. end
  910. local expleft = (dehash(experience) + expbefore) - (ExpTables[_G.Pokemon[PokeOut.Name]["ExpType"].."Exp"](PokeOut.Lvl.Value + 1))
  911.  
  912. levelup(PokeOut)
  913. expupdate(PokeOut,hash(expleft))
  914. elseif expbefore + dehash(experience) < ExpTables[_G.Pokemon[PokeOut.Name]["ExpType"].."Exp"](PokeOut.Lvl.Value + 1) then
  915.  
  916. local newexp = game.ReplicatedStorage.REvents.Internal.GetExp:InvokeServer(PokeOut,experience,"Yb58ByaIXKSIbY1qiqpmtqgiGKve5bhyLY3BA8Kp")
  917.  
  918. local value1 = ExpTables[_G.Pokemon[PokeOut.Name]["ExpType"].."Exp"](PokeOut.Lvl.Value)
  919. local value2 = ExpTables[_G.Pokemon[PokeOut.Name]["ExpType"].."Exp"](PokeOut.Lvl.Value + 1)
  920. local lvlblah = value2 - value1
  921. local nextlvl = value2 - dehash(newexp)
  922. local expbar = lvlblah - nextlvl
  923. if PokeOut == yourpokeout then
  924. ex:TweenSize(UDim2.new(findexpbarsize(expbar,lvlblah),0,1,0),"Out","Quad",1)
  925. wait(1)
  926. end
  927. end
  928. end
  929. end
  930.  
  931. --[[Calcualtion of Stats]]--
  932. function HPcalc(lvl,iv,ev,poke)
  933. return ((iv+2* _G.Pokemon[poke.Name]["Stats"]["HP"] +(ev/4))*lvl/100)+10+lvl
  934. end
  935.  
  936.  
  937.  
  938. function otherstatcalc(basestat,lvl,iv,ev,nature,poke)
  939. return (((iv+2*_G.Pokemon[poke.Name]["Stats"][basestat]+(ev/4))*lvl/100)+5) * nature
  940. end
  941.  
  942. function determinenature(stat,nature)
  943. if natureStats[stat.." Boost"][nature] then
  944. return 1.1
  945. elseif natureStats[stat.." Down"][nature] then
  946. return .9
  947. else return 1
  948. end
  949. end
  950. --[[
  951. Stupid Yes/No function
  952. --]]
  953. function yesno(movelearnt,pokie)
  954. local hold = battle.YesNoHolder
  955. local swagmove = movelearnt
  956. local deletevent
  957. YES = hold.Yes.MouseButton1Click:connect(function()
  958. changevisible(battle.YesNoHolder,"TextButton",false)
  959. scrolltext(dialog,"Which move should "..nickname(pokie).." forget?")
  960. moveappear(pokie,movelist,true)
  961. for i,v in ipairs(movelist:GetChildren()) do
  962. if v:IsA("TextButton") then
  963.  
  964. getfenv()["Delete"..v.Name] = v.MouseButton1Click:connect(function()
  965. movelist.Visible = false
  966. scrolltext(dialog,nickname(pokie).." forgot "..v.MoveName.Text.."...")
  967. scrolltext(dialog,nickname(pokie).." learned "..swagmove.."!")
  968. Math:MoveLearn(pokie,pokie.Moves[v.MoveName.Text],swagmove)
  969.  
  970. for i,v in ipairs(movelist:GetChildren()) do
  971. if getfenv()["Delete"..v.Name] then getfenv()["Delete"..v.Name]:disconnect() end
  972. if getfenv()["Enter"..v.Name] then getfenv()["Enter"..v.Name]:disconnect() end
  973.  
  974. end
  975. deletevent = true
  976. end)
  977. end
  978. end
  979. end)
  980. NO = hold.No.MouseButton1Click:connect(function()
  981. changevisible(battle.YesNoHolder,"TextButton",false)
  982. scrolltext(dialog,nickname(pokie).." did not learn "..swagmove..".")
  983. deletevent = true
  984. end)
  985. repeat wait() until deletevent ~= nil
  986. if YES then YES:disconnect() end if NO then NO:disconnect() end
  987. end
  988.  
  989. --[[
  990. ================================
  991. Level Up
  992. ================================
  993. --]]
  994. local stats = {"HP","Atk","Def","SpA","SpD","Speed"}
  995. function levelup(POKIE)
  996. soundeffect.SoundId = "http://www.roblox.com/asset/?id=201468177"
  997. soundeffect:Play()
  998. Math:NeoPill(POKIE)
  999. if _G.Pokemon[POKIE.Name]["Evolution"][1] ~= nil and tonumber(_G.Pokemon[POKIE.Name]["Evolution"][1]) ~= nil and Evolution[POKIE] ~= true then
  1000. local evolvl = _G.Pokemon[POKIE.Name]["Evolution"][1]
  1001. if evolvl <= POKIE.Lvl.Value then
  1002. Evolution[POKIE] = true
  1003. end
  1004. end
  1005. for i,v in ipairs(POKIE.Stats:GetChildren()) do
  1006. if getfenv()[v.Name] then getfenv()[v.Name] = nil end
  1007. getfenv()[v.Name] = v.Value
  1008. end
  1009. if originalstats[POKIE] == nil then
  1010. Math:StatChange(POKIE)
  1011. end
  1012. if originalstats[POKIE] == nil then
  1013. for i,v in ipairs(POKIE.Stats:GetChildren()) do
  1014. for _,label in ipairs(stats) do
  1015. if label.."Stat" == v.Name then
  1016. battle.LevelUpBG[label].Text = "+"..v.Value-getfenv()[v.Name]
  1017. end
  1018. end
  1019. end
  1020. else
  1021. for i,v in pairs(originalstats[POKIE]["Stats"]) do
  1022. for _,label in ipairs(stats) do
  1023. if label.."Stat" == i then
  1024. if label == "HP" then
  1025.  
  1026. getfenv()[label.."2nd"] = originalstats[POKIE]["Stats"][label.."Stat"]
  1027. originalstats[POKIE]["Stats"][label.."Stat"] = math.floor(HPcalc(POKIE.Lvl.Value,POKIE.IV[label.."IV"].Value,POKIE.EV[label.."EV"].Value,POKIE)+.5)
  1028. else
  1029.  
  1030. getfenv()[label.."2nd"] = originalstats[POKIE]["Stats"][label.."Stat"]
  1031. originalstats[POKIE]["Stats"][label.."Stat"] = math.floor(otherstatcalc(label,POKIE.Lvl.Value,POKIE.IV[label.."IV"].Value,POKIE.EV[label.."EV"].Value,determinenature(label,POKIE.Nature.Value),POKIE)+.5)
  1032. end
  1033. local newvalue = originalstats[POKIE]["Stats"][label.."Stat"]-getfenv()[label.."2nd"]
  1034.  
  1035. battle.LevelUpBG[label].Text = "+"..newvalue
  1036. --Mathhhange(POKIE.Stats[label.."Stat"],POKIE.Stats[label.."Stat"].Value+newvalue)
  1037.  
  1038. end
  1039. end
  1040. end
  1041. end
  1042. --Math:hange(POKIE.CurrentHP,POKIE.CurrentHP.Value+(POKIE.Stats.HPStat.Value-getfenv()["HPStat"]))
  1043. if POKIE == yourpokeout then
  1044. boxupdate(yourpokeout,ybox,true,true)
  1045. end
  1046. scrolltext(dialog,nickname(POKIE).." grew to Lv. "..POKIE.Lvl.Value.."!")
  1047. battle.LevelUpBG.Visible = true
  1048. local useraction = false
  1049. nextevent = battle.LevelUpBG.Next.MouseButton1Click:connect(function()
  1050. useraction = not useraction end)
  1051. repeat wait() until useraction == true
  1052. for i,v in ipairs(POKIE.Stats:GetChildren()) do
  1053. for _,label in ipairs(stats) do
  1054. if label.."Stat" == v.Name then
  1055. battle.LevelUpBG[label].Text = v.Value
  1056. end
  1057. end
  1058. end
  1059. repeat wait() until useraction == false
  1060. nextevent:disconnect()
  1061. battle.LevelUpBG.Visible = false
  1062. if _G.Pokemon[POKIE.Name]["Moves"]["LevelUp"][POKIE.Lvl.Value] ~= nil then
  1063. for _,derp in ipairs(_G.Pokemon[POKIE.Name]["Moves"]["LevelUp"][POKIE.Lvl.Value]) do
  1064. local moveslots = POKIE.Moves:GetChildren()
  1065. local movelearnt = derp
  1066. --print(movelearnt)
  1067. if not POKIE.Moves:FindFirstChild(derp) then
  1068. if #moveslots < 4 then
  1069. Battle:NewMove(POKIE,movelearnt)
  1070. scrolltext(dialog,nickname(POKIE).." learned "..movelearnt.."!")
  1071. elseif #moveslots == 4 then
  1072. scrolltext(dialog,nickname(POKIE).." is trying to learn "..movelearnt..".")
  1073. scrolltext(dialog,"But "..nickname(POKIE).." can't learn more than four moves.")
  1074. scrolltext(dialog,"Delete a move to make room for "..movelearnt.."?")
  1075. wait(.5)
  1076. changevisible(battle.YesNoHolder,"TextButton",true)
  1077. yesno(movelearnt,POKIE)
  1078. end
  1079. end
  1080. end
  1081. end
  1082. end
  1083. --[[
  1084. Evolution Animation
  1085. --]]
  1086. function evolanim(pokecfg,pokeimage,prename,evolvedPoke)
  1087. for i = .6, .1, -.1 do
  1088. pokeimage:TweenSizeAndPosition(UDim2.new(0,0,0,0),UDim2.new(0.5, 64,0.5, 64),"Out","Quad",i,true)
  1089. wait(i)
  1090. pokeimage:TweenSizeAndPosition(UDim2.new(0,256,0,256),UDim2.new(0.5,-128,.5,-128),"Out","Quad",i,true)
  1091. wait(i)
  1092. end
  1093. pokeimage:TweenSizeAndPosition(UDim2.new(0,0,0,0),UDim2.new(0.5, 64,0.5, 64),"Out","Quad",.1,true)
  1094. wait(.25)
  1095. _G.getFrontSprite(pokeimage,pokecfg)
  1096.  
  1097. pokeimage:TweenSizeAndPosition(UDim2.new(0,256,0,256),UDim2.new(0.5,-128,.5,-128))
  1098. return _G.Pokemon[pokecfg.Name]["Evolution"][2]
  1099. end
  1100. --[[Evolving Move Function
  1101. ]]
  1102. function moveevolve(pokecfg)
  1103. changevisible(evolvescreen.EvolveDialog.MovesBG,"TextButton",false)
  1104. for _,dero in ipairs(pokecfg.Moves:GetChildren()) do
  1105. for duh, moves in ipairs(evolvescreen.EvolveDialog.MovesBG:GetChildren()) do
  1106. if tonumber(moves.Name:sub(5,5)) == dero.Value then
  1107. moves.MoveName.Text = dero.Name
  1108. local color = _G.Tables["TypeColors"][_G.Moves[dero.Name]["Type"]]
  1109. moves.BackgroundColor3 = color
  1110. moves.Category.Text = _G.Moves[dero.Name]["AttackType"]
  1111. moves.Type.BackgroundColor3 = Color3.new(color.r-.16,color.g-.16,color.b-.16)
  1112. moves.Type.Text = _G.Moves[dero.Name]["Type"]
  1113. moves.PP.Text = pokecfg.Moves:FindFirstChild(dero.Name).PP.Value.." / ".._G.Moves[dero.Name]["PP"]
  1114. moves.Visible = true
  1115. end
  1116. end
  1117. end
  1118. evolvescreen.EvolveDialog.MovesBG.Visible = true
  1119. end
  1120.  
  1121. --[[
  1122. EvolutionAfterBattleFunction >:)
  1123. --]]
  1124.  
  1125.  
  1126. function EvolvingTime(pokecfg)
  1127. yourpokeout = pokecfg
  1128. battle.Visible = false
  1129. eaction = nil
  1130. local prename = pokecfg.Name
  1131. if pokecfg.Status.Value ~= "Faint" then
  1132. evolvescreen.EvolveDialog.Speak.Text = ""
  1133. evolvescreen.EvolveDialog.Speak.dropshadow.Text = ""
  1134. _G.getFrontSprite(evolvescreen.PokeImage,pokecfg)
  1135.  
  1136. evolvescreen.Visible = true
  1137. scrolltext(evolvescreen.EvolveDialog.Speak, _G.nickname(pokecfg).." is about to evolve. Proceed with this?")
  1138. wait(.6)
  1139. evolvescreen.YesNoHolder.Yes.Visible = true
  1140. evolvescreen.YesNoHolder.No.Visible = true
  1141. yesevolution = evolvescreen.YesNoHolder.Yes.MouseButton1Click:connect(function()
  1142. evolvescreen.YesNoHolder.Yes.Visible = false
  1143. evolvescreen.YesNoHolder.No.Visible = false
  1144. local evolvedPoke = Battle:EvolveCheck(pokecfg,pokecfg.Lvl.Value)
  1145. if evolvedPoke then
  1146. local sound = p.PlayerGui.BattleSound
  1147. sound:Stop()
  1148. sound.SoundId = "http://www.roblox.com/asset/?id=172784223"
  1149. sound:Play()
  1150. scrolltext(evolvescreen.EvolveDialog.Speak,"Congrats! Your "..((pokecfg:FindFirstChild("Nickname") and pokecfg:FindFirstChild("Nickname").Value) or prename).." evolved...")
  1151. local evolvedpoke = evolanim(pokecfg,evolvescreen.PokeImage,prename,evolvedPoke)
  1152. scrolltext(evolvescreen.EvolveDialog.Speak,"...Into "..evolvedPoke.."!")
  1153.  
  1154. Math:StatChange(pokecfg)
  1155. wait(.6)
  1156. if not Pokedex:Check(pokecfg.Name,p) then
  1157. Pokedex:Create(pokecfg.Name,true)
  1158. else
  1159. Pokedex:Caught(pokecfg.Name)
  1160. end
  1161. if _G.Pokemon[pokecfg.Name]["Moves"]["LevelUp"][pokecfg.Lvl.Value] ~= nil then
  1162. for _,newmove in pairs(_G.Pokemon[pokecfg.Name]["Moves"]["LevelUp"][pokecfg.Lvl.Value]) do
  1163. if not pokecfg.Moves:FindFirstChild(newmove) then
  1164. if #pokecfg.Moves:GetChildren() < 4 then
  1165. scrolltext(evolvescreen.EvolveDialog.Speak,pokecfg.Name.." learned "..newmove.."!")
  1166. Battle:NewMove(pokecfg,newmove)
  1167. eaction = true
  1168. elseif #pokecfg.Moves:GetChildren() == 4 then
  1169. yesevolution:disconnect()
  1170. noevolution:disconnect()
  1171. scrolltext(evolvescreen.EvolveDialog.Speak,pokecfg.Name.." is trying to learn "..newmove..".")
  1172. wait(.5)
  1173. scrolltext(evolvescreen.EvolveDialog.Speak,"But "..pokecfg.Name.." can't learn more than four moves.")
  1174. wait(.5)
  1175. scrolltext(evolvescreen.EvolveDialog.Speak,"Delete a move to make room for "..newmove.."?")
  1176. wait(.5)
  1177. evolvescreen.YesNoHolder.Yes.Visible = true
  1178. evolvescreen.YesNoHolder.No.Visible = true
  1179. if yesmove then yesmove:disconnect()end
  1180. if nomove then nomove:disconnect() end
  1181. yesmove = evolvescreen.YesNoHolder.Yes.MouseButton1Click:connect(function()
  1182.  
  1183. evolvescreen.YesNoHolder.Yes.Visible = false
  1184. evolvescreen.YesNoHolder.No.Visible = false
  1185. moveevolve(pokecfg)
  1186. for _,v in ipairs(evolvescreen.EvolveDialog.MovesBG:GetChildren()) do
  1187. if v:IsA("TextButton") then
  1188. getfenv()["DeleteDerp"..v.Name] = v.MouseButton1Click:connect(function()
  1189. changevisible(evolvescreen.EvolveDialog.MovesBG,"TextButton",false)
  1190. scrolltext(evolvescreen.EvolveDialog.Speak,pokecfg.Name.." forgot "..v.MoveName.Text.."...")
  1191. scrolltext(evolvescreen.EvolveDialog.Speak,pokecfg.Name.." learned "..newmove.."!")
  1192. Math:MoveLearn(pokecfg,pokecfg.Moves[v.MoveName.Text],newmove)
  1193.  
  1194. eaction = true
  1195. for i,v in ipairs(evolvescreen.EvolveDialog.MovesBG:GetChildren()) do
  1196. if getfenv()["DeleteDerp"..v.Name] then getfenv()["DeleteDerp"..v.Name]:disconnect() end
  1197. end
  1198. end)
  1199. end
  1200. end
  1201.  
  1202. --eaction = true
  1203. end)
  1204. nomove = evolvescreen.YesNoHolder.No.MouseButton1Click:connect(function()
  1205. evolvescreen.YesNoHolder.Yes.Visible = false
  1206. evolvescreen.YesNoHolder.No.Visible = false
  1207. scrolltext(evolvescreen.EvolveDialog.Speak,pokecfg.Name.." did not learn "..newmove..".")
  1208. eaction = true
  1209. evolvescreen.Visible = false
  1210. end)
  1211. end
  1212. else eaction = true
  1213. end
  1214. end
  1215. else
  1216. eaction = true
  1217. evolvescreen.Visible = false
  1218. end
  1219. Evolution[pokecfg] = nil
  1220. else
  1221. eaction = true
  1222. evolvescreen.Visible = false
  1223. end
  1224. end)
  1225. noevolution = evolvescreen.YesNoHolder.No.MouseButton1Click:connect(function()
  1226. evolvescreen.YesNoHolder.Yes.Visible = false
  1227. evolvescreen.YesNoHolder.No.Visible = false
  1228. scrolltext(evolvescreen.EvolveDialog.Speak,pokecfg.Name.." didn't evolve.")
  1229. evolvescreen.Visible = false
  1230. eaction = true
  1231. Evolution[pokecfg] = nil
  1232. end)
  1233. else
  1234. eaction = false
  1235. end
  1236. repeat wait() until eaction ~= nil
  1237. if yesevolution then
  1238. yesevolution:disconnect()
  1239. end
  1240. if yesevolution then
  1241. noevolution:disconnect()
  1242. end
  1243. if yesmove then
  1244. yesmove:disconnect()
  1245. end
  1246. if nomove then
  1247. nomove:disconnect()
  1248. end
  1249. evolvescreen.YesNoHolder.Yes.Visible = false
  1250. evolvescreen.YesNoHolder.No.Visible = false
  1251. evolvescreen.Visible = false
  1252. end
  1253.  
  1254. function evolutionchecker()
  1255. for i,v in ipairs(userteam:GetChildren()) do
  1256. if Evolution[v] then
  1257. EvolvingTime(v)
  1258. end
  1259. end
  1260. end
  1261. --[[
  1262. ==================================
  1263. Check For Faint FaintFunction <-- Search for that
  1264. ==================================
  1265. --]]
  1266. function checkfaint(poke,foe)
  1267. if poke.CurrentHP.Value <= 0 or poke.CurrentHP.Value > poke.Stats.HPStat.Value then
  1268. poke.Status.Value = "Faint"
  1269. if foe == true then
  1270. scrolltext(dialog,"The "..prefix.." ".._G.nickname(poke).." fainted!")
  1271. theirpokemon:TweenPosition(UDim2.new(0, 0, 1, 0),"Out","Quad",.75)
  1272. wait(.45)
  1273. tbox.Visible = false
  1274. theirpokemon.Visible = false
  1275. theirpokefaint = true
  1276. if prefix ~= "wild" then
  1277. partycheck(theirparty)
  1278. end
  1279. else
  1280. scrolltext(dialog,_G.nickname(poke).." fainted!")
  1281. yourpokemon:TweenPosition(UDim2.new(0,0,1,0),"Out","Quad",.75)
  1282. wait(1)
  1283. yourpokemon.Visible = false
  1284. yourpokemon.Position = UDim2.new(0,0,1,0)
  1285. yourpokefaint = true
  1286. partycheck(yourparty)
  1287. end
  1288. end
  1289. end
  1290. --[[
  1291. ==================================
  1292. Animates the Pokemon, Animation = "Bobbing"
  1293. ==================================
  1294. --]]
  1295. function animatepoke(poke)
  1296. unactive = true
  1297. coroutine.resume(coroutine.create(function()
  1298. while unactive == true do
  1299. poke.Position = UDim2.new(0, 0, 0.25, 0)
  1300. wait(.2)
  1301. poke.Position = UDim2.new(0, 0, .25, -2)
  1302. wait(.05)
  1303. end
  1304. poke.Position = UDim2.new(0, 0, 0.25, 0)
  1305. end))
  1306. end
  1307. --[[
  1308. ==================================
  1309. Makes the Move List Appear. M1
  1310. ==================================
  1311. --]]
  1312. function moveappear(yourpoke,movelist,thing)
  1313. if thing == nil then
  1314. battle.ButtonHolder.Back.Visible=true
  1315. battle.ButtonHolder.Back.MouseButton1Click:connect(function()
  1316. buttonholder.MegaEvolve.Position = UDim2.new(0.25, 0,1, 0)
  1317. battle.ButtonHolder.Back.Visible = false
  1318. movelist.Visible = false
  1319. for happy = 1, 4 do
  1320. if getfenv()["Enter"..happy] ~= nil then
  1321. getfenv()["Enter"..happy]:disconnect()
  1322. end
  1323. if getfenv()["blah"..happy] ~= nil then
  1324. getfenv()["blah"..happy]:disconnect()
  1325. end
  1326. end
  1327. dialog.Text = "What should "..nickname(yourpoke).." do?"
  1328. dropshadowdialog.Text = dialog.Text
  1329. changevisible(buttonholder,"TextButton",true)
  1330. end)
  1331. end
  1332. changevisible(movelist,"TextButton",false)
  1333. local moves = yourpoke.Moves:GetChildren()
  1334. fixmoves(yourpoke)
  1335. for i = 1, #moves do
  1336. for index,v in ipairs(moves) do
  1337. if i == v.Value then
  1338.  
  1339. movelist:FindFirstChild("Move"..i).CrossHolder.Visible = false
  1340. movelist:FindFirstChild("Move"..i).MoveName.Text = v.Name
  1341. local color = _G.Tables["TypeColors"][_G.Moves[v.Name]["Type"]]
  1342. movelist:FindFirstChild("Move"..i).BackgroundColor3 = color
  1343. movelist:FindFirstChild("Move"..i).Category.Text = _G.Moves[movelist:FindFirstChild("Move"..i).MoveName.Text]["AttackType"]
  1344. movelist:FindFirstChild("Move"..i).Type.BackgroundColor3 = Color3.new(color.r-.16,color.g-.16,color.b-.16)
  1345. movelist:FindFirstChild("Move"..i).Type.Text = _G.Moves[v.Name]["Type"]
  1346. movelist:FindFirstChild("Move"..i).PP.Text = yourpoke.Moves:FindFirstChild(v.Name).PP.Value.." / ".._G.Moves[v.Name]["PP"]
  1347. if TauntUser > 0 then
  1348. if _G.Moves[movelist:FindFirstChild("Move"..i).MoveName.Text]["AttackType"] == "Status"then
  1349. movelist:FindFirstChild("Move"..i).CrossHolder.Visible = true
  1350. end
  1351. end
  1352. movelist:FindFirstChild("Move"..i).Visible = true
  1353. movelist.Visible = true
  1354. end
  1355. end
  1356. end
  1357. end
  1358. --[[
  1359. ==================================
  1360. Calculate if it's a critical hit or not.
  1361. ==================================
  1362. --]]
  1363. local abilitydenier = {
  1364. ["Teravolt"] = true,
  1365. ["Turboblaze"] = true,
  1366. ["Mold Breaker"] = true
  1367. }
  1368. function critfunc(critchance,attacker,defender)
  1369. local critblah = math.random(0,1000)
  1370. local actualcrit = critchance
  1371. if _G.Pokemon[attacker.Name]["Ability"] and _G.Pokemon[attacker.Name]["Ability"] == "Super Luck" then
  1372. actualcrit = actualcrit * 2
  1373.  
  1374.  
  1375. end
  1376. if abilitydenier[_G.Pokemon[attacker.Name]["Ability"]] == nil then
  1377. if _G.Pokemon[defender.Name]["Ability"] and _G.Pokemon[defender.Name]["Ability"] == "Battle Armor" then
  1378. return 1
  1379. end
  1380. if _G.Pokemon[defender.Name]["Ability"] and _G.Pokemon[defender.Name]["Ability"] == "Shell Armor" then
  1381. return 1
  1382. end
  1383. end
  1384. if critblah <= actualcrit then
  1385. return 2
  1386. else return 1
  1387. end
  1388. end
  1389. --[[
  1390. ==================================
  1391. Determines if the move actually hits.
  1392. ==================================
  1393. --]]
  1394. function accfunc(move,attackeracc,defenderevasion,attacker,defender)
  1395. local accrandom = math.random(1,100)
  1396. local moveacc = _G.Moves[move]["Accuracy"]
  1397. if moveacc == true then --Always accurate moves such as Aerial Ace
  1398. return true
  1399. end
  1400. if attacker.HeldItem.Value == "Wide Lens" then
  1401. moveacc = moveacc+math.floor(moveacc/10)
  1402. end
  1403. if _G.Pokemon[attacker.Name]["Ability"] == "Compound Eyes" then
  1404. moveacc = moveacc*1.3
  1405. end
  1406. local chance = math.ceil((moveacc) * (accstat[attackeracc]*(evadestat[defenderevasion])))
  1407. if accrandom <= chance then
  1408. return true
  1409. else return false
  1410. end
  1411. end
  1412.  
  1413. local Encrypt = function(CodeSource)
  1414. local StringCode = '';
  1415. for i = 1, #CodeSource do
  1416. StringCode = StringCode ..string.char(48)..string.byte(string.sub(CodeSource,i,i));
  1417. end
  1418. return StringCode;
  1419. end
  1420.  
  1421. _G.PlayingCheckers = function(pokemon,owner,lvl,given,perfect,quality)
  1422. local statholder = game.ReplicatedStorage.REvents.Pokemon.iwillknowXD:InvokeServer(pokemon,owner,lvl,given,perfect,Encrypt(p.Name..lvl..pokemon))
  1423. repeat wait() until statholder ~= nil
  1424. statholder.Parent = owner
  1425. return statholder
  1426. end
  1427. --[[
  1428. =============================================
  1429. Poison/Burn Functions
  1430. ==============================================
  1431. --]]
  1432.  
  1433. function getExperience()
  1434. for index,buh in pairs(pokemonexpsplit) do
  1435. if buh.Status.Value == "Faint" then
  1436. rawset(pokemonexpsplit,index,nil)
  1437. end
  1438. end
  1439. amountofpokes = #pokemonexpsplit
  1440. if p.Bag.Evolution:FindFirstChild("Exp. Share") and p.Bag.Evolution:FindFirstChild("Exp. Share").Value == true then
  1441. local exptable = {}
  1442. for i,v in ipairs(p.PokemonParty:GetChildren()) do
  1443. if v.Status.Value ~= "Faint" then
  1444. exptable[v.PartyPosition.Value] = v
  1445. end
  1446. end
  1447. for z,pokemonexp in pairs(exptable) do
  1448. expupdate(pokemonexp,nil,pokemonexpsplit)
  1449. end
  1450.  
  1451. else
  1452. for z,pokemonexp in pairs(pokemonexpsplit) do
  1453. expupdate(pokemonexp)
  1454. end
  1455. end
  1456. pokemonexpsplit = {}
  1457. end
  1458.  
  1459. function losehealth(percentage,pokecfg,foe,msg)
  1460. local dmgtaken = math.ceil(pokecfg.Stats.HPStat.Value*percentage)
  1461. local hpbefore = pokecfg.CurrentHP.Value
  1462. if pokecfg.CurrentHP.Value - dmgtaken <= 0 then
  1463. Math:Faint(pokecfg)
  1464. if foe == true then
  1465. scrolltext(dialog,"The "..prefix.." "..pokecfg.Name..msg,true)
  1466. theirpokemon.Visible = false
  1467. wait(.1)
  1468. theirpokemon.Visible = true
  1469. updatehealth(tbox,pokecfg,pokecfg.CurrentHP.Value)
  1470. checkfaint(pokecfg,true)
  1471. getExperience()
  1472. else
  1473. scrolltext(dialog,nickname(pokecfg)..msg,true)
  1474. yourpokemon.Visible = false
  1475. wait(.1)
  1476. yourpokemon.Visible = true
  1477. updatehealth(ybox,pokecfg,pokecfg.CurrentHP.Value)
  1478. checkfaint(pokecfg,false)
  1479. end
  1480. elseif pokecfg.CurrentHP.Value - dmgtaken > 0 then
  1481. Math:TakeDamage(pokecfg,pokecfg.CurrentHP.Value - dmgtaken)
  1482. if foe == true then
  1483. scrolltext(dialog,"The "..prefix.." "..pokecfg.Name..msg,true)
  1484. theirpokemon.Visible = false
  1485. wait(.1)
  1486. theirpokemon.Visible = true
  1487. updatehealth(tbox,pokecfg,pokecfg.CurrentHP.Value)
  1488. else
  1489. scrolltext(dialog,nickname(pokecfg)..msg,true)
  1490. yourpokemon.Visible = false
  1491. wait(.1)
  1492. yourpokemon.Visible = true
  1493. updatehealth(ybox,pokecfg,pokecfg.CurrentHP.Value)
  1494. end
  1495. end
  1496. end
  1497. --[[
  1498. ===================================
  1499. Confusion Check
  1500. ===================================
  1501. --]]
  1502. function confusedcheck(pokemon,foe,variable)
  1503.  
  1504. if variable == true and (confusion1 ~= nil or confusion2 ~= nil) and pokemon.Status.Value ~= "Sleep" and pokemon.Status.Value ~= "Freeze" then
  1505.  
  1506. local confusecheck = math.random(1,100)
  1507. if foe == true then
  1508. if confusion2 == 0 then
  1509. theirconfusion = false
  1510. confusion2 = nil
  1511. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." snapped out of confusion!")
  1512. else
  1513. confusion2 = confusion2 - 1
  1514. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." is confused!")
  1515. if confusecheck > 50 then
  1516. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." hits itself with confusion!")
  1517. local dmgconf,we,critderp = dmgcalculate(pokemon,pokemon,"ConfusedAttack",oppmod["Atk"],oppmod["Def"],1)
  1518. local hpbefore = pokemon.CurrentHP.Value
  1519. if hpbefore - dmgconf <= 0 then
  1520. Math:Faint(pokemon)
  1521. theirpokemon.Visible = false
  1522. wait(.1)
  1523. theirpokemon.Visible = true
  1524. updatehealth(tbox,pokemon,pokemon.CurrentHP.Value)
  1525. checkfaint(pokemon,true)
  1526. elseif hpbefore - dmgconf > 0 then
  1527. Math:TakeDamage(pokemon,pokemon.CurrentHP.Value - dmgconf)
  1528. theirpokemon.Visible = false
  1529. wait(.1)
  1530. theirpokemon.Visible = true
  1531. updatehealth(tbox,pokemon,pokemon.CurrentHP.Value)
  1532. end
  1533. return true
  1534. else
  1535. return false
  1536. end
  1537. end
  1538.  
  1539. else
  1540. if confusion1 == 0 then
  1541. urconfusion = false
  1542. confusion1 = nil
  1543. scrolltext(dialog,nickname(pokemon).." snapped out of confusion!")
  1544. return false
  1545. else
  1546. confusion1 = confusion1 - 1
  1547. scrolltext(dialog,nickname(pokemon).." is confused!")
  1548. if confusecheck > 50 then
  1549. scrolltext(dialog,nickname(pokemon).." hits itself with confusion!")
  1550. dmgconf,we,critderp = dmgcalculate(pokemon,pokemon,"ConfusedAttack",usermod["Atk"],usermod["Def"],1)
  1551. local hpbefore = pokemon.CurrentHP.Value
  1552. if hpbefore - dmgconf <= 0 then
  1553. Math:Faint(pokemon)
  1554. yourpokemon.Visible = false
  1555. wait(.1)
  1556. yourpokemon.Visible = true
  1557. updatehealth(ybox,pokemon,pokemon.CurrentHP.Value)
  1558. checkfaint(pokemon,false)
  1559. elseif hpbefore - dmgconf > 0 then
  1560. Math:TakeDamage(pokemon,pokemon.CurrentHP.Value - dmgconf)
  1561. yourpokemon.Visible = false
  1562. wait(.1)
  1563. yourpokemon.Visible = true
  1564. updatehealth(ybox,pokemon,pokemon.CurrentHP.Value)
  1565. end
  1566. return true
  1567. else
  1568. return false
  1569. end
  1570. end
  1571. end
  1572. end
  1573. return false
  1574. end
  1575. --[[
  1576. ===================================
  1577. Paralyze Check
  1578. ===================================
  1579. --]]
  1580. function paralyzecheck(pokemon,foe)
  1581. local prachec = math.random(1,100)
  1582. if pokemon.Status.Value == "Paralysis" then
  1583. if prachec <= 25 then
  1584. if foe == true then
  1585. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." was fully paralyzed!")
  1586. return true
  1587. else
  1588. scrolltext(dialog,nickname(pokemon).." was fully paralyzed!")
  1589. return true
  1590. end
  1591. end
  1592. return false
  1593. end
  1594. return false
  1595. end
  1596. --[[
  1597. ===================================
  1598. Freeze Check
  1599. ===================================
  1600. --]]
  1601. function freezecheck(pokemon,foe)
  1602. local frecheck = math.random(1,100)
  1603. if pokemon.Status.Value == "Freeze" then
  1604. if frecheck <= 20 then
  1605. if foe == true then
  1606. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." thawed out!")
  1607. pokemon.Status.Value = ""
  1608. Math:StatusChange(pokemon,"")
  1609. tbox.Status.Visible = false
  1610. return false
  1611. else
  1612. scrolltext(dialog,nickname(pokemon).." thawed out!")
  1613. Math:StatusChange(pokemon,"")
  1614. ybox.Status.Visible = false
  1615. return false
  1616. end
  1617. end
  1618. if foe == true then
  1619. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." is frozen solid!")
  1620. return true
  1621. else
  1622. scrolltext(dialog,nickname(pokemon).." is frozen solid!")
  1623. return true
  1624. end
  1625. end
  1626. return false
  1627. end
  1628. --[[
  1629. ==================================================
  1630. Sleep Check
  1631. ==================================================
  1632. --]]
  1633. function sleepcheck(pokemon,foe)
  1634. if getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] == nil then
  1635. getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] = math.random(2,4)
  1636. end
  1637. if pokemon.Status.Value == "Sleep" then
  1638. if foe == true then
  1639. getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] = getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] - 1
  1640. if getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] == 0 then
  1641. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." woke up!")
  1642. Math:StatusChange(pokemon,"")
  1643. tbox.Status.Visible = false
  1644. getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] = nil
  1645. return false
  1646. else
  1647. scrolltext(dialog,"The "..prefix.." "..pokemon.Name.." is fast asleep.")
  1648. return true
  1649. end
  1650. else
  1651. getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] = getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value]- 1
  1652. if getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] == 0 then
  1653. scrolltext(dialog,nickname(pokemon).." woke up!")
  1654. Math:StatusChange(pokemon,"")
  1655. ybox.Status.Visible = false
  1656. getfenv()["Sleep"..pokemon.Name..pokemon.Nature.Value] = nil
  1657. return false
  1658. else
  1659. scrolltext(dialog,nickname(pokemon).." is fast asleep.")
  1660. return true
  1661. end
  1662. end
  1663. end
  1664.  
  1665.  
  1666.  
  1667. return false
  1668. end
  1669. --[[
  1670. ==================================
  1671. Determines which Pokemon is Faster.
  1672. ==================================
  1673. --]]
  1674. function speedcalc(Poke1,Poke2,Poke1Move,Poke2Move,Poke1Mod,Poke2Mod)
  1675. local Para1 = 1
  1676. local Para2 = 1
  1677. local Poke1Prior = 0
  1678. local Poke2Prior = 0
  1679. if Poke1.Status.Value == "Paralysis" then
  1680. Para1 = .5
  1681. end
  1682. if Poke2.Status.Value == "Paralysis" then
  1683. Para2 = .5
  1684. end
  1685. if _G.Moves[Poke1Move]["Priority"] ~= nil then
  1686. Poke1Prior = _G.Moves[Poke1Move]["Priority"]
  1687. end
  1688. if _G.Moves[Poke2Move]["Priority"] ~= nil then
  1689. Poke2Prior = _G.Moves[Poke2Move]["Priority"]
  1690. end
  1691. if _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Prankster" and _G.Moves[Poke1Move]["AttackType"] == "Status" then
  1692. Poke1Prior = Poke1Prior + 1
  1693. end
  1694. if _G.Pokemon[Poke2.Name]["Ability"] and _G.Pokemon[Poke2.Name]["Ability"] == "Prankster" and _G.Moves[Poke2Move]["AttackType"] == "Status" then
  1695. Poke2Prior = Poke2Prior + 1
  1696. end
  1697. local Poke1Speed = Poke1.Stats.SpeedStat.Value * modifierstat[Poke1Mod] * Para1
  1698. local Poke2Speed = Poke2.Stats.SpeedStat.Value * modifierstat[Poke2Mod] * Para2
  1699. --print(Poke1.Name,Poke1Speed,Poke2.Name,Poke2Speed)
  1700. if Poke1Prior > Poke2Prior then
  1701. return Poke1, Poke1Move, Poke2, Poke2Move
  1702. elseif Poke2Prior > Poke1Prior then
  1703. return Poke2, Poke2Move, Poke1,Poke1Move
  1704. elseif Poke1Prior == Poke2Prior then
  1705. if Poke1Speed > Poke2Speed then
  1706. return Poke1, Poke1Move, Poke2, Poke2Move
  1707. elseif Poke1Speed < Poke2Speed then
  1708. return Poke2, Poke2Move, Poke1,Poke1Move
  1709. elseif Poke1Speed == Poke2Speed then
  1710. local rundum = math.random(1,2)
  1711. if rundum == 1 then
  1712. return Poke1,Poke1Move, Poke2, Poke2Move
  1713. elseif rundum == 2 then
  1714. return Poke2,Poke2Move, Poke1, Poke1Move
  1715. end
  1716. end
  1717. end
  1718. end
  1719. --=================================
  1720. --[[Recoil]]
  1721. --=================================
  1722. function recoil(pokecfg,rate,foebool,move)
  1723. local dmgtaken = 0
  1724. if rate == "dmgdone" then
  1725. dmgtaken = math.ceil(dmg/move["Effects"]["Rate"])
  1726. else
  1727. dmgtaken = math.ceil(pokecfg.Stats.HPStat.Value/rate)
  1728. end
  1729. local hpbefore = pokecfg.CurrentHP.Value
  1730. if _G.Pokemon[pokecfg.Name]["Ability"] ~= "Rock Head" then
  1731. if pokecfg.CurrentHP.Value - dmgtaken <= 0 then
  1732. Math:Faint(pokecfg)
  1733. if foebool == true then
  1734. updatehealth(tbox,pokecfg,pokecfg.CurrentHP.Value)
  1735. scrolltext(dialog,"The "..prefix.." "..pokecfg.Name.." is hit with recoil!")
  1736. checkfaint(pokecfg,true)
  1737. else
  1738. updatehealth(ybox,pokecfg,pokecfg.CurrentHP.Value)
  1739. scrolltext(dialog,nickname(pokecfg).." is hit with recoil!")
  1740. checkfaint(pokecfg,false)
  1741. end
  1742. elseif pokecfg.CurrentHP.Value - dmgtaken >= 0 then
  1743. Math:TakeDamage(pokecfg,pokecfg.CurrentHP.Value - dmgtaken)
  1744. if foebool == true then
  1745. updatehealth(tbox,pokecfg,pokecfg.CurrentHP.Value)
  1746. scrolltext(dialog,"The "..prefix.." "..pokecfg.Name.." is hit with recoil!")
  1747. else
  1748. updatehealth(ybox,pokecfg,pokecfg.CurrentHP.Value)
  1749. scrolltext(dialog,nickname(pokecfg).." is hit with recoil!")
  1750. end
  1751. end
  1752. end
  1753. end
  1754. --[[
  1755. ==========================================
  1756. Absorb Health
  1757. ===========================================
  1758. --]]
  1759. function gainhealth(user,target,value,foe)
  1760. local hpbefore = user.CurrentHP.Value
  1761. if hpbefore ~= user.Stats.HPStat.Value then
  1762. if hpbefore + math.ceil(value) >= user.Stats.HPStat.Value then
  1763. Math:HealBattle(user,user.Stats.HPStat.Value)
  1764. if foe == true then
  1765. scrolltext(dialog,nickname(target).." had its energy drained!")
  1766. updatehealth(tbox,user,user.CurrentHP.Value)
  1767. else
  1768. scrolltext(dialog,"The "..prefix.." "..target.Name.." had its energy drained!")
  1769. updatehealth(ybox,user,user.CurrentHP.Value)
  1770. end
  1771.  
  1772. elseif hpbefore + math.ceil(value) < user.Stats.HPStat.Value then
  1773. Math:HealBattle(user,hpbefore + math.ceil(value))
  1774. if foe == true then
  1775. scrolltext(dialog,nickname(target).." had its energy drained!")
  1776. updatehealth(tbox,user,user.CurrentHP.Value)
  1777. else
  1778. scrolltext(dialog,"The "..prefix.." "..target.Name.." had its energy drained!")
  1779. updatehealth(ybox,user,user.CurrentHP.Value)
  1780. end
  1781. end
  1782. end
  1783. end
  1784.  
  1785. function nickname(pokemon)
  1786. if pokemon:FindFirstChild("Nickname") then
  1787. return pokemon:FindFirstChild("Nickname").Value
  1788. else
  1789. return pokemon.Name
  1790. end
  1791. end
  1792.  
  1793. --[[leech seed damage + absorption]]--
  1794. function leechdamage(user,target,foe)
  1795. local oldHP = target.CurrentHP.Value
  1796. local userBox = nil
  1797. local targetBox = nil
  1798. local absorbed = 0
  1799. if foe == true then
  1800. userBox = ybox
  1801. targetBox = tbox
  1802. else
  1803. userBox = tbox
  1804. targetBox = ybox
  1805. end
  1806. local amountlost = math.floor(math.min(target.CurrentHP.Value,target.Stats.HPStat.Value / 8))
  1807. target.CurrentHP.Value = math.max(target.CurrentHP.Value-amountlost,0)
  1808. gainhealth(user,target,amountlost,foe)
  1809. updatehealth(userBox,user,target.CurrentHP.Value)
  1810. updatehealth(targetBox,target,oldHP)
  1811. scrolltext(dialog,nickname(user).." regained health!")
  1812. checkfaint(target,foe)
  1813. if foe == true and target.CurrentHP.Value <= 0 then
  1814. getExperience()
  1815. end
  1816. end
  1817.  
  1818. function darkenScreen() --for weather
  1819. tbox.Visible = false
  1820. ybox.Visible = false
  1821. end
  1822. --[[Leech Seed effect--]]
  1823.  
  1824.  
  1825. --[[
  1826. ==================================
  1827. Secondary Effects
  1828. ==================================
  1829. --]]
  1830. function secondary(target,user,targettable,usertable,move,effect,foe,foebool)
  1831. local moveassociation = {
  1832. ["Target"] = {target,targettable},
  1833. ["User"] = {user,usertable}
  1834. }
  1835. if effect == "BreakScreen" then
  1836. if foe ~= user and (oppLightScreen > 0 or oppReflect > 0) then
  1837. oppLightScreen = 0
  1838. oppReflect = 0
  1839. scrolltext(dialog,nickname(user).." shattered the barrier!")
  1840. elseif foe == user and (userLightScreen > 0 or userReflect > 0) then
  1841. userLightScreen = 0
  1842. userReflect = 0
  1843. scrolltext(dialog,nickname(user).." shattered the barrier!")
  1844. end
  1845. elseif effect == "LightScreen" then
  1846. local raise = 5
  1847. if user.HeldItem.Value == "Light Clay" then
  1848. raise = 8
  1849. end
  1850. if foe == user then
  1851. scrolltext(dialog,"Light Screen raised the opponent team's Sp. Defense!")
  1852. oppLightScreen = raise
  1853. elseif foe ~= user then
  1854. scrolltext(dialog,"Light Screen raised your team's Sp. Defense!")
  1855. userLightScreen = raise
  1856. end
  1857. elseif effect == "Reflect" then
  1858. local raise = 5
  1859. if user.HeldItem.Value == "Light Clay" then
  1860. raise = 8
  1861. end
  1862. if foe == user then
  1863. scrolltext(dialog,"Reflect raised the opponent team's Defense!")
  1864. oppReflect = raise
  1865. elseif foe ~= user then
  1866. scrolltext(dialog,"Reflect raised your team's Defense!")
  1867. userReflect = raise
  1868. end
  1869. elseif effect == "Leech" then
  1870. if not isType(target,"Grass") then
  1871. if foe == user and leechseeduser == false then
  1872. leechseeduser = true
  1873. scrolltext(dialog,nickname(target).." was seeded!")
  1874. elseif foe == user and leechseeduser == true then
  1875. scrolltext(dialog,nickname(target).." is already seeded!")
  1876. elseif foe ~= user and leechseedopp == true then
  1877. scrolltext(dialog,nickname(target).." is already seeded!")
  1878. elseif foe ~= user and leechseedopp == false then
  1879. leechseedopp = true
  1880. scrolltext(dialog,nickname(target).." was seeded!")
  1881. end
  1882.  
  1883. else
  1884. scrolltext(dialog,"But it failed...!")
  1885. end
  1886. elseif effect == "ToxicSpikes" then
  1887. if foe == user and TSpikesFoe < 2 then
  1888. TSpikesFoe = TSpikesFoe + 1
  1889. scrolltext(dialog,nickname(user).." scattered poison spikes!")
  1890. elseif foe ~= user and TSpikesUser < 2 then
  1891. TSpikesUser = TSpikesUser + 1
  1892. scrolltext(dialog,nickname(user).." scattered poison spikes!")
  1893. else
  1894. scrolltext(dialog,"But it failed!")
  1895. end
  1896. elseif effect == "Taunt" then
  1897. scrolltext(dialog, nickname(target).." fell for the taunt!")
  1898. if foe == user then
  1899. TauntUser = 3
  1900. else
  1901. TauntFoe = 3
  1902. end
  1903.  
  1904. elseif effect == "DB" and target.Name ~= "Aegis MKII" then
  1905. scrolltext(dialog, nickname(user).." is trying to take the foe with it!")
  1906. if foe == user then
  1907. DBfoe = true
  1908. else
  1909. DBuse = true
  1910. end
  1911. elseif effect == "CureStatus" then
  1912. user.Status.Value = ""
  1913. tbox.Status.Visible = false
  1914. elseif effect == "LoseFlying" then
  1915. if foe == user then
  1916. oppRoosting = true
  1917. else
  1918. userRoosting = true
  1919. end
  1920. elseif effect == "Protect" then
  1921. local succeed = 0
  1922. if foe == user then
  1923. succeed = math.random(1,oppprotect)
  1924. if succeed == 1 then
  1925. oppIsProtected = true
  1926. oppprotect = oppprotect*2
  1927. scrolltext(dialog,nickname(user).." is protecting itself!")
  1928. else
  1929. oppIsProtected = false
  1930. oppprotect = 1
  1931. scrolltext(dialog, "But it failed...")
  1932. end
  1933. else
  1934. succeed = math.random(1,userprotect)
  1935. if succeed == 1 then
  1936. userIsProtected = true
  1937. userprotect = userprotect*2
  1938. scrolltext(dialog,nickname(user).." is protecting itself!")
  1939. else
  1940. userIsProtected = false
  1941. userprotect = 1
  1942. scrolltext(dialog, "But it failed...")
  1943. end
  1944. end
  1945. elseif effect == "Stats" then
  1946. --===========================
  1947. --Effect: Stat Buffs/Debuffs
  1948. --===========================
  1949. for i,v in pairs(move["Effects"]["Stats"]) do
  1950.  
  1951.  
  1952. if moveassociation[v[1]][1].CurrentHP.Value > 0 then
  1953.  
  1954. --print(moveassociation[v[1]][1])
  1955. local chance = math.random(1,100)
  1956. local comparechance = v[3]
  1957. if _G.Pokemon[user.Name]["Ability"] and _G.Pokemon[user.Name]["Ability"] == "Serene Grace" then
  1958. comparechance = comparechance * 2
  1959. end
  1960. if _G.Pokemon[user.Name]["Ability"] == "Sheer Force" and move["AttackType"] ~= "Status" then
  1961. if v[1] == "Target" and v[2] < 0 then
  1962. comparechance = 0
  1963. elseif v[1] == "User" and v[2] > 0 then
  1964. comparechance = 0
  1965. end
  1966. end
  1967. if chance <= comparechance then
  1968. if v[1] == "Target" and v[2] < 0 and _G.Pokemon[target.Name]["Ability"] == "Clear Body" then
  1969. scrolltext(dialog,nickname(target).."'s Clear Body prevents stat changes!")
  1970. else
  1971. local current = moveassociation[v[1]][2][i] + v[2]
  1972. moveassociation[v[1]][2][i] = moveassociation[v[1]][2][i] + v[2]
  1973.  
  1974. --preventin bugs is fun
  1975. if moveassociation[v[1]][2][i] > 6 and v[2] > 0 then
  1976. moveassociation[v[1]][2][i] = 6
  1977. elseif moveassociation[v[1]][2][i] < -6 and v[2] < 0 then
  1978. moveassociation[v[1]][2][i] = -6
  1979. end
  1980. --end
  1981.  
  1982. if current < -6 or current > 6 then
  1983. if current > 6 and ((foe == target and target == moveassociation[v[1]][1]) or (foe == user and user == moveassociation[v[1]][1])) then
  1984. scrolltext(dialog,"The "..prefix.." "..moveassociation[v[1]][1].Name.."'s "..fullnamestats[i].." can't go any higher!")
  1985. elseif current < -6 and((foe == target and target == moveassociation[v[1]][1]) or (foe == user and user == moveassociation[v[1]][1])) then
  1986. scrolltext(dialog,"The "..prefix.." "..moveassociation[v[1]][1].Name.."'s "..fullnamestats[i].." can't go any lower!")
  1987. elseif current > 6 then
  1988. scrolltext(dialog,nickname(moveassociation[v[1]][1]).."'s "..fullnamestats[i].." can't go any higher!")
  1989. elseif current < -6 then
  1990. scrolltext(dialog,nickname(moveassociation[v[1]][1]).."'s "..fullnamestats[i].." can't go any lower!")
  1991. end
  1992. elseif (foe == target and target == moveassociation[v[1]][1]) or (foe == user and user == moveassociation[v[1]][1]) then
  1993. scrolltext(dialog,"The "..prefix.." "..moveassociation[v[1]][1].Name.."'s "..fullnamestats[i]..buffstrings[v[2]])
  1994. else
  1995. scrolltext(dialog,nickname(moveassociation[v[1]][1]).."'s "..fullnamestats[i]..buffstrings[v[2]])
  1996. end
  1997.  
  1998. end
  1999. end
  2000. end
  2001. end
  2002. --==========================
  2003. --Recoil
  2004. --===========================
  2005. elseif effect == "Recoil" then
  2006. recoil(user,move["Effects"]["Recoil"],foebool,move)
  2007. --[[
  2008. ==================================
  2009. Status Effects (Oh Boy)
  2010. ==================================
  2011. ]]
  2012. elseif effect == "Status" then
  2013. local immune = false
  2014. local immuneStatusAbilities = {
  2015. ["Insomnia"] = "Sleep",
  2016. ["Immunity"] = "Poison",
  2017. ["Limber"] = "Paralysis",
  2018. ["Magma Armor"] = "Freeze",
  2019. ["Vital Spirit"] = "Sleep",
  2020. ["Water Veil"] = "Burn",
  2021. }
  2022.  
  2023. for i,v in pairs(move["Effects"]["Status"]) do
  2024. for _,blah in pairs(_G.Pokemon[target.Name]["Type"]) do
  2025. if blah == immunestatus[i] then
  2026. immune = true
  2027.  
  2028. end
  2029. end
  2030. if _G.Pokemon[target.Name]["Ability"] and immuneStatusAbilities[_G.Pokemon[target.Name]["Ability"]] then
  2031. if immuneStatusAbilities[_G.Pokemon[target.Name]["Ability"]]:find(i) then
  2032.  
  2033. immune = true
  2034. end
  2035. end
  2036. if target.CurrentHP.Value > 0 and target.Status.Value == "" and not immune then
  2037.  
  2038.  
  2039. local chance = math.random(1,100)
  2040. local comparechance = v
  2041. if _G.Pokemon[user.Name]["Ability"] and _G.Pokemon[user.Name]["Ability"] == "Serene Grace" then
  2042. comparechance = comparechance * 2
  2043. end
  2044. if _G.Pokemon[user.Name]["Ability"] == "Sheer Force" and move["AttackType"] ~= "Status" then
  2045. comparechance = 0
  2046. end
  2047. if chance <= comparechance then
  2048. target.Status.Value = i
  2049. if foe == target then
  2050. statusupdate(target,true)
  2051. else
  2052. statusupdate(target,false)
  2053. end
  2054. end
  2055. elseif target.CurrentHP.Value > 0 and target.Status.Value ~= "" and move["AttackType"] == "Status" then
  2056.  
  2057. if foe == target then
  2058. scrolltext(dialog,"It doesn't affect the "..prefix.." "..target.Name.."!")
  2059. else
  2060. scrolltext(dialog,"It doesn't affect "..nickname(target).."!")
  2061. end
  2062. elseif immune and move["AttackType"] == "Status" then
  2063. if foe == target then
  2064. scrolltext(dialog,"It doesn't affect the "..prefix.." "..target.Name.."!")
  2065. else
  2066. scrolltext(dialog,"It doesn't affect "..nickname(target).."!")
  2067.  
  2068. end
  2069. end
  2070. end
  2071.  
  2072. --Flinching--
  2073. elseif effect == "Flinch" then
  2074. local flichance = math.random(1,100)
  2075. local comparechance = move["Effects"]["Flinch"]
  2076. if _G.Pokemon[user.Name]["Ability"] == "Sheer Force" then
  2077. comparechance = 0
  2078. end
  2079. if _G.Pokemon[user.Name]["Ability"] and _G.Pokemon[user.Name]["Ability"] == "Serene Grace" then
  2080. comparechance = comparechance * 2
  2081. end
  2082. if _G.Pokemon[target.Name]["Ability"] and (_G.Pokemon[target.Name]["Ability"] == "Inner Focus" or _G.Pokemon[target.Name]["Ability"] == "Own Tempo") then
  2083. flinch = false
  2084. elseif flichance <= comparechance then
  2085. flinch = true
  2086.  
  2087. else flinch = false
  2088. end
  2089. --Volatile Effects
  2090. elseif effect == "Heal" then
  2091. local chump = nil
  2092. local curhp = user.CurrentHP.Value
  2093. local valheal = math.ceil(user.Stats.HPStat.Value*move["Effects"]["Heal"])
  2094. if curhp == user.Stats.HPStat.Value then
  2095. scrolltext(dialog,"It had no effect!")
  2096. -- elseif curhp <= user.Stats.HPStat.Value then
  2097. elseif curhp + valheal >= user.Stats.HPStat.Value then
  2098. chump = true
  2099. Math:HealBattle(user,user.Stats.HPStat.Value)
  2100.  
  2101. else
  2102. chump = true
  2103. Math:HealBattle(user,curhp+valheal)
  2104. end
  2105. if chump ~= nil then
  2106. if user == foe then
  2107. scrolltext(dialog,"The "..prefix.." "..user.Name.." regained health!")
  2108. updatehealth(tbox,user,user.CurrentHP.Value)
  2109.  
  2110. else
  2111. scrolltext(dialog,nickname(user).." regained health!")
  2112. updatehealth(ybox,user,user.CurrentHP.Value)
  2113. end
  2114. end
  2115. elseif effect == "PainSplit" then
  2116. local curhp = user.CurrentHP.Value
  2117. local otherhp = target.CurrentHP.Value
  2118. local hpsplit = math.floor((curhp+otherhp)/2)
  2119. scrolltext(dialog,"The battlers shared their pain!")
  2120. Math:PainSplit(user,math.min(hpsplit,user.Stats.HPStat.Value))
  2121. Math:PainSplit(target,math.min(hpsplit,target.Stats.HPStat.Value))
  2122. updatehealth(tbox,target,target.CurrentHP.Value)
  2123. updatehealth(ybox,user,user.CurrentHP.Value)
  2124. elseif effect == "Rest" then
  2125. local chump = nil
  2126. local curhp = user.CurrentHP
  2127. local hpstat = user.Stats.HPStat
  2128. if hpstat.Value == curhp.Value then
  2129. scrolltext(dialog,"It had no effect!")
  2130. else
  2131. Math:Rest(user)
  2132. chump = true
  2133. end
  2134. if chump ~= nil then
  2135. if user == foe then
  2136. user.Status.Value = "Sleep" --just in case...
  2137. scrolltext(dialog,"The "..prefix.." "..user.Name.." started sleeping!")
  2138. statusupdate(user,true)
  2139. updatehealth(tbox,user,user.CurrentHP.Value)
  2140. else
  2141. scrolltext(dialog,nickname(user).." started sleeping!")
  2142. statusupdate(user,false)
  2143. updatehealth(ybox,user,user.CurrentHP.Value)
  2144. end
  2145. end
  2146. elseif effect == "Volatile" then
  2147. for i,v in pairs(move["Effects"]["Volatile"]) do
  2148. if target.CurrentHP.Value > 0 then
  2149. if i == "Confusion" then
  2150. local volatilecheck = math.random(1,100)
  2151. local comparechance = v
  2152. if _G.Pokemon[user.Name]["Ability"] == "Sheer Force" and move["AttackType"] ~= "Status" then
  2153. comparechance = 0
  2154. end
  2155. if volatilecheck <= comparechance then
  2156.  
  2157. if foe == target then
  2158. if theirconfusion == true then
  2159. scrolltext(dialog,"The "..prefix.." "..target.Name.." is already confused!")
  2160. else
  2161. scrolltext(dialog,"The "..prefix.." "..target.Name.." was confused!")
  2162. confusion2 = math.random(1,3)
  2163. theirconfusion = true
  2164. end
  2165. else
  2166. if urconfusion == true then
  2167. scrolltext(dialog,nickname(target).." is already confused!")
  2168. else
  2169. scrolltext(dialog,nickname(target).." was confused!")
  2170. confusion1 = math.random(1,3)
  2171. urconfusion = true
  2172. end
  2173. end
  2174. end
  2175. end
  2176. end
  2177. end
  2178. --
  2179. elseif effect == "Weather" then
  2180. local turnCount = 5
  2181. if move == "Rain Dance" then
  2182. scrolltext("It started raining!")
  2183. weather = {["CurrentWeather"] = "Rain",
  2184. ["Count"] = turnCount
  2185. }
  2186.  
  2187. end
  2188. elseif effect == "ClearStats" then
  2189. scrolltext(dialog,"All stat changes were reset!")
  2190. usermod = {
  2191. ["Atk"] = 0,
  2192. ["Def"] = 0,
  2193. ["SpA"] = 0,
  2194. ["SpD"] = 0,
  2195. ["Speed"] = 0,
  2196. ["Acc"] = 0,
  2197. ["Evade"] = 0
  2198. }
  2199. oppmod = {
  2200. ["Atk"] = 0,
  2201. ["Def"] = 0,
  2202. ["SpA"] = 0,
  2203. ["SpD"] = 0,
  2204. ["Speed"] = 0,
  2205. ["Acc"] = 0,
  2206. ["Evade"] = 0
  2207. }
  2208. --
  2209. elseif effect == "Absorb" then
  2210. if foe == target then
  2211. gainhealth(user,target,dmg*(move["Effects"]["Absorb"]),false)
  2212. else
  2213. gainhealth(user,target,dmg*(move["Effects"]["Absorb"]),true)
  2214. end
  2215. end
  2216. end
  2217. --[[
  2218. ==================================
  2219. Passive Move (not really LOL)
  2220. ==================================
  2221. --]]
  2222.  
  2223. function passivemove(target,user,targettable,usertable,move,foe,foebool)
  2224. local Move = _G.Moves[move]
  2225. for i,v in pairs(_G.Moves[move]["Effects"]) do
  2226. --secondary(target,user,targettable,usertable,Move,i,foe,foebool)
  2227. secondary(target,user,usertable,targettable,Move,i,foe,foebool)
  2228. end
  2229. end
  2230. lowkicktable = {
  2231. [1] = {20,.1,21.8},
  2232. [2] = {40,21.9,55},
  2233. [3] = {60,55.1,110},
  2234. [4] = {80,110.1,220.2},
  2235. [5] = {100,220.3,440.7},
  2236. }
  2237. --[[===============
  2238. Weight function
  2239. ===============
  2240. --]]
  2241. function weightdmg(pokemon)
  2242. for _,dmg in ipairs(lowkicktable) do
  2243. if _G.Pokemon[pokemon.Name]["Weight"] >= dmg[2] and _G.Pokemon[pokemon.Name]["Weight"] <= dmg[3] then
  2244. return dmg[1]
  2245. end
  2246. end
  2247. return 120
  2248. end
  2249. function getNick(poke)
  2250. if poke:FindFirstChild("Nickname") then
  2251. return poke.Nickname.Value
  2252. end
  2253. return poke.Name
  2254. end
  2255. function canEvolve(poke)
  2256. if #_G.Pokemon[poke.Name]["Evolution"] > 0 then
  2257. return true
  2258. end
  2259. if _G.Pokemon[poke.Name]["EvolutionStone"] then
  2260. return true
  2261. end
  2262. return false
  2263. end
  2264. --[[
  2265. ==================================
  2266. Calculates Damage
  2267. ==================================
  2268. --]]
  2269. local boostedtypes = {
  2270. ["Aerilate"] = "Flying",
  2271. ["Pixilate"] = "Fairy",
  2272. ["Refrigerate"] = "Ice",
  2273. }
  2274. local pinchAbilities = {
  2275. ["Swarm"] = "Bug",
  2276. ["Overgrow"] = "Grass",
  2277. ["Blaze"] = "Fire",
  2278. ["Torrent"] = "Water",
  2279. }
  2280.  
  2281. function isInPinch(pokemon)
  2282. if pokemon.CurrentHP.Value < math.ceil(pokemon.Stats.HPStat.Value) then
  2283. return true
  2284. else
  2285. return false
  2286. end
  2287. end
  2288. function SheerForceCheck(move)
  2289. for i,v in pairs(_G.Moves[move]["Effects"]) do
  2290. if i == "Status" then
  2291. return true
  2292. elseif i == "Stats" then
  2293. for _,derp in pairs(v) do
  2294. if derp[1] == "User" and derp[2] > 0 then
  2295. return true
  2296. elseif derp[1] == "Target" and derp[2] < 0 then
  2297. return true
  2298. end
  2299. end
  2300. elseif i == "Confusion" then
  2301. return true
  2302. elseif i == "Flinch" then
  2303. return true
  2304. end
  2305. end
  2306. return false
  2307. end
  2308. function dmgcalculate(Poke1,Poke2,Move,AtkModi,DefModi,critchance) --Poke1 = Attacker, Poke2 = Defender
  2309. moves = _G.Moves
  2310. local newatkmodi = AtkModi
  2311. local newdefmodi = DefModi
  2312.  
  2313. local burn = 1
  2314. if Poke1.Status.Value == "Burn" then
  2315. burn = .5
  2316. end
  2317. atkerstats = Poke1.Stats
  2318. deferstats = Poke2.Stats
  2319. --print("Modifiers: Attacker ",newatkmodi,"Modifiers: Defender ",newdefmodi)
  2320. --print("Stat:",modifierstat[newatkmodi],modifierstat[newdefmodi])
  2321. crit = false
  2322. local weakness = 1
  2323. local immune = nil
  2324. --===========
  2325. --Weakness Calculation
  2326. --===========
  2327. local power = moves[Move]["Power"]
  2328. local typeMove = moves[Move]["Type"]
  2329.  
  2330.  
  2331. if Move == "Hidden Power" then
  2332. typeMove = getHiddenPower(Poke1)
  2333. elseif _G.Moves[Move]["RandomType"] ~= nil then
  2334. local types = {"Fairy","Flying","Electric","Steel","Ice","Fire","Grass","Dragon","Psychic","Dark","Bug","Ground","Ghost","Poison","Fighting","Water","Normal"}
  2335. typeMove = types[math.random(#types)]
  2336. end
  2337. if type(power) == "number" then
  2338. if _G.Pokemon[Poke1.Name]["Ability"] == "Sheer Force" and SheerForceCheck(Move) then
  2339. power = power * 1.3
  2340. end
  2341. if Move == "Facade" and Poke1.Status.Value ~= "" then
  2342. power = power * 2
  2343. end
  2344. if _G.Pokemon[Poke1.Name]["Ability"] and boostedtypes[_G.Pokemon[Poke1.Name]["Ability"]] then
  2345. if moves[Move]["Type"] == "Normal" then
  2346. power = power * 1.2
  2347. typeMove = boostedtypes[_G.Pokemon[Poke1.Name]["Ability"]]
  2348. end
  2349. elseif _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Tough Claws" and moves[Move]["Contact"] then
  2350. power = power * 1.33
  2351. print("tough claws boost")
  2352. elseif _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Iron Fist" and moves[Move]["Punching"] then
  2353. power = power * 1.2
  2354. print("iron fist boost")
  2355. elseif _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Mega Launcher" and moves[Move]["Pulse"] then
  2356. power = power * 1.5
  2357. print("mega launcher boost")
  2358. elseif _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Strong Jaw" and moves[Move]["Biting"] then
  2359. power = power * 1.5
  2360. print("strong jaw boost")
  2361. elseif _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Steelworker" and moves[Move]["Type"] == "Steel" then
  2362. power = power * 1.5
  2363. print("steelworker boost")
  2364. elseif _G.Pokemon[Poke1.Name]["Ability"] and pinchAbilities[_G.Pokemon[Poke1.Name]["Ability"]] and typeMove == pinchAbilities[_G.Pokemon[Poke1.Name]["Ability"]] and isInPinch(Poke1) then
  2365. power = power * 1.5
  2366. print("pinch ability")
  2367. end
  2368. end
  2369. if moves[Move]["AttackType"] == "Special" and Poke1.HeldItem.Value == "Wise Glasses" then
  2370. power = power * 1.1
  2371. end
  2372. local typetable = _G.Tables.TypeChart[typeMove]
  2373. local types = _G.Pokemon[Poke2.Name]["Type"]
  2374. if originalstats[Poke2] then
  2375. types = originalstats[Poke2]["Type"]
  2376. end
  2377. for i,v in pairs(types) do
  2378. --Immune
  2379.  
  2380. if ((Poke2.Parent.Name == "PokemonParty" and userRoosting ) or (Poke2.Parent.Name == "OppPokemon" and oppRoosting)) and v == "Flying" then
  2381. else
  2382. for _,weak in ipairs(typetable["0x"]) do
  2383. if v == weak then
  2384. weakness = weakness * 0
  2385. end
  2386. end
  2387. if moves[Move]["HitsEverything"] ~= nil and weakness == 0 then
  2388. weakness = 1
  2389. end
  2390. --Resistant
  2391. for _,weak in ipairs(typetable[".5x"]) do
  2392. if v == weak then
  2393. weakness = weakness * .5
  2394. end
  2395. end
  2396. --SuperEffective
  2397. for _,weak in ipairs(typetable["2x"]) do
  2398. if v == weak then
  2399. weakness = weakness * 2
  2400. end
  2401. end
  2402. end
  2403. end
  2404. local reduceDamage = {
  2405. ["Filter"] = true,
  2406. ["Solid Rock"] = true
  2407. }
  2408. local immunities = {
  2409. ["Flame Absorb"] = {"Fire"," absorbed the Fire move with Flame Absorb!"},
  2410. ["Water Absorb"] = {"Water", " absorbed the Water move with Water Absorb!"},
  2411. ["Volt Absorb"] = {"Electric", " absorbed the Electric move with Volt Absorb!"},
  2412. ["Sap Sipper"] = {"Grass", " ate the Grass move with Sap Sipper"},
  2413. }
  2414.  
  2415. if abilitydenier[_G.Pokemon[Poke1.Name]["Ability"]] == nil and _G.Pokemon[Poke2.Name]["Ability"] and immunities[_G.Pokemon[Poke2.Name]["Ability"]] and moves[Move]["Type"] == immunities[_G.Pokemon[Poke2.Name]["Ability"]][1]then
  2416. weakness = 0
  2417. scrolltext(dialog,getNick(Poke2)..immunities[_G.Pokemon[Poke2.Name]["Ability"]][2])
  2418. immune = "Lol"
  2419. Math:AbilityRecover(Poke2)
  2420. if Poke2 == yourpokeout then
  2421.  
  2422. updatehealth(ybox,Poke2,Poke2.CurrentHP.Value)
  2423. elseif Poke2 == theirpokeout then
  2424. updatehealth(tbox,Poke2,Poke2.CurrentHP.Value)
  2425. end
  2426. elseif weakness > 1 and abilitydenier[_G.Pokemon[Poke1.Name]["Ability"]] == nil and _G.Pokemon[Poke2.Name]["Ability"] and reduceDamage[ _G.Pokemon[Poke2.Name]["Ability"]] then
  2427. weakness = weakness * .75
  2428. end
  2429. if abilitydenier[_G.Pokemon[Poke1.Name]["Ability"]] == nil and _G.Pokemon[Poke2.Name]["Ability"] and _G.Pokemon[Poke2.Name]["Ability"] == "Levitate" and moves[Move]["Type"] == "Ground" then
  2430. weakness = 0
  2431. immune = "Levitate"
  2432. end
  2433. local STAB = 1
  2434. local AttackPower = atkerstats.AtkStat.Value
  2435. local DefensePower = deferstats.DefStat.Value
  2436. if Move == "Foul Play" then
  2437. AttackPower = deferstats.AtkStat.Value
  2438. newatkmodi = DefModi
  2439. end
  2440. if _G.Pokemon[Poke1.Name]["Ability"] and (_G.Pokemon[Poke1.Name]["Ability"] == "Huge Power" or _G.Pokemon[Poke1.Name]["Ability"] == "Pure Power") then
  2441.  
  2442. AttackPower = AttackPower * 2
  2443. elseif Poke1.Status.Value ~= "" and _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Guts" then
  2444. AttackPower = AttackPower * 1.5
  2445. burn = 1
  2446. end
  2447. if Poke2.Status.Value ~= "" and (_G.Pokemon[Poke2.Name]["Ability"] == "Marvel Scale") then
  2448. print("Marvel Scale Boost")
  2449. DefensePower = DefensePower * 1.5
  2450. end
  2451. --==========
  2452. --STAB Calculation
  2453. --==========
  2454. if originalstats[Poke1] then
  2455. for i,v in pairs(originalstats[Poke1]["Type"]) do
  2456. if typeMove == v then
  2457. STAB = 1.5
  2458. end
  2459. end
  2460. else
  2461. for i,v in pairs(_G.Pokemon[Poke1.Name]["Type"]) do
  2462. if typeMove == v then
  2463. STAB = 1.5
  2464. end
  2465. end
  2466. end
  2467. if STAB == 1.5 and _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Adaptability" then
  2468. STAB = 2
  2469. end
  2470. --[[==========
  2471. Determine What Stat To Use
  2472. --============]]--
  2473.  
  2474.  
  2475. if power == false then
  2476. if moves[Move]["Effects"]["PowerWeight"] ~= nil then
  2477. power = weightdmg(Poke2)
  2478. end
  2479. end
  2480. if power <= 60 and _G.Pokemon[Poke1.Name]["Ability"] and _G.Pokemon[Poke1.Name]["Ability"] == "Technician" then
  2481. print("Technician activate")
  2482. power = power * 1.5
  2483. end
  2484. local evio = 1
  2485. -- print(power)
  2486. if Poke2.HeldItem.Value == "Eviolite" and canEvolve(Poke2) then
  2487. evio = 1.5
  2488. end
  2489.  
  2490.  
  2491. if moves[Move]["AttackType"] == "Physical" then
  2492. if critchance == 1 then
  2493.  
  2494. dmgcalc= math.ceil((((2 * Poke1.Lvl.Value + 10)/250 * (AttackPower*modifierstat[AtkModi]*burn / ((DefensePower*evio)*modifierstat[DefModi])) * power + 2) * critchance * STAB * weakness * math.random(85,100) / 100) )
  2495. elseif critchance ==2 then
  2496.  
  2497. --print("It's a crit! Ignoring buffs/debuffs!")
  2498. if AtkModi < 0 then
  2499. newatkmodi = 0
  2500. end
  2501. if newdefmodi > 0 then
  2502. newdefmodi = 0
  2503. end
  2504. dmgcalc= math.ceil((((2 * Poke1.Lvl.Value + 10)/250 * ((AttackPower*modifierstat[newatkmodi]) / ((DefensePower*evio)*modifierstat[newdefmodi])) * power + 2) * critchance * STAB * weakness * math.random(85,100) / 100) )
  2505.  
  2506. end
  2507. elseif moves[Move]["AttackType"] == "Special" then
  2508. if critchance == 1 then
  2509. dmgcalc= math.ceil((((2 * Poke1.Lvl.Value + 10)/250 * (atkerstats.SpAStat.Value*modifierstat[AtkModi] / ((deferstats.SpDStat.Value*evio)*modifierstat[DefModi])) * power + 2) * critchance * STAB * weakness * math.random(85,100) / 100) )
  2510.  
  2511. elseif critchance == 2 then
  2512. --print("It's a crit! Ignoring buffs/debuffs!")
  2513. if AtkModi < 0 then
  2514. newatkmodi = 0
  2515. end
  2516. if newdefmodi > 0 then
  2517. newdefmodi = 0
  2518. end
  2519. dmgcalc= math.ceil((((2 * Poke1.Lvl.Value + 10)/250 * (atkerstats.SpAStat.Value*modifierstat[newatkmodi] / ((deferstats.SpDStat.Value*evio)*modifierstat[newdefmodi])) * power + 2) * critchance * STAB * weakness * math.random(85,100) / 100) )
  2520. end
  2521. end
  2522. --print(dmgcalc)
  2523. --print(immune)
  2524. if _G.Pokemon[Poke2.Name]["Ability"] and _G.Pokemon[Poke2.Name]["Ability"] == "Thick Fat" and (moves[Move]["Type"] == "Fire" or moves[Move]["Type"] == "Ice") then
  2525. dmgcalc = math.floor(dmgcalc/2)
  2526. end
  2527. if critchance ~= 2 and Move ~= "Brick Break" and Move ~= "Psychic Fangs" and moves[Move]["AttackType"] == "Physical" and ((Poke2.Parent.Name == "PokemonParty" and userReflect > 0) or (Poke2.Parent.Name == "OppPokemon" and oppReflect > 0)) then
  2528. dmgcalc = math.ceil(dmgcalc/2)
  2529. end
  2530. if critchance ~= 2 and moves[Move]["AttackType"] == "Special" and ((Poke2.Parent.Name == "PokemonParty" and userLightScreen > 0) or (Poke2.Parent.Name == "OppPokemon" and oppLightScreen > 0)) then
  2531. dmgcalc = math.ceil(dmgcalc/2)
  2532. end
  2533. if dmgcalc > 0 then
  2534. if Poke1.HeldItem.Active.Value == true then
  2535. if Poke1.HeldItem.Value == "Life Orb" and type(moves[Move]["Power"]) == "number" then
  2536.  
  2537.  
  2538. dmgcalc = dmgcalc * 1.3
  2539. elseif Poke1.HeldItem.Value == "Expert Belt" and weakness >= 2 and type(moves[Move]["Power"]) == "number" then
  2540.  
  2541. dmgcalc = dmgcalc * 1.2
  2542. elseif Poke1.HeldItem.Value == "Novice Belt" and weakness < 1 and type(moves[Move]["Power"]) == "number" then
  2543.  
  2544. dmgcalc = dmgcalc * 1.5
  2545.  
  2546. end
  2547. end
  2548. end
  2549. return dmgcalc, weakness, critchance, immune
  2550. end
  2551. --[[
  2552. ==================================
  2553. Makes Weakness Text Appear
  2554. ==================================
  2555. --]]
  2556. function weak(w,pokecfg,foe,ability)
  2557.  
  2558. if w > 1 then
  2559. wait(.3)
  2560. scrolltext(dialog,"It's super effective!")
  2561. elseif w < 1 and w ~= 0 then
  2562. wait(.3)
  2563. scrolltext(dialog,"It's not very effective...")
  2564. elseif w == 0 and ability == nil then
  2565. wait(.3)
  2566. if foe == true then
  2567. scrolltext(dialog,"It doesn't affect the "..prefix.." "..pokecfg.Name.."...")
  2568. else
  2569. scrolltext(dialog,"It doesn't affect "..nickname(pokecfg).."...")
  2570. end
  2571. elseif ability == "Levitate" then
  2572. if foe == true then
  2573. scrolltext(dialog,"The "..prefix.." "..pokecfg.Name.." has Levitate!")
  2574. scrolltext(dialog,"The Ground move missed!")
  2575. else
  2576. scrolltext(dialog,pokecfg.Name.." has Levitate!")
  2577. scrolltext(dialog,"The Ground move missed!")
  2578. end
  2579.  
  2580. end
  2581. end
  2582. --[[
  2583. ===================================
  2584. Send Out Next Pokemon ("Foe")
  2585. ==================================
  2586. --]]
  2587. function getpokemon(theirpoke)
  2588. local goal = theirpoke.PartyPosition.Value + 1
  2589. for i,v in ipairs(oppteam:GetChildren()) do
  2590. if v.PartyPosition.Value == goal then
  2591. return v
  2592. end
  2593. end
  2594. end
  2595. --[[
  2596. ==================================
  2597. Wild Pokemon AI
  2598. ==================================
  2599. --]]
  2600. function wildmove(pokeconfig) --this just picks a random move, akin to how wild Pokemon battle
  2601. local moves = pokeconfig.Moves:GetChildren()
  2602. if ppchecker(pokeconfig.Moves) then
  2603. return "Struggle"
  2604. else
  2605. while true do --I think this is hackish...
  2606. local determinemove = moves[math.random(1,#moves)]
  2607. if determinemove.PP.Value > 0 then
  2608. return determinemove.Name
  2609. else
  2610. wait() --just prevents it crashing, I guess?
  2611. end
  2612. end
  2613. end
  2614. end
  2615. --[[
  2616. is string in table? for trainer select moves
  2617. --]]
  2618. function findMove(tab,move)
  2619. for i,v in ipairs(tab) do
  2620. if v == move then
  2621. return true
  2622. end
  2623. end
  2624. return false
  2625. end
  2626. --[[
  2627. ==============================
  2628. Trainer Selects Move (no dummy)
  2629. ==============================
  2630. --]]
  2631.  
  2632.  
  2633. local immuneAbilities = {
  2634. ["Flame Absorb"] = "Fire",
  2635. ["Volt Absorb"] = "Electric",
  2636. ["Water Absorb"] = "Water",
  2637. ["Levitate"] = "Ground",
  2638. ["Sap Sipper"] = "Grass"}
  2639.  
  2640. function tableFind(tabl,content)
  2641. for index,key in pairs(tabl) do
  2642. if key == content then
  2643. return true
  2644. end
  2645. end
  2646. return false
  2647. end
  2648.  
  2649.  
  2650. function negativeNumber()
  2651. local number = math.random(-1,1)
  2652. repeat number = math.random(-1,1) until number ~= 0
  2653. return number
  2654. end
  2655. function sparkles(framez,box,Mega)
  2656. local amountofSparklesCreated = math.random(1,4)
  2657. local colors = {}
  2658. for i,v in ipairs(_G.Pokemon[Mega]["Type"]) do
  2659. table.insert(colors,_G.Tables.TypeColors[v])
  2660. end
  2661. for i = 1, amountofSparklesCreated do
  2662. local negativeCalc = negativeNumber()
  2663. local startBy = negativeCalc*(-20)
  2664. local last = negativeCalc*20
  2665. local UpBy = negativeCalc*.75
  2666. local sparkleFrame = Instance.new("ImageLabel")
  2667. sparkleFrame.BackgroundTransparency = 1
  2668. sparkleFrame.ZIndex = 7
  2669. sparkleFrame.Name = "Sparkles"
  2670. sparkleFrame.Image = "rbxassetid://583229322"
  2671. sparkleFrame.ImageColor3 = colors[math.random(#colors)]
  2672.  
  2673.  
  2674. sparkleFrame.Size = UDim2.new(0,8,0,8)
  2675. sparkleFrame.ImageRectSize = Vector2.new(8,8)
  2676. sparkleFrame.ImageRectOffset = Vector2.new(8,0)
  2677.  
  2678.  
  2679. local originalposition = sparkleFrame.Position
  2680. sparkleFrame.Position = UDim2.new(framez,i*math.random(2,6)+originalposition.X.Scale,0,math.min(startBy+5,startBy)^2)
  2681. sparkleFrame.Parent = box
  2682. local oroabso = sparkleFrame.AbsolutePosition
  2683. local start = math.random(math.min(startBy+5,startBy),math.max(startBy+5,startBy))
  2684. spawn(function()
  2685. for i = start,last,UpBy do
  2686.  
  2687. sparkleFrame.Position = UDim2.new(framez,i*4+originalposition.X.Scale,0,i^2)--+originalposition.Y.Scale)
  2688. sparkleFrame.ImageRectOffset = Vector2.new(0,0)
  2689. wait()
  2690. end
  2691. end)
  2692. end
  2693. end
  2694. function megaEvolve(box,megaEvolution)
  2695. local sl = Instance.new("Sound",box)
  2696. sl.SoundId = "rbxassetid://138724260"
  2697.  
  2698. local lever = Instance.new("Sound",box)
  2699. lever.SoundId = "rbxassetid://377026009"
  2700. local frames = {}
  2701. for i = 1, 9 do
  2702. sparkles(i/10,box,megaEvolution)
  2703. end
  2704. sl:Play()
  2705. wait(1.75)
  2706. for i = 0,9 do
  2707. local frameTrans = Instance.new("Frame")
  2708. table.insert(frames,frameTrans)
  2709. frameTrans.Name = "BoxFrame"
  2710. frameTrans.BorderSizePixel = 1
  2711. frameTrans.BorderColor3 = Color3.new(0,0,0)
  2712. frameTrans.ZIndex = 9
  2713. frameTrans.BackgroundColor3 = Color3.new(0,0,0)
  2714. frameTrans.Size = UDim2.new(.1,0,0,0) --starts at 0,0,0,0 and transform into this
  2715. frameTrans.Position = UDim2.new(i/10,0,i%2,0)
  2716. frameTrans.Parent = box
  2717. frameTrans:TweenSizeAndPosition(UDim2.new(.1,0,1,0),UDim2.new(i/10,0,0,0),"Out","Quad",1)
  2718. lever:Play()
  2719. wait(.2)
  2720. end
  2721. print(2.65)
  2722. local s = Instance.new("Sound",box)
  2723. s.SoundId = "rbxassetid://348316769"
  2724. s:Play()
  2725. yourpokeout.Name = megaEvolution
  2726. yourpokeout.Reverse.Value = megaEvolution:reverse()
  2727. Math:StatChange(yourpokeout)
  2728. _G.getBackSprite(box,yourpokeout)
  2729. wait(.5)
  2730.  
  2731. for i,v in ipairs(frames) do
  2732. sparkles(i/10,box,megaEvolution)
  2733. v:TweenSizeAndPosition(UDim2.new(.1,0,0,0),UDim2.new((i/10)-.1,0,i%2,0),"Out","Quad",1,true,function() v:Destroy() end)
  2734. lever:Play()
  2735. end
  2736. wait(2)
  2737. for i,v in ipairs(box:GetChildren()) do
  2738. if v.Name == "Sparkles" or v.Name == "BoxFrame" then
  2739. v:Destroy()
  2740. end
  2741. end
  2742.  
  2743. end
  2744. function trainerMoveCheck(AIPoke,userPoke) --AIPoke is AI Pokemon, userPoke is player's current Pokemon
  2745. local MovesAvail = AIPoke.Moves:GetChildren()
  2746. local userTypes = _G.Pokemon[userPoke.Name]["Type"]
  2747. local allowedMoves = {}
  2748. local badTypes = {}
  2749. if (_G.Pokemon[userPoke.Name]["Ability"] and immuneAbilities[_G.Pokemon[userPoke.Name]["Ability"]]) then
  2750. table.insert(badTypes, immuneAbilities[_G.Pokemon[userPoke.Name]["Ability"]])
  2751. end
  2752.  
  2753.  
  2754.  
  2755. for _,pokeType in ipairs(userTypes) do
  2756. for origitype,tab in pairs(_G.Tables.TypeChart) do
  2757. for i,v in ipairs(tab["0x"]) do
  2758. if pokeType == v and not tableFind(badTypes,v) then
  2759. table.insert(badTypes,origitype)
  2760. end
  2761. end
  2762. end
  2763. end
  2764.  
  2765.  
  2766.  
  2767.  
  2768. --actual calcs
  2769. for _,Move in ipairs(MovesAvail) do
  2770. local moveType = _G.Moves[Move.Name]["Type"]
  2771. local typetable = _G.Tables.TypeChart[moveType]
  2772.  
  2773.  
  2774.  
  2775. if (not tableFind(allowedMoves,Move) and Move.PP.Value > 0) and ( (_G.Moves[Move.Name]["AttackType"] == "Status") or not tableFind(badTypes,moveType)) then
  2776.  
  2777.  
  2778. table.insert(allowedMoves,Move)
  2779.  
  2780.  
  2781. end
  2782. end
  2783. if #allowedMoves > 0 then
  2784. local determinemove
  2785. local calculations = {}
  2786. local highmove = nil
  2787. local highdamage = 0
  2788. for i,Move in ipairs(allowedMoves) do
  2789.  
  2790.  
  2791. local dmg,weakness,crit,immune
  2792. local atkVal, defVal = "Atk","Def"
  2793. if _G.Moves[Move.Name]["AttackType"] == "Special" then
  2794. atkVal, defVal = "SpA","SpD"
  2795. end
  2796. if _G.Moves[Move.Name]["AttackType"] ~= "Status" then
  2797. if Move.Name == "Seismic Toss" and Move.Name == "Night Shade" then
  2798. dmg = userPoke.Lvl.Value
  2799.  
  2800. elseif type(_G.Moves[Move.Name]["Power"]) == "number" then
  2801. dmg, weakness, crit, immune = dmgcalculate(AIPoke,userPoke,Move.Name,oppmod[atkVal],usermod[defVal],1)
  2802. end
  2803. end
  2804. if dmg == nil then
  2805. if (_G.Moves[Move.Name]["Effects"]["Heal"] or _G.Moves[Move.Name]["Effects"]["Rest"]) and AIPoke.CurrentHP.Value <= AIPoke.Stats.HPStat.Value*2/3 then
  2806. table.insert(calculations,Move)
  2807. elseif (_G.Moves[Move.Name]["Effects"]["Status"] and userPoke.Status.Value == "") or (_G.Moves[Move.Name]["Effects"]["Status"] == nil and _G.Moves[Move.Name]["Effects"]["Heal"] == nil and _G.Moves[Move.Name]["Effects"]["Rest"] == nil) then
  2808. table.insert(calculations,Move)
  2809. end
  2810. else
  2811. table.insert(calculations,Move)
  2812. end
  2813.  
  2814. end
  2815.  
  2816. --for i,v in ipairs(calculations) do print(v) end
  2817. if highdamage > userPoke.CurrentHP.Value then
  2818. determinemove = highmove
  2819.  
  2820. end
  2821.  
  2822. if determinemove == nil and #calculations > 0 then
  2823. determinemove = calculations[math.random(1,#calculations)]
  2824. elseif #calculations == 0 then
  2825. return wildmove(AIPoke)
  2826. end
  2827.  
  2828. return determinemove.Name
  2829. else
  2830. return wildmove(AIPoke)
  2831. end
  2832. end
  2833.  
  2834. --[[
  2835. ==================================
  2836. User Picks Move
  2837. ==================================
  2838. --]]
  2839. function pickmove(poke1,movelist)
  2840. local movechosen = nil
  2841. local num = 0
  2842. changevisible(buttonholder,"TextButton",false)
  2843. for i,v in ipairs(movelist:GetChildren()) do
  2844. if v:IsA("TextButton") then
  2845. num = num + 1
  2846. -- getfenv()["Enter"..num] = v.MouseEnter:connect(function()
  2847. -- movelist.MoveInfo.PP.Text = "PP: "..poke1["Moves"][v.Text]["PP"].Value.."/".._G.Moves[v.Text]["PP"]
  2848. -- end)
  2849. --[[
  2850. ==================================
  2851. Messy Events, but reduces lag and future problems by disconnecting them.
  2852. ==================================
  2853. --]]
  2854. getfenv()["blah"..num] = v.MouseButton1Click:connect(function()
  2855. battle.ButtonHolder.Back.Visible = false
  2856. if v.CrossHolder.Visible == false and poke1["Moves"][v.MoveName.Text]["PP"].Value > 0 then
  2857. movechosen = v.MoveName.Text
  2858. for happy = 1, 4 do
  2859. if getfenv()["Enter"..happy] ~= nil then
  2860. getfenv()["Enter"..happy]:disconnect()
  2861. end
  2862. if getfenv()["blah"..happy] ~= nil then
  2863. getfenv()["blah"..happy]:disconnect()
  2864. end
  2865. end
  2866. elseif v.CrossHolder.Visible == true then
  2867. movelist.Visible = false
  2868. scrolltext(dialog, "You cannot use "..v.MoveName.Text.."!")
  2869. dialog.Text = ""
  2870. dropshadowdialog.Text = ""
  2871. moveappear(poke1,movelist)
  2872. else
  2873. movelist.Visible = false
  2874. scrolltext(dialog, "You don't have enough PP to use "..v.MoveName.Text.."!")
  2875. dialog.Text = ""
  2876. dropshadowdialog.Text = ""
  2877. moveappear(poke1,movelist)
  2878. end
  2879.  
  2880. end)
  2881. end
  2882. end
  2883. repeat wait() until movechosen~= nil
  2884. unactive = false
  2885. movelist.Visible = false
  2886. return "Move",movechosen
  2887. end
  2888.  
  2889. function fixmoves(cfg)
  2890. local val = false
  2891. for i,v in ipairs(cfg.Moves:GetChildren()) do
  2892. if v.Value > 4 then
  2893. val = true
  2894. end
  2895. end
  2896. if val == true then
  2897. Math:FixMoves(cfg)
  2898. end
  2899. end
  2900.  
  2901. function weaksounds(w)
  2902. if w > 1 then
  2903. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476487"
  2904. p.PlayerGui.SoundEffect:Play()
  2905.  
  2906. elseif w < 1 and w ~= 0 then
  2907. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476277"
  2908. p.PlayerGui.SoundEffect:Play()
  2909. elseif w ~= 0 then
  2910. p.PlayerGui.SoundEffect.SoundId = "http://www.roblox.com/asset/?id=201476240"
  2911. p.PlayerGui.SoundEffect:Play()
  2912. end
  2913. end
  2914. --[[
  2915. transformed function
  2916. --]]
  2917. function transformed(pokemon,defender,foe)
  2918. originalstats[pokemon] = {}
  2919. local t = originalstats[pokemon]
  2920. t["Moves"] = {}
  2921. t["Stats"] = {}
  2922. t["Type"] = _G.Pokemon[defender.Name]["Type"]
  2923. for i,v in ipairs(pokemon.Moves:GetChildren()) do
  2924. t["Moves"][v.Value] = v.Name
  2925. end
  2926. for i,v in ipairs(pokemon.Stats:GetChildren()) do
  2927. t["Stats"][v.Name] = v.Value
  2928. end
  2929. for i,v in ipairs(pokemon.Stats:GetChildren()) do
  2930. if v.Name ~= "HPStat" then
  2931. v:Destroy()
  2932. end
  2933. end
  2934. for i,v in ipairs(pokemon.Moves:GetChildren()) do
  2935. v:Destroy()
  2936. end
  2937. for i,v in ipairs(defender.Moves:GetChildren()) do
  2938. v:Clone().Parent = pokemon.Moves
  2939. end
  2940. for i,v in ipairs(defender.Stats:GetChildren()) do
  2941. if v.Name ~= "HPStat" then
  2942. v:Clone().Parent = pokemon.Stats
  2943. end
  2944. end
  2945. if foe == false then
  2946. yourpokemon:TweenSizeAndPosition(UDim2.new(0,0,0,0),yourpokemon.Position + UDim2.new(1,0,1,0),"Out","Quad",.7)
  2947. wait(.75)
  2948. yourpokemon:TweenSize(UDim2.new(-1,0,-1,0),"Out","Quad",.7)
  2949. wait(.75)
  2950. yourpokemon:TweenSize(UDim2.new(0,0,0,0),"Out","Quad",.7)
  2951. wait(.75)
  2952. yourpokemon:TweenSize(UDim2.new(-1,0,-1,0),"Out","Quad",.7)
  2953. wait(.75)
  2954. yourpokemon:TweenSize(UDim2.new(0,0,0,0),"Out","Quad",.7)
  2955. wait(.75)
  2956. _G.getBackSprite(yourpokemon,defender)
  2957.  
  2958. yourpokemon:TweenSizeAndPosition(UDim2.new(1,0,1,0),yourpokemon.Position - UDim2.new(1,0,1,0),"Out","Quad",.7,false, function() yourpokemon.Position = UDim2.new(0, 0, 0.25,0) end)
  2959. usermod = oppmod
  2960. else
  2961. theirpokemon:TweenSizeAndPosition(UDim2.new(0,0,0,0),theirpokemon.Position + UDim2.new(1,0,1,0),"Out","Quad",.7)
  2962. wait(.75)
  2963. theirpokemon:TweenSize(UDim2.new(-1,0,-1,0),"Out","Quad",.7)
  2964. wait(.75)
  2965. theirpokemon:TweenSize(UDim2.new(0,0,0,0),"Out","Quad",.7)
  2966. wait(.75)
  2967. theirpokemon:TweenSize(UDim2.new(-1,0,-1,0),"Out","Quad",.7)
  2968. wait(.75)
  2969. theirpokemon:TweenSize(UDim2.new(0,0,0,0),"Out","Quad",.7)
  2970. wait(.75)
  2971. _G.getFrontSprite(theirpokemon,defender)
  2972.  
  2973. theirpokemon:TweenSizeAndPosition(UDim2.new(1,0,1,0),theirpokemon.Position -UDim2.new(-1,0,-1,0),"Out","Quad",.7,false,function() theirpokemon.Position = UDim2.new(0, 0, 0, 0) end)
  2974. oppmod = usermod
  2975. end
  2976. scrolltext(dialog, pokemon.Name.." transformed into "..defender.Name.."!")
  2977. end
  2978.  
  2979. --[[
  2980. returned pokemon to normal
  2981. --]]
  2982. function returnstats()
  2983. for pokemon,tabl in pairs(originalstats) do
  2984. if pokemon and pokemon.Parent == p.PokemonParty then
  2985. for i,v in ipairs(pokemon.Moves:GetChildren()) do
  2986. v:Destroy()
  2987. end
  2988. for i,v in ipairs(pokemon.Stats:GetChildren()) do
  2989. v:Destroy()
  2990. end
  2991. for value,movename in pairs(tabl["Moves"]) do
  2992. local newmove = Instance.new("IntValue",pokemon.Moves)
  2993. local pp = Instance.new("IntValue",newmove)
  2994. pp.Name = "PP"
  2995. pp.Value = _G.Moves[movename]["PP"]
  2996. newmove.Name = movename
  2997. newmove.Value = value
  2998. end
  2999. for statname,value in pairs(tabl["Stats"]) do
  3000. local newstat = Instance.new("IntValue",pokemon.Stats)
  3001. newstat.Name = statname
  3002. newstat.Value = value
  3003. end
  3004. end
  3005. end
  3006. end
  3007.  
  3008. function findWeakness(Move,Poke2)
  3009. local weakness = 1
  3010. local typetable = _G.Tables.TypeChart[_G.Moves[Move]["Type"]]
  3011. local types = _G.Pokemon[Poke2.Name]["Type"]
  3012. if originalstats[Poke2] then
  3013. types = originalstats[Poke2]["Type"]
  3014. end
  3015. for i,v in pairs(types) do
  3016. --Immune
  3017. for _,weak in ipairs(typetable["0x"]) do
  3018. if v == weak then
  3019. weakness = weakness * 0
  3020. end
  3021. end
  3022. end
  3023. return weakness
  3024. end
  3025. --[[
  3026. Contact move abilities
  3027. --]]
  3028. local contactStatus = {
  3029. ["Static"] = {"Paralysis"},
  3030. ["Effect Spore"] = {"Paralysis","Sleep","Poison"},
  3031. ["Flame Body"] = {"Burn"},
  3032. ["Poison Point"] = {"Poison"},
  3033. }
  3034. function contactMoveDefender(attacker,defender,move,foe)
  3035.  
  3036. local ability
  3037. if _G.Pokemon[defender.Name]["Ability"] then
  3038. ability = _G.Pokemon[defender.Name]["Ability"]
  3039. end
  3040. if contactStatus[ability] then
  3041. local chance = math.random(1,100)
  3042. if chance <= 30 then
  3043.  
  3044. local newStatus = contactStatus[ability][math.random(1,#contactStatus[ability])]
  3045. if (immunestatus[newStatus] and not isType(attacker,immunestatus[newStatus])) then
  3046. if (newStatus == "Poison" and not isType(attacker,"Steel")) or newStatus ~= "Poison" then
  3047. attacker.Status.Value = newStatus
  3048.  
  3049. statusupdate(attacker,foe)
  3050. end
  3051. end
  3052. end
  3053. end
  3054.  
  3055. end
  3056. --[[
  3057. ==============================================
  3058. MOVE
  3059. ===============================================
  3060. --]]
  3061.  
  3062. function superaction(dialog,attacker,defender,move,foe,moveInformation)
  3063. --print(attacker.Name)
  3064. checkfaint(attacker,foe)
  3065.  
  3066. buttonholder.MegaEvolve.Visible = false
  3067. if attacker.CurrentHP.Value > 0 then
  3068. dmg=0
  3069. local weakness = 1
  3070. local crit = 1
  3071. local immune= nil
  3072. flinch = false
  3073. local timesused = 1
  3074. local localtimesactuallyused = 0
  3075. local pressure = 1
  3076.  
  3077. if foe then
  3078. DBfoe = false
  3079. else
  3080. DBuse = false
  3081. end
  3082. if _G.Pokemon[defender.Name]["Ability"] and _G.Pokemon[defender.Name]["Ability"] == "Pressure" then
  3083. pressure = 2
  3084. end
  3085.  
  3086. if foe == true and _G.Moves[move]["Effects"]["Protect"] == nil then
  3087. oppprotect = 1
  3088. end
  3089. if foe == false and _G.Moves[move]["Effects"]["Protect"] == nil then
  3090. userprotect = 1
  3091. end
  3092. --print(move,foe,userIsProtected,_G.Moves[move]["AttackType"],_G.Moves[move]["Accuracy"])
  3093. local hpbefore = defender.CurrentHP.Value
  3094. if foe == true then
  3095. atk = {oppmod,theirconfusion,"The "..prefix.." ",theirpokeout,theirpokemon,theiranime,tbox}
  3096. def = {usermod,urconfusion,"",yourpokeout,yourpokemon,youranime,ybox}
  3097. else
  3098. atk = {usermod,urconfusion,"",yourpokeout,yourpokemon,youranime,ybox}
  3099. def = {oppmod,theirconfusion,"the "..prefix.." ",theirpokeout,theirpokemon,theiranime,tbox}
  3100. end
  3101. if not confusedcheck(attacker,foe,atk[2]) then
  3102. if not paralyzecheck(attacker,foe) and not freezecheck(attacker,foe) and not sleepcheck(attacker,foe) then
  3103.  
  3104. if attacker.HeldItem.Value == "Toxic Orb" and attacker.Status.Value == "" and not isType(attacker,"Poison") and not isType(attacker,"Steel") then
  3105. attacker.Status.Value = "BadlyPoison"
  3106.  
  3107. if foe == true then
  3108. badpoisonOpp = .0625
  3109. else
  3110. badpoisonUser = .0625
  3111. end
  3112. scrolltext(dialog,nickname(attacker).." was badly poisoned by Toxic Orb!")
  3113. statusupdate(attacker,foe)
  3114. end
  3115. if attacker.HeldItem.Value == "Flame Orb" and attacker.Status.Value == "" and not isType(attacker,"Fire") then
  3116. attacker.Status.Value = "Burn"
  3117. scrolltext(dialog,nickname(attacker).." was burnt by Flame Orb!")
  3118. statusupdate(attacker,foe)
  3119. end
  3120. scrolltext(dialog, atk[3]..nickname(attacker).." used "..move.."!")
  3121. if move ~= "Struggle" then
  3122. attacker["Moves"][move]["PP"].Value = math.max(0,attacker["Moves"][move]["PP"].Value - pressure)
  3123. end
  3124. if _G.Moves[move]["Effects"]["MultiHit"] ~= nil then
  3125.  
  3126. timesused = math.random(2,_G.Moves[move]["Effects"]["MultiHit"])
  3127. if _G.Pokemon[attacker.Name]["Ability"] and _G.Pokemon[attacker.Name]["Ability"] == "Skill Link" then
  3128. timesused = _G.Moves[move]["Effects"]["MultiHit"]
  3129. end
  3130. end
  3131. if move == "Splash" then
  3132. scrolltext(dialog,"But it does nothing at all...")
  3133. elseif move == "Transform" then
  3134. if defender.Name ~= "Aegis MKII" then
  3135. transformed(attacker,defender,foe)
  3136. else
  3137. scrolltext(dialog,"But it failed!")
  3138. end
  3139. elseif move == "Sucker Punch" then
  3140.  
  3141. elseif (move == "Dream Eater" and defender.Status.Value ~= "Sleep") then
  3142. scrolltext(dialog,"But "..defender.Name.." is awake!")
  3143. elseif ((foe and userIsProtected) or (not foe and oppIsProtected)) and (type(_G.Moves[move]["Accuracy"]) == "number" or _G.Moves[move]["AttackType"] ~= "Status") then
  3144. scrolltext(dialog,nickname(defender).." protected itself!")
  3145. elseif accfunc(move,atk[1]["Acc"],def[1]["Evade"],attacker,defender) then
  3146. for lolz = 1, timesused do
  3147. if _G.Moves[move]["SetDamage"] ~= nil then
  3148. if _G.Moves[move]["SetDamage"] == "Level" then
  3149. dmg = attacker.Lvl.Value
  3150. else
  3151. dmg = _G.Moves[move]["SetDamage"]
  3152. end
  3153. crit = 1
  3154. weakness = findWeakness(move,defender)
  3155. if weakness == 0 then
  3156. dmg = 0
  3157. end
  3158. elseif _G.Moves[move]["AttackType"] == "Physical" then
  3159. dmg, weakness, crit, immune = dmgcalculate(attacker,defender,move,atk[1]["Atk"],def[1]["Def"],critfunc(_G.Moves[move]["CritChance"],attacker,defender))
  3160. elseif _G.Moves[move]["AttackType"] == "Special" then
  3161. dmg, weakness, crit, immune = dmgcalculate(attacker,defender,move,atk[1]["SpA"],def[1]["SpD"],critfunc(_G.Moves[move]["CritChance"],attacker,defender))
  3162. elseif _G.Moves[move]["AttackType"] == "Status" then
  3163. for i,v in ipairs(_G.Tables.TypeChart[_G.Moves[move]["Type"]]["0x"]) do
  3164. for i2,v2 in ipairs(_G.Pokemon[defender.Name]["Type"]) do
  3165. if v == v2 and _G.Moves[move]["Accuracy"] ~= true then
  3166.  
  3167. weakness = 0
  3168. end
  3169. end
  3170. end
  3171. if weakness ~= 0 or _G.Moves[move]["Effects"]["HitsEverything"] == true then
  3172. passivemove(defender,attacker,atk[1],def[1],move,theirpokeout,foe)
  3173. end
  3174.  
  3175.  
  3176. end --Determing Category Type end
  3177. local hpbefore = defender.CurrentHP.Value
  3178. if dmg > hpbefore then
  3179. dmg = hpbefore
  3180. end
  3181. local sturdy
  3182. local focussash
  3183. if hpbefore == defender.Stats.HPStat.Value and _G.Pokemon[defender.Name]["Ability"] == "Multiscale" and abilitydenier[_G.Pokemon[attacker.Name]["Ability"]] == nil then
  3184. dmg = math.ceil(dmg/2)
  3185. end
  3186. if hpbefore == defender.Stats.HPStat.Value and dmg >= hpbefore then
  3187. if abilitydenier[_G.Pokemon[attacker.Name]["Ability"]] == nil and (_G.Pokemon[defender.Name]["Ability"] == "Sturdy") then
  3188. sturdy = true
  3189. elseif defender.HeldItem.Value == "Focus Sash" then
  3190. focussash = true
  3191. end
  3192.  
  3193. end
  3194. if (dmg > 0 and hpbefore > 0) then
  3195. weaksounds(weakness)
  3196.  
  3197. if move == "False Swipe" and defender.CurrentHP.Value - dmg <= 0 or (sturdy == true or focussash == true) then
  3198. Math:TakeDamage(defender,1)
  3199. else
  3200. Math:TakeDamage(defender,defender.CurrentHP.Value - dmg)
  3201. end
  3202.  
  3203. def[6].ImageColor3 = _G.Tables.TypeColors[_G.Moves[move]["Type"]]
  3204. def[6].Visible = true
  3205. wait(.1)
  3206. def[6].Visible = false
  3207. wait(.1)
  3208. def[5].Visible = false
  3209. wait(.1)
  3210. def[5].Visible = true
  3211. if defender.CurrentHP.Value > 0 then
  3212. localtimesactuallyused = localtimesactuallyused + 1
  3213. updatehealth(def[7],defender,defender.CurrentHP.Value)
  3214. if focussash == true then
  3215. scrolltext(dialog,nickname(defender).." held on with its Focus Sash!")
  3216. game.ReplicatedStorage.REvents.Pokemon.ConsumeHeldItem:InvokeServer(defender)
  3217. end
  3218. if sturdy == true then
  3219. scrolltext(dialog,nickname(defender).." held on with its sturdiness!")
  3220. end
  3221. if crit == 2 then
  3222. scrolltext(dialog,"It's a critical hit!")
  3223. end
  3224. if _G.Moves[move]["Effects"]["HitsEverything"] == nil then
  3225. if _G.Moves[move]["Effects"]["MultiHit"] == nil then
  3226. weak(weakness,defender,foe,immune)
  3227. end
  3228. end
  3229.  
  3230. passivemove(defender,attacker,atk[1],def[1],move,theirpokeout,foe)
  3231.  
  3232. elseif defender.CurrentHP.Value <= 0 then
  3233. defender.CurrentHP.Value = 0
  3234. updatehealth(def[7],defender,defender.CurrentHP.Value)
  3235. if crit == 2 then
  3236. scrolltext(dialog,"It's a critical hit!")
  3237. end
  3238. if _G.Moves[move]["Effects"]["HitEverything"] == nil then
  3239. if _G.Moves[move]["Effects"]["MultiHit"] == nil then
  3240. weak(weakness,defender,foe,immune)
  3241. end
  3242. end
  3243. --POTENTIAL BUGS HERE
  3244. passivemove(defender,attacker,atk[1],def[1],move,theirpokeout,foe)
  3245. --BUGS HERE
  3246.  
  3247. checkfaint(defender,not foe)
  3248. if (foe and DBuse) or (not foe and DBfoe) then
  3249. local box
  3250. if foe == true then
  3251. box = tbox
  3252. else
  3253. box = ybox
  3254. box.HPLabel.Text = 0
  3255. box.HPLabel.Shadow.Text = 0
  3256. end
  3257. attacker.CurrentHP.Value = 0
  3258. updatehealth(box,attacker,hpbefore,true)
  3259. attacker.Status.Value = "Faint"
  3260. scrolltext(dialog, nickname(defender).." took down the foe with it!")
  3261. checkfaint(attacker,foe)
  3262. end
  3263. localtimesactuallyused = localtimesactuallyused + 1
  3264. break
  3265. end
  3266.  
  3267. elseif dmg == 0 then --dmg < 0 line
  3268. if _G.Moves[move]["Effects"]["HitsEverything"] == nil then
  3269. if _G.Moves[move]["Effects"]["MultiHit"] == nil then
  3270. weak(weakness,defender,foe,immune)
  3271. end
  3272. end
  3273. elseif type(hpbefore) == "number" and hpbefore == 0 then
  3274. scrolltext(dialog,"But there's nothing there!")
  3275.  
  3276. end
  3277. end
  3278. if attacker.Status.Value == "" and attacker.CurrentHP.Value > 0 and _G.Moves[move]["Contact"] then
  3279. contactMoveDefender(attacker,defender,move,foe)
  3280. end
  3281. local sheerWorkAround
  3282. if _G.Pokemon[attacker.Name]["Ability"] == "Sheer Force" and SheerForceCheck(move) then
  3283. sheerWorkAround = true
  3284. end
  3285. if attacker.HeldItem.Value == "Life Orb" and dmg > 0 and sheerWorkAround ~= true then
  3286. local curhp = attacker.CurrentHP.Value
  3287. scrolltext(dialog,nickname(attacker).." lost some of its HP!")
  3288. attacker.CurrentHP.Value = math.max(0,attacker.CurrentHP.Value-math.floor((attacker.Stats.HPStat.Value/10)))
  3289. local box = ybox
  3290. if foe == true then
  3291. box = tbox
  3292. end
  3293. updatehealth(box,attacker,attacker.CurrentHP.Value)
  3294. checkfaint(attacker,foe)
  3295.  
  3296. end
  3297. if _G.Moves[move]["UserFaint"] ~= nil then
  3298. local hpbefore = attacker.CurrentHP.Value
  3299. local box
  3300. if foe == true then
  3301. box = tbox
  3302. else
  3303. box = ybox
  3304. box.HPLabel.Text = "0 / "..attacker.Stats.HPStat.Value
  3305. box.HPLabel.Shadow.Text = box.HPLabel.Text
  3306. end
  3307. attacker.CurrentHP.Value = 0
  3308. updatehealth(box,attacker,hpbefore,true)
  3309. attacker.Status.Value = "Faint"
  3310. checkfaint(attacker,foe)
  3311. end
  3312. elseif type(hpbefore) == "number" and hpbefore == 0 then
  3313. scrolltext(dialog,"But there's nothing there!")
  3314.  
  3315. else
  3316. scrolltext(dialog, atk[3]..nickname(attacker).."'s attack missed!")
  3317.  
  3318. end
  3319. if timesused > 1 then
  3320. weak(weakness,defender,foe,immune)
  3321. if localtimesactuallyused > 1 then
  3322. scrolltext(dialog, "It hit "..localtimesactuallyused.." times!")
  3323. elseif localtimesactuallyused == 1 then
  3324. scrolltext(dialog, "It hit "..localtimesactuallyused.." time!")
  3325. end
  3326. end
  3327.  
  3328. end
  3329. else --status effect check else
  3330. end
  3331. end
  3332. end
  3333.  
  3334.  
  3335. --[[
  3336. ==================================
  3337. Turn of Battle
  3338. ==================================
  3339. --]]
  3340. function turn(dialog,fight,sprite,name)
  3341. Math:RequestChange(p.InBattle,true)
  3342. typeaction = nil
  3343. action = nil
  3344. runvar = false
  3345. local GonnaMega = false
  3346. buttonholder.MegaEvolve.Position = UDim2.new(0.25, 0,1, 0)
  3347. if MegaEvent then MegaEvent:disconnect() end
  3348. oppRoosting = false
  3349. userRoosting = false
  3350. userIsProtected = false
  3351. oppIsProtected = false
  3352. if yourpokefaint == true then
  3353. yourpokemon.Position = UDim2.new(0, 0, 0.25, 0)
  3354. typeofaction,poke = _G.PartyBattle(yourpokeout,battle,"Cancel")
  3355. repeat wait() until typeofaction ~= nil
  3356. yourpokeout = returnpokemon(yourpokeball,yourpokemon,ybox,poke)
  3357. end
  3358.  
  3359. if originalstats[yourpokeout] == nil then
  3360. findexploiters(yourpokeout)
  3361. end
  3362.  
  3363. _G.InButtonVariable = false
  3364. buttonholder.Fight.PokemonSprite.Image = _G.Pokemon[yourpokeout.Name]["Sprites"]["Mini"]
  3365. if theirpokefaint == true and yourpokefaint == false then
  3366.  
  3367.  
  3368. wait(.4)
  3369. theirpokemon.Position = UDim2.new(0, 0, 0, 0)
  3370. local opppoke = getpokemon(theirpokeout)
  3371. if checknumber(userteam) > 1 and checknumber(oppteam) > 0 and zol ~= true then
  3372.  
  3373. scrolltext(dialog,sprite.." "..name.." is about to use "..opppoke.Name..".")
  3374. scrolltext(dialog,"Will you change Pokemon?",true)
  3375. wait(.5)
  3376. changevisible(battle.YesNoHolder,"TextButton",true)
  3377. if yes then yes:disconnect() end if no then no:disconnect() end
  3378. yes = battle.YesNoHolder.Yes.MouseButton1Click:connect(function()
  3379. battle.Visible = false
  3380. typeaction,action = _G.PartyBattle(yourpokeout,battle)
  3381. --if yes then yes:disconnect() end if no then no:disconnect() end
  3382. end)
  3383. no = battle.YesNoHolder.No.MouseButton1Click:connect(function()
  3384. typeaction = false
  3385. --if yes then yes:disconnect() end if no then no:disconnect() end
  3386. end)
  3387. repeat wait() until typeaction ~= nil
  3388. if yes then yes:disconnect() end if no then no:disconnect() end
  3389. changevisible(battle.YesNoHolder,"TextButton",false)
  3390. if typeaction ~= false then
  3391. returnpokemon(yourpokeball,yourpokemon,ybox,action)
  3392. yourpokeout = action
  3393. buttonholder.Fight.PokemonSprite.Image = _G.Pokemon[yourpokeout.Name]["Sprites"]["Mini"]
  3394. end
  3395. end
  3396. theirpokeout = foereturnpokemon(theirpokeball,theirpokemon,tbox,opppoke,sprite,name)
  3397. elseif theirpokefaint == true and yourpokefaint == true then
  3398. theirpokemon.Position = UDim2.new(0, 0, 0, 0)
  3399. local opppoke = getpokemon(theirpokeout)
  3400. theirpokeout = foereturnpokemon(theirpokeball,theirpokemon,tbox,opppoke,sprite,name)
  3401. end
  3402. typeaction = nil
  3403. action = nil
  3404. animatepoke(yourpokemon)
  3405. scrolltext(dialog,"What should "..nickname(yourpokeout).." do?",true)
  3406. changevisible(buttonholder,"TextButton",true)
  3407. if userMega ~= true and ItemList[yourpokeout.HeldItem.Value] and ItemList[yourpokeout.HeldItem.Value]["MegaEvolve"] and yourpokeout.Name == ItemList[yourpokeout.HeldItem.Value]["Requirement"] then
  3408. buttonholder.MegaEvolve.PokemonSprite.Image = _G.Pokemon[ItemList[yourpokeout.HeldItem.Value]["MegaEvolve"]]["Sprites"]["Mini"]
  3409. buttonholder.MegaEvolve.BackgroundColor3 = Color3.new(0,170/255,0)
  3410. buttonholder.MegaEvolve.Title.Text = "Mega Evolve"
  3411. buttonholder.MegaEvolve.Title.Drop.Text = buttonholder.MegaEvolve.Title.Text
  3412. buttonholder.MegaEvolve.Visible = true
  3413. GonnaMega = false
  3414. MegaEvent = buttonholder.MegaEvolve.MouseButton1Click:connect(function()
  3415. if GonnaMega == false then
  3416. GonnaMega = true
  3417. buttonholder.MegaEvolve.BackgroundColor3 = Color3.new(170/255, 1, 1)
  3418. buttonholder.MegaEvolve.Title.Text = "Mega Evolving This Turn"
  3419. buttonholder.MegaEvolve.Title.Drop.Text = buttonholder.MegaEvolve.Title.Text
  3420. while userMega == true and buttonholder.MegaEvolve.Visible == true do
  3421. buttonholder.MegaEvolve.PokemonSprite.Position = UDim2.new(0,0,0,0)
  3422. wait(.2)
  3423. buttonholder.MegaEvolve.PokemonSprite.Position = UDim2.new(0,0,0,2)
  3424. wait(.2)
  3425. end
  3426. elseif GonnaMega == true then
  3427. GonnaMega = false
  3428. buttonholder.MegaEvolve.Title.Text = "Mega Evolve"
  3429. buttonholder.MegaEvolve.Title.Drop.Text = buttonholder.MegaEvolve.Title.Text
  3430. buttonholder.MegaEvolve.BackgroundColor3 = Color3.new(0,170/255,0)
  3431. end
  3432. end)
  3433. else
  3434. buttonholder.MegaEvolve.Visible = false
  3435. end
  3436. yourpokefaint = false
  3437. theirpokefaint = false
  3438. if fightevent then
  3439. fightevent:disconnect()
  3440. end
  3441. if bagevent then
  3442. bagevent:disconnect()
  3443. end
  3444. if partyevent then
  3445. partyevent:disconnect()
  3446. end
  3447. --===========================
  3448. --"Fight Event" (Picking Moves)
  3449. --===========================
  3450. fightevent = fight.MouseButton1Click:connect(function()
  3451. if runvar == false then
  3452. dialog.Text = ""
  3453. dropshadowdialog.Text = ""
  3454. buttonholder.MegaEvolve.Position = UDim2.new(0.25, 0,0, 0)
  3455. if ppchecker(yourpokeout.Moves) then
  3456. unactive = false
  3457. changevisible(buttonholder,"TextButton",false)
  3458. scrolltext(dialog,nickname(yourpokeout).." has no moves left!")
  3459. typeaction, action = "Move","Struggle"
  3460. else
  3461. moveappear(yourpokeout,movelist)
  3462. typeaction,action = pickmove(yourpokeout,movelist)
  3463. end
  3464. end
  3465. end)
  3466. --==============================
  3467. --"Bag Pokemon Event"
  3468. --==============================
  3469. bagevent = bag.MouseButton1Click:connect(function()
  3470. if runvar == false and zol ~= true then
  3471. typeaction,action,itemused = _G["ItemBattle"]()
  3472. elseif zol == true then
  3473. changevisible(buttonholder,"TextButton",false)
  3474. scrolltext(dialog,"You cannot use items here!",true)
  3475. wait(.6)
  3476. scrolltext(dialog,"What should "..nickname(yourpokeout).." do?",true)
  3477. changevisible(buttonholder,"TextButton",true)
  3478. end
  3479. end)
  3480. --==============================
  3481. --"Switch Pokemon Event"
  3482. --==============================
  3483. partyevent = party.MouseButton1Click:connect(function()
  3484. if runvar == false then
  3485. battle.Visible = false
  3486. typeaction,action = _G.PartyBattle(yourpokeout,battle)
  3487. end
  3488. end)
  3489. --===============================
  3490. --Run Pokmeon
  3491. --===============================
  3492. runevent = run.MouseButton1Click:connect(function()
  3493. if runvar == false and zol ~= true then
  3494. runvar = true
  3495. if prefix ~= "wild" then
  3496. changevisible(buttonholder,"TextButton",false)
  3497. scrolltext(dialog,"You cannot run from a trainer battle!",true)
  3498. wait(.5)
  3499. scrolltext(dialog,"What should "..nickname(yourpokeout).." do?",true)
  3500. changevisible(buttonholder,"TextButton",true)
  3501. runvar = false
  3502. else
  3503. runtimes = runtimes + 1
  3504. local runvalue = ((yourpokeout.Stats.SpeedStat.Value * 32) / (theirpokeout.Stats.SpeedStat.Value/4%256)) + 30 * runtimes
  3505. local rundom = math.random(1,256)
  3506. local runsuccess = runvalue/rundom
  3507. --print(runvalue,rundom,runsuccess)
  3508. if yourpokeout.Lvl.Value > theirpokeout.Lvl.Value then
  3509. buttonholder.MegaEvolve.Visible = false
  3510. changevisible(buttonholder,"TextButton",false)
  3511. scrolltext(dialog,"You have successfully fled!",true)
  3512. wait(.6)
  3513. moneyrun = true
  3514. typeaction = "RunSuccess"
  3515. elseif runvalue > 255 then
  3516. buttonholder.MegaEvolve.Visible = false
  3517. changevisible(buttonholder,"TextButton",false)
  3518. scrolltext(dialog,"You have successfully fled!",true)
  3519. wait(.6)
  3520. typeaction = "RunSuccess"
  3521. else
  3522. local mathrun = math.random(1,100)
  3523. if mathrun > math.floor(runsuccess * 100) then
  3524. buttonholder.MegaEvolve.Visible = false
  3525. changevisible(buttonholder,"TextButton",false)
  3526. scrolltext(dialog,"You have successfully fled!",true)
  3527. wait(.6)
  3528. typeaction = "RunSuccess"
  3529. else
  3530. changevisible(buttonholder,"TextButton",false)
  3531. scrolltext(dialog,"You cannot escape!",true)
  3532. wait(.6)
  3533. typeaction = "RunFail"
  3534. end
  3535. end
  3536. runvar = false
  3537. end
  3538. elseif zol == true then
  3539. buttonholder.MegaEvolve.Visible = false
  3540. changevisible(buttonholder,"TextButton",false)
  3541. scrolltext(dialog,"You have successfully fled!",true)
  3542. wait(.6)
  3543. typeaction = "RunBattleTower"
  3544. end
  3545.  
  3546.  
  3547. end)
  3548. repeat wait() until typeaction ~= nil
  3549. buttonholder.MegaEvolve.Visible = false
  3550. unactive = false
  3551. if sprite then
  3552. wildaction = trainerMoveCheck(theirpokeout,yourpokeout)
  3553. else
  3554. wildaction = wildmove(theirpokeout)
  3555. end
  3556. -- print(wildaction)
  3557. --==============================
  3558. --Calculating Speed (Both Pokemon Attack)
  3559. --===========================
  3560. if typeaction == "Switch" then
  3561.  
  3562.  
  3563. yourpokeout = returnpokemon(yourpokeball,yourpokemon,ybox,action)
  3564. superaction(dialog,theirpokeout,yourpokeout,wildaction,true)
  3565. elseif typeaction == "ItemUse" then
  3566. --print("ball")
  3567.  
  3568. changevisible(buttonholder,"TextButton",false)
  3569. if itemused:lower():match("ball") then
  3570. throwingball(itemused)
  3571. if action == "Fail" then
  3572. superaction(dialog,theirpokeout,yourpokeout,wildaction,true)
  3573. elseif _G.ShakeCheck == "Success" then
  3574. capturedpokemon(itemused)
  3575. clearpokemon(p)
  3576. p.InBattle.Value = false
  3577. result = "Win"
  3578. end
  3579. else
  3580. useditem(itemused,action)
  3581. superaction(dialog,theirpokeout,yourpokeout,wildaction,true)
  3582. end
  3583. elseif typeaction == "RunSuccess" then
  3584. clearpokemon(p)
  3585. p.InBattle.Value = false
  3586. result = "Win"
  3587. elseif typeaction == "RunBattleTower" then
  3588. clearpokemon(p)
  3589. p.InBattle.Value = false
  3590. result = "Lose"
  3591. elseif typeaction == "RunFail" then
  3592. superaction(dialog,theirpokeout,yourpokeout,wildaction,true)
  3593. elseif typeaction == "Move" then
  3594. if GonnaMega == true then
  3595. userMega = true
  3596. local oldname = yourpokeout.Name
  3597. oldform = yourpokeout.Name
  3598. megaPokemon = yourpokeout
  3599. local megaEvolution = ItemList[yourpokeout.HeldItem.Value]["MegaEvolve"]
  3600. scrolltext(dialog,nickname(yourpokeout).." is awakening its true power!")
  3601. megaEvolve(yourpokemon,megaEvolution)
  3602. scrolltext(dialog,((yourpokeout:FindFirstChild("Nickname") and yourpokeout:FindFirstChild("Nickname").Value) or oldname).." has transformed into "..megaEvolution.."!")
  3603.  
  3604. end
  3605. fastpoke,firstmove,slowpoke,lastmove = speedcalc(yourpokeout,theirpokeout,action,wildaction,usermod.Speed,oppmod.Speed)
  3606. if yourpokeout == slowpoke then
  3607. if yourpokeout.CurrentHP.Value <= 0 then
  3608. checkfaint(yourpokeout,false)
  3609. end
  3610.  
  3611. superaction(dialog,theirpokeout,yourpokeout,wildaction,true)
  3612. elseif yourpokeout == fastpoke then
  3613. if theirpokeout.CurrentHP.Value <= 0 then
  3614. checkfaint(theirpokeout,false)
  3615. end
  3616. superaction(dialog,yourpokeout,theirpokeout,action,false)
  3617. end
  3618.  
  3619. if yourpokeout == slowpoke and yourpokeout.CurrentHP.Value > 0 then
  3620. if TauntUser > 0 and _G.Moves[lastmove]["Category"] == "Status" then
  3621. scrolltext(dialog,nickname(yourpokeout).." was taunted!")
  3622. else
  3623. if flinch == true then
  3624. scrolltext(dialog,nickname(yourpokeout).." flinched!")
  3625. else
  3626. superaction(dialog,yourpokeout,theirpokeout,action,false)
  3627. end
  3628.  
  3629. end
  3630. elseif yourpokeout == fastpoke and theirpokeout.CurrentHP.Value > 0 then
  3631. if TauntFoe > 0 and _G.Moves[lastmove]["Category"] == "Status" then
  3632. scrolltext(dialog,nickname(theirpokeout).." was taunted!")
  3633. else
  3634. if flinch == true then
  3635. scrolltext(dialog,"The "..prefix.." "..theirpokeout.Name.." flinched!")
  3636. else
  3637. superaction(dialog,theirpokeout,yourpokeout,wildaction,true)
  3638. end
  3639. end
  3640. end
  3641. end
  3642. if theirpokefaint == true and yourpokefaint == false then
  3643. for index,buh in pairs(pokemonexpsplit) do
  3644. if buh.Status.Value == "Faint" then
  3645. rawset(pokemonexpsplit,index,nil)
  3646. end
  3647. end
  3648. amountofpokes = #pokemonexpsplit
  3649. if p.Bag.Evolution:FindFirstChild("Exp. Share") and p.Bag.Evolution:FindFirstChild("Exp. Share").Value == true then
  3650.  
  3651. local exptable = {}
  3652. for i,v in ipairs(p.PokemonParty:GetChildren()) do
  3653. if v.Status.Value ~= "Faint" then
  3654. exptable[v.PartyPosition.Value] = v
  3655. end
  3656. end
  3657. for z,pokemonexp in pairs(exptable) do
  3658. expupdate(pokemonexp,nil,pokemonexpsplit)
  3659. end
  3660.  
  3661. else
  3662. for z,pokemonexp in pairs(pokemonexpsplit) do
  3663. expupdate(pokemonexp)
  3664. end
  3665. end
  3666. pokemonexpsplit = {}
  3667. end
  3668. if checkalive(userteam) and checkalive(oppteam) then
  3669. if leechseeduser == true and yourpokeout.CurrentHP.Value > 0 then
  3670. leechdamage(theirpokeout,yourpokeout,false)
  3671. end
  3672. if yourpokeout.HeldItem.Active.Value == true then
  3673. if yourpokeout.HeldItem.Value == "Leftovers" and yourpokeout.CurrentHP.Value > 0 and yourpokeout.CurrentHP.Value ~= yourpokeout.Stats.HPStat.Value then
  3674.  
  3675. scrolltext(dialog,nickname(yourpokeout).." healed itself with its Leftovers!")
  3676. yourpokeout.CurrentHP.Value = math.min(yourpokeout.Stats.HPStat.Value,yourpokeout.CurrentHP.Value+math.floor((yourpokeout.Stats.HPStat.Value/16)))
  3677. updatehealth(ybox,yourpokeout,yourpokeout.CurrentHP.Value)
  3678. end
  3679. end
  3680. updatehealth(ybox,yourpokeout,yourpokeout.CurrentHP.Value)
  3681. if yourpokeout.Status.Value == "Burn" and yourpokeout.CurrentHP.Value > 0 then --losehealth(percentage,pokecfg,foe,msg)
  3682. losehealth(.0625,yourpokeout,false," was hurt by its burn!")
  3683. elseif yourpokeout.Status.Value == "Poison" and yourpokeout.CurrentHP.Value > 0 then
  3684. losehealth(.125,yourpokeout,false," was hurt by poison!")
  3685. elseif yourpokeout.Status.Value == "BadlyPoison" and yourpokeout.CurrentHP.Value > 0 then
  3686. losehealth(badpoisonUser,yourpokeout,false," was hurt by poison!")
  3687. badpoisonUser = badpoisonUser + .0625
  3688. end
  3689. if leechseedopp == true and theirpokeout.CurrentHP.Value > 0 then
  3690. leechdamage(yourpokeout,theirpokeout,true)
  3691. end
  3692. if theirpokeout.HeldItem.Value == "Leftovers" and theirpokeout.CurrentHP.Value > 0 and theirpokeout.CurrentHP.Value ~= theirpokeout.Stats.HPStat.Value then
  3693.  
  3694. scrolltext(dialog,nickname(theirpokeout).." healed itself with its Leftovers!")
  3695. theirpokeout.CurrentHP.Value = math.min(theirpokeout.Stats.HPStat.Value,theirpokeout.CurrentHP.Value+math.floor((theirpokeout.Stats.HPStat.Value/16)))
  3696. updatehealth(tbox,theirpokeout,theirpokeout.CurrentHP.Value)
  3697.  
  3698. end
  3699. if theirpokeout.Status.Value == "Burn" and theirpokeout.CurrentHP.Value > 0 then --losehealth(percentage,pokecfg,foe,msg)
  3700. losehealth(.0625,theirpokeout,true," was hurt by its burn!")
  3701. elseif theirpokeout.Status.Value == "Poison" and theirpokeout.CurrentHP.Value > 0 then
  3702. losehealth(.125,theirpokeout,true," was hurt by poison!")
  3703. elseif theirpokeout.Status.Value == "BadlyPoison" and theirpokeout.CurrentHP.Value > 0 then
  3704. losehealth(badpoisonOpp,theirpokeout,true," was hurt by poison!")
  3705. badpoisonOpp = badpoisonOpp + .0625
  3706. end
  3707. userReflect = userReflect - 1
  3708. oppReflect = oppReflect - 1
  3709. userLightScreen = userLightScreen - 1
  3710. oppLightScreen = userLightScreen - 1
  3711. if userReflect == 0 then
  3712. scrolltext(dialog,"Your team's Reflect wore off!")
  3713. end
  3714. if oppReflect == 0 then
  3715. scrolltext(dialog,"The opponent team's Reflect wore off!")
  3716. end
  3717. if userLightScreen == 0 then
  3718. scrolltext(dialog,"Your team's Light Screen wore off!")
  3719. end
  3720. if oppLightScreen == 0 then
  3721. scrolltext(dialog,"Your team's Light Screen wore off!")
  3722. end
  3723. end
  3724. if not checkalive(userteam) then
  3725. if loser~=nil then
  3726. if name ~= nil then
  3727. flash.Visible = true
  3728. ybox.Visible = false
  3729. trainer.Visible = true
  3730. wait()
  3731. flash.Visible = false
  3732. scrolltext(dialog,loser)
  3733. scrolltext(dialog,p.Name.." has no Pokemon!")
  3734. if zol == nil then
  3735. scrolltext(dialog,p.Name.. " blacked out!")
  3736.  
  3737. else
  3738. scrolltext(dialog,p.Name.." lost the battle!")
  3739. end
  3740. end
  3741. end
  3742. clearpokemon(p)
  3743. Math:RequestChange(p.InBattle,false)
  3744. result = "Lose"
  3745. wait(.2)
  3746. _G.currentgrass = nil
  3747. elseif not checkalive(oppteam) then
  3748. if name ~= nil then
  3749. scrolltext(dialog,sprite.." "..name.." lost the battle!")
  3750. flash.Visible = true
  3751. tbox.Visible = false
  3752. trainer.Visible = true
  3753. end
  3754. if winner ~= nil and result == nil then
  3755. wait()
  3756. flash.Visible = false
  3757. scrolltext(dialog,winner)
  3758. end
  3759. clearpokemon(p)
  3760. p.InBattle.Value = false
  3761. evolutionchecker()
  3762. if result ~= "Lose" then
  3763. result = "Win"
  3764. end
  3765. end
  3766. if result ~= "Win" and result ~= "Lose" then
  3767. turn(dialog,fight,sprite,name)
  3768. else
  3769. if oldform and megaPokemon then
  3770. megaPokemon.Name = oldform
  3771. megaPokemon.Reverse.Value = oldform:reverse()
  3772. Math:StatChange(megaPokemon)
  3773. end
  3774. end
  3775. end
  3776.  
  3777. --local textMod = require(script.CustomFont)
  3778. p = game.Players.LocalPlayer
  3779. mouse = p:GetMouse()
  3780. p:WaitForChild("PlayerGui")
  3781. gui = p.PlayerGui
  3782. gui:WaitForChild("Main")
  3783. gui.Main:WaitForChild("BlackScreen")
  3784. battle = gui.Main.BattleScene
  3785. unactive = true
  3786. yourpokeout = nil
  3787. theirpokeout = nil
  3788. trainer = battle.Trainer
  3789. tbox = battle.TheirBox
  3790. ybox = battle.YourBox
  3791. dialogbg = battle.dialogbg
  3792. evolvescreen = gui.Main.BlackScreen.Evolution
  3793. movelist = dialogbg.MovesBG
  3794. weather = {["CurrentWeather"] = nil,
  3795. ["Count"] = 0
  3796. }
  3797. theirpokemon = battle.TheirPokemon.Sprite
  3798. theirpokeball = battle.TheirPokeball
  3799. theiranime = battle.TheirPokemon.Animation
  3800. theirparty = battle.TheirParty
  3801. yourpokemon = battle.YourPokemon.Sprite
  3802. yourpokeball = battle.YourPokeball
  3803. dialog = dialogbg.dialog
  3804. dropshadowdialog = dialogbg.dialog.dropshadow
  3805. evolvedia = evolvescreen.EvolveDialog.Speak
  3806. dropShaDia = evolvescreen.EvolveDialog.Speak.dropshadow
  3807. youranime = battle.YourPokemon.Animation
  3808. yourparty = battle.YourParty
  3809. flash = battle.Flash
  3810. fight = battle.ButtonHolder.Fight
  3811. party = battle.ButtonHolder.Pokemon
  3812. run = battle.ButtonHolder.Run
  3813. bag = battle.ButtonHolder.Bag
  3814. pokeballanim = battle.PokeballAnim
  3815. -- for i,v in ipairs(evolvescreen.YesNoHolder:GetChildren()) do
  3816. -- textMod.Replace("HemiHead",v.Title.Drop)
  3817. -- textMod.Replace("HemiHead",v.Title)
  3818. -- end
  3819. soundeffect = p.PlayerGui.SoundEffect
  3820. prefix = ""
  3821. buttonholder = battle.ButtonHolder
  3822. mouse.KeyDown:connect(function(key)
  3823. if key == "q" and pressedq == nil and scrollytext == true then
  3824. pressedq = true
  3825. end
  3826. end)
  3827.  
  3828. --=====================================================
  3829. --MoveEvents
  3830. --=====================================================
  3831. local sound = Instance.new("Sound",script)
  3832. function wildAnim()
  3833. spawn(function() zoomAnim() end)
  3834. local absPosX = script.Parent.Main.battleAnim.AbsoluteSize.Y
  3835. for yPos = 0, absPosX*6, absPosX do
  3836. for i = 0, 1, .1 do
  3837. local newFrame = script.Parent.Main.battleAnim:Clone()
  3838. newFrame.Position = UDim2.new(i,0,0,yPos)
  3839. newFrame.Rotation = 50
  3840. newFrame.Parent = script.Parent.Main.animHold
  3841. newFrame.Visible = true
  3842. wait()
  3843. spawn(function()
  3844. for i = 1, 10 do
  3845. newFrame.Rotation = newFrame.Rotation - 5
  3846. wait()
  3847. end
  3848. end)
  3849. end
  3850. end
  3851.  
  3852. workspace.CurrentCamera.FieldOfView = 70
  3853. end
  3854.  
  3855. function trainAnim()
  3856. spawn(function() zoomAnim() end)
  3857. local absPosX = script.Parent.Main.battleAnim.AbsoluteSize.Y
  3858. for yPos = 0, absPosX*7, absPosX do
  3859. for i = 0, 1, .2 do
  3860. local newFrame = script.Parent.Main.battleAnim:Clone()
  3861. newFrame.Size = UDim2.new(0,0,0,0)
  3862. newFrame.Rotation = 0
  3863. newFrame.Position = UDim2.new(i-.1,0,0,yPos)
  3864. local newFrame2 = script.Parent.Main.battleAnim:Clone()
  3865. newFrame2.Size = UDim2.new(0,0,0,0)
  3866. newFrame2.Rotation = 0
  3867. newFrame2.Position = UDim2.new(i,0,0,yPos)
  3868. wait(.035)
  3869. newFrame.Parent = script.Parent.Main.animHold
  3870. newFrame.Visible = true
  3871. newFrame:TweenSize(UDim2.new(.1,1,.1,0),"Out","Quad",.25,true)
  3872. newFrame2.Parent = script.Parent.Main.animHold
  3873. newFrame2.Visible = true
  3874. newFrame2:TweenSize(UDim2.new(.1,1,.1,0),"Out","Quad",.25,true)
  3875. end
  3876. end
  3877. wait(.3)
  3878. workspace.CurrentCamera.FieldOfView = 70
  3879. end
  3880.  
  3881. function zoomAnim()
  3882. for i = 70, 120, 2 do
  3883. workspace.CurrentCamera.FieldOfView = i
  3884. wait()
  3885. end
  3886. for i = 110, 10, -10 do
  3887. workspace.CurrentCamera.FieldOfView = i
  3888. wait()
  3889. end
  3890. workspace.CurrentCamera.FieldOfView = 70
  3891. end
  3892.  
  3893.  
  3894. --local Device = require(script.getPlatform)
  3895. function guiReplace()
  3896. if p.PlayerGui:FindFirstChild("TouchGui") then
  3897.  
  3898. dialog.FontSize = "Size24"
  3899. dialog.dropshadow.FontSize = "Size24"
  3900. evolvescreen.EvolveDialog.Speak.FontSize = "Size24"
  3901. evolvescreen.EvolveDialog.Speak.dropshadow.FontSize = "Size24"
  3902. end
  3903. end
  3904. function wildWorkaround(poke)
  3905. for i,v in ipairs(p.OppPokemon:GetChildren()) do
  3906. if v ~= poke then
  3907. v:Destroy()
  3908. end
  3909. end
  3910. end
  3911.  
  3912.  
  3913. local AuraSound = Instance.new("Sound",script)
  3914. AuraSound.Name = "AuraSound"
  3915. AuraSound.SoundId = "rbxassetid://182813133"
  3916. local ShinySound = Instance.new("Sound",script)
  3917. ShinySound.Name = "ShinySound"
  3918. ShinySound.SoundId = "rbxassetid://201476450"
  3919.  
  3920. local inbattle = false
  3921. _G["BattleInitiate"] =
  3922. function(trainersprite,trainername,winnermessage,losermessage,battlescene,expero,wildanim)
  3923. if inbattle == false then
  3924. inbattle = true
  3925. script.Parent.Main.Leaderboard.Visible = false
  3926.  
  3927.  
  3928. guiReplace()
  3929. zol = nil
  3930. p.Character.Humanoid.WalkSpeed = 0
  3931. p.PlayerGui.Main.Menu.Visible = false
  3932. if p.PlayerGui:FindFirstChild("TouchGui") then
  3933. p.PlayerGui.TouchGui:FindFirstChild("TouchControlFrame").Visible = false
  3934. end
  3935. moneyrun = nil
  3936. if expero ~= nil then
  3937. -- print("Battle Tower Detected.")
  3938. zol = true
  3939. end
  3940. --=====================================================
  3941. --Setting Values and Variables
  3942. --=====================================================
  3943. usermod = {
  3944. ["Atk"] = 0,
  3945. ["Def"] = 0,
  3946. ["SpA"] = 0,
  3947. ["SpD"] = 0,
  3948. ["Speed"] = 0,
  3949. ["Acc"] = 0,
  3950. ["Evade"] = 0
  3951. }
  3952. oppmod = {
  3953. ["Atk"] = 0,
  3954. ["Def"] = 0,
  3955. ["SpA"] = 0,
  3956. ["SpD"] = 0,
  3957. ["Speed"] = 0,
  3958. ["Acc"] = 0,
  3959. ["Evade"] = 0
  3960. }
  3961. Evolution = {
  3962.  
  3963. }
  3964. originalbattle = {
  3965. }
  3966.  
  3967. originalstats = {
  3968.  
  3969. }
  3970. --originalstats = {
  3971. --instance = ["Moves"] = {}, ["Stats"]
  3972. --}
  3973. pokemonexpsplit =
  3974. {}
  3975. _G.WildPokemon = nil
  3976. p.InBattle.Value = true
  3977. runtimes = 0
  3978. theirpokemon.Image = ""
  3979. yourpokemon.Image = ""
  3980.  
  3981. theirpokefaint = false
  3982. yourpokefaint = false
  3983. winner = winnermessage
  3984. loser = losermessage
  3985. userprotect = 1
  3986. userIsProtected = false
  3987. oppprotect = 1
  3988. oppIsProtected = false
  3989. oppRoosting = false
  3990. userRoosting = false
  3991. badpoisonUser = 0.0625
  3992. badpoisonOpp = 0.0625
  3993. oldform = nil
  3994. megaPokemon = nil
  3995. DBfoe = false
  3996. TauntUser = 0
  3997. TauntFoe = 0
  3998. DBuse = false
  3999. weather = {["CurrentWeather"] = nil,
  4000. ["Count"] = 0
  4001. }
  4002. TSpikesFoe = 0
  4003. TSpikesUser = 0
  4004. userLightScreen = 0
  4005. userReflect = 0
  4006. oppReflect = 0
  4007. oppLightScreen = 0
  4008. playeraction = false
  4009. usermove = nil
  4010. battle.Visible = false
  4011. tbox.Visible = false
  4012. ybox.Visible = false
  4013. userMega = false
  4014. theirpokeball.Visible = false
  4015. theirpokemon.Visible = false
  4016. theirparty.Visible = false
  4017. yourpokeball.Visible = false
  4018. yourpokemon.Visible = false
  4019. yourparty.Visible = false
  4020. tbox.Shiny.Visible = false
  4021. tbox.Aura.Visible = false
  4022. tbox.Caught.Visible = false
  4023. battle.Parent.Party.Visible = false
  4024. flash.Visible = false
  4025. trainer.Visible = false
  4026. leechseeduser = false
  4027. leechseedopp = false
  4028. battle.TheirPokemon.ItemSprite.Visible = false
  4029. battle.Position = UDim2.new(.139,0,-1,0)
  4030. yourpokemon.Position = UDim2.new(0,0, 0.25, 0)
  4031. theirpokemon.Position = UDim2.new(0, 0, 0, 0)
  4032. local sprite = trainersprite
  4033. local name = trainername
  4034. oppteam = p.OppPokemon
  4035. userteam = p.PokemonParty
  4036. result = nil
  4037. originalparties(true)
  4038. urconfusion = false
  4039. theirconfusion = false
  4040.  
  4041. partycheck(yourparty)
  4042. --original values
  4043. for i,v in ipairs(userteam:GetChildren()) do
  4044. getfenv()["OriginalValue"..v.PartyPosition.Value..v.Name] = v.PartyPosition
  4045. end
  4046.  
  4047.  
  4048. changevisible(buttonholder,"TextButton",false)
  4049. dialog.Text = ""
  4050. dropshadowdialog.Text = ""
  4051. wait(.1)
  4052. if trainersprite ~= nil and trainersprite ~= "NPCTrainer" then
  4053. if trainersprite == "Elite Four" then
  4054. trainer.Image = _G.Sprites["Trainers"][trainername]
  4055. else
  4056. trainer.Image = _G.Sprites["Trainers"][trainersprite]
  4057. end
  4058.  
  4059.  
  4060. partycheck(theirparty)
  4061. trainer.Visible = true
  4062. --=====================================================
  4063. --Battle Start
  4064. --=====================================================
  4065. elseif trainersprite == nil then
  4066. theirpokeout = findlead(oppteam,1)
  4067. if not Pokedex:Check(theirpokeout.Name,p) and zol == nil then
  4068. Pokedex:Create(theirpokeout.Name)
  4069. end
  4070. if theirpokeout ~= nil then
  4071. _G.getFrontSprite(theirpokemon,theirpokeout)
  4072. if theirpokeout:FindFirstChild("Aura") then
  4073.  
  4074. tbox.Aura.Visible = true
  4075. elseif theirpokeout.Shiny.Value == true then
  4076.  
  4077. tbox.Shiny.Visible = true
  4078. else
  4079.  
  4080. end
  4081. if theirpokeout ~= nil then
  4082. if p.Pokedex:FindFirstChild(_G.Pokemon[theirpokeout.Name]["Pokedex"]) and p.Pokedex:FindFirstChild(_G.Pokemon[theirpokeout.Name]["Pokedex"]).Caught.Value == true then
  4083. tbox.Caught.Visible = true
  4084. else
  4085. tbox.Caught.Visible = false
  4086. end
  4087. end
  4088. boxupdate(theirpokeout,tbox,false)
  4089. theirpokemon.Visible = true
  4090. battle.Parent.Party.Visible = false
  4091. else
  4092. p.InBattle.Value = false
  4093.  
  4094. evolutionchecker()
  4095. return "Win"
  4096. end
  4097. end
  4098.  
  4099. sound = p.PlayerGui.BattleSound
  4100. local tsprite = trainersprite
  4101. local tname = trainername
  4102. if trainersprite == "NPCTrainer" then
  4103. tsprite = "Robot"
  4104. trainer.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&username="..tname
  4105. partycheck(theirparty)
  4106. trainer.Visible = true
  4107. sound.SoundId = "http://www.roblox.com/asset/?id="..trainerBattle[math.random(1,#trainerBattle)]
  4108. elseif tname == "Abraxas" then
  4109. sound.SoundId = "http://www.roblox.com/asset/?id=196517724"
  4110. elseif trainersprite == "Elite Four" then
  4111. sound.SoundId = "http://www.roblox.com/asset/?id=163691760"
  4112. elseif trainersprite == "Master" then
  4113. sound.SoundId = "http://www.roblox.com/asset/?id=166121095"
  4114. elseif trainersprite == "Saint" then
  4115. sound.SoundId = "http://www.roblox.com/asset/?id=181347288"
  4116. elseif trainersprite == "?????" then
  4117. sound.SoundId = "http://www.roblox.com/asset/?id=175757377"
  4118. elseif trainersprite == "cptt" then
  4119. sound.SoundId = "http://www.roblox.com/asset/?id=226672555"
  4120. elseif trainersprite == "/_/" then
  4121. sound.SoundId = "http://www.roblox.com/asset/?id=226672555"
  4122. elseif trainersprite == "Champion" then
  4123. sound.SoundId = "http://www.roblox.com/asset/?id=143993999"
  4124. elseif trainersprite ~= "Zombie" and trainersprite ~= "Prince" and trainersprite ~= "Elite Four" and trainersprite ~= nil then
  4125. sound.SoundId = "http://www.roblox.com/asset/?id="..trainerBattle[math.random(1,#trainerBattle)]
  4126.  
  4127. elseif trainersprite == nil then
  4128. sound.SoundId = "http://www.roblox.com/asset/?id="..wildBattle[math.random(1,#wildBattle)]
  4129. end
  4130. sound:Stop()
  4131. sound:Play()
  4132. if trainersprite == nil and wildanim == true then
  4133. wildAnim()
  4134. elseif trainersprite == nil then
  4135. zoomAnim()
  4136. else
  4137. trainAnim()
  4138. end
  4139.  
  4140. if trainersprite == nil and theirpokeout.HeldItem.Value ~= "" then
  4141. battle.TheirPokemon.ItemSprite.Image = ItemList[theirpokeout.HeldItem.Value]["Sprite"]
  4142. battle.TheirPokemon.ItemSprite.Visible = true
  4143. end
  4144. gui.Main.BlackScreen.Visible = true
  4145. script.Parent.Main.animHold:ClearAllChildren()
  4146. if battlescene ~= nil then
  4147. battle.Image = _G.Sprites["BattleBGs"][battlescene]
  4148. end
  4149. battle.Visible = true
  4150.  
  4151. battle:TweenPosition(UDim2.new(0.139, 0,.15, 0,"Out","Quad",.75))
  4152. wait(.8)
  4153. if trainersprite ~= nil then
  4154. scrolltext(dialog,tsprite.." "..tname.." wants to battle!")
  4155. theirpokeout = findlead(oppteam,1)
  4156. prefix = "foe's"
  4157. else
  4158. _G.WildPokemon = theirpokeout
  4159. wildWorkaround(theirpokeout)
  4160.  
  4161. if theirpokeout:FindFirstChild("Aura") then
  4162.  
  4163. AuraSound:Play()
  4164. scrolltext(dialog,"This Pokemon has a mysterious Aura!")
  4165. elseif theirpokeout.Shiny.Value == true then
  4166. ShinySound:Play()
  4167. scrolltext(dialog,"It's a shiny "..theirpokeout.Name.."!")
  4168. else
  4169. scrolltext(dialog,"You have encountered a wild "..theirpokeout.Name.."!")
  4170. end
  4171. prefix = "wild"
  4172.  
  4173. if theirpokeout.HeldItem.Value ~= "" then
  4174.  
  4175. scrolltext(dialog,"It seems to be holding a "..theirpokeout.HeldItem.Value.."!")
  4176. wait(.35)
  4177. scrolltext(dialog,"If you want this item, you must catch this Pokemon!")
  4178. end
  4179. end
  4180. yourpokeout = findlead(userteam,1)
  4181. reorganize(userteam,yourpokeout)
  4182. --=====================================================
  4183. --Beginning Opponent Animation
  4184. --=====================================================
  4185. if tsprite ~= nil then
  4186. --theirparty.Visible = false
  4187. pokemonout(theirpokeball,theirpokemon,tbox,theirpokeout)
  4188. scrolltext(dialog,tsprite.." "..tname.." sent out "..theirpokeout.Name.."!")
  4189. end
  4190. wait(.4)
  4191. --=====================================================
  4192. --Beginning User Animation
  4193. --=====================================================
  4194. scrolltext(dialog,"Go! "..nickname(yourpokeout).."!",true)
  4195. pokemonout(yourpokeball,yourpokemon,ybox,yourpokeout)
  4196. coroutine.resume(coroutine.create(function()repeat wait() until result ~= nil
  4197. battle:TweenPosition(UDim2.new(1.2,0,.139,0),"Out","Quad",.6,true)
  4198. for i = 0, 1, .05 do
  4199. gui.Main.BlackScreen.Transparency = i
  4200. wait(.05)
  4201. end
  4202. workspace.CurrentCamera.CameraType = "Custom"
  4203.  
  4204. battle.Visible = false
  4205. gui.Main.BlackScreen.Visible = false
  4206. gui.Main.BlackScreen.Transparency = 0
  4207.  
  4208. end))
  4209. --=====================================================
  4210. --Start of Battle
  4211. --=====================================================
  4212. turn(dialog,fight,tsprite,tname)
  4213. originalparties(false)
  4214. sound:Stop()
  4215. returnstats()
  4216. script.Parent.Main.animHold:ClearAllChildren()
  4217. if tsprite and result == "Win" and zol == nil then
  4218. --game.ReplicatedStorage.GoogleAnalytics:FireServer("WinTrainer",trainersprite.." "..trainername,p.Name,1)
  4219. elseif tsprite and result == "Lose" and zol == nil then
  4220. --game.ReplicatedStorage.GoogleAnalytics:FireServer("BlackOut",trainersprite.." "..trainername,p.Name,1)
  4221. elseif result == "Lose" then
  4222. --game.ReplicatedStorage.GoogleAnalytics:FireServer("BlackOut","WildPokemon",p.Name,1)
  4223. end
  4224. workspace.CurrentCamera.CameraSubject = p.Character
  4225. if _G.oldCamera ~= nil then
  4226. workspace.CurrentCamera.CoordinateFrame = _G.oldCamera
  4227. _G.oldCamera = nil
  4228. end
  4229. script.Parent.Main.Leaderboard.Visible = true
  4230. inbattle = false
  4231.  
  4232.  
  4233. return result, moneyrun
  4234.  
  4235.  
  4236. end
  4237. end
  4238. for i,v in pairs(partyb) do
  4239. game:GetService("ContentProvider"):Preload(v)
  4240. end
  4241.  
  4242. game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=124640823")
  4243.  
  4244. function colorLerpTab(img,color)
  4245. local colorTab = {}
  4246. local iterations = 10
  4247. for i = 1, iterations do
  4248. table.insert(colorTab,img.ImageColor3:lerp(color,i/iterations))
  4249. end
  4250. return colorTab
  4251. end
  4252.  
  4253.  
  4254. function colorChange(img,tab)
  4255. local num = 1
  4256. local tuple = tab
  4257. local imgID = img.Image
  4258.  
  4259. img.ImageColor3 = tuple[#tuple]
  4260.  
  4261. spawn(function()
  4262. while img.Image == imgID and (gui.Main.BlackScreen.Visible == true or (img.Parent and img.Parent.Name == "TheirPokemon")) do
  4263. for _,color in ipairs(tuple) do
  4264.  
  4265. local ColorTab = colorLerpTab(img,color)
  4266. for _,color3 in ipairs(ColorTab) do
  4267. img.ImageColor3 = color3
  4268. wait(.1)
  4269. if img.Image ~= imgID or (gui.Main.BlackScreen.Visible == false and img.Parent and img.Parent.Name ~= "TheirPokemon") then
  4270. break
  4271. end
  4272. end
  4273. end
  4274.  
  4275. end
  4276. end)
  4277.  
  4278. end
  4279.  
  4280. function getCountauras(cfg)
  4281. local t = {}
  4282. for i,v in ipairs(cfg.Aura:GetChildren()) do
  4283. if v.Name == "ColorChange" then
  4284. table.insert(t,v)
  4285. end
  4286. end
  4287. return t
  4288. end
  4289.  
  4290. function AuraTable(poke)
  4291. local t = {}
  4292. local num = 1
  4293. -- if poke.Aura:FindFirstChild("Animation") then
  4294. -- num = 0
  4295. -- end
  4296. if poke:FindFirstChild("Aura") then
  4297. local ter = getCountauras(poke)
  4298. for numberOf = 1, #ter do
  4299. for i,v in ipairs(ter) do
  4300. if v:FindFirstChild("Number") and v.Number.Value == num then
  4301. num = num + 1
  4302. table.insert(t,_G.tintColors[v.Value])
  4303. end
  4304. end
  4305. end
  4306. end
  4307. return t
  4308. end
  4309.  
  4310. local auraImage = {
  4311. ["Valentine Heart"] = {
  4312. ["Colors"] = {Color3.new(1,0,0),Color3.new(1,85/255,1),Color3.new(2/3,1/3,2/3)},
  4313. ["Image"] = {"rbxassetid://648337151"},
  4314. ["Size"] = UDim2.new(0,15,0,15),
  4315. ["Amount"] = 8,
  4316. },
  4317. ["Pokeball Ring"] = {
  4318. ["Colors"] = {Color3.new(1,1,1)},
  4319. ["Image"] = {"http://www.roblox.com/asset/?id=124179545","http://www.roblox.com/asset/?id=167825964","http://www.roblox.com/asset/?id=167826200","http://www.roblox.com/asset/?id=168580108"},
  4320. ["Size"] = UDim2.new(0,24,0,24),
  4321. ["Amount"] = 8,
  4322. },
  4323. ["Money Ring"] = {
  4324. ["Colors"] = {Color3.new(1,1,1)},
  4325. ["Image"] = {"rbxassetid://51041387"},
  4326. ["Size"] = UDim2.new(0,18,0,12),
  4327. ["Amount"] = 8,
  4328. },
  4329. ["ROBLOX Logo"] = {
  4330. ["Colors"] = {Color3.new(1,1,1)},
  4331. ["Image"] = {"rbxassetid://631744026"},
  4332. ["Size"] = UDim2.new(0,16,0,16),
  4333. ["Amount"] = 8,
  4334. },
  4335. ["Orbiting Fire"] = {
  4336. ["Colors"] = {Color3.new(1, 1, 1)},
  4337. ["Image"] = {"rbxassetid://654081999"},
  4338. ["Size"] = UDim2.new(0,40,0,40),
  4339. ["Amount"] = 6
  4340. }
  4341. }
  4342. function drawCircle(parent,auraType)
  4343. local colors = auraImage[auraType]["Colors"]
  4344. local image = auraImage[auraType]["Image"]
  4345. local multiply = 360/auraImage[auraType]["Amount"]
  4346. local tab = {}
  4347. local x, y, r = 0, 0,parent.AbsoluteSize.X-6
  4348. for thing = 1, auraImage[auraType]["Amount"] do
  4349. local i = thing * multiply
  4350. local angle = i * math.pi / 180
  4351. local t = Instance.new("ImageLabel",parent)
  4352. t.ImageColor3 = colors[math.random(#colors)]
  4353. t.ZIndex = 8
  4354. t.Name = "Animation"
  4355. t.BackgroundTransparency = 1
  4356. t.Image = image[math.random(#image)]
  4357. t.Size = auraImage[auraType]["Size"]
  4358. if auraType == "Orbiting Fire" then
  4359. t.ImageRectSize = Vector2.new(150,150)
  4360. spawn(function()
  4361. while t.Parent == parent do
  4362. for i = 1, 6 do
  4363. if t.Parent == parent then
  4364. wait(.1)
  4365. t.ImageRectOffset = Vector2.new((i-1)*150,0)
  4366. else
  4367. break
  4368. end
  4369. end
  4370. end
  4371.  
  4372. end)
  4373. end
  4374. local ptx, pty = math.floor(x + r * math.cos( angle )),math.floor( y + r * math.sin( angle ))
  4375. t.Position = UDim2.new(.5,(-1*(ptx)/2)-(math.floor(t.Size.X.Offset)/2),.5,(-1*(pty)/2)-(math.floor(t.Size.Y.Offset)/2))
  4376. tab[thing] = t
  4377. end
  4378. return tab
  4379. end
  4380.  
  4381. function animateCircle(tab,img,imgID,auraType)
  4382. local count = auraImage[auraType]["Amount"]
  4383. local curtab = tab
  4384. local newtab = {}
  4385. for i,v in ipairs(curtab) do
  4386. if i == count then
  4387. newtab[1] = v
  4388. pcall(function() v:TweenPosition(curtab[1].Position,"Out","Linear",.6,true) end)
  4389. elseif i ~= count then
  4390.  
  4391. newtab[i+1] = v
  4392. pcall(function() v:TweenPosition(curtab[i+1].Position,"Out","Linear",.6,true) end)
  4393. end
  4394. end
  4395. wait(.61)
  4396. if img:FindFirstChild("Animation") and img.Image == imgID and (gui.Main.BlackScreen.Visible == true or (img.Parent and img.Parent.Name == "TheirPokemon")) then
  4397. animateCircle(newtab,img,imgID,auraType)
  4398. else
  4399. for i,v in ipairs(newtab) do
  4400. v:Destroy()
  4401. end
  4402. end
  4403. end
  4404.  
  4405. function Confetti(box,Type)
  4406. local absoluteSize = math.floor(box.AbsoluteSize.X/14)
  4407. local amountCreated = math.random(absoluteSize-4,absoluteSize+4)
  4408. for i = 1, amountCreated do
  4409. local confettiImage = Instance.new("ImageLabel")
  4410. confettiImage.BackgroundTransparency = 1
  4411. confettiImage.ZIndex = 7
  4412. confettiImage.Name = "Animation"
  4413. confettiImage.Image = "rbxassetid://672738002"
  4414. if Type == "Confetti" then
  4415. local colors = {Color3.new(0,1,0),Color3.new(1,0,0),Color3.new(0,0,1),Color3.new(1,1,0)}
  4416. confettiImage.ImageColor3 = colors[math.random(#colors)]
  4417. else
  4418. confettiImage.ImageColor3 = Color3.new(math.random(6,10)/10,math.random(6,10)/10,math.random(6,10)/10)
  4419. end
  4420. local pick = math.random(1,8)
  4421.  
  4422. confettiImage.Size = UDim2.new(0,16,0,18)
  4423. confettiImage.ImageRectSize = Vector2.new(16,18)
  4424. confettiImage.ImageRectOffset = Vector2.new(pick*16,0)
  4425.  
  4426.  
  4427. local yRandom = math.random(-3,-1)
  4428.  
  4429. confettiImage.Position = UDim2.new(math.random(-5,13)/20,-16,yRandom/10,0)
  4430. confettiImage.Parent = box
  4431.  
  4432. local waitTime = math.random(30,40)/10
  4433. confettiImage:TweenPosition(UDim2.new(math.random(6,12)/10,confettiImage.Position.X.Offset,1,0),"Out","Linear",waitTime,true,function() confettiImage:Destroy() end)
  4434. end
  4435. wait(.55)
  4436. end
  4437.  
  4438.  
  4439. local currentAnimate = nil
  4440. _G.getFrontSprite = function(img,poke)
  4441. img.ClipsDescendants = true
  4442. local val = poke
  4443. if type(val) == "userdata" then
  4444. val = poke.Name
  4445. end
  4446.  
  4447. if img:FindFirstChild("Animation") then
  4448. for i,v in ipairs(img:GetChildren()) do
  4449. if v.Name == "Animation" then
  4450. v:Destroy()
  4451. end
  4452. end
  4453. end
  4454. img.Image = (poke.Shiny.Value == true and _G.Pokemon[val]["Sprites"]["SF"]) or _G.Pokemon[val]["Sprites"]["Front"]
  4455. img.ImageColor3 = Color3.new(1,1,1)
  4456.  
  4457. if poke:FindFirstChild("Aura") then
  4458. if poke.Aura:FindFirstChild("Animation") then
  4459. local animationAura = poke.Aura.Animation.Value
  4460. if animationAura == "Confetti" or animationAura == "Rainbow Confetti" then
  4461. local imgID = img.Image
  4462. spawn(function()
  4463. while img.Image == imgID and (gui.Main.BlackScreen.Visible == true or (img.Parent and img.Parent.Name == "TheirPokemon")) do
  4464. wait(.2)
  4465. if img.Image == imgID then
  4466. Confetti(img,animationAura)
  4467. end
  4468.  
  4469. end
  4470.  
  4471. end)
  4472. else
  4473. local tab = drawCircle(img,animationAura)
  4474. spawn(function() animateCircle(tab,img,img.Image,animationAura) end)
  4475. end
  4476. end
  4477. if poke.Aura:FindFirstChild("ColorChange") then
  4478. if #poke.Aura:GetChildren() == 1 then
  4479. --print(img.Name,"1")
  4480. img.ImageColor3 = _G.tintColors[poke.Aura:FindFirstChild("ColorChange").Value]
  4481. else
  4482. --print(img.Name,"2")
  4483. colorChange(img,AuraTable(poke))
  4484. end
  4485. end
  4486. end
  4487. end
  4488. _G.getBackSprite = function(img,poke)
  4489. img.ClipsDescendants = true
  4490. local val = poke
  4491. if type(val) == "userdata" then
  4492. val = poke.Name
  4493. end
  4494. if img:FindFirstChild("Animation") then
  4495. for i,v in ipairs(img:GetChildren()) do
  4496. if v.Name == "Animation" then
  4497. v:Destroy()
  4498. end
  4499. end
  4500. end
  4501. img.Image = (poke.Shiny.Value == true and _G.Pokemon[val]["Sprites"]["SB"]) or _G.Pokemon[val]["Sprites"]["Back"]
  4502. img.ImageColor3 = Color3.new(1,1,1)
  4503. if poke:FindFirstChild("Aura") then
  4504. if poke.Aura:FindFirstChild("Animation") then
  4505.  
  4506. local animationAura = poke.Aura.Animation.Value
  4507. if animationAura == "Confetti" or animationAura == "Rainbow Confetti" then
  4508. local imgID = img.Image
  4509. spawn(function()
  4510. while img.Image == imgID and (gui.Main.BlackScreen.Visible == true or (img.Parent and img.Parent.Name == "TheirPokemon")) do
  4511. wait(.2)
  4512. if img.Image == imgID then
  4513. Confetti(img,animationAura)
  4514. end
  4515. end
  4516. end)
  4517. else
  4518. local tab = drawCircle(img,animationAura)
  4519. spawn(function() animateCircle(tab,img,img.Image,animationAura) end)
  4520. end
  4521. end
  4522. if poke.Aura:FindFirstChild("ColorChange") then
  4523. if #poke.Aura:GetChildren() == 1 then
  4524. --print(img.Name,"1")
  4525. img.ImageColor3 = _G.tintColors[poke.Aura:FindFirstChild("ColorChange").Value]
  4526. else
  4527. --print(img.Name,"2")
  4528. colorChange(img,AuraTable(poke))
  4529. end
  4530. end
  4531. end
  4532. end
  4533. _G.BattleReady = true
  4534. print("BattleReady")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement