Class: PFM::Wild_RoamingInfo

Inherits:
Object
  • Object
show all
Defined in:
scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb

Overview

Wild Roaming Pokemon informations

Author:

  • Nuri Yuri

Constant Summary collapse

RoamingProcs =

The proc takes the Wild_RoamingInfo in parameter and change the informations.

[
  proc do |infos|
    infos.map_id = 1
    infos.zone_type = 1
    infos.tag = 1
  end,
  proc do |infos|
    maps = [25, 46, 35, 27] # Maps where the pokemon can spawn
    if (infos.map_id == $game_map.map_id && infos.spotted) || infos.map_id == -1
      infos.map_id = (maps - [infos.map_id]).sample
      infos.spotted = false
    end
    infos.zone_type = 1
    infos.tag = 0
  end
]
@@locked =

True if the roaming informations can't be updated

true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pokemon, chance, zone_proc_id) ⇒ Wild_RoamingInfo

Create a new Wild_RoamingInfo

Parameters:

  • pokemon (PFM::Pokemon)

    the roaming Pokemon

  • chance (Integer)

    the chance divider to see the Pokemon

  • zone_proc_id (Integer)

    ID of the Wild_RoamingInfo::RoamingProcs



36
37
38
39
40
41
42
43
44
45
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 36

def initialize(pokemon, chance, zone_proc_id)
  @pokemon = pokemon
  @proc_id = zone_proc_id
  @map_id = -1
  @chance = chance
  @tag = 0
  @zone_type = -1
  @spotted = true
  update
end

Instance Attribute Details

#map_idInteger

The ID of the map in which the Roaming Pokemon will appear

Returns:



13
14
15
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 13

def map_id
  @map_id
end

#pokemonPFM::Pokemon (readonly)

The roaming Pokemon

Returns:



16
17
18
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 16

def pokemon
  @pokemon
end

#spottedBoolean

The spotted state of the pokemon. True if the player look at the map position or after fighting the roaming pokemon

Returns:

  • (Boolean)


19
20
21
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 19

def spotted
  @spotted
end

#tagInteger

The tag in which the Roaming Pokemon will appear

Returns:



7
8
9
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 7

def tag
  @tag
end

#zone_typeInteger

The system_tag zone ID in which the Roaming Pokemon will appear

Returns:



10
11
12
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 10

def zone_type
  @zone_type
end

Class Method Details

.lock

Disallow roaming informations to be updated



28
29
30
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 28

def self.lock
  @@locked = true
end

.unlock

Allow roaming informations to be updated



24
25
26
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 24

def self.unlock
  @@locked = false
end

Instance Method Details

#appearing?Boolean

Test if the Roaming Pokemon is appearing (to start the battle)

Returns:

  • (Boolean)


60
61
62
63
64
65
66
67
68
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 60

def appearing?
  return false if @pokemon.hp <= 0
  if @map_id == $game_map.map_id &&
     @zone_type == $env.get_zone_type(true) &&
     @tag == $game_player.terrain_tag
    return rand(@chance) == 0
  end
  return false
end

#could_appear?Boolean

Test if the Roaming Pokemon could appear here

Returns:

  • (Boolean)


72
73
74
75
76
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 72

def could_appear?
  return (@map_id == $game_map.map_id &&
    @zone_type == $env.get_zone_type(true) &&
    @tag == $game_player.terrain_tag)
end

#pokemon_dead?Boolean

Test if the Pokemon is dead (delete from the stack)

Returns:

  • (Boolean)


54
55
56
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 54

def pokemon_dead?
  @pokemon.dead?
end

#update

Call the Roaming Proc to update the Roaming Pokemon zone information



48
49
50
# File 'scripts/01450 Systems/99991 Wild/00300 Wild_RoamingInfo.rb', line 48

def update
  RoamingProcs[@proc_id]&.call(self) unless @@locked
end