Module: Yuki::FollowMe
- Defined in:
- scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb,
scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb
Overview
The Player Follower Manager
Class Method Summary collapse
-
.clear
Clears the follower (and dispose them).
-
.dispose
Dispose the follower and release resources.
-
.each_follower(&block)
yield a block on each Followers.
-
.enabled ⇒ Boolean
Tell if the system is enabled or not.
-
.enabled=(state)
Enable or disabled the system.
-
.follower_entities ⇒ Array<#character_name>
Get the follower entities (those giving information about character_name).
-
.get_follower(i) ⇒ Game_Character
Retrieve a follower.
-
.human_count ⇒ Integer
Get the number of human following the player (Heroes from 2 to n+1).
-
.human_count=(count)
Set the number of human following the player.
-
.human_entities ⇒ Array<#character_name>
Get the human follower entities.
-
.in_lets_go_mode? ⇒ Boolean
Is the FollowMe in Let's Go Mode.
-
.init(viewport)
Init the FollowMe on a new viewport.
-
.is_player_follower?(character) ⇒ Boolean
Test if a character is a Follower of the player.
-
.lets_go_mode=(mode)
Set the FollowMe Let's Go Mode state.
-
.other_pokemon_count ⇒ Integer
Get the number of Pokemon from “other_party” following the player.
-
.other_pokemon_count=(count)
Set the number of Pokemon from “other_party” following the player.
-
.other_pokemon_entities ⇒ Array<#character_name>
Get the friend's pokemon follower entities.
-
.particle_push
Push particle of each character if the Follower Manager was in Battle mode.
-
.player_pokemon_entities ⇒ Array<#character_name>
Get the player's pokemon follower entities.
-
.player_pokemon_lets_go_entity ⇒ Array<#character_name>
Get the player's pokemon follower entity if the FollowMe mode is Let's Go.
-
.pokemon_count ⇒ Integer
Get the number of pokemon following the player.
-
.pokemon_count=(count)
Set the number of pokemon following the player.
-
.position_character(c, i)
Sets the default position of a follower.
-
.reset_position
Reset position of each follower to the player (entering in a building).
-
.selected_follower ⇒ Integer
Get the current selected follower (to move using player moveroutes).
-
.selected_follower=(index1)
Set the selected follower.
-
.set_battle_entry(v = true)
Set the Follower Manager in Battle mode.
-
.set_player_follower_particles(value)
Enable / Disable the particles for the player followers.
-
.set_positions(*args)
Sets the position of each follower (Warp).
-
.smart_disable
Smart disable the following system (keep it active when smart_enable is called).
-
.smart_enable
Smart disable the following system (keep it active when smart_enable is called).
-
.update
Update of the Follower Management.
-
.update_follower(last_follower, i, entity, chara_update) ⇒ Game_Character
Update of a single follower.
-
.update_follower_event(last_follower, follower_event)
Function that attempts to set the event as last follower.
Class Method Details
.clear
Clears the follower (and dispose them)
160 161 162 163 164 165 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 160 def clear return unless @followers @followers.each { |i| i&.dispose } @followers.clear end |
.dispose
Dispose the follower and release resources.
252 253 254 255 256 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 252 def dispose @followers&.each { |i| i.dispose if i && !i.disposed? } @followers = nil @viewport = nil end |
.each_follower(&block)
yield a block on each Followers
181 182 183 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 181 def each_follower(&block) @followers&.collect(&:character)&.each(&block) end |
.enabled ⇒ Boolean
Tell if the system is enabled or not
7 8 9 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 7 def enabled $game_switches[Sw::FM_Enabled] end |
.enabled=(state)
Enable or disabled the system
13 14 15 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 13 def enabled=(state) $game_switches[Sw::FM_Enabled] = state end |
.follower_entities ⇒ Array<#character_name>
Get the follower entities (those giving information about character_name)
61 62 63 64 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 61 def follower_entities player_pokemon = in_lets_go_mode? ? player_pokemon_lets_go_entity : player_pokemon_entities return human_entities.concat(player_pokemon).concat(other_pokemon_entities) end |
.get_follower(i) ⇒ Game_Character
Retrieve a follower
170 171 172 173 174 175 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 170 def get_follower(i) if @followers && @followers[i] return @followers[i].character end return $game_player end |
.human_count ⇒ Integer
Get the number of human following the player (Heroes from 2 to n+1)
31 32 33 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 31 def human_count $game_variables[Var::FM_N_Human] end |
.human_count=(count)
Set the number of human following the player
37 38 39 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 37 def human_count=(count) $game_variables[Var::FM_N_Human] = count end |
.human_entities ⇒ Array<#character_name>
Get the human follower entities
68 69 70 71 72 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 68 def human_entities human = (0...human_count).map { |i| $game_actors[i + 2] } human.compact! return human end |
.in_lets_go_mode? ⇒ Boolean
Is the FollowMe in Let's Go Mode
67 68 69 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 67 def in_lets_go_mode? $game_switches[Sw::FollowMe_LetsGoMode] end |
.init(viewport)
Init the FollowMe on a new viewport. Previous Follower are disposed.
15 16 17 18 19 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 15 def init() dispose if @followers @viewport = @followers = [] end |
.is_player_follower?(character) ⇒ Boolean
Test if a character is a Follower of the player
234 235 236 237 238 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 234 def is_player_follower?(character) return false unless @followers return @followers.any? { |follower_sprite| follower_sprite.character == character } end |
.lets_go_mode=(mode)
Set the FollowMe Let's Go Mode state
73 74 75 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 73 def lets_go_mode=(mode) $game_switches[Sw::FollowMe_LetsGoMode] = mode end |
.other_pokemon_count ⇒ Integer
Get the number of Pokemon from “other_party” following the player
55 56 57 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 55 def other_pokemon_count $game_variables[Var::FM_N_Friend] end |
.other_pokemon_count=(count)
Set the number of Pokemon from “other_party” following the player
61 62 63 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 61 def other_pokemon_count=(count) $game_variables[Var::FM_N_Friend] = count end |
.other_pokemon_entities ⇒ Array<#character_name>
Get the friend's pokemon follower entities
94 95 96 97 98 99 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 94 def other_pokemon_entities other_mon = (0...other_pokemon_count).map { |i| $storage.other_party[i] } other_mon.compact! other_mon.reject!(&:dead?) return other_mon end |
.particle_push
Push particle of each character if the Follower Manager was in Battle mode.
246 247 248 249 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 246 def particle_push each_follower(&:particle_push) if @was_fighting @was_fighting = false end |
.player_pokemon_entities ⇒ Array<#character_name>
Get the player's pokemon follower entities
76 77 78 79 80 81 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 76 def player_pokemon_entities player_mon = (0...pokemon_count).map { |i| $actors[i] } player_mon.compact! player_mon.reject!(&:dead?) return player_mon end |
.player_pokemon_lets_go_entity ⇒ Array<#character_name>
Get the player's pokemon follower entity if the FollowMe mode is Let's Go
85 86 87 88 89 90 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 85 def player_pokemon_lets_go_entity follower = $storage.lets_go_follower return [] unless follower && !follower.dead? && $actors.include?(follower) return [follower] end |
.pokemon_count ⇒ Integer
Get the number of pokemon following the player
43 44 45 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 43 def pokemon_count $game_variables[Var::FM_N_Pokem] end |
.pokemon_count=(count)
Set the number of pokemon following the player
49 50 51 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 49 def pokemon_count=(count) $game_variables[Var::FM_N_Pokem] = count end |
.position_character(c, i)
Sets the default position of a follower
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 131 def position_character(c,i) return if $game_variables[Yuki::Var::FM_Sel_Foll] > 0 c1 = (i == 0 ? $game_player : @followers[i - 1].character) x = c1.x y = c1.y if $game_switches[Sw::Env_CanFly] || $game_switches[Sw::FM_NoReset] case c1.direction when 2 y -= 1 when 4 x += 1 when 6 x -= 1 else y += 1 end end c.through = false if c.passable?(x, y, 0) # c1.direction)) #$game_map c.moveto(x, y) else c.moveto(c1.x, c1.y) end c.through = true c.direction = $game_player.direction c.update end |
.reset_position
Reset position of each follower to the player (entering in a building)
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 204 def reset_position return unless @followers $game_player.reset_follower_move @followers.size.times do |i| v = @followers[i] c = v.character x,y = $game_player.x, $game_player.y case $game_player.direction when 2 y -= 1 when 8 y += 1 when 4 x += 1 when 6 x -= 1 end x,y = $game_player.x, $game_player.y if !$game_map.passable?(x,y,$game_player.direction) c.moveto(x,y) c.direction = $game_player.direction c.instance_variable_set(:@memorized_move, nil) c.instance_variable_set(:@memorized_move_arg, nil) c.update v.update v.z -= 1 end end |
.selected_follower ⇒ Integer
Get the current selected follower (to move using player moveroutes)
19 20 21 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 19 def selected_follower $game_variables[Var::FM_Sel_Foll] end |
.selected_follower=(index1)
Set the selected follower
25 26 27 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00001 Config.rb', line 25 def selected_follower=(index1) $game_variables[Var::FM_Sel_Foll] = index1.clamp(0, @followers.size) end |
.set_battle_entry(v = true)
Set the Follower Manager in Battle mode. When getting out of battle every character will get its particle pushed.
241 242 243 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 241 def set_battle_entry(v = true) @was_fighting = v end |
.set_player_follower_particles(value)
Enable / Disable the particles for the player followers
274 275 276 277 278 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 274 def set_player_follower_particles(value) each_follower do |follower| follower.particles_disabled = !value end end |
.set_positions(*args)
Sets the position of each follower (Warp)
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 187 def set_positions(*args) x = y = 0 (args.size / 3).times do |i| next unless (v = @followers[i]) c = v.character x = args[i * 3] y = args[i * 3 + 1] c.moveto(x, y) c.direction = args[i * 3 + 2] c.update c.particle_push v.update end end |
.smart_disable
Smart disable the following system (keep it active when smart_enable is called)
259 260 261 262 263 264 265 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 259 def smart_disable return unless $game_switches[Sw::FM_Enabled] $game_player.set_follower(nil, true) set_player_follower_particles(false) $game_switches[Sw::FM_WasEnabled] = $game_switches[Sw::FM_Enabled] $game_switches[Sw::FM_Enabled] = false end |
.smart_enable
Smart disable the following system (keep it active when smart_enable is called)
268 269 270 271 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 268 def smart_enable set_player_follower_particles(true) $game_switches[Sw::FM_Enabled] = $game_switches[Sw::FM_WasEnabled] end |
.update
Update of the Follower Management. Their graphics are updated here.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 22 def update entities = follower_entities return clear unless enabled last_follower = $game_player follower_event = @followers.find { |follower| follower.character.follower.is_a?(Game_Event) }&.character&.follower follower_event ||= last_follower.follower if last_follower.follower.is_a?(Game_Event) chara_update = selected_follower == 0 # Reset following state last_follower.set_follower(nil, true) @followers.each { |follower| follower.character.set_follower(nil) } # Update each follower entities.each_with_index do |entity, index| last_follower = update_follower(last_follower, index, entity, chara_update) end # Remove the remaining followers @followers.pop&.dispose while @followers.size > entities.size # Update the last follower's follower update_follower_event(last_follower, follower_event) end |
.update_follower(last_follower, i, entity, chara_update) ⇒ Game_Character
Update of a single follower
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 107 def update_follower(last_follower, i, entity, chara_update) follower = @followers[i] unless follower @followers[i] = follower = Sprite_Character.new(@viewport, Game_Character.new) position_character(follower.character, i) follower.character.z = $game_player.z end character = follower.character last_follower.set_follower(character) if chara_update character.character_name = entity.character_name character.is_pokemon = character.step_anime = entity.class == PFM::Pokemon end character.move_speed = $game_player.original_move_speed character.through = true character.update follower.update follower.z -= 1 if character.x == $game_player.x && character.y == $game_player.y return (@followers[i] = follower).character end |
.update_follower_event(last_follower, follower_event)
Function that attempts to set the event as last follower
50 51 52 53 54 55 56 57 |
# File 'scripts/01450 Systems/00003 Map Engine/00002 Logic/00200 FollowMe/00300 Core.rb', line 50 def update_follower_event(last_follower, follower_event) last_follower_event = follower_event while last_follower_event&.follower last_follower_event.set_follower(nil) unless last_follower_event.follower.is_a?(Game_Event) last_follower_event = last_follower_event.follower end last_follower.set_follower(follower_event) if last_follower.follower != follower_event end |