def pbGainEXP
return if !@internalbattle
successbegin=true
for i in 0..3 # Not ordered by priority
if !@doublebattle && pbIsDoubleBattler?(i)
@battlers[i].participants=[]
next
end
if pbIsOpposing?(i) && @battlers[i].participants.length>0 && @battlers[i].hp<=0
dexdata=pbOpenDexData
battlerSpecies=@battlers[i].species
# Current species, not original species; also using R/S base EXP
pbDexDataOffset(dexdata,battlerSpecies,17)
baseexp=dexdata.fgetb
level=@battlers[i].level
dexdata.close
# First count the number of participants
partic=0
expshare=0
for j in @battlers[i].participants
@participants[j]=true # Add participant to global list
end
for j in @battlers[i].participants
next if !@party1[j] || !pbIsOwner?(0,j)
partic+=1 if @party1[j].hp>0 && !@party1[j].egg?
end
for j in [email protected]
next if !@party1[j] || !pbIsOwner?(0,j)
expshare+=1 if @party1[j].hp>0 && !@party1[j].egg? &&
isConst?(@party1[j].item,PBItems,:EXPSHARE)
end
# Now calculate EXP for the participants
if partic>0
if !@opponent && successbegin && pbAllFainted?(@party2)
@scene.pbWildBattleSuccess
successbegin=false
end
for j in [email protected]
thispoke=@party1[j]
next if !@party1[j] || !pbIsOwner?(0,j)
ispartic=0
level=@battlers[i].level
haveexpshare=(isConst?(thispoke.item,PBItems,:EXPSHARE)) ? 1 : 0
for k in @battlers[i].participants
ispartic=1 if k==j
end
if thispoke.hp>0 && !thispoke.egg?
exp=0
if expshare>0
exp=((level*baseexp/7).floor/2).floor
exp=(exp/partic).floor*ispartic+(exp/expshare).floor*haveexpshare
elsif ispartic==1
exp=((level*baseexp/7).floor/partic).floor
end
isOutsider=(thispoke.trainerID!=self.pbPlayer.id ||
(thispoke.language!=0 && thispoke.language!=self.pbPlayer.language))
exp=(exp*3/2).floor if @opponent
exp=(exp*3/2).floor if isOutsider
exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG)
growthrate=thispoke.growthrate
newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
exp=newexp-thispoke.exp;
if exp > 0
if isOutsider
pbDisplayPaused(_INTL("{1} gained a boosted\r\n{2} Exp. Points!",thispoke.name,exp))
else
pbDisplayPaused(_INTL("{1} gained\r\n{2} Exp. Points!",thispoke.name,exp))
end
#Gain effort value points, using RS effort values
totalev=0
for k in 0..5
totalev+=thispoke.ev[k]
end
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,battlerSpecies,23)
for k in 0..5
evgain=dexdata.fgetb
if isConst?(thispoke.item,PBItems,:MACHOBRACE)
evgain*=2
end
if evgain>0
# Can't exceed overall limit
if totalev+evgain>510
# Bug Fix: must use "-=" instead of "="
evgain-=totalev+evgain-510
end
# Can't exceed stat limit
if thispoke.ev[k]+evgain>255
# Bug Fix: must use "-=" instead of "="
evgain-=thispoke.ev[k]+evgain-255
end
# Add EV gain
thispoke.ev[k]+=evgain
if thispoke.ev[k]>255
print "Single-stat EV limit 255 exceeded.\r\nStat: #{k} EV gain: #{evgain} EVs: #{thispoke.ev.inspect}"
thispoke.ev[k]=255
end
totalev+=evgain
if totalev>510
print "EV limit 510 exceeded.\r\nTotal EVs: #{totalev} EV gain: #{evgain} EVs: #{thispoke.ev.inspect}"
end
end
end
newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
tempexp=0
curlevel=thispoke.level
thisPokeSpecies=thispoke.species
if newlevel<curlevel
debuginfo="#{thispoke.name}: #{thispoke.level}/#{newlevel} | #{thispoke.exp}/#{newexp} | gain: #{exp}"
raise RuntimeError.new(
_INTL("The new level ({1}) is less than the Pokémon's\r\ncurrent level ({2}), which shouldn't happen.\r\n[Debug: {3}]",
newlevel,curlevel,debuginfo))
return
end
if thispoke.respond_to?("isShadow?") && thispoke.isShadow?
thispoke.exp+=exp
else
tempexp1=thispoke.exp
tempexp2=0
# Find battler
battler=pbFindPlayerBattler(j)
loop do
#EXP Bar animation
startexp=PBExperience.pbGetStartExperience(curlevel,growthrate)
endexp=PBExperience.pbGetStartExperience(curlevel+1,growthrate)
tempexp2=(endexp<newexp) ? endexp : newexp
thispoke.exp=tempexp2
@scene.pbEXPBar(thispoke,battler,startexp,endexp,tempexp1,tempexp2)
tempexp1=tempexp2
curlevel+=1
break if curlevel>newlevel
oldtotalhp=thispoke.totalhp
oldattack=thispoke.attack
olddefense=thispoke.defense
oldspeed=thispoke.speed
oldspatk=thispoke.spatk
oldspdef=thispoke.spdef
thispoke.calcStats
battler.pbUpdate if battler
@scene.pbRefresh
###########################
#####MY CODE#####
#######
case rand(6)
when 0
pbDisplayPaused(_INTL("{1} looks to be getting stronger!",thispoke.name))
pbDisplayPaused(_INTL("Using PokéDex to calculate stats."))
when 1
pbDisplayPaused(_INTL("{1} is enjoying all this battle time!",thispoke.name))
pbDisplayPaused(_INTL("Let's check {1}'s stats with the PokéDex.",thispoke.name))
when 2
pbDisplayPaused(_INTL("Look at {1} go!",thispoke.name))
pbDisplayPaused(_INTL("I wonder how strong you're getting."))
when 3
pbDisplayPaused(_INTL("Battling feels good doesn't it {1}!",thispoke.name))
pbDisplayPaused(_INTL("Let's use the PokéDex to calculate your stats."))
when 4
pbDisplayPaused(_INTL("I love how strong {1} is getting!",thispoke.name))
pbDisplayPaused(_INTL("PokéDex, what are {1}'s stats?",thispoke.name))
when 5
pbDisplayPaused(_INTL("Let's put this strength to good use, {1}!",thispoke.name))
pbDisplayPaused(_INTL("Better check how strong you are."))
when 6
pbDisplayPaused(_INTL("I suspect {1} is getting stronger!",thispoke.name))
pbDisplayPaused(_INTL("PokéDex should be able to tell me."))
end
@scene.pbLevelUp(thispoke,battler,oldtotalhp,oldattack,
olddefense,oldspeed,oldspatk,oldspdef)
# Finding all moves learned at this level
# atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
# offset=atkdata.getOffset(thisPokeSpecies-1)
# length=atkdata.getLength(thisPokeSpecies-1)>>1
# atkdata.pos=offset
########
#####MY CODE#####
###########################
if battler
if battler.pokemon && @internalbattle
battler.pokemon.happiness+=2
battler.pokemon.happiness=255 if battler.pokemon.happiness>255
end
end
# pbDisplayPaused(_INTL("{1} grew to Level {2}!",thispoke.name,curlevel)) ##########MY CODE##########
# @scene.pbLevelUp(thispoke,battler,oldtotalhp,oldattack, ##########MY CODE##########
# olddefense,oldspeed,oldspatk,oldspdef) ##########MY CODE##########
# Finding all moves learned at this level
atkdata=pbRgssOpen("Data/attacksRS.dat","rb")
offset=atkdata.getOffset(thisPokeSpecies-1)
length=atkdata.getLength(thisPokeSpecies-1)>>1
atkdata.pos=offset
for k in 0..length-1
atklevel=atkdata.fgetw
move=atkdata.fgetw
if atklevel==thispoke.level
# Learned a new move
pbLearnMove(j,move)
end
end
atkdata.close
end
end
end
end
end
end
# Now clear the participants array
@battlers[i].participants=[]
end
end
end