Class: PFM::Environment

Inherits:
Object show all
Includes:
GameData::SystemTags
Defined in:
docs/4_Systems_202_Environment.rb

Overview

Environment management (Weather, Zone, etc…)

The global Environment object is stored in $env and PFM.game_state.env

Author:

  • Nuri Yuri

Constant Summary collapse

UNKNOWN_ZONE =

Unkonw location text

'Zone ???'
WEATHER_NAMES =

List of weather symbols

%i[none rain sunny sandstorm hail fog hardsun hardrain strong_winds snow]

Constants included from GameData::SystemTags

GameData::SystemTags::AcroBike, GameData::SystemTags::AcroBikeRL, GameData::SystemTags::AcroBikeUD, GameData::SystemTags::BridgeRL, GameData::SystemTags::BridgeUD, GameData::SystemTags::CrackedSoil, GameData::SystemTags::DeepSwamp, GameData::SystemTags::Empty, GameData::SystemTags::HeadButt, GameData::SystemTags::Hole, GameData::SystemTags::JumpD, GameData::SystemTags::JumpL, GameData::SystemTags::JumpR, GameData::SystemTags::JumpU, GameData::SystemTags::MachBike, GameData::SystemTags::Puddle, GameData::SystemTags::RClimb, GameData::SystemTags::RapidsD, GameData::SystemTags::RapidsL, GameData::SystemTags::RapidsR, GameData::SystemTags::RapidsU, GameData::SystemTags::Road, GameData::SystemTags::RocketD, GameData::SystemTags::RocketL, GameData::SystemTags::RocketR, GameData::SystemTags::RocketRD, GameData::SystemTags::RocketRL, GameData::SystemTags::RocketRR, GameData::SystemTags::RocketRU, GameData::SystemTags::RocketU, GameData::SystemTags::SlopesL, GameData::SystemTags::SlopesR, GameData::SystemTags::StairsD, GameData::SystemTags::StairsL, GameData::SystemTags::StairsR, GameData::SystemTags::StairsU, GameData::SystemTags::StopSlide, GameData::SystemTags::SwampBorder, GameData::SystemTags::TCave, GameData::SystemTags::TGrass, GameData::SystemTags::TIce, GameData::SystemTags::TMount, GameData::SystemTags::TPond, GameData::SystemTags::TSand, GameData::SystemTags::TSea, GameData::SystemTags::TSnow, GameData::SystemTags::TTallGrass, GameData::SystemTags::TUnderWater, GameData::SystemTags::TWetSand, GameData::SystemTags::WaterFall, GameData::SystemTags::Whirlpool, GameData::SystemTags::ZTag

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GameData::SystemTags

gen, system_tag_db_symbol

Constructor Details

#initialize(game_state = PFM.game_state) ⇒ Environment

Create a new Environnement object

Parameters:

  • game_state (PFM::GameState) (defaults to: PFM.game_state)

    variable responsive of containing the whole game state for easier access



28
29
# File 'docs/4_Systems_202_Environment.rb', line 28

def initialize(game_state = PFM.game_state)
end

Instance Attribute Details

#game_statePFM::GameState

Get the game state responsive of the whole game state

Returns:



25
26
27
# File 'docs/4_Systems_202_Environment.rb', line 25

def game_state
  @game_state
end

#last_map_idInteger (readonly)

Last visited map ID

Returns:

  • (Integer)


16
17
18
# File 'docs/4_Systems_202_Environment.rb', line 16

def last_map_id
  @last_map_id
end

#master_zoneInteger (readonly)

Note:

Master zone are used inside Pokemon data

The master zone (zone that show the panel like city, unlike house of city)

Returns:

  • (Integer)


13
14
15
# File 'docs/4_Systems_202_Environment.rb', line 13

def master_zone
  @master_zone
end

#modified_worldmap_positionArray? (readonly)

Return the modified worldmap position or nil

Returns:

  • (Array, nil)


22
23
24
# File 'docs/4_Systems_202_Environment.rb', line 22

def modified_worldmap_position
  @modified_worldmap_position
end

#worldmap_custom_markersArray (readonly)

Custom markers on worldmap

Returns:

  • (Array)


19
20
21
# File 'docs/4_Systems_202_Environment.rb', line 19

def worldmap_custom_markers
  @worldmap_custom_markers
end

Instance Method Details

#add_worldmap_custom_icon(filename, worldmap_id, x, y, ox_mode = :center, oy_mode = :center)

Add the custom marker to the worldmap

