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