DimbusMaximus

Pokémon Sage Following Pokémon Fix

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