Code: |
#============================================================================== # ■ Window_Base # Pokemon Script Project - Krosk # 18/07/07 # 23/02/10 - Palbolsky #----------------------------------------------------------------------------- # Scène modifiable #----------------------------------------------------------------------------- class Window_Base < Window def normal_color return Color.new(60, 60, 60, 255) end def platine return Color.new(82, 82, 90, 255) end def ombre return Color.new(160,160,168,255) end def disabled_color return Color.new(60, 60, 60, 128) end def white return Color.new(255, 255, 255, 255) end def draw_text_bis(x, y, w, h, string, align = 0, color = Color.new(255, 255, 255, 255)) self.contents.font.color = Color.new(107,107,107,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_bis_plus(x, y, w, h, string, align = 0, color = Color.new(255, 247, 231, 255)) self.contents.font.color = Color.new(66,66,66,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.draw_text(x - 1, y - 1, w, h, string, align) self.contents.draw_text(x, y - 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x - 1, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y - 1, w, h, string, align) self.contents.draw_text(x - 1, y, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_bis_plus_2(x, y, w, h, string, align = 0, color = Color.new(255, 247, 231, 255)) self.contents.font.color = Color.new(82,99,99,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text(x, y, w, h, string, align = 0, color = platine) self.contents.font.color = Color.new(160,160,168,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_red(x, y, w, h, string, align = 0, color = Color.new(232, 32, 16, 255)) self.contents.font.color = Color.new(248, 168, 184, 255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_blue(x, y, w, h, string, align = 0, color = Color.new(0, 112, 248, 255)) self.contents.font.color = Color.new(120, 184, 232, 255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_menu(x, y, w, h, string, align = 0, color = Color.new(66, 66, 66, 255)) self.contents.font.color = Color.new(181,181,181,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_mappanel(x, y, w, h, string, align = 0, color = Color.new(0, 0, 0, 255)) self.contents.font.color = Color.new(144,144,160,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_battle(x, y, w, h, string, align = 0, color = Color.new(74, 74, 74, 255)) self.contents.font.color = Color.new(189,189,189,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_trainer(x, y, w, h, string, align = 0, color = Color.new(72, 72, 72, 255)) self.contents.font.color = Color.new(160,160,160,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_contour(x, y, w, h, string, align = 0, color = white) self.contents.font.color = Color.new(107,107,107,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.draw_text(x, y - 1, w, h, string, align) self.contents.draw_text(x - 1, y, w, h, string, align) self.contents.draw_text(x - 1, y - 1, w, h, string, align) self.contents.draw_text(x - 1, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y - 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_interface(x, y, w, h, string, align = 0, color = white) self.contents.font.color = Color.new(107,107,107,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def draw_text_stat(x, y, w, h, string, align = 0, color = white) self.contents.font.color = Color.new(8,8,0,255) self.contents.draw_text(x, y + 1, w, h, string, align) self.contents.draw_text(x + 1, y, w, h, string, align) self.contents.draw_text(x + 1, y + 1, w, h, string, align) self.contents.font.color = color self.contents.draw_text(x, y, w, h, string, align) end def text_color(n) case n when 0 return normal_color when 1 return Color.new(128, 128, 255, 255) when 2 return Color.new(255, 128, 128, 255) when 3 return Color.new(128, 255, 128, 255) when 4 return Color.new(128, 255, 255, 255) when 5 return Color.new(255, 128, 255, 255) when 6 return Color.new(255, 255, 128, 255) when 7 return Color.new(192, 192, 192, 255) else normal_color end end end |
Code: |
#============================================================================== # ■ Pokemon_Skill_Learn # Pokemon Script Project - Krosk # 01/08/07 # Modifié par Slash le 23/05/10 #----------------------------------------------------------------------------- # Scène à ne pas modifier de préférence #----------------------------------------------------------------------------- # Scène parallèle appelée en cas de level_up #----------------------------------------------------------------------------- module POKEMON_S class Pokemon_Skill_Learn attr_accessor :return_data def initialize(pokemon, skill_id, backscene = nil) if backscene == nil @z_level = 500 @scene = nil else @z_level = backscene.z_level + 100 @scene = backscene end @pokemon = pokemon @skill = Skill.new(skill_id) @text_window = Pokemon_Window_Help.new #Window_Base.new(4, 340, 632, 136) #@text_window.opacity = 0 #@text_window.z = @z_level + 1 #@text_window.contents = Bitmap.new(600 + 32, 104 + 32) #@text_window.contents.font.name = $fontface #@text_window.contents.font.size = $fontsizebig @phase = 0 @done = false end def main if @pokemon.skills_set.length < 4 draw_text(@pokemon.given_name + " a appris", @skill.name+"!") @pokemon.learn_skill(@skill.id) Audio.me_play("Audio/ME/PkmRS-LevelUp.mid") wait(30) wait_hit @done = true @return_data = true else loop do Graphics.update Input.update if @done break end if [0,1,3].include?(@phase) update end if @phase == 2 update_skill end if @phase == 4 update_stat end end end @text_window.dispose @text_window = nil end def update name = @pokemon.given_name.to_s skill = @skill.name.to_s case @phase when 0 draw_text(name + " tente", "d'apprendre " + skill+".") wait(40) draw_text("Mais "+name+" ne peut pas","avoir plus de 4 capacités.") wait(40) draw_text("Lui faire oublier une","capacité ?") decision = draw_choice if decision #Oui draw_text("Oublier quelle ","capacité ?") initialize_skill_window @phase = 2 return else #Non @phase = 1 return end when 1 draw_text("Arrêter d'apprendre", skill +"?") decisionbis = draw_choice if decisionbis #Oui draw_text(name + " n'a pas appris",skill+".") wait_hit @done = true @return_data = false return else @phase = 0 return end when 3 draw_text("1...") wait(10) draw_text("1... 2... ") wait(10) draw_text("1... 2... et Tadaa!") wait_hit draw_text(name + " oublie", @pokemon.skills_set[@skill_index].name+".") wait_hit draw_text("Et...") wait_hit draw_text(name + " apprend", skill+"!") Audio.me_play("Audio/ME/PkmRS-LevelUp.mid") wait(40) @pokemon.replace_skill_index(@skill_index, @skill.id) @done = true @return_data = true end end # ------------------------------------------------------- # Fonctions de la fenêtre des Skills # ------------------------------------------------------- def initialize_stat_window Graphics.freeze # Fond @background = Sprite.new @background.z = @z_level + 10 @background.bitmap = RPG::Cache.picture("Battle_skill_stat.png") @background.x = 13 @background.y = 227 # Statut des skills @status = Window_Base.new(0 - 16, 54 - 16, 640 + 32, 426 + 32) @status.opacity = 0 @status.z = @z_level + 12 @status.contents = Bitmap.new(640, 426) @status.contents.font.name = $fontface @status.contents.font.size = $fontsizebig # Icone @pokemon_sprite = Sprite.new @pokemon_sprite.x = 23 @pokemon_sprite.y = 224 @pokemon_sprite.z = @z_level + 12 @pokemon_sprite.zoom_x = @pokemon_sprite.zoom_y = 0.5 @pokemon_sprite.bitmap = RPG::Cache.battler(@pokemon.icon, 0) # Informations @pokemon_window = Window_Base.new(-36-16, 229-16, 292+32, 39+32) @pokemon_window.opacity = 0 @pokemon_window.z = @z_level + 12 @pokemon_window.contents = Bitmap.new(292, 39) @pokemon_window.contents.font.name = $fontface @pokemon_window.contents.font.size = $fontsizebig @pokemon_window.draw_text_stat(9, -6, 87, 39, "N."+ @pokemon.level.to_s) @pokemon_window.draw_text_stat(90, -6, 180, 39, @pokemon.given_name) draw_gender(158, 10, @pokemon.gender) @stat_index = 0 refresh_stat(@skill_index) Graphics.transition(5) end def initialize_skill_window(index = 0) @skill_index = index Graphics.freeze # Fond @background = Sprite.new @background.z = @z_level + 10 @background.bitmap = RPG::Cache.picture("Battle_skill_choice.png") @background.x = 13 @background.y = 227 # Statut des skills @status = Window_Base.new(0 - 16, 54 - 16, 640 + 32, 426 + 32) @status.opacity = 0 @status.z = @z_level + 12 @status.contents = Bitmap.new(640, 426) @status.contents.font.name = $fontface @status.contents.font.size = $fontsizebig # Icone @pokemon_sprite = Sprite.new @pokemon_sprite.x = 23 @pokemon_sprite.y = 224 @pokemon_sprite.z = @z_level + 12 @pokemon_sprite.zoom_x = @pokemon_sprite.zoom_y = 0.5 @pokemon_sprite.bitmap = RPG::Cache.battler(@pokemon.icon, 0) # Informations @pokemon_window = Window_Base.new(-36-16, 229-16, 292+32, 39+32) @pokemon_window.opacity = 0 @pokemon_window.z = @z_level + 12 @pokemon_window.contents = Bitmap.new(292, 39) @pokemon_window.contents.font.name = $fontface @pokemon_window.contents.font.size = $fontsizebig @pokemon_window.draw_text_stat(9, -6, 87, 39, "N."+ @pokemon.level.to_s) @pokemon_window.draw_text_stat(90, -6, 180, 39, @pokemon.given_name) draw_gender(158, 10, @pokemon.gender) refresh Graphics.transition(5) end #_______________________________________________________________________________ def update_stat if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @stat_index == 1) @phase = 2 $game_system.se_play($data_system.decision_se) dispose_window_skill initialize_skill_window(@skill_index) return end if Input.trigger?(Input::C) and @stat_index == 0 if @skill_index < 4 @phase = 3 $game_system.se_play($data_system.decision_se) dispose_window_skill else @phase = 1 $game_system.se_play($data_system.decision_se) dispose_window_skill end end if Input.trigger?(Input::LEFT) if @stat_index > 0 $game_system.se_play($data_system.cursor_se) end @stat_index -= @stat_index == 0 ? 0 : 1 refresh_stat(@skill_index) end if Input.trigger?(Input::RIGHT) if @stat_index < 1 $game_system.se_play($data_system.cursor_se) end @stat_index += @stat_index == 1 ? 0 : 1 refresh_stat(@skill_index) end end def update_skill if Input.trigger?(Input::UP) and @skill_index > 1 $game_system.se_play($data_system.cursor_se) @skill_index -= 2 refresh end if Input.trigger?(Input::DOWN) and @skill_index < 4 $game_system.se_play($data_system.cursor_se) @skill_index += 2 refresh end if Input.trigger?(Input::LEFT) if @skill_index > 0 $game_system.se_play($data_system.cursor_se) end @skill_index -= @skill_index == 0 ? 0 : 1 refresh end if Input.trigger?(Input::RIGHT) if @skill_index < 5 $game_system.se_play($data_system.cursor_se) end @skill_index += @skill_index == 5 ? 0 : 1 refresh end if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @skill_index == 5) @phase = 1 $game_system.se_play($data_system.decision_se) dispose_window_skill return end if Input.trigger?(Input::C) and @skill_index < 5 @phase = 4 $game_system.se_play($data_system.decision_se) dispose_window_skill initialize_stat_window return end end def refresh_stat(index) @skill_index = index @status.contents.clear i = 0 draw_type(135, 181, @pokemon.type1) draw_type(169,181, @pokemon.type2) rect = Rect.new(0, 0, 303, 72) if @stat_index == 0 bitmap = RPG::Cache.picture("curseur_oubli.png") x = 14 y = 326 @status.contents.blt(x ,y, bitmap, rect) else bitmap = RPG::Cache.picture("curseur_back.png") x = 230 y = 326 @status.contents.blt(x ,y, bitmap, rect) end # Skills appris for skill in @pokemon.skills_set if @skill_index == i draw_type(138, 214, skill.type) @status.draw_text_stat(46, 213, 200, $fhb, skill.name.to_s, 0) @status.draw_text_stat(126, 213, 110, $fhb, "PP " + skill.pp.to_s + "/" + skill.ppmax.to_s, 2) if skill.power == 0 or skill.power == 1 string = "---" else string = skill.power.to_s end @status.draw_text(68, 277, 74, $fhb, string, 1, @status.normal_color) if skill.accuracy == 0 string = "---" else string = skill.accuracy.to_s end @status.draw_text(68, 301, 74, $fhb, string, 1, @status.normal_color) list = string_builder(skill.description, 24) for k in 0..3 @status.draw_text(142, 237 + 16*k, 276, $fhb, list[k].to_s, 0, @status.normal_color) end @status.draw_text_bis_plus(7, 337 , 220, $fhb, "OUBLIER", 1) end i += 1 end # Skill en apprentissage if @skill_index == @pokemon.skills_set.length draw_type(138, 214, @skill.type) @status.draw_text_stat(46, 213, 200, $fhb, @skill.name.to_s, 0) @status.draw_text_stat(126, 213, 110, $fhb, "PP " + @skill.pp.to_s + "/" + skill.ppmax.to_s, 2) if @skill.power == 0 or @skill.power == 1 string = "---" else string = @skill.power.to_s end @status.draw_text(68, 277, 74, $fhb, string, 1, @status.normal_color) if @skill.accuracy == 0 string = "---" else string = @skill.accuracy.to_s end @status.draw_text(68, 301, 74, $fhb, string, 1, @status.normal_color) list = string_builder(@skill.description, 24) for k in 0..3 @status.draw_text(142, 237 + 16*k, 276, $fhb, list[k].to_s, 0, @status.normal_color) end @status.draw_text_bis_plus(7, 337 , 220, $fhb, "ANNULER", 1) end end def refresh @status.contents.clear i = 0 draw_type(135, 181, @pokemon.type1) draw_type(169,181, @pokemon.type2) # Skills appris for skill in @pokemon.skills_set if @skill_index == i if @skill_selected != @skill_index rect = Rect.new(0, 0, 303, 72) bitmap = RPG::Cache.picture("curseur_skill.png") x = i%2 * 128 + 14 y = i/2 * 48 + 222 @status.contents.blt(x ,y, bitmap, rect) end end # if @skill_selected == i # rect = Rect.new(0, 0, 303, 72) # bitmap = RPG::Cache.picture("skillselected.png") #@status.contents.blt(335 ,9+i*84, bitmap, rect) #end x = i%2 * 128 + 23 y = i/2 * 48 + 229 draw_type(x, 16 + y, skill.type) @status.draw_text_bis_plus(x, y, 110, $fhb, skill.name, 1) @status.draw_text_stat(x, y + 16, 110, $fhb, "PP " + skill.pp.to_s + "/" + skill.ppmax.to_s, 2) i += 1 end # Curseur en position retour if @skill_index == 5 rect = Rect.new(0, 0, 303, 72) bitmap = RPG::Cache.picture("curseur_back.png") x = 230 y = 326 @status.contents.blt(x ,y, bitmap, rect) end # Skill en apprentissage if @skill_index == @pokemon.skills_set.length if @skill_index == 4 rect = Rect.new(0, 0, 303, 72) bitmap = RPG::Cache.picture("curseur_skill.png") x = 4%2 * 128 + 78 y = 4/2 * 48 + 222 @status.contents.blt(x ,y, bitmap, rect) end end x = 4%2 * 128 + 86 y = 4/2 * 48 + 229 draw_type(x, 16 + y, @skill.type) @status.draw_text_bis_plus(x, y , 110, $fhb, @skill.name, 1) @status.draw_text_stat(x, y + 16, 110, $fhb, "PP " + @skill.pp.to_s + "/" + @skill.ppmax.to_s, 2) end def dispose_window_skill Graphics.freeze @background.dispose @pokemon_sprite.dispose @pokemon_window.dispose @status.dispose @background = nil @pokemon_sprite = nil @pokemon_window = nil @status = nil Graphics.transition end # ----------------------------------------------------------- # Fonctions Annexes # ----------------------------------------------------------- def draw_choice @command = Window_Command.new(50, ["OUI", "NON"], $fontsizebig) @command.x = 218 @command.y = 94 @command.z = @z_level loop do Graphics.update Input.update @command.update if Input.trigger?(Input::C) and @command.index == 0 @command.dispose @command = nil Input.update return true end if Input.trigger?(Input::C) and @command.index == 1 @command.dispose @command = nil Input.update return false end end end def draw_type(x, y, type) src_rect = Rect.new(0, 0, 96, 42) bitmap = RPG::Cache.picture("T" + type.to_s + ".png") @status.contents.blt(x, y, bitmap, src_rect, 255) end def draw_text(line1 = "", line2 = "") if @scene == nil Graphics.freeze @text_window.contents.clear #@text_window.draw_text(12, 0, 460, 50, line1) #@text_window.draw_text(12, 55, 460, 50, line2) @text_window.draw_text(line1, line2) Graphics.transition(5) else @scene.draw_text(line1, line2) end end def wait_hit loop do Graphics.update Input.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) break end end end def wait(frame) i = 0 loop do i += 1 Graphics.update if i >= frame break end end end def draw_gender(x, y, gender) if gender == 1 rect = Rect.new(0, 0, 18, 33) bitmap = RPG::Cache.picture("Maleb_battler.png") @pokemon_window.contents.blt(x, y, bitmap, rect, 255) end if gender == 2 rect = Rect.new(0, 0, 18, 33) bitmap = RPG::Cache.picture("Femaleb_battler.png") @pokemon_window.contents.blt(x, y, bitmap, rect, 255) end end def string_builder(text, limit) length = text.length full1 = false full2 = false full3 = false full4 = false string1 = "" string2 = "" string3 = "" string4 = "" word = "" for i in 0..length letter = text[i..i] if letter != " " and i != length word += letter.to_s else word = word + " " if (string1 + word).length < limit and not(full1) string1 += word word = "" else full1 = true end if (string2 + word).length < limit and not(full2) string2 += word word = "" else full2 = true end if (string3 + word).length < limit and not(full3) string3 += word word = "" else full3 = true end if (string4 + word).length < limit and not(full4) string4 += word word = "" else full4 = true end end end if string4.length > 1 string4 = string4[0..string4.length-2] end return [string1, string2, string3, string4] end end end |