Module: Util::Item

Included in:
GamePlay::Bag, GamePlay::Shortcut
Defined in:
scripts/01450 Systems/00103 Bag/00100 Util__Item.rb

Overview

Item Helper

Author:

  • Nuri Yuri

Instance Method Summary collapse

Instance Method Details

#util_item_on_use_sequence(extend_data) ⇒ PFM::ItemDescriptor::Wrapper, false

Part where the extend_data request to use the item

Parameters:

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'scripts/01450 Systems/00103 Bag/00100 Util__Item.rb', line 58

def util_item_on_use_sequence(extend_data)
  message = parse_text(22, 46, PFM::Text::TRNAME[0] => $trainer.name,
                               PFM::Text::ITEM2[1] => extend_data.item.exact_name)

  if extend_data.use_before_telling
    if extend_data.on_use(self) != :unused
      $bag.remove_item(extend_data.item.id, 1) if extend_data.item.is_limited
      display_message(message) if $scene == self
      return_to_scene(Scene_Map) if $game_temp.common_event_id > 0
      return extend_data
    end
    return false
  end

  $bag.remove_item(extend_data.item.id, 1) if extend_data.item.is_limited
  display_message(message)
  extend_data.on_use(self)

  return extend_data
end

#util_item_open_party_sequence(extend_data, result_process) ⇒ PFM::ItemDescriptor::Wrapper, false

Part where the extend_data request to open the party

Parameters:

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'scripts/01450 Systems/00103 Bag/00100 Util__Item.rb', line 38

def util_item_open_party_sequence(extend_data, result_process)
  party = @team || $actors
  GamePlay.open_party_menu_to_use_item(extend_data, party) do |scene|
    if $game_temp.in_battle && scene.pokemon_selected?
      GamePlay.bag_mixin.from(self).battle_item_wrapper = extend_data
      @running = false
      next
    elsif scene.pokemon_selected?
      $bag.remove_item(extend_data.item.id, 1) if extend_data.item.is_limited
    end
    result_process&.call
  end
  return false unless @running

  return extend_data
end

#util_item_useitem(item_id, &result_process) ⇒ PFM::ItemDescriptor::Wrapper, false

Use an item in a GamePlay::Base child class

Parameters:

  • item_id (Integer)

    ID of the item in the database

Returns:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'scripts/01450 Systems/00103 Bag/00100 Util__Item.rb', line 9

def util_item_useitem(item_id, &result_process)
  extend_data = PFM::ItemDescriptor.actions(item_id)

  if extend_data.chen
    display_message(parse_text(22, 43))
    return false
  elsif extend_data.no_effect
    display_message(parse_text(22, 108))
    return false
  elsif $actors.empty? && extend_data.open_party
    display_message(parse_text(22, 119))
    return false
  elsif extend_data.open_party
    return util_item_open_party_sequence(extend_data, result_process)
  end
  return util_item_on_use_sequence(extend_data)
=begin
  if extend_data[:action_to_push] || extend_data[:ball_data]
    @return_data = [item.id, extend_data, false]
    @running = false
  end
  return extend_data
=end
end