Advertisement
cilerba

Untitled

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