Advertisement
tustin2121

Pokemon Essentials [16.1 to 16.2] diff

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