Heures au format UTC + 1 heure [ Heure d’été ]


Règles du forum


Consultez la liste des Scripts : cliquez ici



Publier un nouveau sujet Répondre au sujet  [ 1 message ] 
Auteur Message
 Sujet du message: Script QuestCreator
MessagePublié: 28 Jan 2012, 01:33 
Artisan (Nv 4)
Avatar de l’utilisateur

Inscrit le: 22 Nov 2011, 22:01
Messages: 167
Niveau RPG Maker: Moyen
Logiciel(s) préféré(s): RPG Maker XP
Point(s) Fort(s): Scripts
Sexe: Masculin
Points d'aide: 17/60

Créations :

Voir ses créations

Salut à tous,

Auteur: Bad_maker
Script: QuestCreator
Utilisation:

Voici les codes à utiliser avec insérer_script
Code: Tout sélectionner
$game_party.get_quest(id_de_la_quete)
$game_party.progress_quest(id_de_la_quete, progression)
$game_party.finish_quest(id_de_la_quete)


J'ai décidé de poster un script que j'avais fait
il y a quelques temps maintenant. Plus de deux ans en fait ^^" :rolleyes:
Attention, c'est l'un de mes premiers scripts, il y a beaucoups de bugs à corriger.
Bref ce script est plus une version bêta (voir même alpha) à améliorer qu'un script fini,
libre à ceux qui le veulent de me proposer des versions arrangées du script que je
mettrais à la place de l'actuel (non je n'oublierais pas de vous mettre en avant si c'est
le cas :D )

LES POINTS PLUS:
-> Pas besoin de toucher au script tout se fait durant le test du jeu, et deux ou trois
trucs dans les "appels de scripts".
-> Il suffit de changer de windowskin pour changer l'interface, tout est en fenêtre.

LES BAD POINTS:
-> La gestion du clavier (lettre) n'est pas mise en place.
-> Problème au niveau de la création des quêtes:
On ne peut pas avoir de quête n°1 puis une n°3 et pas de quête n°2, je ne sais pas
ou plus pourquoi.
-> Il n'y a qu'une ligne pour la description de la quête, de même pour son nom.
-> Le gain d'objets ... sauf d'expérience et d'argent doit se faire par événements

Je ne me pencherais plus sur ce script mais je pense qu'il peut servir à certains donc je
le partage. Ce script a été crée en même temps que j'apprenais mes premières notions de
ruby sur ce forum donc il a été calqué sur le tuto pour apprendre le ruby mais je l'ai
tout de même un peu modifié.

Code: Tout sélectionner
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# RPG::Quest
# class de type Object.
# Une quête possède un identifiant, un nom,
# une description, un pourcentage de progression,
# un montant d'argent et d'expériences en récompense
# quand la quête est accomplie et une étiquette
# décrivant l'état de la quête.
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class RPG::Quest
  def initialize
    @id = 0
    @name = ""
    @description = ""
    @progression = 0
    @gold = 0
    @exp = 0
    @flag = 0
  end
  attr_accessor :id
  attr_accessor :name
  attr_accessor :description
  attr_accessor :progression
  attr_accessor :gold
  attr_accessor :exp
  attr_accessor :flag
  # quest.flag = 0 :: La quête n'est pas en cours, ni terminée
  # quest.flag = 1 :: La quête est en cours mais pas terminée
  # quest.flag = 2 :: La quête n'est pas en cours mais terminée
  # quand quest.flag == 0 elle peut être sélectionnée cependant,
  # quand quest.flag == 1 ou quest.flag == 2 la quête ne peut pas l'être.
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Game_Quest
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Game_Quest
  attr_reader :id
  attr_reader :name
  attr_reader :description
  attr_reader :progression
  attr_reader :gold
  attr_reader :exp
  attr_reader :flag
  def initialize(quest_id)
    quest = $data_quests[quest_id]
    @id = quest.id
    @name = quest.name
    @description = quest.description
    @progression = quest.progression
    @gold = quest.gold
    @exp = quest.exp
    @flag = quest.flag
  end
  def iterate_actor_id(param)
    if param == 0
      for actor in $game_party.members do yield actor end
    else
      actor = $game_actors[param]
      yield actor unless actor == nil
    end
  end
  def finished?
    @finished = true if @flag == 2
    @finished = false unless @flag == 2
    return @finished
  end
  def running?
    @running = true if @flag == 1
    @running = false unless @flag == 1
    return @running
  end
  def nothing?
    @nothing = true if @flag == 0
    @nothing = false unless @flag == 0
    return @nothing
  end
  def finish
    @flag = 2
    $game_party.gain_gold(@gold)
    iterate_actor_id(0) do |actor|
      actor.change_exp(actor.exp + @exp, 0)
    end
    $data_quests[@id].flag = @flag
    $data_quests[@id].progression = 100
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Game_Party
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Game_Party < Game_Unit
  attr_reader :quests
  alias quest_initialize initialize
  def initialize
    quest_initialize
    @quests = []
  end
  def progress_quest(quest_id, progression)
    quest = @quests.find { |quest|
    quest.id == quest_id and quest.nothing?
    }
    $data_quests[quest_id].progression += progression
    $data_quests[quest_id].progression = 100 if $data_quests[quest_id].progression > 100
    quest.finish if quest != nil and $data_quests[quest_id].progression == 100
  end
  def get_quest(quest_id)
    quest = @quests.find { |quest|
    quest.id == quest_id and quest.nothing?
    }
    @quests << Game_Quest.new(quest_id) if $data_quests[quest_id].flag == 0
    $data_quests[quest_id].flag = 1
  end
  def finish_quest(quest_id)
    quest = @quests.find { |quest|
    quest.id == quest_id and not quest.finished?
    }
    quest.finish if quest != nil
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Quests
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Quests < Window_Base
  def initialize(x,y)
    super(x,y,128,64)
    refresh
  end
  def refresh
    self.contents.clear
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Quest
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Quest < Window_Base
  def initialize(x)
    super(x,32,288,384)
    refresh
  end
  def refresh
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Numbers
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Numbers < Window_Selectable
  def initialize(x,y)
    super(x,y,80,64)
    self.index = 0
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0,0,self.width-32,24, self.index)
  end
  def update_cursor
    self.cursor_rect.empty
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Name
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Name < Window_Base
  def initialize(x,y)
    super(x,y,320,64)
    refresh
  end
  def refresh
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Letters
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Letters < Window_Selectable
  def initialize(x,y)
    super(x,y,320,288)
    self.index = 0
    @letters_tab = ["A", "B", "C", "D", "E", "F", "G", "H", "I",
    "J", "K", "L", "M", "N", "O", "P", "Q", "R",
    "S", "T", "U", "V", "W", "X", "Y", "Z", " ",
    "a", "b", "c", "d", "e", "f", "g", "h", "i",
    "j", "k", "l", "m", "n", "o", "p", "q", "r",
    "s", "t", "u", "v", "w", "x", "y", "z", "0",
    "1", "2", "3", "4", "5", "6", "7", "8", "9",
    "\'", "é", "è", "ê", "à", "ù", ",", "!", "?"]
    refresh
  end
  def refresh
    self.contents.clear
    x=0; y=0
    for i in 0..@letters_tab.size
      x += 32 if i != 0
      y += 32 if x > 256
      x = 0 if x > 256
      self.contents.draw_text(x, y, 32,24, @letters_tab[i])
    end
  end
  def update_cursor
    x = 32*self.index
    y = 32*0 if x < 288*1
    y = 32*1 if x >= 288*1 and x < 288*2
    y = 32*2 if x >= 288*2 and x < 288*3
    y = 32*3 if x >= 288*3 and x < 288*4
    y = 32*4 if x >= 288*4 and x < 288*5
    y = 32*5 if x >= 288*5 and x < 288*6
    y = 32*6 if x >= 288*6 and x < 288*7
    y = 32*7 if x >= 288*7 and x < 288*8
    x -= 288 if x >= 288 and x < 288*2
    x -= 288*2 if x >= 288*2 and x < 288*3
    x -= 288*3 if x >= 288*3 and x < 288*4
    x -= 288*4 if x >= 288*4 and x < 288*5
    x -= 288*5 if x >= 288*5 and x < 288*6
    x -= 288*6 if x >= 288*6 and x < 288*7
    x -= 288*7 if x >= 288*7 and x < 288*8
    self.cursor_rect.set(x-8, y, 28, 28)
  end
  def letter
    return @letters_tab[self.index]
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Trigger
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Trigger < Window_Base
  def initialize(x,y)
    super(x,y,224,128)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0,0,196,24,"Appuyez sur L ou R")
    self.contents.draw_text(0,24,196,24,"pour passer de droite")
    self.contents.draw_text(0,48,196,24,"à gauche ou de")
    self.contents.draw_text(0,72,196,24,"gauche à droite.")
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_NameDelete
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_NameDelete < Window_Base
  def initialize(x,y)
    super(x,y,160,64)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0,0,128,24,"Effacer le nom")
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Confirm
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Confirm < Window_Base
  def initialize(x,y)
    super(x,y,64,64)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0,0,32,24,"OK")
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_Description
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_Description < Window_Base
  def initialize(x,y)
    super(x,y,320,64)
    refresh
  end
  def refresh
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Window_DescriptionDelete
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Window_DescriptionDelete < Window_Base
  def initialize(x,y)
    super(x,y,160,64)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.draw_text(0,0,128,24,"Tout effacer")
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Scene_Title
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Scene_Title < Scene_Base
  def create_command_window
    s1 = Vocab::new_game; s2 = Vocab::continue; s3 = Vocab::shutdown; s4 = "Création de quêtes"
    array = [s1, s2, s3] unless $TEST; array = [s1, s2, s3, s4] if $TEST
    @command_window = Window_Command.new(212, array)
    @command_window.x = (544 - @command_window.width) / 2
    @command_window.y = 272
    if @continue_enabled; @command_window.index = 1; else; @command_window.draw_item(1, false); end
    @command_window.openness = 0; @command_window.open
  end
  def update
    super
    @command_window.update
    if Input.trigger?(Input::C)
      command_new_game if @command_window.index == 0
      command_continue if @command_window.index == 1
      command_shutdown if @command_window.index == 2
      command_create_quest if @command_window.index == 3
    end
  end
  def command_new_game
    confirm_player_location
    Sound.play_decision
    load_data_quests
    $game_party.setup_starting_members
    $game_map.setup($data_system.start_map_id)
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    $scene = Scene_Map.new
    RPG::BGM.fade(1500)
    close_command_window
    Graphics.fadeout(60)
    Graphics.wait(40)
    Graphics.frame_count = 0
    RPG::BGM.stop
    $game_map.autoplay
  end
  def command_create_quest
    Sound.play_decision
    $scene = Scene_CreateQuest.new
    RPG::BGM.fade(1500)
    close_command_window
    Graphics.fadeout(60)
    Graphics.wait(40)
    Graphics.frame_count = 0
    RPG::BGM.stop
  end
  def load_data_quests
    $data_quests = load_data("Data/Quests.rvdata")
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Scene_File
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Scene_File < Scene_Base
  def write_save_data(file)
    characters = []
    for actor in $game_party.members
      characters.push([actor.character_name, actor.character_index])
    end
    $game_system.save_count += 1
    $game_system.version_id = $data_system.version_id
    @last_bgm = RPG::BGM::last; @last_bgs = RPG::BGS::last
    Marshal.dump(characters, file); Marshal.dump(Graphics.frame_count, file)
    Marshal.dump(@last_bgm, file); Marshal.dump(@last_bgs,            file)
    Marshal.dump($game_system, file); Marshal.dump($game_message,        file)
    Marshal.dump($game_switches, file); Marshal.dump($game_variables,      file)
    Marshal.dump($game_self_switches, file); Marshal.dump($game_actors,         file)
    Marshal.dump($data_quests, file); Marshal.dump($game_party,          file)
    Marshal.dump($game_troop, file); Marshal.dump($game_map,            file)
    Marshal.dump($game_player, file)
  end
  def read_save_data(file)
    characters = Marshal.load(file); Graphics.frame_count = Marshal.load(file)
    @last_bgm = Marshal.load(file); @last_bgs = Marshal.load(file)
    $game_system = Marshal.load(file); $game_message = Marshal.load(file)
    $game_switches = Marshal.load(file); $game_variables = Marshal.load(file)
    $game_self_switches = Marshal.load(file); $game_actors = Marshal.load(file)
    $data_quests = Marshal.load(file); $game_party = Marshal.load(file)
    $game_troop = Marshal.load(file); $game_map = Marshal.load(file)
    $game_player = Marshal.load(file)
    if $game_system.version_id != $data_system.version_id
      $game_map.setup($game_map.map_id); $game_player.center($game_player.x, $game_player.y)
    end
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Scene_Menu
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Scene_Menu < Scene_Base
  def create_command_window
    s1 = Vocab::item; s2 = Vocab::skill; s3 = Vocab::equip; s4 = Vocab::status
    s5 = Vocab::save; s6 = Vocab::game_end; s7 = "Menu Quêtes"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    if $game_party.members.size == 0
      @command_window.draw_item(0, false); @command_window.draw_item(1, false)
      @command_window.draw_item(2, false); @command_window.draw_item(3, false)
    end
    if $game_system.save_disabled; @command_window.draw_item(4, false); end
  end
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel; $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer; return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer; return
      end
      Sound.play_decision
      $scene = Scene_Item.new if @command_window.index == 0
      start_actor_selection if @command_window.index > 0 and @command_window.index < 4
      $scene = Scene_File.new(true, false, false) if @command_window.index == 4
      $scene = Scene_End.new if @command_window.index == 5
      command_quest if @command_window.index == 6
    end
  end
  def command_quest
    Sound.play_decision
    $scene = Scene_Quest.new
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
# Scene_CreateQuest
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-
class Scene_CreateQuest < Scene_Base
  def start
    super
    @etape = 0
    @in_etape = 0
    @in_in_etape = 0
    @quest_id = 0
    @quest_name = ""
    @quest_description = ""
    @quest_progression = 0
    @quest_gold = 0
    @quest_exp = 0
    @quest_flag = 0
    @background = Sprite.new; @background2 = Sprite.new
    @background.bitmap = Cache.parallax("ocean"); @background2.bitmap = Cache.parallax("ocean")
    @background.x = 0; @background2.x = 0 - @background2.width
    @background.z = -1; @background2.z = -1
    @help_window = Window_Base.new(0,0,544,64)
    @help_window.opacity = 120
    @numbers_window = Window_Numbers.new(0,64)
    @numbers_window.opacity = 120
    @name_window = Window_Name.new(0,64)
    @name_window.opacity = 0
    @name_window.contents_opacity = 0
    @letters_window = Window_Letters.new(0,128)
    @letters_window.opacity = 0
    @letters_window.contents_opacity = 0
    @trigger_window = Window_Trigger.new(320,64)
    @trigger_window.opacity = 0
    @trigger_window.contents_opacity = 0
    @deletename_window = Window_NameDelete.new(320,192)
    @deletename_window.opacity = 0
    @deletename_window.contents_opacity = 0
    @confirm_window = Window_Confirm.new(480,192)
    @confirm_window.opacity = 0
    @confirm_window.contents_opacity = 0
    @description_window = Window_Description.new(0,64)
    @description_window.opacity = 0
    @description_window.contents_opacity = 0
    @deletedescription_window = Window_DescriptionDelete.new(320,192)
    @deletedescription_window.opacity = 0
    @deletedescription_window.contents_opacity = 0
  end
  def terminate
    super
    @background.dispose; @background.bitmap.dispose
    @background2.dispose; @background2.bitmap.dispose
    @help_window.dispose
    @numbers_window.dispose
    @name_window.dispose
    @letters_window.dispose
    @trigger_window.dispose
    @deletename_window.dispose
    @confirm_window.dispose
    @description_window.dispose
    @deletedescription_window.dispose
  end
  def update
    super
    update_background
    update_help_window
    etapes
  end
  def update_help_window
    @help_window.update
    @help_window.contents.clear
    @help_window.contents.draw_text(0,0,512,24,"ID de la quête à modifier") if @etape == 0
    @help_window.contents.draw_text(0,0,512,24,"Nom de la quête") if @etape == 1
    @help_window.contents.draw_text(0,0,512,24,"Description de la quête") if @etape == 2
    @help_window.contents.draw_text(0,0,512,24,"Progression initiale de la quête") if @etape == 3
    @help_window.contents.draw_text(0,0,512,24,"Somme d'argent gagnée à la fin de la quête") if @etape == 4
    @help_window.contents.draw_text(0,0,512,24,"Expérience gagnée à la fin de la quête") if @etape == 5
    @help_window.contents.draw_text(0,0,512,24,"Etat initiale de la quête") if @etape == 6
  end
  def update_background
    @background.x += 1; @background2.x += 1
    @background.x = 0 - @background.width if @background.x == @background.width
    @background2.x = 0 - @background2.width if @background2.x == @background2.width
  end
  def change_etape(since, to)
    if since == 0
      @numbers_window.opacity = 0; @numbers_window.contents_opacity = 0
    elsif since == 1
      @name_window.opacity = 0; @name_window.contents_opacity = 0
      @letters_window.opacity = 0; @letters_window.contents_opacity = 0
      @trigger_window.opacity = 0; @trigger_window.contents_opacity = 0
      @deletename_window.opacity = 0; @deletename_window.contents_opacity = 0
      @confirm_window.opacity = 0; @confirm_window.contents_opacity = 0
    elsif since == 2
      @description_window.opacity = 0; @description_window.contents_opacity = 0
      @letters_window.opacity = 0; @letters_window.contents_opacity = 0
      @trigger_window.opacity = 0; @trigger_window.contents_opacity = 0
      @deletedescription_window.opacity = 0; @deletedescription_window.contents_opacity = 0
      @confirm_window.opacity = 0; @confirm_window.contents_opacity = 0
    elsif since == 3
      @numbers_window.opacity = 0; @numbers_window.contents_opacity = 0
    elsif since == 4
      @numbers_window.opacity = 0; @numbers_window.contents_opacity = 0
    elsif since == 5
      @numbers_window.opacity = 0; @numbers_window.contents_opacity = 0
    elsif since == 6
      @numbers_window.opacity = 0; @numbers_window.contents_opacity = 0
    end
    if to == 0
      @numbers_window.opacity = 120; @numbers_window.contents_opacity = 255
    elsif to == 1
      @name_window.opacity = 120; @name_window.contents_opacity = 255
      @letters_window.opacity = 255; @letters_window.contents_opacity = 255
      @trigger_window.opacity = 120; @trigger_window.contents_opacity = 255
      @deletename_window.opacity = 120; @deletename_window.contents_opacity = 255
      @confirm_window.opacity = 120; @confirm_window.contents_opacity = 255
    elsif to == 2
      @description_window.opacity = 120; @description_window.contents_opacity = 255
      @letters_window.opacity = 255; @letters_window.contents_opacity = 255
      @trigger_window.opacity = 120; @trigger_window.contents_opacity = 255
      @deletedescription_window.opacity = 120; @deletedescription_window.contents_opacity = 255
      @confirm_window.opacity = 120; @confirm_window.contents_opacity = 255
    elsif to == 3
      @numbers_window.opacity = 120; @numbers_window.contents_opacity = 255
    elsif to == 4
      @numbers_window.opacity = 120; @numbers_window.contents_opacity = 255
    elsif to == 5
      @numbers_window.opacity = 120; @numbers_window.contents_opacity = 255
    elsif to == 6
      @numbers_window.opacity = 120; @numbers_window.contents_opacity = 255
    end
    @etape = to
  end
  def etapes
    etape0 if @etape == 0; etape1 if @etape == 1; etape2 if @etape == 2
    etape3 if @etape == 3; etape4 if @etape == 4; etape5 if @etape == 5
    etape6 if @etape == 6
  end
  def etape0
    @numbers_window.refresh
    @numbers_window.index+= 1 if Input.repeat?(Input::RIGHT) and @numbers_window.index < 9999
    @numbers_window.index -= 1 if Input.repeat?(Input::LEFT) and @numbers_window.index > 0
    @numbers_window.index += 10 if Input.repeat?(Input::UP) and @numbers_window.index < 9990
    @numbers_window.index -= 10 if Input.repeat?(Input::DOWN) and @numbers_window.index > 9
    @numbers_window.index += 100 if Input.repeat?(Input::R) and @numbers_window.index < 9900
    @numbers_window.index -= 100 if Input.repeat?(Input::L) and @numbers_window.index > 99
    if Input.trigger?(Input::B); Sound.play_cancel; $scene = Scene_Title.new; end
    if Input.trigger?(Input::C)
      @quest_id = @numbers_window.index
      @numbers_window.index = 0; @numbers_window.refresh
      Sound.play_decision; change_etape(0,1)
      Input.update
    end
  end
  def etape1
    @name_window.refresh
    if Input.trigger?(Input::B)
      @name_window.contents.clear
      Sound.play_cancel; change_etape(1,0); @quest_name = ""
      @in_in_etape = 0; @in_etape = 0
    end
    if @in_etape == 0
      update_letters_trigger
      if Input.trigger?(Input::C)
        Sound.play_cursor; @quest_name += @letters_window.letter
        @name_window.contents.draw_text(0,0,288,24,@quest_name)
      elsif Input.trigger?(Input::R)
        @deletename_window.opacity = 255 if @in_in_etape == 0
        @confirm_window.opacity = 255 if @in_in_etape == 1
        Sound.play_cursor; @letters_window.opacity = 120; @in_etape = 1
      end
    end
    if @in_etape == 1
      if @in_in_etape == 0
        if Input.trigger?(Input::C)
          Sound.play_decision; @quest_name = ""
          @name_window.contents.clear
        elsif Input.trigger?(Input::RIGHT)
          Sound.play_cursor; @in_in_etape = 1
          @deletename_window.opacity = 120
          @confirm_window.opacity = 255
        end
      end
      if @in_in_etape == 1
        if Input.trigger?(Input::C)
          Sound.play_decision; @in_in_etape = 0
          @in_etape = 0; change_etape(1,2)
          Input.update
        elsif Input.trigger?(Input::LEFT)
          Sound.play_cursor; @in_in_etape = 0
          @deletename_window.opacity = 255
          @confirm_window.opacity = 120
        end
      end
      if Input.trigger?(Input::L)
        Sound.play_cursor; @in_etape = 0; @deletename_window.opacity = 120
        @confirm_window.opacity = 120; @letters_window.opacity = 255
      end
    end
  end
  def etape2
    @description_window.refresh
    if Input.trigger?(Input::B)
      @description_window.contents.clear
      Sound.play_cancel; change_etape(2,1); @quest_description = ""
      @in_in_etape = 0; @in_etape = 0
    end
    if @in_etape == 0
      update_letters_trigger
      if Input.trigger?(Input::C)
        Sound.play_cursor; @quest_description += @letters_window.letter
        @description_window.contents.draw_text(0,0,288,24,@quest_description)
      elsif Input.trigger?(Input::R)
        @deletedescription_window.opacity = 255 if @in_in_etape == 0
        @confirm_window.opacity = 255 if @in_in_etape == 1
        Sound.play_cursor; @letters_window.opacity = 120; @in_etape = 1
      end
    end
    if @in_etape == 1
      if @in_in_etape == 0
        if Input.trigger?(Input::C)
          Sound.play_decision; @quest_description = ""
          @description_window.contents.clear
        elsif Input.trigger?(Input::RIGHT)
          Sound.play_cursor; @in_in_etape = 1
          @deletedescription_window.opacity = 120
          @confirm_window.opacity = 255
        end
      end
      if @in_in_etape == 1
        if Input.trigger?(Input::C)
          Sound.play_decision; @in_in_etape = 0
          @in_etape = 0; change_etape(2,3)
          Input.update
        elsif Input.trigger?(Input::LEFT)
          Sound.play_cursor; @in_in_etape = 0
          @deletedescription_window.opacity = 255
          @confirm_window.opacity = 120
        end
      end
      if Input.trigger?(Input::L)
        Sound.play_cursor; @in_etape = 0; @deletedescription_window.opacity = 120
        @confirm_window.opacity = 120; @letters_window.opacity = 255
      end
    end
  end
  def etape3
    @numbers_window.refresh
    @numbers_window.index+= 1 if Input.repeat?(Input::RIGHT) and @numbers_window.index < 100
    @numbers_window.index -= 1 if Input.repeat?(Input::LEFT) and @numbers_window.index > 0
    @numbers_window.index += 10 if Input.repeat?(Input::UP) and @numbers_window.index < 91
    @numbers_window.index -= 10 if Input.repeat?(Input::DOWN) and @numbers_window.index > 9
    if Input.trigger?(Input::B); Sound.play_cancel; change_etape(3,2); end
    if Input.trigger?(Input::C)
      @quest_progression = @numbers_window.index
      @numbers_window.index = 0; @numbers_window.refresh
      Sound.play_decision; change_etape(3,4)
      Input.update
    end
  end
  def etape4
    @numbers_window.refresh
    @numbers_window.index+= 1 if Input.repeat?(Input::RIGHT) and @numbers_window.index < 9999
    @numbers_window.index -= 1 if Input.repeat?(Input::LEFT) and @numbers_window.index > 0
    @numbers_window.index += 10 if Input.repeat?(Input::UP) and @numbers_window.index < 9990
    @numbers_window.index -= 10 if Input.repeat?(Input::DOWN) and @numbers_window.index > 9
    @numbers_window.index += 100 if Input.repeat?(Input::R) and @numbers_window.index < 9900
    @numbers_window.index -= 100 if Input.repeat?(Input::L) and @numbers_window.index > 99
    if Input.trigger?(Input::B); Sound.play_cancel; change_etape(4,3); end
    if Input.trigger?(Input::C)
      @quest_gold = @numbers_window.index
      @numbers_window.index = 0; @numbers_window.refresh
      Sound.play_decision; change_etape(4,5)
      Input.update
    end
  end
  def etape5
    @numbers_window.refresh
    @numbers_window.index+= 1 if Input.repeat?(Input::RIGHT) and @numbers_window.index < 9999
    @numbers_window.index -= 1 if Input.repeat?(Input::LEFT) and @numbers_window.index > 0
    @numbers_window.index += 10 if Input.repeat?(Input::UP) and @numbers_window.index < 9990
    @numbers_window.index -= 10 if Input.repeat?(Input::DOWN) and @numbers_window.index > 9
    @numbers_window.index += 100 if Input.repeat?(Input::R) and @numbers_window.index < 9900
    @numbers_window.index -= 100 if Input.repeat?(Input::L) and @numbers_window.index > 99
    if Input.trigger?(Input::B); Sound.play_cancel; change_etape(5,4); end
    if Input.trigger?(Input::C)
      @quest_exp = @numbers_window.index
      @numbers_window.index = 0; @numbers_window.refresh
      Sound.play_decision; change_etape(5,6)
      Input.update
    end
  end
  def etape6
    @numbers_window.refresh
    @numbers_window.index+= 1 if Input.repeat?(Input::RIGHT) and @numbers_window.index < 2
    @numbers_window.index -= 1 if Input.repeat?(Input::LEFT) and @numbers_window.index > 0
    if Input.trigger?(Input::B); Sound.play_cancel; change_etape(6,5); end
    if Input.trigger?(Input::C)
      @quest_flag = @numbers_window.index
      @numbers_window.index = 0; @numbers_window.refresh
      Sound.play_decision
      change_etape(6,0)
      create_quest
      $scene = Scene_Title.new
      Input.update
    end
  end
  def create_quest
    quest = RPG::Quest.new
    quest.id = @quest_id
    quest.name = @quest_name
    quest.description = @quest_description
    quest.progression = @quest_progression
    quest.gold = @quest_gold
    quest.exp = @quest_exp
    quest.flag = @quest_flag
    quests_data = [] unless FileTest.exist?("Data/Quests.rvdata")
    if FileTest.exist?("Data/Quests.rvdata")
      $data_quests = load_data("Data/Quests.rvdata")
      quests_data = $data_quests
    end
    quests_data[quest.id] = quest
    File.open("Data/Quests.rvdata", 'wb') do |rvdata_file|
      Marshal.dump(quests_data, rvdata_file)
    end
  end
  def update_letters_trigger
    if Input.repeat?(Input::RIGHT) and @letters_window.index < 71
      @letters_window.index += 1; Sound.play_cursor
    elsif Input.repeat?(Input::LEFT) and @letters_window.index > 0
      @letters_window.index -= 1; Sound.play_cursor
    elsif Input.repeat?(Input::UP) and @letters_window.index > 8
      @letters_window.index -= 9; Sound.play_cursor
    elsif Input.repeat?(Input::DOWN) and @letters_window.index < 63
      @letters_window.index += 9; Sound.play_cursor
    end
  end
