Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pbGainEXP
- return if !@internalbattle
- successbegin=true
- for i in 0...4 # Not ordered by priority
- if !@doublebattle && pbIsDoubleBattler?(i)
- @battlers[i].participants=[]
- next
- end
- if pbIsOpposing?(i) && @battlers[i].participants.length>0 && (@battlers[i].isFainted? || @battlers[i].wasCaptured)
- battlerSpecies=@battlers[i].pokemon.species
- # Original species, not current species
- baseexp=@battlers[i].pokemon.baseExp
- level=@battlers[i].level
- # First count the number of participants
- partic=[]
- expshare=[]
- expAll=[]
- receivingExp=[]
- for j in @battlers[i].participants
- next if !@party1[j] || !pbIsOwner?(0,j)
- if @party1[j].hp>0 && !@party1[j].isEgg?
- expshare.push(@party1[j])
- receivingExp.push(@party1[j])
- end
- end
- for j in 0...@party1.length
- next if !@party1[j] || !pbIsOwner?(0,j)
- if @party1[j].hp>0 && !@party1[j].isEgg? &&
- !(isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
- isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
- expshare.push(@party1[j])
- receivingExp.push(@party1[j])
- end
- end
- # new exp share
- for j in 0...@party1.length
- next if !@party1[j] || !pbIsOwner?(0,j)
- if @party1[j].hp>0 && !@party1[j].isEgg? && $PokemonGlobal.expAll
- expAll.push(@party1[j])
- receivingExp.push(@party1[j])
- end
- end
- receivingExp.uniq! #remove duplicates
- # Now calculate EXP for the all the pokemon
- if receivingExp.length>0
- if !@opponent && successbegin && pbAllFainted?(@party2)
- @scene.pbWildBattleSuccess
- successbegin=false
- end
- for j in 0...receivingExp.length
- thispoke=@party1[receivingExp[j].partyIndex]
- next if !@party1[receivingExp[j].partyIndex] || !pbIsOwner?(0,receivingExp[j].partyIndex)
- ispartic=0
- haveexpshare=!(isConst?(thispoke.item,PBItems,:EXPSHARE) ||
- isConst?(thispoke.itemInitial,PBItems,:EXPSHARE)) ? 1 : 0
- giveExpAll = $PokemonGlobal.expAll
- for k in @battlers[i].participants
- ispartic=1 if k==thispoke.partyIndex
- end
- if thispoke.hp>0 && !thispoke.isEgg?
- exp=0
- if expshare.length>0
- if partic.length==0
- exp=(level*baseexp).floor
- exp=(exp/expshare.length).floor*haveexpshare
- else
- exp=(level*baseexp/2).floor
- exp=(exp/partic.length).floor*ispartic + (exp/expshare.length).floor*haveexpshare
- end
- elsif ispartic==1
- exp=(level*baseexp/partic.length).floor
- elsif giveExpAll #if not a participant or holding normal exp share, give 1/2 exp
- exp=(level*baseexp/partic.length/2).floor
- end
- #exp=(exp*3/2).floor if @opponent
- if USENEWEXPFORMULA
- exp=(exp/3).floor
- exp=(exp*(100+33*(level-thispoke.level))/100).floor #DemICE's dynamic Exp. formula
- exp+=1 if ispartic>0 || haveexpshare>0
- else # Use old (Gen 1-4) Exp. formula
- exp=(exp/7).floor
- end
- isOutsider=(thispoke.trainerID!=self.pbPlayer.id ||
- (thispoke.language!=0 && thispoke.language!=self.pbPlayer.language))
- exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
- isConst?(thispoke.itemInitial,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 {2} Exp. Points!",thispoke.name,exp))
- else
- pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement