Module: PFM::HoneyTree
- Defined in:
- scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb
Constant Summary collapse
- COUNT =
Maximum number of honney trees
21
- MON_INDEXES =
List of probability for each mon_index
[0...40, 40...60, 60...80, 80...90, 90...95, 95...100]
- LAST_MON_INDEX_CHANCES =
Probablity to get the last mon_index on the same tree
90
- SHAKES_NUMBERS =
2D List of shakes value (column -> chance -> nb_shakes)
[ [], [0...20, 20...79, 79...99, 99...100], [0...1, 1...21, 21...96, 96...100], [0...1, 1...2, 2...7, 7...100] ]
- COLUMN_INDEXES =
List of chance to get a specific column if the Tree is a Munchlax tree or not
{ false => [0...10, 10...80, 80...100], # Normal true => [0...9, 9...29, 29...99, 99...100] # Munchlax }
- WAIT_TO_BATTLE =
Time to wait before being able to fight a Pokemon (in seconds)
21540
- LEAVE_TREE_TIME =
Time when the Pokemon leave the tree
86340
- POKEMON_LISTS =
List of Pokemon / Column
[], # 0 should be empty %i[combee wurmple burmy cherubi aipom aipom], # 1 %i[burmy cherubi combee aipom aipom heracross], # 2 %i[munchlax munchlax munchlax munchlax munchlax munchlax]
- LEVEL_RANGE =
Level range of the battles
5..15
Class Method Summary collapse
-
.can_battle?(id) ⇒ Boolean
Tell if the tree is ready to battle.
-
.get(id) ⇒ Hash{ Symbol => Integer}
Return the honney tree info.
-
.has_pokemon?(id) ⇒ Boolean
Tell if a tree has a Pokemon in it.
-
.last_mon_index ⇒ Integer
Return the last index of the choosen mon in the table.
-
.last_mon_index=(index)
Set the ID of the last choosen mon in the table.
-
.last_tree_id ⇒ Integer
Return the ID of the last tree.
-
.last_tree_id=(id)
Set the ID of the last tree.
-
.munchlax?(id) ⇒ Boolean
Tell if the tree is a munchlax tree or not.
-
.slather(id)
Slather a tree.
Class Method Details
.can_battle?(id) ⇒ Boolean
Tell if the tree is ready to battle
55 56 57 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 55 def can_battle?(id) has_pokemon?(id) && (Graphics.current_time - get(id)[:slather_time]) > WAIT_TO_BATTLE end |
.get(id) ⇒ Hash{ Symbol => Integer}
Return the honney tree info
40 41 42 43 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 40 def get(id) log_error("Honney tree #{id} should not be read, max_id = #{COUNT - 1}") unless id.between?(0, COUNT - 1) return PFM.game_state.honey_trees[id] ||= { column: 0, sakes: 0, mon_index: 0 } end |
.has_pokemon?(id) ⇒ Boolean
Tell if a tree has a Pokemon in it
48 49 50 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 48 def has_pokemon?(id) get(id)[:column] != 0 && (Graphics.current_time - get(id)[:slather_time]) < LEAVE_TREE_TIME end |
.last_mon_index ⇒ Integer
Return the last index of the choosen mon in the table
84 85 86 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 84 def last_mon_index PFM.game_state.user_data[:last_honey_mon_index] || 0 end |
.last_mon_index=(index)
Set the ID of the last choosen mon in the table
90 91 92 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 90 def last_mon_index=(index) PFM.game_state.user_data[:last_honey_mon_index] = index end |
.last_tree_id ⇒ Integer
Return the ID of the last tree
72 73 74 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 72 def last_tree_id return PFM.game_state.user_data[:last_honey_tree] || -1 end |
.last_tree_id=(id)
Set the ID of the last tree
78 79 80 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 78 def last_tree_id=(id) PFM.game_state.user_data[:last_honey_tree] = id end |
.munchlax?(id) ⇒ Boolean
Tell if the tree is a munchlax tree or not
97 98 99 100 101 102 103 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 97 def munchlax?(id) tid = $trainer.id return ((tid & 0xFF) % COUNT) == 0 || ((tid >> 8 & 0xFF) % COUNT) == 0 || ((tid >> 16 & 0xFF) % COUNT) == 0 || ((tid >> 24 & 0xFF) % COUNT) == 0 end |
.slather(id)
Slather a tree
61 62 63 64 65 66 67 68 |
# File 'scripts/01450 Systems/99990 Global Systems/01500 HoneyTree.rb', line 61 def slather(id) column = column(id) tree = get(id) tree[:column] = column tree[:mon_index] = mon_index(id) tree[:sakes] = shakes(column) tree[:slather_time] = Graphics.current_time end |