Guest User

Untitled

a guest
Jun 26th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. def pbGainEXP
  2. return if !@internalbattle
  3. successbegin=true
  4. for i in 0...4 # Not ordered by priority
  5. if !@doublebattle && pbIsDoubleBattler?(i)
  6. @battlers[i].participants=[]
  7. next
  8. end
  9. if pbIsOpposing?(i) && @battlers[i].participants.length>0 && (@battlers[i].isFainted? || @battlers[i].wasCaptured)
  10. battlerSpecies=@battlers[i].pokemon.species
  11. # Original species, not current species
  12. baseexp=@battlers[i].pokemon.baseExp
  13. level=@battlers[i].level
  14. # First count the number of participants
  15. partic=[]
  16. expshare=[]
  17. expAll=[]
  18. receivingExp=[]
  19. for j in @battlers[i].participants
  20. next if !@party1[j] || !pbIsOwner?(0,j)
  21. if @party1[j].hp>0 && !@party1[j].isEgg?
  22. expshare.push(@party1[j])
  23. receivingExp.push(@party1[j])
  24. end
  25. end
  26. next if !@party1[j] || !pbIsOwner?(0,j)
  27. if @party1[j].hp>0 && !@party1[j].isEgg? &&
  28. !(isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
  29. isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
  30. expshare.push(@party1[j])
  31. receivingExp.push(@party1[j])
  32. end
  33. end
  34. # new exp share
  35. next if !@party1[j] || !pbIsOwner?(0,j)
  36. if @party1[j].hp>0 && !@party1[j].isEgg? && $PokemonGlobal.expAll
  37. expAll.push(@party1[j])
  38. receivingExp.push(@party1[j])
  39. end
  40. end
  41. receivingExp.uniq! #remove duplicates
  42. # Now calculate EXP for the all the pokemon
  43. if receivingExp.length>0
  44. if !@opponent && successbegin && pbAllFainted?(@party2)
  45. @scene.pbWildBattleSuccess
  46. successbegin=false
  47. end
  48. for j in 0...receivingExp.length
  49. thispoke=@party1[receivingExp[j].partyIndex]
  50. next if !@party1[receivingExp[j].partyIndex] || !pbIsOwner?(0,receivingExp[j].partyIndex)
  51.  
  52. ispartic=0
  53. haveexpshare=!(isConst?(thispoke.item,PBItems,:EXPSHARE) ||
  54. isConst?(thispoke.itemInitial,PBItems,:EXPSHARE)) ? 1 : 0
  55. giveExpAll = $PokemonGlobal.expAll
  56. for k in @battlers[i].participants
  57. ispartic=1 if k==thispoke.partyIndex
  58. end
  59. if thispoke.hp>0 && !thispoke.isEgg?
  60. exp=0
  61. if expshare.length>0
  62. if partic.length==0
  63. exp=(level*baseexp).floor
  64. exp=(exp/expshare.length).floor*haveexpshare
  65. else
  66. exp=(level*baseexp/2).floor
  67. exp=(exp/partic.length).floor*ispartic + (exp/expshare.length).floor*haveexpshare
  68. end
  69. elsif ispartic==1
  70. exp=(level*baseexp/partic.length).floor
  71. elsif giveExpAll #if not a participant or holding normal exp share, give 1/2 exp
  72. exp=(level*baseexp/partic.length/2).floor
  73. end
  74. #exp=(exp*3/2).floor if @opponent
  75. if USENEWEXPFORMULA
  76. exp=(exp/3).floor
  77. exp=(exp*(100+33*(level-thispoke.level))/100).floor #DemICE's dynamic Exp. formula
  78. exp+=1 if ispartic>0 || haveexpshare>0
  79. else # Use old (Gen 1-4) Exp. formula
  80. exp=(exp/7).floor
  81. end
  82. isOutsider=(thispoke.trainerID!=self.pbPlayer.id ||
  83. (thispoke.language!=0 && thispoke.language!=self.pbPlayer.language))
  84. exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
  85. isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
  86. growthrate=thispoke.growthrate
  87. newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
  88. exp=newexp-thispoke.exp
  89. if exp > 0
  90. if isOutsider
  91. pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
  92. else
  93. pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
  94. end
Advertisement
Add Comment
Please, Sign In to add comment