Illusionniste Lv.12
Age : 34 Inscrit le : 27/12/2008 Messages : 757
| Sujet: Script Bestiaire Lun 2 Fév 2009 - 16:42 | |
| Salut je viens de faire mon premier script c'est un bestiaire mais j'ai un problème la liste des monstre ne défile pas pouvez vous m'aider à le résoudre et pouvez vous me dire ce que je dois changer ou ajouter? - Spoiler:
- Code:
-
=begin pour faire fonctionner ce script appeler $Scene_Bestiaire.new =end #------------------------------------------------------------------------------------------------------------ #Module yama #------------------------------------------------------------------------------------------------------------ module Yama def self.get_monstre(id_monstre) return $game_variables[id_monstre] end
def self.set_monstre(id_monstre, nombre) $game_variables[id_monstre] = nombre end
def self.ajouter_monstre(id_monstre, nombre) $game_variables[id_monstre] += nombre# stocke les monstres tués dans une variable end end #------------------------------------------------------------------------------------------------------------ #Scene_Battle #------------------------------------------------------------------------------------------------------------ class Scene_Battle alias yama_process_victory process_victory def process_victory compte_les_morts yama_process_victory end
alias yama_process_escape process_escape def process_escape compte_les_morts yama_process_escape end
def compte_les_morts for enemy in $game_troop.members if enemy.dead? Yama.ajouter_monstre(enemy.enemy_id, 1) end end end
end #------------------------------------------------------------------------------------------------------------ #Scene_Bestiaire #------------------------------------------------------------------------------------------------------------ class Scene_Bestiaire<Scene_Base
def initialize(enemy_index=1) @enemy_index=enemy_index @Nbre=0 end def start super create_menu_background @viewport = Viewport.new(0, 0, 544, 416) @help_window = Window_Help.new @help_window.viewport = @viewport @best_window = Window_Best.new(0, 56, 272, 360,@enemy_index) @img_window=Window_Img.new(272,56,272,360,@enemy_index) @img_window.viewport=@viewport update_help end def terminate super dispose_menu_background @help_window.dispose @best_window.dispose @img_window.dispose end def update super update_menu_background update_enemy_selection end def next_enemy @enemy_index += 1 @enemy_index %= $data_enemies.size if @enemy_index == 0 @enemy_index = 1 end $scene = Scene_Bestiaire.new(@enemy_index) end def prev_enemy @enemy_index += $data_enemies.size - 1 @enemy_index %= $data_enemies.size if @enemy_index == 0 @enemy_index = $data_enemies.size-1 end $scene = Scene_Bestiaire.new(@enemy_index) end
def update_enemy_selection if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Menu.new elsif Input.trigger?(Input::C) if $game_variables[@enemy_index]<=0 Sound.play_buzzer else Sound.play_decision $scene=Scene_Info.new(@enemy_index) end elsif Input.trigger?(Input::DOWN)||Input.repeat?(Input::DOWN) Sound.play_cursor next_enemy elsif Input.trigger?(Input::UP)||Input.repeat?(Input::UP) Sound.play_cursor prev_enemy end end def complete for pos in 1..$data_enemies.size if $game_variables[pos]>0 @Nbre+=1 end end return @Nbre end
def update_help @help_window.set_text("Pourcentage "+((complete/$data_enemies.size)*100).to_s+" %") end end
#------------------------------------------------------------------------------------------------------------ #Window_Best #------------------------------------------------------------------------------------------------------------ class Window_Best < Window_Selectable def initialize(x,y,height,width,index) super(x,y,height,width) @column_max = 1 @pos=0 self.index = index refresh end def refresh @data = []
for enemy in $data_enemies @data.push(enemy) end @enemy_max = @data.size create_contents for i in 0...@enemy_max draw_item(i) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) enemy = @data[index] if enemy != nil rect.width -= 4 if $game_variables[index]>0 self.contents.draw_text(rect.x+10,rect.y, contents.width,WLH,enemy.name) self.contents.draw_text(rect,$game_variables[index], 2) else self.contents.draw_text(rect.x+10,rect.y, contents.width,WLH,"?????????") end end end end #------------------------------------------------------------------------------------------------------------ #Window_Img #------------------------------------------------------------------------------------------------------------ class Window_Img < Window_Selectable def initialize(x,y,height,width,index=1) super(x,y,height,width) @image=Sprite.new @index=index refresh end def refresh self.contents.clear if $game_variables[index]>0 @image.bitmap = Cache.battler($data_enemies[@index].battler_name, $data_enemies[@index].battler_hue) @image.x=(self.width*1.5)-(@image.width/2) @image.y=((self.height+56)/2)-(@image.height/2) else self.contents.draw_text(10,150, contents.width,WLH,"Pas d'image disponible") end end def dispose @image.dispose end end #------------------------------------------------------------------------------------------------------------ #Scene_Info #------------------------------------------------------------------------------------------------------------ class Scene_Info<Scene_Base def initialize(enemy_index) @enemy_index=enemy_index end
def start super create_menu_background @viewport = Viewport.new(0, 0, 544, 416) @info_window=Window_Info.new(0,0,272,416,@enemy_index) @descript_window=Window_Descript.new(272,0,272,416,@enemy_index) @image=Sprite.new refresh end def terminate super dispose_menu_background @info_window.dispose @info_window.dispose_img @descript_window.dispose end def update super update_menu_background update_info_selection end def next_enemy @enemy_index += $data_enemies.size + 1 @enemy_index %= $data_enemies.size if @enemy_index == 0 @enemy_index = 1 end $scene = Scene_Info.new(@enemy_index) end def prev_enemy @enemy_index += $data_enemies.size - 1 @enemy_index %= $data_enemies.size if @enemy_index == 0 @enemy_index = $data_enemies.size-1 end $scene = Scene_Info.new(@enemy_index) end def update_info_selection if Input.trigger?(Input::B) $scene = Scene_Bestiaire.new(@enemy_index) Sound.play_cancel elsif Input.repeat?(Input::RIGHT) Sound.play_cursor next_enemy elsif Input.repeat?(Input::LEFT) Sound.play_cursor prev_enemy end end def refresh @image.bitmap=Cache.picture("grimoire") end end #------------------------------------------------------------------------------------------------------------ #Window_Info #------------------------------------------------------------------------------------------------------------ class Window_Info < Window_Selectable def initialize(x,y,height,width,index=1) super(x,y,height,width) @img_enemy=Sprite.new @index=index refresh end def refresh self.contents.clear self.opacity=0 @img_enemy.bitmap = Cache.battler($data_enemies[@index].battler_name, $data_enemies[@index].battler_hue) @img_enemy.x=(self.width/2)-(@img_enemy.width/2) @img_enemy.y=145-(@img_enemy.height/2) self.contents.draw_text(10, 0, 40, WLH, @index.to_s) self.contents.draw_text(35,0,contents.width,WLH,$data_enemies[@index].name) draw_enemy_param($data_enemies[@index].maxhp,15,300,Vocab::hp_a) draw_enemy_param($data_enemies[@index].maxmp,15,330,Vocab::mp_a) draw_enemy_param($data_enemies[@index].atk,15,360,Vocab::atk) draw_enemy_param($data_enemies[@index].def,150,300,Vocab::def) draw_enemy_param($data_enemies[@index].spi,150,330,Vocab::spi) draw_enemy_param($data_enemies[@index].agi,150,360,Vocab::agi) end def dispose_img @img_enemy.dispose end def draw_enemy_param(actor, x, y,init) self.contents.font.color = system_color self.contents.draw_text(x, y, 40, WLH, init) self.contents.font.color = normal_color self.contents.draw_text(x + 45, y, 24, WLH, actor, 2) end end #------------------------------------------------------------------------------------------------------------ #Window_Descript #------------------------------------------------------------------------------------------------------------ class Window_Descript <Window_Selectable def initialize(x,y,height,width,index=1) super(x,y,height,width) @index =index @img_icon=Sprite.new @text @Nbre=0 refresh end def refresh self.contents.clear self.opacity=0 @text=$data_enemies[@index].note self.contents.draw_text(0, 0, 290, 245, @text) self.contents.font.color = system_color self.contents.draw_text(10,300,75,25,"RESISTANCE") self.contents.draw_text(10,330,75,25,"FAIBLESSE") self.contents.draw_text(10,360,75,25,"EXPERIENCE") self.contents.draw_text(10,270,75,25,"GILS") self.contents.draw_text(10,240,75,25,"TRESOR") self.contents.font.color = normal_color self.contents.draw_text(90,270,75,25,$data_enemies[@index].gold) self.contents.draw_text(90,360,75,25,$data_enemies[@index].exp) for di in [$data_enemies[@index].drop_item1, $data_enemies[@index].drop_item2] if di.kind == 1 self.draw_icon($data_items[di.item_id].icon_index,90+(@Nbre*60),230,true) self.contents.draw_text(90+(@Nbre*60),250, contents.width, WLH,$data_items[di.item_id].name[0,6]) elsif di.kind == 2 draw_icon($data_weapons[di.weapon_id].icon_index,90+(@Nbre*60),230,true) self.contents.draw_text(90+(@Nbre*60),250, contents.width, WLH,$data_weapons[di.weapon_id].name[0,5]) elsif di.kind == 3 draw_icon($data_armors[di.armor_id].icon_index,90+(@Nbre*60),230,true) self.contents.draw_text(90+(@Nbre*60),250, contents.width, WLH,$data_armors[di.armor_id].name[0,8]) end @Nbre+=1 end end end
Lienvers l'image à mettre dans Picture |
|