Advertisement
tustin2121

Pokemon Essentials [16.1 to 16.2] diff

May 23rd, 2016
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 252.86 KB | None | 0 0
  1. diff --git a/Data/Scripts.rxdata/[005] Sockets.rb b/Data/Scripts.rxdata/[005] Sockets.rb
  2. index da941b4..3cecf74 100644
  3. --- a/Data/Scripts.rxdata/[005] Sockets.rb 
  4. +++ b/Data/Scripts.rxdata/[005] Sockets.rb 
  5. @@ -204,21 +204,21 @@ class Socket
  6.    SO_SNDBUF                 = 4097
  7.    SO_RCVBUF                 = 4098
  8.    SO_SNDLOWAT               = 4099
  9. -  TCP_NODELAY               =  1
  10. +  TCP_NODELAY               = 1
  11.    MSG_OOB                   = 1
  12.    MSG_PEEK                  = 2
  13.    MSG_DONTROUTE             = 4
  14. -  IP_OPTIONS                =  1
  15. -  IP_DEFAULT_MULTICAST_LOOP =  1
  16. -  IP_DEFAULT_MULTICAST_TTL  =  1
  17. -  IP_MULTICAST_IF           =  2
  18. -  IP_MULTICAST_TTL          =  3
  19. -  IP_MULTICAST_LOOP         =  4
  20. -  IP_ADD_MEMBERSHIP         =  5
  21. -  IP_DROP_MEMBERSHIP        =  6
  22. -  IP_TTL                    =  7
  23. -  IP_TOS                    =  8
  24. -  IP_MAX_MEMBERSHIPS        =  20
  25. +  IP_OPTIONS                = 1
  26. +  IP_DEFAULT_MULTICAST_LOOP = 1
  27. +  IP_DEFAULT_MULTICAST_TTL  = 1
  28. +  IP_MULTICAST_IF           = 2
  29. +  IP_MULTICAST_TTL          = 3
  30. +  IP_MULTICAST_LOOP         = 4
  31. +  IP_ADD_MEMBERSHIP         = 5
  32. +  IP_DROP_MEMBERSHIP        = 6
  33. +  IP_TTL                    = 7
  34. +  IP_TOS                    = 8
  35. +  IP_MAX_MEMBERSHIPS        = 20
  36.    EAI_ADDRFAMILY            = 1
  37.    EAI_AGAIN                 = 2
  38.    EAI_BADFLAGS              = 3
  39. diff --git a/Data/Scripts.rxdata/[019] Game_Character.rb b/Data/Scripts.rxdata/[019] Game_Character.rb
  40. index af7da18..911c70d 100644
  41. --- a/Data/Scripts.rxdata/[019] Game_Character.rb  
  42. +++ b/Data/Scripts.rxdata/[019] Game_Character.rb  
  43. @@ -132,9 +132,7 @@ class Game_Character
  44.    end
  45.  
  46.    def lock
  47. -    if @locked
  48. -      return
  49. -    end
  50. +    return if @locked
  51.      @prelock_direction = @direction
  52.      turn_toward_player
  53.      @locked = true
  54. @@ -145,9 +143,7 @@ class Game_Character
  55.    end
  56.  
  57.    def unlock
  58. -    unless @locked
  59. -      return
  60. -    end
  61. +    return unless @locked
  62.      @locked = false
  63.      unless @direction_fix
  64.        if @prelock_direction != 0
  65. @@ -158,12 +154,12 @@ class Game_Character
  66.  
  67.    def triggerLeaveTile
  68.      if @oldX && @oldY && @oldMap &&
  69. -         (@oldX!=self.x || @oldY!=self.y || @oldMap!=self.map.map_id)
  70. +       (@oldX!=self.x || @oldY!=self.y || @oldMap!=self.map.map_id)
  71.        Events.onLeaveTile.trigger(self,self,@oldMap,@oldX,@oldY)
  72. -     end
  73. -     @oldX=self.x
  74. -     @oldY=self.y
  75. -     @oldMap=self.map.map_id
  76. +    end
  77. +    @oldX=self.x
  78. +    @oldY=self.y
  79. +    @oldMap=self.map.map_id
  80.    end
  81.  
  82.    def moveto(x, y)
  83. @@ -182,15 +178,10 @@ class Game_Character
  84.    def screen_y
  85.      y = (@real_y - self.map.display_y + 3) / 4 + (Game_Map::TILEHEIGHT)
  86.      if jumping?
  87. -      if @jump_count >= @jump_peak
  88. -        n = @jump_count - @jump_peak
  89. -      else
  90. -        n = @jump_peak - @jump_count
  91. -      end
  92. +      n = (@jump_count - @jump_peak).abs
  93.        return y - (@jump_peak * @jump_peak - n * n) / 2
  94. -    else
  95. -      return y
  96.      end
  97. +    return y
  98.    end
  99.  
  100.    def screen_y_ground
  101. @@ -204,26 +195,26 @@ class Game_Character
  102.      z = (@real_y - self.map.display_y + 3) / 4 + 32
  103.      if @tile_id > 0
  104.        return z + self.map.priorities[@tile_id] * 32
  105. -    else
  106. -      # Add z if height exceeds 32
  107. -      return z + ((height > 32) ? 31 : 0)
  108.      end
  109. +    # Add z if height exceeds 32
  110. +    return z + ((height > 32) ? 31 : 0)
  111.    end
  112.  
  113.    def bush_depth
  114.      if @tile_id > 0 or @always_on_top
  115.        return 0
  116.      end
  117. -    xbehind=(@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
  118. -    ybehind=(@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
  119. -    if @jump_count <= 0 and self.map.deepBush?(@x, @y) and
  120. -                            self.map.deepBush?(xbehind, ybehind)
  121. -      return 32
  122. -    elsif @jump_count <= 0 and self.map.bush?(@x, @y) and !moving?
  123. -      return 12
  124. -    else
  125. -      return 0
  126. +    if @jump_count <= 0
  127. +      xbehind=(@direction==4) ? @x+1 : (@direction==6) ? @x-1 : @x
  128. +      ybehind=(@direction==8) ? @y+1 : (@direction==2) ? @y-1 : @y
  129. +      if self.map.deepBush?(@x, @y) and self.map.deepBush?(xbehind, ybehind)
  130. +        return 32
  131. +      end
  132. +      if self.map.bush?(@x, @y) and !moving?
  133. +        return 12
  134. +      end
  135.      end
  136. +    return 0
  137.    end
  138.  
  139.    def terrain_tag
  140. @@ -233,13 +224,24 @@ class Game_Character
  141.  # Updating stuff ###############################################################
  142.    def update
  143.      return if $game_temp.in_menu
  144. -    if jumping?
  145. -      update_jump
  146. -    elsif moving?
  147. -      update_move
  148. -    else
  149. -      update_stop
  150. +    if jumping?; update_jump
  151. +    elsif moving?; update_move
  152. +    else; update_stop
  153.      end
  154. +    if @wait_count > 0
  155. +      @wait_count -= 1
  156. +    elsif @move_route_forcing
  157. +      move_type_custom
  158. +    elsif !@starting && !lock?
  159. +      if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  160. +        case @move_type
  161. +        when 1; move_type_random
  162. +        when 2; move_type_toward_player
  163. +        when 3; move_type_custom
  164. +        end
  165. +      end
  166. +    end
  167. +    @anime_count=20 if not @step_anime and @stop_count > 0
  168.      if @anime_count > 18 - @move_speed * 3
  169.        if not @step_anime and @stop_count > 0
  170.          @pattern = @original_pattern
  171. @@ -248,27 +250,6 @@ class Game_Character
  172.        end
  173.        @anime_count = 0
  174.      end
  175. -    if @wait_count > 0
  176. -      @wait_count -= 1
  177. -      return
  178. -    end
  179. -    if @move_route_forcing
  180. -      move_type_custom
  181. -      return
  182. -    end
  183. -    if @starting or lock?
  184. -      return
  185. -    end
  186. -    if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
  187. -      case @move_type
  188. -      when 1  
  189. -        move_type_random
  190. -      when 2  
  191. -        move_type_toward_player
  192. -      when 3  
  193. -        move_type_custom
  194. -      end
  195. -    end
  196.    end
  197.  
  198.    def update_jump
  199. @@ -284,15 +265,15 @@ class Game_Character
  200.      distance = 2 ** @move_speed
  201.      realResX=Game_Map.realResX
  202.      realResY=Game_Map.realResY
  203. -    if @y * realResY > @real_y
  204. -      @real_y = [@real_y + distance, @y * realResY].min
  205. -    end
  206.      if @x * realResX < @real_x
  207.        @real_x = [@real_x - distance, @x * realResX].max
  208.      end
  209.      if @x * realResX > @real_x
  210.        @real_x = [@real_x + distance, @x * realResX].min
  211.      end
  212. +    if @y * realResY > @real_y
  213. +      @real_y = [@real_y + distance, @y * realResY].min
  214. +    end
  215.      if @y * realResY < @real_y
  216.        @real_y = [@real_y - distance, @y * realResY].max
  217.      end
  218. @@ -309,9 +290,6 @@ class Game_Character
  219.    def update_stop
  220.      if @step_anime
  221.        @anime_count += 1
  222. -    elsif @pattern != @original_pattern
  223. -      @pattern=@original_pattern
  224. -      @anime_count=0
  225.      end
  226.      unless @starting or lock?
  227.        @stop_count += 1
  228. @@ -332,9 +310,7 @@ class Game_Character
  229.    def move_type_toward_player
  230.      sx = @x - $game_player.x
  231.      sy = @y - $game_player.y
  232. -    abs_sx = sx > 0 ? sx : -sx
  233. -    abs_sy = sy > 0 ? sy : -sy
  234. -    if sx + sy >= 20
  235. +    if sx.abs + sy.abs >= 20
  236.        move_random
  237.        return
  238.      end
  239. @@ -371,39 +347,24 @@ class Game_Character
  240.        end
  241.        if command.code <= 14
  242.          case command.code
  243. -        when 1
  244. -          move_down
  245. -        when 2
  246. -          move_left
  247. -        when 3
  248. -          move_right
  249. -        when 4
  250. -          move_up
  251. -        when 5
  252. -          move_lower_left
  253. -        when 6
  254. -          move_lower_right
  255. -        when 7
  256. -          move_upper_left
  257. -        when 8
  258. -          move_upper_right
  259. -        when 9
  260. -          move_random
  261. -        when 10
  262. -          move_toward_player
  263. -        when 11
  264. -          move_away_from_player
  265. -        when 12
  266. -          move_forward
  267. -        when 13
  268. -          move_backward
  269. -        when 14
  270. -          jump(command.parameters[0], command.parameters[1])
  271. +        when 1; move_down
  272. +        when 2; move_left
  273. +        when 3; move_right
  274. +        when 4; move_up
  275. +        when 5; move_lower_left
  276. +        when 6; move_lower_right
  277. +        when 7; move_upper_left
  278. +        when 8; move_upper_right
  279. +        when 9; move_random
  280. +        when 10; move_toward_player
  281. +        when 11; move_away_from_player
  282. +        when 12; move_forward
  283. +        when 13; move_backward
  284. +        when 14; jump(command.parameters[0], command.parameters[1])
  285.          end
  286. -        if not @move_route.skippable and not moving? and not jumping?
  287. -          return
  288. +        if @move_route.skippable or moving? or jumping?
  289. +          @move_route_index += 1
  290.          end
  291. -        @move_route_index += 1
  292.          return
  293.        end
  294.        if command.code == 15
  295. @@ -413,28 +374,17 @@ class Game_Character
  296.        end
  297.        if command.code >= 16 and command.code <= 26
  298.          case command.code
  299. -        when 16
  300. -          turn_down
  301. -        when 17
  302. -          turn_left
  303. -        when 18
  304. -          turn_right
  305. -        when 19
  306. -          turn_up
  307. -        when 20
  308. -          turn_right_90
  309. -        when 21
  310. -          turn_left_90
  311. -        when 22
  312. -          turn_180
  313. -        when 23
  314. -          turn_right_or_left_90
  315. -        when 24
  316. -          turn_random
  317. -        when 25
  318. -          turn_toward_player
  319. -        when 26
  320. -          turn_away_from_player
  321. +        when 16; turn_down
  322. +        when 17; turn_left
  323. +        when 18; turn_right
  324. +        when 19; turn_up
  325. +        when 20; turn_right_90
  326. +        when 21; turn_left_90
  327. +        when 22; turn_180
  328. +        when 23; turn_right_or_left_90
  329. +        when 24; turn_random
  330. +        when 25; turn_toward_player
  331. +        when 26; turn_away_from_player
  332.          end
  333.          @move_route_index += 1
  334.          return
  335. @@ -447,30 +397,18 @@ class Game_Character
  336.          when 28
  337.            $game_switches[command.parameters[0]] = false
  338.            self.map.need_refresh = true
  339. -        when 29
  340. -          @move_speed = command.parameters[0]
  341. -        when 30
  342. -          @move_frequency = command.parameters[0]
  343. -        when 31
  344. -          @walk_anime = true
  345. -        when 32
  346. -          @walk_anime = false
  347. -        when 33
  348. -          @step_anime = true
  349. -        when 34
  350. -          @step_anime = false
  351. -        when 35
  352. -          @direction_fix = true
  353. -        when 36
  354. -          @direction_fix = false
  355. -        when 37
  356. -          @through = true
  357. -        when 38
  358. -          @through = false
  359. -        when 39
  360. -          @always_on_top = true
  361. -        when 40
  362. -          @always_on_top = false
  363. +        when 29; @move_speed = command.parameters[0]
  364. +        when 30; @move_frequency = command.parameters[0]
  365. +        when 31; @walk_anime = true
  366. +        when 32; @walk_anime = false
  367. +        when 33; @step_anime = true
  368. +        when 34; @step_anime = false
  369. +        when 35; @direction_fix = true
  370. +        when 36; @direction_fix = false
  371. +        when 37; @through = true
  372. +        when 38; @through = false
  373. +        when 39; @always_on_top = true
  374. +        when 40; @always_on_top = false
  375.          when 41
  376.            @tile_id = 0
  377.            @character_name = command.parameters[0]
  378. @@ -484,14 +422,10 @@ class Game_Character
  379.              @pattern = command.parameters[3]
  380.              @original_pattern = @pattern
  381.            end
  382. -        when 42
  383. -          @opacity = command.parameters[0]
  384. -        when 43
  385. -          @blend_type = command.parameters[0]
  386. -        when 44
  387. -          pbSEPlay(command.parameters[0])
  388. -        when 45
  389. -          result = eval(command.parameters[0])
  390. +        when 42; @opacity = command.parameters[0]
  391. +        when 43; @blend_type = command.parameters[0]
  392. +        when 44; pbSEPlay(command.parameters[0])
  393. +        when 45; result = eval(command.parameters[0])
  394.          end
  395.          @move_route_index += 1
  396.        end
  397. @@ -652,7 +586,7 @@ class Game_Character
  398.      abs_sx = sx.abs
  399.      abs_sy = sy.abs
  400.      if abs_sx == abs_sy
  401. -      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  402. +      (rand(2) == 0) ? abs_sx += 1 : abs_sy += 1
  403.      end
  404.      if abs_sx > abs_sy
  405.        sx > 0 ? move_left : move_right
  406. @@ -676,7 +610,7 @@ class Game_Character
  407.      abs_sx = sx.abs
  408.      abs_sy = sy.abs
  409.      if abs_sx == abs_sy
  410. -      rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
  411. +      (rand(2) == 0) ? abs_sx += 1 : abs_sy += 1
  412.      end
  413.      if abs_sx > abs_sy
  414.        sx > 0 ? move_right : move_left
  415. diff --git a/Data/Scripts.rxdata/[020] Game_Event.rb b/Data/Scripts.rxdata/[020] Game_Event.rb
  416. index 6dac81b..7fbda59 100644
  417. --- a/Data/Scripts.rxdata/[020] Game_Event.rb  
  418. +++ b/Data/Scripts.rxdata/[020] Game_Event.rb  
  419. @@ -88,7 +88,7 @@ class Game_Event < Game_Character
  420.    end
  421.  
  422.    def setTempSwitchOn(c)
  423. -    @tempSwitches[c]=true    
  424. +    @tempSwitches[c]=true
  425.      refresh
  426.    end
  427.  
  428. diff --git a/Data/Scripts.rxdata/[024] Sprite_Character.rb b/Data/Scripts.rxdata/[024] Sprite_Character.rb
  429. index d5588db..4f52595 100644
  430. --- a/Data/Scripts.rxdata/[024] Sprite_Character.rb
  431. +++ b/Data/Scripts.rxdata/[024] Sprite_Character.rb
  432. @@ -36,6 +36,7 @@ class Sprite_Character < RPG::Sprite
  433.      super(viewport)
  434.      @character = character
  435.      @oldbushdepth=0
  436. +    @bobframetime=1.0/15
  437.      update
  438.    end
  439.  
  440. @@ -84,6 +85,7 @@ class Sprite_Character < RPG::Sprite
  441.        @tile_id = @character.tile_id
  442.        @character_name = @character.character_name
  443.        @character_hue = @character.character_hue
  444. +      @oldbushdepth = @character.bush_depth
  445.        if @tile_id >= 384
  446.          @charbitmap.dispose if @charbitmap
  447.          @charbitmap = pbGetTileBitmap(@character.map.tileset_name,
  448. @@ -98,20 +100,15 @@ class Sprite_Character < RPG::Sprite
  449.          self.oy = Game_Map::TILEHEIGHT
  450.        else
  451.          @charbitmap.dispose if @charbitmap
  452. -        @charbitmap = AnimatedBitmap.new(
  453. -           "Graphics/Characters/"+@character.character_name,
  454. -           @character.character_hue)
  455. +        @charbitmap = AnimatedBitmap.new("Graphics/Characters/"+@character.character_name,
  456. +                                         @character.character_hue)
  457.          @charbitmapAnimated=true
  458.          @bushbitmap.dispose if @bushbitmap
  459.          @bushbitmap=nil
  460.          @cw = @charbitmap.width / 4
  461.          @ch = @charbitmap.height / 4
  462.          self.ox = @cw / 2
  463. -        if @character_name[/offset/]
  464. -          self.oy = @ch - 16
  465. -        else
  466. -          self.oy = @ch
  467. -        end
  468. +        self.oy = (@character_name[/offset/]) ? @ch - 16 : @ch
  469.        end
  470.      end
  471.      @charbitmap.update if @charbitmapAnimated
  472. @@ -125,23 +122,18 @@ class Sprite_Character < RPG::Sprite
  473.        self.bitmap=@bushbitmap.bitmap
  474.      end
  475.      self.visible = (not @character.transparent)
  476. -    if @character==$game_player && @tile_id == 0
  477. -      if $PokemonGlobal.surfing || $PokemonGlobal.diving
  478. -        bob=((Graphics.frame_count%60)/15).floor
  479. -        self.oy=(bob>=2) ? @ch-16-2 : @ch-16
  480. -      end
  481. -    end
  482.      if @tile_id == 0
  483. -      if @character==$game_player && !$PokemonGlobal.fishing &&
  484. +      sx=@character.pattern * @cw
  485. +      if @character==$game_player &&
  486.           ($PokemonGlobal.surfing || $PokemonGlobal.diving)
  487. -        sx = bob * @cw
  488. -        sy = (@character.direction - 2) / 2 * @ch
  489. -        self.src_rect.set(sx, sy, @cw, @ch)
  490. -      else
  491. -        sx = @character.pattern * @cw
  492. -        sy = (@character.direction - 2) / 2 * @ch
  493. -        self.src_rect.set(sx, sy, @cw, @ch)
  494. +        bob=((Graphics.frame_count%60)*@bobframetime).floor
  495. +        self.oy=(bob>=2) ? @ch-16-2 : @ch-16
  496. +        if !$PokemonGlobal.fishing
  497. +          sx=bob * @cw
  498. +        end
  499.        end
  500. +      sy = (@character.direction - 2) / 2 * @ch
  501. +      self.src_rect.set(sx, sy, @cw, @ch)
  502.      end
  503.      if self.visible
  504.        if $PokemonSystem.tilemap==0 ||
  505. diff --git a/Data/Scripts.rxdata/[030] Tilemap_XP.rb b/Data/Scripts.rxdata/[030] Tilemap_XP.rb
  506. index 863da1e..d6754a2 100644
  507. --- a/Data/Scripts.rxdata/[030] Tilemap_XP.rb  
  508. +++ b/Data/Scripts.rxdata/[030] Tilemap_XP.rb  
  509. @@ -782,7 +782,7 @@ class CustomTilemap
  510.            for x in xrange
  511.              xpos=(x*twidth)-@oxLayer0
  512.              id = mapdata[x, y, z]
  513. -            next if id==0 || @priorities[id]!=0 || !@priorities[id]
  514. +            next if id==0 || !@priorities[id] || @priorities[id]!=0
  515.              if id>=384
  516.                tmprect.set( ((id - 384)&7)*@tileSrcWidth,((id - 384)>>3)*@tileSrcHeight,
  517.                   @tileSrcWidth,@tileSrcHeight)
  518. @@ -926,7 +926,7 @@ class CustomTilemap
  519.      end
  520.      if count<@tiles.length
  521.        bigchange=(count<=(@tiles.length*2/3)) && (@tiles.length*2/3)>25
  522. -      j=count;len=@tiles.length;while j<len
  523. +      j=count; len=@tiles.length; while j<len
  524.          sprite=@tiles[j]
  525.          @tiles[j+1]=-1
  526.          if bigchange
  527. diff --git a/Data/Scripts.rxdata/[038] Interpreter.rb b/Data/Scripts.rxdata/[038] Interpreter.rb
  528. index c54d25f..6adc114 100644
  529. --- a/Data/Scripts.rxdata/[038] Interpreter.rb 
  530. +++ b/Data/Scripts.rxdata/[038] Interpreter.rb 
  531. @@ -258,7 +258,7 @@ class Interpreter
  532.             if line[/^\s*\(/]
  533.               message+="\r\n***Line '#{line}' shouldn't begin with '('. Try\r\n"
  534.               message+="putting the '(' at the end of the previous line instead,\r\n"
  535. -             message+="or using Extendtext."
  536. +             message+="or using 'extendtext.exe'."
  537.             end
  538.          }
  539.        else
  540. diff --git a/Data/Scripts.rxdata/[048] BitmapCache.rb b/Data/Scripts.rxdata/[048] BitmapCache.rb
  541. index c8d68e3..7776542 100644
  542. --- a/Data/Scripts.rxdata/[048] BitmapCache.rb 
  543. +++ b/Data/Scripts.rxdata/[048] BitmapCache.rb 
  544. @@ -49,16 +49,16 @@ class WeakRef
  545.       begin
  546.         rids = @@id_map[id]
  547.         if rids
  548. -          for rid in rids
  549. -            @@id_rev_map.delete(rid)
  550. +         for rid in rids
  551. +           @@id_rev_map.delete(rid)
  552.           end
  553.           @@id_map.delete(id)
  554.         end
  555.         rid = @@id_rev_map[id]
  556.         if rid
  557. -          @@id_rev_map.delete(id)
  558. -          @@id_map[rid].delete(id)
  559. -          @@id_map.delete(rid) if @@id_map[rid].empty?
  560. +         @@id_rev_map.delete(id)
  561. +         @@id_map[rid].delete(id)
  562. +         @@id_map.delete(rid) if @@id_map[rid].empty?
  563.         end
  564.       ensure
  565.         Thread.critical = __old_status
  566. @@ -205,7 +205,7 @@ end
  567.  module RPG
  568.    module Cache
  569.      def self.load_bitmap(folder_name, filename, hue = 0)
  570. -       BitmapCache.load_bitmap(folder_name+filename.to_s,hue, true)
  571. +      BitmapCache.load_bitmap(folder_name+filename.to_s,hue, true)
  572.      end
  573.  
  574.      def self.animation(filename, hue)
  575. diff --git a/Data/Scripts.rxdata/[050] SpriteWindow.rb b/Data/Scripts.rxdata/[050] SpriteWindow.rb
  576. index 5676912..c71ffe7 100644
  577. --- a/Data/Scripts.rxdata/[050] SpriteWindow.rb
  578. +++ b/Data/Scripts.rxdata/[050] SpriteWindow.rb
  579. @@ -3057,7 +3057,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base
  580.      self.top_row = [self.top_row, self.row_max - self.page_row_max].min
  581.      cursor_width = (self.width-self.borderX) / @column_max
  582.      x = self.index % @column_max * (cursor_width + @column_spacing)
  583. -    y = self.index/ @column_max * @row_height - @virtualOy
  584. +    y = self.index / @column_max * @row_height - @virtualOy
  585.      self.cursor_rect.set(x, y, cursor_width, @row_height)
  586.      self.refresh if dorefresh || force
  587.    end
  588. diff --git a/Data/Scripts.rxdata/[057] Scene_Intro.rb b/Data/Scripts.rxdata/[057] Scene_Intro.rb
  589. index b3791fc..68857c6 100644
  590. --- a/Data/Scripts.rxdata/[057] Scene_Intro.rb 
  591. +++ b/Data/Scripts.rxdata/[057] Scene_Intro.rb 
  592. @@ -75,8 +75,8 @@ class IntroEventScene < EventScene
  593.      onCTrigger.clear
  594.      onUpdate.clear
  595.      # Play random cry
  596. -    cry=pbResolveAudioSE(pbCryFile(1+rand(PBSpecies.maxValue)))
  597. -    pbSEPlay(cry,100,100) if cry
  598. +    cry=pbCryFile(1+rand(PBSpecies.maxValue))
  599. +    pbSEPlay(cry,80,100) if cry
  600.      # Fade out
  601.      @pic.moveOpacity(15,0,0)
  602.      @pic2.moveOpacity(15,0,0)
  603. @@ -92,8 +92,8 @@ class IntroEventScene < EventScene
  604.      onCTrigger.clear
  605.      onUpdate.clear
  606.      # Play random cry
  607. -    cry=pbResolveAudioSE(pbCryFile(1+rand(PBSpecies.maxValue)))
  608. -    pbSEPlay(cry,100,100) if cry
  609. +    cry=pbCryFile(1+rand(PBSpecies.maxValue))
  610. +    pbSEPlay(cry,80,100) if cry
  611.      # Fade out
  612.      @pic.moveOpacity(15,0,0)
  613.      @pic2.moveOpacity(15,0,0)
  614. diff --git a/Data/Scripts.rxdata/[066] PBTypes_Extra.rb b/Data/Scripts.rxdata/[066] PBTypes_Extra.rb
  615. index 5495136..3845698 100644
  616. --- a/Data/Scripts.rxdata/[066] PBTypes_Extra.rb   
  617. +++ b/Data/Scripts.rxdata/[066] PBTypes_Extra.rb   
  618. @@ -21,36 +21,41 @@ class PBTypes
  619.    end
  620.  
  621.    def PBTypes.getEffectiveness(attackType,opponentType)
  622. +    return 2 if !opponentType || opponentType<0
  623.      return PBTypes.loadTypeData()[2][attackType*(PBTypes.maxValue+1)+opponentType]
  624.    end
  625.  
  626. -  def PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2=nil)
  627. -    if opponentType2==nil || opponentType1==opponentType2
  628. -      return PBTypes.getEffectiveness(attackType,opponentType1)*2
  629. -    else
  630. -      mod1=PBTypes.getEffectiveness(attackType,opponentType1)
  631. +  def PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2=nil,opponentType3=nil)
  632. +    mod1=PBTypes.getEffectiveness(attackType,opponentType1)
  633. +    mod2=2
  634. +    if opponentType2!=nil && opponentType2>=0 && opponentType1!=opponentType2
  635.        mod2=PBTypes.getEffectiveness(attackType,opponentType2)
  636. -      return (mod1*mod2)
  637.      end
  638. +    mod3=2
  639. +    if opponentType3!=nil && opponentType3>=0 &&
  640. +       opponentType1!=opponentType3 && opponentType2!=opponentType3
  641. +      mod3=PBTypes.getEffectiveness(attackType,opponentType3)
  642. +    end
  643. +    return (mod1*mod2*mod3)
  644.    end
  645.  
  646. -  def PBTypes.isIneffective?(attackType,opponentType1,opponentType2=nil)
  647. -    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2)
  648. +  def PBTypes.isIneffective?(attackType,opponentType1,opponentType2=nil,opponentType3=nil)
  649. +    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2,opponentType3)
  650.      return e==0
  651.    end
  652.  
  653. -  def PBTypes.isNotVeryEffective?(attackType,opponentType1,opponentType2=nil)
  654. -    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2)
  655. -    return e>0 && e<4
  656. +  def PBTypes.isNotVeryEffective?(attackType,opponentType1,opponentType2=nil,opponentType3=nil)
  657. +    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2,opponentType3)
  658. +    return e>0 && e<8
  659.    end
  660.  
  661. -  def PBTypes.isNormalEffective?(attackType,opponentType1,opponentType2=nil)
  662. -    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2)
  663. -    return e==4
  664. +  def PBTypes.isNormalEffective?(attackType,opponentType1,opponentType2=nil,opponentType3=nil)
  665. +    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2,opponentType3)
  666. +    return e==8
  667.    end
  668.  
  669. -  def PBTypes.isSuperEffective?(attackType,opponentType1,opponentType2=nil)
  670. -    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2)
  671. -    return e>4
  672. +  def PBTypes.isSuperEffective?(attackType,opponentType1,opponentType2=nil,opponentType3=nil)
  673. +    e=PBTypes.getCombinedEffectiveness(attackType,opponentType1,opponentType2,opponentType3)
  674. +    return e>8
  675.    end
  676.  end
  677. \ No newline at end of file
  678. diff --git a/Data/Scripts.rxdata/[075] PBEffects.rb b/Data/Scripts.rxdata/[075] PBEffects.rb
  679. index de3e6ed..0161f66 100644
  680. --- a/Data/Scripts.rxdata/[075] PBEffects.rb   
  681. +++ b/Data/Scripts.rxdata/[075] PBEffects.rb   
  682. @@ -45,69 +45,71 @@ begin
  683.      Ingrain            = 41
  684.      KingsShield        = 42
  685.      LeechSeed          = 43
  686. -    LockOn             = 44
  687. -    LockOnPos          = 45
  688. -    LunarDance         = 46
  689. -    MagicCoat          = 47
  690. -    MagnetRise         = 48
  691. -    MeanLook           = 49
  692. -    MeFirst            = 50
  693. -    Metronome          = 51
  694. -    MicleBerry         = 52
  695. -    Minimize           = 53
  696. -    MiracleEye         = 54
  697. -    MirrorCoat         = 55
  698. -    MirrorCoatTarget   = 56
  699. -    MoveNext           = 57
  700. -    MudSport           = 58
  701. -    MultiTurn          = 59 # Trapping move
  702. -    MultiTurnAttack    = 60
  703. -    MultiTurnUser      = 61
  704. -    Nightmare          = 62
  705. -    Outrage            = 63
  706. -    ParentalBond       = 64
  707. -    PerishSong         = 65
  708. -    PerishSongUser     = 66
  709. -    PickupItem         = 67
  710. -    PickupUse          = 68
  711. -    Pinch              = 69 # Battle Palace only
  712. -    Powder             = 70
  713. -    PowerTrick         = 71
  714. -    Protect            = 72
  715. -    ProtectNegation    = 73
  716. -    ProtectRate        = 74
  717. -    Pursuit            = 75
  718. -    Quash              = 76
  719. -    Rage               = 77
  720. -    Revenge            = 78
  721. -    Roar               = 79
  722. -    Rollout            = 80
  723. -    Roost              = 81
  724. -    SkyDrop            = 82
  725. -    SmackDown          = 83
  726. -    Snatch             = 84
  727. -    SpikyShield        = 85
  728. -    Stockpile          = 86
  729. -    StockpileDef       = 87
  730. -    StockpileSpDef     = 88
  731. -    Substitute         = 89
  732. -    Taunt              = 90
  733. -    Telekinesis        = 91
  734. -    Torment            = 92
  735. -    Toxic              = 93
  736. -    Transform          = 94
  737. -    Truant             = 95
  738. -    TwoTurnAttack      = 96
  739. -    Type3              = 97
  740. -    Unburden           = 98
  741. -    Uproar             = 99
  742. -    Uturn              = 100
  743. -    WaterSport         = 101
  744. -    WeightChange       = 102
  745. -    Wish               = 103
  746. -    WishAmount         = 104
  747. -    WishMaker          = 105
  748. -    Yawn               = 106
  749. +    LifeOrb            = 44
  750. +    LockOn             = 45
  751. +    LockOnPos          = 46
  752. +    LunarDance         = 47
  753. +    MagicCoat          = 48
  754. +    MagnetRise         = 49
  755. +    MeanLook           = 50
  756. +    MeFirst            = 51
  757. +    Metronome          = 52
  758. +    MicleBerry         = 53
  759. +    Minimize           = 54
  760. +    MiracleEye         = 55
  761. +    MirrorCoat         = 56
  762. +    MirrorCoatTarget   = 57
  763. +    MoveNext           = 58
  764. +    MudSport           = 59
  765. +    MultiTurn          = 60 # Trapping move
  766. +    MultiTurnAttack    = 61
  767. +    MultiTurnUser      = 62
  768. +    Nightmare          = 63
  769. +    Outrage            = 64
  770. +    ParentalBond       = 65
  771. +    PerishSong         = 66
  772. +    PerishSongUser     = 67
  773. +    PickupItem         = 68
  774. +    PickupUse          = 69
  775. +    Pinch              = 70 # Battle Palace only
  776. +    Powder             = 71
  777. +    PowerTrick         = 72
  778. +    Protect            = 73
  779. +    ProtectNegation    = 74
  780. +    ProtectRate        = 75
  781. +    Pursuit            = 76
  782. +    Quash              = 77
  783. +    Rage               = 78
  784. +    Revenge            = 79
  785. +    Roar               = 80
  786. +    Rollout            = 81
  787. +    Roost              = 82
  788. +    SkipTurn           = 83 # For when using Pok├⌐ Balls/Pok├⌐ Dolls
  789. +    SkyDrop            = 84
  790. +    SmackDown          = 85
  791. +    Snatch             = 86
  792. +    SpikyShield        = 87
  793. +    Stockpile          = 88
  794. +    StockpileDef       = 89
  795. +    StockpileSpDef     = 90
  796. +    Substitute         = 91
  797. +    Taunt              = 92
  798. +    Telekinesis        = 93
  799. +    Torment            = 94
  800. +    Toxic              = 95
  801. +    Transform          = 96
  802. +    Truant             = 97
  803. +    TwoTurnAttack      = 98
  804. +    Type3              = 99
  805. +    Unburden           = 100
  806. +    Uproar             = 101
  807. +    Uturn              = 102
  808. +    WaterSport         = 103
  809. +    WeightChange       = 104
  810. +    Wish               = 105
  811. +    WishAmount         = 106
  812. +    WishMaker          = 107
  813. +    Yawn               = 108
  814.      
  815.      ############################################################################
  816.      # These effects apply to a side
  817. @@ -151,9 +153,10 @@ begin
  818.      
  819.      ############################################################################
  820.      # These effects apply to the usage of a move
  821. -    SpecialUsage = 0
  822. -    PassedTrying = 1
  823. -    TotalDamage  = 2
  824. +    SkipAccuracyCheck = 0
  825. +    SpecialUsage      = 1
  826. +    PassedTrying      = 2
  827. +    TotalDamage       = 3
  828.    end
  829.  
  830.  rescue Exception
  831. diff --git a/Data/Scripts.rxdata/[079] PokeBattle_DamageState.rb b/Data/Scripts.rxdata/[079] PokeBattle_DamageState.rb
  832. index 73ed84b..7d803ee 100644
  833. --- a/Data/Scripts.rxdata/[079] PokeBattle_DamageState.rb  
  834. +++ b/Data/Scripts.rxdata/[079] PokeBattle_DamageState.rb  
  835. @@ -26,4 +26,46 @@ class PokeBattle_DamageState
  836.    def initialize
  837.      reset
  838.    end
  839. +end
  840. +
  841. +
  842. +
  843. +################################################################################
  844. +# Success state (used for Battle Arena)
  845. +################################################################################
  846. +class PokeBattle_SuccessState
  847. +  attr_accessor :typemod
  848. +  attr_accessor :useState    # 0 - not used, 1 - failed, 2 - succeeded
  849. +  attr_accessor :protected
  850. +  attr_accessor :skill
  851. +
  852. +  def initialize
  853. +    clear
  854. +  end
  855. +
  856. +  def clear
  857. +    @typemod   = 4
  858. +    @useState  = 0
  859. +    @protected = false
  860. +    @skill     = 0
  861. +  end
  862. +
  863. +  def updateSkill
  864. +    if @useState==1 && !@protected
  865. +      @skill-=2
  866. +    elsif @useState==2
  867. +      if @typemod>4
  868. +        @skill+=2 # "Super effective"
  869. +      elsif @typemod>=1 && @typemod<4
  870. +        @skill-=1 # "Not very effective"
  871. +      elsif @typemod==0
  872. +        @skill-=2 # Ineffective
  873. +      else
  874. +        @skill+=1
  875. +      end
  876. +    end
  877. +    @typemod=4
  878. +    @useState=0
  879. +    @protected=false
  880. +  end
  881.  end
  882. \ No newline at end of file
  883. diff --git a/Data/Scripts.rxdata/[080] PokeBattle_Battler.rb b/Data/Scripts.rxdata/[080] PokeBattle_Battler.rb
  884. index 64c998d..279d29c 100644
  885. --- a/Data/Scripts.rxdata/[080] PokeBattle_Battler.rb  
  886. +++ b/Data/Scripts.rxdata/[080] PokeBattle_Battler.rb  
  887. @@ -410,6 +410,7 @@ class PokeBattle_Battler
  888.      end
  889.      @effects[PBEffects::Imprison]         = false
  890.      @effects[PBEffects::KingsShield]      = false
  891. +    @effects[PBEffects::LifeOrb]          = false
  892.      @effects[PBEffects::MagicCoat]        = false
  893.      @effects[PBEffects::MeanLook]         = -1
  894.      for i in 0...4
  895. @@ -454,6 +455,7 @@ class PokeBattle_Battler
  896.      @effects[PBEffects::Roar]             = false
  897.      @effects[PBEffects::Rollout]          = 0
  898.      @effects[PBEffects::Roost]            = false
  899. +    @effects[PBEffects::SkipTurn]         = false
  900.      @effects[PBEffects::SkyDrop]          = false
  901.      @effects[PBEffects::SmackDown]        = false
  902.      @effects[PBEffects::Snatch]           = false
  903. @@ -588,6 +590,17 @@ class PokeBattle_Battler
  904.      return false
  905.    end
  906.  
  907. +  def pbHasMoveType?(type)
  908. +    if type.is_a?(String) || type.is_a?(Symbol)
  909. +      type=getID(PBTypes,type)
  910. +    end
  911. +    return false if !type || type<0
  912. +    for i in @moves
  913. +      return true if i.type==type
  914. +    end
  915. +    return false
  916. +  end
  917. +
  918.    def pbHasMoveFunction?(code)
  919.      return false if !code
  920.      for i in @moves
  921. @@ -1109,8 +1122,8 @@ class PokeBattle_Battler
  922.          next if foe.isFainted?
  923.          for j in foe.moves
  924.            movedata=PBMoveData.new(j.id)
  925. -          eff=PBTypes.getCombinedEffectiveness(movedata.type,type1,type2)
  926. -          if (movedata.basedamage>0 && eff>4) ||
  927. +          eff=PBTypes.getCombinedEffectiveness(movedata.type,type1,type2,@effects[PBEffects::Type3])
  928. +          if (movedata.basedamage>0 && eff>8) ||
  929.               (movedata.function==0x70 && eff>0) # OHKO
  930.              found=true
  931.              break
  932. @@ -1491,7 +1504,7 @@ class PokeBattle_Battler
  933.          end
  934.        end
  935.        # Life Orb
  936. -      if user.hasWorkingItem(:LIFEORB) && !user.hasWorkingAbility(:MAGICGUARD)
  937. +      if user.effects[PBEffects::LifeOrb] && !user.hasWorkingAbility(:MAGICGUARD)
  938.          PBDebug.log("[Item triggered] #{user.pbThis}'s Life Orb (recoil)")
  939.          hploss=user.pbReduceHP((user.totalhp/10).floor,true)
  940.          if hploss>0
  941. @@ -2084,7 +2097,7 @@ class PokeBattle_Battler
  942.      if targets.length==1 && isConst?(thismove.pbType(thismove.type,user,target),PBTypes,:ELECTRIC) &&
  943.         !target.hasWorkingAbility(:LIGHTNINGROD)
  944.        for i in priority # use Pok├⌐mon earliest in priority
  945. -        next if target.index==i.index
  946. +        next if user.index==i.index || target.index==i.index
  947.          if i.hasWorkingAbility(:LIGHTNINGROD)
  948.            PBDebug.log("[Ability triggered] #{i.pbThis}'s Lightningrod (change target)")
  949.            target=i # X's Lightningrod took the attack!
  950. @@ -2097,7 +2110,7 @@ class PokeBattle_Battler
  951.      if targets.length==1 && isConst?(thismove.pbType(thismove.type,user,target),PBTypes,:WATER) &&
  952.         !target.hasWorkingAbility(:STORMDRAIN)
  953.        for i in priority # use Pok├⌐mon earliest in priority
  954. -        next if target.index==i.index
  955. +        next if user.index==i.index || target.index==i.index
  956.          if i.hasWorkingAbility(:STORMDRAIN)
  957.            PBDebug.log("[Ability triggered] #{i.pbThis}'s Storm Drain (change target)")
  958.            target=i # X's Storm Drain took the attack!
  959. @@ -2111,7 +2124,7 @@ class PokeBattle_Battler
  960.      if PBTargets.targetsOneOpponent?(thismove)
  961.        newtarget=nil; strength=100
  962.        for i in priority # use Pok├⌐mon latest in priority
  963. -        next if !pbIsOpposing?(i.index)
  964. +        next if !user.pbIsOpposing?(i.index)
  965.          if !i.isFainted? && !@battle.switching && !i.effects[PBEffects::SkyDrop] &&
  966.             i.effects[PBEffects::FollowMe]>0 && i.effects[PBEffects::FollowMe]<strength
  967.            PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Follow Me")
  968. @@ -2122,9 +2135,9 @@ class PokeBattle_Battler
  969.        target=newtarget if newtarget
  970.      end
  971.      # TODO: Pressure here is incorrect if Magic Coat redirects target
  972. -    if user.index!=target.index && target.hasWorkingAbility(:PRESSURE)
  973. +    if user.pbIsOpposing?(target.index) && target.hasWorkingAbility(:PRESSURE)
  974.        PBDebug.log("[Ability triggered] #{target.pbThis}'s Pressure (in pbChangeTarget)")
  975. -      pbReducePP(thismove) # Reduce PP
  976. +      user.pbReducePP(thismove) # Reduce PP
  977.      end  
  978.      # Change user to user of Snatch
  979.      if thismove.canSnatch?
  980. @@ -2137,7 +2150,7 @@ class PokeBattle_Battler
  981.            user=i
  982.            # Snatch's PP is reduced if old user has Pressure
  983.            userchoice=@battle.choices[user.index][1]
  984. -          if target.hasWorkingAbility(:PRESSURE) && userchoice>=0
  985. +          if target.hasWorkingAbility(:PRESSURE) && user.pbIsOpposing?(target.index) && userchoice>=0
  986.              PBDebug.log("[Ability triggered] #{target.pbThis}'s Pressure (part of Snatch)")
  987.              pressuremove=user.moves[userchoice]
  988.              pbSetPP(pressuremove,pressuremove.pp-1) if pressuremove.pp>0
  989. @@ -2200,7 +2213,6 @@ class PokeBattle_Battler
  990.    end
  991.  
  992.    def pbReducePP(move)
  993. -    #TODO: Pressure
  994.      if @effects[PBEffects::TwoTurnAttack]>0 ||
  995.         @effects[PBEffects::Bide]>0 ||
  996.         @effects[PBEffects::Outrage]>0 ||
  997. @@ -2299,7 +2311,7 @@ class PokeBattle_Battler
  998.      end
  999.    end
  1000.  
  1001. -  def pbSuccessCheck(thismove,user,target,accuracy=true)
  1002. +  def pbSuccessCheck(thismove,user,target,turneffects,accuracy=true)
  1003.      if user.effects[PBEffects::TwoTurnAttack]>0
  1004.        return true
  1005.      end
  1006. @@ -2375,8 +2387,9 @@ class PokeBattle_Battler
  1007.        @battle.pbDisplay(_INTL("{1} protected itself!",target.pbThis))
  1008.        @battle.successStates[user.index].protected=true
  1009.        PBDebug.log("[Move failed] #{user.pbThis}'s Spiky Shield stopped the attack")
  1010. -      if thismove.isContactMove?
  1011. -        amt=target.pbReduceHP((target.totalhp/8).floor) if !target.isFainted?
  1012. +      if thismove.isContactMove? && !user.isFainted?
  1013. +        @battle.scene.pbDamageAnimation(user,0)
  1014. +        amt=user.pbReduceHP((user.totalhp/8).floor)
  1015.          @battle.pbDisplay(_INTL("{1} was hurt!",user.pbThis)) if amt>0
  1016.        end
  1017.        return false
  1018. @@ -2469,6 +2482,7 @@ class PokeBattle_Battler
  1019.                           thismove.function==0x15 ||  # Hurricane
  1020.                           thismove.function==0x77 ||  # Gust
  1021.                           thismove.function==0x78 ||  # Twister
  1022. +                         thismove.function==0xCE ||  # Sky Drop
  1023.                           thismove.function==0x11B || # Sky Uppercut
  1024.                           thismove.function==0x11C    # Smack Down
  1025.        end
  1026. @@ -2477,6 +2491,7 @@ class PokeBattle_Battler
  1027.                      @battle.futuresight
  1028.        override=true if USENEWBATTLEMECHANICS && thismove.function==0x06 && # Toxic
  1029.                      thismove.basedamage==0 && user.pbHasType?(:POISON)
  1030. +      override=true if !miss && turneffects[PBEffects::SkipAccuracyCheck] # Called by another move
  1031.        if !override && (miss || !thismove.pbAccuracyCheck(user,target)) # Includes Counter/Mirror Coat
  1032.          PBDebug.log(sprintf("[Move failed] Failed pbAccuracyCheck (function code %02X) or target is semi-invulnerable",thismove.function))
  1033.          if thismove.target==PBTargets::AllOpposing &&
  1034. @@ -2501,7 +2516,9 @@ class PokeBattle_Battler
  1035.    def pbTryUseMove(choice,thismove,turneffects)
  1036.      return true if turneffects[PBEffects::PassedTrying]
  1037.      # TODO: Return true if attack has been Mirror Coated once already
  1038. -    return false if !pbObedienceCheck?(choice)
  1039. +    if !turneffects[PBEffects::SkipAccuracyCheck]
  1040. +      return false if !pbObedienceCheck?(choice)
  1041. +    end
  1042.      if @effects[PBEffects::SkyDrop] # Intentionally no message here
  1043.        PBDebug.log("[Move failed] #{pbThis} can't use #{thismove.name} because of being Sky Dropped")
  1044.        return false
  1045. @@ -2568,16 +2585,18 @@ class PokeBattle_Battler
  1046.        PBDebug.log("[Ability triggered] #{pbThis}'s Truant")
  1047.        return false
  1048.      end
  1049. -    if self.status==PBStatuses::SLEEP
  1050. -      self.statusCount-=1
  1051. -      if self.statusCount<=0
  1052. -        self.pbCureStatus
  1053. -      else
  1054. -        self.pbContinueStatus
  1055. -        PBDebug.log("[Status] #{pbThis} remained asleep (count: #{self.statusCount})")
  1056. -        if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage
  1057. -          PBDebug.log("[Move failed] #{pbThis} couldn't use #{thismove.name} while asleep")
  1058. -          return false
  1059. +    if !turneffects[PBEffects::SkipAccuracyCheck]
  1060. +      if self.status==PBStatuses::SLEEP
  1061. +        self.statusCount-=1
  1062. +        if self.statusCount<=0
  1063. +          self.pbCureStatus
  1064. +        else
  1065. +          self.pbContinueStatus
  1066. +          PBDebug.log("[Status] #{pbThis} remained asleep (count: #{self.statusCount})")
  1067. +          if !thismove.pbCanUseWhileAsleep? # Snore/Sleep Talk/Outrage
  1068. +            PBDebug.log("[Move failed] #{pbThis} couldn't use #{thismove.name} while asleep")
  1069. +            return false
  1070. +          end
  1071.          end
  1072.        end
  1073.      end
  1074. @@ -2587,7 +2606,7 @@ class PokeBattle_Battler
  1075.          self.pbCureStatus(false)
  1076.          @battle.pbDisplay(_INTL("{1} melted the ice!",pbThis))
  1077.          pbCheckForm
  1078. -      elsif @battle.pbRandom(10)<2
  1079. +      elsif @battle.pbRandom(10)<2 && !turneffects[PBEffects::SkipAccuracyCheck]
  1080.          self.pbCureStatus
  1081.          pbCheckForm
  1082.        elsif !thismove.canThawUser?
  1083. @@ -2596,18 +2615,20 @@ class PokeBattle_Battler
  1084.          return false
  1085.        end
  1086.      end
  1087. -    if @effects[PBEffects::Confusion]>0
  1088. -      @effects[PBEffects::Confusion]-=1
  1089. -      if @effects[PBEffects::Confusion]<=0
  1090. -        pbCureConfusion
  1091. -      else
  1092. -        pbContinueConfusion
  1093. -        PBDebug.log("[Status] #{pbThis} remained confused (count: #{@effects[PBEffects::Confusion]})")
  1094. -        if @battle.pbRandom(2)==0
  1095. -          pbConfusionDamage
  1096. -          @battle.pbDisplay(_INTL("It hurt itself in its confusion!"))
  1097. -          PBDebug.log("[Status] #{pbThis} hurt itself in its confusion and couldn't move")
  1098. -          return false
  1099. +    if !turneffects[PBEffects::SkipAccuracyCheck]
  1100. +      if @effects[PBEffects::Confusion]>0
  1101. +        @effects[PBEffects::Confusion]-=1
  1102. +        if @effects[PBEffects::Confusion]<=0
  1103. +          pbCureConfusion
  1104. +        else
  1105. +          pbContinueConfusion
  1106. +          PBDebug.log("[Status] #{pbThis} remained confused (count: #{@effects[PBEffects::Confusion]})")
  1107. +          if @battle.pbRandom(2)==0
  1108. +            pbConfusionDamage
  1109. +            @battle.pbDisplay(_INTL("It hurt itself in its confusion!"))
  1110. +            PBDebug.log("[Status] #{pbThis} hurt itself in its confusion and couldn't move")
  1111. +            return false
  1112. +          end
  1113.          end
  1114.        end
  1115.      end
  1116. @@ -2622,19 +2643,21 @@ class PokeBattle_Battler
  1117.        end
  1118.        return false
  1119.      end
  1120. -    if @effects[PBEffects::Attract]>=0
  1121. -      pbAnnounceAttract(@battle.battlers[@effects[PBEffects::Attract]])
  1122. -      if @battle.pbRandom(2)==0
  1123. -        pbContinueAttract
  1124. -        PBDebug.log("[Lingering effect triggered] #{pbThis} was infatuated and couldn't move")
  1125. -        return false
  1126. +    if !turneffects[PBEffects::SkipAccuracyCheck]
  1127. +      if @effects[PBEffects::Attract]>=0
  1128. +        pbAnnounceAttract(@battle.battlers[@effects[PBEffects::Attract]])
  1129. +        if @battle.pbRandom(2)==0
  1130. +          pbContinueAttract
  1131. +          PBDebug.log("[Lingering effect triggered] #{pbThis} was infatuated and couldn't move")
  1132. +          return false
  1133. +        end
  1134.        end
  1135. -    end
  1136. -    if self.status==PBStatuses::PARALYSIS
  1137. -      if @battle.pbRandom(4)==0
  1138. -        pbContinueStatus
  1139. -        PBDebug.log("[Status] #{pbThis} was fully paralysed and couldn't move")
  1140. -        return false
  1141. +      if self.status==PBStatuses::PARALYSIS
  1142. +        if @battle.pbRandom(4)==0
  1143. +          pbContinueStatus
  1144. +          PBDebug.log("[Status] #{pbThis} was fully paralysed and couldn't move")
  1145. +          return false
  1146. +        end
  1147.        end
  1148.      end
  1149.      turneffects[PBEffects::PassedTrying]=true
  1150. @@ -2662,7 +2685,7 @@ class PokeBattle_Battler
  1151.        target.damagestate.reset
  1152.        # Check success (accuracy/evasion calculation)
  1153.        if !nocheck &&
  1154. -         !pbSuccessCheck(thismove,user,target,i==0 || thismove.successCheckPerHit?)
  1155. +         !pbSuccessCheck(thismove,user,target,turneffects,i==0 || thismove.successCheckPerHit?)
  1156.          if thismove.function==0xBF && realnumhits>0   # Triple Kick
  1157.            break   # Considered a success if Triple Kick hits at least once
  1158.          elsif thismove.function==0x10B   # Hi Jump Kick, Jump Kick
  1159. @@ -2751,7 +2774,6 @@ class PokeBattle_Battler
  1160.        end
  1161.        if target.isFainted?
  1162.          destinybond=destinybond || target.effects[PBEffects::DestinyBond]
  1163. -        target.pbFaint # no return
  1164.        end
  1165.        user.pbFaint if user.isFainted? # no return
  1166.        break if user.isFainted?
  1167. @@ -2879,6 +2901,7 @@ class PokeBattle_Battler
  1168.      # Note: user.lastMoveUsedType IS to be updated on nested calls; is used for Conversion 2
  1169.      turneffects=[]
  1170.      turneffects[PBEffects::SpecialUsage]=specialusage
  1171. +    turneffects[PBEffects::SkipAccuracyCheck]=specialusage
  1172.      turneffects[PBEffects::PassedTrying]=false
  1173.      turneffects[PBEffects::TotalDamage]=0
  1174.      # Start using the move
  1175. @@ -2916,21 +2939,22 @@ class PokeBattle_Battler
  1176.          self.form=1
  1177.          pbUpdate(true)
  1178.          @battle.scene.pbChangePokemon(self,@pokemon)
  1179. -        @battle.pbDisplay(_INTL("{1} changed to Blade Forme",pbThis))
  1180. +        @battle.pbDisplay(_INTL("{1} changed to Blade Forme!",pbThis))
  1181.          PBDebug.log("[Form changed] #{pbThis} changed to Blade Forme")
  1182.        elsif isConst?(thismove.id,PBMoves,:KINGSSHIELD) && self.form!=0
  1183.          self.form=0
  1184.          pbUpdate(true)
  1185.          @battle.scene.pbChangePokemon(self,@pokemon)
  1186. -        @battle.pbDisplay(_INTL("{1} changed to Shield Forme",pbThis))
  1187. +        @battle.pbDisplay(_INTL("{1} changed to Shield Forme!",pbThis))
  1188.          PBDebug.log("[Form changed] #{pbThis} changed to Shield Forme")
  1189.        end      
  1190.      end
  1191. +    # Record that user has used a move this round (ot at least tried to)
  1192. +    self.lastRoundMoved=@battle.turncount
  1193.      # Try to use the move
  1194.      if !pbTryUseMove(choice,thismove,turneffects)
  1195.        self.lastMoveUsed=-1
  1196.        self.lastMoveUsedType=-1
  1197. -      self.lastRoundMoved=@battle.turncount
  1198.        if !turneffects[PBEffects::SpecialUsage]
  1199.          self.lastMoveUsedSketch=-1 if self.effects[PBEffects::TwoTurnAttack]==0
  1200.          self.lastRegularMoveUsed=-1
  1201. @@ -2949,7 +2973,6 @@ class PokeBattle_Battler
  1202.          self.lastMoveUsedType=-1
  1203.          self.lastMoveUsedSketch=-1 if self.effects[PBEffects::TwoTurnAttack]==0
  1204.          self.lastRegularMoveUsed=-1
  1205. -        self.lastRoundMoved=@battle.turncount
  1206.          pbEndTurn(choice)
  1207.          @battle.pbJudge #        @battle.pbSwitch
  1208.          PBDebug.log("[Move failed] #{thismove.name} has no PP left")
  1209. @@ -2973,12 +2996,10 @@ class PokeBattle_Battler
  1210.      # "X used Y!" message
  1211.      case thismove.pbDisplayUseMessage(self)
  1212.      when 2   # Continuing Bide
  1213. -      self.lastRoundMoved=@battle.turncount
  1214.        return
  1215.      when 1   # Starting Bide
  1216.        self.lastMoveUsed=thismove.id
  1217.        self.lastMoveUsedType=thismove.pbType(thismove.type,self,nil)
  1218. -      self.lastRoundMoved=@battle.turncount
  1219.        if !turneffects[PBEffects::SpecialUsage]
  1220.          self.lastMoveUsedSketch=thismove.id if self.effects[PBEffects::TwoTurnAttack]==0
  1221.          self.lastRegularMoveUsed=thismove.id
  1222. @@ -2991,7 +3012,6 @@ class PokeBattle_Battler
  1223.      when -1   # Was hurt while readying Focus Punch, fails use
  1224.        self.lastMoveUsed=thismove.id
  1225.        self.lastMoveUsedType=thismove.pbType(thismove.type,self,nil)
  1226. -      self.lastRoundMoved=@battle.turncount
  1227.        if !turneffects[PBEffects::SpecialUsage]
  1228.          self.lastMoveUsedSketch=thismove.id if self.effects[PBEffects::TwoTurnAttack]==0
  1229.          self.lastRegularMoveUsed=thismove.id
  1230. @@ -3010,12 +3030,10 @@ class PokeBattle_Battler
  1231.      @battle.successStates[user.index].useState=1
  1232.      @battle.successStates[user.index].typemod=8
  1233.      # Check whether Selfdestruct works
  1234. -    selffaint=(thismove.function==0xE0) # Selfdestruct
  1235.      if !thismove.pbOnStartUse(user) # Selfdestruct, Natural Gift, Beat Up can return false here
  1236.        PBDebug.log(sprintf("[Move failed] Failed pbOnStartUse (function code %02X)",thismove.function))
  1237.        user.lastMoveUsed=thismove.id
  1238.        user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  1239. -      user.lastRoundMoved=@battle.turncount
  1240.        if !turneffects[PBEffects::SpecialUsage]
  1241.          user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  1242.          user.lastRegularMoveUsed=thismove.id
  1243. @@ -3024,10 +3042,6 @@ class PokeBattle_Battler
  1244.        @battle.lastMoveUser=user.index
  1245.        return
  1246.      end
  1247. -    if selffaint
  1248. -      user.hp=0
  1249. -      user.pbFaint # no return
  1250. -    end
  1251.      # Primordial Sea, Desolate Land
  1252.      if thismove.pbIsDamaging?
  1253.        case @battle.pbWeather
  1254. @@ -3037,7 +3051,6 @@ class PokeBattle_Battler
  1255.            @battle.pbDisplay(_INTL("The Fire-type attack fizzled out in the heavy rain!"))
  1256.            user.lastMoveUsed=thismove.id
  1257.            user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  1258. -          user.lastRoundMoved=@battle.turncount
  1259.            if !turneffects[PBEffects::SpecialUsage]
  1260.              user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  1261.              user.lastRegularMoveUsed=thismove.id
  1262. @@ -3052,7 +3065,6 @@ class PokeBattle_Battler
  1263.            @battle.pbDisplay(_INTL("The Water-type attack evaporated in the harsh sunlight!"))
  1264.            user.lastMoveUsed=thismove.id
  1265.            user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  1266. -          user.lastRoundMoved=@battle.turncount
  1267.            if !turneffects[PBEffects::SpecialUsage]
  1268.              user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  1269.              user.lastRegularMoveUsed=thismove.id
  1270. @@ -3071,7 +3083,6 @@ class PokeBattle_Battler
  1271.        user.pbReduceHP(1+(user.totalhp/4).floor) if !user.hasWorkingAbility(:MAGICGUARD)  
  1272.        user.lastMoveUsed=thismove.id
  1273.        user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  1274. -      user.lastRoundMoved=@battle.turncount
  1275.        if !turneffects[PBEffects::SpecialUsage]
  1276.          user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  1277.          user.lastRegularMoveUsed=thismove.id
  1278. @@ -3150,57 +3161,32 @@ class PokeBattle_Battler
  1279.          showanimation=false
  1280.          i+=1
  1281.        end
  1282. -      # Pok├⌐mon switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail, Red Card
  1283. -      if !user.isFainted?
  1284. -        switched=[]
  1285. -        for i in 0...4
  1286. -          if @battle.battlers[i].effects[PBEffects::Roar]
  1287. -            @battle.battlers[i].effects[PBEffects::Roar]=false
  1288. -            @battle.battlers[i].effects[PBEffects::Uturn]=false
  1289. -            next if @battle.battlers[i].isFainted?
  1290. -            next if !@battle.pbCanSwitch?(i,-1,false)
  1291. -            choices=[]
  1292. -            party=@battle.pbParty(i)
  1293. -            for j in 0...party.length
  1294. -              choices.push(j) if @battle.pbCanSwitchLax?(i,j,false)
  1295. -            end
  1296. -            if choices.length>0
  1297. -              newpoke=choices[@battle.pbRandom(choices.length)]
  1298. -              newpokename=newpoke
  1299. -              if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION)
  1300. -                newpokename=pbGetLastPokeInTeam(i)
  1301. -              end
  1302. -              switched.push(i)
  1303. -              @battle.battlers[i].pbResetForm
  1304. -              @battle.pbRecallAndReplace(i,newpoke,newpokename,false,user.hasMoldBreaker)
  1305. -              @battle.pbDisplay(_INTL("{1} was dragged out!",@battle.battlers[i].pbThis))
  1306. -            end
  1307. -          end
  1308. -        end
  1309. -        for i in @battle.pbPriority
  1310. -          next if !switched.include?(i.index)
  1311. -          i.pbAbilitiesOnSwitchIn(true)
  1312. -        end
  1313. -      end
  1314. -      # Pok├⌐mon switching caused by U-Turn, Volt Switch, Eject Button
  1315. +    end
  1316. +    # Pok├⌐mon switching caused by Roar, Whirlwind, Circle Throw, Dragon Tail, Red Card
  1317. +    if !user.isFainted?
  1318.        switched=[]
  1319.        for i in 0...4
  1320. -        if @battle.battlers[i].effects[PBEffects::Uturn]
  1321. -          @battle.battlers[i].effects[PBEffects::Uturn]=false
  1322. +        if @battle.battlers[i].effects[PBEffects::Roar]
  1323.            @battle.battlers[i].effects[PBEffects::Roar]=false
  1324. -          if !@battle.battlers[i].isFainted? && @battle.pbCanChooseNonActive?(i) &&
  1325. -             !@battle.pbAllFainted?(@battle.pbOpposingParty(i))
  1326. -            # TODO: Pursuit should go here, and negate this effect if it KO's attacker
  1327. -            @battle.pbDisplay(_INTL("{1} went back to {2}!",@battle.battlers[i].pbThis,@battle.pbGetOwner(i).name))
  1328. -            newpoke=0
  1329. -            newpoke=@battle.pbSwitchInBetween(i,true,false)
  1330. +          @battle.battlers[i].effects[PBEffects::Uturn]=false
  1331. +          next if @battle.battlers[i].isFainted?
  1332. +          next if !@battle.pbCanSwitch?(i,-1,false)
  1333. +          choices=[]
  1334. +          party=@battle.pbParty(i)
  1335. +          for j in 0...party.length
  1336. +            choices.push(j) if @battle.pbCanSwitchLax?(i,j,false)
  1337. +          end
  1338. +          if choices.length>0
  1339. +            newpoke=choices[@battle.pbRandom(choices.length)]
  1340.              newpokename=newpoke
  1341. -            if isConst?(@battle.pbParty(i)[newpoke].ability,PBAbilities,:ILLUSION)
  1342. +            if isConst?(party[newpoke].ability,PBAbilities,:ILLUSION)
  1343.                newpokename=pbGetLastPokeInTeam(i)
  1344.              end
  1345.              switched.push(i)
  1346.              @battle.battlers[i].pbResetForm
  1347. -            @battle.pbRecallAndReplace(i,newpoke,newpokename,@battle.battlers[i].effects[PBEffects::BatonPass])
  1348. +            @battle.pbRecallAndReplace(i,newpoke,newpokename,false,user.hasMoldBreaker)
  1349. +            @battle.pbDisplay(_INTL("{1} was dragged out!",@battle.battlers[i].pbThis))
  1350. +            @battle.choices[i]=[0,0,nil,-1]   # Replacement Pok├⌐mon does nothing this round
  1351.            end
  1352.          end
  1353.        end
  1354. @@ -3208,27 +3194,54 @@ class PokeBattle_Battler
  1355.          next if !switched.include?(i.index)
  1356.          i.pbAbilitiesOnSwitchIn(true)
  1357.        end
  1358. -      # Baton Pass
  1359. -      if user.effects[PBEffects::BatonPass]
  1360. -        user.effects[PBEffects::BatonPass]=false
  1361. -        if !user.isFainted? && @battle.pbCanChooseNonActive?(user.index) &&
  1362. -           !@battle.pbAllFainted?(@battle.pbParty(target.index))
  1363. +    end
  1364. +    # Pok├⌐mon switching caused by U-Turn, Volt Switch, Eject Button
  1365. +    switched=[]
  1366. +    for i in 0...4
  1367. +      if @battle.battlers[i].effects[PBEffects::Uturn]
  1368. +        @battle.battlers[i].effects[PBEffects::Uturn]=false
  1369. +        @battle.battlers[i].effects[PBEffects::Roar]=false
  1370. +        if !@battle.battlers[i].isFainted? && @battle.pbCanChooseNonActive?(i) &&
  1371. +           !@battle.pbAllFainted?(@battle.pbOpposingParty(i))
  1372. +          # TODO: Pursuit should go here, and negate this effect if it KO's attacker
  1373. +          @battle.pbDisplay(_INTL("{1} went back to {2}!",@battle.battlers[i].pbThis,@battle.pbGetOwner(i).name))
  1374.            newpoke=0
  1375. -          newpoke=@battle.pbSwitchInBetween(user.index,true,false)
  1376. +          newpoke=@battle.pbSwitchInBetween(i,true,false)
  1377.            newpokename=newpoke
  1378. -          if isConst?(@battle.pbParty(user.index)[newpoke].ability,PBAbilities,:ILLUSION)
  1379. -            newpokename=pbGetLastPokeInTeam(user.index)
  1380. +          if isConst?(@battle.pbParty(i)[newpoke].ability,PBAbilities,:ILLUSION)
  1381. +            newpokename=pbGetLastPokeInTeam(i)
  1382.            end
  1383. -          user.pbResetForm
  1384. -          @battle.pbRecallAndReplace(user.index,newpoke,newpokename,true)
  1385. -          user.pbAbilitiesOnSwitchIn(true)
  1386. +          switched.push(i)
  1387. +          @battle.battlers[i].pbResetForm
  1388. +          @battle.pbRecallAndReplace(i,newpoke,newpokename,@battle.battlers[i].effects[PBEffects::BatonPass])
  1389. +          @battle.choices[i]=[0,0,nil,-1]   # Replacement Pok├⌐mon does nothing this round
  1390.          end
  1391.        end
  1392.      end
  1393. +    for i in @battle.pbPriority
  1394. +      next if !switched.include?(i.index)
  1395. +      i.pbAbilitiesOnSwitchIn(true)
  1396. +    end
  1397. +    # Baton Pass
  1398. +    if user.effects[PBEffects::BatonPass]
  1399. +      user.effects[PBEffects::BatonPass]=false
  1400. +      if !user.isFainted? && @battle.pbCanChooseNonActive?(user.index) &&
  1401. +         !@battle.pbAllFainted?(@battle.pbParty(user.index))
  1402. +        newpoke=0
  1403. +        newpoke=@battle.pbSwitchInBetween(user.index,true,false)
  1404. +        newpokename=newpoke
  1405. +        if isConst?(@battle.pbParty(user.index)[newpoke].ability,PBAbilities,:ILLUSION)
  1406. +          newpokename=pbGetLastPokeInTeam(user.index)
  1407. +        end
  1408. +        user.pbResetForm
  1409. +        @battle.pbRecallAndReplace(user.index,newpoke,newpokename,true)
  1410. +        @battle.choices[user.index]=[0,0,nil,-1]   # Replacement Pok├⌐mon does nothing this round
  1411. +        user.pbAbilitiesOnSwitchIn(true)
  1412. +      end
  1413. +    end
  1414.      # Record move as having been used
  1415.      user.lastMoveUsed=thismove.id
  1416.      user.lastMoveUsedType=thismove.pbType(thismove.type,user,nil)
  1417. -    user.lastRoundMoved=@battle.turncount
  1418.      if !turneffects[PBEffects::SpecialUsage]
  1419.        user.lastMoveUsedSketch=thismove.id if user.effects[PBEffects::TwoTurnAttack]==0
  1420.        user.lastRegularMoveUsed=thismove.id
  1421. diff --git a/Data/Scripts.rxdata/[081] PokeBattle_BattlerEffects.rb b/Data/Scripts.rxdata/[081] PokeBattle_BattlerEffects.rb
  1422. index a6ddd71..79654d2 100644
  1423. --- a/Data/Scripts.rxdata/[081] PokeBattle_BattlerEffects.rb   
  1424. +++ b/Data/Scripts.rxdata/[081] PokeBattle_BattlerEffects.rb   
  1425. @@ -25,7 +25,7 @@ class PokeBattle_Battler
  1426.          return false
  1427.        end
  1428.      end
  1429. -    if attacker.hasMoldBreaker || !hasWorkingAbility(:SOUNDPROOF)
  1430. +    if (attacker && attacker.hasMoldBreaker) || !hasWorkingAbility(:SOUNDPROOF)
  1431.        for i in 0...4
  1432.          if @battle.battlers[i].effects[PBEffects::Uproar]>0
  1433.            @battle.pbDisplay(_INTL("But the uproar kept {1} awake!",pbThis(true))) if showMessages
  1434. @@ -851,11 +851,11 @@ class PokeBattle_Battler
  1435.             _INTL("{1}'s {2} severely fell!",pbThis,PBStats.getName(stat))]
  1436.          @battle.pbDisplay(arrStatTexts[[increment-1,2].min])
  1437.          # Defiant
  1438. -        if hasWorkingAbility(:DEFIANT) && (!attacker || attacker.pbIsOpposing?(self))
  1439. +        if hasWorkingAbility(:DEFIANT) && (!attacker || attacker.pbIsOpposing?(self.index))
  1440.            pbIncreaseStatWithCause(PBStats::ATTACK,2,self,PBAbilities.getName(self.ability))
  1441.          end
  1442.          # Competitive
  1443. -        if hasWorkingAbility(:COMPETITIVE) && (!attacker || attacker.pbIsOpposing?(self))
  1444. +        if hasWorkingAbility(:COMPETITIVE) && (!attacker || attacker.pbIsOpposing?(self.index))
  1445.            pbIncreaseStatWithCause(PBStats::SPATK,2,self,PBAbilities.getName(self.ability))
  1446.          end
  1447.          return true
  1448. @@ -894,11 +894,11 @@ class PokeBattle_Battler
  1449.          end
  1450.          @battle.pbDisplay(arrStatTexts[[increment-1,2].min]) if showmessage
  1451.          # Defiant
  1452. -        if hasWorkingAbility(:DEFIANT) && (!attacker || attacker.pbIsOpposing?(self))
  1453. +        if hasWorkingAbility(:DEFIANT) && (!attacker || attacker.pbIsOpposing?(self.index))
  1454.            pbIncreaseStatWithCause(PBStats::ATTACK,2,self,PBAbilities.getName(self.ability))
  1455.          end
  1456.          # Competitive
  1457. -        if hasWorkingAbility(:COMPETITIVE) && (!attacker || attacker.pbIsOpposing?(self))
  1458. +        if hasWorkingAbility(:COMPETITIVE) && (!attacker || attacker.pbIsOpposing?(self.index))
  1459.            pbIncreaseStatWithCause(PBStats::SPATK,2,self,PBAbilities.getName(self.ability))
  1460.          end
  1461.          return true
  1462. diff --git a/Data/Scripts.rxdata/[082] PokeBattle_Move.rb b/Data/Scripts.rxdata/[082] PokeBattle_Move.rb
  1463. index 484b5d7..3a82c86 100644
  1464. --- a/Data/Scripts.rxdata/[082] PokeBattle_Move.rb 
  1465. +++ b/Data/Scripts.rxdata/[082] PokeBattle_Move.rb 
  1466. @@ -77,17 +77,19 @@ class PokeBattle_Move
  1467.  
  1468.    def pbModifyType(type,attacker,opponent)
  1469.      if type>=0
  1470. -      if attacker.hasWorkingAbility(:NORMALIZE)
  1471. -        type=getConst(PBTypes,:NORMAL) || 0
  1472. -      elsif attacker.hasWorkingAbility(:AERILATE)
  1473. -        type=getConst(PBTypes,:FLYING) || 0
  1474. -        @powerboost=true
  1475. -      elsif attacker.hasWorkingAbility(:REFRIGERATE)
  1476. -        type=getConst(PBTypes,:ICE) || 0
  1477. -        @powerboost=true
  1478. -      elsif attacker.hasWorkingAbility(:PIXILATE)
  1479. -        type=getConst(PBTypes,:FAIRY) || 0
  1480. -        @powerboost=true
  1481. +      if attacker.hasWorkingAbility(:NORMALIZE) && hasConst?(PBTypes,:NORMAL)
  1482. +        type=getConst(PBTypes,:NORMAL)
  1483. +      elsif isConst?(type,PBTypes,:NORMAL)
  1484. +        if attacker.hasWorkingAbility(:AERILATE) && hasConst?(PBTypes,:FLYING)
  1485. +          type=getConst(PBTypes,:FLYING)
  1486. +          @powerboost=true
  1487. +        elsif attacker.hasWorkingAbility(:REFRIGERATE) && hasConst?(PBTypes,:ICE)
  1488. +          type=getConst(PBTypes,:ICE)
  1489. +          @powerboost=true
  1490. +        elsif attacker.hasWorkingAbility(:PIXILATE) && hasConst?(PBTypes,:FAIRY)
  1491. +          type=getConst(PBTypes,:FAIRY)
  1492. +          @powerboost=true
  1493. +        end
  1494.        end
  1495.      end
  1496.      return type
  1497. @@ -96,13 +98,13 @@ class PokeBattle_Move
  1498.    def pbType(type,attacker,opponent)
  1499.      @powerboost=false
  1500.      type=pbModifyType(type,attacker,opponent)
  1501. -    if type>=0
  1502. +    if type>=0 && hasConst?(PBTypes,:ELECTRIC)
  1503.        if @battle.field.effects[PBEffects::IonDeluge] && isConst?(type,PBTypes,:NORMAL)
  1504. -        type=getConst(PBTypes,:ELECTRIC) || 0
  1505. +        type=getConst(PBTypes,:ELECTRIC)
  1506.          @powerboost=false
  1507.        end
  1508.        if attacker.effects[PBEffects::Electrify]
  1509. -        type=getConst(PBTypes,:ELECTRIC) || 0
  1510. +        type=getConst(PBTypes,:ELECTRIC)
  1511.          @powerboost=false
  1512.        end
  1513.      end
  1514. @@ -159,13 +161,15 @@ class PokeBattle_Move
  1515.      # Parental Bond goes here (for single target moves only)
  1516.      if attacker.hasWorkingAbility(:PARENTALBOND)
  1517.        if pbIsDamaging? && !pbTargetsMultiple?(attacker) &&
  1518. -         !pbIsMultiHit && !pbTwoTurnAttack(attacker) &&
  1519. -         [0x6E,                     # Endeavor
  1520. -          0xE0,                     # Selfdestruct/Explosion
  1521. -          0xE1,                     # Final Gambit
  1522. -          0xF7].include?(@function) # Fling
  1523. -        attacker.effects[PBEffects::ParentalBond]=3
  1524. -        return 2
  1525. +         !pbIsMultiHit && !pbTwoTurnAttack(attacker)
  1526. +        exceptions=[0x6E,   # Endeavor
  1527. +                    0xE0,   # Selfdestruct/Explosion
  1528. +                    0xE1,   # Final Gambit
  1529. +                    0xF7]   # Fling
  1530. +        if !exceptions.include?(@function)
  1531. +          attacker.effects[PBEffects::ParentalBond]=3
  1532. +          return 2
  1533. +        end
  1534.        end
  1535.      end
  1536.      # Need to record that Parental Bond applies, to weaken the second attack
  1537. @@ -382,8 +386,7 @@ class PokeBattle_Move
  1538.        mod3=2 if mod3==0
  1539.      end
  1540.      # Foresight
  1541. -    if attacker.hasWorkingAbility(:SCRAPPY) ||
  1542. -       opponent.effects[PBEffects::Foresight]
  1543. +    if attacker.hasWorkingAbility(:SCRAPPY) || opponent.effects[PBEffects::Foresight]
  1544.        mod1=2 if isConst?(otype1,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype1)
  1545.        mod2=2 if isConst?(otype2,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype2)
  1546.        mod3=2 if isConst?(otype3,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype3)
  1547. @@ -401,11 +404,11 @@ class PokeBattle_Move
  1548.        mod3=2 if isConst?(otype3,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype3)
  1549.      end
  1550.      # Smack Down makes Ground moves work against fliers
  1551. -    if !opponent.isAirborne?(attacker.hasMoldBreaker) ||
  1552. -       @function==0x11C # Smack Down
  1553. -      mod1=2 if isConst?(otype1,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
  1554. -      mod2=2 if isConst?(otype2,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
  1555. -      mod3=2 if isConst?(otype3,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
  1556. +    if (!opponent.isAirborne?(attacker.hasMoldBreaker) || @function==0x11C) && # Smack Down
  1557. +       isConst?(atype,PBTypes,:GROUND)
  1558. +      mod1=2 if isConst?(otype1,PBTypes,:FLYING)
  1559. +      mod2=2 if isConst?(otype2,PBTypes,:FLYING)
  1560. +      mod3=2 if isConst?(otype3,PBTypes,:FLYING)
  1561.      end
  1562.      if @function==0x135 && !attacker.effects[PBEffects::Electrify] # Freeze-Dry
  1563.        mod1=4 if isConst?(otype1,PBTypes,:WATER)
  1564. @@ -1102,6 +1105,7 @@ class PokeBattle_Move
  1565.        finaldamagemult=(finaldamagemult*1.2).round
  1566.      end
  1567.      if attacker.hasWorkingItem(:LIFEORB) && (options&SELFCONFUSE)==0
  1568. +      attacker.effects[PBEffects::LifeOrb]=true
  1569.        finaldamagemult=(finaldamagemult*1.3).round
  1570.      end
  1571.      if opponent.damagestate.typemod>8 && (options&IGNOREPKMNTYPES)==0
  1572. @@ -1284,9 +1288,6 @@ class PokeBattle_Move
  1573.    def pbAddTarget(targets,attacker)
  1574.    end
  1575.  
  1576. -  def pbSuccessCheck(attacker,opponent,numtargets)
  1577. -  end
  1578. -
  1579.    def pbDisplayUseMessage(attacker)
  1580.    # Return values:
  1581.    # -1 if the attack should exit as a failure
  1582. diff --git a/Data/Scripts.rxdata/[083] PokeBattle_MoveEffects.rb b/Data/Scripts.rxdata/[083] PokeBattle_MoveEffects.rb
  1583. index 3fbb268..56c8814 100644
  1584. --- a/Data/Scripts.rxdata/[083] PokeBattle_MoveEffects.rb  
  1585. +++ b/Data/Scripts.rxdata/[083] PokeBattle_MoveEffects.rb  
  1586. @@ -74,7 +74,7 @@ class PokeBattle_Struggle < PokeBattle_Move
  1587.      @name       = _INTL("Struggle")
  1588.      @basedamage = 50
  1589.      @type       = -1
  1590. -    @accuracy   = 100
  1591. +    @accuracy   = 0
  1592.      @addlEffect = 0
  1593.      @target     = 0
  1594.      @priority   = 0
  1595. @@ -91,13 +91,11 @@ class PokeBattle_Struggle < PokeBattle_Move
  1596.    def pbIsPhysical?(type); return true; end
  1597.    def pbIsSpecial?(type); return false; end
  1598.  
  1599. -  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
  1600. -    ret=super(attacker,opponent,hitnum,alltargets,showanimation)
  1601. -    if opponent.damagestate.calcdamage>0
  1602. -      attacker.pbReduceHP((attacker.totalhp/4).floor)
  1603. +  def pbEffectAfterHit(attacker,opponent,turneffects)
  1604. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  1605. +      attacker.pbReduceHP((attacker.totalhp/4.0).round)
  1606.        @battle.pbDisplay(_INTL("{1} is damaged by recoil!",attacker.pbThis))
  1607.      end
  1608. -    return ret
  1609.    end
  1610.  
  1611.    def pbCalcDamage(attacker,opponent)
  1612. @@ -156,11 +154,10 @@ class PokeBattle_Move_003 < PokeBattle_Move
  1613.    end
  1614.  
  1615.    def pbAdditionalEffect(attacker,opponent)
  1616. +    return if opponent.damagestate.substitute
  1617.      if opponent.pbCanSleep?(attacker,false,self)
  1618.        opponent.pbSleep
  1619. -      return true
  1620.      end
  1621. -    return false
  1622.    end
  1623.  
  1624.    def pbEffectAfterHit(attacker,opponent,turneffects)
  1625. @@ -169,7 +166,7 @@ class PokeBattle_Move_003 < PokeBattle_Move
  1626.           !attacker.effects[PBEffects::Transform] &&
  1627.           !(attacker.hasWorkingAbility(:SHEERFORCE) && self.addlEffect>0) &&
  1628.           !attacker.isFainted?
  1629. -        attacker.form=(self.form+1)%2
  1630. +        attacker.form=(attacker.form+1)%2
  1631.          attacker.pbUpdate(true)
  1632.          @battle.scene.pbChangePokemon(attacker,attacker.pokemon)
  1633.          @battle.pbDisplay(_INTL("{1} transformed!",attacker.pbThis))
  1634. @@ -213,9 +210,10 @@ class PokeBattle_Move_005 < PokeBattle_Move
  1635.    end
  1636.  
  1637.    def pbAdditionalEffect(attacker,opponent)
  1638. -    return false if !opponent.pbCanPoison?(attacker,false,self)
  1639. -    opponent.pbPoison(attacker)
  1640. -    return true
  1641. +    return if opponent.damagestate.substitute
  1642. +    if opponent.pbCanPoison?(attacker,false,self)
  1643. +      opponent.pbPoison(attacker)
  1644. +    end
  1645.    end
  1646.  end
  1647.  
  1648. @@ -231,14 +229,15 @@ class PokeBattle_Move_006 < PokeBattle_Move
  1649.      return super(attacker,opponent,hitnum,alltargets,showanimation) if pbIsDamaging?
  1650.      return -1 if !opponent.pbCanPoison?(attacker,true,self)
  1651.      pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
  1652. -    opponent.pbPoison(attacker,true)
  1653. +    opponent.pbPoison(attacker,nil,true)
  1654.      return 0
  1655.    end
  1656.  
  1657.    def pbAdditionalEffect(attacker,opponent)
  1658. -    return false if !opponent.pbCanPoison?(attacker,false,self)
  1659. -    opponent.pbPoison(attacker,true)
  1660. -    return true
  1661. +    return if opponent.damagestate.substitute
  1662. +    if opponent.pbCanPoison?(attacker,false,self)
  1663. +      opponent.pbPoison(attacker,nil,true)
  1664. +    end
  1665.    end
  1666.  end
  1667.  
  1668. @@ -274,9 +273,10 @@ class PokeBattle_Move_007 < PokeBattle_Move
  1669.    end
  1670.  
  1671.    def pbAdditionalEffect(attacker,opponent)
  1672. -    return false if !opponent.pbCanParalyze?(attacker,false,self)
  1673. -    opponent.pbParalyze(attacker)
  1674. -    return true
  1675. +    return if opponent.damagestate.substitute
  1676. +    if opponent.pbCanParalyze?(attacker,false,self)
  1677. +      opponent.pbParalyze(attacker)
  1678. +    end
  1679.    end
  1680.  end
  1681.  
  1682. @@ -288,9 +288,10 @@ end
  1683.  ################################################################################
  1684.  class PokeBattle_Move_008 < PokeBattle_Move
  1685.    def pbAdditionalEffect(attacker,opponent)
  1686. -    return false if !opponent.pbCanParalyze?(attacker,false,self)
  1687. -    opponent.pbParalyze(attacker)
  1688. -    return true
  1689. +    return if opponent.damagestate.substitute
  1690. +    if opponent.pbCanParalyze?(attacker,false,self)
  1691. +      opponent.pbParalyze(attacker)
  1692. +    end
  1693.    end
  1694.  
  1695.    def pbModifyBaseAccuracy(baseaccuracy,attacker,opponent)
  1696. @@ -311,18 +312,15 @@ end
  1697.  ################################################################################
  1698.  class PokeBattle_Move_009 < PokeBattle_Move
  1699.    def pbAdditionalEffect(attacker,opponent)
  1700. -    hadeffect=false
  1701. +    return if opponent.damagestate.substitute
  1702.      if @battle.pbRandom(10)==0
  1703. -      break if !opponent.pbCanParalyze?(attacker,false,self)
  1704. -      opponent.pbParalyze(attacker)
  1705. -      hadeffect=true
  1706. -    end
  1707. -    if @battle.pbRandom(10)==0
  1708. -      if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1709. -        hadeffect=true if opponent.pbFlinch(attacker)
  1710. +      if opponent.pbCanParalyze?(attacker,false,self)
  1711. +        opponent.pbParalyze(attacker)
  1712.        end
  1713.      end
  1714. -    return hadeffect
  1715. +    if @battle.pbRandom(10)==0
  1716. +      opponent.pbFlinch(attacker)
  1717. +    end
  1718.    end
  1719.  end
  1720.  
  1721. @@ -351,9 +349,10 @@ class PokeBattle_Move_00A < PokeBattle_Move
  1722.    end
  1723.  
  1724.    def pbAdditionalEffect(attacker,opponent)
  1725. -    return false if !opponent.pbCanBurn?(attacker,false,self)
  1726. -    opponent.pbBurn(attacker)
  1727. -    return true
  1728. +    return if opponent.damagestate.substitute
  1729. +    if opponent.pbCanBurn?(attacker,false,self)
  1730. +      opponent.pbBurn(attacker)
  1731. +    end
  1732.    end
  1733.  end
  1734.  
  1735. @@ -364,18 +363,15 @@ end
  1736.  ################################################################################
  1737.  class PokeBattle_Move_00B < PokeBattle_Move
  1738.    def pbAdditionalEffect(attacker,opponent)
  1739. -    hadeffect=false
  1740. +    return if opponent.damagestate.substitute
  1741.      if @battle.pbRandom(10)==0
  1742. -      break if !opponent.pbCanBurn?(attacker,false,self)
  1743. -      opponent.pbBurn(attacker)
  1744. -      hadeffect=true
  1745. -    end
  1746. -    if @battle.pbRandom(10)==0
  1747. -      if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1748. -        hadeffect=true if opponent.pbFlinch(attacker)
  1749. +      if opponent.pbCanBurn?(attacker,false,self)
  1750. +        opponent.pbBurn(attacker)
  1751.        end
  1752.      end
  1753. -    return hadeffect
  1754. +    if @battle.pbRandom(10)==0
  1755. +      opponent.pbFlinch(attacker)
  1756. +    end
  1757.    end
  1758.  end
  1759.  
  1760. @@ -394,11 +390,10 @@ class PokeBattle_Move_00C < PokeBattle_Move
  1761.    end
  1762.  
  1763.    def pbAdditionalEffect(attacker,opponent)
  1764. +    return if opponent.damagestate.substitute
  1765.      if opponent.pbCanFreeze?(attacker,false,self)
  1766.        opponent.pbFreeze
  1767. -      return true
  1768.      end
  1769. -    return false
  1770.    end
  1771.  end
  1772.  
  1773. @@ -417,11 +412,10 @@ class PokeBattle_Move_00D < PokeBattle_Move
  1774.    end
  1775.  
  1776.    def pbAdditionalEffect(attacker,opponent)
  1777. +    return if opponent.damagestate.substitute
  1778.      if opponent.pbCanFreeze?(attacker,false,self)
  1779.        opponent.pbFreeze
  1780. -      return true
  1781.      end
  1782. -    return false
  1783.    end
  1784.  
  1785.    def pbModifyBaseAccuracy(baseaccuracy,attacker,opponent)
  1786. @@ -439,18 +433,15 @@ end
  1787.  ################################################################################
  1788.  class PokeBattle_Move_00E < PokeBattle_Move
  1789.    def pbAdditionalEffect(attacker,opponent)
  1790. -    hadeffect=false
  1791. +    return if opponent.damagestate.substitute
  1792.      if @battle.pbRandom(10)==0
  1793. -      break if !opponent.pbCanFreeze?(attacker,false,self)
  1794. -      opponent.pbFreeze
  1795. -      hadeffect=true
  1796. -    end
  1797. -    if @battle.pbRandom(10)==0
  1798. -      if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1799. -        hadeffect=true if opponent.pbFlinch(attacker)
  1800. +      if opponent.pbCanFreeze?(attacker,false,self)
  1801. +        opponent.pbFreeze
  1802.        end
  1803.      end
  1804. -    return hadeffect
  1805. +    if @battle.pbRandom(10)==0
  1806. +      opponent.pbFlinch(attacker)
  1807. +    end
  1808.    end
  1809.  end
  1810.  
  1811. @@ -461,10 +452,8 @@ end
  1812.  ################################################################################
  1813.  class PokeBattle_Move_00F < PokeBattle_Move
  1814.    def pbAdditionalEffect(attacker,opponent)
  1815. -    if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1816. -      return opponent.pbFlinch(attacker)
  1817. -    end
  1818. -    return false
  1819. +    return if opponent.damagestate.substitute
  1820. +    opponent.pbFlinch(attacker)
  1821.    end
  1822.  end
  1823.  
  1824. @@ -476,10 +465,8 @@ end
  1825.  ################################################################################
  1826.  class PokeBattle_Move_010 < PokeBattle_Move
  1827.    def pbAdditionalEffect(attacker,opponent)
  1828. -    if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1829. -      return opponent.pbFlinch(attacker)
  1830. -    end
  1831. -    return false
  1832. +    return if opponent.damagestate.substitute
  1833. +    opponent.pbFlinch(attacker)
  1834.    end
  1835.  
  1836.    def tramplesMinimize?(param=1)
  1837. @@ -505,10 +492,8 @@ class PokeBattle_Move_011 < PokeBattle_Move
  1838.    end
  1839.  
  1840.    def pbAdditionalEffect(attacker,opponent)
  1841. -    if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1842. -      return opponent.pbFlinch(attacker)
  1843. -    end
  1844. -    return false
  1845. +    return if opponent.damagestate.substitute
  1846. +    opponent.pbFlinch(attacker)
  1847.    end
  1848.  end
  1849.  
  1850. @@ -523,10 +508,8 @@ class PokeBattle_Move_012 < PokeBattle_Move
  1851.    end
  1852.  
  1853.    def pbAdditionalEffect(attacker,opponent)
  1854. -    if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  1855. -      return opponent.pbFlinch(attacker)
  1856. -    end
  1857. -    return false
  1858. +    return if opponent.damagestate.substitute
  1859. +    opponent.pbFlinch(attacker)
  1860.    end
  1861.  end
  1862.  
  1863. @@ -548,12 +531,11 @@ class PokeBattle_Move_013 < PokeBattle_Move
  1864.    end
  1865.  
  1866.    def pbAdditionalEffect(attacker,opponent)
  1867. +    return if opponent.damagestate.substitute
  1868.      if opponent.pbCanConfuse?(attacker,false,self)
  1869.        opponent.pbConfuse
  1870.        @battle.pbDisplay(_INTL("{1} became confused!",opponent.pbThis))
  1871. -      return true
  1872.      end
  1873. -    return false
  1874.    end
  1875.  end
  1876.  
  1877. @@ -575,12 +557,11 @@ class PokeBattle_Move_014 < PokeBattle_Move
  1878.    end
  1879.  
  1880.    def pbAdditionalEffect(attacker,opponent)
  1881. +    return if opponent.damagestate.substitute
  1882.      if opponent.pbCanConfuse?(attacker,false,self)
  1883.        opponent.pbConfuse
  1884.        @battle.pbDisplay(_INTL("{1} became confused!",opponent.pbThis))
  1885. -      return true
  1886.      end
  1887. -    return false
  1888.    end
  1889.  end
  1890.  
  1891. @@ -603,12 +584,11 @@ class PokeBattle_Move_015 < PokeBattle_Move
  1892.    end
  1893.  
  1894.    def pbAdditionalEffect(attacker,opponent)
  1895. +    return if opponent.damagestate.substitute
  1896.      if opponent.pbCanConfuse?(attacker,false,self)
  1897.        opponent.pbConfuse
  1898.        @battle.pbDisplay(_INTL("{1} became confused!",opponent.pbThis))
  1899. -      return true
  1900.      end
  1901. -    return false
  1902.    end
  1903.  
  1904.    def pbModifyBaseAccuracy(baseaccuracy,attacker,opponent)
  1905. @@ -656,19 +636,21 @@ end
  1906.  ################################################################################
  1907.  class PokeBattle_Move_017 < PokeBattle_Move
  1908.    def pbAdditionalEffect(attacker,opponent)
  1909. -    rnd=@battle.pbRandom(3)
  1910. -    case rnd
  1911. +    return if opponent.damagestate.substitute
  1912. +    case @battle.pbRandom(3)
  1913.      when 0
  1914. -      return false if !opponent.pbCanBurn?(attacker,false,self)
  1915. -      opponent.pbBurn(attacker)
  1916. +      if opponent.pbCanBurn?(attacker,false,self)
  1917. +        opponent.pbBurn(attacker)
  1918. +      end
  1919.      when 1
  1920. -      return false if !opponent.pbCanFreeze?(attacker,false,self)
  1921. -      opponent.pbFreeze
  1922. +      if opponent.pbCanFreeze?(attacker,false,self)
  1923. +        opponent.pbFreeze
  1924. +      end
  1925.      when 2
  1926. -      return false if !opponent.pbCanParalyze?(attacker,false,self)
  1927. -      opponent.pbParalyze(attacker)
  1928. +      if opponent.pbCanParalyze?(attacker,false,self)
  1929. +        opponent.pbParalyze(attacker)
  1930. +      end
  1931.      end
  1932. -    return true
  1933.    end
  1934.  end
  1935.  
  1936. @@ -807,7 +789,7 @@ class PokeBattle_Move_01B < PokeBattle_Move
  1937.        attacker.pbCureStatus(false)
  1938.        @battle.pbDisplay(_INTL("{1} woke up.",attacker.pbThis))
  1939.      when PBStatuses::POISON
  1940. -      opponent.pbPoison(attacker,attacker.statusCount!=0)
  1941. +      opponent.pbPoison(attacker,nil,attacker.statusCount!=0)
  1942.        opponent.pbAbilityCureCheck
  1943.        attacker.pbCureStatus(false)
  1944.        @battle.pbDisplay(_INTL("{1} was cured of its poisoning.",attacker.pbThis))
  1945. @@ -844,7 +826,6 @@ class PokeBattle_Move_01C < PokeBattle_Move
  1946.      if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
  1947.        attacker.pbIncreaseStat(PBStats::ATTACK,1,attacker,false,self)
  1948.      end
  1949. -    return true
  1950.    end
  1951.  end
  1952.  
  1953. @@ -866,7 +847,6 @@ class PokeBattle_Move_01D < PokeBattle_Move
  1954.      if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
  1955.        attacker.pbIncreaseStat(PBStats::DEFENSE,1,attacker,false,self)
  1956.      end
  1957. -    return true
  1958.    end
  1959.  end
  1960.  
  1961. @@ -903,7 +883,6 @@ class PokeBattle_Move_01F < PokeBattle_Move
  1962.      if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
  1963.        attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self)
  1964.      end
  1965. -    return true
  1966.    end
  1967.  end
  1968.  
  1969. @@ -925,7 +904,6 @@ class PokeBattle_Move_020 < PokeBattle_Move
  1970.      if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
  1971.        attacker.pbIncreaseStat(PBStats::SPATK,1,attacker,false,self)
  1972.      end
  1973. -    return true
  1974.    end
  1975.  end
  1976.  
  1977. @@ -965,7 +943,6 @@ class PokeBattle_Move_022 < PokeBattle_Move
  1978.      if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
  1979.        attacker.pbIncreaseStat(PBStats::EVASION,1,attacker,false,self)
  1980.      end
  1981. -    return true
  1982.    end
  1983.  end
  1984.  
  1985. @@ -992,7 +969,6 @@ class PokeBattle_Move_023 < PokeBattle_Move
  1986.        attacker.effects[PBEffects::FocusEnergy]=2
  1987.        @battle.pbDisplay(_INTL("{1} is getting pumped!",attacker.pbThis))
  1988.      end
  1989. -    return true
  1990.    end
  1991.  end
  1992.  
  1993. @@ -1275,7 +1251,6 @@ class PokeBattle_Move_02D < PokeBattle_Move
  1994.        attacker.pbIncreaseStat(PBStats::SPEED,1,attacker,false,self,showanim)
  1995.        showanim=false
  1996.      end
  1997. -    return true
  1998.    end
  1999.  end
  2000.  
  2001. @@ -1297,7 +1272,6 @@ class PokeBattle_Move_02E < PokeBattle_Move
  2002.      if attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self)
  2003.        attacker.pbIncreaseStat(PBStats::ATTACK,2,attacker,false,self)
  2004.      end
  2005. -    return true
  2006.    end
  2007.  end
  2008.  
  2009. @@ -1319,7 +1293,6 @@ class PokeBattle_Move_02F < PokeBattle_Move
  2010.      if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
  2011.        attacker.pbIncreaseStat(PBStats::DEFENSE,2,attacker,false,self)
  2012.      end
  2013. -    return true
  2014.    end
  2015.  end
  2016.  
  2017. @@ -1341,7 +1314,6 @@ class PokeBattle_Move_030 < PokeBattle_Move
  2018.      if attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
  2019.        attacker.pbIncreaseStat(PBStats::SPEED,2,attacker,false,self)
  2020.      end
  2021. -    return true
  2022.    end
  2023.  end
  2024.  
  2025. @@ -1381,7 +1353,6 @@ class PokeBattle_Move_032 < PokeBattle_Move
  2026.      if attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self)
  2027.        attacker.pbIncreaseStat(PBStats::SPATK,2,attacker,false,self)
  2028.      end
  2029. -    return true
  2030.    end
  2031.  end
  2032.  
  2033. @@ -1403,7 +1374,6 @@ class PokeBattle_Move_033 < PokeBattle_Move
  2034.      if attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,attacker,false,self)
  2035.        attacker.pbIncreaseStat(PBStats::SPDEF,2,attacker,false,self)
  2036.      end
  2037. -    return true
  2038.    end
  2039.  end
  2040.  
  2041. @@ -1427,7 +1397,6 @@ class PokeBattle_Move_034 < PokeBattle_Move
  2042.      if attacker.pbCanIncreaseStatStage?(PBStats::EVASION,attacker,false,self)
  2043.        attacker.pbIncreaseStat(PBStats::EVASION,2,attacker,false,self)
  2044.      end
  2045. -    return true
  2046.    end
  2047.  end
  2048.  
  2049. @@ -1546,7 +1515,6 @@ class PokeBattle_Move_038 < PokeBattle_Move
  2050.      if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
  2051.        attacker.pbIncreaseStat(PBStats::DEFENSE,3,attacker,false,self)
  2052.      end
  2053. -    return true
  2054.    end
  2055.  end
  2056.  
  2057. @@ -1568,7 +1536,6 @@ class PokeBattle_Move_039 < PokeBattle_Move
  2058.      if attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,attacker,false,self)
  2059.        attacker.pbIncreaseStat(PBStats::SPATK,3,attacker,false,self)
  2060.      end
  2061. -    return true
  2062.    end
  2063.  end
  2064.  
  2065. @@ -1777,10 +1744,10 @@ class PokeBattle_Move_042 < PokeBattle_Move
  2066.    end
  2067.  
  2068.    def pbAdditionalEffect(attacker,opponent)
  2069. +    return if opponent.damagestate.substitute
  2070.      if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
  2071.        opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self)
  2072.      end
  2073. -    return true
  2074.    end
  2075.  end
  2076.  
  2077. @@ -1799,10 +1766,10 @@ class PokeBattle_Move_043 < PokeBattle_Move
  2078.    end
  2079.  
  2080.    def pbAdditionalEffect(attacker,opponent)
  2081. +    return if opponent.damagestate.substitute
  2082.      if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
  2083.        opponent.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self)
  2084.      end
  2085. -    return true
  2086.    end
  2087.  end
  2088.  
  2089. @@ -1821,10 +1788,10 @@ class PokeBattle_Move_044 < PokeBattle_Move
  2090.    end
  2091.  
  2092.    def pbAdditionalEffect(attacker,opponent)
  2093. +    return if opponent.damagestate.substitute
  2094.      if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
  2095.        opponent.pbReduceStat(PBStats::SPEED,1,attacker,false,self)
  2096.      end
  2097. -    return true
  2098.    end
  2099.  
  2100.    def pbModifyDamage(damagemult,attacker,opponent)
  2101. @@ -1851,10 +1818,10 @@ class PokeBattle_Move_045 < PokeBattle_Move
  2102.    end
  2103.  
  2104.    def pbAdditionalEffect(attacker,opponent)
  2105. +    return if opponent.damagestate.substitute
  2106.      if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
  2107.        opponent.pbReduceStat(PBStats::SPATK,1,attacker,false,self)
  2108.      end
  2109. -    return true
  2110.    end
  2111.  end
  2112.  
  2113. @@ -1873,10 +1840,10 @@ class PokeBattle_Move_046 < PokeBattle_Move
  2114.    end
  2115.  
  2116.    def pbAdditionalEffect(attacker,opponent)
  2117. +    return if opponent.damagestate.substitute
  2118.      if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
  2119.        opponent.pbReduceStat(PBStats::SPDEF,1,attacker,false,self)
  2120.      end
  2121. -    return true
  2122.    end
  2123.  end
  2124.  
  2125. @@ -1895,10 +1862,10 @@ class PokeBattle_Move_047 < PokeBattle_Move
  2126.    end
  2127.  
  2128.    def pbAdditionalEffect(attacker,opponent)
  2129. +    return if opponent.damagestate.substitute
  2130.      if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
  2131.        opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self)
  2132.      end
  2133. -    return true
  2134.    end
  2135.  end
  2136.  
  2137. @@ -1918,18 +1885,18 @@ class PokeBattle_Move_048 < PokeBattle_Move
  2138.    end
  2139.  
  2140.    def pbAdditionalEffect(attacker,opponent)
  2141. +    return if opponent.damagestate.substitute
  2142.      if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
  2143.        increment=(USENEWBATTLEMECHANICS) ? 2 : 1
  2144.        opponent.pbReduceStat(PBStats::EVASION,increment,attacker,false,self)
  2145.      end
  2146. -    return true
  2147.    end
  2148.  end
  2149.  
  2150.  
  2151.  
  2152.  ################################################################################
  2153. -# Decreases the target's evasion by 1 stage.  Ends all barriers and entry
  2154. +# Decreases the target's evasion by 1 stage. Ends all barriers and entry
  2155.  # hazards for the target's side OR on both sides. (Defog)
  2156.  ################################################################################
  2157.  class PokeBattle_Move_049 < PokeBattle_Move
  2158. @@ -1959,8 +1926,10 @@ class PokeBattle_Move_049 < PokeBattle_Move
  2159.    end
  2160.  
  2161.    def pbAdditionalEffect(attacker,opponent)
  2162. -    if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
  2163. -      opponent.pbReduceStat(PBStats::EVASION,1,attacker,false,self)
  2164. +    if !opponent.damagestate.substitute
  2165. +      if opponent.pbCanReduceStatStage?(PBStats::EVASION,attacker,false,self)
  2166. +        opponent.pbReduceStat(PBStats::EVASION,1,attacker,false,self)
  2167. +      end
  2168.      end
  2169.      opponent.pbOwnSide.effects[PBEffects::Reflect]     = 0
  2170.      opponent.pbOwnSide.effects[PBEffects::LightScreen] = 0
  2171. @@ -1980,7 +1949,6 @@ class PokeBattle_Move_049 < PokeBattle_Move
  2172.        opponent.pbOpposingSide.effects[PBEffects::StickyWeb]   = false
  2173.        opponent.pbOpposingSide.effects[PBEffects::ToxicSpikes] = 0
  2174.      end
  2175. -    return true
  2176.    end
  2177.  end
  2178.  
  2179. @@ -2049,10 +2017,10 @@ class PokeBattle_Move_04B < PokeBattle_Move
  2180.    end
  2181.  
  2182.    def pbAdditionalEffect(attacker,opponent)
  2183. +    return if opponent.damagestate.substitute
  2184.      if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
  2185.        opponent.pbReduceStat(PBStats::ATTACK,2,attacker,false,self)
  2186.      end
  2187. -    return true
  2188.    end
  2189.  end
  2190.  
  2191. @@ -2071,10 +2039,10 @@ class PokeBattle_Move_04C < PokeBattle_Move
  2192.    end
  2193.  
  2194.    def pbAdditionalEffect(attacker,opponent)
  2195. +    return if opponent.damagestate.substitute
  2196.      if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
  2197.        opponent.pbReduceStat(PBStats::DEFENSE,2,attacker,false,self)
  2198.      end
  2199. -    return true
  2200.    end
  2201.  end
  2202.  
  2203. @@ -2095,11 +2063,11 @@ class PokeBattle_Move_04D < PokeBattle_Move
  2204.    end
  2205.  
  2206.    def pbAdditionalEffect(attacker,opponent)
  2207. +    return if opponent.damagestate.substitute
  2208.      if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
  2209.        increment=(isConst?(@id,PBMoves,:STRINGSHOT) && !USENEWBATTLEMECHANICS) ? 1 : 2
  2210.        opponent.pbReduceStat(PBStats::SPEED,increment,attacker,false,self)
  2211.      end
  2212. -    return true
  2213.    end
  2214.  end
  2215.  
  2216. @@ -2128,13 +2096,14 @@ class PokeBattle_Move_04E < PokeBattle_Move
  2217.    end
  2218.  
  2219.    def pbAdditionalEffect(attacker,opponent)
  2220. -    return false if attacker.gender==2 || opponent.gender==2 ||
  2221. -                    attacker.gender==opponent.gender
  2222. -    return false if !attacker.hasMoldBreaker && opponent.hasWorkingAbility(:OBLIVIOUS)
  2223. -    if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
  2224. -      opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self)
  2225. +    return if opponent.damagestate.substitute
  2226. +    if attacker.gender!=2 && opponent.gender!=2 && attacker.gender!=opponent.gender
  2227. +      if attacker.hasMoldBreaker || !opponent.hasWorkingAbility(:OBLIVIOUS)
  2228. +        if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
  2229. +          opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self)
  2230. +        end
  2231. +      end
  2232.      end
  2233. -    return true
  2234.    end
  2235.  end
  2236.  
  2237. @@ -2153,10 +2122,10 @@ class PokeBattle_Move_04F < PokeBattle_Move
  2238.    end
  2239.  
  2240.    def pbAdditionalEffect(attacker,opponent)
  2241. +    return if opponent.damagestate.substitute
  2242.      if opponent.pbCanReduceStatStage?(PBStats::SPDEF,attacker,false,self)
  2243.        opponent.pbReduceStat(PBStats::SPDEF,2,attacker,false,self)
  2244.      end
  2245. -    return true
  2246.    end
  2247.  end
  2248.  
  2249. @@ -2586,24 +2555,24 @@ class PokeBattle_Move_060 < PokeBattle_Move
  2250.        @battle.pbDisplay(_INTL("But it failed!"))
  2251.        return -1
  2252.      end
  2253. -    envtypes=[
  2254. -       :NORMAL, # None
  2255. -       :GRASS,  # Grass
  2256. -       :GRASS,  # Tall grass
  2257. -       :WATER,  # Moving water
  2258. -       :WATER,  # Still water
  2259. -       :WATER,  # Underwater
  2260. -       :ROCK,   # Cave
  2261. -       :GROUND, # Rock
  2262. -       :GROUND, # Sand
  2263. -       :BUG,    # Forest
  2264. -       :ICE,    # Snow
  2265. -       :FIRE,   # Volcano
  2266. -       :GHOST,  # Graveyard
  2267. -       :FLYING, # Sky
  2268. -       :DRAGON  # Space
  2269. -    ]
  2270. -    type=getConst(PBTypes,envtypes[@battle.environment]) || 0
  2271. +    type=getConst(PBTypes,:NORMAL) || 0
  2272. +    case @battle.environment
  2273. +    when PBEnvironment::None;        type=getConst(PBTypes,:NORMAL) || 0
  2274. +    when PBEnvironment::Grass;       type=getConst(PBTypes,:GRASS) || 0
  2275. +    when PBEnvironment::TallGrass;   type=getConst(PBTypes,:GRASS) || 0
  2276. +    when PBEnvironment::MovingWater; type=getConst(PBTypes,:WATER) || 0
  2277. +    when PBEnvironment::StillWater;  type=getConst(PBTypes,:WATER) || 0
  2278. +    when PBEnvironment::Underwater;  type=getConst(PBTypes,:WATER) || 0
  2279. +    when PBEnvironment::Cave;        type=getConst(PBTypes,:ROCK) || 0
  2280. +    when PBEnvironment::Rock;        type=getConst(PBTypes,:GROUND) || 0
  2281. +    when PBEnvironment::Sand;        type=getConst(PBTypes,:GROUND) || 0
  2282. +    when PBEnvironment::Forest;      type=getConst(PBTypes,:BUG) || 0
  2283. +    when PBEnvironment::Snow;        type=getConst(PBTypes,:ICE) || 0
  2284. +    when PBEnvironment::Volcano;     type=getConst(PBTypes,:FIRE) || 0
  2285. +    when PBEnvironment::Graveyard;   type=getConst(PBTypes,:GHOST) || 0
  2286. +    when PBEnvironment::Sky;         type=getConst(PBTypes,:FLYING) || 0
  2287. +    when PBEnvironment::Space;       type=getConst(PBTypes,:DRAGON) || 0
  2288. +    end
  2289.      if @battle.field.effects[PBEffects::ElectricTerrain]>0
  2290.        type=getConst(PBTypes,:ELECTRIC) if hasConst?(PBTypes,:ELECTRIC)
  2291.      elsif @battle.field.effects[PBEffects::GrassyTerrain]>0
  2292. @@ -3153,9 +3122,9 @@ class PokeBattle_Move_074 < PokeBattle_Move
  2293.      ret=super(attacker,opponent,hitnum,alltargets,showanimation)
  2294.      if opponent.damagestate.calcdamage>0
  2295.        if opponent.pbPartner && !opponent.pbPartner.isFainted? &&
  2296. -         !opponent.pbParnter.hasWorkingAbility(:MAGICGUARD)
  2297. +         !opponent.pbPartner.hasWorkingAbility(:MAGICGUARD)
  2298.          opponent.pbPartner.pbReduceHP((opponent.pbPartner.totalhp/16).floor)
  2299. -        @battle.pbDisplay(_INTL("The bursting flame hit {1}",opponent.pbPartner.pbThis(true)))
  2300. +        @battle.pbDisplay(_INTL("The bursting flame hit {1}!",opponent.pbPartner.pbThis(true)))
  2301.        end
  2302.      end
  2303.      return ret
  2304. @@ -3234,10 +3203,8 @@ class PokeBattle_Move_078 < PokeBattle_Move
  2305.    end
  2306.  
  2307.    def pbAdditionalEffect(attacker,opponent)
  2308. -    if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  2309. -      return opponent.pbFlinch(attacker)
  2310. -    end
  2311. -    return false
  2312. +    return if opponent.damagestate.substitute
  2313. +    opponent.pbFlinch(attacker)
  2314.    end
  2315.  end
  2316.  
  2317. @@ -3826,7 +3793,7 @@ end
  2318.  class PokeBattle_Move_096 < PokeBattle_Move
  2319.    def pbOnStartUse(attacker)
  2320.      if !pbIsBerry?(attacker.item) ||
  2321. -       @effects[PBEffects::Embargo]>0 ||
  2322. +       attacker.effects[PBEffects::Embargo]>0 ||
  2323.         @battle.field.effects[PBEffects::MagicRoom]>0 ||
  2324.         attacker.hasWorkingAbility(:KLUTZ) ||
  2325.         attacker.pbOpposing1.hasWorkingAbility(:UNNERVE) ||
  2326. @@ -3907,7 +3874,7 @@ class PokeBattle_Move_096 < PokeBattle_Move
  2327.    end
  2328.  
  2329.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2330. -    if opponent.damagestate.calcdamage>0
  2331. +    if turneffects[PBEffects::TotalDamage]>0>0
  2332.        attacker.pbConsumeItem
  2333.      end
  2334.    end
  2335. @@ -4214,88 +4181,94 @@ end
  2336.  ################################################################################
  2337.  class PokeBattle_Move_0A4 < PokeBattle_Move
  2338.    def pbAdditionalEffect(attacker,opponent)
  2339. +    return if opponent.damagestate.substitute
  2340.      if @battle.field.effects[PBEffects::ElectricTerrain]>0
  2341. -      return false if !opponent.pbCanParalyze?(attacker,false,self)
  2342. -      opponent.pbParalyze(attacker)
  2343. -      return true
  2344. +      if opponent.pbCanParalyze?(attacker,false,self)
  2345. +        opponent.pbParalyze(attacker)
  2346. +        return
  2347. +      end
  2348.      elsif @battle.field.effects[PBEffects::GrassyTerrain]>0
  2349. -      return false if !opponent.pbCanSleep?(attacker,false,self)
  2350. -      opponent.pbSleep
  2351. -      return true
  2352. +      if opponent.pbCanSleep?(attacker,false,self)
  2353. +        opponent.pbSleep
  2354. +        return
  2355. +      end
  2356.      elsif @battle.field.effects[PBEffects::MistyTerrain]>0
  2357. -      return false if !opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
  2358. -      opponent.pbReduceStat(PBStats::SPATK,1,attacker,false,self)
  2359. -      return true
  2360. +      if !opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
  2361. +        opponent.pbReduceStat(PBStats::SPATK,1,attacker,false,self)
  2362. +        return
  2363. +      end
  2364.      end
  2365.      case @battle.environment
  2366.      when PBEnvironment::Grass, PBEnvironment::TallGrass, PBEnvironment::Forest
  2367. -      return false if !opponent.pbCanSleep?(attacker,false,self)
  2368. -      opponent.pbSleep
  2369. +      if opponent.pbCanSleep?(attacker,false,self)
  2370. +        opponent.pbSleep
  2371. +      end
  2372.      when PBEnvironment::MovingWater, PBEnvironment::Underwater
  2373. -      return false if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
  2374. -      opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self)
  2375. +      if opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker,false,self)
  2376. +        opponent.pbReduceStat(PBStats::ATTACK,1,attacker,false,self)
  2377. +      end
  2378.      when PBEnvironment::StillWater, PBEnvironment::Sky
  2379. -      return false if !opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
  2380. -      opponent.pbReduceStat(PBStats::SPEED,1,attacker,false,self)
  2381. +      if !opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
  2382. +        opponent.pbReduceStat(PBStats::SPEED,1,attacker,false,self)
  2383. +      end
  2384.      when PBEnvironment::Sand
  2385. -      return false if !opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
  2386. -      opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self)
  2387. +      if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
  2388. +        opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self)
  2389. +      end
  2390.      when PBEnvironment::Rock
  2391.        if USENEWBATTLEMECHANICS
  2392. -        return false if !opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
  2393. -        opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self)
  2394. +        if opponent.pbCanReduceStatStage?(PBStats::ACCURACY,attacker,false,self)
  2395. +          opponent.pbReduceStat(PBStats::ACCURACY,1,attacker,false,self)
  2396. +        end
  2397.        else
  2398. -        return false if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
  2399. -        return opponent.pbFlinch(attacker)
  2400. +        if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  2401. +          opponent.pbFlinch(attacker)
  2402. +        end
  2403.        end
  2404.      when PBEnvironment::Cave, PBEnvironment::Graveyard, PBEnvironment::Space
  2405. -      return false if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
  2406. -      return opponent.pbFlinch(attacker)
  2407. +      if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  2408. +        opponent.pbFlinch(attacker)
  2409. +      end
  2410.      when PBEnvironment::Snow
  2411. -      return false if !opponent.pbCanFreeze?(attacker,false,self)
  2412. -      opponent.pbFreeze
  2413. +      if opponent.pbCanFreeze?(attacker,false,self)
  2414. +        opponent.pbFreeze
  2415. +      end
  2416.      when PBEnvironment::Volcano
  2417. -      return false if !opponent.pbCanBurn?(attacker,false,self)
  2418. -      opponent.pbBurn(attacker)
  2419. +      if opponent.pbCanBurn?(attacker,false,self)
  2420. +        opponent.pbBurn(attacker)
  2421. +      end
  2422.      else
  2423. -      return false if !opponent.pbCanParalyze?(attacker,false,self)
  2424. -      opponent.pbParalyze(attacker)
  2425. +      if opponent.pbCanParalyze?(attacker,false,self)
  2426. +        opponent.pbParalyze(attacker)
  2427. +      end
  2428.      end
  2429. -    return true
  2430.    end
  2431.  
  2432.    def pbShowAnimation(id,attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
  2433.      id=getConst(PBMoves,:BODYSLAM)
  2434.      case @battle.environment
  2435.      when PBEnvironment::Grass, PBEnvironment::TallGrass
  2436. -      id=(USENEWBATTLEMECHANICS) ? getConst(PBMoves,:VINEWHIP) : getConst(PBMoves,:NEEDLEARM)
  2437. -    when PBEnvironment::Forest
  2438. -      id=getConst(PBMoves,:RAZORLEAF)
  2439. -    when PBEnvironment::MovingWater, PBEnvironment::Underwater
  2440. -      id=getConst(PBMoves,:WATERPULSE)
  2441. -    when PBEnvironment::StillWater
  2442. -      id=getConst(PBMoves,:MUDSHOT)
  2443. -    when PBEnvironment::Cave
  2444. -      id=getConst(PBMoves,:ROCKTHROW)
  2445. -    when PBEnvironment::Rock, PBEnvironment::Sand
  2446. -      id=getConst(PBMoves,:MUDSLAP)
  2447. -    when PBEnvironment::Snow
  2448. -      id=getConst(PBMoves,:AVALANCHE) # Ice tiles in Gen 6 should be Ice Shard
  2449. -    when PBEnvironment::Volcano
  2450. -      id=getConst(PBMoves,:INCINERATE)
  2451. -    when PBEnvironment::Graveyard
  2452. -      id=getConst(PBMoves,:SHADOWSNEAK)
  2453. -    when PBEnvironment::Sky
  2454. -      id=getConst(PBMoves,:GUST)
  2455. -    when PBEnvironment::Space
  2456. -      id=getConst(PBMoves,:SWIFT)
  2457. +      id=((USENEWBATTLEMECHANICS) ? getConst(PBMoves,:VINEWHIP) : getConst(PBMoves,:NEEDLEARM)) || id
  2458. +    when PBEnvironment::MovingWater; id=getConst(PBMoves,:WATERPULSE) || id
  2459. +    when PBEnvironment::StillWater;  id=getConst(PBMoves,:MUDSHOT) || id
  2460. +    when PBEnvironment::Underwater;  id=getConst(PBMoves,:WATERPULSE) || id
  2461. +    when PBEnvironment::Cave;        id=getConst(PBMoves,:ROCKTHROW) || id
  2462. +    when PBEnvironment::Rock;        id=getConst(PBMoves,:MUDSLAP) || id
  2463. +    when PBEnvironment::Sand;        id=getConst(PBMoves,:MUDSLAP) || id
  2464. +    when PBEnvironment::Forest;      id=getConst(PBMoves,:RAZORLEAF) || id
  2465. +    # Ice tiles in Gen 6 should be Ice Shard
  2466. +    when PBEnvironment::Snow;        id=getConst(PBMoves,:AVALANCHE) || id
  2467. +    when PBEnvironment::Volcano;     id=getConst(PBMoves,:INCINERATE) || id
  2468. +    when PBEnvironment::Graveyard;   id=getConst(PBMoves,:SHADOWSNEAK) || id
  2469. +    when PBEnvironment::Sky;         id=getConst(PBMoves,:GUST) || id
  2470. +    when PBEnvironment::Space;       id=getConst(PBMoves,:SWIFT) || id
  2471.      end
  2472.      if @battle.field.effects[PBEffects::ElectricTerrain]>0
  2473. -      id=getConst(PBMoves,:THUNDERSHOCK)
  2474. +      id=getConst(PBMoves,:THUNDERSHOCK) || id
  2475.      elsif @battle.field.effects[PBEffects::GrassyTerrain]>0
  2476. -      id=getConst(PBMoves,:VINEWHIP)
  2477. +      id=getConst(PBMoves,:VINEWHIP) || id
  2478.      elsif @battle.field.effects[PBEffects::MistyTerrain]>0
  2479. -      id=getConst(PBMoves,:FAIRYWIND)
  2480. +      id=getConst(PBMoves,:FAIRYWIND) || id
  2481.      end
  2482.      return super(id,attacker,opponent,hitnum,alltargets,showanimation) # Environment-specific anim
  2483.    end
  2484. @@ -4682,47 +4655,23 @@ class PokeBattle_Move_0B3 < PokeBattle_Move
  2485.      move=getConst(PBMoves,:TRIATTACK) || 0
  2486.      case @battle.environment
  2487.      when PBEnvironment::Grass, PBEnvironment::TallGrass, PBEnvironment::Forest
  2488. -      if USENEWBATTLEMECHANICS
  2489. -        move=getConst(PBMoves,:ENERGYBALL) || move
  2490. -      else
  2491. -        move=getConst(PBMoves,:SEEDBOMB) || move
  2492. -      end
  2493. -    when PBEnvironment::MovingWater, PBEnvironment::Underwater
  2494. -      move=getConst(PBMoves,:HYDROPUMP) || move
  2495. -    when PBEnvironment::StillWater
  2496. -      move=getConst(PBMoves,:MUDBOMB) || move
  2497. +      move=((USENEWBATTLEMECHANICS) ? getConst(PBMoves,:ENERGYBALL) : getConst(PBMoves,:SEEDBOMB)) || move
  2498. +    when PBEnvironment::MovingWater; move=getConst(PBMoves,:HYDROPUMP) || move
  2499. +    when PBEnvironment::StillWater;  move=getConst(PBMoves,:MUDBOMB) || move
  2500. +    when PBEnvironment::Underwater;  move=getConst(PBMoves,:HYDROPUMP) || move
  2501.      when PBEnvironment::Cave
  2502. -      if USENEWBATTLEMECHANICS
  2503. -        move=getConst(PBMoves,:POWERGEM) || move
  2504. -      else
  2505. -        move=getConst(PBMoves,:ROCKSLIDE) || move
  2506. -      end
  2507. +      move=((USENEWBATTLEMECHANICS) ? getConst(PBMoves,:POWERGEM) : getConst(PBMoves,:ROCKSLIDE)) || move
  2508.      when PBEnvironment::Rock
  2509. -      if USENEWBATTLEMECHANICS
  2510. -        move=getConst(PBMoves,:EARTHPOWER) || move
  2511. -      else
  2512. -        move=getConst(PBMoves,:ROCKSLIDE) || move
  2513. -      end
  2514. +      move=((USENEWBATTLEMECHANICS) ? getConst(PBMoves,:EARTHPOWER) : getConst(PBMoves,:ROCKSLIDE)) || move
  2515.      when PBEnvironment::Sand
  2516. -      if USENEWBATTLEMECHANICS
  2517. -        move=getConst(PBMoves,:EARTHPOWER) || move
  2518. -      else
  2519. -        move=getConst(PBMoves,:EARTHQUAKE) || move
  2520. -      end
  2521. +      move=((USENEWBATTLEMECHANICS) ? getConst(PBMoves,:EARTHPOWER) : getConst(PBMoves,:EARTHQUAKE)) || move
  2522. +    # Ice tiles in Gen 6 should be Ice Beam
  2523.      when PBEnvironment::Snow
  2524. -      if USENEWBATTLEMECHANICS
  2525. -        move=getConst(PBMoves,:FROSTBREATH) || move # Ice tiles in Gen 6 should be Ice Beam
  2526. -      else
  2527. -        move=getConst(PBMoves,:ICEBEAM) || move
  2528. -      end
  2529. -    when PBEnvironment::Volcano
  2530. -      move=getConst(PBMoves,:LAVAPLUME) || move
  2531. -    when PBEnvironment::Graveyard
  2532. -      move=getConst(PBMoves,:SHADOWBALL) || move
  2533. -    when PBEnvironment::Sky
  2534. -      move=getConst(PBMoves,:AIRSLASH) || move
  2535. -    when PBEnvironment::Space
  2536. -      move=getConst(PBMoves,:DRACOMETEOR) || move
  2537. +      move=((USENEWBATTLEMECHANICS) ? getConst(PBMoves,:FROSTBREATH) : getConst(PBMoves,:ICEBEAM)) || move
  2538. +    when PBEnvironment::Volcano;     move=getConst(PBMoves,:LAVAPLUME) || move
  2539. +    when PBEnvironment::Graveyard;   move=getConst(PBMoves,:SHADOWBALL) || move
  2540. +    when PBEnvironment::Sky;         move=getConst(PBMoves,:AIRSLASH) || move
  2541. +    when PBEnvironment::Space;       move=getConst(PBMoves,:DRACOMETEOR) || move
  2542.      end
  2543.      if @battle.field.effects[PBEffects::ElectricTerrain]>0
  2544.        move=getConst(PBMoves,:THUNDERBOLT) || move
  2545. @@ -4738,7 +4687,7 @@ class PokeBattle_Move_0B3 < PokeBattle_Move
  2546.      thismovename=PBMoves.getName(@id)
  2547.      movename=PBMoves.getName(move)
  2548.      @battle.pbDisplay(_INTL("{1} turned into {2}!",thismovename,movename))
  2549. -    target=(USENEWBATTLEMECHANICS) ? opponent.index : -1
  2550. +    target=(USENEWBATTLEMECHANICS && opponent) ? opponent.index : -1
  2551.      attacker.pbUseMoveSimple(move,-1,target)
  2552.      return 0
  2553.    end
  2554. @@ -4804,7 +4753,7 @@ class PokeBattle_Move_0B4 < PokeBattle_Move
  2555.      end
  2556.      pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
  2557.      choice=choices[@battle.pbRandom(choices.length)]
  2558. -    attacker.pbUseMoveSimple(attacker.moves[choice].id,choice,attacker.pbOppositeOpposing)
  2559. +    attacker.pbUseMoveSimple(attacker.moves[choice].id,choice,attacker.pbOppositeOpposing.index)
  2560.      return 0
  2561.    end
  2562.  end
  2563. @@ -5182,7 +5131,7 @@ end
  2564.  
  2565.  
  2566.  ################################################################################
  2567. -# Hits twice. May poison the targer on each hit. (Twineedle)
  2568. +# Hits twice. May poison the target on each hit. (Twineedle)
  2569.  ################################################################################
  2570.  class PokeBattle_Move_0BE < PokeBattle_Move
  2571.    def pbIsMultiHit
  2572. @@ -5194,9 +5143,10 @@ class PokeBattle_Move_0BE < PokeBattle_Move
  2573.    end
  2574.  
  2575.    def pbAdditionalEffect(attacker,opponent)
  2576. -    return false if !opponent.pbCanPoison?(attacker,false,self)
  2577. -    opponent.pbPoison(attacker)
  2578. -    return true
  2579. +    return if opponent.damagestate.substitute
  2580. +    if opponent.pbCanPoison?(attacker,false,self)
  2581. +      opponent.pbPoison(attacker)
  2582. +    end
  2583.    end
  2584.  end
  2585.  
  2586. @@ -5416,9 +5366,10 @@ class PokeBattle_Move_0C5 < PokeBattle_Move
  2587.    end
  2588.    
  2589.    def pbAdditionalEffect(attacker,opponent)
  2590. -    return false if !opponent.pbCanParalyze?(attacker,false,self)
  2591. -    opponent.pbParalyze(attacker)
  2592. -    return true
  2593. +    return if opponent.damagestate.substitute
  2594. +    if opponent.pbCanParalyze?(attacker,false,self)
  2595. +      opponent.pbParalyze(attacker)
  2596. +    end
  2597.    end
  2598.  end
  2599.  
  2600. @@ -5453,9 +5404,10 @@ class PokeBattle_Move_0C6 < PokeBattle_Move
  2601.    end
  2602.    
  2603.    def pbAdditionalEffect(attacker,opponent)
  2604. -    return false if !opponent.pbCanBurn?(attacker,false,self)
  2605. -    opponent.pbBurn(attacker)
  2606. -    return true
  2607. +    return if opponent.damagestate.substitute
  2608. +    if opponent.pbCanBurn?(attacker,false,self)
  2609. +      opponent.pbBurn(attacker)
  2610. +    end
  2611.    end
  2612.  end
  2613.  
  2614. @@ -5490,10 +5442,8 @@ class PokeBattle_Move_0C7 < PokeBattle_Move
  2615.    end
  2616.  
  2617.    def pbAdditionalEffect(attacker,opponent)
  2618. -    if opponent.effects[PBEffects::Substitute]==0 || ignoresSubstitute?(attacker)
  2619. -      return opponent.pbFlinch(attacker)
  2620. -    end
  2621. -    return false
  2622. +    return if opponent.damagestate.substitute
  2623. +    opponent.pbFlinch(attacker)
  2624.    end
  2625.  end
  2626.  
  2627. @@ -5664,9 +5614,10 @@ class PokeBattle_Move_0CC < PokeBattle_Move
  2628.    end
  2629.  
  2630.    def pbAdditionalEffect(attacker,opponent)
  2631. -    return false if !opponent.pbCanParalyze?(attacker,false,self)
  2632. -    opponent.pbParalyze(attacker)
  2633. -    return true
  2634. +    return if opponent.damagestate.substitute
  2635. +    if opponent.pbCanParalyze?(attacker,false,self)
  2636. +      opponent.pbParalyze(attacker)
  2637. +    end
  2638.    end
  2639.  end
  2640.  
  2641. @@ -5725,7 +5676,7 @@ class PokeBattle_Move_0CE < PokeBattle_Move
  2642.      ret=false
  2643.      ret=true if opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker)
  2644.      ret=true if opponent.effects[PBEffects::TwoTurnAttack]>0
  2645. -    ret=true if opponent.effects[PBEffects::SkyDrop]
  2646. +    ret=true if opponent.effects[PBEffects::SkyDrop] && attacker.effects[PBEffects::TwoTurnAttack]>0
  2647.      ret=true if !opponent.pbIsOpposing?(attacker.index)
  2648.      ret=true if USENEWBATTLEMECHANICS && opponent.weight(attacker)>=2000
  2649.      return ret
  2650. @@ -5742,9 +5693,10 @@ class PokeBattle_Move_0CE < PokeBattle_Move
  2651.        opponent.effects[PBEffects::SkyDrop]=true
  2652.      end
  2653.      return 0 if attacker.effects[PBEffects::TwoTurnAttack]>0
  2654. +    ret=super
  2655.      @battle.pbDisplay(_INTL("{1} was freed from the Sky Drop!",opponent.pbThis))
  2656.      opponent.effects[PBEffects::SkyDrop]=false
  2657. -    return super
  2658. +    return ret
  2659.    end
  2660.  
  2661.    def pbTypeModifier(type,attacker,opponent)
  2662. @@ -6259,21 +6211,23 @@ end
  2663.  ################################################################################
  2664.  class PokeBattle_Move_0E0 < PokeBattle_Move
  2665.    def pbOnStartUse(attacker)
  2666. -    bearer=@battle.pbCheckGlobalAbility(:DAMP)
  2667. -    bearer=nil if attacker.hasMoldBreaker
  2668. -    if bearer
  2669. -      @battle.pbDisplay(_INTL("{1}'s {2} prevents {3} from using {4}!",
  2670. -         bearer.pbThis,PBAbilities.getName(bearer.ability),attacker.pbThis(true),@name))
  2671. -      return false
  2672. +    if !attacker.hasMoldBreaker
  2673. +      bearer=@battle.pbCheckGlobalAbility(:DAMP)
  2674. +      if bearer!=nil
  2675. +        @battle.pbDisplay(_INTL("{1}'s {2} prevents {3} from using {4}!",
  2676. +           bearer.pbThis,PBAbilities.getName(bearer.ability),attacker.pbThis(true),@name))
  2677. +        return false
  2678. +      end
  2679.      end
  2680. -    @battle.pbAnimation(@id,attacker,nil)
  2681. -    pbShowAnimation(@id,attacker,nil)
  2682. -    attacker.pbReduceHP(attacker.hp)
  2683.      return true
  2684.    end
  2685.  
  2686.    def pbShowAnimation(id,attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
  2687. -    return
  2688. +    super(id,attacker,opponent,hitnum,alltargets,showanimation)
  2689. +    if !attacker.isFainted?
  2690. +      attacker.pbReduceHP(attacker.hp)
  2691. +      attacker.pbFaint if attacker.isFainted?
  2692. +    end
  2693.    end
  2694.  end
  2695.  
  2696. @@ -6296,8 +6250,10 @@ class PokeBattle_Move_0E1 < PokeBattle_Move
  2697.  
  2698.    def pbShowAnimation(id,attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
  2699.      super(id,attacker,opponent,hitnum,alltargets,showanimation)
  2700. -    attacker.pbReduceHP(attacker.hp)
  2701. -    attacker.pbFaint if attacker.isFainted?
  2702. +    if !attacker.isFainted?
  2703. +      attacker.pbReduceHP(attacker.hp)
  2704. +      attacker.pbFaint if attacker.isFainted?
  2705. +    end
  2706.    end
  2707.  end
  2708.  
  2709. @@ -6392,7 +6348,7 @@ class PokeBattle_Move_0E5 < PokeBattle_Move
  2710.        return -1
  2711.      end
  2712.      pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
  2713. -    @battle.pbDisplay(_INTL("All Pok├⌐mon hearing the song will faint in three turns!"))
  2714. +    @battle.pbDisplay(_INTL("All Pok├⌐mon that hear the song will faint in three turns!"))
  2715.      for i in 0...4
  2716.        if @battle.battlers[i].effects[PBEffects::PerishSong]==0
  2717.          if !attacker.hasMoldBreaker && @battle.battlers[i].hasWorkingAbility(:SOUNDPROOF)
  2718. @@ -6633,7 +6589,7 @@ class PokeBattle_Move_0EF < PokeBattle_Move
  2719.        if opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute &&
  2720.           !opponent.isFainted?
  2721.          if opponent.effects[PBEffects::MeanLook]<0 &&
  2722. -           (!USENEWBATTLEMECHANICS || !opponent.pbHasType(:GHOST))
  2723. +           (!USENEWBATTLEMECHANICS || !opponent.pbHasType?(:GHOST))
  2724.            opponent.effects[PBEffects::MeanLook]=attacker.index
  2725.            @battle.pbDisplay(_INTL("{1} can no longer escape!",opponent.pbThis))
  2726.          end
  2727. @@ -6643,11 +6599,11 @@ class PokeBattle_Move_0EF < PokeBattle_Move
  2728.      if opponent.effects[PBEffects::MeanLook]>=0 ||
  2729.         (opponent.effects[PBEffects::Substitute]>0 && !ignoresSubstitute?(attacker))
  2730.        @battle.pbDisplay(_INTL("But it failed!"))
  2731. -      return ret
  2732. +      return -1
  2733.      end
  2734. -    if USENEWBATTLEMECHANICS && opponent.pbHasType(:GHOST)
  2735. +    if USENEWBATTLEMECHANICS && opponent.pbHasType?(:GHOST)
  2736.        @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
  2737. -      return ret
  2738. +      return -1
  2739.      end
  2740.      pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
  2741.      opponent.effects[PBEffects::MeanLook]=attacker.index
  2742. @@ -6848,7 +6804,6 @@ class PokeBattle_Move_0F4 < PokeBattle_Move
  2743.          end
  2744.        end
  2745.      end
  2746. -    return ret
  2747.    end
  2748.  end
  2749.  
  2750. @@ -7062,7 +7017,7 @@ class PokeBattle_Move_0F7 < PokeBattle_Move
  2751.          end
  2752.        elsif attacker.hasWorkingItem(:TOXICORB)
  2753.          if opponent.pbCanPoison?(attacker,false,self)
  2754. -          opponent.pbPoison(attacker,true)
  2755. +          opponent.pbPoison(attacker,nil,true)
  2756.          end
  2757.        elsif attacker.hasWorkingItem(:WHITEHERB)
  2758.          while true
  2759. @@ -7135,7 +7090,7 @@ class PokeBattle_Move_0FA < PokeBattle_Move
  2760.    end
  2761.  
  2762.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2763. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2764. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2765.        if !attacker.hasWorkingAbility(:ROCKHEAD) &&
  2766.           !attacker.hasWorkingAbility(:MAGICGUARD)
  2767.          attacker.pbReduceHP((turneffects[PBEffects::TotalDamage]/4.0).round)
  2768. @@ -7156,7 +7111,7 @@ class PokeBattle_Move_0FB < PokeBattle_Move
  2769.    end
  2770.  
  2771.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2772. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2773. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2774.        if !attacker.hasWorkingAbility(:ROCKHEAD) &&
  2775.           !attacker.hasWorkingAbility(:MAGICGUARD)
  2776.          attacker.pbReduceHP((turneffects[PBEffects::TotalDamage]/3.0).round)
  2777. @@ -7178,7 +7133,7 @@ class PokeBattle_Move_0FC < PokeBattle_Move
  2778.    end
  2779.  
  2780.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2781. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2782. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2783.        if !attacker.hasWorkingAbility(:ROCKHEAD) &&
  2784.           !attacker.hasWorkingAbility(:MAGICGUARD)
  2785.          attacker.pbReduceHP((turneffects[PBEffects::TotalDamage]/2.0).round)
  2786. @@ -7200,7 +7155,7 @@ class PokeBattle_Move_0FD < PokeBattle_Move
  2787.    end
  2788.  
  2789.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2790. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2791. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2792.        if !attacker.hasWorkingAbility(:ROCKHEAD) &&
  2793.           !attacker.hasWorkingAbility(:MAGICGUARD)
  2794.          attacker.pbReduceHP((turneffects[PBEffects::TotalDamage]/3.0).round)
  2795. @@ -7210,9 +7165,10 @@ class PokeBattle_Move_0FD < PokeBattle_Move
  2796.    end
  2797.  
  2798.    def pbAdditionalEffect(attacker,opponent)
  2799. -    return false if !opponent.pbCanParalyze?(attacker,false,self)
  2800. -    opponent.pbParalyze(attacker)
  2801. -    return true
  2802. +    return if opponent.damagestate.substitute
  2803. +    if opponent.pbCanParalyze?(attacker,false,self)
  2804. +      opponent.pbParalyze(attacker)
  2805. +    end
  2806.    end
  2807.  end
  2808.  
  2809. @@ -7228,7 +7184,7 @@ class PokeBattle_Move_0FE < PokeBattle_Move
  2810.    end
  2811.  
  2812.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2813. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2814. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2815.        if !attacker.hasWorkingAbility(:ROCKHEAD) &&
  2816.           !attacker.hasWorkingAbility(:MAGICGUARD)
  2817.          attacker.pbReduceHP((turneffects[PBEffects::TotalDamage]/3.0).round)
  2818. @@ -7238,9 +7194,10 @@ class PokeBattle_Move_0FE < PokeBattle_Move
  2819.    end
  2820.  
  2821.    def pbAdditionalEffect(attacker,opponent)
  2822. -    return false if !opponent.pbCanBurn?(attacker,false,self)
  2823. -    opponent.pbBurn(attacker)
  2824. -    return true
  2825. +    return if opponent.damagestate.substitute
  2826. +    if opponent.pbCanBurn?(attacker,false,self)
  2827. +      opponent.pbBurn(attacker)
  2828. +    end
  2829.    end
  2830.  end
  2831.  
  2832. @@ -7935,7 +7892,7 @@ end
  2833.  ################################################################################
  2834.  class PokeBattle_Move_110 < PokeBattle_Move
  2835.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2836. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2837. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2838.        if attacker.effects[PBEffects::MultiTurn]>0
  2839.          mtattack=PBMoves.getName(attacker.effects[PBEffects::MultiTurnAttack])
  2840.          mtuser=@battle.battlers[attacker.effects[PBEffects::MultiTurnUser]]
  2841. @@ -8057,7 +8014,7 @@ class PokeBattle_Move_113 < PokeBattle_Move
  2842.    end
  2843.  
  2844.    def pbEffectAfterHit(attacker,opponent,turneffects)
  2845. -    if !attacker.isFainted? && opponent.damagestate.calcdamage>0
  2846. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  2847.        showanim=true
  2848.        if attacker.effects[PBEffects::StockpileDef]>0
  2849.          if attacker.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
  2850. @@ -8545,11 +8502,10 @@ end
  2851.  ################################################################################
  2852.  class PokeBattle_Move_135 < PokeBattle_Move
  2853.    def pbAdditionalEffect(attacker,opponent)
  2854. +    return if opponent.damagestate.substitute
  2855.      if opponent.pbCanFreeze?(attacker,false,self)
  2856.        opponent.pbFreeze
  2857. -      return true
  2858.      end
  2859. -    return false
  2860.    end
  2861.  end
  2862.  
  2863. @@ -8694,10 +8650,10 @@ class PokeBattle_Move_13B < PokeBattle_Move
  2864.    end
  2865.  
  2866.    def pbAdditionalEffect(attacker,opponent)
  2867. +    return if opponent.damagestate.substitute
  2868.      if opponent.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
  2869.        opponent.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self)
  2870.      end
  2871. -    return true
  2872.    end
  2873.  end
  2874.  
  2875. @@ -8735,10 +8691,10 @@ class PokeBattle_Move_13D < PokeBattle_Move
  2876.    end
  2877.  
  2878.    def pbAdditionalEffect(attacker,opponent)
  2879. +    return if opponent.damagestate.substitute
  2880.      if opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,false,self)
  2881.        opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self)
  2882.      end
  2883. -    return true
  2884.    end
  2885.  end
  2886.  
  2887. @@ -8933,14 +8889,8 @@ class PokeBattle_Move_144 < PokeBattle_Move
  2888.    def pbModifyDamage(damagemult,attacker,opponent)
  2889.      type=getConst(PBTypes,:FLYING) || -1
  2890.      if type>=0
  2891. -      mult=PBTypes.getCombinedEffectiveness(type,opponent.type1,opponent.type2)
  2892. -      if opponent.effects[PBEffects::Type3]>=0 &&
  2893. -         opponent.effects[PBEffects::Type3]!=opponent.type1 &&
  2894. -         opponent.effects[PBEffects::Type3]!=opponent.type2
  2895. -        mult*=PBTypes.getEffectiveness(type,opponent.effects[PBEffects::Type3])
  2896. -      else
  2897. -        mult*=2
  2898. -      end
  2899. +      mult=PBTypes.getCombinedEffectiveness(type,
  2900. +         opponent.type1,opponent.type2,opponent.effects[PBEffects::Type3])
  2901.        return ((damagemult*mult)/8).round
  2902.      end
  2903.      return damagemult
  2904. @@ -9166,8 +9116,7 @@ class PokeBattle_Move_14C < PokeBattle_Move
  2905.        end
  2906.      end
  2907.      if !unmoved ||
  2908. -       (!USENEWBATTLEMECHANICS &&
  2909. -       @battle.pbRandom(65536)>=(65536/attacker.effects[PBEffects::ProtectRate]).floor)
  2910. +       @battle.pbRandom(65536)>=(65536/attacker.effects[PBEffects::ProtectRate]).floor
  2911.        attacker.effects[PBEffects::ProtectRate]=1
  2912.        @battle.pbDisplay(_INTL("But it failed!"))
  2913.        return -1
  2914. diff --git a/Data/Scripts.rxdata/[084] PokeBattle_Battle.rb b/Data/Scripts.rxdata/[084] PokeBattle_Battle.rb
  2915. index 4539926..0323013 100644
  2916. --- a/Data/Scripts.rxdata/[084] PokeBattle_Battle.rb   
  2917. +++ b/Data/Scripts.rxdata/[084] PokeBattle_Battle.rb   
  2918. @@ -5,84 +5,6 @@
  2919.  #    3 - Player or wild Pok├⌐mon ran from battle, or player forfeited the match
  2920.  #    4 - Wild Pok├⌐mon was caught
  2921.  #    5 - Draw
  2922. -################################################################################
  2923. -# Placeholder battle peer.
  2924. -################################################################################
  2925. -class PokeBattle_NullBattlePeer
  2926. -  def pbStorePokemon(player,pokemon)
  2927. -    if player.party.length<6
  2928. -      player.party[player.party.length]=pokemon
  2929. -    end
  2930. -    return -1
  2931. -  end
  2932. -
  2933. -  def pbOnEnteringBattle(battle,pokemon)
  2934. -  end
  2935. -
  2936. -  def pbGetStorageCreator()
  2937. -    return nil
  2938. -  end
  2939. -
  2940. -  def pbCurrentBox()
  2941. -    return -1
  2942. -  end
  2943. -
  2944. -  def pbBoxName(box)
  2945. -    return ""
  2946. -  end
  2947. -end
  2948. -
  2949. -
  2950. -
  2951. -class PokeBattle_BattlePeer
  2952. -  def self.create
  2953. -    return PokeBattle_NullBattlePeer.new()
  2954. -  end
  2955. -end
  2956. -
  2957. -
  2958. -
  2959. -################################################################################
  2960. -# Success state (used for Battle Arena).
  2961. -################################################################################
  2962. -class PokeBattle_SuccessState
  2963. -  attr_accessor :typemod
  2964. -  attr_accessor :useState    # 0 - not used, 1 - failed, 2 - succeeded
  2965. -  attr_accessor :protected
  2966. -  attr_accessor :skill
  2967. -
  2968. -  def initialize
  2969. -    clear
  2970. -  end
  2971. -
  2972. -  def clear
  2973. -    @typemod   = 4
  2974. -    @useState  = 0
  2975. -    @protected = false
  2976. -    @skill     = 0
  2977. -  end
  2978. -
  2979. -  def updateSkill
  2980. -    if @useState==1 && !@protected
  2981. -      @skill-=2
  2982. -    elsif @useState==2
  2983. -      if @typemod>4
  2984. -        @skill+=2 # "Super effective"
  2985. -      elsif @typemod>=1 && @typemod<4
  2986. -        @skill-=1 # "Not very effective"
  2987. -      elsif @typemod==0
  2988. -        @skill-=2 # Ineffective
  2989. -      else
  2990. -        @skill+=1
  2991. -      end
  2992. -    end
  2993. -    @typemod=4
  2994. -    @useState=0
  2995. -    @protected=false
  2996. -  end
  2997. -end
  2998. -
  2999. -
  3000.  
  3001.  ################################################################################
  3002.  # Catching and storing Pok├⌐mon.
  3003. @@ -298,6 +220,7 @@ class PokeBattle_Battle
  3004.    include PokeBattle_BattleCommon
  3005.    
  3006.    MAXPARTYSIZE = 6
  3007. +  MEGARINGS=[:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM]
  3008.  
  3009.    class BattleAbortedException < Exception; end
  3010.  
  3011. @@ -649,8 +572,7 @@ class PokeBattle_Battle
  3012.  
  3013.    def pbGetMegaRingName(battlerIndex)
  3014.      if pbBelongsToPlayer?(battlerIndex)
  3015. -      rings=[:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM]
  3016. -      for i in rings
  3017. +      for i in MEGARINGS
  3018.          next if !hasConst?(PBItems,i)
  3019.          return PBItems.getName(getConst(PBItems,i)) if $PokemonBag.pbQuantity(i)>0
  3020.        end
  3021. @@ -664,8 +586,7 @@ class PokeBattle_Battle
  3022.  
  3023.    def pbHasMegaRing(battlerIndex)
  3024.      return true if !pbBelongsToPlayer?(battlerIndex)
  3025. -    rings=[:MEGARING,:MEGABRACELET,:MEGACUFF,:MEGACHARM]
  3026. -    for i in rings
  3027. +    for i in MEGARINGS
  3028.        next if !hasConst?(PBItems,i)
  3029.        return true if $PokemonBag.pbQuantity(i)>0
  3030.      end
  3031. @@ -1054,10 +975,10 @@ class PokeBattle_Battle
  3032.          thismove=thispkmn.moves[thispkmn.effects[PBEffects::EncoreIndex]]
  3033.          target=thispkmn.pbTarget(thismove)
  3034.          if target==PBTargets::SingleNonUser
  3035. -          target=@scene.pbChooseTarget(idxPokemon)
  3036. +          target=@scene.pbChooseTarget(idxPokemon,target)
  3037.            pbRegisterTarget(idxPokemon,target) if target>=0
  3038.          elsif target==PBTargets::UserOrPartner
  3039. -          target=@scene.pbChooseTarget(idxPokemon)
  3040. +          target=@scene.pbChooseTarget(idxPokemon,target)
  3041.            pbRegisterTarget(idxPokemon,target) if target>=0 && (target&1)==(idxPokemon&1)
  3042.          end
  3043.        end
  3044. @@ -1573,18 +1494,30 @@ class PokeBattle_Battle
  3045.    end
  3046.  
  3047.    def pbRegisterItem(idxPokemon,idxItem,idxTarget=nil)
  3048. -    if idxTarget!=nil && idxTarget>=0 && @battlers[idxTarget].effects[PBEffects::Embargo]>0
  3049. -      pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",@battlers[idxTarget].pbThis(true)))
  3050. -      return false
  3051. +    if idxTarget!=nil && idxTarget>=0
  3052. +      for i in 0...4
  3053. +        if !@battlers[i].pbIsOpposing?(idxPokemon) &&
  3054. +           @battlers[i].pokemonIndex==idxTarget &&
  3055. +           @battlers[i].effects[PBEffects::Embargo]>0
  3056. +          pbDisplay(_INTL("Embargo's effect prevents the item's use on {1}!",@battlers[i].pbThis(true)))
  3057. +          if pbBelongsToPlayer?(@battlers[i].index)
  3058. +            if $PokemonBag.pbCanStore?(idxItem)
  3059. +              $PokemonBag.pbStoreItem(idxItem)
  3060. +            else
  3061. +              raise _INTL("Couldn't return unused item to Bag somehow.")
  3062. +            end
  3063. +          end
  3064. +          return false
  3065. +        end
  3066. +      end
  3067.      end
  3068.      if ItemHandlers.hasUseInBattle(idxItem)
  3069.        if idxPokemon==0 # Player's first Pok├⌐mon
  3070.          if ItemHandlers.triggerBattleUseOnBattler(idxItem,@battlers[idxPokemon],self)
  3071. +          # Using Pok├⌐ Balls or Pok├⌐ Doll only
  3072.            ItemHandlers.triggerUseInBattle(idxItem,@battlers[idxPokemon],self)
  3073.            if @doublebattle
  3074. -            @choices[idxPokemon+2][0]=3         # "Use an item"
  3075. -            @choices[idxPokemon+2][1]=idxItem   # ID of item to be used
  3076. -            @choices[idxPokemon+2][2]=idxTarget # Index of Pok├⌐mon to use item on
  3077. +            @battlers[idxPokemon+2].effects[PBEffects::SkipTurn]=true
  3078.            end
  3079.          else
  3080.            if $PokemonBag.pbCanStore?(idxItem)
  3081. @@ -1956,6 +1889,54 @@ class PokeBattle_Battle
  3082.      level=defeated.level
  3083.      baseexp=defeated.pokemon.baseExp
  3084.      evyield=defeated.pokemon.evYield
  3085. +    # Gain effort value points, using RS effort values
  3086. +    totalev=0
  3087. +    for k in 0...6
  3088. +      totalev+=thispoke.ev[k]
  3089. +    end
  3090. +    for k in 0...6
  3091. +      evgain=evyield[k]
  3092. +      evgain*=2 if isConst?(thispoke.item,PBItems,:MACHOBRACE) ||
  3093. +                   isConst?(thispoke.itemInitial,PBItems,:MACHOBRACE)
  3094. +      case k
  3095. +      when PBStats::HP
  3096. +        evgain+=4 if isConst?(thispoke.item,PBItems,:POWERWEIGHT) ||
  3097. +                     isConst?(thispoke.itemInitial,PBItems,:POWERWEIGHT)
  3098. +      when PBStats::ATTACK
  3099. +        evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBRACER) ||
  3100. +                     isConst?(thispoke.itemInitial,PBItems,:POWERBRACER)
  3101. +      when PBStats::DEFENSE
  3102. +        evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBELT) ||
  3103. +                     isConst?(thispoke.itemInitial,PBItems,:POWERBELT)
  3104. +      when PBStats::SPATK
  3105. +        evgain+=4 if isConst?(thispoke.item,PBItems,:POWERLENS) ||
  3106. +                     isConst?(thispoke.itemInitial,PBItems,:POWERLENS)
  3107. +      when PBStats::SPDEF
  3108. +        evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBAND) ||
  3109. +                     isConst?(thispoke.itemInitial,PBItems,:POWERBAND)
  3110. +      when PBStats::SPEED
  3111. +        evgain+=4 if isConst?(thispoke.item,PBItems,:POWERANKLET) ||
  3112. +                     isConst?(thispoke.itemInitial,PBItems,:POWERANKLET)
  3113. +      end
  3114. +      evgain*=2 if thispoke.pokerusStage>=1 # Infected or cured
  3115. +      if evgain>0
  3116. +        # Can't exceed overall limit
  3117. +        evgain-=totalev+evgain-PokeBattle_Pokemon::EVLIMIT if totalev+evgain>PokeBattle_Pokemon::EVLIMIT
  3118. +        # Can't exceed stat limit
  3119. +        evgain-=thispoke.ev[k]+evgain-PokeBattle_Pokemon::EVSTATLIMIT if thispoke.ev[k]+evgain>PokeBattle_Pokemon::EVSTATLIMIT
  3120. +        # Add EV gain
  3121. +        thispoke.ev[k]+=evgain
  3122. +        if thispoke.ev[k]>PokeBattle_Pokemon::EVSTATLIMIT
  3123. +          print "Single-stat EV limit #{PokeBattle_Pokemon::EVSTATLIMIT} exceeded.\r\nStat: #{k}  EV gain: #{evgain}  EVs: #{thispoke.ev.inspect}"
  3124. +          thispoke.ev[k]=PokeBattle_Pokemon::EVSTATLIMIT
  3125. +        end
  3126. +        totalev+=evgain
  3127. +        if totalev>PokeBattle_Pokemon::EVLIMIT
  3128. +          print "EV limit #{PokeBattle_Pokemon::EVLIMIT} exceeded.\r\nTotal EVs: #{totalev} EV gain: #{evgain}  EVs: #{thispoke.ev.inspect}"
  3129. +        end
  3130. +      end
  3131. +    end
  3132. +    # Gain experience
  3133.      ispartic=0
  3134.      ispartic=1 if defeated.participants.include?(index)
  3135.      haveexpshare=(isConst?(thispoke.item,PBItems,:EXPSHARE) ||
  3136. @@ -2013,53 +1994,6 @@ class PokeBattle_Battle
  3137.            pbDisplayPaused(_INTL("{1} gained {2} Exp. Points!",thispoke.name,exp))
  3138.          end
  3139.        end
  3140. -      # Gain effort value points, using RS effort values
  3141. -      totalev=0
  3142. -      for k in 0...6
  3143. -        totalev+=thispoke.ev[k]
  3144. -      end
  3145. -      for k in 0...6
  3146. -        evgain=evyield[k]
  3147. -        evgain*=2 if isConst?(thispoke.item,PBItems,:MACHOBRACE) ||
  3148. -                     isConst?(thispoke.itemInitial,PBItems,:MACHOBRACE)
  3149. -        case k
  3150. -        when PBStats::HP
  3151. -          evgain+=4 if isConst?(thispoke.item,PBItems,:POWERWEIGHT) ||
  3152. -                       isConst?(thispoke.itemInitial,PBItems,:POWERWEIGHT)
  3153. -        when PBStats::ATTACK
  3154. -          evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBRACER) ||
  3155. -                       isConst?(thispoke.itemInitial,PBItems,:POWERBRACER)
  3156. -        when PBStats::DEFENSE
  3157. -          evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBELT) ||
  3158. -                       isConst?(thispoke.itemInitial,PBItems,:POWERBELT)
  3159. -        when PBStats::SPATK
  3160. -          evgain+=4 if isConst?(thispoke.item,PBItems,:POWERLENS) ||
  3161. -                       isConst?(thispoke.itemInitial,PBItems,:POWERLENS)
  3162. -        when PBStats::SPDEF
  3163. -          evgain+=4 if isConst?(thispoke.item,PBItems,:POWERBAND) ||
  3164. -                       isConst?(thispoke.itemInitial,PBItems,:POWERBAND)
  3165. -        when PBStats::SPEED
  3166. -          evgain+=4 if isConst?(thispoke.item,PBItems,:POWERANKLET) ||
  3167. -                       isConst?(thispoke.itemInitial,PBItems,:POWERANKLET)
  3168. -        end
  3169. -        evgain*=2 if thispoke.pokerusStage>=1 # Infected or cured
  3170. -        if evgain>0
  3171. -          # Can't exceed overall limit
  3172. -          evgain-=totalev+evgain-PokeBattle_Pokemon::EVLIMIT if totalev+evgain>PokeBattle_Pokemon::EVLIMIT
  3173. -          # Can't exceed stat limit
  3174. -          evgain-=thispoke.ev[k]+evgain-PokeBattle_Pokemon::EVSTATLIMIT if thispoke.ev[k]+evgain>PokeBattle_Pokemon::EVSTATLIMIT
  3175. -          # Add EV gain
  3176. -          thispoke.ev[k]+=evgain
  3177. -          if thispoke.ev[k]>PokeBattle_Pokemon::EVSTATLIMIT
  3178. -            print "Single-stat EV limit #{PokeBattle_Pokemon::EVSTATLIMIT} exceeded.\r\nStat: #{k}  EV gain: #{evgain}  EVs: #{thispoke.ev.inspect}"
  3179. -            thispoke.ev[k]=PokeBattle_Pokemon::EVSTATLIMIT
  3180. -          end
  3181. -          totalev+=evgain
  3182. -          if totalev>PokeBattle_Pokemon::EVLIMIT
  3183. -            print "EV limit #{PokeBattle_Pokemon::EVLIMIT} exceeded.\r\nTotal EVs: #{totalev} EV gain: #{evgain}  EVs: #{thispoke.ev.inspect}"
  3184. -          end
  3185. -        end
  3186. -      end
  3187.        newlevel=PBExperience.pbGetLevelFromExperience(newexp,growthrate)
  3188.        tempexp=0
  3189.        curlevel=thispoke.level
  3190. @@ -2245,11 +2179,11 @@ class PokeBattle_Battle
  3191.        if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.isFainted?
  3192.          if !pkmn.hasWorkingAbility(:MAGICGUARD)
  3193.            atype=getConst(PBTypes,:ROCK) || 0
  3194. -          eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2)
  3195. +          eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
  3196.            if eff>0
  3197.              PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
  3198.              @scene.pbDamageAnimation(pkmn,0)
  3199. -            pkmn.pbReduceHP(((pkmn.totalhp*eff)/32).floor)
  3200. +            pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
  3201.              pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
  3202.            end
  3203.          end
  3204. @@ -2265,9 +2199,9 @@ class PokeBattle_Battle
  3205.            elsif pkmn.pbCanPoisonSpikes?(moldbreaker)
  3206.              PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Toxic Spikes")
  3207.              if pkmn.pbOwnSide.effects[PBEffects::ToxicSpikes]==2
  3208. -              pkmn.pbPoison(nil,_INTL("{1} was badly poisoned by the poison spikes!",i.pbThis,true))
  3209. +              pkmn.pbPoison(nil,_INTL("{1} was badly poisoned by the poison spikes!",pkmn.pbThis,true))
  3210.              else
  3211. -              pkmn.pbPoison(nil,_INTL("{1} was poisoned by the poison spikes!",i.pbThis))
  3212. +              pkmn.pbPoison(nil,_INTL("{1} was poisoned by the poison spikes!",pkmn.pbThis))
  3213.              end
  3214.            end
  3215.          end
  3216. @@ -2681,6 +2615,7 @@ class PokeBattle_Battle
  3217.      @scene.pbBeginCommandPhase
  3218.      @scene.pbResetCommandIndices
  3219.      for i in 0...4   # Reset choices if commands can be shown
  3220. +      @battlers[i].effects[PBEffects::SkipTurn]=false
  3221.        if pbCanShowCommands?(i) || @battlers[i].isFainted?
  3222.          @choices[i][0]=0
  3223.          @choices[i][1]=0
  3224. @@ -2693,7 +2628,7 @@ class PokeBattle_Battle
  3225.        end
  3226.      end
  3227.      # Reset choices to perform Mega Evolution if it wasn't done somehow
  3228. -    for i in 0..1
  3229. +    for i in 0...2
  3230.        for j in 0...@megaEvolution[i].length
  3231.          @megaEvolution[i][j]=-1 if @megaEvolution[i][j]>=0
  3232.        end
  3233. @@ -2729,11 +2664,11 @@ class PokeBattle_Battle
  3234.                      thismove=@battlers[i].moves[index]
  3235.                      target=@battlers[i].pbTarget(thismove)
  3236.                      if target==PBTargets::SingleNonUser # single non-user
  3237. -                      target=@scene.pbChooseTarget(i)
  3238. +                      target=@scene.pbChooseTarget(i,target)
  3239.                        next if target<0
  3240.                        pbRegisterTarget(i,target)
  3241.                      elsif target==PBTargets::UserOrPartner # Acupressure
  3242. -                      target=@scene.pbChooseTarget(i)
  3243. +                      target=@scene.pbChooseTarget(i,target)
  3244.                        next if target<0 || (target&1)==1
  3245.                        pbRegisterTarget(i,target)
  3246.                      end
  3247. @@ -2825,12 +2760,13 @@ class PokeBattle_Battle
  3248.      # Mega Evolution
  3249.      megaevolved=[]
  3250.      for i in priority
  3251. -      next if @choices[i.index][0]!=1
  3252. -      side=(pbIsOpposing?(i.index)) ? 1 : 0
  3253. -      owner=pbGetOwnerIndex(i.index)
  3254. -      if @megaEvolution[side][owner]==i.index
  3255. -        pbMegaEvolve(i.index)
  3256. -        megaevolved.push(i.index)
  3257. +      if @choices[i.index][0]==1 && !i.effects[PBEffects::SkipTurn]
  3258. +        side=(pbIsOpposing?(i.index)) ? 1 : 0
  3259. +        owner=pbGetOwnerIndex(i.index)
  3260. +        if @megaEvolution[side][owner]==i.index
  3261. +          pbMegaEvolve(i.index)
  3262. +          megaevolved.push(i.index)
  3263. +        end
  3264.        end
  3265.      end
  3266.      if megaevolved.length>0
  3267. @@ -2840,7 +2776,7 @@ class PokeBattle_Battle
  3268.      end
  3269.      # Call at Pok├⌐mon
  3270.      for i in priority
  3271. -      if @choices[i.index][0]==4
  3272. +      if @choices[i.index][0]==4 && !i.effects[PBEffects::SkipTurn]
  3273.          pbCall(i.index)
  3274.        end
  3275.      end
  3276. @@ -2848,7 +2784,7 @@ class PokeBattle_Battle
  3277.      @switching=true
  3278.      switched=[]
  3279.      for i in priority
  3280. -      if @choices[i.index][0]==2
  3281. +      if @choices[i.index][0]==2 && !i.effects[PBEffects::SkipTurn]
  3282.          index=@choices[i.index][1] # party position of Pok├⌐mon to switch to
  3283.          newpokename=index
  3284.          if isConst?(pbParty(i.index)[index].ability,PBAbilities,:ILLUSION)
  3285. @@ -2900,20 +2836,23 @@ class PokeBattle_Battle
  3286.      @switching=false
  3287.      # Use items
  3288.      for i in priority
  3289. -      if pbIsOpposing?(i.index) && @choices[i.index][0]==3
  3290. -        pbEnemyUseItem(@choices[i.index][1],i)
  3291. -      elsif @choices[i.index][0]==3
  3292. -        # Player use item
  3293. -        item=@choices[i.index][1]
  3294. -        if item>0
  3295. -          usetype=$ItemData[item][ITEMBATTLEUSE]
  3296. -          if usetype==1 || usetype==3
  3297. -            if @choices[i.index][2]>=0
  3298. -              pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
  3299. -            end
  3300. -          elsif usetype==2 || usetype==4
  3301. -            if !ItemHandlers.hasUseInBattle(item) # Pok├⌐ Ball/Pok├⌐ Doll used already
  3302. -              pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
  3303. +      if @choices[i.index][0]==3 && !i.effects[PBEffects::SkipTurn]
  3304. +        if pbIsOpposing?(i.index)
  3305. +          # Opponent use item
  3306. +          pbEnemyUseItem(@choices[i.index][1],i)
  3307. +        else
  3308. +          # Player use item
  3309. +          item=@choices[i.index][1]
  3310. +          if item>0
  3311. +            usetype=$ItemData[item][ITEMBATTLEUSE]
  3312. +            if usetype==1 || usetype==3
  3313. +              if @choices[i.index][2]>=0
  3314. +                pbUseItemOnPokemon(item,@choices[i.index][2],i,@scene)
  3315. +              end
  3316. +            elsif usetype==2 || usetype==4
  3317. +              if !ItemHandlers.hasUseInBattle(item) # Pok├⌐ Ball/Pok├⌐ Doll used already
  3318. +                pbUseItemOnBattler(item,@choices[i.index][2],i,@scene)
  3319. +              end
  3320.              end
  3321.            end
  3322.          end
  3323. @@ -2921,6 +2860,7 @@ class PokeBattle_Battle
  3324.      end
  3325.      # Use attacks
  3326.      for i in priority
  3327. +      next if i.effects[PBEffects::SkipTurn]
  3328.        if pbChoseMoveFunctionCode?(i.index,0x115) # Focus Punch
  3329.          pbCommonAnimation("FocusPunch",i,nil)
  3330.          pbDisplay(_INTL("{1} is tightening its focus!",i.pbThis))
  3331. @@ -2931,7 +2871,7 @@ class PokeBattle_Battle
  3332.        advance=false
  3333.        for i in priority
  3334.          next if !i.effects[PBEffects::MoveNext]
  3335. -        next if i.hasMovedThisRound?
  3336. +        next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  3337.          advance=i.pbProcessTurn(@choices[i.index])
  3338.          break if advance
  3339.        end
  3340. @@ -2940,7 +2880,7 @@ class PokeBattle_Battle
  3341.        # Regular priority order
  3342.        for i in priority
  3343.          next if i.effects[PBEffects::Quash]
  3344. -        next if i.hasMovedThisRound?
  3345. +        next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  3346.          advance=i.pbProcessTurn(@choices[i.index])
  3347.          break if advance
  3348.        end
  3349. @@ -2949,7 +2889,7 @@ class PokeBattle_Battle
  3350.        # Quashed
  3351.        for i in priority
  3352.          next if !i.effects[PBEffects::Quash]
  3353. -        next if i.hasMovedThisRound?
  3354. +        next if i.hasMovedThisRound? || i.effects[PBEffects::SkipTurn]
  3355.          advance=i.pbProcessTurn(@choices[i.index])
  3356.          break if advance
  3357.        end
  3358. @@ -2957,7 +2897,8 @@ class PokeBattle_Battle
  3359.        next if advance
  3360.        # Check for all done
  3361.        for i in priority
  3362. -        advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound?
  3363. +        advance=true if @choices[i.index][0]==1 && !i.hasMovedThisRound? &&
  3364. +                        !i.effects[PBEffects::SkipTurn]
  3365.          break if advance
  3366.        end
  3367.        next if advance
  3368. @@ -2972,18 +2913,19 @@ class PokeBattle_Battle
  3369.    def pbEndOfRoundPhase
  3370.      PBDebug.log("[End of round]")
  3371.      for i in 0...4
  3372. -      @battlers[i].effects[PBEffects::Roost]=false
  3373. +      @battlers[i].effects[PBEffects::Electrify]=false
  3374. +      @battlers[i].effects[PBEffects::Endure]=false
  3375. +      @battlers[i].effects[PBEffects::FirstPledge]=0
  3376. +      @battlers[i].effects[PBEffects::HyperBeam]-=1 if @battlers[i].effects[PBEffects::HyperBeam]>0
  3377. +      @battlers[i].effects[PBEffects::KingsShield]=false
  3378. +      @battlers[i].effects[PBEffects::LifeOrb]=false
  3379. +      @battlers[i].effects[PBEffects::MoveNext]=false
  3380. +      @battlers[i].effects[PBEffects::Powder]=false
  3381.        @battlers[i].effects[PBEffects::Protect]=false
  3382.        @battlers[i].effects[PBEffects::ProtectNegation]=false
  3383. -      @battlers[i].effects[PBEffects::KingsShield]=false
  3384. -      @battlers[i].effects[PBEffects::SpikyShield]=false
  3385. -      @battlers[i].effects[PBEffects::Endure]=false
  3386. -      @battlers[i].effects[PBEffects::HyperBeam]-=1 if @battlers[i].effects[PBEffects::HyperBeam]>0
  3387. -      @battlers[i].effects[PBEffects::Electrify]=false
  3388. -      @battlers[i].effects[PBEffects::MoveNext]=false
  3389.        @battlers[i].effects[PBEffects::Quash]=false
  3390. -      @battlers[i].effects[PBEffects::Powder]=false
  3391. -      @battlers[i].effects[PBEffects::FirstPledge]=0
  3392. +      @battlers[i].effects[PBEffects::Roost]=false
  3393. +      @battlers[i].effects[PBEffects::SpikyShield]=false
  3394.      end
  3395.      @usepriority=false  # recalculate priority
  3396.      priority=pbPriority(true) # Ignoring Quick Claw here
  3397. @@ -3020,7 +2962,7 @@ class PokeBattle_Battle
  3398.          PBDebug.log("[End of effect] Rain weather ended")
  3399.        else
  3400.          pbCommonAnimation("Rain",nil,nil)
  3401. -#        pbDisplay(_INTL("Rain continues to fall."));
  3402. +#        pbDisplay(_INTL("Rain continues to fall."))
  3403.        end
  3404.      when PBWeather::SANDSTORM
  3405.        @weatherduration=@weatherduration-1 if @weatherduration>0
  3406. @@ -3607,7 +3549,7 @@ class PokeBattle_Battle
  3407.        next if i.isFainted?
  3408.        if i.effects[PBEffects::PerishSong]>0
  3409.          i.effects[PBEffects::PerishSong]-=1
  3410. -        pbDisplay(_INTL("{1}'s Perish count fell to {2}!",i.pbThis,i.effects[PBEffects::PerishSong]))
  3411. +        pbDisplay(_INTL("{1}'s perish count fell to {2}!",i.pbThis,i.effects[PBEffects::PerishSong]))
  3412.          PBDebug.log("[Lingering effect triggered] #{i.pbThis}'s Perish Song count dropped to #{i.effects[PBEffects::PerishSong]}")
  3413.          if i.effects[PBEffects::PerishSong]==0
  3414.            perishSongUsers.push(i.effects[PBEffects::PerishSongUser])
  3415. diff --git a/Data/Scripts.rxdata/[085] PokeBattle_AI.rb b/Data/Scripts.rxdata/[085] PokeBattle_AI.rb
  3416. index 39b0983..9266265 100644
  3417. --- a/Data/Scripts.rxdata/[085] PokeBattle_AI.rb   
  3418. +++ b/Data/Scripts.rxdata/[085] PokeBattle_AI.rb   
  3419. @@ -2416,6 +2416,245 @@ class PokeBattle_Battle
  3420.        else
  3421.          score-=110
  3422.        end
  3423. +    when 0x133, 0x134
  3424. +      score-=95
  3425. +      if skill>=PBTrainerAI.highSkill
  3426. +        score=0
  3427. +      end
  3428. +    when 0x135
  3429. +      if opponent.pbCanFreeze?(attacker,false)
  3430. +        score+=30
  3431. +        if skill>=PBTrainerAI.highSkill
  3432. +          score-=20 if opponent.hasWorkingAbility(:MARVELSCALE)
  3433. +        end
  3434. +      end
  3435. +    when 0x136
  3436. +      score+=20 if attacker.stages[PBStats::DEFENSE]<0
  3437. +    when 0x137
  3438. +      if attacker.pbTooHigh?(PBStats::DEFENSE) &&
  3439. +         attacker.pbTooHigh?(PBStats::SPDEF) &&
  3440. +         !attacker.pbPartner.isFainted? &&
  3441. +         attacker.pbPartner.pbTooHigh?(PBStats::DEFENSE) &&
  3442. +         attacker.pbPartner.pbTooHigh?(PBStats::SPDEF)
  3443. +        score-=90
  3444. +      else
  3445. +        score-=attacker.stages[PBStats::DEFENSE]*10
  3446. +        score-=attacker.stages[PBStats::SPDEF]*10
  3447. +        if !attacker.pbPartner.isFainted?
  3448. +          score-=attacker.pbPartner.stages[PBStats::DEFENSE]*10
  3449. +          score-=attacker.pbPartner.stages[PBStats::SPDEF]*10
  3450. +        end
  3451. +      end
  3452. +    when 0x138
  3453. +      if !@doublebattle
  3454. +        score-=100
  3455. +      elsif attacker.pbPartner.isFainted?
  3456. +        score-=90
  3457. +      else
  3458. +        score-=attacker.pbPartner.stages[PBStats::SPDEF]*10
  3459. +      end
  3460. +    when 0x139
  3461. +      if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,attacker)
  3462. +        score-=90
  3463. +      else
  3464. +        score+=opponent.stages[PBStats::ATTACK]*20
  3465. +        if skill>=PBTrainerAI.mediumSkill
  3466. +          hasphysicalattack=false
  3467. +          for thismove in opponent.moves
  3468. +            if thismove.id!=0 && thismove.basedamage>0 &&
  3469. +               thismove.pbIsPhysical?(thismove.type)
  3470. +              hasphysicalattack=true
  3471. +            end
  3472. +          end
  3473. +          if hasphysicalattack
  3474. +            score+=20
  3475. +          elsif skill>=PBTrainerAI.highSkill
  3476. +            score-=90
  3477. +          end
  3478. +        end
  3479. +      end
  3480. +    when 0x13A
  3481. +      avg=opponent.stages[PBStats::ATTACK]*10
  3482. +      avg+=opponent.stages[PBStats::SPATK]*10
  3483. +      score+=avg/2
  3484. +    when 0x13B
  3485. +      if !isConst?(attacker.species,PBSpecies,:HOOPA) || attacker.form!=1
  3486. +        score-=100
  3487. +      else
  3488. +        score+=20 if opponent.stages[PBStats::DEFENSE]>0
  3489. +      end
  3490. +    when 0x13C
  3491. +      score+=20 if opponent.stages[PBStats::SPATK]>0
  3492. +    when 0x13D
  3493. +      if !opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker)
  3494. +        score-=90
  3495. +      else
  3496. +        score+=40 if attacker.turncount==0
  3497. +        score+=opponent.stages[PBStats::SPATK]*20
  3498. +      end
  3499. +    when 0x13E
  3500. +      count=0
  3501. +      for i in 0...4
  3502. +        battler=@battlers[i]
  3503. +        if battler.pbHasType?(:GRASS) && !battler.isAirborne? &&
  3504. +           (!battler.pbTooHigh?(PBStats::ATTACK) || !battler.pbTooHigh?(PBStats::SPATK))
  3505. +          count+=1
  3506. +          if attacker.pbIsOpposing?(battler)
  3507. +            score-=20
  3508. +          else
  3509. +            score-=attacker.stages[PBStats::ATTACK]*10
  3510. +            score-=attacker.stages[PBStats::SPATK]*10
  3511. +          end
  3512. +        end
  3513. +      end
  3514. +      score-=95 if count==0
  3515. +    when 0x13F
  3516. +      count=0
  3517. +      for i in 0...4
  3518. +        battler=@battlers[i]
  3519. +        if battler.pbHasType?(:GRASS) && !battler.pbTooHigh?(PBStats::DEFENSE)
  3520. +          count+=1
  3521. +          if attacker.pbIsOpposing?(battler)
  3522. +            score-=20
  3523. +          else
  3524. +            score-=attacker.stages[PBStats::DEFENSE]*10
  3525. +          end
  3526. +        end
  3527. +      end
  3528. +      score-=95 if count==0
  3529. +    when 0x140
  3530. +      count=0
  3531. +      for i in 0...4
  3532. +        battler=@battlers[i]
  3533. +        if battler.status==PBStatuses::POISON &&
  3534. +           (!battler.pbTooLow?(PBStats::ATTACK) ||
  3535. +           !battler.pbTooLow?(PBStats::SPATK) ||
  3536. +           !battler.pbTooLow?(PBStats::SPEED))
  3537. +          count+=1
  3538. +          if attacker.pbIsOpposing?(battler)
  3539. +            score+=attacker.stages[PBStats::ATTACK]*10
  3540. +            score+=attacker.stages[PBStats::SPATK]*10
  3541. +            score+=attacker.stages[PBStats::SPEED]*10
  3542. +          else
  3543. +            score-=20
  3544. +          end
  3545. +        end
  3546. +      end
  3547. +      score-=95 if count==0
  3548. +    when 0x141
  3549. +      if opponent.effects[PBEffects::Substitute]>0
  3550. +        score-=90
  3551. +      else
  3552. +        numpos=0; numneg=0
  3553. +        for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,
  3554. +                  PBStats::SPATK,PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
  3555. +          stat=opponent.stages[i]
  3556. +          (stat>0) ? numpos+=stat : numneg+=stat
  3557. +        end
  3558. +        if numpos!=0 || numneg!=0
  3559. +          score+=(numpos-numneg)*10
  3560. +        else
  3561. +          score-=95
  3562. +        end
  3563. +      end
  3564. +    when 0x142
  3565. +      if opponent.pbHasType?(:GHOST)
  3566. +        score-=90
  3567. +      end
  3568. +    when 0x143
  3569. +      if opponent.pbHasType?(:GRASS)
  3570. +        score-=90
  3571. +      end
  3572. +    when 0x144
  3573. +    when 0x145
  3574. +      aspeed=pbRoughStat(attacker,PBStats::SPEED,skill)
  3575. +      ospeed=pbRoughStat(opponent,PBStats::SPEED,skill)
  3576. +      if aspeed>ospeed
  3577. +        score-=90
  3578. +      end
  3579. +    when 0x146
  3580. +    when 0x147
  3581. +    when 0x148
  3582. +      aspeed=pbRoughStat(attacker,PBStats::SPEED,skill)
  3583. +      ospeed=pbRoughStat(opponent,PBStats::SPEED,skill)
  3584. +      if aspeed>ospeed
  3585. +        score-=90
  3586. +      else
  3587. +        score+=30 if opponent.pbHasMoveType?(:FIRE)
  3588. +      end
  3589. +    when 0x149
  3590. +      if attacker.turncount==0
  3591. +        score+=30
  3592. +      else
  3593. +        score-=90 # Because it will fail here
  3594. +        score=0 if skill>=PBTrainerAI.bestSkill
  3595. +      end
  3596. +    when 0x14A
  3597. +    when 0x14B, 0x14C
  3598. +      if attacker.effects[PBEffects::ProtectRate]>1 ||
  3599. +         opponent.effects[PBEffects::HyperBeam]>0
  3600. +        score-=90
  3601. +      else
  3602. +        if skill>=PBTrainerAI.mediumSkill
  3603. +          score-=(attacker.effects[PBEffects::ProtectRate]*40)
  3604. +        end
  3605. +        score+=50 if attacker.turncount==0
  3606. +        score+=30 if opponent.effects[PBEffects::TwoTurnAttack]!=0
  3607. +      end
  3608. +    when 0x14D
  3609. +    when 0x14E
  3610. +      if attacker.pbTooHigh?(PBStats::SPATK) &&
  3611. +         attacker.pbTooHigh?(PBStats::SPDEF) &&
  3612. +         attacker.pbTooHigh?(PBStats::SPEED)
  3613. +        score-=90
  3614. +      else
  3615. +        score-=attacker.stages[PBStats::SPATK]*10 # Only *10 isntead of *20
  3616. +        score-=attacker.stages[PBStats::SPDEF]*10 # because two-turn attack
  3617. +        score-=attacker.stages[PBStats::SPEED]*10
  3618. +        if skill>=PBTrainerAI.mediumSkill
  3619. +          hasspecialattack=false
  3620. +          for thismove in attacker.moves
  3621. +            if thismove.id!=0 && thismove.basedamage>0 &&
  3622. +               thismove.pbIsSpecial?(thismove.type)
  3623. +              hasspecialattack=true
  3624. +            end
  3625. +          end
  3626. +          if hasspecialattack
  3627. +            score+=20
  3628. +          elsif skill>=PBTrainerAI.highSkill
  3629. +            score-=90
  3630. +          end
  3631. +        end
  3632. +        if skill>=PBTrainerAI.highSkill
  3633. +          aspeed=pbRoughStat(attacker,PBStats::SPEED,skill)
  3634. +          ospeed=pbRoughStat(opponent,PBStats::SPEED,skill)
  3635. +          if aspeed<ospeed && aspeed*2>ospeed
  3636. +            score+=30
  3637. +          end
  3638. +        end
  3639. +      end
  3640. +    when 0x14F
  3641. +      if skill>=PBTrainerAI.highSkill && opponent.hasWorkingAbility(:LIQUIDOOZE)
  3642. +        score-=80
  3643. +      else
  3644. +        score+=40 if attacker.hp<=(attacker.totalhp/2)
  3645. +      end
  3646. +    when 0x150
  3647. +      score+=20 if !attacker.pbTooHigh?(:ATTACK) && opponent.hp<=(opponent.totalhp/4)
  3648. +    when 0x151
  3649. +      avg=opponent.stages[PBStats::ATTACK]*10
  3650. +      avg+=opponent.stages[PBStats::SPATK]*10
  3651. +      score+=avg/2
  3652. +    when 0x152
  3653. +    when 0x153
  3654. +      score-=95 if opponent.pbOwnSide.effects[PBEffects::StickyWeb]
  3655. +    when 0x154
  3656. +    when 0x155
  3657. +    when 0x156
  3658. +    when 0x157
  3659. +      score-=90
  3660. +    when 0x158
  3661. +      score-=90 if !attacker.pokemon || !attacker.pokemon.belch
  3662.      end
  3663.      # A score of 0 here means it should absolutely not be used
  3664.      return score if score<=0
  3665. @@ -2455,8 +2694,7 @@ class PokeBattle_Battle
  3666.                               move.function==0x95    # Magnitude
  3667.            when 0xCB # Dive
  3668.              miss=true unless move.function==0x75 || # Surf
  3669. -                             move.function==0xD0 || # Whirlpool
  3670. -                             move.function==0x12D   # Shadow Storm
  3671. +                             move.function==0xD0    # Whirlpool
  3672.            when 0xCD # Shadow Force
  3673.              miss=true
  3674.            when 0xCE # Sky Drop
  3675. @@ -2466,6 +2704,8 @@ class PokeBattle_Battle
  3676.                               move.function==0x78 ||  # Twister
  3677.                               move.function==0x11B || # Sky Uppercut
  3678.                               move.function==0x11C    # Smack Down
  3679. +          when 0x14D # Phantom Force
  3680. +            miss=true
  3681.            end
  3682.            if opponent.effects[PBEffects::SkyDrop]
  3683.              miss=true unless move.function==0x08 ||  # Thunder
  3684. @@ -2625,11 +2865,12 @@ class PokeBattle_Battle
  3685.    def pbTypeModifier(type,attacker,opponent)
  3686.      return 8 if type<0
  3687.      return 8 if isConst?(type,PBTypes,:GROUND) && opponent.pbHasType?(:FLYING) &&
  3688. -                opponent.hasWorkingItem(:IRONBALL)
  3689. +                opponent.hasWorkingItem(:IRONBALL) && !USENEWBATTLEMECHANICS
  3690.      atype=type
  3691.      otype1=opponent.type1
  3692.      otype2=opponent.type2
  3693.      otype3=opponent.effects[PBEffects::Type3] || -1
  3694. +    # Roost
  3695.      if isConst?(otype1,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
  3696.        if isConst?(otype2,PBTypes,:FLYING) && isConst?(otype3,PBTypes,:FLYING)
  3697.          otype1=getConst(PBTypes,:NORMAL) || 0
  3698. @@ -2640,59 +2881,65 @@ class PokeBattle_Battle
  3699.      if isConst?(otype2,PBTypes,:FLYING) && opponent.effects[PBEffects::Roost]
  3700.        otype2=otype1
  3701.      end
  3702. +    # Get effectivenesses
  3703.      mod1=PBTypes.getEffectiveness(atype,otype1)
  3704.      mod2=(otype1==otype2) ? 2 : PBTypes.getEffectiveness(atype,otype2)
  3705. -    mod3=(otype1==otype3 || otype2==otype3) ? 2 : PBTypes.getEffectiveness(atype,otype3)
  3706. +    mod3=(otype3<0 || otype1==otype3 || otype2==otype3) ? 2 : PBTypes.getEffectiveness(atype,otype3)
  3707.      if opponent.hasWorkingItem(:RINGTARGET)
  3708.        mod1=2 if mod1==0
  3709.        mod2=2 if mod2==0
  3710.        mod3=2 if mod3==0
  3711.      end
  3712. -    if attacker.hasWorkingAbility(:SCRAPPY) ||
  3713. -       opponent.effects[PBEffects::Foresight]
  3714. -      mod1=2 if isConst?(otype1,PBTypes,:GHOST) &&
  3715. -        (isConst?(atype,PBTypes,:NORMAL) || isConst?(atype,PBTypes,:FIGHTING))
  3716. -      mod2=2 if isConst?(otype2,PBTypes,:GHOST) &&
  3717. -        (isConst?(atype,PBTypes,:NORMAL) || isConst?(atype,PBTypes,:FIGHTING))
  3718. -      mod3=2 if isConst?(otype3,PBTypes,:GHOST) &&
  3719. -        (isConst?(atype,PBTypes,:NORMAL) || isConst?(atype,PBTypes,:FIGHTING))
  3720. +    # Foresight
  3721. +    if (attacker.hasWorkingAbility(:SCRAPPY) rescue false) || opponent.effects[PBEffects::Foresight]
  3722. +      mod1=2 if isConst?(otype1,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype1)
  3723. +      mod2=2 if isConst?(otype2,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype2)
  3724. +      mod3=2 if isConst?(otype3,PBTypes,:GHOST) && PBTypes.isIneffective?(atype,otype3)
  3725.      end
  3726. +    # Miracle Eye
  3727.      if opponent.effects[PBEffects::MiracleEye]
  3728. -      mod1=2 if isConst?(otype1,PBTypes,:DARK) && isConst?(atype,PBTypes,:PSYCHIC)
  3729. -      mod2=2 if isConst?(otype2,PBTypes,:DARK) && isConst?(atype,PBTypes,:PSYCHIC)
  3730. -      mod3=2 if isConst?(otype3,PBTypes,:DARK) && isConst?(atype,PBTypes,:PSYCHIC)
  3731. +      mod1=2 if isConst?(otype1,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype1)
  3732. +      mod2=2 if isConst?(otype2,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype2)
  3733. +      mod3=2 if isConst?(otype3,PBTypes,:DARK) && PBTypes.isIneffective?(atype,otype3)
  3734.      end
  3735. -    if !opponent.isAirborne?
  3736. -      mod1=2 if isConst?(otype1,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
  3737. -      mod2=2 if isConst?(otype2,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
  3738. -      mod3=2 if isConst?(otype3,PBTypes,:FLYING) && isConst?(atype,PBTypes,:GROUND)
  3739. +    # Delta Stream's weather
  3740. +    if pbWeather==PBWeather::STRONGWINDS
  3741. +      mod1=2 if isConst?(otype1,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype1)
  3742. +      mod2=2 if isConst?(otype2,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype2)
  3743. +      mod3=2 if isConst?(otype3,PBTypes,:FLYING) && PBTypes.isSuperEffective?(atype,otype3)
  3744. +    end
  3745. +    # Smack Down makes Ground moves work against fliers
  3746. +    if !opponent.isAirborne?((attacker.hasMoldBreaker rescue false)) && isConst?(atype,PBTypes,:GROUND)
  3747. +      mod1=2 if isConst?(otype1,PBTypes,:FLYING)
  3748. +      mod2=2 if isConst?(otype2,PBTypes,:FLYING)
  3749. +      mod3=2 if isConst?(otype3,PBTypes,:FLYING)
  3750.      end
  3751.      return mod1*mod2*mod3
  3752.    end
  3753.  
  3754.    def pbTypeModifier2(battlerThis,battlerOther)
  3755. +    # battlerThis isn't a Battler object, it's a Pok├⌐mon - it has no third type
  3756.      if battlerThis.type1==battlerThis.type2
  3757.        return 4*pbTypeModifier(battlerThis.type1,battlerThis,battlerOther)
  3758. -    else
  3759. -      ret=pbTypeModifier(battlerThis.type1,battlerThis,battlerOther)
  3760. -      ret*=pbTypeModifier(battlerThis.type2,battlerThis,battlerOther)
  3761. -      return ret # 0,1,2,4,8,_16_,32,64,128,256
  3762.      end
  3763. +    ret=pbTypeModifier(battlerThis.type1,battlerThis,battlerOther)
  3764. +    ret*=pbTypeModifier(battlerThis.type2,battlerThis,battlerOther)
  3765. +    return ret*2 # 0,1,2,4,_8_,16,32,64
  3766.    end
  3767.  
  3768.    def pbRoughStat(battler,stat,skill)
  3769. -    if skill>=PBTrainerAI.highSkill && stat==PBStats::SPEED
  3770. -      return battler.pbSpeed
  3771. -    end
  3772. +    return battler.pbSpeed if skill>=PBTrainerAI.highSkill && stat==PBStats::SPEED
  3773.      stagemul=[2,2,2,2,2,2,2,3,4,5,6,7,8]
  3774.      stagediv=[8,7,6,5,4,3,2,2,2,2,2,2,2]
  3775.      stage=battler.stages[stat]+6
  3776.      value=0
  3777. -    value=battler.attack if stat==PBStats::ATTACK
  3778. -    value=battler.defense if stat==PBStats::DEFENSE
  3779. -    value=battler.speed if stat==PBStats::SPEED
  3780. -    value=battler.spatk if stat==PBStats::SPATK
  3781. -    value=battler.spdef if stat==PBStats::SPDEF
  3782. +    case stat
  3783. +    when PBStats::ATTACK; value=battler.attack
  3784. +    when PBStats::DEFENSE; value=battler.defense
  3785. +    when PBStats::SPEED; value=battler.speed
  3786. +    when PBStats::SPATK; value=battler.spatk
  3787. +    when PBStats::SPDEF; value=battler.spdef
  3788. +    end
  3789.      return (value*1.0*stagemul[stage]/stagediv[stage]).floor
  3790.    end
  3791.  
  3792. @@ -2886,6 +3133,13 @@ class PokeBattle_Battle
  3793.        #TODO
  3794.      when 0x113 # Spit Up
  3795.        basedamage*=attacker.effects[PBEffects::Stockpile]
  3796. +    when 0x144
  3797. +      type=getConst(PBTypes,:FLYING) || -1
  3798. +      if type>=0
  3799. +        mult=PBTypes.getCombinedEffectiveness(type,
  3800. +           opponent.type1,opponent.type2,opponent.effects[PBEffects::Type3])
  3801. +        basedamage=((basedamage*mult)/8).round
  3802. +      end
  3803.      end
  3804.      return basedamage
  3805.    end
  3806. @@ -3965,7 +4219,7 @@ class PokeBattle_Battle
  3807.            end
  3808.            if movetype>=0 && pbTypeModifier(movetype,@battlers[index],@battlers[index])==0
  3809.              weight=65
  3810. -            if pbTypeModifier2(party[i],@battlers[index].pbOppositeOpposing)<16
  3811. +            if pbTypeModifier2(party[i],@battlers[index].pbOppositeOpposing)>8
  3812.                # Greater weight if new Pokemon's type is effective against opponent
  3813.                weight=85
  3814.              end
  3815. @@ -3974,7 +4228,7 @@ class PokeBattle_Battle
  3816.              end
  3817.            elsif movetype>=0 && pbTypeModifier(movetype,@battlers[index],@battlers[index])<8
  3818.              weight=40
  3819. -            if pbTypeModifier2(party[i],@battlers[index].pbOppositeOpposing)<16
  3820. +            if pbTypeModifier2(party[i],@battlers[index].pbOppositeOpposing)>8
  3821.                # Greater weight if new Pokemon's type is effective against opponent
  3822.                weight=60
  3823.              end
  3824. @@ -4030,10 +4284,10 @@ class PokeBattle_Battle
  3825.          md=PBMoveData.new(move.id)
  3826.          next if md.basedamage==0
  3827.          if o1
  3828. -          sum+=PBTypes.getCombinedEffectiveness(md.type,o1.type1,o1.type2)
  3829. +          sum+=PBTypes.getCombinedEffectiveness(md.type,o1.type1,o1.type2,o1.effects[PBEffects::Type3])
  3830.          end
  3831.          if o2
  3832. -          sum+=PBTypes.getCombinedEffectiveness(md.type,o2.type1,o2.type2)
  3833. +          sum+=PBTypes.getCombinedEffectiveness(md.type,o2.type1,o2.type2,o2.effects[PBEffects::Type3])
  3834.          end
  3835.        end
  3836.        if best==-1 || sum>bestSum
  3837. diff --git a/Data/Scripts.rxdata/[087] PokeBattle_Scene.rb b/Data/Scripts.rxdata/[087] PokeBattle_Scene.rb
  3838. index ce80b8b..58cae67 100644
  3839. --- a/Data/Scripts.rxdata/[087] PokeBattle_Scene.rb
  3840. +++ b/Data/Scripts.rxdata/[087] PokeBattle_Scene.rb
  3841. @@ -348,6 +348,7 @@ class FightMenuDisplay
  3842.        @info.text=_ISPRINTF("{1:s}PP: {2: 2d}/{3: 2d}<br>TYPE/{4:s}",
  3843.           @ctag,selmove.pp,selmove.totalpp,movetype)
  3844.      end
  3845. +    @buttons.refresh(self.index,@battler ? @battler.moves : nil,@megaButton) if @buttons
  3846.    end
  3847.  
  3848.    def update
  3849. @@ -2508,12 +2509,17 @@ class PokeBattle_Scene
  3850.      end
  3851.    end
  3852.  
  3853. -  def pbFirstTarget(index)
  3854. -    for i in 0...4
  3855. -      if i!=index && !@battle.battlers[i].isFainted? &&
  3856. -         @battle.battlers[index].pbIsOpposing?(i)
  3857. -        return i
  3858. -      end  
  3859. +  def pbFirstTarget(index,targettype)
  3860. +    case targettype
  3861. +    when PBTargets::SingleNonUser
  3862. +      for i in 0...4
  3863. +        if i!=index && !@battle.battlers[i].isFainted? &&
  3864. +           @battle.battlers[index].pbIsOpposing?(i)
  3865. +          return i
  3866. +        end  
  3867. +      end
  3868. +    when PBTargets::UserOrPartner
  3869. +      return index
  3870.      end
  3871.      return -1
  3872.    end
  3873. @@ -2535,9 +2541,19 @@ class PokeBattle_Scene
  3874.  
  3875.  # Use this method to make the player choose a target
  3876.  # for certain moves in double battles.
  3877. -  def pbChooseTarget(index)
  3878. +  def pbChooseTarget(index,targettype)
  3879.      pbShowWindow(FIGHTBOX)
  3880. -    curwindow=pbFirstTarget(index)
  3881. +    cw = @sprites["fightwindow"]
  3882. +    battler=@battle.battlers[index]
  3883. +    cw.battler=battler
  3884. +    lastIndex=@lastmove[index]
  3885. +    if battler.moves[lastIndex].id!=0
  3886. +      cw.setIndex(lastIndex)
  3887. +    else
  3888. +      cw.setIndex(0)
  3889. +    end
  3890. +    
  3891. +    curwindow=pbFirstTarget(index,targettype)
  3892.      if curwindow==-1
  3893.        raise RuntimeError.new(_INTL("No targets somehow..."))
  3894.      end
  3895. @@ -2557,22 +2573,36 @@ class PokeBattle_Scene
  3896.        if curwindow>=0
  3897.          if Input.trigger?(Input::RIGHT) || Input.trigger?(Input::DOWN)
  3898.            loop do
  3899. -            newcurwindow=3 if curwindow==0
  3900. -            newcurwindow=1 if curwindow==3
  3901. -            newcurwindow=2 if curwindow==1
  3902. -            newcurwindow=0 if curwindow==2
  3903. +            case targettype
  3904. +            when PBTargets::SingleNonUser
  3905. +              case curwindow
  3906. +              when 0; newcurwindow=2
  3907. +              when 1; newcurwindow=0
  3908. +              when 2; newcurwindow=3
  3909. +              when 3; newcurwindow=1
  3910. +              end
  3911. +            when PBTargets::UserOrPartner
  3912. +              newcurwindow=(curwindow+2)%4
  3913. +            end
  3914.              curwindow=newcurwindow
  3915. -            next if curwindow==index
  3916. +            next if targettype==PBTargets::SingleNonUser && curwindow==index
  3917.              break if !@battle.battlers[curwindow].isFainted?
  3918.            end
  3919.          elsif Input.trigger?(Input::LEFT) || Input.trigger?(Input::UP)
  3920.            loop do
  3921. -            newcurwindow=2 if curwindow==0
  3922. -            newcurwindow=1 if curwindow==2
  3923. -            newcurwindow=3 if curwindow==1
  3924. -            newcurwindow=0 if curwindow==3
  3925. +            case targettype
  3926. +            when PBTargets::SingleNonUser
  3927. +              case curwindow
  3928. +              when 0; newcurwindow=1
  3929. +              when 1; newcurwindow=3
  3930. +              when 2; newcurwindow=0
  3931. +              when 3; newcurwindow=2
  3932. +              end
  3933. +            when PBTargets::UserOrPartner
  3934. +              newcurwindow=(curwindow+2)%4
  3935. +            end
  3936.              curwindow=newcurwindow
  3937. -            next if curwindow==index
  3938. +            next if targettype==PBTargets::SingleNonUser && curwindow==index
  3939.              break if !@battle.battlers[curwindow].isFainted?
  3940.            end
  3941.          end
  3942. diff --git a/Data/Scripts.rxdata/[089] PokeBattle_SafariZone.rb b/Data/Scripts.rxdata/[089] PokeBattle_SafariZone.rb
  3943. index 106d89d..3e23687 100644
  3944. --- a/Data/Scripts.rxdata/[089] PokeBattle_SafariZone.rb   
  3945. +++ b/Data/Scripts.rxdata/[089] PokeBattle_SafariZone.rb   
  3946. @@ -5,6 +5,7 @@ class PokeBattle_FakeBattler
  3947.      @owned=$Trainer.owned[pokemon.species]
  3948.    end
  3949.  
  3950. +  def index; return @index; end
  3951.    def pokemon; @pokemon; end
  3952.    def species; @pokemon.species; end
  3953.    def gender; @pokemon.gender; end
  3954. @@ -21,10 +22,9 @@ class PokeBattle_FakeBattler
  3955.    def isMega?; return false; end
  3956.    def hasPrimal?; return false; end
  3957.    def isPrimal?; return false; end
  3958. -
  3959. -  def index
  3960. -    return @index
  3961. -  end
  3962. +  def displayGender; return @pokemon.gender; end
  3963. +  def captured; return false; end
  3964. +  def captured=(value); end
  3965.  
  3966.    def pbThis(lowercase=false)
  3967.      return lowercase ? _INTL("the wild {1}",@pokemon.name) : _INTL("The wild {1}",@pokemon.name)
  3968. @@ -230,4 +230,6 @@ class PokeBattle_SafariZone
  3969.    def pbRandom(x)
  3970.      return rand(x)
  3971.    end
  3972. +
  3973. +  def pbGainEXP; end
  3974.  end
  3975. \ No newline at end of file
  3976. diff --git a/Data/Scripts.rxdata/[093] PokeBattle_OtherScenes.rb b/Data/Scripts.rxdata/[093] PokeBattle_OtherScenes.rb
  3977. index ae6ba22..ba638d9 100644
  3978. --- a/Data/Scripts.rxdata/[093] PokeBattle_OtherScenes.rb  
  3979. +++ b/Data/Scripts.rxdata/[093] PokeBattle_OtherScenes.rb  
  3980. @@ -348,7 +348,7 @@ class PokeBattle_DebugScene
  3981.      return -1
  3982.    end
  3983.  
  3984. -  def pbFirstTarget(index)
  3985. +  def pbFirstTarget(index,targettype)
  3986.      for i in 0...4
  3987.        if i!=index && !@battle.battlers[i].isFainted?
  3988.          return i
  3989. @@ -380,8 +380,8 @@ class PokeBattle_DebugScene
  3990.  
  3991.  # Use this method to make the player choose a target
  3992.  # for certain moves in double battles.
  3993. -  def pbChooseTarget(index)
  3994. -    curwindow=pbFirstTarget(index)
  3995. +  def pbChooseTarget(index,targettype)
  3996. +    curwindow=pbFirstTarget(index,targettype)
  3997.      if curwindow==-1
  3998.        raise RuntimeError.new("No targets somehow...")
  3999.      end
  4000. @@ -586,7 +586,7 @@ class PokeBattle_SceneNonInteractive < PokeBattle_Scene
  4001.      return -1
  4002.    end
  4003.  
  4004. -  def pbChooseTarget(index)
  4005. +  def pbChooseTarget(index,targettype)
  4006.      targets=[]
  4007.      for i in 0...4
  4008.        if @battle.battlers[index].pbIsOpposing?(i) &&
  4009. @@ -698,7 +698,7 @@ class PokeBattle_DebugSceneNoLogging
  4010.      return -1
  4011.    end
  4012.  
  4013. -  def pbChooseTarget(index)
  4014. +  def pbChooseTarget(index,targettype)
  4015.      targets=[]
  4016.      for i in 0...4
  4017.        if @battle.battlers[index].pbIsOpposing?(i) &&
  4018. @@ -879,7 +879,7 @@ class PokeBattle_DebugSceneNoGraphics
  4019.      return -1
  4020.    end
  4021.  
  4022. -  def pbChooseTarget(index)
  4023. +  def pbChooseTarget(index,targettype)
  4024.      targets=[]
  4025.      for i in 0...4
  4026.        if @battle.battlers[index].pbIsOpposing?(i) &&
  4027. diff --git a/Data/Scripts.rxdata/[094] PokeBattle_BattlePeer.rb b/Data/Scripts.rxdata/[094] PokeBattle_BattlePeer.rb
  4028. index 7c98e7a..290f2b0 100644
  4029. --- a/Data/Scripts.rxdata/[094] PokeBattle_BattlePeer.rb   
  4030. +++ b/Data/Scripts.rxdata/[094] PokeBattle_BattlePeer.rb   
  4031. @@ -1,3 +1,29 @@
  4032. +class PokeBattle_NullBattlePeer
  4033. +  def pbOnEnteringBattle(battle,pokemon)
  4034. +  end
  4035. +
  4036. +  def pbStorePokemon(player,pokemon)
  4037. +    if player.party.length<6
  4038. +      player.party[player.party.length]=pokemon
  4039. +    end
  4040. +    return -1
  4041. +  end
  4042. +
  4043. +  def pbGetStorageCreator()
  4044. +    return nil
  4045. +  end
  4046. +
  4047. +  def pbCurrentBox()
  4048. +    return -1
  4049. +  end
  4050. +
  4051. +  def pbBoxName(box)
  4052. +    return ""
  4053. +  end
  4054. +end
  4055. +
  4056. +
  4057. +
  4058.  class PokeBattle_RealBattlePeer
  4059.    def pbStorePokemon(player,pokemon)
  4060.      if player.party.length<6
  4061. diff --git a/Data/Scripts.rxdata/[098] PField_Field.rb b/Data/Scripts.rxdata/[098] PField_Field.rb
  4062. index a2b1cb8..80af919 100644
  4063. --- a/Data/Scripts.rxdata/[098] PField_Field.rb
  4064. +++ b/Data/Scripts.rxdata/[098] PField_Field.rb
  4065. @@ -523,22 +523,114 @@ def pbBattleAnimation(bgm=nil,trainerid=-1,trainername="")
  4066.      $game_temp.background_bitmap.dispose
  4067.    end
  4068.    $game_temp.background_bitmap=Graphics.snap_to_bitmap
  4069. -# Animate the screen ($game_temp.background_bitmap contains
  4070. -# the current game screen).
  4071. -#
  4072. -# The following example runs a common event that does a custom animation if some
  4073. -# condition is true. The screen should fade to black when the common event is
  4074. -# finished:
  4075. -#
  4076. -# if $game_map && $game_map.map_id==20  # If on map 20
  4077. -#   pbCommonEvent(20)
  4078. -#   handled=true                        # Note that the battle animation is done
  4079. -# end
  4080. -#
  4081. -################################################################################
  4082. -# VS. animation, by Luka S.J.
  4083. -# Tweaked by Maruno.
  4084. -################################################################################
  4085. +  # Check for custom battle intro animations
  4086. +  handled=pbBattleAnimationOverride(viewport,trainerid,trainername)
  4087. +  # Default battle intro animation
  4088. +  if !handled
  4089. +    if Sprite.method_defined?(:wave_amp) && rand(15)==0
  4090. +      viewport.color=Color.new(0,0,0,255)
  4091. +      sprite = Sprite.new
  4092. +      bitmap=Graphics.snap_to_bitmap
  4093. +      bm=bitmap.clone
  4094. +      sprite.z=99999
  4095. +      sprite.bitmap = bm
  4096. +      sprite.wave_speed=500
  4097. +      for i in 0..25
  4098. +        sprite.opacity-=10
  4099. +        sprite.wave_amp+=60
  4100. +        sprite.update
  4101. +        sprite.wave_speed+=30
  4102. +        2.times do
  4103. +          Graphics.update
  4104. +        end
  4105. +      end
  4106. +      bitmap.dispose
  4107. +      bm.dispose
  4108. +      sprite.dispose
  4109. +    elsif Bitmap.method_defined?(:radial_blur) && rand(15)==0
  4110. +      viewport.color=Color.new(0,0,0,255)
  4111. +      sprite = Sprite.new
  4112. +      bitmap=Graphics.snap_to_bitmap
  4113. +      bm=bitmap.clone
  4114. +      sprite.z=99999
  4115. +      sprite.bitmap = bm
  4116. +      for i in 0..15
  4117. +        bm.radial_blur(i,2)
  4118. +        sprite.opacity-=15
  4119. +        2.times do
  4120. +          Graphics.update
  4121. +        end
  4122. +      end
  4123. +      bitmap.dispose
  4124. +      bm.dispose
  4125. +      sprite.dispose
  4126. +    elsif rand(10)==0 # Custom transition method
  4127. +      scroll=["ScrollDown","ScrollLeft","ScrollRight","ScrollUp",
  4128. +              "ScrollDownRight","ScrollDownLeft","ScrollUpRight","ScrollUpLeft"]
  4129. +      Graphics.freeze
  4130. +      viewport.color=Color.new(0,0,0,255)
  4131. +      Graphics.transition(50,sprintf("Graphics/Transitions/%s",scroll[rand(scroll.length)]))
  4132. +    else
  4133. +      transitions=[
  4134. +         # Transitions with graphic files
  4135. +         "021-Normal01","022-Normal02",
  4136. +         "Battle","battle1","battle2","battle3","battle4",
  4137. +         "computertr","computertrclose",
  4138. +         "hexatr","hexatrc","hexatzr",
  4139. +         "Image1","Image2","Image3","Image4",
  4140. +         # Custom transition methods
  4141. +         "Splash","Random_stripe_v","Random_stripe_h",
  4142. +         "RotatingPieces","ShrinkingPieces",
  4143. +         "BreakingGlass","Mosaic","zoomin"
  4144. +      ]
  4145. +      rnd=rand(transitions.length)
  4146. +      Graphics.freeze
  4147. +      viewport.color=Color.new(0,0,0,255)
  4148. +      Graphics.transition(40,sprintf("Graphics/Transitions/%s",transitions[rnd]))
  4149. +    end
  4150. +    5.times do
  4151. +      Graphics.update
  4152. +      Input.update
  4153. +      pbUpdateSceneMap
  4154. +    end
  4155. +  end
  4156. +  pbPushFade
  4157. +  yield if block_given?
  4158. +  pbPopFade
  4159. +  if $game_system && $game_system.is_a?(Game_System)
  4160. +    $game_system.bgm_resume(playingBGM)
  4161. +    $game_system.bgs_resume(playingBGS)
  4162. +  end
  4163. +  $PokemonGlobal.nextBattleBGM=nil
  4164. +  $PokemonGlobal.nextBattleME=nil
  4165. +  $PokemonGlobal.nextBattleBack=nil
  4166. +  $PokemonEncounters.clearStepCount
  4167. +  for j in 0..17
  4168. +    viewport.color=Color.new(0,0,0,(17-j)*15)
  4169. +    Graphics.update
  4170. +    Input.update
  4171. +    pbUpdateSceneMap
  4172. +  end
  4173. +  viewport.dispose
  4174. +end
  4175. +
  4176. +# Alias and use this method if you want to add a custom battle intro animation
  4177. +# e.g. variants of the Vs. animation.
  4178. +# Note that $game_temp.background_bitmap contains an image of the current game
  4179. +# screen.
  4180. +# When the custom animation has finished, the screen should have faded to black
  4181. +# somehow.
  4182. +def pbBattleAnimationOverride(viewport,trainerid=-1,trainername="")
  4183. +  # The following example runs a common event that ought to do a custom
  4184. +  # animation if some condition is true:
  4185. +  #
  4186. +  # if $game_map && $game_map.map_id==20   # If on map 20
  4187. +  #   pbCommonEvent(20)
  4188. +  #   return true                          # Note that the battle animation is done
  4189. +  # end
  4190. +  #
  4191. +  ##### VS. animation, by Luka S.J. #####
  4192. +  ##### Tweaked by Maruno           #####
  4193.    if trainerid>=0
  4194.      tbargraphic=sprintf("Graphics/Transitions/vsBar%s",getConstantName(PBTrainers,trainerid)) rescue nil
  4195.      tbargraphic=sprintf("Graphics/Transitions/vsBar%d",trainerid) if !pbResolveBitmap(tbargraphic)
  4196. @@ -687,96 +779,10 @@ def pbBattleAnimation(bgm=nil,trainerid=-1,trainername="")
  4197.        viewopp.dispose
  4198.        viewplayer.dispose
  4199.        viewport.color=Color.new(0,0,0,255)
  4200. -      handled=true
  4201. +      return true
  4202.      end
  4203.    end
  4204. -  # End of VS. sequence script
  4205. -  if !handled
  4206. -    if Sprite.method_defined?(:wave_amp) && rand(15)==0
  4207. -      viewport.color=Color.new(0,0,0,255)
  4208. -      sprite = Sprite.new
  4209. -      bitmap=Graphics.snap_to_bitmap
  4210. -      bm=bitmap.clone
  4211. -      sprite.z=99999
  4212. -      sprite.bitmap = bm
  4213. -      sprite.wave_speed=500
  4214. -      for i in 0..25
  4215. -        sprite.opacity-=10
  4216. -        sprite.wave_amp+=60
  4217. -        sprite.update
  4218. -        sprite.wave_speed+=30
  4219. -        2.times do
  4220. -          Graphics.update
  4221. -        end
  4222. -      end
  4223. -      bitmap.dispose
  4224. -      bm.dispose
  4225. -      sprite.dispose
  4226. -    elsif Bitmap.method_defined?(:radial_blur) && rand(15)==0
  4227. -      viewport.color=Color.new(0,0,0,255)
  4228. -      sprite = Sprite.new
  4229. -      bitmap=Graphics.snap_to_bitmap
  4230. -      bm=bitmap.clone
  4231. -      sprite.z=99999
  4232. -      sprite.bitmap = bm
  4233. -      for i in 0..15
  4234. -        bm.radial_blur(i,2)
  4235. -        sprite.opacity-=15
  4236. -        2.times do
  4237. -          Graphics.update
  4238. -        end
  4239. -      end
  4240. -      bitmap.dispose
  4241. -      bm.dispose
  4242. -      sprite.dispose
  4243. -    elsif rand(10)==0 # Custom transition method
  4244. -      scroll=["ScrollDown","ScrollLeft","ScrollRight","ScrollUp",
  4245. -              "ScrollDownRight","ScrollDownLeft","ScrollUpRight","ScrollUpLeft"]
  4246. -      Graphics.freeze
  4247. -      viewport.color=Color.new(0,0,0,255)
  4248. -      Graphics.transition(50,sprintf("Graphics/Transitions/%s",scroll[rand(scroll.length)]))
  4249. -    else
  4250. -      transitions=[
  4251. -         # Transitions with graphic files
  4252. -         "021-Normal01","022-Normal02",
  4253. -         "Battle","battle1","battle2","battle3","battle4",
  4254. -         "computertr","computertrclose",
  4255. -         "hexatr","hexatrc","hexatzr",
  4256. -         "Image1","Image2","Image3","Image4",
  4257. -         # Custom transition methods
  4258. -         "Splash","Random_stripe_v","Random_stripe_h",
  4259. -         "RotatingPieces","ShrinkingPieces",
  4260. -         "BreakingGlass","Mosaic","zoomin"
  4261. -      ]
  4262. -      rnd=rand(transitions.length)
  4263. -      Graphics.freeze
  4264. -      viewport.color=Color.new(0,0,0,255)
  4265. -      Graphics.transition(40,sprintf("Graphics/Transitions/%s",transitions[rnd]))
  4266. -    end
  4267. -    5.times do
  4268. -      Graphics.update
  4269. -      Input.update
  4270. -      pbUpdateSceneMap
  4271. -    end
  4272. -  end
  4273. -  pbPushFade
  4274. -  yield if block_given?
  4275. -  pbPopFade
  4276. -  if $game_system && $game_system.is_a?(Game_System)
  4277. -    $game_system.bgm_resume(playingBGM)
  4278. -    $game_system.bgs_resume(playingBGS)
  4279. -  end
  4280. -  $PokemonGlobal.nextBattleBGM=nil
  4281. -  $PokemonGlobal.nextBattleME=nil
  4282. -  $PokemonGlobal.nextBattleBack=nil
  4283. -  $PokemonEncounters.clearStepCount
  4284. -  for j in 0..17
  4285. -    viewport.color=Color.new(0,0,0,(17-j)*15)
  4286. -    Graphics.update
  4287. -    Input.update
  4288. -    pbUpdateSceneMap
  4289. -  end
  4290. -  viewport.dispose
  4291. +  return false
  4292.  end
  4293.  
  4294.  def pbPrepareBattle(battle)
  4295. @@ -808,22 +814,19 @@ def pbGetEnvironment
  4296.    elsif !pbGetMetadata($game_map.map_id,MetadataOutdoor)
  4297.      return PBEnvironment::None
  4298.    else
  4299. -    terrain=$game_player.terrain_tag
  4300. -    if terrain==PBTerrain::Grass # Normal grass
  4301. -      return PBEnvironment::Grass
  4302. -    elsif terrain==PBTerrain::TallGrass # Tall grass
  4303. -      return PBEnvironment::TallGrass
  4304. -    elsif terrain==PBTerrain::DeepWater || terrain==PBTerrain::Water
  4305. -      return PBEnvironment::MovingWater
  4306. -    elsif terrain==PBTerrain::StillWater
  4307. -      return PBEnvironment::StillWater
  4308. -    elsif terrain==PBTerrain::Rock
  4309. -      return PBEnvironment::Rock
  4310. -    elsif terrain==PBTerrain::Sand
  4311. -      return PBEnvironment::Sand
  4312. +    case $game_player.terrain_tag
  4313. +    when PBTerrain::Grass;      return PBEnvironment::Grass       # Normal grass
  4314. +    when PBTerrain::Sand;       return PBEnvironment::Sand
  4315. +    when PBTerrain::Rock;       return PBEnvironment::Rock
  4316. +    when PBTerrain::DeepWater;  return PBEnvironment::MovingWater
  4317. +    when PBTerrain::StillWater; return PBEnvironment::StillWater
  4318. +    when PBTerrain::Water;      return PBEnvironment::MovingWater
  4319. +    when PBTerrain::TallGrass;  return PBEnvironment::TallGrass   # Tall grass
  4320. +    when PBTerrain::SootGrass;  return PBEnvironment::Grass       # Sooty tall grass
  4321. +    when PBTerrain::Puddle;     return PBEnvironment::StillWater
  4322.      end
  4323. -    return PBEnvironment::None
  4324.    end
  4325. +  return PBEnvironment::None
  4326.  end
  4327.  
  4328.  def pbGenerateWildPokemon(species,level,isroamer=false)
  4329. @@ -1134,7 +1137,7 @@ def pbEncounter(enctype)
  4330.      return false if !encounter
  4331.      $PokemonTemp.encounterType=enctype
  4332.      pbWildBattle(encounter[0],encounter[1])
  4333. -     $PokemonTemp.encounterType=-1
  4334. +    $PokemonTemp.encounterType=-1
  4335.      return true
  4336.    end
  4337.  end
  4338. @@ -2426,11 +2429,9 @@ def pbMoveRoute(event,commands,waitComplete=false)
  4339.    route.list.push(RPG::MoveCommand.new(PBMoveRoute::ThroughOn))
  4340.    i=0; while i<commands.length
  4341.      case commands[i]
  4342. -    when PBMoveRoute::Wait, PBMoveRoute::SwitchOn,
  4343. -       PBMoveRoute::SwitchOff, PBMoveRoute::ChangeSpeed,
  4344. -       PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity,
  4345. -       PBMoveRoute::Blending, PBMoveRoute::PlaySE,
  4346. -       PBMoveRoute::Script
  4347. +    when PBMoveRoute::Wait, PBMoveRoute::SwitchOn, PBMoveRoute::SwitchOff,
  4348. +       PBMoveRoute::ChangeSpeed, PBMoveRoute::ChangeFreq, PBMoveRoute::Opacity,
  4349. +       PBMoveRoute::Blending, PBMoveRoute::PlaySE, PBMoveRoute::Script
  4350.        route.list.push(RPG::MoveCommand.new(commands[i],[commands[i+1]]))
  4351.        i+=1
  4352.      when PBMoveRoute::ScriptAsync
  4353. diff --git a/Data/Scripts.rxdata/[102] PField_HiddenMoves.rb b/Data/Scripts.rxdata/[102] PField_HiddenMoves.rb
  4354. index 4ec5735..fbc714f 100644
  4355. --- a/Data/Scripts.rxdata/[102] PField_HiddenMoves.rb  
  4356. +++ b/Data/Scripts.rxdata/[102] PField_HiddenMoves.rb  
  4357. @@ -338,7 +338,7 @@ def Kernel.pbHeadbutt(event)
  4358.    if $DEBUG || movefinder
  4359.      if Kernel.pbConfirmMessage(_INTL("A Pok├⌐mon could be in this tree. Would you like to use Headbutt?"))
  4360.        speciesname=!movefinder ? $Trainer.name : movefinder.name
  4361. -      Kernel.pbMessage(_INTL("{1} used Headbutt.",speciesname))
  4362. +      Kernel.pbMessage(_INTL("{1} used Headbutt!",speciesname))
  4363.        pbHiddenMoveAnimation(movefinder)
  4364.        Kernel.pbHeadbuttEffect(event)
  4365.      end
  4366. @@ -360,7 +360,7 @@ HiddenMoveHandlers::CanUseMove.add(:HEADBUTT,proc{|move,pkmn|
  4367.  
  4368.  HiddenMoveHandlers::UseMove.add(:HEADBUTT,proc{|move,pokemon|
  4369.     if !pbHiddenMoveAnimation(pokemon)
  4370. -     Kernel.pbMessage(_INTL("{1} used {2}.",pokemon.name,PBMoves.getName(move)))
  4371. +     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  4372.     end
  4373.     facingEvent=$game_player.pbFacingEvent
  4374.     Kernel.pbHeadbuttEffect(facingEvent)
  4375. @@ -407,7 +407,7 @@ HiddenMoveHandlers::CanUseMove.add(:ROCKSMASH,proc{|move,pkmn|
  4376.       Kernel.pbMessage(_INTL("Can't use that here."))
  4377.       return false
  4378.     end
  4379. -   return true  
  4380. +   return true
  4381.  })
  4382.  
  4383.  HiddenMoveHandlers::UseMove.add(:ROCKSMASH,proc{|move,pokemon|
  4384. @@ -419,7 +419,7 @@ HiddenMoveHandlers::UseMove.add(:ROCKSMASH,proc{|move,pokemon|
  4385.       facingEvent.erase
  4386.       $PokemonMap.addErasedEvent(facingEvent.id)
  4387.     end
  4388. -   return true  
  4389. +   return true
  4390.  })
  4391.  
  4392.  #===============================================================================
  4393. @@ -470,15 +470,16 @@ HiddenMoveHandlers::CanUseMove.add(:STRENGTH,proc{|move,pkmn|
  4394.       Kernel.pbMessage(_INTL("Strength is already being used."))
  4395.       return false
  4396.     end
  4397. -   return true  
  4398. +   return true
  4399.  })
  4400.  
  4401.  HiddenMoveHandlers::UseMove.add(:STRENGTH,proc{|move,pokemon|
  4402. -   pbHiddenMoveAnimation(pokemon)
  4403. -   Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  4404. +   if !pbHiddenMoveAnimation(pokemon)
  4405. +     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  4406. +   end
  4407.     Kernel.pbMessage(_INTL("{1}'s Strength made it possible to move boulders around!",pokemon.name))
  4408.     $PokemonMap.strengthUsed=true
  4409. -   return true  
  4410. +   return true
  4411.  })
  4412.  
  4413.  #===============================================================================
  4414. @@ -497,9 +498,7 @@ def Kernel.pbSurf
  4415.          Kernel.pbMessage(_INTL("{1} used Surf!",speciesname))
  4416.          pbHiddenMoveAnimation(movefinder)
  4417.          surfbgm=pbGetMetadata(0,MetadataSurfBGM)
  4418. -        if surfbgm
  4419. -          pbCueBGM(surfbgm,0.5)
  4420. -        end
  4421. +        pbCueBGM(surfbgm,0.5) if surfbgm
  4422.          pbStartSurfing()
  4423.          return true
  4424.        end
  4425. @@ -563,8 +562,6 @@ Events.onAction+=proc{|sender,e|
  4426.  }
  4427.  
  4428.  HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
  4429. -   terrain=Kernel.pbFacingTerrainTag
  4430. -   notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
  4431.     if !$DEBUG &&
  4432.        !(HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
  4433.       Kernel.pbMessage(_INTL("Sorry, a new Badge is required."))
  4434. @@ -582,6 +579,8 @@ HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
  4435.       Kernel.pbMessage(_INTL("Let's enjoy cycling!"))
  4436.       return false
  4437.     end
  4438. +   terrain=Kernel.pbFacingTerrainTag
  4439. +   notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
  4440.     if !PBTerrain.isSurfable?(terrain) || !notCliff
  4441.       Kernel.pbMessage(_INTL("No surfing here!"))
  4442.       return false
  4443. @@ -590,9 +589,12 @@ HiddenMoveHandlers::CanUseMove.add(:SURF,proc{|move,pkmn|
  4444.  })
  4445.  
  4446.  HiddenMoveHandlers::UseMove.add(:SURF,proc{|move,pokemon|
  4447. +   $game_temp.in_menu=false
  4448.     if !pbHiddenMoveAnimation(pokemon)
  4449.       Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  4450.     end
  4451. +   surfbgm=pbGetMetadata(0,MetadataSurfBGM)
  4452. +   pbCueBGM(surfbgm,0.5) if surfbgm
  4453.     pbStartSurfing()
  4454.     return true
  4455.  })
  4456. @@ -645,7 +647,7 @@ def Kernel.pbWaterfall
  4457.      if $DEBUG || movefinder
  4458.        if Kernel.pbConfirmMessage(_INTL("It's a large waterfall. Would you like to use Waterfall?"))
  4459.          speciesname=!movefinder ? $Trainer.name : movefinder.name
  4460. -        Kernel.pbMessage(_INTL("{1} used Waterfall.",speciesname))
  4461. +        Kernel.pbMessage(_INTL("{1} used Waterfall!",speciesname))
  4462.          pbHiddenMoveAnimation(movefinder)
  4463.          pbAscendWaterfall
  4464.          return true
  4465. @@ -687,7 +689,7 @@ HiddenMoveHandlers::CanUseMove.add(:WATERFALL,proc{|move,pkmn|
  4466.  
  4467.  HiddenMoveHandlers::UseMove.add(:WATERFALL,proc{|move,pokemon|
  4468.     if !pbHiddenMoveAnimation(pokemon)
  4469. -     Kernel.pbMessage(_INTL("{1} used {2}.",pokemon.name,PBMoves.getName(move)))
  4470. +     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  4471.     end
  4472.     Kernel.pbAscendWaterfall
  4473.     return true
  4474. @@ -705,7 +707,7 @@ def Kernel.pbDive
  4475.      if $DEBUG || movefinder
  4476.        if Kernel.pbConfirmMessage(_INTL("The sea is deep here. Would you like to use Dive?"))
  4477.          speciesname=!movefinder ? $Trainer.name : movefinder.name
  4478. -        Kernel.pbMessage(_INTL("{1} used Dive.",speciesname))
  4479. +        Kernel.pbMessage(_INTL("{1} used Dive!",speciesname))
  4480.          pbHiddenMoveAnimation(movefinder)
  4481.          pbFadeOutIn(99999){
  4482.             $game_temp.player_new_map_id=divemap
  4483. @@ -748,7 +750,7 @@ def Kernel.pbSurfacing
  4484.      (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORDIVE : $Trainer.badges[BADGEFORDIVE]) )
  4485.      if Kernel.pbConfirmMessage(_INTL("Light is filtering down from above. Would you like to use Dive?"))
  4486.        speciesname=!movefinder ? $Trainer.name : movefinder.name
  4487. -      Kernel.pbMessage(_INTL("{1} used Dive.",speciesname))
  4488. +      Kernel.pbMessage(_INTL("{1} used Dive!",speciesname))
  4489.        pbHiddenMoveAnimation(movefinder)
  4490.        pbFadeOutIn(99999){
  4491.           $game_temp.player_new_map_id=divemap
  4492. @@ -873,7 +875,7 @@ HiddenMoveHandlers::UseMove.add(:DIVE,proc{|move,pokemon|
  4493.     end
  4494.     return false if !divemap
  4495.     if !pbHiddenMoveAnimation(pokemon)
  4496. -     Kernel.pbMessage(_INTL("{1} used {2}.",pokemon.name,PBMoves.getName(move)))
  4497. +     Kernel.pbMessage(_INTL("{1} used {2}!",pokemon.name,PBMoves.getName(move)))
  4498.     end
  4499.     pbFadeOutIn(99999){
  4500.        $game_temp.player_new_map_id=divemap
  4501. diff --git a/Data/Scripts.rxdata/[104] PField_EncounterModifiers.rb b/Data/Scripts.rxdata/[104] PField_EncounterModifiers.rb
  4502. index f8e091b..946d3fd 100644
  4503. --- a/Data/Scripts.rxdata/[104] PField_EncounterModifiers.rb   
  4504. +++ b/Data/Scripts.rxdata/[104] PField_EncounterModifiers.rb   
  4505. @@ -20,7 +20,10 @@ Events.onWildPokemonCreate+=proc {|sender,e|
  4506.  Events.onWildPokemonCreate+=proc {|sender,e|
  4507.     pokemon=e[0]
  4508.     if $game_map.map_id==51
  4509. -     pokemon.level=pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
  4510. +     newlevel=pbBalancedLevel($Trainer.party) - 4 + rand(5)   # For variety
  4511. +     newlevel=1 if newlevel<1
  4512. +     newlevel=PBExperience::MAXLEVEL if newlevel>PBExperience::MAXLEVEL
  4513. +     pokemon.level=newlevel
  4514.       pokemon.calcStats
  4515.       pokemon.resetMoves
  4516.     end
  4517. diff --git a/Data/Scripts.rxdata/[106] PField_RandomDungeons.rb b/Data/Scripts.rxdata/[106] PField_RandomDungeons.rb
  4518. index 7c8e5a0..45b9dc8 100644
  4519. --- a/Data/Scripts.rxdata/[106] PField_RandomDungeons.rb   
  4520. +++ b/Data/Scripts.rxdata/[106] PField_RandomDungeons.rb   
  4521. @@ -377,7 +377,7 @@ class Dungeon
  4522.  
  4523.    class DungeonTable
  4524.      def initialize(dungeon)
  4525. -       @dungeon=dungeon
  4526. +      @dungeon=dungeon
  4527.      end
  4528.    
  4529.      def xsize; @dungeon.width; end
  4530. @@ -526,15 +526,15 @@ class Dungeon
  4531.    end
  4532.  
  4533.    def intersects?(r1,r2)
  4534. -   return !((( r2[0] + r2[2]  <= r1[0] ) ||
  4535. -        ( r2[0] >= r1[0] + r1[2] ) ||
  4536. -          ( r2[1] + r2[3] <= r1[1] ) ||
  4537. -          ( r2[1] >= r1[1] + r1[3] ) ) &&
  4538. -          (( r1[0] <= r2[0] + r2[2] )||
  4539. -          ( r1[0] >= r2[0] + r2[2] ) ||
  4540. -          ( r1[1] + r1[3] <= r2[1] ) ||
  4541. -        ( r1[1] >= r2[1] + r2[3] ))
  4542. -       );
  4543. +    return !((( r2[0] + r2[2]  <= r1[0] ) ||
  4544. +       ( r2[0] >= r1[0] + r1[2] ) ||
  4545. +       ( r2[1] + r2[3] <= r1[1] ) ||
  4546. +       ( r2[1] >= r1[1] + r1[3] ) ) &&
  4547. +       (( r1[0] <= r2[0] + r2[2] )||
  4548. +       ( r1[0] >= r2[0] + r2[2] ) ||
  4549. +       ( r1[1] + r1[3] <= r2[1] ) ||
  4550. +       ( r1[1] >= r2[1] + r2[3] ))
  4551. +    );
  4552.    end
  4553.  end
  4554.  
  4555. diff --git a/Data/Scripts.rxdata/[107] PField_BerryPlants.rb b/Data/Scripts.rxdata/[107] PField_BerryPlants.rb
  4556. index fd42e0c..5c0cbfd 100644
  4557. --- a/Data/Scripts.rxdata/[107] PField_BerryPlants.rb  
  4558. +++ b/Data/Scripts.rxdata/[107] PField_BerryPlants.rb  
  4559. @@ -7,7 +7,8 @@ class PokemonTemp
  4560.           @berryPlantData=Marshal.load(f)
  4561.        }
  4562.      end
  4563. -    return @berryPlantData[item]
  4564. +    return @berryPlantData[item] if @berryPlantData && @berryPlantData[item]!=nil
  4565. +    return [3,15,2,5] # Hours/stage, drying/hour, min yield, max yield
  4566.    end
  4567.  end
  4568.  
  4569. @@ -32,6 +33,9 @@ class BerryPlantMoistureSprite
  4570.      @event=event
  4571.      @map=map
  4572.      @light = IconSprite.new(0,0,viewport)
  4573. +    @light.ox=16
  4574. +    @light.oy=24
  4575. +    @oldmoisture=-1   # -1=none, 0=dry, 1=damp, 2=wet
  4576.      updateGraphic
  4577.      @disposed=false
  4578.    end
  4579. @@ -48,27 +52,30 @@ class BerryPlantMoistureSprite
  4580.    end
  4581.  
  4582.    def updateGraphic
  4583. -    if @event.variable && @event.variable.length>6
  4584. -      if @event.variable[1]<=0
  4585. -        @light.setBitmap("")
  4586. -      elsif @event.variable[4]>50
  4587. -        @light.setBitmap("Graphics/Characters/berrytreeWet")
  4588. -      elsif @event.variable[4]>0
  4589. -        @light.setBitmap("Graphics/Characters/berrytreeDamp")
  4590. -      else
  4591. -        @light.setBitmap("Graphics/Characters/berrytreeDry")
  4592. -      end
  4593. -    else
  4594. +    case @oldmoisture
  4595. +    when -1
  4596.        @light.setBitmap("")
  4597. +    when 0
  4598. +      @light.setBitmap("Graphics/Characters/berrytreeDry")
  4599. +    when 1
  4600. +      @light.setBitmap("Graphics/Characters/berrytreeDamp")
  4601. +    when 2
  4602. +      @light.setBitmap("Graphics/Characters/berrytreeWet")
  4603.      end
  4604.    end
  4605.  
  4606.    def update
  4607.      return if !@light || !@event
  4608. +    newmoisture=-1
  4609. +    if @event.variable && @event.variable.length>6 && @event.variable[1]>0
  4610. +      # Berry was planted, show moisture patch
  4611. +      newmoisture=(@event.variable[4]>50) ? 2 : (@event.variable[4]>0) ? 1 : 0
  4612. +    end
  4613. +    if @oldmoisture!=newmoisture
  4614. +      @oldmoisture=newmoisture
  4615. +      updateGraphic
  4616. +    end
  4617.      @light.update
  4618. -    updateGraphic
  4619. -    @light.ox=16
  4620. -    @light.oy=24
  4621.      if (Object.const_defined?(:ScreenPosHelper) rescue false)
  4622.        @light.x = ScreenPosHelper.pbScreenX(@event)
  4623.        @light.y = ScreenPosHelper.pbScreenY(@event)
  4624. @@ -86,7 +93,6 @@ end
  4625.  
  4626.  
  4627.  class BerryPlantSprite
  4628. -  DEFAULTBERRYVALUES = [3,15,2,5] # Hours/stage, drying/hour, min yield, max yield
  4629.    REPLANTS = 9
  4630.  
  4631.    def initialize(event,map,viewport)
  4632. @@ -99,8 +105,8 @@ class BerryPlantSprite
  4633.      @oldstage=berryData[0]
  4634.      @event.character_name=""
  4635.      berryData=updatePlantDetails(berryData)
  4636. -    setGraphic(berryData,true)     # Set the event's graphic
  4637. -    event.setVariable(berryData)   # Set new berry data
  4638. +    setGraphic(berryData,true)      # Set the event's graphic
  4639. +    @event.setVariable(berryData)   # Set new berry data
  4640.    end
  4641.  
  4642.    def dispose
  4643. @@ -118,120 +124,118 @@ class BerryPlantSprite
  4644.      if berryData
  4645.        berryData=updatePlantDetails(berryData) if berryData.length>6
  4646.        setGraphic(berryData)
  4647. +      @event.setVariable(berryData)
  4648.      end
  4649.    end
  4650.  
  4651.    def updatePlantDetails(berryData)
  4652. +    return berryData if berryData[0]==0
  4653.      berryvalues=$PokemonTemp.pbGetBerryPlantData(berryData[1])
  4654. -    berryvalues=DEFAULTBERRYVALUES if !berryvalues # Default values
  4655. -    timeperstage=berryvalues[0]
  4656. +    timeperstage=berryvalues[0]*3600
  4657. +    timenow=pbGetTimeNow
  4658.      if berryData.length>6
  4659.        # Gen 4 growth mechanisms
  4660. -      if berryData[0]>0
  4661. -        dryingrate=berryvalues[1]
  4662. -        timeperstage*=3600
  4663. -        if hasConst?(PBItems,:GROWTHMULCH) && isConst?(berryData[7],PBItems,:GROWTHMULCH)
  4664. -          timeperstage=(timeperstage*0.75).to_i
  4665. -          dryingrate=(dryingrate*1.5).ceil
  4666. -        elsif hasConst?(PBItems,:DAMPMULCH) && isConst?(berryData[7],PBItems,:DAMPMULCH)
  4667. -          timeperstage=(timeperstage*1.25).to_i
  4668. -          dryingrate=(dryingrate/2).floor
  4669. +      # Check time elapsed since last check
  4670. +      timeDiff=(timenow.to_i-berryData[3])   # in seconds
  4671. +      return berryData if timeDiff<=0
  4672. +      berryData[3]=timenow.to_i   # last updated now
  4673. +      # Mulch modifiers
  4674. +      dryingrate=berryvalues[1]
  4675. +      maxreplants=REPLANTS
  4676. +      ripestages=4
  4677. +      if isConst?(berryData[7],PBItems,:GROWTHMULCH)
  4678. +        timeperstage=(timeperstage*0.75).to_i
  4679. +        dryingrate=(dryingrate*1.5).ceil
  4680. +      elsif isConst?(berryData[7],PBItems,:DAMPMULCH)
  4681. +        timeperstage=(timeperstage*1.25).to_i
  4682. +        dryingrate=(dryingrate*0.5).floor
  4683. +      elsif isConst?(berryData[7],PBItems,:GOOEYMULCH)
  4684. +        maxreplants=(maxreplants*1.5).ceil
  4685. +      elsif isConst?(berryData[7],PBItems,:STABLEMULCH)
  4686. +        ripestages=6
  4687. +      end
  4688. +      # Cycle through all replants since last check
  4689. +      loop do
  4690. +        secondsalive=berryData[2]
  4691. +        growinglife=(berryData[5]>0) ? 3 : 4 # number of growing stages
  4692. +        numlifestages=growinglife+ripestages # number of growing + ripe stages
  4693. +        # Should replant itself?
  4694. +        if secondsalive+timeDiff>=timeperstage*numlifestages
  4695. +          # Should replant
  4696. +          if berryData[5]>=maxreplants   # Too many replants
  4697. +            return [0,0,0,0,0,0,0,0]
  4698. +          end
  4699. +          # Replant
  4700. +          berryData[0]=2   # replants start in sprouting stage
  4701. +          berryData[2]=0   # seconds alive
  4702. +          berryData[5]+=1  # add to replant count
  4703. +          berryData[6]=0   # yield penalty
  4704. +          timeDiff-=(timeperstage*numlifestages-secondsalive)
  4705. +        else
  4706. +          break
  4707.          end
  4708. -        # Get time elapsed since last check
  4709. -        timenow=pbGetTimeNow
  4710. -        timeDiff=(timenow.to_i-berryData[3]) # in seconds
  4711. -        return berryData if timeDiff<=0
  4712. -        berryData[3]=timenow.to_i # last updated now
  4713. -        hasreplanted=true
  4714. -        while hasreplanted
  4715. -          hasreplanted=false
  4716. -          secondsalive=berryData[2]
  4717. -          # Should replant itself?
  4718. -          growinglife=(berryData[5]>0) ? 3 : 4 # number of growing stages
  4719. -          numlifestages=growinglife+4 # number of growing + ripe stages
  4720. -          numlifestages+=2 if hasConst?(PBItems,:STABLEMULCH) &&
  4721. -                               isConst?(berryData[7],PBItems,:STABLEMULCH)
  4722. -          if secondsalive+timeDiff>=timeperstage*numlifestages
  4723. -            # Should replant
  4724. -            # Has it been replanted too many times already?
  4725. -            replantmult=1
  4726. -            replantmult=1.5 if hasConst?(PBItems,:GOOEYMULCH) &&
  4727. -                               isConst?(berryData[7],PBItems,:GOOEYMULCH)
  4728. -            if berryData[5]>=(REPLANTS*replantmult).ceil   # Too many replants
  4729. -              berryData=nil
  4730. -              break
  4731. -            end
  4732. -            # Replant
  4733. -            berryData[0]=2   # replants start in sprouting stage
  4734. -            berryData[2]=0   # seconds alive
  4735. -            berryData[5]+=1  # add to replant count
  4736. -            berryData[6]=0   # yield penalty
  4737. -            timeDiff-=(timeperstage*numlifestages-secondsalive)
  4738. -            hasreplanted=true
  4739. +      end
  4740. +      # Update current stage and dampness
  4741. +      if berryData[0]>0
  4742. +        # Advance growth stage
  4743. +        oldlifetime=berryData[2]
  4744. +        newlifetime=oldlifetime+timeDiff
  4745. +        if berryData[0]<5
  4746. +          berryData[0]=1+(newlifetime/timeperstage).floor
  4747. +          berryData[0]+=1 if berryData[5]>0   # replants start at stage 2
  4748. +          berryData[0]=5 if berryData[0]>5
  4749. +        end
  4750. +        # Update the "seconds alive" counter
  4751. +        berryData[2]=newlifetime
  4752. +        # Reduce dampness, apply yield penalty if dry
  4753. +        growinglife=(berryData[5]>0) ? 3 : 4 # number of growing stages
  4754. +        oldhourtick=(oldlifetime/3600).floor
  4755. +        newhourtick=(([newlifetime,timeperstage*growinglife].min)/3600).floor
  4756. +        (newhourtick-oldhourtick).times do
  4757. +          if berryData[4]>0
  4758. +            berryData[4]=[berryData[4]-dryingrate,0].max
  4759.            else
  4760. -            # Reduce dampness, apply yield penalty if dry
  4761. -            oldhourtick=(secondsalive/3600).floor
  4762. -            newhourtick=(([secondsalive+timeDiff,timeperstage*growinglife].min)/3600).floor
  4763. -            (newhourtick-oldhourtick).times do
  4764. -              if berryData[4]>0
  4765. -                berryData[4]=[berryData[4]-dryingrate,0].max
  4766. -              else
  4767. -                berryData[6]+=1
  4768. -              end
  4769. -            end
  4770. -            # Advance growth stage
  4771. -            if secondsalive+timeDiff>=timeperstage*growinglife
  4772. -              berryData[0]=5
  4773. -            else
  4774. -              berryData[0]=1+((secondsalive+timeDiff)/timeperstage).floor
  4775. -              berryData[0]+=1 if berryData[0]<5 && berryData[5]>0 # replants start at stage 2
  4776. -            end
  4777. -            # Update the "seconds alive" counter
  4778. -            berryData[2]+=timeDiff
  4779. -            break
  4780. +            berryData[6]+=1
  4781.            end
  4782.          end
  4783.        end
  4784.      else
  4785.        # Gen 3 growth mechanics
  4786.        loop do
  4787. -        break if berryData[0]==0
  4788. -        levels=0
  4789.          if berryData[0]>0 && berryData[0]<5
  4790. +          levels=0
  4791.            # Advance time
  4792. -          timenow=pbGetTimeNow
  4793.            timeDiff=(timenow.to_i-berryData[3]) # in seconds
  4794. -          if timeDiff>=timeperstage*3600
  4795. -           levels+=1
  4796. -          end
  4797. -          if timeDiff>=timeperstage*2*3600
  4798. -            levels+=1
  4799. -          end
  4800. -          if timeDiff>=timeperstage*3*3600
  4801. -            levels+=1
  4802. -          end
  4803. -          if timeDiff>=timeperstage*4*3600
  4804. +          if timeDiff>=timeperstage
  4805.              levels+=1
  4806. +            if timeDiff>=timeperstage*2
  4807. +              levels+=1
  4808. +              if timeDiff>=timeperstage*3
  4809. +                levels+=1
  4810. +                if timeDiff>=timeperstage*4
  4811. +                  levels+=1
  4812. +                end
  4813. +              end
  4814. +            end
  4815.            end
  4816.            levels=5-berryData[0] if levels>5-berryData[0]
  4817.            break if levels==0
  4818. -          berryData[2]=false
  4819. -          berryData[3]+=levels*timeperstage*3600
  4820. -          berryData[0]+=levels
  4821. +          berryData[2]=false                  # not watered this stage
  4822. +          berryData[3]+=levels*timeperstage   # add to time existed
  4823. +          berryData[0]+=levels                # increase growth stage
  4824.            berryData[0]=5 if berryData[0]>5
  4825.          end
  4826.          if berryData[0]>=5
  4827.            # Advance time
  4828. -          timenow=pbGetTimeNow
  4829. -          timeDiff=(timenow.to_i-berryData[3]) # in seconds
  4830. -          if timeDiff>=timeperstage*3600*4 # ripe for 4 times as long as a stage
  4831. +          timeDiff=(timenow.to_i-berryData[3])   # in seconds
  4832. +          if timeDiff>=timeperstage*4   # ripe for 4 times as long as a stage
  4833.              # Replant
  4834. -            berryData[0]=2 # restarts in sprouting stage
  4835. -            berryData[2]=false
  4836. -            berryData[3]+=timeperstage*4*3600
  4837. -            berryData[4]=0
  4838. +            berryData[0]=2                      # replants start at stage 2
  4839. +            berryData[2]=false                  # not watered this stage
  4840. +            berryData[3]+=timeperstage*4        # add to time existed
  4841. +            berryData[4]=0                      # reset total waterings count
  4842.              berryData[5]+=1                     # add to replanted count
  4843. -            if berryData[5]>REPLANTS            # Too many replants
  4844. +            if berryData[5]>REPLANTS   # Too many replants
  4845.                berryData=[0,0,false,0,0,0]
  4846.                break
  4847.              end
  4848. @@ -240,6 +244,7 @@ class BerryPlantSprite
  4849.            end
  4850.          end
  4851.        end
  4852. +      # Check auto-watering
  4853.        if berryData[0]>0 && berryData[0]<5
  4854.          # Reset watering
  4855.          if $game_screen &&
  4856. @@ -258,29 +263,33 @@ class BerryPlantSprite
  4857.    end
  4858.  
  4859.    def setGraphic(berryData,fullcheck=false)
  4860. -    return if !berryData
  4861. -    if berryData[0]==0
  4862. +    return if !berryData || (@oldstage==berryData[0] && !fullcheck)
  4863. +    case berryData[0]
  4864. +    when 0
  4865.        @event.character_name=""
  4866. -    elsif berryData[0]==1                     # X planted
  4867. +    when 1
  4868.        @event.character_name="berrytreeplanted"   # Common to all berries
  4869.        @event.turn_down
  4870. -    elsif fullcheck || berryData.length>6
  4871. +    else
  4872.        filename=sprintf("berrytree%s",getConstantName(PBItems,berryData[1])) rescue nil
  4873.        filename=sprintf("berrytree%03d",berryData[1]) if !pbResolveBitmap("Graphics/Characters/"+filename)
  4874.        if pbResolveBitmap("Graphics/Characters/"+filename)
  4875.          @event.character_name=filename
  4876. -        @event.turn_down if berryData[0]==2   # X sprouted
  4877. -        @event.turn_left if berryData[0]==3   # X taller
  4878. -        @event.turn_right if berryData[0]==4  # X flowering
  4879. -        @event.turn_up if berryData[0]==5     # X berries
  4880. +        case berryData[0]
  4881. +        when 2; @event.turn_down    # X sprouted
  4882. +        when 3; @event.turn_left    # X taller
  4883. +        when 4; @event.turn_right   # X flowering
  4884. +        when 5; @event.turn_up      # X berries
  4885. +        end
  4886.        else
  4887.          @event.character_name="Object ball"
  4888.        end
  4889. -      if @oldstage!=berryData[0] && berryData.length>6
  4890. +      if @oldstage!=berryData[0] && berryData.length>6   # Gen 4 growth mechanisms
  4891.          $scene.spriteset.addUserAnimation(PLANT_SPARKLE_ANIMATION_ID,@event.x,@event.y) if $scene.spriteset
  4892. -        @oldstage=berryData[0]
  4893.        end
  4894.      end
  4895. +    @oldstage=berryData[0]
  4896. +p "here",berryData,@oldstage if Input.trigger?(Input::CTRL)
  4897.    end
  4898.  end
  4899.  
  4900. @@ -290,6 +299,7 @@ def pbBerryPlant
  4901.    interp=pbMapInterpreter
  4902.    thisEvent=interp.get_character(0)
  4903.    berryData=interp.getVariable
  4904. +p berryData if Input.trigger?(Input::CTRL)
  4905.    if !berryData
  4906.      if NEWBERRYPLANTS
  4907.        berryData=[0,0,0,0,0,0,0,0]
  4908. @@ -299,22 +309,18 @@ def pbBerryPlant
  4909.    end
  4910.    # Stop the event turning towards the player
  4911.    case berryData[0]
  4912. -  when 1  # X planted
  4913. -    thisEvent.turn_down
  4914. -  when 2  # X sprouted
  4915. -    thisEvent.turn_down
  4916. -  when 3  # X taller
  4917. -    thisEvent.turn_left
  4918. -  when 4  # X flowering
  4919. -    thisEvent.turn_right
  4920. -  when 5  # X berries
  4921. -    thisEvent.turn_up
  4922. +  when 1; thisEvent.turn_down  # X planted
  4923. +  when 2; thisEvent.turn_down  # X sprouted
  4924. +  when 3; thisEvent.turn_left  # X taller
  4925. +  when 4; thisEvent.turn_right  # X flowering
  4926. +  when 5; thisEvent.turn_up  # X berries
  4927.    end
  4928.    watering=[]
  4929. -  watering.push(getConst(PBItems,:SPRAYDUCK)) if hasConst?(PBItems,:SPRAYDUCK)
  4930. -  watering.push(getConst(PBItems,:SQUIRTBOTTLE)) if hasConst?(PBItems,:SQUIRTBOTTLE)
  4931. -  watering.push(getConst(PBItems,:WAILMERPAIL)) if hasConst?(PBItems,:WAILMERPAIL)
  4932. -  watering.push(getConst(PBItems,:SPRINKLOTAD)) if hasConst?(PBItems,:SPRINKLOTAD)
  4933. +  watering.push(getConst(PBItems,:SPRAYDUCK))
  4934. +  watering.push(getConst(PBItems,:SQUIRTBOTTLE))
  4935. +  watering.push(getConst(PBItems,:WAILMERPAIL))
  4936. +  watering.push(getConst(PBItems,:SPRINKLOTAD))
  4937. +  watering.compact!
  4938.    berry=berryData[1]
  4939.    case berryData[0]
  4940.    when 0  # empty
  4941. @@ -333,29 +339,33 @@ def pbBerryPlant
  4942.               ret=screen.pbChooseItemScreen
  4943.            }
  4944.            if ret>0
  4945. -            berryData[7]=ret if pbIsMulch?(ret)
  4946. -            Kernel.pbMessage(_INTL("The {1} was scattered on the soil.",PBItems.getName(ret)))
  4947. -            if Kernel.pbConfirmMessage(_INTL("Want to plant a Berry?"))
  4948. -              pbFadeOutIn(99999){
  4949. -                 scene=PokemonBag_Scene.new
  4950. -                 screen=PokemonBagScreen.new(scene,$PokemonBag)
  4951. -                 berry=screen.pbChooseBerryScreen
  4952. -              }
  4953. -              if berry>0
  4954. -                timenow=pbGetTimeNow
  4955. -                berryData[0]=1             # growth stage (1-5)
  4956. -                berryData[1]=berry         # item ID of planted berry
  4957. -                berryData[2]=0             # seconds alive
  4958. -                berryData[3]=timenow.to_i  # time of last checkup (now)
  4959. -                berryData[4]=100           # dampness value
  4960. -                berryData[5]=0             # number of replants
  4961. -                berryData[6]=0             # yield penalty
  4962. -                $PokemonBag.pbDeleteItem(berry,1)
  4963. -                Kernel.pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
  4964. -                   PBItems.getName(berry)))
  4965. +            if pbIsMulch?(ret)
  4966. +              berryData[7]=ret
  4967. +              Kernel.pbMessage(_INTL("The {1} was scattered on the soil.",PBItems.getName(ret)))
  4968. +              if Kernel.pbConfirmMessage(_INTL("Want to plant a Berry?"))
  4969. +                pbFadeOutIn(99999){
  4970. +                   scene=PokemonBag_Scene.new
  4971. +                   screen=PokemonBagScreen.new(scene,$PokemonBag)
  4972. +                   berry=screen.pbChooseBerryScreen
  4973. +                }
  4974. +                if berry>0
  4975. +                  timenow=pbGetTimeNow
  4976. +                  berryData[0]=1             # growth stage (1-5)
  4977. +                  berryData[1]=berry         # item ID of planted berry
  4978. +                  berryData[2]=0             # seconds alive
  4979. +                  berryData[3]=timenow.to_i  # time of last checkup (now)
  4980. +                  berryData[4]=100           # dampness value
  4981. +                  berryData[5]=0             # number of replants
  4982. +                  berryData[6]=0             # yield penalty
  4983. +                  $PokemonBag.pbDeleteItem(berry,1)
  4984. +                  Kernel.pbMessage(_INTL("The {1} was planted in the soft, earthy soil.",
  4985. +                     PBItems.getName(berry)))
  4986. +                end
  4987.                end
  4988. +              interp.setVariable(berryData)
  4989. +            else
  4990. +              Kernel.pbMessage(_INTL("That won't fertilize the soil!"))
  4991.              end
  4992. -            interp.setVariable(berryData)
  4993.              return
  4994.            end
  4995.          elsif cmd==1 # Plant Berry
  4996. @@ -455,7 +465,6 @@ def pbBerryPlant
  4997.      end
  4998.    when 5  # X berries
  4999.      berryvalues=$PokemonTemp.pbGetBerryPlantData(berryData[1])
  5000. -    berryvalues=DEFAULTBERRYVALUES if !berryvalues # Default values
  5001.      # Get berry yield (berrycount)
  5002.      berrycount=1
  5003.      if berryData.length>6
  5004. diff --git a/Data/Scripts.rxdata/[108] PField_DayCare.rb b/Data/Scripts.rxdata/[108] PField_DayCare.rb
  5005. index a7d4ed5..34f39b1 100644
  5006. --- a/Data/Scripts.rxdata/[108] PField_DayCare.rb  
  5007. +++ b/Data/Scripts.rxdata/[108] PField_DayCare.rb  
  5008. @@ -207,7 +207,7 @@ def pbDayCareGenerateEgg
  5009.      if k[0]<=EGGINITIALLEVEL
  5010.        moves.push(k[1])
  5011.      else
  5012. -      othermoves.push(k[1]) if mother.knowsMove?(k[1]) && father.knowsMove?(k[1])
  5013. +      othermoves.push(k[1]) if mother.hasMove?(k[1]) && father.hasMove?(k[1])
  5014.      end
  5015.    end
  5016.    # Inheriting Natural Moves
  5017. @@ -221,7 +221,7 @@ def pbDayCareGenerateEgg
  5018.        atk=$ItemData[i][ITEMMACHINE]
  5019.        next if !atk || atk==0
  5020.        if egg.isCompatibleWithMove?(atk)
  5021. -        moves.push(atk) if movefather.knowsMove?(atk)
  5022. +        moves.push(atk) if movefather.hasMove?(atk)
  5023.        end
  5024.      end
  5025.    end
  5026. @@ -235,7 +235,7 @@ def pbDayCareGenerateEgg
  5027.           f.pos=offset
  5028.           i=0; loop do break unless i<length
  5029.             atk=f.fgetw
  5030. -           moves.push(atk) if movefather.knowsMove?(atk)
  5031. +           moves.push(atk) if movefather.hasMove?(atk)
  5032.             i+=1
  5033.           end
  5034.         end
  5035. @@ -250,7 +250,7 @@ def pbDayCareGenerateEgg
  5036.           f.pos=offset
  5037.           i=0; loop do break unless i<length
  5038.             atk=f.fgetw
  5039. -           moves.push(atk) if movemother.knowsMove?(atk)
  5040. +           moves.push(atk) if movemother.hasMove?(atk)
  5041.             i+=1
  5042.           end
  5043.         end
  5044. diff --git a/Data/Scripts.rxdata/[112] PokeBattle_Trainer.rb b/Data/Scripts.rxdata/[112] PokeBattle_Trainer.rb
  5045. index 2158aff..fd33f40 100644
  5046. --- a/Data/Scripts.rxdata/[112] PokeBattle_Trainer.rb  
  5047. +++ b/Data/Scripts.rxdata/[112] PokeBattle_Trainer.rb  
  5048. @@ -99,7 +99,8 @@ class PokeBattle_Trainer
  5049.    end
  5050.  
  5051.    def hasSkillCode(code)
  5052. -    return true if skillCode[/#{code}/]
  5053. +    c=skillCode
  5054. +    return true if c!=nil && c!="" && c[/#{code}/]
  5055.      return false
  5056.    end
  5057.  
  5058. @@ -115,7 +116,7 @@ class PokeBattle_Trainer
  5059.      ret=2   # 2 = gender unknown
  5060.      pbRgssOpen("Data/trainertypes.dat","rb"){|f|
  5061.         trainertypes=Marshal.load(f)
  5062. -       if !trainertypes[trainertype]
  5063. +       if !trainertypes || !trainertypes[trainertype]
  5064.           ret=2
  5065.         else
  5066.           ret=trainertypes[trainertype][7]
  5067. diff --git a/Data/Scripts.rxdata/[113] PTrainer_NPCTrainers.rb b/Data/Scripts.rxdata/[113] PTrainer_NPCTrainers.rb
  5068. index 56dde88..a143881 100644
  5069. --- a/Data/Scripts.rxdata/[113] PTrainer_NPCTrainers.rb
  5070. +++ b/Data/Scripts.rxdata/[113] PTrainer_NPCTrainers.rb
  5071. @@ -205,7 +205,7 @@ def pbMissingTrainer(trainerid, trainername, trainerparty)
  5072.    traineridstring="#{trainerid}"
  5073.    traineridstring=getConstantName(PBTrainers,trainerid) rescue "-"
  5074.    if $DEBUG
  5075. -     message=""
  5076. +    message=""
  5077.      if trainerparty!=0
  5078.        message=(_INTL("Add new trainer ({1}, {2}, ID {3})?",traineridstring,trainername,trainerparty))
  5079.      else
  5080. diff --git a/Data/Scripts.rxdata/[115] PItem_Items.rb b/Data/Scripts.rxdata/[115] PItem_Items.rb
  5081. index 8aefc54..d15d691 100644
  5082. --- a/Data/Scripts.rxdata/[115] PItem_Items.rb 
  5083. +++ b/Data/Scripts.rxdata/[115] PItem_Items.rb 
  5084. @@ -580,6 +580,8 @@ def pbConsumeItemInBattle(bag,item)
  5085.    end
  5086.  end
  5087.  
  5088. +# Only called when in the party screen and having chosen an item to be used on
  5089. +# the selected Pokémon
  5090.  def pbUseItemOnPokemon(item,pokemon,scene)
  5091.    if $ItemData[item][ITEMUSE]==3 || $ItemData[item][ITEMUSE]==4    # TM or HM
  5092.      machine=$ItemData[item][ITEMMACHINE]
  5093. @@ -608,6 +610,8 @@ def pbUseItemOnPokemon(item,pokemon,scene)
  5094.      return false
  5095.    else
  5096.      ret=ItemHandlers.triggerUseOnPokemon(item,pokemon,scene)
  5097. +    scene.pbClearAnnotations
  5098. +    scene.pbHardRefresh
  5099.      if ret && $ItemData[item][ITEMUSE]==1 # Usable on Pok├⌐mon, consumed
  5100.        $PokemonBag.pbDeleteItem(item)
  5101.      end
  5102. @@ -714,7 +718,7 @@ def pbUseItem(bag,item,bagscene=nil)
  5103.    end
  5104.  end
  5105.  
  5106. -def Kernel.pbChooseItem(var=0)
  5107. +def Kernel.pbChooseItem(var=0,*args)
  5108.    ret=0
  5109.    scene=PokemonBag_Scene.new
  5110.    screen=PokemonBagScreen.new(scene,$PokemonBag)
  5111. diff --git a/Data/Scripts.rxdata/[116] PItem_ItemEffects.rb b/Data/Scripts.rxdata/[116] PItem_ItemEffects.rb
  5112. index f3640bf..d9d03f8 100644
  5113. --- a/Data/Scripts.rxdata/[116] PItem_ItemEffects.rb   
  5114. +++ b/Data/Scripts.rxdata/[116] PItem_ItemEffects.rb   
  5115. @@ -293,8 +293,10 @@ ItemHandlers::UseOnPokemon.add(:FIRESTONE,proc{|item,pokemon,scene|
  5116.          evo.pbStartScreen(pokemon,newspecies)
  5117.          evo.pbEvolution(false)
  5118.          evo.pbEndScreen
  5119. -        scene.pbRefreshAnnotations(proc{|p| pbCheckEvolution(p,item)>0 })
  5120. -        scene.pbRefresh
  5121. +        if scene.is_a?(PokemonBag_Scene)
  5122. +          scene.pbRefreshAnnotations(proc{|p| pbCheckEvolution(p,item)>0 })
  5123. +          scene.pbRefresh
  5124. +        end
  5125.       }
  5126.       next true
  5127.     end
  5128. diff --git a/Data/Scripts.rxdata/[122] PokeBattle_Pokemon.rb b/Data/Scripts.rxdata/[122] PokeBattle_Pokemon.rb
  5129. index 291e450..a5a1b80 100644
  5130. --- a/Data/Scripts.rxdata/[122] PokeBattle_Pokemon.rb  
  5131. +++ b/Data/Scripts.rxdata/[122] PokeBattle_Pokemon.rb  
  5132. @@ -134,7 +134,9 @@ class PokeBattle_Pokemon
  5133.    def isEgg?
  5134.      return @eggsteps>0
  5135.    end
  5136. -  
  5137. +
  5138. +  def egg?; return isEgg?; end
  5139. +
  5140.  # Returns this Pokemon's growth rate.
  5141.    def growthrate
  5142.      dexdata=pbOpenDexData
  5143. @@ -245,6 +247,19 @@ class PokeBattle_Pokemon
  5144.      return ret1
  5145.    end
  5146.  
  5147. +# Returns whether this Pokémon has a particular ability.
  5148. +  def hasAbility?(value=0)
  5149. +    if value==0
  5150. +      return self.ability>0
  5151. +    else
  5152. +      if value.is_a?(String) || value.is_a?(Symbol)
  5153. +        value=getID(PBAbilities,value)
  5154. +      end
  5155. +      return self.ability==value
  5156. +    end
  5157. +    return false
  5158. +  end
  5159. +
  5160.  # Sets this Pok├⌐mon's ability to a particular ability (if possible).
  5161.    def setAbility(value)
  5162.      @abilityflag=value
  5163. @@ -284,6 +299,19 @@ class PokeBattle_Pokemon
  5164.      return @personalID%25
  5165.    end
  5166.  
  5167. +# Returns whether this Pokémon has a particular nature.
  5168. +  def hasNature?(value=-1)
  5169. +    if value<0
  5170. +      return self.nature>=0
  5171. +    else
  5172. +      if value.is_a?(String) || value.is_a?(Symbol)
  5173. +        value=getID(PBNatures,value)
  5174. +      end
  5175. +      return self.nature==value
  5176. +    end
  5177. +    return false
  5178. +  end
  5179. +
  5180.  # Sets this Pok├⌐mon's nature to a particular nature.
  5181.    def setNature(value)
  5182.      if value.is_a?(String) || value.is_a?(Symbol)
  5183. @@ -395,7 +423,7 @@ class PokeBattle_Pokemon
  5184.    end
  5185.  
  5186.  # Returns true if the Pok├⌐mon knows the given move.
  5187. -  def knowsMove?(move)
  5188. +  def hasMove?(move)
  5189.      if move.is_a?(String) || move.is_a?(Symbol)
  5190.        move=getID(PBMoves,move)
  5191.      end
  5192. @@ -406,6 +434,8 @@ class PokeBattle_Pokemon
  5193.      return false
  5194.    end
  5195.  
  5196. +  def knowsMove?(move); return self.hasMove?(move); end
  5197. +
  5198.  # Returns the list of moves this Pok├⌐mon can learn by levelling up.
  5199.    def getMoveList
  5200.      movelist=[]
  5201. @@ -943,6 +973,10 @@ class PokeBattle_Pokemon
  5202.          @moves[j]=PBMove.new(moveid)
  5203.          j+=1
  5204.        end
  5205. +    else
  5206. +      for i in 0...4
  5207. +        @moves[i]=PBMove.new(0)
  5208. +      end
  5209.      end
  5210.    end
  5211.  end
  5212. \ No newline at end of file
  5213. diff --git a/Data/Scripts.rxdata/[123] Pokemon_MultipleForms.rb b/Data/Scripts.rxdata/[123] Pokemon_MultipleForms.rb
  5214. index c593c50..95bedf7 100644
  5215. --- a/Data/Scripts.rxdata/[123] Pokemon_MultipleForms.rb   
  5216. +++ b/Data/Scripts.rxdata/[123] Pokemon_MultipleForms.rb   
  5217. @@ -13,9 +13,9 @@ class PokeBattle_Pokemon
  5218.  
  5219.    def form=(value)
  5220.      @form=value
  5221. +    MultipleForms.call("onSetForm",self,value)
  5222.      self.calcStats
  5223.      pbSeenForm(self)
  5224. -    MultipleForms.call("onSetForm",self,value)
  5225.    end
  5226.  
  5227.    def formNoCall=(value)
  5228. @@ -694,8 +694,7 @@ MultipleForms.register(:DARMANITAN,{
  5229.  
  5230.  MultipleForms.register(:DEERLING,{
  5231.  "getForm"=>proc{|pokemon|
  5232. -   time=pbGetTimeNow
  5233. -   next (time.month-1)%4
  5234. +   next pbGetSeason
  5235.  }
  5236.  })
  5237.  
  5238. @@ -778,10 +777,8 @@ MultipleForms.register(:KYUREM,{
  5239.  },
  5240.  "getAbilityList"=>proc{|pokemon|
  5241.     case pokemon.form
  5242. -   when 1; next [[getID(PBAbilities,:PRESSURE),0],
  5243. -                 [getID(PBAbilities,:TURBOBLAZE),2]] # White Kyurem
  5244. -   when 2; next [[getID(PBAbilities,:PRESSURE),0],
  5245. -                 [getID(PBAbilities,:TERAVOLT),2]]   # Black Kyurem
  5246. +   when 1; next [[getID(PBAbilities,:TURBOBLAZE),0]] # White Kyurem
  5247. +   when 2; next [[getID(PBAbilities,:TERAVOLT),0]]   # Black Kyurem
  5248.     else;   next                                      # Kyurem
  5249.     end
  5250.  },
  5251. @@ -816,8 +813,8 @@ MultipleForms.register(:KYUREM,{
  5252.  
  5253.  MultipleForms.register(:KELDEO,{
  5254.  "getForm"=>proc{|pokemon|
  5255. -   next 1 if pokemon.knowsMove?(:SECRETSWORD) # Resolute Form
  5256. -   next 0                                     # Ordinary Form
  5257. +   next 1 if pokemon.hasMove?(:SECRETSWORD) # Resolute Form
  5258. +   next 0                                   # Ordinary Form
  5259.  }
  5260.  })
  5261.  
  5262. @@ -864,9 +861,7 @@ MultipleForms.copy(:FLABEBE,:FLOETTE,:FLORGES)
  5263.  
  5264.  MultipleForms.register(:FURFROU,{
  5265.  "getForm"=>proc{|pokemon|
  5266. -   timenow=pbGetTimeNow
  5267. -   if pokemon.form>0 && (!pokemon.formTime ||
  5268. -                         timenow.to_i>pokemon.formTime.to_i+60*60*24*5) # 5 days
  5269. +   if !pokemon.formTime || pbGetTimeNow.to_i>pokemon.formTime.to_i+60*60*24*5 # 5 days
  5270.       next 0
  5271.     end
  5272.     next
  5273. @@ -969,9 +964,7 @@ MultipleForms.register(:XERNEAS,{
  5274.  
  5275.  MultipleForms.register(:HOOPA,{
  5276.  "getForm"=>proc{|pokemon|
  5277. -   timenow=pbGetTimeNow
  5278. -   if pokemon.form>0 && (!pokemon.formTime ||
  5279. -                         timenow.to_i>pokemon.formTime.to_i+60*60*24*3) # 3 days
  5280. +   if !pokemon.formTime || pbGetTimeNow.to_i>pokemon.formTime.to_i+60*60*24*3 # 3 days
  5281.       next 0
  5282.     end
  5283.     next
  5284. diff --git a/Data/Scripts.rxdata/[124] Pokemon_MegaEvolution.rb b/Data/Scripts.rxdata/[124] Pokemon_MegaEvolution.rb
  5285. index 2c4eb4e..dc7612a 100644
  5286. --- a/Data/Scripts.rxdata/[124] Pokemon_MegaEvolution.rb   
  5287. +++ b/Data/Scripts.rxdata/[124] Pokemon_MegaEvolution.rb   
  5288. @@ -22,7 +22,7 @@ class PokeBattle_Pokemon
  5289.  
  5290.    def makeUnmega
  5291.      v=MultipleForms.call("getUnmegaForm",self)
  5292. -    self.form=(v!=nil) ? v : 0
  5293. +    self.form=v if v!=nil
  5294.    end
  5295.  
  5296.    def megaName
  5297. @@ -52,7 +52,7 @@ class PokeBattle_Pokemon
  5298.  
  5299.    def makeUnprimal
  5300.      v=MultipleForms.call("getUnprimalForm",self)
  5301. -    self.form=(v!=nil) ? v : 0
  5302. +    self.form=v if v!=nil
  5303.    end
  5304.  end
  5305.  
  5306. @@ -974,7 +974,7 @@ MultipleForms.register(:LATIOS,{
  5307.  
  5308.  MultipleForms.register(:RAYQUAZA,{
  5309.  "getMegaForm"=>proc{|pokemon|
  5310. -   next 1 if pokemon.knowsMove?(:DRAGONASCENT)
  5311. +   next 1 if pokemon.hasMove?(:DRAGONASCENT)
  5312.     next
  5313.  },
  5314.  "megaMessage"=>proc{|pokemon|
  5315. diff --git a/Data/Scripts.rxdata/[125] Pokemon_ShadowPokemon.rb b/Data/Scripts.rxdata/[125] Pokemon_ShadowPokemon.rb
  5316. index c5bf673..1afd3a8 100644
  5317. --- a/Data/Scripts.rxdata/[125] Pokemon_ShadowPokemon.rb   
  5318. +++ b/Data/Scripts.rxdata/[125] Pokemon_ShadowPokemon.rb   
  5319. @@ -734,19 +734,18 @@ end
  5320.  # User takes recoil damage equal to 1/2 of its current HP. (Shadow End)
  5321.  ################################################################################
  5322.  class PokeBattle_Move_130 < PokeBattle_Move
  5323. -  def isRecoilMove?
  5324. -    return true
  5325. -  end
  5326. -
  5327.    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
  5328.      ret=super(attacker,opponent,hitnum,alltargets,showanimation)
  5329. -    if opponent.damagestate.calcdamage>0 && !opponent.damagestate.substitute
  5330. -      attacker.pbReduceHP([1,((attacker.hp+1)/2).floor].max)
  5331. -      @battle.pbDisplay(_INTL("{1} is damaged by the recoil!",attacker.pbThis))
  5332. -    end
  5333.      attacker.pbHyperMode if ret>=0
  5334.      return ret
  5335.    end
  5336. +
  5337. +  def pbEffectAfterHit(attacker,opponent,turneffects)
  5338. +    if !attacker.isFainted? && turneffects[PBEffects::TotalDamage]>0
  5339. +      attacker.pbReduceHP((attacker.hp/2.0).round)
  5340. +      @battle.pbDisplay(_INTL("{1} is damaged by recoil!",attacker.pbThis))
  5341. +    end
  5342. +  end
  5343.  end
  5344.  
  5345.  
  5346. diff --git a/Data/Scripts.rxdata/[128] Pokemon_Sprites.rb b/Data/Scripts.rxdata/[128] Pokemon_Sprites.rb
  5347. index 24ed6c6..2451050 100644
  5348. --- a/Data/Scripts.rxdata/[128] Pokemon_Sprites.rb 
  5349. +++ b/Data/Scripts.rxdata/[128] Pokemon_Sprites.rb 
  5350. @@ -43,7 +43,7 @@ class PokemonSprite < SpriteWrapper
  5351.  
  5352.    def setSpeciesBitmap(species,female=false,form=0,shiny=false,shadow=false,back=false,egg=false)
  5353.      @_iconbitmap.dispose if @_iconbitmap
  5354. -    @_iconbitmap=species>0 ? pbLoadSpeciesBitmap(species,female,form,shiny,shadow,back,egg) : nil
  5355. +    @_iconbitmap=pbLoadSpeciesBitmap(species,female,form,shiny,shadow,back,egg)
  5356.      self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil
  5357.    end
  5358.  end
  5359. diff --git a/Data/Scripts.rxdata/[133] PScreen_Party.rb b/Data/Scripts.rxdata/[133] PScreen_Party.rb
  5360. index f816d9b..4fd5a9d 100644
  5361. --- a/Data/Scripts.rxdata/[133] PScreen_Party.rb   
  5362. +++ b/Data/Scripts.rxdata/[133] PScreen_Party.rb   
  5363. @@ -777,6 +777,8 @@ class PokemonScreen_Scene
  5364.      for i in 0...6
  5365.        if annot
  5366.          @sprites["pokemon#{i}"].text=annot[i]
  5367. +      else
  5368. +        @sprites["pokemon#{i}"].text=nil
  5369.        end
  5370.      end
  5371.    end
  5372. @@ -1178,6 +1180,10 @@ class PokemonScreen
  5373.      @scene.pbAnnotate(annot)
  5374.    end
  5375.  
  5376. +  def pbClearAnnotations
  5377. +    @scene.pbAnnotate(nil)
  5378. +  end
  5379. +
  5380.    def pbPokemonDebug(pkmn,pkmnid)
  5381.      command=0
  5382.      loop do
  5383. @@ -1812,34 +1818,34 @@ class PokemonScreen
  5384.        pkmnid=@scene.pbChoosePokemon
  5385.        break if pkmnid<0
  5386.        pkmn=@party[pkmnid]
  5387. -      commands=[]
  5388. -      cmdSummary=-1
  5389. -      cmdDebug=-1
  5390. -      cmdMoves=[-1,-1,-1,-1]
  5391. -      cmdSwitch=-1
  5392. -      cmdMail=-1
  5393. -      cmdItem=-1
  5394. +      commands   = []
  5395. +      cmdSummary = -1
  5396. +      cmdDebug   = -1
  5397. +      cmdMoves   = [-1,-1,-1,-1]
  5398. +      cmdSwitch  = -1
  5399. +      cmdMail    = -1
  5400. +      cmdItem    = -1
  5401.        # Build the commands
  5402. -      commands[cmdSummary=commands.length]=_INTL("Summary")
  5403. -      commands[cmdDebug=commands.length]=_INTL("Debug") if $DEBUG
  5404. +      commands[cmdSummary=commands.length]      = _INTL("Summary")
  5405. +      commands[cmdDebug=commands.length]        = _INTL("Debug") if $DEBUG
  5406.        for i in 0...pkmn.moves.length
  5407.          move=pkmn.moves[i]
  5408.          # Check for hidden moves and add any that were found
  5409.          if !pkmn.isEgg? && (isConst?(move.id,PBMoves,:MILKDRINK) ||
  5410.                              isConst?(move.id,PBMoves,:SOFTBOILED) ||
  5411.                              HiddenMoveHandlers.hasHandler(move.id))
  5412. -          commands[cmdMoves[i]=commands.length]=PBMoves.getName(move.id)
  5413. +          commands[cmdMoves[i]=commands.length] = PBMoves.getName(move.id)
  5414.          end
  5415.        end
  5416. -      commands[cmdSwitch=commands.length]=_INTL("Switch") if @party.length>1
  5417. +      commands[cmdSwitch=commands.length]       = _INTL("Switch") if @party.length>1
  5418.        if !pkmn.isEgg?
  5419.          if pkmn.mail
  5420. -          commands[cmdMail=commands.length]=_INTL("Mail")
  5421. +          commands[cmdMail=commands.length]     = _INTL("Mail")
  5422.          else
  5423. -          commands[cmdItem=commands.length]=_INTL("Item")
  5424. +          commands[cmdItem=commands.length]     = _INTL("Item")
  5425.          end
  5426.        end
  5427. -      commands[commands.length]=_INTL("Cancel")
  5428. +      commands[commands.length]                 = _INTL("Cancel")
  5429.        command=@scene.pbShowCommands(_INTL("Do what with {1}?",pkmn.name),commands)
  5430.        havecommand=false
  5431.        for i in 0...4
  5432. @@ -1847,7 +1853,8 @@ class PokemonScreen
  5433.            havecommand=true
  5434.            if isConst?(pkmn.moves[i].id,PBMoves,:SOFTBOILED) ||
  5435.               isConst?(pkmn.moves[i].id,PBMoves,:MILKDRINK)
  5436. -            if pkmn.hp<=(pkmn.totalhp/5).floor
  5437. +            amt=[(pkmn.totalhp/5).floor,1].max
  5438. +            if pkmn.hp<=amt
  5439.                pbDisplay(_INTL("Not enough HP..."))
  5440.                break
  5441.              end
  5442. @@ -1865,12 +1872,12 @@ class PokemonScreen
  5443.                elsif newpkmn.hp==0 || newpkmn.hp==newpkmn.totalhp
  5444.                  pbDisplay(_INTL("{1} can't be used on that Pok├⌐mon.",PBMoves.getName(pkmn.moves[i].id)))
  5445.                else
  5446. -                pkmn.hp-=(pkmn.totalhp/5).floor
  5447. -                hpgain=pbItemRestoreHP(newpkmn,(pkmn.totalhp/5).floor)
  5448. +                pkmn.hp-=amt
  5449. +                hpgain=pbItemRestoreHP(newpkmn,amt)
  5450.                  @scene.pbDisplay(_INTL("{1}'s HP was restored by {2} points.",newpkmn.name,hpgain))
  5451.                  pbRefresh
  5452.                end
  5453. -              break if pkmn.hp<=(pkmn.totalhp/5).floor
  5454. +              break if pkmn.hp<=amt
  5455.              end
  5456.              break
  5457.            elsif Kernel.pbCanUseHiddenMove?(pkmn,pkmn.moves[i].id)
  5458. @@ -1918,17 +1925,17 @@ class PokemonScreen
  5459.            pbRefreshSingle(pkmnid)
  5460.          end
  5461.        elsif cmdItem>=0 && command==cmdItem
  5462. -        itemcommands=[]
  5463. -        cmdUseItem=-1
  5464. -        cmdGiveItem=-1
  5465. -        cmdTakeItem=-1
  5466. -        cmdMoveItem=-1
  5467. +        itemcommands = []
  5468. +        cmdUseItem   = -1
  5469. +        cmdGiveItem  = -1
  5470. +        cmdTakeItem  = -1
  5471. +        cmdMoveItem  = -1
  5472.          # Build the commands
  5473. -        itemcommands[cmdUseItem=itemcommands.length]=_INTL("Use")
  5474. -        itemcommands[cmdGiveItem=itemcommands.length]=_INTL("Give")
  5475. -        itemcommands[cmdTakeItem=itemcommands.length]=_INTL("Take") if pkmn.hasItem?
  5476. -        itemcommands[cmdMoveItem=itemcommands.length]=_INTL("Move") if pkmn.hasItem? && !pbIsMail?(pkmn.item)
  5477. -        itemcommands[itemcommands.length]=_INTL("Cancel")
  5478. +        itemcommands[cmdUseItem=itemcommands.length]  = _INTL("Use")
  5479. +        itemcommands[cmdGiveItem=itemcommands.length] = _INTL("Give")
  5480. +        itemcommands[cmdTakeItem=itemcommands.length] = _INTL("Take") if pkmn.hasItem?
  5481. +        itemcommands[cmdMoveItem=itemcommands.length] = _INTL("Move") if pkmn.hasItem? && !pbIsMail?(pkmn.item)
  5482. +        itemcommands[itemcommands.length]             = _INTL("Cancel")
  5483.          command=@scene.pbShowCommands(_INTL("Do what with an item?"),itemcommands)
  5484.          if cmdUseItem>=0 && command==cmdUseItem   # Use
  5485.            item=@scene.pbUseItem($PokemonBag,pkmn)
  5486. diff --git a/Data/Scripts.rxdata/[135] PScreen_Bag.rb b/Data/Scripts.rxdata/[135] PScreen_Bag.rb
  5487. index 042e161..e3f90cf 100644
  5488. --- a/Data/Scripts.rxdata/[135] PScreen_Bag.rb 
  5489. +++ b/Data/Scripts.rxdata/[135] PScreen_Bag.rb 
  5490. @@ -234,7 +234,7 @@ class PokemonBag_Scene
  5491.    end
  5492.  
  5493.  # Called when the item screen wants an item to be chosen from the screen
  5494. -  def pbChooseItem
  5495. +  def pbChooseItem(lockpocket=false)
  5496.      pbRefresh
  5497.      @sprites["helpwindow"].visible=false
  5498.      itemwindow=@sprites["itemwindow"]
  5499. @@ -264,19 +264,21 @@ class PokemonBag_Scene
  5500.             # Update selected item for current pocket
  5501.             @bag.setChoice(itemwindow.pocket,itemwindow.index)
  5502.           end
  5503. -         # Change pockets if Left/Right pressed
  5504. -         numpockets=PokemonBag.numPockets
  5505. -         if Input.trigger?(Input::LEFT)
  5506. -           if !sorting
  5507. -             itemwindow.pocket=(itemwindow.pocket==1) ? numpockets : itemwindow.pocket-1
  5508. -             @bag.lastpocket=itemwindow.pocket
  5509. -             pbRefresh
  5510. -           end
  5511. -         elsif Input.trigger?(Input::RIGHT)
  5512. -           if !sorting
  5513. -             itemwindow.pocket=(itemwindow.pocket==numpockets) ? 1 : itemwindow.pocket+1
  5514. -             @bag.lastpocket=itemwindow.pocket
  5515. -             pbRefresh
  5516. +         if !lockpocket
  5517. +           # Change pockets if Left/Right pressed
  5518. +           numpockets=PokemonBag.numPockets
  5519. +           if Input.trigger?(Input::LEFT)
  5520. +             if !sorting
  5521. +               itemwindow.pocket=(itemwindow.pocket==1) ? numpockets : itemwindow.pocket-1
  5522. +               @bag.lastpocket=itemwindow.pocket
  5523. +               pbRefresh
  5524. +             end
  5525. +           elsif Input.trigger?(Input::RIGHT)
  5526. +             if !sorting
  5527. +               itemwindow.pocket=(itemwindow.pocket==numpockets) ? 1 : itemwindow.pocket+1
  5528. +               @bag.lastpocket=itemwindow.pocket
  5529. +               pbRefresh
  5530. +             end
  5531.             end
  5532.           end
  5533.           # Select item for switching if A is pressed
  5534. @@ -398,7 +400,7 @@ class PokemonBagScreen
  5535.      @scene.pbStartScene(@bag)
  5536.      item=0
  5537.      loop do
  5538. -      item=@scene.pbChooseItem
  5539. +      item=@scene.pbChooseItem(true)
  5540.        break if item==0
  5541.        itemname=PBItems.getName(item)
  5542.        if !pbIsBerry?(item)
  5543. @@ -544,12 +546,12 @@ class PokemonBagScreen
  5544.      loop do
  5545.        item=@scene.pbChooseItem
  5546.        break if item==0
  5547. -      cmdUse=-1
  5548. -      cmdRegister=-1
  5549. -      cmdGive=-1
  5550. -      cmdToss=-1
  5551. -      cmdRead=-1
  5552. -      cmdMysteryGift=-1
  5553. +      cmdUse         = -1
  5554. +      cmdRegister    = -1
  5555. +      cmdGive        = -1
  5556. +      cmdToss        = -1
  5557. +      cmdRead        = -1
  5558. +      cmdMysteryGift = -1
  5559.        commands=[]
  5560.        # Generate command list
  5561.        commands[cmdRead=commands.length]=_INTL("Read") if pbIsMail?(item)
  5562. diff --git a/Data/Scripts.rxdata/[141] PScreen_Load.rb b/Data/Scripts.rxdata/[141] PScreen_Load.rb
  5563. index 4870976..513fee0 100644
  5564. --- a/Data/Scripts.rxdata/[141] PScreen_Load.rb
  5565. +++ b/Data/Scripts.rxdata/[141] PScreen_Load.rb
  5566. @@ -322,6 +322,7 @@ class PokemonLoad
  5567.      @scene.pbStartScene(commands,showContinue,trainer,framecount,mapid)
  5568.      @scene.pbSetParty(trainer) if showContinue
  5569.      @scene.pbStartScene2
  5570. +    $ItemData = readItemList("Data/items.dat")
  5571.      loop do
  5572.        command=@scene.pbChoose(commands)
  5573.        if cmdContinue>=0 && command==cmdContinue
  5574. @@ -347,7 +348,6 @@ class PokemonLoad
  5575.             $game_player         = Marshal.load(f)
  5576.             $PokemonGlobal       = Marshal.load(f)
  5577.             metadata             = Marshal.load(f)
  5578. -           $ItemData            = readItemList("Data/items.dat")
  5579.             $PokemonBag          = Marshal.load(f)
  5580.             $PokemonStorage      = Marshal.load(f)
  5581.             magicNumberMatches=false
  5582. @@ -415,7 +415,6 @@ class PokemonLoad
  5583.          $game_self_switches  = Game_SelfSwitches.new
  5584.          $game_screen         = Game_Screen.new
  5585.          $game_player         = Game_Player.new
  5586. -        $ItemData            = readItemList("Data/items.dat")
  5587.          $PokemonMap          = PokemonMapMetadata.new
  5588.          $PokemonGlobal       = PokemonGlobalMetadata.new
  5589.          $PokemonStorage      = PokemonStorage.new
  5590. diff --git a/Data/Scripts.rxdata/[143] PScreen_Options.rb b/Data/Scripts.rxdata/[143] PScreen_Options.rb
  5591. index 5c28817..3566fbb 100644
  5592. --- a/Data/Scripts.rxdata/[143] PScreen_Options.rb 
  5593. +++ b/Data/Scripts.rxdata/[143] PScreen_Options.rb 
  5594. @@ -484,8 +484,10 @@ class PokemonOptionScene
  5595.         EnumOption.new(_INTL("Running Key"),[_INTL("Hold"),_INTL("Toggle")],
  5596.            proc { $PokemonSystem.runstyle },
  5597.            proc {|value|
  5598. -             $PokemonSystem.runstyle=value
  5599. -             $PokemonGlobal.runtoggle=false if $PokemonGlobal
  5600. +             if $PokemonSystem.runstyle!=value
  5601. +               $PokemonSystem.runstyle=value
  5602. +               $PokemonGlobal.runtoggle=false if $PokemonGlobal
  5603. +             end
  5604.            }
  5605.         ),
  5606.         NumberOption.new(_INTL("Speech Frame"),1,$SpeechFrames.length,
  5607. diff --git a/Data/Scripts.rxdata/[144] PScreen_Storage.rb b/Data/Scripts.rxdata/[144] PScreen_Storage.rb
  5608. index 6dbe68f..e94b1bc 100644
  5609. --- a/Data/Scripts.rxdata/[144] PScreen_Storage.rb 
  5610. +++ b/Data/Scripts.rxdata/[144] PScreen_Storage.rb 
  5611. @@ -699,62 +699,50 @@ class PokemonStorageScreen
  5612.            pbBoxCommands
  5613.          else
  5614.            pokemon=@storage[selected[0],selected[1]]
  5615. -          commands=[
  5616. -             _INTL("Move"),
  5617. -             _INTL("Summary"),
  5618. -             _INTL("Withdraw"),
  5619. -             _INTL("Item"),
  5620. -             _INTL("Mark"),
  5621. -             _INTL("Release")
  5622. -          ]
  5623. -          commands.push(_INTL("Debug")) if $DEBUG
  5624. -          commands.push(_INTL("Cancel"))
  5625.            heldpoke=pbHeldPokemon
  5626. +          next if !pokemon && !heldpoke
  5627. +          commands    = []
  5628. +          cmdMove     = -1
  5629. +          cmdSummary  = -1
  5630. +          cmdWithdraw = -1
  5631. +          cmdItem     = -1
  5632. +          cmdMark     = -1
  5633. +          cmdRelease  = -1
  5634. +          cmdDebug    = -1
  5635. +          cmdCancel   = -1
  5636.            if heldpoke
  5637.              helptext=_INTL("{1} is selected.",heldpoke.name)
  5638. -            commands[0]=pokemon ? _INTL("Shift") : _INTL("Place")
  5639. +            commands[cmdMove=commands.length]   = (pokemon) ? _INTL("Shift") : _INTL("Place")
  5640.            elsif pokemon
  5641.              helptext=_INTL("{1} is selected.",pokemon.name)
  5642. -            commands[0]=_INTL("Move")
  5643. -          else
  5644. -            next
  5645. -          end
  5646. -          if selected[0]==-1
  5647. -            commands[2]=_INTL("Store")
  5648. -          else
  5649. -            commands[2]=_INTL("Withdraw")
  5650. +            commands[cmdMove=commands.length]   = _INTL("Move")
  5651.            end
  5652. +          commands[cmdSummary=commands.length]  = _INTL("Summary")
  5653. +          commands[cmdWithdraw=commands.length] = (selected[0]==-1) ? _INTL("Store") : _INTL("Withdraw")
  5654. +          commands[cmdItem=commands.length]     = _INTL("Item")
  5655. +          commands[cmdMark=commands.length]     = _INTL("Mark")
  5656. +          commands[cmdRelease=commands.length]  = _INTL("Release")
  5657. +          commands[cmdDebug=commands.length]    = _INTL("Debug") if $DEBUG
  5658. +          commands[cmdCancel=commands.length]   = _INTL("Cancel")
  5659.            command=pbShowCommands(helptext,commands)
  5660. -          case command
  5661. -          when 0 # Move/Shift/Place
  5662. -            if @heldpkmn && pokemon
  5663. -              pbSwap(selected)
  5664. -            elsif @heldpkmn
  5665. -              pbPlace(selected)
  5666. +          if cmdMove>=0 && command==cmdMove   # Move/Shift/Place
  5667. +            if @heldpkmn
  5668. +              (pokemon) ? pbSwap(selected) : pbPlace(selected)
  5669.              else
  5670.                pbHold(selected)
  5671.              end
  5672. -          when 1 # Summary
  5673. +          elsif cmdSummary>=0 && command==cmdSummary   # Summary
  5674.              pbSummary(selected,@heldpkmn)
  5675. -          when 2 # Withdraw
  5676. -            if selected[0]==-1
  5677. -              pbStore(selected,@heldpkmn)
  5678. -            else
  5679. -              pbWithdraw(selected,@heldpkmn)
  5680. -            end
  5681. -          when 3 # Item
  5682. +          elsif cmdWithdraw>=0 && command==cmdWithdraw   # Withdraw/Store
  5683. +            (selected[0]==-1) ? pbStore(selected,@heldpkmn) : pbWithdraw(selected,@heldpkmn)
  5684. +          elsif cmdItem>=0 && command==cmdItem   # Item
  5685.              pbItem(selected,@heldpkmn)
  5686. -          when 4 # Mark
  5687. +          elsif cmdMark>=0 && command==cmdMark   # Mark
  5688.              pbMark(selected,@heldpkmn)
  5689. -          when 5 # Release
  5690. +          elsif cmdRelease>=0 && command==cmdRelease   # Release
  5691.              pbRelease(selected,@heldpkmn)
  5692. -          when 6
  5693. -            if $DEBUG
  5694. -              pkmn=@heldpkmn ? @heldpkmn : pokemon
  5695. -              debugMenu(selected,pkmn,heldpoke)
  5696. -            else
  5697. -              next
  5698. -            end
  5699. +          elsif cmdDebug>=0 && command==cmdDebug   # Debug
  5700. +            debugMenu(selected,(@heldpkmn) ? @heldpkmn : pokemon,heldpoke)
  5701.            end
  5702.          end
  5703.        end
  5704. @@ -2335,29 +2323,29 @@ class PokemonStorageScene
  5705.        else
  5706.          textstrings.push([_INTL("No item"),85,342,2,nonbase,nonshadow])
  5707.        end
  5708. +      if pokemon.isShiny?
  5709. +        imagepos=[(["Graphics/Pictures/shiny",156,198,0,0,-1,-1])]
  5710. +        pbDrawImagePositions(overlay,imagepos)
  5711. +      end
  5712. +      typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
  5713. +      type1rect=Rect.new(0,pokemon.type1*28,64,28)
  5714. +      type2rect=Rect.new(0,pokemon.type2*28,64,28)
  5715. +      if pokemon.type1==pokemon.type2
  5716. +        overlay.blt(52,272,typebitmap.bitmap,type1rect)
  5717. +      else
  5718. +        overlay.blt(18,272,typebitmap.bitmap,type1rect)
  5719. +        overlay.blt(88,272,typebitmap.bitmap,type2rect)
  5720. +      end
  5721. +      drawMarkings(overlay,66,240,128,20,pokemon.markings)
  5722.      end
  5723.      pbSetSystemFont(overlay)
  5724.      pbDrawTextPositions(overlay,textstrings)
  5725. -    textstrings.clear
  5726.      if !pokemon.isEgg?
  5727. +      textstrings.clear
  5728.        textstrings.push([_INTL("Lv."),10,238,false,base,shadow])
  5729. +      pbSetSmallFont(overlay)
  5730. +      pbDrawTextPositions(overlay,textstrings)
  5731.      end
  5732. -    pbSetSmallFont(overlay)
  5733. -    pbDrawTextPositions(overlay,textstrings)
  5734. -    if pokemon.isShiny?
  5735. -      imagepos=[(["Graphics/Pictures/shiny",156,198,0,0,-1,-1])]
  5736. -      pbDrawImagePositions(overlay,imagepos)
  5737. -    end
  5738. -    typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
  5739. -    type1rect=Rect.new(0,pokemon.type1*28,64,28)
  5740. -    type2rect=Rect.new(0,pokemon.type2*28,64,28)
  5741. -    if pokemon.type1==pokemon.type2
  5742. -      overlay.blt(52,272,typebitmap.bitmap,type1rect)
  5743. -    else
  5744. -      overlay.blt(18,272,typebitmap.bitmap,type1rect)
  5745. -      overlay.blt(88,272,typebitmap.bitmap,type2rect)
  5746. -    end
  5747. -    drawMarkings(overlay,66,240,128,20,pokemon.markings)
  5748.      @sprites["pokemon"].setPokemonBitmap(pokemon)
  5749.      pbPositionPokemonSprite(@sprites["pokemon"],26,70)
  5750.    end
  5751. diff --git a/Data/Scripts.rxdata/[147] PScreen_MoveRelearner.rb b/Data/Scripts.rxdata/[147] PScreen_MoveRelearner.rb
  5752. index 8510c96..9d5381d 100644
  5753. --- a/Data/Scripts.rxdata/[147] PScreen_MoveRelearner.rb   
  5754. +++ b/Data/Scripts.rxdata/[147] PScreen_MoveRelearner.rb   
  5755. @@ -13,14 +13,14 @@ def pbGetRelearnableMoves(pokemon)
  5756.    return [] if !pokemon || pokemon.isEgg? || (pokemon.isShadow? rescue false)
  5757.    moves=[]
  5758.    pbEachNaturalMove(pokemon){|move,level|
  5759. -     if level<=pokemon.level && !pokemon.knowsMove?(move)
  5760. +     if level<=pokemon.level && !pokemon.hasMove?(move)
  5761.         moves.push(move) if !moves.include?(move)
  5762.       end
  5763.    }
  5764.    tmoves=[]
  5765.    if pokemon.firstmoves
  5766.      for i in pokemon.firstmoves
  5767. -      tmoves.push(i) if !pokemon.knowsMove?(i) && !moves.include?(i)
  5768. +      tmoves.push(i) if !pokemon.hasMove?(i) && !moves.include?(i)
  5769.      end
  5770.    end
  5771.    moves=tmoves+moves
  5772. diff --git a/Data/Scripts.rxdata/[148] PScreen_PurifyChamber.rb b/Data/Scripts.rxdata/[148] PScreen_PurifyChamber.rb
  5773. index c30a85b..1e04adb 100644
  5774. --- a/Data/Scripts.rxdata/[148] PScreen_PurifyChamber.rb   
  5775. +++ b/Data/Scripts.rxdata/[148] PScreen_PurifyChamber.rb   
  5776. @@ -7,7 +7,7 @@ class PurifyChamberSet
  5777.    end
  5778.  
  5779.    def length
  5780. -     return @list.length
  5781. +    return @list.length
  5782.    end
  5783.  
  5784.    def initialize
  5785. @@ -16,15 +16,15 @@ class PurifyChamberSet
  5786.    end
  5787.  
  5788.    def facing=(value)
  5789. -     if value>=0 && value<@list.length  
  5790. -       @facing=value
  5791. -     end
  5792. +    if value>=0 && value<@list.length  
  5793. +      @facing=value
  5794. +    end
  5795.    end
  5796.  
  5797.    def shadow=(value)
  5798. -     if value==nil || value.isShadow?
  5799. -         @shadow=value
  5800. -     end
  5801. +    if value==nil || value.isShadow?
  5802. +      @shadow=value
  5803. +    end
  5804.    end
  5805.  
  5806.  =begin
  5807. @@ -33,15 +33,15 @@ Boosted if center has advantage over facing Pokemon
  5808.  Boosted based on number of best circles
  5809.  =end
  5810.    def flow
  5811. -     ret=0
  5812. -     return 0 if !@shadow
  5813. -     for i in 0...@list.length
  5814. -       ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0
  5815. -     end
  5816. -     if @list[@facing]
  5817. -         ret+=PurifyChamberSet.isSuperEffective(@shadow,@list[@facing]) ? 1 : 0
  5818. -     end
  5819. -     return [ret+(@list.length/2),4].min
  5820. +    ret=0
  5821. +    return 0 if !@shadow
  5822. +    for i in 0...@list.length
  5823. +      ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0
  5824. +    end
  5825. +    if @list[@facing]
  5826. +      ret+=PurifyChamberSet.isSuperEffective(@shadow,@list[@facing]) ? 1 : 0
  5827. +    end
  5828. +    return [ret+(@list.length/2),4].min
  5829.    end
  5830.  
  5831.    def shadowAffinity
  5832. @@ -57,19 +57,19 @@ Boosted based on number of best circles
  5833.  # Tempo refers to the type advantages of each Pokemon in a certain set in a
  5834.  # clockwise direction. Tempo also depends on the number of Pokemon in the set
  5835.    def tempo
  5836. -     ret=0
  5837. -     for i in 0...@list.length
  5838. -         ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0
  5839. -     end
  5840. -     return partialSum(@list.length)+ret
  5841. +    ret=0
  5842. +    for i in 0...@list.length
  5843. +      ret+=(PurifyChamberSet.isSuperEffective(@list[i],@list[(i+1)%@list.length])) ? 1 : 0
  5844. +    end
  5845. +    return partialSum(@list.length)+ret
  5846.    end
  5847.  
  5848.    def list
  5849. -     return @list.clone
  5850. +    return @list.clone
  5851.    end
  5852.  
  5853.    def [](index)
  5854. -     return @list[index]
  5855. +    return @list[index]
  5856.    end
  5857.  
  5858.    def insertAfter(index,value)
  5859. @@ -239,9 +239,9 @@ class PurifyChamber # German: der Kryptorbis
  5860.      species=getID(PBSpecies,species)
  5861.      pkmn=PseudoPokemon.new(shadow,type1,type2||type1)
  5862.      if pkmn.isShadow?
  5863. -      self.setShadow(set,pkmn)
  5864. +     self.setShadow(set,pkmn)
  5865.      else
  5866. -      self.insertAfter(set,setCount(set),pkmn)
  5867. +     self.insertAfter(set,setCount(set),pkmn)
  5868.      end
  5869.    end
  5870.  end
  5871. @@ -256,7 +256,7 @@ class PokemonGlobalMetadata
  5872.      if !@purifyChamber
  5873.        @purifyChamber=PurifyChamber.new()
  5874.      end
  5875. -     return @purifyChamber
  5876. +    return @purifyChamber
  5877.    end
  5878.  end
  5879.  
  5880. @@ -341,13 +341,13 @@ module PurifyChamberHelper
  5881.  
  5882.    def self.adjustOnInsert(position)
  5883.      if position>0
  5884. -       position-=1
  5885. -       oldpos=position/2
  5886. -       if position%2==0
  5887. +      position-=1
  5888. +      oldpos=position/2
  5889. +      if position%2==0
  5890.          return position+1
  5891. -       else
  5892. -         return ((oldpos+1)*2)+1
  5893. -       end
  5894. +      else
  5895. +        return ((oldpos+1)*2)+1
  5896. +      end
  5897.      end
  5898.      return position
  5899.    end
  5900. @@ -363,7 +363,7 @@ module PurifyChamberHelper
  5901.          chamber.insertAfter(chamber.currentSet,position/2,value)
  5902.        end
  5903.      end
  5904. -  end 
  5905. +  end
  5906.  end
  5907.  
  5908.  
  5909. @@ -395,8 +395,8 @@ class PurifyChamberScreen
  5910.            @scene.pbShift(position,pkmn)
  5911.          else
  5912.            @scene.pbPlace(position,pkmn)
  5913. -         end
  5914. -         PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn)
  5915. +        end
  5916. +        PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn)
  5917.          @scene.pbRefresh()
  5918.        else
  5919.          @scene.pbDisplay(_INTL("Only a Shadow Pok├⌐mon can go there."))
  5920. @@ -409,8 +409,8 @@ class PurifyChamberScreen
  5921.            @scene.pbShift(position,pkmn)
  5922.          else
  5923.            @scene.pbPlace(position,pkmn)
  5924. -         end
  5925. -         PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn)
  5926. +        end
  5927. +        PurifyChamberHelper.pbSetPokemon(@chamber,position,pkmn)
  5928.          @scene.pbRefresh()
  5929.        else
  5930.          @scene.pbDisplay(_INTL("Can't place a Shadow Pok├⌐mon there."))
  5931. @@ -470,7 +470,7 @@ class PurifyChamberScreen
  5932.            if !heldpkmn && curpkmn
  5933.              commands[cmdReplace=commands.length]=_INTL("REPLACE")
  5934.            end
  5935. -           commands.push(_INTL("CANCEL"))
  5936. +          commands.push(_INTL("CANCEL"))
  5937.            choice=@scene.pbShowCommands(
  5938.               _INTL("What shall I do with this {1}?",
  5939.               heldpkmn ? heldpkmn.name : curpkmn.name),commands)
  5940. @@ -479,7 +479,7 @@ class PurifyChamberScreen
  5941.                if pbPlace(heldpkmn,cmd[1]) # calls place or shift as appropriate
  5942.                  if !curpkmn
  5943.                    pbOnPlace(heldpkmn)
  5944. -                       @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1]))
  5945. +                  @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1]))
  5946.                    heldpkmn=nil # Pokemon was placed
  5947.                  else
  5948.                    heldpkmn=curpkmn # Pokemon was shifted
  5949. @@ -501,7 +501,7 @@ class PurifyChamberScreen
  5950.                $PokemonStorage.pbStoreCaught(heldpkmn)
  5951.                heldpkmn=nil
  5952.                @scene.pbRefresh()
  5953. -               else
  5954. +            else
  5955.                # Store and delete Pokemon.
  5956.                @scene.pbWithdraw(cmd[1],heldpkmn)
  5957.                $PokemonStorage.pbStoreCaught(curpkmn)
  5958. @@ -527,7 +527,7 @@ class PurifyChamberScreen
  5959.                    @scene.pbReplace(cmd,pos)
  5960.                    PurifyChamberHelper.pbSetPokemon(@chamber,cmd[1],newpkmn)
  5961.                    $PokemonStorage[pos[0],pos[1]]=curpkmn
  5962. -                     @scene.pbRefresh()
  5963. +                  @scene.pbRefresh()
  5964.                    pbOnPlace(curpkmn)
  5965.                  end
  5966.                end
  5967. @@ -538,7 +538,7 @@ class PurifyChamberScreen
  5968.            if pbPlacePokemon(pos,cmd[1])
  5969.              curpkmn=PurifyChamberHelper.pbGetPokemon(@chamber,cmd[1])
  5970.              pbOnPlace(curpkmn)
  5971. -               @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1]))
  5972. +            @scene.pbPositionHint(PurifyChamberHelper.adjustOnInsert(cmd[1]))
  5973.            end
  5974.          end
  5975.        elsif cmd[0]==1 # Change the active set
  5976. @@ -920,7 +920,7 @@ class PurifyChamberSetView < SpriteWrapper
  5977.        if @chamber.setCount(@set)==PurifyChamber::SETSIZE
  5978.          points=[points/2,1].max
  5979.          pos/=2
  5980. -      end   
  5981. +      end  
  5982.        seg=pos*8/points
  5983.        if seg==7 || seg==0
  5984.          pos-=1 if button==Input::LEFT
  5985. @@ -967,30 +967,30 @@ class PurifyChamberSetView < SpriteWrapper
  5986.      pbSetSmallFont(@info.bitmap)
  5987.      textpos=[]
  5988.      if pkmn
  5989. -       if pkmn.type1==pkmn.type2
  5990. +      if pkmn.type1==pkmn.type2
  5991.          textpos.push([_INTL("{1}  Lv{2}  {3}",pkmn.name,pkmn.level,PBTypes.getName(pkmn.type1)),2,0,0,
  5992. -            Color.new(248,248,248),Color.new(128,128,128)])
  5993. +           Color.new(248,248,248),Color.new(128,128,128)])
  5994.        else
  5995.          textpos.push([_INTL("{1}  Lv{2}  {3}/{4}",pkmn.name,pkmn.level,PBTypes.getName(pkmn.type1),
  5996. -            PBTypes.getName(pkmn.type2)),2,0,0,
  5997. -            Color.new(248,248,248),Color.new(128,128,128)])
  5998. +           PBTypes.getName(pkmn.type2)),2,0,0,
  5999. +           Color.new(248,248,248),Color.new(128,128,128)])
  6000.        end
  6001.        textpos.push([_INTL("FLOW"),2+@info.bitmap.width/2,24,0,
  6002. -          Color.new(248,248,248),Color.new(128,128,128)])
  6003. -         # draw heart gauge
  6004. -       pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8),
  6005. -          Color.new(192,0,256),pkmn.heartgauge,
  6006. +         Color.new(248,248,248),Color.new(128,128,128)])
  6007. +      # draw heart gauge
  6008. +      pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,8,@info.bitmap.width*1/4,8),
  6009. +         Color.new(192,0,256),pkmn.heartgauge,
  6010.           PokeBattle_Pokemon::HEARTGAUGESIZE)
  6011. -       # draw flow gauge
  6012. +      # draw flow gauge
  6013.        pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*3/4,24+8,@info.bitmap.width*1/4,8),
  6014. -          Color.new(0,0,248),@chamber.chamberFlow(@set),6)
  6015. +         Color.new(0,0,248),@chamber.chamberFlow(@set),6)
  6016.      end
  6017.      if @chamber.setCount(@set)>0
  6018.        textpos.push([_INTL("TEMPO"),2,24,0,
  6019. -          Color.new(248,248,248),Color.new(128,128,128)])
  6020. +         Color.new(248,248,248),Color.new(128,128,128)])
  6021.        # draw tempo gauge
  6022.        pbDrawGauge(@info.bitmap,Rect.new(@info.bitmap.width*1/4,24+8,@info.bitmap.width*1/4,8),
  6023. -          Color.new(0,0,248),@chamber[@set].tempo,
  6024. +         Color.new(0,0,248),@chamber[@set].tempo,
  6025.           PurifyChamber.maximumTempo())
  6026.      end
  6027.      pbDrawTextPositions(@info.bitmap,textpos)
  6028. diff --git a/Data/Scripts.rxdata/[150] PScreen_MysteryGift.rb b/Data/Scripts.rxdata/[150] PScreen_MysteryGift.rb
  6029. index 8594636..b69c795 100644
  6030. --- a/Data/Scripts.rxdata/[150] PScreen_MysteryGift.rb 
  6031. +++ b/Data/Scripts.rxdata/[150] PScreen_MysteryGift.rb 
  6032. @@ -50,9 +50,9 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
  6033.              item.obtainText=obtainname
  6034.              break
  6035.            end
  6036. -          return nil if Kernel.pbConfirmMessage(_INTL("Stop editng this gift?"))
  6037. +          return nil if Kernel.pbConfirmMessage(_INTL("Stop editing this gift?"))
  6038.          elsif command==-1
  6039. -          return nil if Kernel.pbConfirmMessage(_INTL("Stop editng this gift?"))
  6040. +          return nil if Kernel.pbConfirmMessage(_INTL("Stop editing this gift?"))
  6041.          end
  6042.        end
  6043.      elsif type>0   # Item
  6044. @@ -63,7 +63,7 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
  6045.        loop do
  6046.          newtype=Kernel.pbMessageChooseNumber(_INTL("Choose a quantity."),params)
  6047.          if newtype==0
  6048. -          return nil if Kernel.pbConfirmMessage(_INTL("Stop editng this gift?"))
  6049. +          return nil if Kernel.pbConfirmMessage(_INTL("Stop editing this gift?"))
  6050.          else
  6051.            type=newtype
  6052.            break
  6053. @@ -84,7 +84,7 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
  6054.        loop do
  6055.          newid=Kernel.pbMessageChooseNumber(_INTL("Choose a unique ID for this gift."),params)
  6056.          if newid==0
  6057. -          return nil if Kernel.pbConfirmMessage(_INTL("Stop editng this gift?"))
  6058. +          return nil if Kernel.pbConfirmMessage(_INTL("Stop editing this gift?"))
  6059.          else
  6060.            if idlist.include?(newid)
  6061.              Kernel.pbMessage(_INTL("That ID is already used by a Mystery Gift."))
  6062. @@ -101,7 +101,7 @@ def pbEditMysteryGift(type,item,id=0,giftname="")
  6063.          giftname=newgiftname
  6064.          break
  6065.        end
  6066. -      return nil if Kernel.pbConfirmMessage(_INTL("Stop editng this gift?"))
  6067. +      return nil if Kernel.pbConfirmMessage(_INTL("Stop editing this gift?"))
  6068.      end
  6069.      return [id,type,item,giftname]
  6070.    rescue
  6071. diff --git a/Data/Scripts.rxdata/[155] PBattle_OrgBattle.rb b/Data/Scripts.rxdata/[155] PBattle_OrgBattle.rb
  6072. index 34282c3..779c752 100644
  6073. --- a/Data/Scripts.rxdata/[155] PBattle_OrgBattle.rb   
  6074. +++ b/Data/Scripts.rxdata/[155] PBattle_OrgBattle.rb   
  6075. @@ -186,7 +186,7 @@ class PBPokemon
  6076.  
  6077.    def convertMove(move)
  6078.      if isConst?(move,PBMoves,:RETURN) && hasConst?(PBMoves,:FRUSTRATION)
  6079. -       move=getConst(PBMoves,:FRUSTRATION)
  6080. +      move=getConst(PBMoves,:FRUSTRATION)
  6081.      end
  6082.      return move
  6083.    end
  6084. @@ -899,8 +899,8 @@ def pbBattleFactoryPokemon(rule,numwins,numswaps,rentals)
  6085.        if (table[i*4+1]<0 || table[i*4+1]>=numwins)
  6086.          pokemonNumbers=[
  6087.             table[i*4+2]*btpokemon.length/882,
  6088. -            table[i*4+3]*btpokemon.length/882
  6089. -         ]
  6090. +           table[i*4+3]*btpokemon.length/882
  6091. +        ]
  6092.        end
  6093.      end
  6094.    end
  6095. diff --git a/Data/Scripts.rxdata/[156] PBattle_OrgBattleRules.rb b/Data/Scripts.rxdata/[156] PBattle_OrgBattleRules.rb
  6096. index 3aec8b8..4c3bb62 100644
  6097. --- a/Data/Scripts.rxdata/[156] PBattle_OrgBattleRules.rb  
  6098. +++ b/Data/Scripts.rxdata/[156] PBattle_OrgBattleRules.rb  
  6099. @@ -622,8 +622,8 @@ class LittleCupRestriction
  6100.    def isValid?(pokemon)
  6101.      return false if isConst?(pokemon.item,PBItems,:BERRYJUICE)
  6102.      return false if isConst?(pokemon.item,PBItems,:DEEPSEATOOTH)
  6103. -    return false if pokemon.knowsMove?(:SONICBOOM)
  6104. -    return false if pokemon.knowsMove?(:DRAGONRAGE)
  6105. +    return false if pokemon.hasMove?(:SONICBOOM)
  6106. +    return false if pokemon.hasMove?(:DRAGONRAGE)
  6107.      return false if isConst?(pokemon.species,PBSpecies,:SCYTHER)
  6108.      return false if isConst?(pokemon.species,PBSpecies,:SNEASEL)
  6109.      return false if isConst?(pokemon.species,PBSpecies,:MEDITITE)
  6110. diff --git a/Data/Scripts.rxdata/[157] PBattle_OrgBattleGenerator.rb b/Data/Scripts.rxdata/[157] PBattle_OrgBattleGenerator.rb
  6111. index 46c8a28..00097c8 100644
  6112. --- a/Data/Scripts.rxdata/[157] PBattle_OrgBattleGenerator.rb  
  6113. +++ b/Data/Scripts.rxdata/[157] PBattle_OrgBattleGenerator.rb  
  6114. @@ -121,31 +121,31 @@ def pbGetLegalMoves2(species,maxlevel)
  6115.    end
  6116.    # Delete less powerful moves
  6117.    deleteAll=proc{|a,item|
  6118. -       while a.include?(item)
  6119. -         a.delete(item)
  6120. -   end
  6121. +    while a.include?(item)
  6122. +      a.delete(item)
  6123. +    end
  6124.    }
  6125.    for move in moves
  6126.      md=moveData(move)
  6127.      for move2 in movedatas
  6128.        if md.function==0xA5 && move2[1].function==0 && md.type==move2[1].type &&
  6129.           md.basedamage>=move2[1].basedamage
  6130. -           deleteAll.call(moves,move2[0])
  6131. +        deleteAll.call(moves,move2[0])
  6132.        elsif md.function==move2[1].function && md.basedamage==0 &&
  6133.           md.accuracy>move2[1].accuracy
  6134.          # Supersonic vs. Confuse Ray, etc.
  6135.          deleteAll.call(moves,move2[0])
  6136.        elsif md.function==0x06 && move2[1].function==0x05
  6137. -           deleteAll.call(moves,move2[0])
  6138. +        deleteAll.call(moves,move2[0])
  6139.        elsif md.function==move2[1].function && md.basedamage!=0 &&
  6140. -            md.type==move2[1].type &&
  6141. -            (md.totalpp==15 || md.totalpp==10 || md.totalpp==move2[1].totalpp) &&
  6142. -            (md.basedamage>move2[1].basedamage ||
  6143. -            (md.basedamage==move2[1].basedamage && md.accuracy>move2[1].accuracy))
  6144. -           # Surf, Flamethrower, Thunderbolt, etc.
  6145. -           deleteAll.call(moves,move2[0])
  6146. -         end
  6147. -     end
  6148. +         md.type==move2[1].type &&
  6149. +         (md.totalpp==15 || md.totalpp==10 || md.totalpp==move2[1].totalpp) &&
  6150. +         (md.basedamage>move2[1].basedamage ||
  6151. +         (md.basedamage==move2[1].basedamage && md.accuracy>move2[1].accuracy))
  6152. +        # Surf, Flamethrower, Thunderbolt, etc.
  6153. +        deleteAll.call(moves,move2[0])
  6154. +      end
  6155. +    end
  6156.    end
  6157.    return moves
  6158.  end
  6159. @@ -920,13 +920,12 @@ def pbDecideWinnerEffectiveness(move,otype1,otype2,ability,scores)
  6160.    return 0 if data.basedamage==0
  6161.    atype=data.type
  6162.    typemod=4
  6163. -  if isConst?(ability,PBAbilities,:LEVITATE) &&
  6164. -     isConst?(data.type,PBTypes,:GROUND)
  6165. +  if isConst?(ability,PBAbilities,:LEVITATE) && isConst?(data.type,PBTypes,:GROUND)
  6166.      typemod=4
  6167.    else
  6168.      mod1=PBTypes.getEffectiveness(atype,otype1)
  6169.      mod2=(otype1==otype2) ? 2 : PBTypes.getEffectiveness(atype,otype2)
  6170. -    if(isConst?(ability,PBAbilities,:WONDERGUARD))
  6171. +    if isConst?(ability,PBAbilities,:WONDERGUARD)
  6172.        mod1=2 if mod1!=4
  6173.        mod2=2 if mod2!=4
  6174.      end
  6175. @@ -968,16 +967,16 @@ def pbDecideWinnerScore(party0,party1,rating)
  6176.  end
  6177.  
  6178.  def pbDecideWinner(party0,party1,rating0,rating1)
  6179. -   rating0=(rating0*15.0/100).round
  6180. -   rating1=(rating1*15.0/100).round
  6181. -   score0=pbDecideWinnerScore(party0,party1,rating0)
  6182. -   score1=pbDecideWinnerScore(party1,party0,rating1)
  6183. -   if score0==score1
  6184. -       return 5 if rating0==rating1
  6185. -       return (rating0>rating1) ? 1 : 2
  6186. -   else
  6187. -       return (score0>score1) ? 1 : 2
  6188. -   end
  6189. +  rating0=(rating0*15.0/100).round
  6190. +  rating1=(rating1*15.0/100).round
  6191. +  score0=pbDecideWinnerScore(party0,party1,rating0)
  6192. +  score1=pbDecideWinnerScore(party1,party0,rating1)
  6193. +  if score0==score1
  6194. +    return 5 if rating0==rating1
  6195. +    return (rating0>rating1) ? 1 : 2
  6196. +  else
  6197. +    return (score0>score1) ? 1 : 2
  6198. +  end
  6199.  end
  6200.  
  6201.  def pbRuledBattle(team1,team2,rule)
  6202. @@ -1073,7 +1072,7 @@ def pbTrainerInfo(pokemonlist,trfile,rules)
  6203.        gender=(!trainertypes[trainerid] ||
  6204.                !trainertypes[trainerid][7]) ? 2 : trainertypes[trainerid][7]
  6205.        randomName=getRandomNameEx(gender,nil,0,12)
  6206. -       tr=[trainerid,randomName,_INTL("Here I come!"),
  6207. +      tr=[trainerid,randomName,_INTL("Here I come!"),
  6208.            _INTL("Yes, I won!"),_INTL("Man, I lost!"),[]]
  6209.        bttrainers.push(tr)
  6210.      end
  6211. @@ -1178,11 +1177,11 @@ def pbTrainerInfo(pokemonlist,trfile,rules)
  6212.            end
  6213.            break if numbers.length>=6 && rules.ruleset.hasValidTeam?(numbersPokemon)
  6214.          end
  6215. -         if numbers.length<6 || !rules.ruleset.hasValidTeam?(numbersPokemon)
  6216. +        if numbers.length<6 || !rules.ruleset.hasValidTeam?(numbersPokemon)
  6217.            while numbers.length<pokemonlist.length &&
  6218.               (numbers.length<6 || !rules.ruleset.hasValidTeam?(numbersPokemon))
  6219.              index=rand(pokemonlist.length)
  6220. -             if !numbers.include?(index)
  6221. +            if !numbers.include?(index)
  6222.                numbers.push(index)
  6223.                numbersPokemon.push(pokemonlist[index])
  6224.              end
  6225. diff --git a/Data/Scripts.rxdata/[160] PMinigame_Duel.rb b/Data/Scripts.rxdata/[160] PMinigame_Duel.rb
  6226. index 2e033af..14f53c2 100644
  6227. --- a/Data/Scripts.rxdata/[160] PMinigame_Duel.rb  
  6228. +++ b/Data/Scripts.rxdata/[160] PMinigame_Duel.rb  
  6229. @@ -72,12 +72,10 @@ class PokemonDuel
  6230.      @oldeventspeed=event.move_speed
  6231.      pbMoveRoute($game_player,[
  6232.         PBMoveRoute::ChangeSpeed,2,
  6233. -       PBMoveRoute::DirectionFixOn
  6234. -    ])
  6235. +       PBMoveRoute::DirectionFixOn])
  6236.      pbMoveRoute(event,[
  6237.         PBMoveRoute::ChangeSpeed,2,
  6238. -       PBMoveRoute::DirectionFixOn
  6239. -    ])
  6240. +       PBMoveRoute::DirectionFixOn])
  6241.      pbWait(30)
  6242.    end
  6243.  
  6244. @@ -124,12 +122,10 @@ class PokemonDuel
  6245.      pbWait(30)
  6246.      pbMoveRoute($game_player,[
  6247.         PBMoveRoute::DirectionFixOff,
  6248. -       PBMoveRoute::ChangeSpeed,@oldmovespeed
  6249. -    ])
  6250. +       PBMoveRoute::ChangeSpeed,@oldmovespeed])
  6251.      pbMoveRoute(@event,[
  6252.         PBMoveRoute::DirectionFixOff,
  6253. -       PBMoveRoute::ChangeSpeed,@oldeventspeed
  6254. -    ])
  6255. +       PBMoveRoute::ChangeSpeed,@oldeventspeed])
  6256.      16.times do
  6257.        @sprites["player"].opacity-=16
  6258.        @sprites["opponent"].opacity-=16
  6259. @@ -200,28 +196,24 @@ class PokemonDuel
  6260.             PBMoveRoute::ScriptAsync,"moveRight90",
  6261.             PBMoveRoute::ScriptAsync,"moveLeft90",
  6262.             PBMoveRoute::ScriptAsync,"moveLeft90",
  6263. -           PBMoveRoute::ScriptAsync,"moveRight90"
  6264. -        ])
  6265. +           PBMoveRoute::ScriptAsync,"moveRight90"])
  6266.          pbMoveRoute(event,[
  6267.             PBMoveRoute::ScriptAsync,"moveLeft90",
  6268.             PBMoveRoute::ScriptAsync,"moveRight90",
  6269.             PBMoveRoute::ScriptAsync,"moveRight90",
  6270. -           PBMoveRoute::ScriptAsync,"moveLeft90"
  6271. -        ])
  6272. +           PBMoveRoute::ScriptAsync,"moveLeft90"])
  6273.          pbWait(10*2)
  6274.          Kernel.pbMessage(_INTL("You study each other's movements..."))
  6275.        elsif action==0 && command==1
  6276.          pbMoveRoute($game_player,[
  6277.             PBMoveRoute::ChangeSpeed,4,
  6278. -           PBMoveRoute::Forward
  6279. -        ])
  6280. +           PBMoveRoute::Forward])
  6281.          pbWait(8*2)
  6282.          pbShake(9,9,8)
  6283.          pbFlashScreens(false,true)
  6284.          pbMoveRoute($game_player,[
  6285.             PBMoveRoute::ChangeSpeed,2,
  6286. -           PBMoveRoute::Backward
  6287. -        ])
  6288. +           PBMoveRoute::Backward])
  6289.          @hp[1]-=1
  6290.          Kernel.pbMessage(_INTL("Your attack was not blocked!"))
  6291.        elsif action==0 && command==2
  6292. @@ -241,8 +233,8 @@ class PokemonDuel
  6293.          Kernel.pbMessage(_INTL("Your attack was evaded!"))
  6294.        elsif (action==0 || action==1 || action==2) && command==3
  6295.          pbMoveRoute($game_player,[
  6296. -        PBMoveRoute::ChangeSpeed,4,
  6297. -        PBMoveRoute::ScriptAsync,"jumpForward"])
  6298. +           PBMoveRoute::ChangeSpeed,4,
  6299. +           PBMoveRoute::ScriptAsync,"jumpForward"])
  6300.          pbWait(8*2)
  6301.          pbMoveRoute(event,[
  6302.             PBMoveRoute::ChangeSpeed,5,
  6303. @@ -262,15 +254,13 @@ class PokemonDuel
  6304.        elsif action==1 && command==0
  6305.          pbMoveRoute(event,[
  6306.             PBMoveRoute::ChangeSpeed,4,
  6307. -           PBMoveRoute::Forward
  6308. -        ])
  6309. +           PBMoveRoute::Forward])
  6310.          pbWait(8*2)
  6311.          pbShake(9,9,8)
  6312.          pbFlashScreens(true,false)
  6313.          pbMoveRoute(event,[
  6314.             PBMoveRoute::ChangeSpeed,2,
  6315. -           PBMoveRoute::Backward
  6316. -        ])
  6317. +           PBMoveRoute::Backward])
  6318.          @hp[0]-=1
  6319.          Kernel.pbMessage(_INTL("You fail to block the opponent's attack!"))
  6320.        elsif action==1 && command==1
  6321. @@ -357,24 +347,20 @@ class PokemonDuel
  6322.          pbMoveRoute($game_player,[PBMoveRoute::Backward])
  6323.          pbMoveRoute($game_player,[
  6324.             PBMoveRoute::ChangeSpeed,4,
  6325. -           PBMoveRoute::ScriptAsync,"jumpForward"
  6326. -        ])
  6327. +           PBMoveRoute::ScriptAsync,"jumpForward"])
  6328.          pbMoveRoute(event,[
  6329.             PBMoveRoute::Wait,15,
  6330.             PBMoveRoute::ChangeSpeed,4,
  6331. -           PBMoveRoute::ScriptAsync,"jumpForward"
  6332. -        ])
  6333. +           PBMoveRoute::ScriptAsync,"jumpForward"])
  6334.          pbWait(20*2)
  6335.          pbMoveRoute(event,[
  6336.             PBMoveRoute::ChangeSpeed,5,
  6337.             PBMoveRoute::Backward,
  6338. -           PBMoveRoute::ChangeSpeed,2
  6339. -        ])
  6340. +           PBMoveRoute::ChangeSpeed,2])
  6341.          pbMoveRoute($game_player,[
  6342.             PBMoveRoute::ChangeSpeed,5,
  6343.             PBMoveRoute::Backward,
  6344. -           PBMoveRoute::ChangeSpeed,2
  6345. -        ])
  6346. +           PBMoveRoute::ChangeSpeed,2])
  6347.          pbShake(9,9,8)
  6348.          pbFlash(Color.new(255,255,255,255),20)
  6349.          pbFlashScreens(true,true)
  6350. diff --git a/Data/Scripts.rxdata/[161] PMinigame_TripleTriad.rb b/Data/Scripts.rxdata/[161] PMinigame_TripleTriad.rb
  6351. index ced70b6..8bed697 100644
  6352. --- a/Data/Scripts.rxdata/[161] PMinigame_TripleTriad.rb   
  6353. +++ b/Data/Scripts.rxdata/[161] PMinigame_TripleTriad.rb   
  6354. @@ -37,10 +37,11 @@ class TriadCard
  6355.    def bonus(opponent)
  6356.      atype=@type
  6357.      otype=opponent.type
  6358. -    mod=PBTypes.getEffectiveness(atype,otype)
  6359. -    return -2 if mod==0
  6360. -    return -1 if mod==1
  6361. -    return 1 if mod==4
  6362. +    case PBTypes.getEffectiveness(atype,otype)
  6363. +    when 0; return -2
  6364. +    when 1; return -1
  6365. +    when 4; return 1
  6366. +    end
  6367.      return 0
  6368.    end
  6369.  
  6370. diff --git a/Data/Scripts.rxdata/[170] PSystem_Utilities.rb b/Data/Scripts.rxdata/[170] PSystem_Utilities.rb
  6371. index e2bc992..a020edd 100644
  6372. --- a/Data/Scripts.rxdata/[170] PSystem_Utilities.rb   
  6373. +++ b/Data/Scripts.rxdata/[170] PSystem_Utilities.rb   
  6374. @@ -1987,10 +1987,11 @@ def pbBalancedLevel(party)
  6375.    mean/=weightSum
  6376.    # Round to nearest number
  6377.    mean=mean.round
  6378. +  # Adjust level to minimum
  6379. +  mean=1 if mean<1
  6380.    # Add 2 to the mean to challenge the player
  6381.    mean+=2
  6382. -  # Adjust level to minimum and maximum
  6383. -  mean=1 if mean<1
  6384. +  # Adjust level to maximum
  6385.    mean=PBExperience::MAXLEVEL if mean>PBExperience::MAXLEVEL
  6386.    return mean
  6387.  end
  6388. @@ -2131,8 +2132,7 @@ def pbChoosePokemonForTrade(variableNumber,nameVarNumber,wanted)
  6389.       if wanted.is_a?(String) || wanted.is_a?(Symbol)
  6390.         wanted=getID(PBSpecies,wanted)
  6391.       end
  6392. -     return !poke.isEgg? && !(poke.isShadow? rescue false) &&
  6393. -            isConst?(poke.species,PBSpecies,wanted)
  6394. +     return !poke.isEgg? && !(poke.isShadow? rescue false) && poke.species==wanted
  6395.    })
  6396.  end
  6397.  
  6398. diff --git a/Data/Scripts.rxdata/[175] Editor.rb b/Data/Scripts.rxdata/[175] Editor.rb
  6399. index 9e97c20..8ab4a8f 100644
  6400. --- a/Data/Scripts.rxdata/[175] Editor.rb  
  6401. +++ b/Data/Scripts.rxdata/[175] Editor.rb  
  6402. @@ -19,10 +19,10 @@ module MakeshiftConsts
  6403.  
  6404.    def self.get(c,i,modname=nil)
  6405.      if !@@consts[c]
  6406. -     @@consts[c]=[]
  6407. +      @@consts[c]=[]
  6408.      end
  6409.      if @@consts[c][i]
  6410. -       return @@consts[c][i]
  6411. +      return @@consts[c][i]
  6412.      end
  6413.      if modname
  6414.        v=getConstantName(modname,i) rescue nil
  6415. @@ -44,7 +44,7 @@ module MakeshiftConsts
  6416.        trconst="T_"+trconst
  6417.      end
  6418.      while @@consts[c].include?(trconst)
  6419. -      trconst=sprintf("%s_%03d",trconst,i)
  6420. +     trconst=sprintf("%s_%03d",trconst,i)
  6421.      end
  6422.      @@consts[c][i]=trconst
  6423.      return trconst
  6424. @@ -140,7 +140,9 @@ def pbSavePokemonData
  6425.      kind=messages.get(MessageTypes::Kinds,i)
  6426.      entry=messages.get(MessageTypes::Entries,i)
  6427.      formnames=messages.get(MessageTypes::FormNames,i)
  6428. -    pbDexDataOffset(dexdata,i,6)
  6429. +    pbDexDataOffset(dexdata,i,2)
  6430. +    ability1=dexdata.fgetw
  6431. +    ability2=dexdata.fgetw
  6432.      color=dexdata.fgetb
  6433.      habitat=dexdata.fgetb
  6434.      type1=dexdata.fgetb
  6435. @@ -159,19 +161,17 @@ def pbSavePokemonData
  6436.      for j in 0...6
  6437.        effort.push(dexdata.fgetb)
  6438.      end
  6439. -    ability1=dexdata.fgetb
  6440. -    ability2=dexdata.fgetb
  6441. +    pbDexDataOffset(dexdata,i,31)
  6442.      compat1=dexdata.fgetb
  6443.      compat2=dexdata.fgetb
  6444.      height=dexdata.fgetw
  6445.      weight=dexdata.fgetw
  6446.      pbDexDataOffset(dexdata,i,38)
  6447.      baseexp=dexdata.fgetw
  6448. -    hiddenability1=dexdata.fgetb
  6449. -    hiddenability2=dexdata.fgetb
  6450. -    hiddenability3=dexdata.fgetb
  6451. -    hiddenability4=dexdata.fgetb
  6452. -    pbDexDataOffset(dexdata,i,48)
  6453. +    hiddenability1=dexdata.fgetw
  6454. +    hiddenability2=dexdata.fgetw
  6455. +    hiddenability3=dexdata.fgetw
  6456. +    hiddenability4=dexdata.fgetw
  6457.      item1=dexdata.fgetw
  6458.      item2=dexdata.fgetw
  6459.      item3=dexdata.fgetw
  6460. @@ -185,14 +185,24 @@ def pbSavePokemonData
  6461.        pokedata.write("Type2=#{ctype2}\r\n")
  6462.      end
  6463.      pokedata.write("BaseStats=#{basestats[0]},#{basestats[1]},#{basestats[2]},#{basestats[3]},#{basestats[4]},#{basestats[5]}\r\n")
  6464. -    pokedata.write("GenderRate=AlwaysMale\r\n") if gender==0
  6465. -    pokedata.write("GenderRate=FemaleOneEighth\r\n") if gender==31
  6466. -    pokedata.write("GenderRate=Female25Percent\r\n") if gender==63
  6467. -    pokedata.write("GenderRate=Female50Percent\r\n") if gender==127
  6468. -    pokedata.write("GenderRate=Female75Percent\r\n") if gender==191
  6469. -    pokedata.write("GenderRate=FemaleSevenEighths\r\n") if gender==223
  6470. -    pokedata.write("GenderRate=AlwaysFemale\r\n") if gender==254
  6471. -    pokedata.write("GenderRate=Genderless\r\n") if gender==255
  6472. +    case gender
  6473. +    when 0
  6474. +      pokedata.write("GenderRate=AlwaysMale\r\n")
  6475. +    when 31
  6476. +      pokedata.write("GenderRate=FemaleOneEighth\r\n")
  6477. +    when 63
  6478. +      pokedata.write("GenderRate=Female25Percent\r\n")
  6479. +    when 127
  6480. +      pokedata.write("GenderRate=Female50Percent\r\n")
  6481. +    when 191
  6482. +      pokedata.write("GenderRate=Female75Percent\r\n")
  6483. +    when 223
  6484. +      pokedata.write("GenderRate=FemaleSevenEighths\r\n")
  6485. +    when 254
  6486. +      pokedata.write("GenderRate=AlwaysFemale\r\n")
  6487. +    when 255
  6488. +      pokedata.write("GenderRate=Genderless\r\n")
  6489. +    end
  6490.      pokedata.write("GrowthRate=" + ["Medium","Erratic","Fluctuating","Parabolic","Fast","Slow"][growthrate]+"\r\n")
  6491.      pokedata.write("BaseEXP=#{baseexp}\r\n")
  6492.      pokedata.write("EffortPoints=#{effort[0]},#{effort[1]},#{effort[2]},#{effort[3]},#{effort[4]},#{effort[5]}\r\n")
  6493. @@ -449,11 +459,11 @@ def pbSaveItems
  6494.         if data[ITEMMACHINE]>0
  6495.           machine=getConstantName(PBMoves,data[ITEMMACHINE]) rescue pbGetMoveConst(data[ITEMMACHINE]) rescue ""
  6496.         end
  6497. -       f.write(sprintf("%d,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n",
  6498. +       f.write(sprintf("%d,%s,%s,%s,%d,%d,%s,%d,%d,%d,%s\r\n",
  6499.            data[ITEMID],csvquote(cname),csvquote(data[ITEMNAME]),
  6500. -          data[ITEMPOCKET],data[ITEMPRICE],csvquote(data[ITEMDESC]),
  6501. -          data[ITEMUSE],data[ITEMBATTLEUSE],data[ITEMTYPE],
  6502. -          csvquote(machine)
  6503. +          csvquote(data[ITEMPLURAL]),data[ITEMPOCKET],data[ITEMPRICE],
  6504. +          csvquote(data[ITEMDESC]),data[ITEMUSE],data[ITEMBATTLEUSE],
  6505. +          data[ITEMTYPE],csvquote(machine)
  6506.         ))
  6507.       end
  6508.   }
  6509. diff --git a/Data/Scripts.rxdata/[176] Compiler.rb b/Data/Scripts.rxdata/[176] Compiler.rb
  6510. index 08a529c..e8c5fa4 100644
  6511. --- a/Data/Scripts.rxdata/[176] Compiler.rb
  6512. +++ b/Data/Scripts.rxdata/[176] Compiler.rb
  6513. @@ -113,7 +113,11 @@ module FileLineData
  6514.  
  6515.    def self.linereport
  6516.      if @section
  6517. -      return _INTL("File {1}, section {2}, key {3}\r\n{4}\r\n",@file,@section,@key,@value)
  6518. +      if @key!=nil
  6519. +        return _INTL("File {1}, section {2}, key {3}\r\n{4}\r\n",@file,@section,@key,@value)
  6520. +      else
  6521. +        return _INTL("File {1}, section {2}\r\n{3}\r\n",@file,@section,@value)
  6522. +      end
  6523.      else
  6524.        return _INTL("File {1}, line {2}\r\n{3}\r\n",@file,@lineno,@linedata)
  6525.      end
  6526. @@ -180,9 +184,11 @@ def pbEachFileSectionEx(f)
  6527.           lastsection={}
  6528.         else
  6529.          if sectionname==nil
  6530. +          FileLineData.setLine(line,lineno)
  6531.            raise _INTL("Expected a section at the beginning of the file. This error may also occur if the file was not saved in UTF-8.\r\n{1}",FileLineData.linereport)
  6532.          end
  6533.          if !line[/^\s*(\w+)\s*=\s*(.*)$/]
  6534. +          FileLineData.setSection(sectionname,nil,line)
  6535.            raise _INTL("Bad line syntax (expected syntax like XXX=YYY)\r\n{1}",FileLineData.linereport)
  6536.          end
  6537.          r1=$~[1]
  6538. @@ -2103,10 +2109,11 @@ def pbExtractTrainers
  6539.         rescue
  6540.           next
  6541.         end
  6542. -       f.write(sprintf("%d,%s,%s,%d,%s,%s,%s,%s\r\n",
  6543. +       f.write(sprintf("%d,%s,%s,%d,%s,%s,%s,%s,%d,%s\r\n",
  6544.            record[0],csvquote(cnst),csvquote(record[2]),
  6545.            record[3],csvquote(record[4]),csvquote(record[5]),csvquote(record[6]),
  6546. -          record[7] ? ["Male","Female","Mixed"][record[7]] : "Mixed"
  6547. +          record[7] ? ["Male","Female","Mixed"][record[7]] : "Mixed",
  6548. +          record[8],record[9]
  6549.         ))
  6550.       end
  6551.    }
  6552. @@ -2119,7 +2126,7 @@ def pbCompileTrainers
  6553.    count=0
  6554.    maxValue=0
  6555.    pbCompilerEachPreppedLine("PBS/trainertypes.txt"){|line,lineno|
  6556. -     record=pbGetCsvRecord(line,lineno,[0,"unsUSSSeUs", # ID can be 0
  6557. +     record=pbGetCsvRecord(line,lineno,[0,"unsUSSSeUS", # ID can be 0
  6558.          nil,nil,nil,nil,nil,nil,nil,{
  6559.          ""=>2,"Male"=>0,"M"=>0,"0"=>0,"Female"=>1,"F"=>1,"1"=>1,"Mixed"=>2,"X"=>2,"2"=>2
  6560.          },nil,nil]
  6561. @@ -2132,12 +2139,11 @@ def pbCompileTrainers
  6562.         raise _INTL("Bad skill value (must be from 0 through 255)\r\n{1}",FileLineData.linereport)
  6563.       end
  6564.       record[8]=record[3] if !record[8]
  6565. -     record[9]="" if !record[9]
  6566. -     trainernames[record[0]]=record[2]
  6567.       if records[record[0]]
  6568.         raise _INTL("Two trainer types ({1} and {2}) have the same ID ({3}), which is not allowed.\r\n{4}",
  6569.            records[record[0]][1],record[1],record[0],FileLineData.linereport)
  6570.       end
  6571. +     trainernames[record[0]]=record[2]
  6572.       records[record[0]]=record
  6573.       maxValue=[maxValue,record[0]].max
  6574.    }
  6575. @@ -2148,9 +2154,9 @@ def pbCompileTrainers
  6576.      next if !rec
  6577.      code+="#{rec[1]}=#{rec[0]}\r\n"
  6578.    end
  6579. -  code+="\r\ndef PBTrainers.getName(id)\r\nreturn pbGetMessage(MessageTypes::TrainerTypes,id)\r\nend"
  6580. -  code+="\r\ndef PBTrainers.getCount\r\nreturn #{count}\r\nend"
  6581. -  code+="\r\ndef PBTrainers.maxValue\r\nreturn #{maxValue}\r\nend\r\nend"
  6582. +  code+="\r\ndef self.getName(id)\r\nreturn pbGetMessage(MessageTypes::TrainerTypes,id)\r\nend"
  6583. +  code+="\r\ndef self.getCount\r\nreturn #{count}\r\nend"
  6584. +  code+="\r\ndef self.maxValue\r\nreturn #{maxValue}\r\nend\r\nend"
  6585.    eval(code)
  6586.    pbAddScript(code,"PBTrainers")
  6587.    File.open("Data/trainertypes.dat","wb"){|f|
  6588. @@ -2468,6 +2474,7 @@ def pbCompileTrainerLists
  6589.    MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechWin,[])
  6590.    MessageTypes.setMessagesAsHash(MessageTypes::EndSpeechLose,[])
  6591.    File.open("PBS/trainerlists.txt","rb"){|f|
  6592. +     FileLineData.file="PBS/trainerlists.txt"
  6593.       pbEachFileSectionEx(f){|section,name|
  6594.          next if name!="DefaultTrainerList" && name!="TrainerList"
  6595.          rsection=[]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement