Module: PFM::ItemDescriptor

Includes:
GameData::SystemTags
Defined in:
scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb

Overview

Module that help item to be used by returning an “extend_data” that every interface can understand

Structure of the extend_data returned
  no_effect: opt Boolean # The item has no effect
  chen: opt Boolean # The stalker also called Prof. CHEN that tells you the item cannot be used there
  open_party: opt Boolean # If the item require the Party menu to be opened in selection mode
  on_creature_choice: opt Proc # The proc to check when the player select a Pokemon(parameter) (return a value usefull to the interface)
  on_creature_use: opt Proc # The proc executed on a Pokemon(parameter) when the item is used
  open_skill: opt Boolean # If the item require the Skill selection interface to be open
  open_skill_learn: opt Integer # ID of the skill to learn if the item require to Open the Skill learn interface
  on_skill_choice: opt Proc # Proc to call to validate the choice of the skill(parameter)
  on_skill_use: opt Proc # Proc to call when a skill(parameter) is validated and choosen 
  on_use: opt Proc # The proc to call when the item is used.
  action_to_push: opt Proc # The proc to call to push the specific action when the item is used in battle
  stone_evolve: opt Boolean # If a Pokemon evolve by stone
  use_before_telling: opt Boolean # If :on_use proc is called before telling the item is used
  skill_message_id: opt Integer # ID of the message to show in the win_text in the Summary

Author:

  • Nuri Yuri

Defined Under Namespace

Classes: Wrapper

Constant Summary collapse

LVL_SOUND =

Sound played when a Pokemon levels up

'audio/me/rosa_levelup'
NO_CONDITION =

Proc executed when there's no condition (returns true)

proc { true }
COMMON_EVENT_CONDITIONS =

Common event condition procs to call before calling event (common_event_id => proc { conditions })

Hash.new(NO_CONDITION)
CommonEventConditions =

Fallback for old users

COMMON_EVENT_CONDITIONS
NO_EFFECT =

No effect Hash descriptor

{ no_effect: true }
CHEN =

You cannot use this item here Hash descriptor

{ chen: true }
BOOST =

Stage boost method Symbol in PFM::Pokemon

%i[change_atk change_dfe change_spd change_ats change_dfs change_eva change_acc]
BagStatesHeal =

Message text id of the various item heals (index => text_id)

[116, 110, 111, 112, 120, 113, 116, 116, 110]
EVStat =

Message text id of the various EV change (index => text_id)

[134, 129, 130, 133, 131, 132]
EXTEND_DATAS =

Constant containing all the default extend_data

Returns:

Hash.new { Wrapper.new }
CHEN_PREVENTIONS =

Constant containing all the chen prevention

{}

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

Class Method Summary collapse

Methods included from GameData::SystemTags

gen, system_tag_db_symbol

Class Method Details

.actions(item_id) ⇒ Wrapper

Describe an item with a Hash descriptor

Parameters:

  • item_id (Integer)

    ID of the item in the database

Returns:

  • (Wrapper)

    the Wrapper helping to use the item



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 51

def actions(item_id)
  item = data_item(item_id)
  # @type [Wrapper]
  wrapper = (EXTEND_DATAS.key?(item.db_symbol) ? EXTEND_DATAS[item.db_symbol] : EXTEND_DATAS[item.class]).dup
  wrapper.item = item
  wrapper.stone_evolve = item.is_a?(Studio::StoneItem)
  wrapper.open_skill_learn = item.is_a?(Studio::TechItem) ? Studio::TechItem.from(item).move_db_symbol : nil
  wrapper.no_effect = item.db_symbol == :__undef__
  wrapper.void_non_battle_block if $game_temp.in_battle
  return wrapper if wrapper.no_effect

  chen = CHEN_PREVENTIONS[item.db_symbol] || CHEN_PREVENTIONS[item.class]
  wrapper.chen = chen&.call(item)
  wrapper.chen = true unless $game_temp.in_battle ? item.is_battle_usable : item.is_map_usable
  return wrapper
end

.define_bag_use(klass, use_before_telling = false) {|item, scene| ... }

Define a usage of item from the bag

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

  • use_before_telling (Boolean) (defaults to: false)

    if the item should be used before showing the message

Yield Parameters:

Yield Returns:

  • (:unused)

    if block returns :unused, the item is considered as not used and not consumed



81
82
83
84
85
86
87
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 81

def define_bag_use(klass, use_before_telling = false, &block)
  raise 'Block is mandatory' unless block_given?

  EXTEND_DATAS[klass] = wrapper = Wrapper.new
  wrapper.on_use = block
  wrapper.use_before_telling = use_before_telling
end

.define_chen_prevention(klass) {|item| ... }

Define a chen prevention for an item (It's not time to use this item)

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

Yield Parameters:

Yield Returns:

  • (Boolean)

    if chen tells it's not time for that!



93
94
95
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 93

def define_chen_prevention(klass, &block)
  CHEN_PREVENTIONS[klass] = block
end

.define_event_condition(event_id, &block)

Define an event condition

Parameters:

  • event_id (Integer)

    ID of the common event that will be called if the condition validates

Yield Returns:

  • (Boolean)

    if the event can be called



71
72
73
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 71

def define_event_condition(event_id, &block)
  COMMON_EVENT_CONDITIONS[event_id] = block || NO_CONDITION
end

.define_on_battle_move_use(klass) {|item, creature, skill, scene| ... }

Define the actions of the item on a specific move in battle

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the item can be used on the Pokemon



174
175
176
177
178
179
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 174

def define_on_battle_move_use(klass, &block)
  raise 'Block is mandatory' unless block_given?
  raise 'Please use define_on_move_usability before' unless EXTEND_DATAS[klass]&.open_skill

  EXTEND_DATAS[klass].action_to_push = block
end

.define_on_creature_battler_use(klass) {|item, creature, scene| ... }

Define the actions performed on a Pokemon in battle

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the item can be used on the Pokemon



130
131
132
133
134
135
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 130

def define_on_creature_battler_use(klass, &block)
  raise 'Block is mandatory' unless block_given?
  raise 'Please use define_on_creature_usability before' unless EXTEND_DATAS[klass]&.open_party

  EXTEND_DATAS[klass].action_to_push = block
end

.define_on_creature_usability(klass) {|item, creature| ... }

Define if an item can be used on a specific Pokemon

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the item can be used on the Pokemon



102
103
104
105
106
107
108
109
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 102

def define_on_creature_usability(klass, &block)
  raise 'Block is mandatory' unless block_given?

  wrapper = EXTEND_DATAS[klass]&.open_party ? EXTEND_DATAS[klass] : Wrapper.new
  wrapper.open_party = true
  wrapper.on_creature_choice = block
  EXTEND_DATAS[klass] = wrapper
end

.define_on_creature_use(klass) {|item, creature, scene| ... }

Define the actions performed on a Pokemon on map

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the item can be used on the Pokemon



117
118
119
120
121
122
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 117

def define_on_creature_use(klass, &block)
  raise 'Block is mandatory' unless block_given?
  raise 'Please use define_on_creature_usability before' unless EXTEND_DATAS[klass]&.open_party

  EXTEND_DATAS[klass].on_creature_use = block
end

.define_on_move_usability(klass, skill_message_id = nil) {|item, skill, scene| ... }

Define if an item can be used on a specific Move

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

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

    ID of the message shown in the summary UI

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the item can be used on the Pokemon



144
145
146
147
148
149
150
151
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 144

def define_on_move_usability(klass, skill_message_id = nil, &block)
  raise 'Block is mandatory' unless block_given?
  raise 'Please use define_on_creature_usability before' unless EXTEND_DATAS[klass]&.open_party

  (wrapper = EXTEND_DATAS[klass]).open_skill = true
  wrapper.skill_message_id = skill_message_id
  wrapper.on_skill_choice = block
end

.define_on_move_use(klass) {|item, creature, skill, scene| ... }

Define the actions of the item on a specific move on map

Parameters:

  • klass (Class<Studio::Item>, Symbol)

    class or db_symbol of the item

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the item can be used on the Pokemon



160
161
162
163
164
165
# File 'scripts/00800 Studio/00001 Data/00002 Item/00000 ItemDescriptor.rb', line 160

def define_on_move_use(klass, &block)
  raise 'Block is mandatory' unless block_given?
  raise 'Please use define_on_move_usability before' unless EXTEND_DATAS[klass]&.open_skill

  EXTEND_DATAS[klass].on_skill_use = block
end