Parameters:

  • filename (String)

    the name of the icon in the interface/worldmap/icons directory

  • worldmap_id (Integer)

    the id of the worldmap

  • x (Integer)

    coord x on the worldmap

  • y (Integer)

    coord y on the wolrdmap

  • ox_mode (Symbol, :center) (defaults to: :center)

    :center (the icon will be centered on the tile center), :base

  • oy_mode (Symbol, :center) (defaults to: :center)

    :center (the icon will be centered on the tile center), :base



188
189
# File 'docs/4_Systems_202_Environment.rb', line 188

def add_worldmap_custom_icon(filename, worldmap_id, x, y, ox_mode = :center, oy_mode = :center)
end

#apply_weather(id, duration = nil)

Apply a new weather to the current environment

Parameters:

  • id (Integer, Symbol)

    ID of the weather : 0 = None, 1 = Rain, 2 = Sun/Zenith, 3 = Darud Sandstorm, 4 = Hail, 5 = Foggy

  • duration (Integer, nil) (defaults to: nil)

    the total duration of the weather (battle), nil = never stops



211
212
# File 'docs/4_Systems_202_Environment.rb', line 211

def apply_weather(id, duration = nil)
end

#building?Boolean

Is the player inside a building (and not on a systemtag)

Returns:

  • (Boolean)


32
33
# File 'docs/4_Systems_202_Environment.rb', line 32

def building?
end

#can_fish?Boolean

Can the player fish ?

Returns:

  • (Boolean)


167
168
# File 'docs/4_Systems_202_Environment.rb', line 167

def can_fish?
end

#cave?Boolean

Is the player in a cave ?

Returns:

  • (Boolean)


109
110
# File 'docs/4_Systems_202_Environment.rb', line 109

def cave?
end

#convert_zone_type(system_tag) ⇒ Integer

Convert a system_tag to a zone_type

Parameters:

  • system_tag (Integer)

    the system tag

Returns:

  • (Integer)

    same as get_zone_type



147
148
# File 'docs/4_Systems_202_Environment.rb', line 147

def convert_zone_type(system_tag)
end

#current_weatherInteger

Return the current weather id according to the game state (in battle or not)

Returns:

  • (Integer)


224
225
# File 'docs/4_Systems_202_Environment.rb', line 224

def current_weather
end

#current_weather_db_symbolSymbol

Return the db_symbol of the current weather

Returns:

  • (Symbol)


228
229
# File 'docs/4_Systems_202_Environment.rb', line 228

def current_weather_db_symbol
end

#current_zoneInteger Also known as: get_current_zone

Return the current zone in which the player is

Returns:

  • (Integer)

    the zone ID in the database



50
51
# File 'docs/4_Systems_202_Environment.rb', line 50

def current_zone
end

#current_zone_dataStudio::Zone Also known as: get_current_zone_data

Return the zone data in which the player is

Returns:



55
56
# File 'docs/4_Systems_202_Environment.rb', line 55

def current_zone_data
end

#current_zone_nameString

Return the zone name in which the player is (master zone)

Returns:



60
61
# File 'docs/4_Systems_202_Environment.rb', line 60

def current_zone_name
end

#day?Boolean

Is it day time ?

Returns:

  • (Boolean)


155
156
# File 'docs/4_Systems_202_Environment.rb', line 155

def day?
end

#decrease_weather_durationBoolean

Decrease the weather duration, set it to normal (none = 0) if the duration is less than 0

Returns:

  • (Boolean)

    true = the weather stopped



220
221
# File 'docs/4_Systems_202_Environment.rb', line 220

def decrease_weather_duration
end

#fog?Boolean

Is it foggy ?

Returns:

  • (Boolean)


265
266
# File 'docs/4_Systems_202_Environment.rb', line 265

def fog?
end

#get_event_delete_state(event_id, map_id = @game_state.game_map.map_id) ⇒ Boolean

Get the delete state of an event

Parameters:

  • event_id (Integer)

    id of the event

  • map_id (Integer) (defaults to: @game_state.game_map.map_id)

    id of the map where the event is

Returns:

  • (Boolean)

    if the event is deleted



179
180
# File 'docs/4_Systems_202_Environment.rb', line 179

def get_event_delete_state(event_id, map_id = @game_state.game_map.map_id)
end

#get_worldmap(zone = @zone) ⇒ Integer

Get the worldmap from the zone

Parameters:

  • zone (Integer) (defaults to: @zone)

    <default : current zone>

Returns:

  • (Integer)


88
89
# File 'docs/4_Systems_202_Environment.rb', line 88

def get_worldmap(zone = @zone)
end

#get_zone(x, y, worldmap_id = @worldmap) ⇒ Studio::Zone?

Get the zone data in the worldmap

Parameters:

  • x (Integer)

    the x position of the zone in the World Map

  • y (Integer)

    the y position of the zone in the World Map

  • worldmap_id (Integer) (defaults to: @worldmap)

    <default : @worldmap> the worldmap to refer at

Returns:



72
73
# File 'docs/4_Systems_202_Environment.rb', line 72

def get_zone(x, y, worldmap_id = @worldmap)
end

#get_zone_pos(zone_id, worldmap_id = @worldmap) ⇒ Array(Integer, Integer)

Return the zone coordinate in the worldmap

Parameters:

  • zone_id (Integer)

    id of the zone in the database

  • worldmap_id (Integer) (defaults to: @worldmap)

    <default : @worldmap> the worldmap to refer at

Returns:

  • (Array(Integer, Integer))

    the x,y coordinates



78
79
# File 'docs/4_Systems_202_Environment.rb', line 78

def get_zone_pos(zone_id, worldmap_id = @worldmap)
end

#get_zone_type(ice_prio = false) ⇒ Integer

Return the zone type

Parameters:

  • ice_prio (Boolean) (defaults to: false)

    when on snow for background, return ice ID if player is on ice

Returns:

  • (Integer)

    1 = tall grass, 2 = taller grass, 3 = cave, 4 = mount, 5 = sand, 6 = pond, 7 = sea, 8 = underwater, 9 = snow, 10 = ice, 0 = building



142
143
# File 'docs/4_Systems_202_Environment.rb', line 142

def get_zone_type(ice_prio = false)
end

#grass?Boolean

Is the player standing in grass ?

Returns:

  • (Boolean)


97
98
# File 'docs/4_Systems_202_Environment.rb', line 97

def grass?
end

#hail?Boolean

Does it hail ?

Returns:

  • (Boolean)


257
258
# File 'docs/4_Systems_202_Environment.rb', line 257

def hail?
end

#hardrain?Boolean

Is it hardrainning?

Returns:

  • (Boolean)


236
237
# File 'docs/4_Systems_202_Environment.rb', line 236

def hardrain?
end

#hardsun?Boolean

Is it hardsunny?

Returns:

  • (Boolean)


244
245
# File 'docs/4_Systems_202_Environment.rb', line 244

def hardsun?
end

#ice?Boolean

Is the player on ice ?

Returns:

  • (Boolean)


133
134
# File 'docs/4_Systems_202_Environment.rb', line 133

def ice?
end

#load_zone_information(data, index)

Load the zone information

Parameters:

  • data (Studio::Zone)

    the current zone data

  • index (Integer)

    the index of the zone in the stack



43
44
# File 'docs/4_Systems_202_Environment.rb', line 43

def load_zone_information(data, index)
end

#morning?Boolean

Is it morning time ?

Returns:

  • (Boolean)


159
160
# File 'docs/4_Systems_202_Environment.rb', line 159

def morning?
end

#mount?Boolean

Is the player on a mount ?

Returns:

  • (Boolean)


113
114
# File 'docs/4_Systems_202_Environment.rb', line 113

def mount?
end

#night?Boolean

Is it night time ?

Returns:

  • (Boolean)


151
152
# File 'docs/4_Systems_202_Environment.rb', line 151

def night?
end

#normal?Boolean

Is the weather normal

Returns:

  • (Boolean)


269
270
# File 'docs/4_Systems_202_Environment.rb', line 269

def normal?
end

#pond?Boolean

Is the player on a pond/river ?

Returns:

  • (Boolean)


121
122
# File 'docs/4_Systems_202_Environment.rb', line 121

def pond?
end

#rain?Boolean

Is it rainning?

Returns:

  • (Boolean)


232
233
# File 'docs/4_Systems_202_Environment.rb', line 232

def rain?
end

#remove_worldmap_custom_icon(filename, worldmap_id, x, y)

Remove all custom worldmap icons on the coords

Parameters:

  • filename (String)

    the name of the icon in the interface/worldmap/icons directory

  • worldmap_id (Integer)

    the id of the worldmap

  • x (Integer)

    coord x on the worldmap

  • y (Integer)

    coord y on the wolrdmap



195
196
# File 'docs/4_Systems_202_Environment.rb', line 195

def remove_worldmap_custom_icon(filename, worldmap_id, x, y)
end

#reset_worldmap_position

Reset the modified worldmap position



204
205
# File 'docs/4_Systems_202_Environment.rb', line 204

def reset_worldmap_position
end

#reset_zone

Reset the zone informations to get the zone id with update_zone (Panel display)



46
47
# File 'docs/4_Systems_202_Environment.rb', line 46

def reset_zone
end

#sand?Boolean

Is the player on sand ?

Returns:

  • (Boolean)


117
118
# File 'docs/4_Systems_202_Environment.rb', line 117

def sand?
end

#sandstorm?Boolean

Duuuuuuuuuuuuuuuuuuuuuuun Dun dun dun dun dun dun dun dun dun dun dun dundun dun dundundun dun dun dun dun dun dun dundun dundun

Returns:

  • (Boolean)


253
254
# File 'docs/4_Systems_202_Environment.rb', line 253

def sandstorm?
end

#sea?Boolean

Is the player on a sea/ocean ?

Returns:

  • (Boolean)


125
126
# File 'docs/4_Systems_202_Environment.rb', line 125

def sea?
end

#set_event_delete_state(event_id, map_id = @game_state.game_map.map_id, state = true)

Set the delete state of an event

Parameters:

  • event_id (Integer)

    id of the event

  • map_id (Integer) (defaults to: @game_state.game_map.map_id)

    id of the map where the event is

  • state (Boolean) (defaults to: true)

    new delete state of the event



173
174
# File 'docs/4_Systems_202_Environment.rb', line 173

def set_event_delete_state(event_id, map_id = @game_state.game_map.map_id, state = true)
end

#set_worldmap_position(new_x, new_y, new_worldmap_id = nil)

Overwrite the zone worldmap position

Parameters:

  • new_x (Integer)

    the new x coords on the worldmap

  • new_y (Integer)

    the new y coords on the worldmap

  • new_worldmap_id (Integer, nil) (defaults to: nil)

    the new worldmap id



201
202
# File 'docs/4_Systems_202_Environment.rb', line 201

def set_worldmap_position(new_x, new_y, new_worldmap_id = nil)
end

#snow?Boolean

Is the player on snow or ice ?

Returns:

  • (Boolean)


137
138
# File 'docs/4_Systems_202_Environment.rb', line 137

def snow?
end

#snowing?Boolean

Is it snowing?

Returns:

  • (Boolean)


261
262
# File 'docs/4_Systems_202_Environment.rb', line 261

def snowing?
end

#strong_winds?Boolean

Is it Strong Winds ? (Mega Rayquaza)

Returns:

  • (Boolean)


248
249
# File 'docs/4_Systems_202_Environment.rb', line 248

def strong_winds?
end

#sunny?Boolean

Is it sunny?

Returns:

  • (Boolean)


240
241
# File 'docs/4_Systems_202_Environment.rb', line 240

def sunny?
end

#sunset?Boolean

Is it sunset time ?

Returns:

  • (Boolean)


163
164
# File 'docs/4_Systems_202_Environment.rb', line 163

def sunset?
end

#tall_grass?Boolean

Is the player standing in tall grass ?

Returns:

  • (Boolean)


101
102
# File 'docs/4_Systems_202_Environment.rb', line 101

def tall_grass?
end

#under_water?Boolean

Is the player underwater ?

Returns:

  • (Boolean)


129
130
# File 'docs/4_Systems_202_Environment.rb', line 129

def under_water?
end

#update_zoneInteger, false

Update the zone informations, return the ID of the zone when the player enter in an other zone

Add the zone to the visited zone Array if the zone has not been visited yet

Returns:

  • (Integer, false)

    false = player was in the zone



38
39
# File 'docs/4_Systems_202_Environment.rb', line 38

def update_zone
end

#very_tall_grass?Boolean

Is the player standing in taller grass ?

Returns:

  • (Boolean)


105
106
# File 'docs/4_Systems_202_Environment.rb', line 105

def very_tall_grass?
end

#visited_worldmap?(worldmap) ⇒ Boolean

Test if the given world map has been visited

Parameters:

  • worldmap (Integer)

Returns:

  • (Boolean)


93
94
# File 'docs/4_Systems_202_Environment.rb', line 93

def visited_worldmap?(worldmap)
end

#visited_zone?(zone) ⇒ Boolean

Check if a zone has been visited

Parameters:

  • zone (Integer, Studio::Zone)

    the zone id in the database or the zone

Returns:

  • (Boolean)


83
84
# File 'docs/4_Systems_202_Environment.rb', line 83

def visited_zone?(zone)
end

#warp_zoneInteger Also known as: get_warp_zone

Return the warp zone ID (where the player will teleport with skills)

Returns:

  • (Integer)

    the ID of the zone in the database



64
65
# File 'docs/4_Systems_202_Environment.rb', line 64

def warp_zone
end

#weather_durationNumeric Also known as: get_weather_duration

Return the current weather duration

Returns:

  • (Numeric)

    can be Float::INFINITY



215
216
# File 'docs/4_Systems_202_Environment.rb', line 215

def weather_duration
end