mej71

Following Pokemon v1.51

Jan 4th, 2016 (edited)
27,567
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #===============================================================================
  2. # * Config Script For Your Game Here. Change the emo_ to what ever number is
  3. #        the cell holding the animation.
  4. #===============================================================================
  5. Unused_Common_Event         = 5       #Common event should be blank, but reserved
  6. Following_Activated_Switch = 126      # Switch should be reserved
  7. Toggle_Following_Switch = 103         # Switch should be reserved
  8. Current_Following_Variable = 36       # Variable should be reserved
  9. ItemWalk=26                           # Variable should be reserved
  10. Walking_Time_Variable = 27            # Variable should be reserved
  11. Walking_Item_Variable = 28            # Variable should be reserved
  12. Animation_Come_Out = 93              
  13. Animation_Come_In = 94
  14. Emo_Happy = 95
  15. Emo_Normal = 96
  16. Emo_Hate = 97
  17. Emo_Poison= 98
  18. Emo_sing= 99
  19. Emo_love= 100
  20.  
  21. # * Support for Pokemon Birthsigns script
  22. Emo_Cake= 92 if self.class.const_defined?(:PBBirthsigns) &&  self.class.const_get(:PBBirthsigns).instance_of?(::Module)
  23.  
  24. ALLOWTOGGLEFOLLOW = true             # Allow the player to toggle followers on/off
  25. ALLOWFIELDSWITCHING = true          # Allow the player to cycle through pokemon
  26. APPLYSTATUSTONES = true# Add tone to follower if statused
  27. #Status tones to be used, if the above is true (Red,Green,Blue,Gray)
  28. BURNTONE = [204,51,51,50]
  29. POISONTONE = [153,102,204,50]
  30. PARALYSISTONE = [255,255,153,50]
  31. FREEZETONE = [153,204,204,50]
  32. SLEEPTONE = [0,0,0,0]  # I did not use this tone, but you may if you wish
  33. ALWAYS_ANIMATE  = true #Follower sprite will always animated while standing still
  34. #Regardless of the above setting,the species in this array will always animate
  35. ALWAYS_ANIMATED_FOLLOWERS=[151]  # Mew
  36. #Add exclusions to always animated (small birds like Pidgey mostly hop, due to small wings)
  37. ALWAYS_ANIMATED_EXCEPTION=[16] #Pidgey
  38. #Removed for now
  39. #REGULAR_WALKING = true  
  40. WATERPOKEMONCANSURF = true  # Allow water pokemon to follow the player while surfing
  41. WATERPOKEMONCANDIVE = true #Allow water pokemon to follow the player while diving
  42. ALWAYS_ANIMATED_CAN_SURF = true #Pokemon that are always animated can follow you
  43.                                 # across water (flying, levitating, or specified)
  44.  
  45. #Don't change
  46. FOLLOWER_FILE_PATH = "Graphics/Characters/"
  47. #The subfolder where your follower sprites are located
  48. #Has to be within Graphics/Characters
  49. FOLLOWER_FILE_DIR = ""
  50.                            
  51. $TEMPALLOWTOGGLE = false #internal logic use, do not change
  52.  
  53. #===============================================================================
  54. # * Credit to Help-14 for both the original scripts and sprites
  55. # * Change Log:
  56. #===============================================================================
  57.  
  58. #===============================================================================
  59. # * Edited by zingzags
  60. #===============================================================================
  61. # * Fixed bugs
  62. # * Clean ups
  63. # * Fixed Surf Bug (After Surf is done)
  64. # * Fixed def talk_to_pokemon while in surf
  65. # * Fixed Surf Check
  66. # * Fixed Type Check
  67. # * Added Door Support
  68. # * Fixed Hp Bug
  69. # * Added Pokemon Center Support
  70. # * Animation problems
  71. # * Fixed Walk_time_variable problem
  72. # * Added random item loot
  73. # * Added egg check
  74. #===============================================================================
  75.  
  76. #===============================================================================
  77. # * Edited by Rayd12smitty
  78. # * Version 1.0
  79. #===============================================================================
  80. # * Fixed Walk_Time_Variable
  81. # * Fixed crash when talking to Pokemon on a different map than the original
  82. #   they appeared on
  83. # * Receiving Items from Pokemon now works
  84. # * Improved Talk_to_Pokemon wiht more messages and special messages
  85. # * Added messages for all Status Conditions
  86. # * Added Party Rotation to switch follower
  87. # * Made Following Pokemon Toggleable
  88. # * Added Animation for Pokemon coming out of Pokeball in sprite_refresh
  89. # * Tidied up script layout and made more user friendly
  90. # * Fixed Issues with Pokemon jumping around on ledges
  91. # * Fixed Badge for Surf Typo in the script
  92. #===============================================================================
  93. # * Version 1.1
  94. #===============================================================================
  95. # * Fixed Surfing so Pokemon doesn't reappear on water when toggled off
  96. # * Changed Layout and location of Toggle Script
  97. #===============================================================================
  98.  
  99. #===============================================================================
  100. # * Edited by Rayd12smitty and venom12
  101. # * Version 1.2
  102. #===============================================================================
  103. # * Fixed Walk step count so it doesn't add on when Pokemon is toggled off
  104. # * No longer have to manually set Toggle_Following_Switch and
  105. #   Following_Activated_Switch whenever "pbPokemonFollow(x)" is called
  106. # * Now supports Pokemon with multiple forms
  107. # * Items found on specific maps support
  108. # * Support for messages when on a map including a word/phrase in its name
  109. #   rather than a single map
  110. # * Added stepping animation for follower
  111. # * Fixed dismount bike so Pokemon reappears
  112. # * Fixed bike so if it couldn't be used it now can
  113. # * Few other small bike fixes
  114. #===============================================================================
  115.  
  116. #===============================================================================
  117. # * Version 1.3
  118. #===============================================================================
  119. # * Fixed bug with surf where the Follower could block the player from being
  120. #   able to surf, possibly stranding the player
  121. # * Added script to animate all events named "Poke"
  122. # * Increased time to find an item. I realize now that 5000 frames is less than
  123. #   5 min. Way too short.
  124. #===============================================================================
  125.  
  126. #===============================================================================
  127. # * Edited by mej71
  128. # * Version 1.4
  129. #===============================================================================
  130. # * Combined all into one script section for ease of installation
  131. # * Added setting to allow/disallow cycling through pokemon in field
  132. # * Added tone effect to following pokemon if statused
  133. # * Fixed follower grass animations
  134. # * NPCs won't walk over the follower
  135. # * Fixed crash caused by toggling follower when loading a map sometimes
  136. # * Prevent some HM usage when having a nonfollower dependent event
  137. #   so hopefully this will lead more towards support for regular dependent events
  138. # * Your followers don't automatically turn when you do, so it looks more natural
  139. # * There's a setting now to make pokemon always animate while you're standing still
  140. #   Note that flying, levitating, or any pokemon species specified will always animate
  141. #   regardless of this setting
  142. # *Reflected sprites support for followers
  143. # *Player transfer works a bit better, your follower shouldn't appear on top of
  144. #  you anymore
  145. # *There's a setting that allows water pokemon to follow you over water
  146. # *Additional setting allows flying, levitating, or other pokemon species to also
  147. #  follow you over water
  148. # *Sprite refreshes after evolution
  149. # *Blacking out won't cause errors
  150. # *v15.1 compatability
  151. # *Followers walk cycle works properly
  152. # *Move routes work properly (they worked in old versions, but were temporarily
  153. #  broken in my version)
  154. # *Pokemon get put away when transferring to a bike only map
  155. # *Follower gets checked when going underwater (water pokemon can follow underwater)
  156. # * Support for Pokemon Birthsigns script
  157. #===============================================================================
  158.  
  159. #===============================================================================
  160. # * To Do
  161. #===============================================================================
  162. # * None.  Perfect?
  163. #===============================================================================
  164.  
  165.  
  166.  
  167. #===============================================================================
  168. # * Control the following Pokemon
  169. # * Example:
  170. #     FollowingMoveRoute([
  171. #         PBMoveRoute::TurnRight,
  172. #         PBMoveRoute::Wait,4,
  173. #         PBMoveRoute::Jump,0,0
  174. #     ])
  175. # * The Pokemon turns Right, waits 4 frames, and then jumps
  176. # * Call pbPokeStep to animate all events on the map named "Poke"
  177. #===============================================================================
  178. def FollowingMoveRoute(commands,waitComplete=false)
  179.   return if $Trainer.party[0].hp<=0 || $Trainer.party[0].isEgg? ||
  180.       $game_variables[Current_Following_Variable]==0 ||
  181.       !$game_switches[Toggle_Following_Switch]
  182.   $PokemonTemp.dependentEvents.SetMoveRoute(commands,waitComplete)
  183. end
  184.  
  185. def pbPokeStep
  186.   for event in $game_map.events.values
  187.     if event.name=="Poke"              
  188.       pbMoveRoute(event,[PBMoveRoute::StepAnimeOn])
  189.     end
  190.   end
  191. end
  192. #===============================================================================
  193. # * Toggle for Following Pokemon
  194. #===============================================================================
  195. def pbToggleFollowingPokemon(anim=true)
  196.   $TEMPALLOWTOGGLE = false
  197.   return if $Trainer.party[0].hp<=0 || $Trainer.party[0].isEgg?
  198.   if $game_switches[Following_Activated_Switch]
  199.     if $game_switches[Toggle_Following_Switch]
  200.       $game_switches[Toggle_Following_Switch]=false
  201.       $PokemonTemp.dependentEvents.remove_sprite(anim)
  202.       pbWait(1)      
  203.     else
  204.       $game_switches[Toggle_Following_Switch]=true
  205.       $PokemonTemp.dependentEvents.refresh_sprite
  206.       pbWait(1)
  207.      
  208.     end
  209.   end
  210. end
  211.  
  212.  
  213.  
  214. class DependentEvents
  215.   attr_accessor :realEvents
  216. #===============================================================================
  217. # Raises The Current Pokemon's Happiness level +1 per each time the
  218. # Walk_time_Variable reachs 5000 then resets to 0
  219. # ItemWalk, is when the variable reaches a certain amount, that you are able
  220. # to talk to your pokemon to recieve an item
  221. #===============================================================================
  222.   def add_following_time
  223.     if $game_switches[Toggle_Following_Switch] && $Trainer.party.length>=1
  224.       $game_variables[Walking_Time_Variable]+=1 if $game_variables[Current_Following_Variable]!=0
  225.       $game_variables[Walking_Item_Variable]+=1 if $game_variables[Current_Following_Variable]!=0
  226.       if $game_variables[Walking_Time_Variable]==5000
  227.         $Trainer.party[0].happiness+=1
  228.         $game_variables[Walking_Time_Variable]=0
  229.       end
  230.       if $game_variables[Walking_Item_Variable]==1000
  231.         if $game_variables[ItemWalk]==15
  232.         else
  233.           $game_variables[ItemWalk]+=1
  234.         end
  235.         $game_variables[Walking_Item_Variable]=0
  236.       end
  237.     end
  238.   end
  239. #===============================================================================
  240. # * refresh_sprite
  241. # * Updates the sprite sprite with an animation
  242. #===============================================================================
  243.   def refresh_sprite(animation=true)
  244.     if $game_variables[Current_Following_Variable]!=0
  245.       return unless $game_switches[Toggle_Following_Switch]
  246.       return if $PokemonGlobal.bicycle
  247.       if $Trainer.party[0].isShiny?
  248.         shiny=true
  249.       else
  250.         shiny=false
  251.       end
  252.       if $Trainer.party[0].form>0
  253.         form=$Trainer.party[0].form
  254.       else
  255.         form=nil
  256.       end
  257.       if defined?($Trainer.party[0].isShadow?)
  258.         shadow = $Trainer.party[0].isShadow?
  259.       else
  260.         shadow = false
  261.       end
  262.       if $PokemonGlobal.surfing
  263.         if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $Trainer.party[0].hasType?(:WATER)
  264.           events=$PokemonGlobal.dependentEvents
  265.           if animation
  266.             for i in 0...events.length
  267.               $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)
  268.               pbWait(10)
  269.             end
  270.           end
  271.           change_sprite($Trainer.party[0].species, shiny, false, form, $Trainer.party[0].gender, shadow)
  272.         elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  273.           isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  274.           ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  275.           !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species)) &&
  276.           $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg?
  277.           events=$PokemonGlobal.dependentEvents
  278.           if animation
  279.             for i in 0...events.length
  280.               $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)
  281.               pbWait(10)
  282.             end
  283.           end
  284.           change_sprite($Trainer.party[0].species, shiny, false, form, $Trainer.party[0].gender, shadow)
  285.         else
  286.           remove_sprite(false)
  287.         end  
  288.       elsif $PokemonGlobal.diving
  289.         if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $Trainer.party[0].hasType?(:WATER) && WATERPOKEMONCANDIVE
  290.           events=$PokemonGlobal.dependentEvents
  291.           if animation
  292.             for i in 0...events.length
  293.               $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)
  294.               pbWait(10)
  295.             end
  296.           end
  297.           change_sprite($Trainer.party[0].species, shiny, false, form, $Trainer.party[0].gender, shadow)
  298.         else
  299.           remove_sprite(false)
  300.         end  
  301.       else
  302.         if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $scene.is_a?(Scene_Map)
  303.           events=$PokemonGlobal.dependentEvents
  304.           if animation
  305.             for i in 0...events.length
  306.               $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)
  307.               pbWait(10)
  308.             end
  309.           end
  310.           change_sprite($Trainer.party[0].species, shiny, false, form, $Trainer.party[0].gender, shadow)
  311.         elsif $Trainer.party[0].hp<=0 || $Trainer.party[0].isEgg?
  312.           remove_sprite(animation)
  313.         end
  314.       end
  315.     else
  316.       check_faint
  317.     end
  318.   end
  319. #===============================================================================
  320. # * change_sprite(id, shiny, animation)
  321. # * Example, to change sprite to shiny lugia with animation:
  322. #     change_sprite(249, true, true)
  323. # * If just change sprite:
  324. #     change_sprite(249)
  325. #===============================================================================
  326.   def change_sprite(id, shiny=nil, animation=nil, form=nil, gender=nil, shadow=false)
  327.     events=$PokemonGlobal.dependentEvents
  328.     for i in 0...events.length
  329.       if events[i] && events[i][8]=="Dependent"
  330.         tgender = (gender==1)? "f" : ""
  331.         tshiny  = (shiny)? "s" : ""
  332.         tform   = (form && form>0) ? "_#{form}" : ""
  333.         tshadow = (shadow)? "_shadow": ""
  334.         speciesname = getConstantName(PBSpecies,id)
  335.         bitmapFileName=sprintf("%s%s%s%s%s",speciesname,tgender,tshiny,tform,tshadow)
  336.         if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  337.           events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  338.           @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  339.         else
  340.           bitmapFileName=sprintf("%s%s",speciesname,tshiny)
  341.           if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  342.             events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  343.             @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  344.           else
  345.             bitmapFileName=sprintf("%s",speciesname)
  346.             if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  347.               events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  348.               @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  349.             else  
  350.               bitmapFileName=sprintf("%03d%s%s%s%s",id,tgender,tshiny,tform,tshadow)
  351.               if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  352.                 events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  353.                 @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  354.               else  
  355.                 bitmapFileName=sprintf("%03d%s%s%s",id,tshiny,tform,tshadow)
  356.                 if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  357.                   events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  358.                   @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  359.                 else
  360.                   bitmapFileName=sprintf("%03d%s",id,tshiny)
  361.                   if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  362.                     events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  363.                     @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  364.                   else
  365.                     bitmapFileName=sprintf("%03d",id)
  366.                     events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  367.                     @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  368.                   end
  369.                 end
  370.               end
  371.             end
  372.           end
  373.         end
  374.         if animation
  375.           $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)
  376.         end
  377.         $game_variables[Walking_Time_Variable]=0
  378.       end
  379.     end
  380.   end
  381. #===============================================================================
  382. # * update_stepping
  383. # * Adds step animation for followers
  384. #===============================================================================  
  385.   def update_stepping
  386.     FollowingMoveRoute([PBMoveRoute::StepAnimeOn])
  387.   end
  388.  
  389.   def stop_stepping
  390.     FollowingMoveRoute([PBMoveRoute::StepAnimeOff])
  391.   end
  392. #===============================================================================
  393. # * remove_sprite(animation)
  394. # * Example, to remove sprite with animation:
  395. #     remove_sprite(true)
  396. # * If just remove sprite:
  397. #     remove_sprite
  398. #===============================================================================
  399.   def remove_sprite(animation=nil)
  400.     events=$PokemonGlobal.dependentEvents
  401.     for i in 0...events.length
  402.       if events[i] && events[i][8]=="Dependent"
  403.         events[i][6]=sprintf("nil")
  404.         @realEvents[i].character_name=sprintf("nil")
  405.         if animation==true
  406.           $scene.spriteset.addUserAnimation(Animation_Come_In,@realEvents[i].x,@realEvents[i].y)
  407.           pbWait(10)
  408.         end
  409.         $game_variables[Current_Following_Variable]=$Trainer.party[0]
  410.         $game_variables[Walking_Time_Variable]=0
  411.       end
  412.     end
  413.   end
  414. #===============================================================================
  415. # * check_surf(animation)
  416. # * If current Pokemon is a water Pokemon, it is still following.
  417. # * If current Pokemon is not a water Pokemon, remove sprite.
  418. # * Require Water_Pokemon_Can_Surf = true to enable
  419. #===============================================================================
  420.   def check_surf(animation=nil)
  421.     if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg?
  422.       if ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  423.         isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  424.         ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  425.         !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  426.        
  427.           #do nothing
  428.       elsif $Trainer.party[0].hasType?(:WATER) && WATERPOKEMONCANSURF
  429.         #do nothing
  430.       else
  431.         remove_sprite(animation)
  432.       end
  433.      
  434.     end
  435.   end
  436. #===============================================================================
  437. # * talk_to_pokemon
  438. # * It will run when you talk to Pokemon following
  439. #===============================================================================
  440.   def talk_to_pokemon
  441.     e=$Trainer.party[0]
  442.     events=$PokemonGlobal.dependentEvents
  443.     for i in 0...events.length
  444.       if events[i] && events[i][8]=="Dependent"
  445.         pos_x=@realEvents[i].x
  446.         pos_y=@realEvents[i].y
  447.         case $game_player.direction
  448.         when 2 # Facing Down
  449.           return if $game_player.x != pos_x
  450.           return if $game_player.y != pos_y-1
  451.         when 4 # Facing Left
  452.           return if $game_player.x != pos_x+1
  453.           return if $game_player.y != pos_y
  454.         when 6 # Facing Right
  455.           return if $game_player.x != pos_x-1
  456.           return if $game_player.y != pos_y
  457.         when 8 # Facing Up
  458.           return if $game_player.x != pos_x
  459.           return if $game_player.y != pos_y+1
  460.         else
  461.           return false
  462.         end
  463.       end
  464.     end
  465.     if e!=0
  466.       if e.hp>0 && !$Trainer.party[0].isEgg?        
  467.         if $PokemonGlobal.bicycle
  468.           return
  469.         elsif $PokemonGlobal.surfing
  470.           flag = true
  471.           if WATERPOKEMONCANSURF && $Trainer.party[0].hasType?(:WATER)
  472.             flag = false
  473.           elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  474.               isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  475.               ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  476.               !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  477.             flag = false
  478.           end
  479.           return if flag
  480.         elsif $PokemonGlobal.diving && (!WATERPOKEMONCANDIVE || !$Trainer.party[0].hasType?(:WATER))
  481.           return
  482.         end
  483. #===============================================================================
  484. # * Checks to make sure the Pokemon isn't blocking a surfable water surface
  485. # * If the water is blocked by the sprite (even though it is invisible) and
  486. #   the player should be able to surf, calls surf
  487. #===============================================================================
  488.         terrain=Kernel.pbFacingTerrainTag
  489.         notCliff=$game_map.passable?($game_player.x,$game_player.y,$game_player.direction)
  490.         if PBTerrain.isWater?(terrain) || !notCliff
  491.           if !pbGetMetadata($game_map.map_id,MetadataBicycleAlways) && !$PokemonGlobal.surfing
  492.             if $DEBUG
  493.               Kernel.pbSurf
  494.               return
  495.             elsif (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
  496.               Kernel.pbSurf
  497.               return
  498.             end
  499.           end
  500.         end
  501. #===============================================================================
  502. # * talk_to_pokemon when possible begins here
  503. #===============================================================================
  504.         if e!=6 && $game_switches[Toggle_Following_Switch]==true
  505.           pbPlayCry(e.species)
  506.           random1=rand(7) # random message if no special conditions apply
  507.           mapname=$game_map.name # Get's current map name
  508. #===============================================================================
  509. # * Pokemon Messages when Status Condition
  510. #===============================================================================          
  511.           if e.status==PBStatuses::POISON && e.hp>0 && !e.isEgg? # Pokemon Poisoned
  512.             $scene.spriteset.addUserAnimation(Emo_Poison, pos_x, pos_y-2)
  513.             pbWait(120)
  514.             Kernel.pbMessage(_INTL("{1} is shivering with the effects of being poisoned.",e.name))
  515.            
  516.           elsif e.status==PBStatuses::BURN && e.hp>0 && !e.isEgg? # Pokemon Burned
  517.             $scene.spriteset.addUserAnimation(Emo_Hate, pos_x, pos_y-2)
  518.             pbWait(70)
  519.             Kernel.pbMessage(_INTL("{1}'s burn looks painful.",e.name))
  520.            
  521.           elsif e.status==PBStatuses::FROZEN && e.hp>0 && !e.isEgg? # Pokemon Frozen
  522.             $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y-2)
  523.             pbWait(100)
  524.             Kernel.pbMessage(_INTL("{1} seems very cold. It's frozen solid!",e.name))
  525.          
  526.           elsif e.status==PBStatuses::SLEEP && e.hp>0 && !e.isEgg? # Pokemon Asleep
  527.             $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y-2)
  528.             pbWait(100)
  529.             Kernel.pbMessage(_INTL("{1} seems really tired.",e.name))
  530.            
  531.           elsif e.status==PBStatuses::PARALYSIS && e.hp>0 && !e.isEgg? # Pokemon Paralyzed
  532.             $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y-2)
  533.             pbWait(100)
  534.             Kernel.pbMessage(_INTL("{1} is standing still and twitching.",e.name))
  535. #===============================================================================
  536. # * Pokemon is holding an item on a Specific Map
  537. #===============================================================================          
  538.           elsif $game_variables[ItemWalk]==15 and mapname=="Item Map" # Pokemon has item and is on map "Item Map"
  539.             items=[:MASTERBALL,:MASTERBALL] # This array can be edited and extended. Look at the one below for a guide
  540.             random2=0
  541.             loop do
  542.               random2=rand(items.length)
  543.               break if hasConst?(PBItems,items[random2])
  544.             end
  545.             Kernel.pbMessage(_INTL("{1} seems to be holding something.",e.name))
  546.             Kernel.pbPokemonFound(getConst(PBItems,items[random2]))
  547.             $game_variables[ItemWalk]=0
  548. #===============================================================================
  549. # * Pokemon is holding an item on any other map
  550. #===============================================================================            
  551.           elsif $game_variables[ItemWalk]==15 # Pokemon has Item
  552.             items=[:POTION,:SUPERPOTION,:FULLRESTORE,:REVIVE,:PPUP,
  553.                  :PPMAX,:RARECANDY,:REPEL,:MAXREPEL,:ESCAPEROPE,
  554.                  :HONEY,:TINYMUSHROOM,:PEARL,:NUGGET,:GREATBALL,
  555.                  :ULTRABALL,:THUNDERSTONE,:MOONSTONE,:SUNSTONE,:DUSKSTONE,
  556.                  :REDAPRICORN,:BLUAPRICORN,:YLWAPRICORN,:GRNAPRICORN,:PNKAPRICORN,
  557.                  :BLKAPRICORN,:WHTAPRICORN
  558.             ]
  559.             random2=0
  560.             loop do
  561.               random2=rand(items.length)
  562.               break if hasConst?(PBItems,items[random2])
  563.             end
  564.  
  565.             Kernel.pbMessage(_INTL("{1} seems to be holding something.",e.name))
  566.             Kernel.pbPokemonFound(getConst(PBItems,items[random2]))
  567.             $game_variables[ItemWalk]=0
  568. #===============================================================================
  569. # * Examples of Map Specific Messages
  570. #===============================================================================
  571.           elsif mapname=="Dusk Forest" && e.hasType?(:BUG) # Bug Type in Dusk Forest
  572.             $scene.spriteset.addUserAnimation(Emo_sing, pos_x, pos_y-2)
  573.             pbWait(50)
  574.             random3=rand(3)
  575.             if random3==0
  576.               Kernel.pbMessage(_INTL("{1} seems highly interested in the trees.",e.name,$Trainer.name))
  577.             elsif random3==1
  578.               Kernel.pbMessage(_INTL("{1} seems to enjoy the buzzing of the bug Pokémon.",e.name,$Trainer.name))
  579.             elsif random3==2
  580.               Kernel.pbMessage(_INTL("{1} is jumping around restlessly in the forest.",e.name,$Trainer.name))
  581.             end
  582.          
  583.           elsif mapname=="Old Lab" # In the Old Lab
  584.             $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y-2)
  585.             pbWait(100)
  586.             random3=rand(3)
  587.             if random3==0
  588.               Kernel.pbMessage(_INTL("{1} is touching some kind of switch.",e.name,$Trainer.name))
  589.             elsif random3==1
  590.               Kernel.pbMessage(_INTL("{1} has a cord in its mouth!",e.name,$Trainer.name))
  591.             elsif random3==2
  592.               Kernel.pbMessage(_INTL("{1} seems to want to touch the machinery.",e.name,$Trainer.name))
  593.             end  
  594.            
  595.           elsif mapname=="Home" # In the Player's Home
  596.             $scene.spriteset.addUserAnimation(Emo_Happy, pos_x, pos_y-2)
  597.             pbWait(70)
  598.             random3=rand(3)
  599.             if random3==0
  600.               Kernel.pbMessage(_INTL("{1} is sniffing around the room.",e.name,$Trainer.name))
  601.             elsif random3==1
  602.               Kernel.pbMessage(_INTL("{1} noticed {2}'s mom is nearby.",e.name,$Trainer.name))
  603.             elsif random3==2
  604.               Kernel.pbMessage(_INTL("{1} seems to want to settle down at home.",e.name,$Trainer.name))
  605.             end
  606. #===============================================================================
  607. # * Pokemon Messages when birthday
  608. # * Support for Pokemon Birthsigns script
  609. #===============================================================================          
  610.           elsif defined?(e.isBirthday?) && e.isBirthday?
  611.             $scene.spriteset.addUserAnimation(Emo_Cake, pos_x, pos_y-2)
  612.             pbWait(50)
  613.             messages=rand(10)
  614.             case messages
  615.             when 0
  616.               Kernel.pbMessage(_INTL("{1} seems to be reminiscing on all it has learned in the last year.",e.name,$Trainer.name))
  617.             when 1
  618.               Kernel.pbMessage(_INTL("{1} seems glad to be spending its birthday with {2}.",e.name,$Trainer.name))
  619.             when 2
  620.               Kernel.pbMessage(_INTL("{1} is having the best birthday ever!",e.name,$Trainer.name))
  621.             when 3
  622.               Kernel.pbMessage(_INTL("{1} can't believe its been a whole year already!",e.name,$Trainer.name))
  623.             when 4
  624.               Kernel.pbMessage(_INTL("{1} seems to be sniffing around for presents...",e.name,$Trainer.name))
  625.             when 5
  626.               Kernel.pbMessage(_INTL("{1} seems a bit out of breath...\nYou're getting old!",e.name,$Trainer.name))
  627.             when 6
  628.               Kernel.pbMessage(_INTL("{1} looks ready to party!",e.name,$Trainer.name))
  629.             when 7
  630.               Kernel.pbMessage(_INTL("You wish {1} a happy birthday.\nHappy birthday, {1}!",e.name,$Trainer.name))
  631.             when 8
  632.               Kernel.pbMessage(_INTL("{1} seems to be looking forward to another year with {2}.",e.name,$Trainer.name))
  633.             when 9
  634.               Kernel.pbMessage(_INTL("{1} wants to eat some cake!",e.name,$Trainer.name))
  635.             end
  636. #===============================================================================
  637. # * Random Messages if none of the above apply
  638. #===============================================================================            
  639.           elsif random1==0 # Music Note
  640.             $scene.spriteset.addUserAnimation(Emo_sing, pos_x, pos_y-2)
  641.             pbWait(50)
  642.             random3=rand(5)
  643.             if random3==0
  644.               Kernel.pbMessage(_INTL("{1} seems to want to play with {2}.",e.name,$Trainer.name))
  645.             elsif random3==1
  646.               Kernel.pbMessage(_INTL("{1} is singing and humming.",e.name,$Trainer.name))
  647.             elsif random3==2
  648.               Kernel.pbMessage(_INTL("{1} is looking up at the sky.",e.name,$Trainer.name))
  649.             elsif random3==3
  650.               Kernel.pbMessage(_INTL("{1} swayed and danced around as it pleased.",e.name,$Trainer.name))
  651.             elsif random3==4
  652.               Kernel.pbMessage(_INTL("{1} is pulling out the grass.",e.name,$Trainer.name))
  653.             end
  654.            
  655.           elsif random1==1 # Hate/Angry Face
  656.             $scene.spriteset.addUserAnimation(Emo_Hate, pos_x, pos_y-2)
  657.             pbWait(70)
  658.             random3=rand(5)
  659.             if random3==0
  660.               Kernel.pbMessage(_INTL("{1} let out a roar!",e.name,$Trainer.name))
  661.             elsif random3==1
  662.               Kernel.pbMessage(_INTL("{1} is making a face like it's angry!",e.name,$Trainer.name))
  663.             elsif random3==2
  664.               Kernel.pbMessage(_INTL("{1} seems to be angry for some reason.",e.name,$Trainer.name))
  665.             elsif random3==3
  666.               Kernel.pbMessage(_INTL("{1} chewed on your feet.",e.name,$Trainer.name))
  667.             elsif random3==4
  668.               Kernel.pbMessage(_INTL("{1} is trying to be intimidating.",e.name,$Trainer.name))
  669.             end
  670.            
  671.           elsif random1==2 # ... Emoji
  672.             $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y-2)
  673.             pbWait(70)
  674.             random3=rand(5)
  675.             if random3==0
  676.               Kernel.pbMessage(_INTL("{1} is looking down steadily.",e.name,$Trainer.name))
  677.             elsif random3==1
  678.               Kernel.pbMessage(_INTL("{1} is sniffing at the floor.",e.name,$Trainer.name))
  679.             elsif random3==2
  680.               Kernel.pbMessage(_INTL("{1} is concentrating deeply.",e.name,$Trainer.name))
  681.             elsif random3==3
  682.               Kernel.pbMessage(_INTL("{1} faced this way and nodded.",e.name,$Trainer.name))
  683.             elsif random3==4
  684.               Kernel.pbMessage(_INTL("{1} is glaring straight into {2}'s eyes.",e.name,$Trainer.name))
  685.             end
  686.            
  687.           elsif random1==3 # Happy Face
  688.             $scene.spriteset.addUserAnimation(Emo_Happy, pos_x, pos_y-2)
  689.             pbWait(70)
  690.             random3=rand(5)
  691.             if random3==0
  692.               Kernel.pbMessage(_INTL("{1} began poking you in the stomach.",e.name,$Trainer.name))
  693.             elsif random3==1
  694.               Kernel.pbMessage(_INTL("{1} looks very happy.",e.name,$Trainer.name))
  695.             elsif random3==2
  696.               Kernel.pbMessage(_INTL("{1} happily cuddled up to you.",e.name,$Trainer.name))
  697.             elsif random3==3
  698.               Kernel.pbMessage(_INTL("{1} is so happy that it can't stand still.",e.name,$Trainer.name))
  699.             elsif random3==4
  700.               Kernel.pbMessage(_INTL("{1} looks like it wants to lead!",e.name,$Trainer.name))
  701.             end
  702.            
  703.           elsif random1==4 # Heart Emoji
  704.             $scene.spriteset.addUserAnimation(Emo_love, pos_x, pos_y-2)
  705.             pbWait(70)
  706.             random3=rand(5)
  707.             if random3==0
  708.               Kernel.pbMessage(_INTL("{1} suddenly started walking closer.",e.name,$Trainer.name))
  709.             elsif random3==1
  710.               Kernel.pbMessage(_INTL("Woah! {1} suddenly hugged {2}.",e.name,$Trainer.name))
  711.             elsif random3==2
  712.               Kernel.pbMessage(_INTL("{1} is rubbing up against you.",e.name,$Trainer.name))
  713.             elsif random3==3
  714.               Kernel.pbMessage(_INTL("{1} is keeping close to {2}.",e.name,$Trainer.name))
  715.             elsif random3==4
  716.               Kernel.pbMessage(_INTL("{1} blushed.",e.name,$Trainer.name))
  717.             end
  718.            
  719.           elsif random1==5 # No Emoji
  720.             random3=rand(5)
  721.             if random3==0
  722.               Kernel.pbMessage(_INTL("{1} spun around in a circle!",e.name,$Trainer.name))
  723.             elsif random3==1
  724.               Kernel.pbMessage(_INTL("{1} let our a battle cry.",e.name,$Trainer.name))
  725.             elsif random3==2
  726.               Kernel.pbMessage(_INTL("{1} is on the lookout!",e.name,$Trainer.name))
  727.             elsif random3==3
  728.               Kernel.pbMessage(_INTL("{1} is standing patiently.",e.name,$Trainer.name))
  729.             elsif random3==4
  730.               Kernel.pbMessage(_INTL("{1} is looking around restlessly.",e.name,$Trainer.name))
  731.             end
  732. #===============================================================================
  733. # * This random message shows the Pokemon's Happiness Level
  734. #===============================================================================            
  735.           elsif random1==6 # Check Happiness Level
  736.             if e.happiness>0 && e.happiness<=50
  737.               $scene.spriteset.addUserAnimation(Emo_Hate, pos_x, pos_y-2)
  738.               pbWait(70)
  739.               Kernel.pbMessage(_INTL("{1} hates to travel with {2}.",e.name,$Trainer.name))
  740.             elsif e.happiness>50 && e.happiness<=100
  741.               $scene.spriteset.addUserAnimation(Emo_Normal, pos_x, pos_y-2)
  742.               pbWait(100)
  743.               Kernel.pbMessage(_INTL("{1} is still unsure about traveling with {2} is a good thing or not.",e.name,$Trainer.name))
  744.             elsif e.happiness>100 && e.happiness<150
  745.               $scene.spriteset.addUserAnimation(Emo_Happy, pos_x, pos_y-2)
  746.               Kernel.pbMessage(_INTL("{1} is happy traveling with {2}.",e.name,$Trainer.name))
  747.             elsif e.happiness>=150
  748.               $scene.spriteset.addUserAnimation(Emo_love, pos_x, pos_y-2)
  749.               pbWait(70)
  750.               Kernel.pbMessage(_INTL("{1} loves traveling with {2}.",e.name,$Trainer.name))
  751.             end
  752.           end
  753.         else
  754.         end
  755.     end
  756.   end
  757. end
  758. #===============================================================================
  759. # * Pokemon reapear after using surf
  760. #===============================================================================
  761. def Come_back(shiny=nil, animation=nil)
  762.   return if !$game_variables[Following_Activated_Switch]
  763.   return if $Trainer.party.length==0
  764.   $PokemonTemp.dependentEvents.pbMoveDependentEvents
  765.   events=$PokemonGlobal.dependentEvents
  766.   if $game_variables[Current_Following_Variable]==$Trainer.party[0]
  767.     remove_sprite(false)
  768.     if $scene.is_a?(Scene_Map)
  769.       for i in 0...events.length
  770.         $scene.spriteset.addUserAnimation(Animation_Come_Out,@realEvents[i].x,@realEvents[i].y)
  771.       end
  772.     end
  773.   end
  774.   if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg?
  775.     $game_variables[Current_Following_Variable]=$Trainer.party[0]
  776.     refresh_sprite(animation)
  777.   end
  778.   for i in 0...events.length
  779.     if events[i] && events[i][8]=="Dependent"
  780.       id = $Trainer.party[0].species
  781.       tgender = ($Trainer.party[0].gender==1)? "f" : ""
  782.       tshiny  = ($Trainer.party[0].isShiny?)? "s" : ""
  783.       tform   = ($Trainer.party[0].form && $Trainer.party[0].form>0) ? "_#{$Trainer.party[0].form}" : ""
  784.       tshadow = ($Trainer.party[0].shadow)? "_shadow": ""
  785.       speciesname = getConstantName(PBSpecies,id)
  786.       bitmapFileName=sprintf("%s%s%s%s%s",speciesname,tgender,tshiny,tform,tshadow)
  787.       if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  788.         events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  789.         @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  790.       else
  791.         bitmapFileName=sprintf("%s%s",speciesname,tshiny)
  792.         if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  793.           events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  794.           @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  795.         else
  796.           bitmapFileName=sprintf("%s",speciesname)
  797.           if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  798.             events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  799.             @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  800.           else  
  801.             bitmapFileName=sprintf("%03d%s%s%s%s",id,tgender,tshiny,tform,tshadow)
  802.             if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  803.               events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  804.               @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  805.             else  
  806.               bitmapFileName=sprintf("%03d%s",id,tshiny)
  807.               if pbResolveBitmap(FOLLOWER_FILE_PATH+FOLLOWER_FILE_DIR+bitmapFileName)
  808.                 events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  809.                 @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  810.               else
  811.                 bitmapFileName=sprintf("%03d",id)
  812.                 events[i][6] = FOLLOWER_FILE_DIR+bitmapFileName
  813.                 @realEvents[i].character_name=FOLLOWER_FILE_DIR+bitmapFileName
  814.               end
  815.             end
  816.           end
  817.         end
  818.       end
  819.     end
  820.   end
  821. end
  822. #===============================================================================
  823. # * check_faint
  824. # * If current Pokemon is fainted, removes the sprite
  825. #===============================================================================
  826. def check_faint
  827.   return if !$game_switches[Following_Activated_Switch] || $Trainer.party.length<=0
  828.   if $PokemonGlobal.bicycle
  829.     return
  830.   elsif $PokemonGlobal.diving && WATERPOKEMONCANDIVE && $Trainer.party[0].hasType?(:WATER)
  831.     return
  832.   elsif $PokemonGlobal.surfing && WATERPOKEMONCANSURF && $Trainer.party[0].hasType?(:WATER)
  833.     return
  834.   elsif $PokemonGlobal.surfing && ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  835.         isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  836.         ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  837.         !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  838.     return
  839.   else
  840.     if $Trainer.party[0].hp<=0
  841.       $game_variables[Current_Following_Variable]=0
  842.       remove_sprite
  843.     elsif $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $game_variables[Current_Following_Variable]==0
  844.         $game_variables[Current_Following_Variable]=$Trainer.party[0]
  845.         refresh_sprite
  846.     end
  847.   end
  848. end
  849. #===============================================================================
  850. # * SetMoveRoute
  851. # * Used in the "Control Following Pokemon" Script listed farther above
  852. #===============================================================================
  853. def SetMoveRoute(commands,waitComplete=true)
  854.     events=$PokemonGlobal.dependentEvents
  855.     for i in 0...events.length
  856.       if events[i] && events[i][8]=="Dependent"
  857.         pbMoveRoute(@realEvents[i],commands,waitComplete)
  858.       end
  859.     end
  860.   end
  861. end
  862.  
  863.  
  864.  
  865. #===============================================================================
  866. # * Update followers for surfing
  867. # * Non-follower dependent events not allowed
  868. #===============================================================================
  869. def Kernel.pbSurf
  870.   if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  871.     return false
  872.   end
  873.   if $DEBUG ||
  874.     (HIDDENMOVESCOUNTBADGES ? $Trainer.numbadges>=BADGEFORSURF : $Trainer.badges[BADGEFORSURF])
  875.     movefinder=Kernel.pbCheckMove(:SURF)
  876.     if $DEBUG || movefinder
  877.       if Kernel.pbConfirmMessage(_INTL("The water is dyed a deep blue...  Would you like to surf?"))
  878.         speciesname=!movefinder ? $Trainer.name : movefinder.name
  879.         Kernel.pbMessage(_INTL("{1} used Surf!",speciesname))
  880.         pbHiddenMoveAnimation(movefinder)
  881.         surfbgm=pbGetMetadata(0,MetadataSurfBGM)
  882.         $PokemonTemp.dependentEvents.check_surf(true)
  883.         if surfbgm
  884.           pbCueBGM(surfbgm,0.5)
  885.         end
  886.         pbStartSurfing()
  887.         return true
  888.       end
  889.     end
  890.   end
  891.   return false
  892. end
  893.  
  894. alias follow_pbStartSurfing pbStartSurfing
  895. def pbStartSurfing()
  896.   follow_pbStartSurfing
  897.   $PokemonGlobal.surfing=true
  898. end
  899.  
  900. alias follow_pbEndSurf pbEndSurf
  901. def pbEndSurf(xOffset,yOffset)
  902.   ret = follow_pbEndSurf(xOffset,yOffset)
  903.   if $game_switches[Toggle_Following_Switch] && ret && $game_variables[Current_Following_Variable]!=0
  904.     if WATERPOKEMONCANSURF && $Trainer.party[0].hasType?(:WATER)
  905.       $PokemonTemp.dependentEvents.Come_back($Trainer.party[0].isShiny?,false)
  906.     elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  907.         isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  908.         ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  909.         !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  910.         $PokemonTemp.dependentEvents.Come_back($Trainer.party[0].isShiny?,false)
  911.     else
  912.       $PokemonTemp.dependentEvents.Come_back(true)
  913.     end
  914.   end
  915. end
  916.  
  917. #===============================================================================
  918. # * Auto add Script to Kernel.pbCanUseHiddenMove, fix HM bug
  919. # * Fixed so non-pokemon follower dependent events will return false
  920. #===============================================================================
  921. def Kernel.pbCanUseHiddenMove?(pkmn,move,showmsg=true)
  922.   case move
  923.     when PBMoves::FLY
  924.       if !$DEBUG && !$Trainer.badges[BADGEFORFLY]
  925.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  926.         return false
  927.       end
  928.      if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  929.        Kernel.pbMessage(_INTL("You can't use that if you have someone with you.")) if showmsg
  930.        return false
  931.      end
  932.       if !pbGetMetadata($game_map.map_id,MetadataOutdoor)
  933.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  934.         return false
  935.       end
  936.       return true
  937.     when PBMoves::CUT
  938.       if !$DEBUG && !$Trainer.badges[BADGEFORCUT]
  939.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  940.         return false
  941.       end
  942.       facingEvent=$game_player.pbFacingEvent
  943.       if !facingEvent || facingEvent.name!="Tree"
  944.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  945.         return false
  946.       end
  947.       return true
  948.     when PBMoves::HEADBUTT
  949.       facingEvent=$game_player.pbFacingEvent
  950.       if !facingEvent || facingEvent.name!="HeadbuttTree"
  951.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  952.         return false
  953.       end
  954.       return true
  955.     when PBMoves::SURF
  956.       terrain=Kernel.pbFacingTerrainTag
  957.       if !$DEBUG && !$Trainer.badges[BADGEFORSURF]
  958.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  959.         return false
  960.       end
  961.       if $PokemonGlobal.surfing
  962.         Kernel.pbMessage(_INTL("You're already surfing.")) if showmsg
  963.         return false
  964.       end
  965.       if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  966.          Kernel.pbMessage(_INTL("You can't use that if you have someone with you.")) if showmsg
  967.          return false
  968.       end
  969.       terrain=Kernel.pbFacingTerrainTag
  970.       if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
  971.         Kernel.pbMessage(_INTL("Let's enjoy cycling!")) if showmsg
  972.         return false
  973.       end
  974.       if !PBTerrain.isWater?(terrain)
  975.         Kernel.pbMessage(_INTL("No surfing here!")) if showmsg
  976.         return false
  977.       end
  978.       return true
  979.     when PBMoves::STRENGTH
  980.       if !$DEBUG && !$Trainer.badges[BADGEFORSTRENGTH]
  981.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  982.         return false
  983.       end
  984.       facingEvent=$game_player.pbFacingEvent
  985.       if !facingEvent || facingEvent.name!="Boulder"
  986.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  987.         return false
  988.       end
  989.       return true  
  990.     when PBMoves::ROCKSMASH
  991.       terrain=Kernel.pbFacingTerrainTag
  992.       if !$DEBUG && !$Trainer.badges[BADGEFORROCKSMASH]
  993.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  994.         return false
  995.       end
  996.       facingEvent=$game_player.pbFacingEvent
  997.       if !facingEvent || facingEvent.name!="Rock"
  998.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  999.         return false
  1000.       end
  1001.       return true  
  1002.     when PBMoves::FLASH
  1003.       if !$DEBUG && !$Trainer.badges[BADGEFORFLASH]
  1004.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  1005.         return false
  1006.       end
  1007.       if !pbGetMetadata($game_map.map_id,MetadataDarkMap)
  1008.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1009.         return false
  1010.       end
  1011.       if $PokemonGlobal.flashUsed
  1012.         Kernel.pbMessage(_INTL("This is in use already.")) if showmsg
  1013.         return false
  1014.       end
  1015.       return true
  1016.     when PBMoves::WATERFALL
  1017.       if !$DEBUG && !$Trainer.badges[BADGEFORWATERFALL]
  1018.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  1019.         return false
  1020.       end
  1021.       terrain=Kernel.pbFacingTerrainTag
  1022.       if terrain!=PBTerrain::Waterfall
  1023.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1024.         return false
  1025.       end
  1026.       return true
  1027.     when PBMoves::DIVE
  1028.       if !$DEBUG && !$Trainer.badges[BADGEFORDIVE]
  1029.         Kernel.pbMessage(_INTL("Sorry, a new Badge is required.")) if showmsg
  1030.         return false
  1031.       end
  1032.       if $PokemonGlobal.diving
  1033.         return true
  1034.       end
  1035.       if $game_player.terrain_tag!=PBTerrain::DeepWater
  1036.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1037.         return false
  1038.       end
  1039.       if !pbGetMetadata($game_map.map_id,MetadataDiveMap)
  1040.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1041.         return false
  1042.       end
  1043.       return true
  1044.     when PBMoves::TELEPORT
  1045.       if !pbGetMetadata($game_map.map_id,MetadataOutdoor)
  1046.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1047.         return false
  1048.       end
  1049.      if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  1050.        Kernel.pbMessage(_INTL("You can't use that if you have someone with you.")) if showmsg
  1051.        return false
  1052.      end
  1053.       healing=$PokemonGlobal.healingSpot
  1054.       if !healing
  1055.         healing=pbGetMetadata(0,MetadataHome) # Home
  1056.       end
  1057.       if healing
  1058.         mapname=pbGetMapNameFromId(healing[0])
  1059.         if Kernel.pbConfirmMessage(_INTL("Want to return to the healing spot used last in {1}?",mapname))
  1060.           return true
  1061.         end
  1062.         return false
  1063.       else
  1064.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1065.         return false
  1066.       end
  1067.     when PBMoves::DIG
  1068.       escape=($PokemonGlobal.escapePoint rescue nil)
  1069.       if !escape || escape.empty?
  1070.         Kernel.pbMessage(_INTL("Can't use that here.")) if showmsg
  1071.         return false
  1072.       end
  1073.       if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  1074.         Kernel.pbMessage(_INTL("You can't use that if you have someone with you.")) if showmsg
  1075.         return false
  1076.       end
  1077.       mapname=pbGetMapNameFromId(escape[0])
  1078.       if Kernel.pbConfirmMessage(_INTL("Want to escape from here and return to {1}?",mapname))
  1079.         return true
  1080.       end
  1081.       return false
  1082.     when PBMoves::SWEETSCENT
  1083.       return true
  1084.     else
  1085.       return HiddenMoveHandlers.triggerCanUseMove(move,pkmn)
  1086.     end
  1087.   return false
  1088. end
  1089.  
  1090.  
  1091. #===============================================================================
  1092. # * Modifies bike scripts to properly affect the follower sprites
  1093. #===============================================================================
  1094. module Kernel
  1095.   class << self
  1096.     alias follow_pbDismountBike pbDismountBike
  1097.     alias follow_pbMountBike pbMountBike
  1098.     alias follow_pbCancelVehicles pbCancelVehicles
  1099.   end
  1100.  
  1101.   def self.pbDismountBike
  1102.     return if !$PokemonGlobal.bicycle
  1103.     ret=follow_pbDismountBike
  1104.     if $game_switches[Toggle_Following_Switch]
  1105.       $PokemonTemp.dependentEvents.Come_back(true)
  1106.     end
  1107.     $PokemonTemp.dependentEvents.refresh_sprite
  1108.     return ret
  1109.   end
  1110.  
  1111.   def self.pbMountBike
  1112.     ret=follow_pbMountBike
  1113.     if $game_switches[Toggle_Following_Switch]
  1114.       if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
  1115.         $PokemonTemp.dependentEvents.remove_sprite
  1116.       else
  1117.         $PokemonTemp.dependentEvents.remove_sprite(true)
  1118.       end
  1119.     end
  1120.     return ret
  1121.   end
  1122.  
  1123.   def self.pbCancelVehicles(destination=nil)
  1124.     if $game_switches[Toggle_Following_Switch] && ($PokemonGlobal.bicycle ||
  1125.                                                     $PokemonGlobal.diving) &&
  1126.                                                     destination.nil?
  1127.       $PokemonTemp.dependentEvents.Come_back(false)
  1128.     end
  1129.     return follow_pbCancelVehicles(destination)
  1130.   end
  1131.  
  1132. end
  1133.  
  1134. #===============================================================================
  1135. # * Replaces pbBikeCheck
  1136. # * Can still reject for dependent events if the pokemon follower has been removed
  1137. #===============================================================================
  1138. def pbBikeCheck
  1139.   if $PokemonGlobal.surfing ||
  1140.      (!$PokemonGlobal.bicycle && pbGetTerrainTag==PBTerrain::TallGrass)
  1141.     Kernel.pbMessage(_INTL("Can't use that here."))
  1142.     return false
  1143.   end
  1144.   if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  1145.     Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
  1146.     return false
  1147.   end
  1148.   if $PokemonGlobal.bicycle
  1149.     if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
  1150.       Kernel.pbMessage(_INTL("You can't dismount your Bike here."))
  1151.       return false
  1152.     end
  1153.     return true
  1154.   else
  1155.     val=pbGetMetadata($game_map.map_id,MetadataBicycle)
  1156.     val=pbGetMetadata($game_map.map_id,MetadataOutdoor) if val==nil
  1157.     if !val
  1158.       Kernel.pbMessage(_INTL("Can't use that here."))
  1159.       return false
  1160.     end
  1161.     return true
  1162.   end
  1163. end
  1164.  
  1165.  
  1166.  
  1167. #===============================================================================
  1168. # * Refresh follower after accessing TrainerPC
  1169. #===============================================================================
  1170. alias follow_pbTrainerPC pbTrainerPC
  1171. def pbTrainerPC
  1172.   follow_pbTrainerPC
  1173.   $PokemonTemp.dependentEvents.refresh_sprite
  1174. end
  1175. #===============================================================================
  1176. # * Refresh follower after accessing TrainerPC
  1177. #===============================================================================
  1178. class TrainerPC
  1179.  
  1180.   alias follow_access access
  1181.   def access
  1182.     follow_access
  1183.     $PokemonTemp.dependentEvents.refresh_sprite
  1184.   end
  1185. end
  1186. #===============================================================================
  1187. # * Auto add Script to pbPokeCenterPC
  1188. #===============================================================================
  1189. alias follow_pbPokeCenterPC pbPokeCenterPC
  1190. def pbPokeCenterPC
  1191.   follow_pbPokeCenterPC
  1192.   $PokemonTemp.dependentEvents.refresh_sprite
  1193. end
  1194. #===============================================================================
  1195. #Fix for followers having animations (grass, etc) when toggled off
  1196. #Treats followers as if they are under a bridge when toggled
  1197. #===============================================================================
  1198. alias follow_pbGetTerrainTag pbGetTerrainTag
  1199. def pbGetTerrainTag(event=nil,countBridge=false)
  1200.   ret=follow_pbGetTerrainTag(event,countBridge)
  1201.   if event && event!=$game_player
  1202.     for devent in $PokemonGlobal.dependentEvents
  1203.       if event.id==devent[1] && (!$game_switches[Toggle_Following_Switch] ||
  1204.                                   $Trainer.party.length==0 ||
  1205.                                   $Trainer.party[0].isEgg? || $Trainer.party[0].hp<=0)
  1206.         ret = PBTerrain::Bridge
  1207.         break
  1208.       end
  1209.     end
  1210.   end
  1211.   return ret
  1212. end
  1213.  
  1214.  
  1215.  
  1216.  
  1217. #===============================================================================
  1218. # * Start Pokemon Following
  1219. # * x is the Event ID that will become the follower
  1220. #===============================================================================
  1221. def pbPokemonFollow(x)
  1222.   Kernel.pbAddDependency2(x, "Dependent", Unused_Common_Event)
  1223.   $PokemonTemp.dependentEvents.refresh_sprite
  1224.   $PokemonTemp.dependentEvents.Come_back(nil,false)
  1225.   $game_switches[Following_Activated_Switch]=true
  1226.   $game_switches[Toggle_Following_Switch]=true
  1227. end
  1228.  
  1229.  
  1230. def pbTestPass(follower,x,y,direction=nil)
  1231.   ret = $MapFactory.isPassable?(follower.map.map_id,x,y,follower)
  1232.   if !ret && $PokemonGlobal.bridge>0&&
  1233.           PBTerrain.isBridge?($MapFactory.getTerrainTag(follower.map.map_id,x,y))
  1234.     ret = true
  1235.   end
  1236.   return ret
  1237. end
  1238.  
  1239.  
  1240. class DependentEvents
  1241.  
  1242.   def pbFollowEventAcrossMaps(leader,follower,instant=false,leaderIsTrueLeader=true)
  1243.     d=leader.direction
  1244.     areConnected=$MapFactory.areConnected?(leader.map.map_id,follower.map.map_id)
  1245.     # Get the rear facing tile of leader
  1246.     facingDirection=[0,0,8,0,6,0,4,0,2][d]
  1247.     if !leaderIsTrueLeader && areConnected
  1248.       relativePos=$MapFactory.getThisAndOtherEventRelativePos(leader,follower)
  1249.       if (relativePos[1]==0 && relativePos[0]==2) # 2 spaces to the right of leader
  1250.         facingDirection=6
  1251.       elsif (relativePos[1]==0 && relativePos[0]==-2) # 2 spaces to the left of leader
  1252.         facingDirection=4
  1253.       elsif relativePos[1]==-2 && relativePos[0]==0 # 2 spaces above leader
  1254.         facingDirection=8
  1255.       elsif relativePos[1]==2 && relativePos[0]==0 # 2 spaces below leader
  1256.         facingDirection=2
  1257.       end
  1258.     end
  1259.     facings=[facingDirection] # Get facing from behind
  1260.     facings.push([0,0,4,0,8,0,2,0,6][d]) # Get right facing
  1261.     facings.push([0,0,6,0,2,0,8,0,4][d]) # Get left facing
  1262.     if !leaderIsTrueLeader
  1263.       facings.push([0,0,2,0,4,0,6,0,8][d]) # Get forward facing
  1264.     end
  1265.     mapTile=nil
  1266.     if areConnected
  1267.       bestRelativePos=-1
  1268.       oldthrough=follower.through
  1269.       follower.through=false
  1270.       for i in 0...facings.length
  1271.         facing=facings[i]
  1272.         tile=$MapFactory.getFacingTile(facing,leader)
  1273.         passable=tile && $MapFactory.isPassable?(tile[0],tile[1],tile[2],follower)
  1274.         if !passable && $PokemonGlobal.bridge>0
  1275.           passable = PBTerrain.isBridge?($MapFactory.getTerrainTag(tile[0],tile[1],tile[2]))
  1276.         elsif passable && !$PokemonGlobal.surfing && $PokemonGlobal.bridge==0      
  1277.           passable=!PBTerrain.isWater?($MapFactory.getTerrainTag(tile[0],tile[1],tile[2]))
  1278.         end
  1279.         if i==0 && !passable && tile &&
  1280.            $MapFactory.getTerrainTag(tile[0],tile[1],tile[2],true)==PBTerrain::Ledge &&
  1281.            $PokemonGlobal.bridge==0
  1282.           # If the tile isn't passable and the tile is a ledge,
  1283.           # get tile from further behind
  1284.           tile=$MapFactory.getFacingTileFromPos(tile[0],tile[1],tile[2],facing)
  1285.           passable=tile && $MapFactory.isPassable?(tile[0],tile[1],tile[2],follower)
  1286.           if passable && !$PokemonGlobal.surfing
  1287.             passable=!PBTerrain.isWater?($MapFactory.getTerrainTag(tile[0],tile[1],tile[2]))
  1288.           end
  1289.         end
  1290.         if passable
  1291.           relativePos=$MapFactory.getThisAndOtherPosRelativePos(
  1292.              follower,tile[0],tile[1],tile[2])
  1293.           distance=Math.sqrt(relativePos[0]*relativePos[0]+relativePos[1]*relativePos[1])
  1294.           if bestRelativePos==-1 || bestRelativePos>distance
  1295.             bestRelativePos=distance
  1296.             mapTile=tile
  1297.           end
  1298.           if i==0 && distance<=1 # Prefer behind if tile can move up to 1 space
  1299.             break
  1300.           end
  1301.         end
  1302.       end
  1303.       follower.through=oldthrough
  1304.     else
  1305.       tile=$MapFactory.getFacingTile(facings[0],leader)
  1306.       passable=tile && $MapFactory.isPassable?(
  1307.          tile[0],tile[1],tile[2],follower)
  1308.       mapTile=passable ? mapTile : nil
  1309.     end
  1310.     if mapTile && follower.map.map_id==mapTile[0]
  1311.       # Follower is on same map
  1312.       newX=mapTile[1]
  1313.       newY=mapTile[2]
  1314.       deltaX=(d == 6 ? -1 : d == 4 ? 1 : 0)
  1315.       deltaY=(d == 2 ? -1 : d == 8 ? 1 : 0)
  1316.       posX = newX + deltaX
  1317.       posY = newY + deltaY
  1318.       follower.move_speed=leader.move_speed # sync movespeed
  1319.       if (follower.x-newX==-1 && follower.y==newY) ||
  1320.          (follower.x-newX==1 && follower.y==newY) ||
  1321.          (follower.y-newY==-1 && follower.x==newX) ||
  1322.          (follower.y-newY==1 && follower.x==newX)
  1323.         if instant
  1324.           follower.moveto(newX,newY)
  1325.         else
  1326.           pbFancyMoveTo(follower,newX,newY)
  1327.         end
  1328.       elsif (follower.x-newX==-2 && follower.y==newY) ||
  1329.             (follower.x-newX==2 && follower.y==newY) ||
  1330.             (follower.y-newY==-2 && follower.x==newX) ||
  1331.             (follower.y-newY==2 && follower.x==newX)
  1332.         if instant
  1333.           follower.moveto(newX,newY)
  1334.         else
  1335.           pbFancyMoveTo(follower,newX,newY)
  1336.         end
  1337.       elsif follower.x!=posX || follower.y!=posY
  1338.         if instant
  1339.           follower.moveto(newX,newY)
  1340.         else
  1341.           pbFancyMoveTo(follower,posX,posY)
  1342.           pbFancyMoveTo(follower,newX,newY)
  1343.         end
  1344.       end
  1345.     else
  1346.       if !mapTile
  1347.         # Make current position into leader's position
  1348.         mapTile=[leader.map.map_id,leader.x,leader.y]
  1349.       end
  1350.       if follower.map.map_id==mapTile[0]
  1351.         # Follower is on same map as leader
  1352.         follower.moveto(leader.x,leader.y)
  1353.         #pbTurnTowardEvent(follower,leader)
  1354.       else
  1355.         # Follower will move to different map
  1356.         events=$PokemonGlobal.dependentEvents
  1357.         eventIndex=pbEnsureEvent(follower,mapTile[0])
  1358.         if eventIndex>=0
  1359.           newFollower=@realEvents[eventIndex]
  1360.           newEventData=events[eventIndex]
  1361.           newFollower.moveto(mapTile[1],mapTile[2])
  1362.           newEventData[3]=mapTile[1]
  1363.           newEventData[4]=mapTile[2]
  1364.           if mapTile[0]==leader.map.map_id
  1365.             #pbTurnTowardEvent(follower,leader)
  1366.           end
  1367.         end
  1368.       end
  1369.     end
  1370.   end
  1371.  
  1372.   #Fix follower not being in the same spot upon save
  1373.   def pbMapChangeMoveDependentEvents
  1374.     return
  1375.   end
  1376. end
  1377.  
  1378.  
  1379.  
  1380. class DependentEventSprites
  1381.  
  1382.   attr_accessor :sprites
  1383.  
  1384.   def refresh
  1385.     for sprite in @sprites
  1386.       sprite.dispose
  1387.     end
  1388.     @sprites.clear
  1389.     $PokemonTemp.dependentEvents.eachEvent {|event,data|
  1390.        if data[0]==@map.map_id # Check original map
  1391.          #@map.events[data[1]].erase
  1392.        end
  1393.        if data[2]==@map.map_id # Check current map
  1394.          spr = Sprite_Character.new(@viewport,event)
  1395.          spr.setReflection(event, @viewport)
  1396.          @sprites.push(spr)
  1397.        end
  1398.     }
  1399.   end
  1400.  
  1401.   def update
  1402.     if $PokemonTemp.dependentEvents.lastUpdate!=@lastUpdate
  1403.       refresh
  1404.       @lastUpdate=$PokemonTemp.dependentEvents.lastUpdate
  1405.     end
  1406.     for sprite in @sprites
  1407.       sprite.update
  1408.     end
  1409.     for i in 0...@sprites.length
  1410.       pbDayNightTint(@sprites[i])
  1411.       if $game_switches[Toggle_Following_Switch] && APPLYSTATUSTONES && $Trainer.party[0] && $Trainer.party[0].hp>0
  1412.         case $Trainer.party[0].status
  1413.         when PBStatuses::BURN
  1414.           @sprites[i].tone.set(@sprites[i].tone.red+BURNTONE[0],@sprites[i].tone.green+BURNTONE[1],@sprites[i].tone.blue+BURNTONE[2],@sprites[i].tone.gray+BURNTONE[3])
  1415.         when PBStatuses::POISON
  1416.           @sprites[i].tone.set(@sprites[i].tone.red+POISONTONE[0],@sprites[i].tone.green+POISONTONE[1],@sprites[i].tone.blue+POISONTONE[2],@sprites[i].tone.gray+POISONTONE[3])
  1417.         when PBStatuses::PARALYSIS
  1418.           @sprites[i].tone.set(@sprites[i].tone.red+PARALYSISTONE[0],@sprites[i].tone.green+PARALYSISTONE[1],@sprites[i].tone.blue+PARALYSISTONE[2],@sprites[i].tone.gray+PARALYSISTONE[3])
  1419.         when PBStatuses::FROZEN
  1420.           @sprites[i].tone.set(@sprites[i].tone.red+FREEZETONE[0],@sprites[i].tone.green+FREEZETONE[1],@sprites[i].tone.blue+FREEZETONE[2],@sprites[i].tone.gray+FREEZETONE[3])
  1421.         when PBStatuses::SLEEP
  1422.           @sprites[i].tone.set(@sprites[i].tone.red+SLEEPTONE[0],@sprites[i].tone.green+SLEEPTONE[1],@sprites[i].tone.blue+SLEEPTONE[2],@sprites[i].tone.gray+SLEEPTONE[3])
  1423.         end
  1424.       end
  1425.     end
  1426.   end
  1427.  
  1428. end
  1429.  
  1430.  
  1431. #Refresh following pokemon after switching pokemon around
  1432. class PokemonPartyScreen
  1433.  
  1434.   alias follow_pbSwitch pbSwitch
  1435.   def pbSwitch(oldid,newid)
  1436.     follow_pbSwitch(oldid,newid)
  1437.     $PokemonTemp.dependentEvents.refresh_sprite(false)
  1438.   end
  1439.  
  1440.   alias follow_pbRefreshSingle pbRefreshSingle
  1441.   def pbRefreshSingle(pkmnid)
  1442.     follow_pbRefreshSingle(pkmnid)
  1443.     $PokemonTemp.dependentEvents.refresh_sprite(false)
  1444.   end
  1445.  
  1446. end
  1447.  
  1448. #Refresh after evolution
  1449. class PokemonEvolutionScene
  1450.  
  1451.   alias follow_pbEndScreen pbEndScreen
  1452.   def pbEndScreen
  1453.     follow_pbEndScreen
  1454.     if @pokemon==$Trainer.party[0]
  1455.       $PokemonTemp.dependentEvents.refresh_sprite(false)
  1456.     end
  1457.   end
  1458.  
  1459. end
  1460.  
  1461. #Update follower's following time
  1462. class Game_Player < Game_Character
  1463.  
  1464.   alias follow_update update
  1465.   def update
  1466.     follow_update
  1467.     $PokemonTemp.dependentEvents.add_following_time
  1468.   end
  1469.  
  1470.   alias follow_moveto moveto
  1471.   def moveto(x,y)
  1472.     ret = follow_moveto(x,y)
  1473.     events=$PokemonGlobal.dependentEvents
  1474.     leader=$game_player
  1475.     for i in 0...events.length
  1476.       event=$PokemonTemp.dependentEvents.realEvents[i]
  1477.       $PokemonTemp.dependentEvents.pbFollowEventAcrossMaps(leader,event,true,i==0)
  1478.     end
  1479.     return ret
  1480.   end
  1481.  
  1482. end
  1483.  
  1484. #Update follower after battle
  1485. class PokeBattle_Scene
  1486.  
  1487.   alias follow_pbEndBattle pbEndBattle
  1488.   def pbEndBattle(result)
  1489.     follow_pbEndBattle(result)
  1490.     $PokemonTemp.dependentEvents.check_faint
  1491.   end
  1492.  
  1493. end
  1494.  
  1495. #Script for when a pokemon finds an item in the field
  1496. class PokemonField
  1497.  
  1498.   def Kernel.pbPokemonFound(item,quantity=1,plural=nil)
  1499.     itemname=PBItems.getName(item)
  1500.     pocket=pbGetPocket(item)
  1501.     e=$Trainer.party[0].name
  1502.     if $PokemonBag.pbStoreItem(item,quantity)
  1503.       pbWait(5)
  1504.       if $ItemData[item][ITEMUSE]==3 || $ItemData[item][ITEMUSE]==4
  1505.         Kernel.pbMessage(_INTL("\\se[]{1} found {2}!\\se[itemlevel]\\nIt contained {3}.\\wtnp[30]",e,itemname,PBMoves.getName($ItemData[item][ITEMMACHINE])))
  1506.         Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the {3} Pocket.",$Trainer.name,itemname,PokemonBag.pocketNames()[pocket]))
  1507.       elsif PBItems.const_defined?(:LEFTOVERS) && isConst?(item,PBItems,:LEFTOVERS)
  1508.         Kernel.pbMessage(_INTL("\\se[]{1} found some {2}!\\se[itemlevel]\\wtnp[30]",e,itemname))
  1509.         Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the {3} Pocket.",$Trainer.name,itemname,PokemonBag.pocketNames()[pocket]))
  1510.       else
  1511.         if quantity>1
  1512.           if plural
  1513.             Kernel.pbMessage(_INTL("\\se[]{1} found {2} {3}!\\se[itemlevel]\\wtnp[30]",e,quantity,plural))
  1514.             Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the {3} Pocket.",$Trainer.name,plural,PokemonBag.pocketNames()[pocket]))
  1515.           else
  1516.             Kernel.pbMessage(_INTL("\\se[]{1} found {2} {3}s!\\se[itemlevel]\\wtnp[30]",e,quantity,itemname))
  1517.             Kernel.pbMessage(_INTL("{1} put the {2}s\r\nin the {3} Pocket.",$Trainer.name,itemname,PokemonBag.pocketNames()[pocket]))
  1518.           end
  1519.         else
  1520.           Kernel.pbMessage(_INTL("\\se[]{1} found one {2}!\\se[itemlevel]\\wtnp[30]",e,itemname))
  1521.           Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the {3} Pocket.",$Trainer.name,itemname,PokemonBag.pocketNames()[pocket]))
  1522.         end
  1523.       end
  1524.       return true
  1525.     else   # Can't add the item
  1526.       if $ItemData[item][ITEMUSE]==3 || $ItemData[item][ITEMUSE]==4
  1527.         Kernel.pbMessage(_INTL("{1} found {2}!\\wtnp[20]",e,itemname))
  1528.       elsif PBItems.const_defined?(:LEFTOVERS) && isConst?(item,PBItems,:LEFTOVERS)
  1529.         Kernel.pbMessage(_INTL("{1} found some {2}!\\wtnp[20]",$Trainer.name,itemname))
  1530.       else
  1531.         if quantity>1
  1532.           if plural
  1533.             Kernel.pbMessage(_INTL("{1} found {2} {3}!\\wtnp[20]",e,quantity,plural))
  1534.           else
  1535.             Kernel.pbMessage(_INTL("{1} found {2} {3}s!\\wtnp[20]",$Trainer.name,quantity,itemname))
  1536.           end
  1537.         else
  1538.           Kernel.pbMessage(_INTL("{1} found one {2}!\\wtnp[20]",e,itemname))
  1539.         end
  1540.       end
  1541.       Kernel.pbMessage(_INTL("Too bad... The Bag is full..."))
  1542.       return false
  1543.     end
  1544.   end
  1545. end
  1546.  
  1547. $IssueStop = false
  1548.  
  1549. #Toggle follower, cycle through pokemon in field
  1550. class Scene_Map
  1551.  
  1552.   alias follow_update update
  1553.   def update
  1554.     follow_update
  1555.     return if $FollowerMoveRoute
  1556.     for i in 0...$PokemonGlobal.dependentEvents.length
  1557.       event=$PokemonTemp.dependentEvents.realEvents[i]
  1558.       return if event.move_route_forcing
  1559.     end    
  1560.     if $game_switches[Following_Activated_Switch] && $Trainer.party.length>0
  1561.       if Input.trigger?(Input::C) # try to talk to pokemon
  1562.         $PokemonTemp.dependentEvents.talk_to_pokemon
  1563.       end
  1564.       # Pokemon always move if switch is on, have flying type, or are in a settings array
  1565.       moving = Input.press?(Input::DOWN) || Input.press?(Input::UP) ||
  1566.                 Input.press?(Input::RIGHT) || Input.press?(Input::LEFT)
  1567.       if (ALWAYS_ANIMATE || $game_player.moving? || moving ||
  1568.         $Trainer.party[0].hasType?(:FLYING) ||
  1569.         isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  1570.         ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  1571.         !$PokemonGlobal.surfing
  1572.           if !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  1573.             $PokemonTemp.dependentEvents.update_stepping
  1574.           end
  1575.       elsif $PokemonGlobal.surfing && $Trainer.party[0].hasType?(:WATER)
  1576.         if !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  1577.           $PokemonTemp.dependentEvents.update_stepping
  1578.         end
  1579.       elsif $PokemonGlobal.surfing &&
  1580.                 ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  1581.                 isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  1582.                 ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  1583.                 !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species)) &&
  1584.                 $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg?
  1585.           $PokemonTemp.dependentEvents.update_stepping
  1586.       elsif $PokemonGlobal.diving && $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $Trainer.party[0].hasType?(:WATER)  && WATERPOKEMONCANDIVE
  1587.             $PokemonTemp.dependentEvents.update_stepping
  1588.       else
  1589.             $PokemonTemp.dependentEvents.stop_stepping
  1590.       end
  1591.       if Input.trigger?(Input::CTRL) && (ALLOWTOGGLEFOLLOW || TEMPALLOWTOGGLE) && !$PokemonGlobal.bicycle
  1592.         if $PokemonGlobal.surfing
  1593.           if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $Trainer.party[0].hasType?(:WATER)
  1594.             if WATERPOKEMONCANSURF
  1595.               pbToggleFollowingPokemon
  1596.             end
  1597.           elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  1598.             isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  1599.             ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  1600.             !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species))
  1601.            
  1602.             pbToggleFollowingPokemon
  1603.           end
  1604.         elsif $PokemonGlobal.diving
  1605.           if $Trainer.party[0].hp>0 && !$Trainer.party[0].isEgg? && $Trainer.party[0].hasType?(:WATER)
  1606.             if WATERPOKEMONCANDIVE
  1607.               pbToggleFollowingPokemon
  1608.             end
  1609.           end
  1610.         else
  1611.           pbToggleFollowingPokemon
  1612.         end
  1613.       end
  1614.       if ALLOWFIELDSWITCHING && !$PokemonGlobal.bicycle
  1615.         tlength=$Trainer.party.length-1
  1616.         tparty=$Trainer.party
  1617.         return if tlength<=0
  1618.         if Input.trigger?(Input::X) && $Trainer.party.size > 1
  1619.           tparty.push(tparty.delete_at(0))
  1620.           if $game_switches[Toggle_Following_Switch]
  1621.             if $PokemonGlobal.surfing
  1622.               if tparty[0].hp>0 && !tparty[0].isEgg? && tparty[0].hasType?(:WATER)
  1623.                 $PokemonTemp.dependentEvents.refresh_sprite
  1624.               elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  1625.                 isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  1626.                 ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  1627.                 !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species)) &&
  1628.                 tparty[0].hp>0 && !tparty[0].isEgg?
  1629.                
  1630.                 $PokemonTemp.dependentEvents.refresh_sprite
  1631.               else
  1632.                 $PokemonTemp.dependentEvents.refresh_sprite(false)
  1633.               end
  1634.               if tparty[tlength].hp>0 && !tparty[tlength].isEgg? && tparty[tlength].hasType?(:WATER)
  1635.                 $PokemonTemp.dependentEvents.check_surf(true)
  1636.               elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[tlength].hasType?(:FLYING) ||
  1637.                 isConst?($Trainer.party[tlength].ability,PBAbilities,:LEVITATE) ||
  1638.                 ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[tlength].species)) &&
  1639.                 !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[tlength].species)) &&
  1640.                 tparty[tlength].hp>0 && !tparty[tlength].isEgg?
  1641.                
  1642.                 $PokemonTemp.dependentEvents.check_surf(true)
  1643.               else
  1644.                 $PokemonTemp.dependentEvents.check_surf(false)
  1645.               end
  1646.             elsif $PokemonGlobal.diving
  1647.               if tparty[0].hp>0 && !tparty[0].isEgg? && tparty[0].hasType?(:WATER) && WATERPOKEMONCANDIVE
  1648.                 $PokemonTemp.dependentEvents.refresh_sprite
  1649.               end
  1650.               if tparty[tlength].hp>0 && !tparty[tlength].isEgg? && tparty[tlength].hasType?(:WATER) && WATERPOKEMONCANDIVE
  1651.                 $PokemonTemp.dependentEvents.check_surf(true)
  1652.               end
  1653.             else
  1654.               $PokemonTemp.dependentEvents.refresh_sprite
  1655.             end
  1656.           end
  1657.         end
  1658.         if Input.trigger?(Input::Z) && $Trainer.party.size > 1
  1659.           $Trainer.party.insert(0,$Trainer.party.pop)
  1660.           if $game_switches[Toggle_Following_Switch]
  1661.             if $PokemonGlobal.surfing
  1662.               if tparty[0].hp>0 && !tparty[0].isEgg? && tparty[0].hasType?(:WATER)
  1663.                 $PokemonTemp.dependentEvents.refresh_sprite
  1664.               elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[0].hasType?(:FLYING) ||
  1665.                 isConst?($Trainer.party[0].ability,PBAbilities,:LEVITATE) ||
  1666.                 ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[0].species)) &&
  1667.                 !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[0].species)) &&
  1668.                 tparty[0].hp>0 && !tparty[0].isEgg?
  1669.                
  1670.                 $PokemonTemp.dependentEvents.refresh_sprite
  1671.                
  1672.               else
  1673.                 $PokemonTemp.dependentEvents.refresh_sprite(false)
  1674.               end
  1675.               if tparty[1].hp>0 && !tparty[1].isEgg? && tparty[1].hasType?(:WATER)
  1676.                 $PokemonTemp.dependentEvents.check_surf(true)
  1677.               elsif ALWAYS_ANIMATED_CAN_SURF && ($Trainer.party[1].hasType?(:FLYING) ||
  1678.                 isConst?($Trainer.party[1].ability,PBAbilities,:LEVITATE) ||
  1679.                 ALWAYS_ANIMATED_FOLLOWERS.include?($Trainer.party[1].species)) &&
  1680.                 !(ALWAYS_ANIMATED_EXCEPTION.include?($Trainer.party[1].species)) &&
  1681.                 tparty[1].hp>0 && !tparty[1].isEgg?
  1682.                
  1683.                 $PokemonTemp.dependentEvents.check_surf(true)
  1684.               else
  1685.                 $PokemonTemp.dependentEvents.check_surf(false)
  1686.               end
  1687.             elsif $PokemonGlobal.diving
  1688.                if tparty[0].hp>0 && !tparty[0].isEgg? && tparty[0].hasType?(:WATER)  && WATERPOKEMONCANDIVE
  1689.                 $PokemonTemp.dependentEvents.refresh_sprite
  1690.               end
  1691.               if tparty[1].hp>0 && !tparty[1].isEgg? && tparty[1].hasType?(:WATER) && WATERPOKEMONCANDIVE
  1692.                 $PokemonTemp.dependentEvents.check_surf(true)
  1693.               end
  1694.             else
  1695.               $PokemonTemp.dependentEvents.refresh_sprite
  1696.             end
  1697.           end
  1698.         end
  1699.       end
  1700.     end
  1701.   end
  1702.  
  1703.   alias follow_transfer transfer_player
  1704.   def transfer_player(cancelVehicles=true)
  1705.     follow_transfer(cancelVehicles)
  1706.     events=$PokemonGlobal.dependentEvents
  1707.     $PokemonTemp.dependentEvents.updateDependentEvents
  1708.     leader=$game_player
  1709.     for i in 0...events.length
  1710.       event=$PokemonTemp.dependentEvents.realEvents[i]
  1711.       $PokemonTemp.dependentEvents.pbFollowEventAcrossMaps(leader,event,false,i==0)
  1712.     end
  1713.   end
  1714.  
  1715. end
  1716.  
  1717. #Fix follower landing on player when transfering
  1718. $NeedFollowerUpdate = false
  1719. #Don't try to unlock the follower events
  1720. class Interpreter
  1721.  
  1722.   def command_end
  1723.     # Clear list of event commands
  1724.     @list = nil
  1725.     # If main map event and event ID are valid
  1726.     if @main && @event_id > 0 && !($game_map.events[@event_id] && $game_map.events[@event_id].name=="Dependent")
  1727.       # Unlock event
  1728.       $game_map.events[@event_id].unlock if $game_map.events[@event_id]
  1729.     end
  1730.     if $NeedFollowerUpdate
  1731.       events=$PokemonGlobal.dependentEvents
  1732.       $PokemonTemp.dependentEvents.updateDependentEvents
  1733.       leader=$game_player
  1734.       for i in 0...events.length
  1735.         event=$PokemonTemp.dependentEvents.realEvents[i]
  1736.         $PokemonTemp.dependentEvents.pbFollowEventAcrossMaps(leader,event,false,i==0)
  1737.       end
  1738.       $NeedFollowerUpdate=true
  1739.     end
  1740.   end
  1741.  
  1742.   alias follow_201 command_201
  1743.   def command_201
  1744.     ret=follow_201
  1745.     $NeedFollowerUpdate=true
  1746.     return ret
  1747.   end
  1748.  
  1749. end
  1750.  
  1751.  
  1752. # Fix other events walking through dependent events
  1753. class Game_Map
  1754.  
  1755.   alias follow_passable? passable?
  1756.   def passable?(x, y, d, self_event=nil)
  1757.     ret=follow_passable?(x,y,d,self_event)
  1758.     if !ret && !$game_temp.player_transferring && $game_player.pbHasDependentEvents? && $game_switches[Toggle_Following_Switch] &&
  1759.        self_event != $game_player
  1760.          dependent=pbGetDependency("Dependent")
  1761.          if dependent != nil && self_event != dependent
  1762.            if dependent.x==x && dependent.y==y
  1763.              return false
  1764.            end
  1765.          end
  1766.     end
  1767.     return ret
  1768.    end
  1769.    
  1770. end
  1771.  
  1772.  
  1773. #Fix blacking out
  1774. #overwrite starting over to fix black out error
  1775. def Kernel.pbStartOver(gameover=false)
  1776.   if pbInBugContest?
  1777.     Kernel.pbBugContestStartOver
  1778.     return
  1779.   end
  1780.   pbHealAll()
  1781.   if $PokemonGlobal.pokecenterMapId && $PokemonGlobal.pokecenterMapId>=0
  1782.     if gameover
  1783.       Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]After the unfortunate defeat, {1} scurried to a Pokémon Center.",$Trainer.name))
  1784.     else
  1785.       Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]{1} scurried to a Pokémon Center, protecting the exhausted and fainted Pokémon from further harm.",$Trainer.name))
  1786.     end
  1787.     Kernel.pbCancelVehicles
  1788.     pbRemoveDependencies() if !$game_switches[Following_Activated_Switch]
  1789.     $game_switches[STARTING_OVER_SWITCH]=true
  1790.     $game_temp.player_new_map_id=$PokemonGlobal.pokecenterMapId
  1791.     $game_temp.player_new_x=$PokemonGlobal.pokecenterX
  1792.     $game_temp.player_new_y=$PokemonGlobal.pokecenterY
  1793.     $game_temp.player_new_direction=$PokemonGlobal.pokecenterDirection
  1794.     $scene.transfer_player if $scene.is_a?(Scene_Map)
  1795.     $game_map.refresh
  1796.   else
  1797.     homedata=pbGetMetadata(0,MetadataHome)
  1798.     if (homedata && !pbRxdataExists?(sprintf("Data/Map%03d",homedata[0])) )
  1799.       if $DEBUG
  1800.         Kernel.pbMessage(_ISPRINTF("Can't find the map 'Map{1:03d}' in the Data folder. The game will resume at the player's position.",homedata[0]))
  1801.       end
  1802.       pbHealAll()
  1803.       return
  1804.     end
  1805.     if gameover
  1806.       Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]After the unfortunate defeat, {1} scurried home.",$Trainer.name))
  1807.     else
  1808.       Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]{1} scurried home, protecting the exhausted and fainted Pokémon from further harm.",$Trainer.name))
  1809.     end
  1810.     if homedata
  1811.       Kernel.pbCancelVehicles
  1812.       pbRemoveDependencies() if !$game_switches[Following_Activated_Switch]
  1813.       $game_switches[STARTING_OVER_SWITCH]=true
  1814.       $game_temp.player_new_map_id=homedata[0]
  1815.       $game_temp.player_new_x=homedata[1]
  1816.       $game_temp.player_new_y=homedata[2]
  1817.       $game_temp.player_new_direction=homedata[3]
  1818.       $scene.transfer_player if $scene.is_a?(Scene_Map)
  1819.       $game_map.refresh
  1820.     else
  1821.       pbHealAll()
  1822.     end
  1823.   end
  1824.   pbToggleFollowingPokemon(false) if $game_switches[Following_Activated_Switch] && $game_switches[Toggle_Following_Switch]
  1825.   $TEMPALLOWTOGGLE = true;
  1826.   pbEraseEscapePoint
  1827. end
  1828.  
  1829. #Fix Escape Rope
  1830. ItemHandlers::UseInField.add(:ESCAPEROPE,proc{|item|
  1831.    escape=($PokemonGlobal.escapePoint rescue nil)
  1832.    if !escape || escape==[]
  1833.      Kernel.pbMessage(_INTL("Can't use that here."))
  1834.      next
  1835.    end
  1836.    if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  1837.      Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
  1838.      next
  1839.    end
  1840.    Kernel.pbMessage(_INTL("{1} used the {2}.",$Trainer.name,PBItems.getName(item)))
  1841.    pbFadeOutIn(99999){
  1842.       Kernel.pbCancelVehicles
  1843.       $game_temp.player_new_map_id=escape[0]
  1844.       $game_temp.player_new_x=escape[1]
  1845.       $game_temp.player_new_y=escape[2]
  1846.       $game_temp.player_new_direction=escape[3]
  1847.       $scene.transfer_player
  1848.       $game_map.autoplay
  1849.       $game_map.refresh
  1850.    }
  1851.    $TEMPALLOWTOGGLE = true;
  1852.    pbEraseEscapePoint
  1853. })
  1854.  
  1855.  
  1856. ItemHandlers::UseFromBag.add(:ESCAPEROPE,proc{|item|
  1857.    if $game_player.pbHasDependentEvents? && !$game_switches[Following_Activated_Switch]
  1858.      Kernel.pbMessage(_INTL("It can't be used when you have someone with you."))
  1859.      next 0
  1860.    end
  1861.    if ($PokemonGlobal.escapePoint rescue false) && $PokemonGlobal.escapePoint.length>0
  1862.      next 4 # End screen and consume item
  1863.    else
  1864.      Kernel.pbMessage(_INTL("Can't use that here."))
  1865.      next 0
  1866.    end
  1867. })
  1868.  
  1869.  
  1870. #Update sprites on give item
  1871. class PokemonPartyScreen
  1872.  
  1873.   alias follow_pbPokemonGiveScreen pbPokemonGiveScreen
  1874.   def pbPokemonGiveScreen(item)
  1875.     ret=follow_pbPokemonGiveScreen(item)
  1876.     $PokemonTemp.dependentEvents.refresh_sprite(false) if ret
  1877.     return ret
  1878.   end
  1879.  
  1880. end
  1881.  
  1882. #Update sprites on use item
  1883. module ItemHandlers
  1884.  
  1885.   class << self
  1886.     alias follow_triggerUseOnPokemon triggerUseOnPokemon
  1887.   end
  1888.  
  1889.   def self.triggerUseOnPokemon(item,pokemon,scene)
  1890.     ret = follow_triggerUseOnPokemon(item,pokemon,scene)
  1891.     $PokemonTemp.dependentEvents.refresh_sprite(false) if ret
  1892.     return ret
  1893.   end
  1894.  
  1895. end
  1896.  
  1897. class Sprite_Character < RPG::Sprite
  1898.  
  1899.   def setReflection(event, viewport)
  1900.     @reflection = Sprite_Reflection.new(self,event,viewport)
  1901.   end
  1902. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×