SHARE
TWEET

Untitled

a guest Jun 26th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         for j in 0...@party1.length
  27.           next if !@party1[j] || !pbIsOwner?(0,j)
  28.           if @party1[j].hp>0 && !@party1[j].isEgg? &&
  29.              !(isConst?(@party1[j].item,PBItems,:EXPSHARE) ||
  30.               isConst?(@party1[j].itemInitial,PBItems,:EXPSHARE))
  31.             expshare.push(@party1[j])
  32.             receivingExp.push(@party1[j])
  33.           end
  34.         end
  35.         # new exp share
  36.         for j in 0...@party1.length
  37.           next if !@party1[j] || !pbIsOwner?(0,j)
  38.           if @party1[j].hp>0 && !@party1[j].isEgg? && $PokemonGlobal.expAll
  39.             expAll.push(@party1[j])
  40.             receivingExp.push(@party1[j])
  41.           end
  42.         end
  43.         receivingExp.uniq! #remove duplicates
  44.         # Now calculate EXP for the all the pokemon
  45.         if receivingExp.length>0
  46.           if !@opponent && successbegin && pbAllFainted?(@party2)
  47.             @scene.pbWildBattleSuccess
  48.             successbegin=false
  49.           end
  50.           for j in 0...receivingExp.length
  51.             thispoke=@party1[receivingExp[j].partyIndex]
  52.             next if !@party1[receivingExp[j].partyIndex] || !pbIsOwner?(0,receivingExp[j].partyIndex)
  53.            
  54.             ispartic=0
  55.             haveexpshare=!(isConst?(thispoke.item,PBItems,:EXPSHARE) ||
  56.                           isConst?(thispoke.itemInitial,PBItems,:EXPSHARE)) ? 1 : 0
  57.             giveExpAll = $PokemonGlobal.expAll
  58.             for k in @battlers[i].participants
  59.               ispartic=1 if k==thispoke.partyIndex
  60.             end
  61.             if thispoke.hp>0 && !thispoke.isEgg?
  62.               exp=0
  63.               if expshare.length>0
  64.                 if partic.length==0
  65.                   exp=(level*baseexp).floor
  66.                   exp=(exp/expshare.length).floor*haveexpshare
  67.                 else
  68.                   exp=(level*baseexp/2).floor
  69.                   exp=(exp/partic.length).floor*ispartic + (exp/expshare.length).floor*haveexpshare
  70.                 end
  71.               elsif ispartic==1
  72.                 exp=(level*baseexp/partic.length).floor
  73.               elsif giveExpAll #if not a participant or holding normal exp share, give 1/2 exp
  74.                 exp=(level*baseexp/partic.length/2).floor
  75.               end
  76.               #exp=(exp*3/2).floor if @opponent
  77.               if USENEWEXPFORMULA  
  78.                 exp=(exp/3).floor  
  79.                 exp=(exp*(100+33*(level-thispoke.level))/100).floor   #DemICE's dynamic Exp. formula
  80.                 exp+=1 if ispartic>0 || haveexpshare>0
  81.               else                  # Use old (Gen 1-4) Exp. formula
  82.                 exp=(exp/7).floor
  83.               end
  84.               isOutsider=(thispoke.trainerID!=self.pbPlayer.id ||
  85.                  (thispoke.language!=0 && thispoke.language!=self.pbPlayer.language))
  86.               exp=(exp*3/2).floor if isConst?(thispoke.item,PBItems,:LUCKYEGG) ||
  87.                                      isConst?(thispoke.itemInitial,PBItems,:LUCKYEGG)
  88.               growthrate=thispoke.growthrate
  89.               newexp=PBExperience.pbAddExperience(thispoke.exp,exp,growthrate)
  90.               exp=newexp-thispoke.exp
  91.               if exp > 0
  92.                 if isOutsider
  93.                   pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
  94.                 else
  95.                   pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
  96.                 end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top