end

class Scene_Quest < Scene_Base
  def start
    super
    @etape = 0; @in_etape = 0; @in_in_etape
    @quests_array = $data_quests; @quest_window = []
    @index = 0; @questidtop = 0; @questiddown = 0
    @questwindow = Window_Quest.new(544)
    x = 0; y = 32
    for i in 1..@quests_array.size
      x += 128 if i != 1
      y += 64 if x >= 256
      x = 0 if x >= 256
      @quest_window[i] = Window_Quests.new(x,y)
      @quest_window[i].contents.draw_text(0,0,96,24,"Quête #{i}")
      @quest_window[i].opacity = 120
    end
    create_background
    change_etape(1)
  end
  def terminate
    super
    @background.bitmap.dispose; @background.dispose
    @background2.bitmap.dispose; @background2.dispose
    for i in 1..@quests_array.size
      @quest_window[i].dispose
    end
  end
   
  def update
    super
    etapes
    update_background
  end
   
  def create_background
    @background = Sprite.new; @background2 = Sprite.new
    @background.bitmap = Cache.parallax("ocean"); @background2.bitmap = Cache.parallax("ocean")
    @background.x = 0; @background2.x = 0 - @background2.width
  end
   
  def update_background
    @background.x += 1; @background2.x += 1
    @background.x = 0 - @background.width if @background.x == @background.width
    @background2.x = 0 - @background2.width if @background2.x == @background2.width
  end
   
  def change_etape(to)
    @etape = to
  end
   
  def etapes
    etape1 if @etape == 1; etape2 if @etape == 2; etape3 if @etape == 3; etape4 if @etape == 4; 
    etape5 if @etape == 5; etape6 if @etape == 6; etape7 if @etape == 7; etape8 if @etape == 8
  end
   
  def etape1
    @questwindow.x += 8 if @questwindow.x != 544
    @questwindow.contents.clear if @questwindow.x == 544
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Menu.new(6)
    end
    if Input.trigger?(Input::C)
      Sound.play_decision
      change_etape(2)
    end
    for i in 1..@quests_array.size
      @quest_window[i].opacity = 255 if i == @index + 1
      @quest_window[i].opacity = 155 if i != @index + 1 and $data_quests[i-1].flag == 2
      @quest_window[i].opacity = 55 if i != @index + 1 and not $data_quests[i-1].flag == 2
    end
    update_triggers
  end
   
  def etape2
    @questwindow.x -= 8 if @questwindow.x != 256
    @questwindow.contents.font.size = 18
    @questwindow.contents.draw_text(0,0,256,24,@quests_array[@index].name)
    @questwindow.contents.draw_text(0,0,256,124,@quests_array[@index].description)
    @questwindow.contents.draw_text(0,0,256,160,"Progression #{@quests_array[@index].progression} %")
    @questwindow.contents.draw_text(0,0,256,196,"#{@quests_array[@index].gold} #{Vocab.gold}")
    @questwindow.contents.draw_text(0,0,256,232,"#{@quests_array[@index].gold} exp")
    @questwindow.contents.draw_text(0,0,256,304,"Disponible") if @quests_array[@index].flag == 0
    @questwindow.contents.draw_text(0,0,256,304,"En cours") if @quests_array[@index].flag == 1
    @questwindow.contents.draw_text(0,0,256,304,"Terminée") if @quests_array[@index].flag == 2
    if Input.trigger?(Input::B)
      Sound.play_cancel
      change_etape(1)
    end
  end
   
  def update_triggers
    if Input.trigger?(Input::RIGHT)
      @index += 1 if @index < @quests_array.size - 1
      update_windows_position(4)
    elsif Input.trigger?(Input::LEFT)
      @index -= 1 if @index > 0
      update_windows_position(3)
    elsif Input.trigger?(Input::UP)
      @index -= 2 if @index > 1
      update_windows_position(1)
    elsif Input.trigger?(Input::DOWN)
      @index += 2 if @index < @quests_array.size - 2
      update_windows_position(2)
    elsif Input.trigger?(Input::CTRL)
      print @index, " ", $data_quests[@index].name
    end
  end
   
  def update_windows_position(direction)
    if @quests_array.size > 12
      for i in 1..@quests_array.size
        if @quest_window[i].y == 32
          @questidtop = i
        end
      end
      for i in 1..@quests_array.size
        if @quest_window[i].y == 352
          @questiddown = i - 3
        end
      end
      if direction == 2 or direction == 4
        if @index > @questidtop + 9 and @index < @questidtop + 12 and @quests_array[@index] != nil
          for i in 1..@quests_array.size
            @quest_window[i].y -= 64
          end
        end
      end
      if direction == 1 or direction == 3
        if @index < @questiddown - 9 and @index > @questiddown - 12 and @quests_array[@index] != nil
          for i in 1..@quests_array.size
            @quest_window[i].y += 64
          end
        end
      end
    end
  end
end
# =+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-

_________________
--- Bad_maker ---
Projet: Gilgamesh's hope
Script: EasyWindowsCreator


Haut
 Profil  
 
Afficher les messages depuis:  Trier par  
Publier un nouveau sujet Répondre au sujet  [ 1 message ] 

Heures au format UTC + 1 heure [ Heure d’été ]


Qui est en ligne ?

Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 1 invité


Vous ne pouvez pas publier de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas insérer de pièces jointes dans ce forum

Rechercher pour:
Sauter vers:  
cron
RPG Creative Forum version 5 ; Tous droits réservés
phpBB Group (Traduit par Xaphos)
Optimisé pour une résolution 1024*728