Module: Debugger

Defined in:
scripts/00700 Ajout_PSDK/01700 Debugger.rb

Overview

A module that helps the PSDK_DEBUG to perform some commands

Constant Summary collapse

WarpError =

Warp Error message

'Aucune map de cet ID'
WarpMapName =

Name of the map to load to prevent warp error

'Data/Map%03d.rxdata'

Class Method Summary collapse

Class Method Details

.__find_maker_warp(id) ⇒ Boolean

Find the normal position where the player should warp in a specific map

Parameters:

Returns:

  • (Boolean)

    if a normal position has been found

Author:

  • Nuri Yuri



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'scripts/00700 Ajout_PSDK/01700 Debugger.rb', line 53

def __find_maker_warp(id)
  each_data_zone do |data|
    if data.maps.include?(id)
      if data.warp.x && data.warp.y
        $game_temp.player_new_x = data.warp.x + ::Yuki::MapLinker.get_OffsetX
        $game_temp.player_new_y = data.warp.y + ::Yuki::MapLinker.get_OffsetY
        return true
      end
      break
    end
  end
  return false
end

.__find_map_warp(map)

Find an alternative position where to warp

Parameters:

Author:

  • Nuri Yuri



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'scripts/00700 Ajout_PSDK/01700 Debugger.rb', line 70

def __find_map_warp(map)
  warp_x = cx = map.width / 2
  warp_y = cy = map.height / 2
  lowest_radius = ((cx * cy) * 2) ** 2
  map.events.each_value do |event|
    radius = (cx - event.x) ** 2 + (cy - event.y) ** 2
    if(radius < lowest_radius)
      if(__warp_command_found(event.pages))
        warp_x = event.x
        warp_y = event.y
        lowest_radius = radius
      end
    end
  end
  $game_temp.player_new_x = warp_x + ::Yuki::MapLinker.get_OffsetX
  $game_temp.player_new_y = warp_y + ::Yuki::MapLinker.get_OffsetY
end

.__warp_command_found(pages) ⇒ Boolean

Detect a teleport command in the pages of an event

Parameters:

Returns:

  • (Boolean)

    if a command has been found

Author:

  • Nuri Yuri



92
93
94
95
96
97
98
99
# File 'scripts/00700 Ajout_PSDK/01700 Debugger.rb', line 92

def __warp_command_found(pages)
  pages.each do |page|
    page.list.each do |command|
      return true if command.code == 201
    end
  end
  false
end

.battle_trainer(id, bgm = Interpreter::DEFAULT_TRAINER_BGM, troop_id = 3)

Fight a specific trainer by its ID

Parameters:

  • id (Integer)

    ID of the trainer in Ruby Host

  • bgm (Array(String, Integer, Integer)) (defaults to: Interpreter::DEFAULT_TRAINER_BGM)

    bgm description of the trainer battle

  • troop_id (Integer) (defaults to: 3)

    ID of the RMXP Troop to use



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'scripts/00700 Ajout_PSDK/01700 Debugger.rb', line 35

def battle_trainer(id, bgm = Interpreter::DEFAULT_TRAINER_BGM, troop_id = 3)
  original_battle_bgm = $game_system.battle_bgm
  $game_system.battle_bgm = RPG::AudioFile.new(*bgm)
  $game_variables[Yuki::Var::Trainer_Battle_ID] = id
  $game_temp.battle_abort = true
  $game_temp.battle_calling = true
  $game_temp.battle_troop_id = troop_id
  $game_temp.battle_can_escape = false
  $game_temp.battle_can_lose = false
  $game_temp.battle_proc = proc do |n|
    $game_system.battle_bgm = original_battle_bgm
  end
end

.warp(id, x = -1,, y = -1))

Warp command

Parameters:

  • id (Integer)

    ID of the map to warp

  • x (Integer) (defaults to: -1,)

    X position

  • y (Integer) (defaults to: -1))

    Y position

Author:

  • Nuri Yuri



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'scripts/00700 Ajout_PSDK/01700 Debugger.rb', line 14

def warp(id, x = -1, y = -1)
  map = load_data(format(WarpMapName, id)) rescue nil
  return WarpError unless map

  if y < 0
    unless __find_maker_warp(id)
      __find_map_warp(map)
    end
  else
    $game_temp.player_new_x = x + ::Yuki::MapLinker.get_OffsetX
    $game_temp.player_new_y = y + ::Yuki::MapLinker.get_OffsetY
  end
  $game_temp.player_new_direction = 0
  $game_temp.player_new_map_id = id
  $game_temp.player_transferring = true
end