# {STADE => POURCENTAGE}
TPS_STADES = {
0 => 5, # Passage entre le stade 0 et le stade 1
1 => 15, # Passage entre le stade 1 et le stade 2
2 => 30, # Passage entre le stade 2 et le stade 3
3 => 50, # Passage entre le stade 3 et le stade 4
}
# {"TYPE" => [id,[h,m,s], nb_baies_max, nb_arrosages]}
BAIE = {
"BAIE CERIZ" => [ 1, [12, 0, 0], 5, 3],
"BAIE MARRON" => [ 2, [12, 0, 0], 5, 3],
"BAIE PECHA" => [ 3, [12, 0, 0], 5, 3],
"BAIE FRAIVE" => [ 4, [12,0,0], 5, 3],
"BAIE WILLIA" => [ 5, [12,0,0], 5, 3],
# "BAIE MEPO" => [ 6, [16,0,0], 5, 4],
"BAIE ORAN" => [ 7, [16,0,0], 5, 4],
# "BAIE KIKA" => [ 8, [16,0,0], 5, 4],
# "BAIE PRINE" => [ 9, [48,0,0], 5, 12],
# "BAIE SITRUS" => [10, [32,0,0], 5, 8],
# "BAIE FIGUY" => [11, [20,0,0], 5, 5],
# "BAIE WIKI" => [12, [20,0,0], 5, 5],
}
class Baie
attr_accessor :type
attr_accessor :id_type
attr_accessor :id_baies
attr_accessor :date
attr_accessor :temps
attr_accessor :dt_st_sv
attr_accessor :pousse
attr_accessor :joie
attr_accessor :baies
attr_accessor :stade
attr_accessor :arrosage
def initialize(type)
clock = Time.now
@type = type
@id_type = BAIE[@type][0]
@id_baies = $baie_id
$baie_id = 0
@date = [$game_variables[99],clock.hour,clock.min,clock.sec]
@arrosage = 0
@stade = 0
@temps = BAIE[type][1].dup
for i in 0... @temps.size
@temps[i] *= TPS_STADES[@stade] / 100.0
end
tps = @temps[0] * 3600
tps += @temps[1] * 60
tps += @temps[2]
tps = tps.to_i
@dt_st_sv = [
@date[0] + tps / 86400,
@date[1] + (tps % 86400) / 3600,
@date[2] + (tps % 3600) / 60,
@date[3] + tps % 60
]
@pousse = false
@joie = 0
@baies = 1
end
def maj
clock = Time.new
date = [$game_variables[99],clock.hour,clock.min,clock.sec]
for i in 0..3
if date[i] > @dt_st_sv[i]
retour = true
break
elsif date[i] == @dt_st_sv[i]
next
else
retour = false
break
end
end
if retour
@stade += 1 if @stade < 4
@pousse = (@stade == 4)
if @stade <= 3
@temps = BAIE[type][1]
for i in
0...@temps.size @temps[i] *= TPS_STADES[@stade] / 100.0
end
tps = @temps[0] * 3600
tps += @temps[1] * 60
tps += @temps[2]
tps = tps.to_i
date = [$game_variables[99],clock.hour,clock.min,clock.sec]
@dt_st_sv = [
date[0] + tps / 86400,
date[1] + (tps % 86400) / 3600,
date[2] + (tps % 3600) / 60,
date[3] + tps % 60
]
end
end
end
def arroser
@arrosage += 1
if BAIE[type][3] >= @arrosage
@joie += 3
@baies += (rand(@joie) / 5)
else
@joie -= rand(5)
@baies -= (rand(50) / 20)
end
@baies = (@baies > BAIE[type][2] ? BAIE[type][2] : (@baies < 1 ? 1 : @baies))
tps = @dt_st_sv[0] * 86400
tps += @dt_st_sv[1] * 3600
tps += @dt_st_sv[2] * 60
tps += @dt_st_sv[3]
tps = tps.to_i
tps -= 60
@dt_st_sv = [
tps / 86400,
(tps % 86400) / 3600,
(tps % 3600) / 60,
tps % 60
]
end
end
class Game_Map
alias baie_refresh refresh
def refresh
if @map_id > 0
baie_refresh
if not(@events.empty?) and $game_variables[5000].type == Hash and $game_variables[5000]["baies"] != nil and $game_variables[5000]["baies"][@map_id] != nil
for i in @events.keys
if $game_variables[5000]["baies"][@map_id][i] != nil
maj_baie
stade = $game_variables[5000]["baies"][@map_id][i].stade
if stade == 0
@events[i].character_name = "baie_00.png"
@events[i].direction = 2
else
@events[i].character_name = "baie_" + sprintf("%02d",$game_variables[5000]["baies"][@map_id][i].id_type) + ".png"
@events[i].direction = 2 * stade
end
elsif $game_variables[5000]["baies"][@map_id][i] == nil and @events[i].event.name == "BAIE"
@events[i].character_name = "blanc"
@events[i].direction = 2
end
end
end
end
end
def maj_baie
for i in
1..@events.size if $game_variables[5000]["baies"][@map_id][i] != nil
$game_variables[5000]["baies"][@map_id][i].maj
end
end
end
end
class Interpreter
def planter_baie
scene = Pokemon_Item_Bag.new([4,0], 100, "planter")
scene.main
Graphics.transition
return scene.return_data
end
def init_baies(map = $game_map.map_id, no_arbre = @event_id, baie = "BAIE CERIZ", nbre = BAIE[baie][2])
$baie_id = Item.id(baie)
$game_variables[5000]["baies"][map] = [] if $game_variables[5000]["baies"][map] == nil
$game_variables[5000]["baies"][map][no_arbre] = Baie.new(baie)
$game_variables[5000]["baies"][map][no_arbre].stade = 4
$game_variables[5000]["baies"][map][no_arbre].baies = nbre
end
end