Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.18 KB | None | 0 0
  1. What Essentials had:
  2.  
  3.         n = temp.length
  4.         for m in 0...temp.length-1
  5.           for i in 1...temp.length
  6.             # For each pair of battlers, rank the second compared to the first.
  7.             # -1 means rank higher, 0 means rank equal, 1 means rank lower
  8.             cmp = 0
  9.             if quickclaw[temp[i]]
  10.               cmp = -1
  11.               if quickclaw[temp[i-1]]
  12.                 if speeds[temp[i]]==speeds[temp[i-1]]
  13.                   cmp = 0
  14.                 else
  15.                   cmp = (speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : 1
  16.                 end
  17.               end
  18.             elsif quickclaw[temp[i-1]]
  19.               cmp = 1
  20.             elsif lagging[temp[i]]
  21.               cmp = 1
  22.               if lagging[temp[i-1]]
  23.                 if speeds[temp[i]]==speeds[temp[i-1]]
  24.                   cmp = 0
  25.                 else
  26.                   cmp = (speeds[temp[i]]>speeds[temp[i-1]]) ? 1 : -1
  27.                 end
  28.               end
  29.             elsif lagging[temp[i-1]]
  30.               cmp = -1
  31.             elsif speeds[temp[i]]!=speeds[temp[i-1]]
  32.               if @field.effects[PBEffects::TrickRoom]>0
  33.                 cmp = (speeds[temp[i]]>speeds[temp[i-1]]) ? 1 : -1
  34.               else
  35.                 cmp = (speeds[temp[i]]>speeds[temp[i-1]]) ? -1 : 1
  36.               end
  37.             end
  38.             if cmp<0 ||   # Swap the pair according to the second battler's rank
  39.                (cmp==0 && pbRandom(2)==0)
  40.               temp[i],temp[i-1] = temp[i-1],temp[i]
  41.             end
  42.           end
  43.         end
  44.  
  45.  
  46.  
  47. What Essentials has now:
  48.  
  49.         # Sort by speed
  50.         if @field.effects[PBEffects::TrickRoom]>0
  51.           temp.sort!{|a,b| (a==b) ? pbRandom(2) : speeds[a]<=>speeds[b]}
  52.         else
  53.           temp.sort!{|a,b| (a==b) ? pbRandom(2) : speeds[b]<=>speeds[a]}
  54.         end
  55.         # Move Quick Clawers and laggers to the start/end
  56.         q = []; l = []
  57.         for i in 0...temp.length
  58.           if quickclaw[temp[i]]
  59.             q[q.length] = temp[i]; temp[i] = nil
  60.           end
  61.           if lagging[temp[i]]
  62.             l[l.length] = temp[i]; temp[i] = nil
  63.           end
  64.         end
  65.         temp.compact!
  66.         temp = q + temp + l
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement