Class: PFM::Environment

Inherits:
Object show all
Includes:
GameData::SystemTags
Defined in:
scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb,
scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.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

WEATHER_NAMES =

List of weather symbols

%i[none rain sunny sandstorm hail fog hardsun hardrain wind]
UNKNOWN_ZONE =

Unkonw location text

'Zone ???'

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::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::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::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



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 29

def initialize(game_state = PFM.game_state)
  @weather = 0
  @battle_weather = 0
  @fterrain = 0
  @battle_fterrain = 0
  @duration = Float::INFINITY
  @ftduration = Float::INFINITY
  # Zone where the player currently is
  @zone = 0
  # Zone where the current zone is a child of
  @master_zone = 0
  @warp_zone = 0
  @last_map_id = 0
  @visited_zone = []
  @visited_worldmap = []
  @deleted_events = {}
  # Worldmap where the player currently is
  @worldmap = 0
  @worldmap_custom_markers = []
  @game_state = game_state
end

Instance Attribute Details

#game_statePFM::GameState

Get the game state responsive of the whole game state

Returns:



25
26
27
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 25

def game_state
  @game_state
end

#last_map_idInteger (readonly)

Last visited map ID

Returns:



16
17
18
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.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:



13
14
15
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.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 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.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 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.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



385
386
387
388
389
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 385

def add_worldmap_custom_icon(filename, worldmap_id, x, y, ox_mode = :center, oy_mode = :center)
  @worldmap_custom_markers ||= []
  @worldmap_custom_markers[worldmap_id] ||= []
  @worldmap_custom_markers[worldmap_id].push [filename, x, y, ox_mode, oy_mode]
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



8
9
10
11
12
13
14
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 8

def apply_weather(id, duration = nil)
  id = WEATHER_NAMES.index(id) || 0 if id.is_a?(Symbol)
  @battle_weather = id
  @weather = id unless @game_state.game_temp.in_battle && !@game_state.game_switches[::Yuki::Sw::MixWeather]
  @duration = (duration || Float::INFINITY)
  ajust_weather_switches
end

#building?Boolean

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

Returns:

  • (Boolean)


53
54
55
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 53

def building?
  return (!@game_state.game_switches[Yuki::Sw::Env_CanFly] && @game_state.game_player.system_tag == 0)
end

#can_fish?Boolean

Can the player fish ?

Returns:

  • (Boolean)


353
354
355
356
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 353

def can_fish?
  tag = @game_state.game_player.front_system_tag
  return (tag == TPond or tag == TSea)
end

#cave?Boolean

Is the player in a cave ?

Returns:

  • (Boolean)


220
221
222
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 220

def cave?
  return @game_state.game_player.system_tag == TCave
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



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 300

def convert_zone_type(system_tag)
  case system_tag
  when TGrass
    return 1
  when TTallGrass
    return 2
  when TCave
    return 3
  when TMount
    return 4
  when TSand
    return 5
  when TPond
    return 6
  when TSea
    return 7
  when TUnderWater
    return 8
  when TSnow
    return 9
  when TIce
    return 10
  else
    return 0
  end
end

#current_weatherInteger

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

Returns:



36
37
38
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 36

def current_weather
  return @game_state.game_temp.in_battle ? @battle_weather : @weather
end

#current_weather_db_symbolSymbol

Return the db_symbol of the current weather

Returns:

  • (Symbol)


42
43
44
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 42

def current_weather_db_symbol
  WEATHER_NAMES[current_weather] || :__undef__
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



117
118
119
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 117

def current_zone
  return @zone
end

#current_zone_dataStudio::Zone Also known as: get_current_zone_data

Return the zone data in which the player is

Returns:



124
125
126
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 124

def current_zone_data
  data_zone(@zone)
end

#current_zone_nameString

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

Returns:



131
132
133
134
135
136
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 131

def current_zone_name
  zone = @master_zone
  return data_zone(zone).name if zone

  UNKNOWN_ZONE
end

#day?Boolean

Is it day time ?

Returns:

  • (Boolean)


335
336
337
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 335

def day?
  return @game_state.game_switches[::Yuki::Sw::TJN_DayTime]
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



25
26
27
28
29
30
31
32
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 25

def decrease_weather_duration
  @duration -= 1 if @duration > 0
  if @duration <= 0 && @battle_weather != 0
    apply_weather(0, 0)
    return true
  end
  return false
end

#fog?Boolean

Is it foggy ?

Returns:

  • (Boolean)


91
92
93
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 91

def fog?
  return current_weather_db_symbol == :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



372
373
374
375
376
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 372

def get_event_delete_state(event_id, map_id = @game_state.game_map.map_id)
  return false unless (deleted_events = @deleted_events)
  return false unless deleted_events[map_id]
  return deleted_events[map_id][event_id]
end

#get_worldmap(zone = @zone) ⇒ Integer

Get the worldmap from the zone

Parameters:

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

    <default : current zone>

Returns:



183
184
185
186
187
188
189
190
191
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 183

def get_worldmap(zone = @zone)
  if @modified_worldmap_position && @modified_worldmap_position[2]
    return @modified_worldmap_position[2] || 0
  elsif zone.is_a?(Studio::Zone)
    return Studio::Zone.from(zone).worldmaps.first || 0
  else
    return data_zone(zone).worldmaps.first || 0
  end
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:



150
151
152
153
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 150

def get_zone(x, y, worldmap_id = @worldmap)
  zone_id = data_world_map(worldmap_id).grid.dig(y, x)
  return zone_id && zone_id >= 0 ? data_zone(zone_id) : nil
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:



159
160
161
162
163
164
165
166
167
168
169
170
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 159

def get_zone_pos(zone_id, worldmap_id = @worldmap)
  return 0, 0 unless (zone = data_zone(zone_id))
  return zone.position.x, zone.position.y if zone.position.x && zone.position.y

  # Trying to find the current zone
  world_map = data_world_map(worldmap_id)
  y = world_map.grid.find_index { |row| row.include?(zone_id) }
  return 0, 0 unless y

  x = world_map.grid[y].find_index { |cell| cell == zone_id } || 0
  return x, y
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



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 271

def get_zone_type(ice_prio = false)
  if tall_grass?
    return 1
  elsif very_tall_grass?
    return 2
  elsif cave?
    return 3
  elsif mount?
    return 4
  elsif sand?
    return 5
  elsif pond?
    return 6
  elsif sea?
    return 7
  elsif under_water?
    return 8
  elsif snow?
    return ((ice_prio && ice?) ? 10 : 9)
  elsif ice?
    return 10
  else
    return 0
  end
end

#grass?Boolean

Is the player standing in grass ?

Returns:

  • (Boolean)


202
203
204
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 202

def grass?
  return (@game_state.game_switches[Yuki::Sw::Env_CanFly] && @game_state.game_player.system_tag == 0)
end

#hail?Boolean

Does it hail ?

Returns:

  • (Boolean)


85
86
87
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 85

def hail?
  return current_weather_db_symbol == :hail
end

#hardrain?Boolean

Is it hardrainning?

Returns:

  • (Boolean)


54
55
56
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 54

def hardrain?
  return current_weather_db_symbol == :hardrain
end

#hardsun?Boolean

Is it hardsunny?

Returns:

  • (Boolean)


66
67
68
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 66

def hardsun?
  return current_weather_db_symbol == :hardsun
end

#ice?Boolean

Is the player on ice ?

Returns:

  • (Boolean)


257
258
259
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 257

def ice?
  return @game_state.game_player.system_tag == TIce
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



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 83

def load_zone_information(data, index)
  @zone = index
  # We store this zone as the zone where to warp if it's possible
  @warp_zone = index if data.warp.x && data.warp.y
  # We store this zone as the master zone if there's a panel
  @master_zone = index if data.panel_id&.>(0)
  # We memorize the fact we visited this zone
  @visited_zone << index unless @visited_zone.include?(index)
  if data.worldmaps.any?
    # We memorize the fact we visited this worldmap
    @visited_worldmap << data.worldmaps.first unless @visited_worldmap.include?(data.worldmaps.first)
    # We store the zone worldmap
    @worldmap = data.worldmaps.first
  end
  # We store the new switch info
  @game_state.game_switches[Yuki::Sw::Env_CanFly] = (!data.is_warp_disallowed && data.is_fly_allowed)
  @game_state.game_switches[Yuki::Sw::Env_CanDig] = (!data.is_warp_disallowed && !data.is_fly_allowed)
  return unless data.forced_weather

  if data.forced_weather == 0
    @game_state.game_screen.weather(0, 0, @game_state.game_switches[Yuki::Sw::Env_CanFly] ? 40 : 0)
  else
    @game_state.game_screen.weather(0, 9, 40, psdk_weather: data.forced_weather)
  end
end

#morning?Boolean

Is it morning time ?

Returns:

  • (Boolean)


341
342
343
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 341

def morning?
  return @game_state.game_switches[::Yuki::Sw::TJN_MorningTime]
end

#mount?Boolean

Is the player on a mount ?

Returns:

  • (Boolean)


226
227
228
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 226

def mount?
  return @game_state.game_player.system_tag == TMount
end

#night?Boolean

Is it night time ?

Returns:

  • (Boolean)


329
330
331
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 329

def night?
  return @game_state.game_switches[::Yuki::Sw::TJN_NightTime]
end

#normal?Boolean

Is the weather normal

Returns:

  • (Boolean)


97
98
99
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 97

def normal?
  return current_weather_db_symbol == :none
end

#pond?Boolean

Is the player on a pond/river ?

Returns:

  • (Boolean)


239
240
241
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 239

def pond? # Etang / Rivière etc...
  return @game_state.game_player.system_tag == TPond
end

#rain?Boolean

Is it rainning?

Returns:

  • (Boolean)


48
49
50
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 48

def rain?
  return current_weather_db_symbol == :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



396
397
398
399
400
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 396

def remove_worldmap_custom_icon(filename, worldmap_id, x, y)
  return unless @worldmap_custom_markers[worldmap_id]

  @worldmap_custom_markers[worldmap_id].delete_if { |i| i[0] == filename && i[1] == x && i[2] == y }
end

#reset_worldmap_position

Reset the modified worldmap position



411
412
413
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 411

def reset_worldmap_position
  @modified_worldmap_position = nil
end

#reset_zone

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



110
111
112
113
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 110

def reset_zone
  @last_map_id = -1
  @zone = -1
end

#sand?Boolean

Is the player on sand ?

Returns:

  • (Boolean)


232
233
234
235
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 232

def sand?
  tag = @game_state.game_player.system_tag
  return (tag == TSand || tag == TWetSand)
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)


79
80
81
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 79

def sandstorm?
  return current_weather_db_symbol == :sandstorm
end

#sea?Boolean

Is the player on a sea/ocean ?

Returns:

  • (Boolean)


245
246
247
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 245

def sea?
  return @game_state.game_player.system_tag == TSea
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



362
363
364
365
366
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 362

def set_event_delete_state(event_id, map_id = @game_state.game_map.map_id, state = true)
  deleted_events = @deleted_events = {} unless (deleted_events = @deleted_events)
  deleted_events[map_id] = {} unless deleted_events[map_id]
  deleted_events[map_id][event_id] = state
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



406
407
408
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 406

def set_worldmap_position(new_x, new_y, new_worldmap_id = nil)
  @modified_worldmap_position = [new_x, new_y, new_worldmap_id]
end

#snow?Boolean

Is the player on snow or ice ?

Returns:

  • (Boolean)


263
264
265
266
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 263

def snow?
  tag = @game_state.game_player.system_tag
  return (tag == TSnow || tag == TIce) # Ice will be the same as snow for skills
end

#sunny?Boolean

Is it sunny?

Returns:

  • (Boolean)


60
61
62
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 60

def sunny?
  return current_weather_db_symbol == :sunny
end

#sunset?Boolean

Is it sunset time ?

Returns:

  • (Boolean)


347
348
349
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 347

def sunset?
  return @game_state.game_switches[::Yuki::Sw::TJN_SunsetTime]
end

#tall_grass?Boolean

Is the player standing in tall grass ?

Returns:

  • (Boolean)


208
209
210
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 208

def tall_grass?
  return @game_state.game_player.system_tag == TGrass
end

#under_water?Boolean

Is the player underwater ?

Returns:

  • (Boolean)


251
252
253
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 251

def under_water?
  return @game_state.game_player.system_tag == TUnderWater
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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 61

def update_zone
  return false if @last_map_id == @game_state.game_map.map_id

  @last_map_id = map_id = @game_state.game_map.map_id
  last_zone = @zone
  # Searching for the current zone
  each_data_zone do |data|
    next unless data

    if data.maps.include?(map_id)
      load_zone_information(data, data.id)
      break
    end
  end
  return false if last_zone == @zone

  return @zone
end

#very_tall_grass?Boolean

Is the player standing in taller grass ?

Returns:

  • (Boolean)


214
215
216
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 214

def very_tall_grass?
  return @game_state.game_player.system_tag == TTallGrass
end

#visited_worldmap?(worldmap) ⇒ Boolean

Test if the given world map has been visited

Parameters:

Returns:

  • (Boolean)


196
197
198
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 196

def visited_worldmap?(worldmap)
  return @visited_worldmap.include?(worldmap)
end

#visited_zone?(zone) ⇒ Boolean

Check if a zone has been visited

Parameters:

Returns:

  • (Boolean)


175
176
177
178
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 175

def visited_zone?(zone)
  zone = zone.id if zone.is_a?(Studio::Zone)
  return @visited_zone.include?(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



140
141
142
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01200 Environnement.rb', line 140

def warp_zone
  return @warp_zone
end

#weather_durationNumeric Also known as: get_weather_duration

Return the current weather duration

Returns:

  • (Numeric)

    can be Float::INFINITY



18
19
20
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 18

def weather_duration
  return @duration
end

#wind?Boolean

Is it hardsunny?

Returns:

  • (Boolean)


72
73
74
# File 'scripts/01450 Systems/00202 Environment/00001 PFM/01201 Weather.rb', line 72

def wind?
  return current_weather_db_symbol == :wind
end