Accueil du SiteAccueil du Site  AccueilAccueil  Dernières imagesDernières images  RechercherRechercher  ConnexionConnexion  S'enregistrerS'enregistrer  




Partagez
 

 Job System by Charlie Fleed (Résolu)

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Tedrainbow
Paysan (niveau 3)
Paysan (niveau 3)
Tedrainbow

Masculin
Messages postés : 25
Date d'inscription : 24/02/2012
Jauge LPC :
Job System by Charlie Fleed (Résolu) 89152714000 / 1000 / 100Job System by Charlie Fleed (Résolu) 8915271400


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 17:45

--Logiciel utilisé :-: (RPG Maker XP)

--Niveau de maîtrise approximatif :-: (moyen)

--Domaine d'aide attendue :-: scripting

---Job System by Charlie Fleed    Je veux apprende des magie avec plusieur requirement de magie de d'autres classe...

--Solutions tentées :-:(J'ai tenté de tout saimplement changer le requirement pour faire apprendre la compétence avec des magie de deux autre classe mais quand j'ai les magie appris, c'elle si ne veux pas être appris,ils y a rien..............

--Screenshots :-: Sa marche si les magie sont de la même classe,mais si je change pour ce que je veux....

Job System by Charlie Fleed (Résolu) Test110
Sa donne ca et sa veux pas marcher.......
Job System by Charlie Fleed (Résolu) Test210


Dernière édition par Tedrainbow le Ven 15 Nov 2013 - 22:38, édité 1 fois
Revenir en haut Aller en bas
shin
Chevalier Dragon (niveau 1)
Chevalier Dragon (niveau 1)
shin

Masculin
Messages postés : 726
Date d'inscription : 18/10/2011
Jauge LPC :
Job System by Charlie Fleed (Résolu) 891527140043 / 10043 / 100Job System by Charlie Fleed (Résolu) 8915271400

Job System by Charlie Fleed (Résolu) Membre10
Job System by Charlie Fleed (Résolu) Altrui10
Job System by Charlie Fleed (Résolu) Script10
Job System by Charlie Fleed (Résolu) Collec10
Job System by Charlie Fleed (Résolu) Collec11
Job System by Charlie Fleed (Résolu) Collec12
Job System by Charlie Fleed (Résolu) Collec13
Job System by Charlie Fleed (Résolu) Zibrop11


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 17:59

Pourrais tu poster le script que je puisse y jeter un œil ??
Revenir en haut Aller en bas
Tedrainbow
Paysan (niveau 3)
Paysan (niveau 3)
Tedrainbow

Masculin
Messages postés : 25
Date d'inscription : 24/02/2012
Jauge LPC :
Job System by Charlie Fleed (Résolu) 89152714000 / 1000 / 100Job System by Charlie Fleed (Résolu) 8915271400


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 18:58

Voila.. le code

Code:
#==============================================================================
# ** Job System by Charlie Fleed  
#
# Version:           0.2
# Author:    Charlie Fleed
#==============================================================================

#==============================================================================
# ** CONFIGURATION
#==============================================================================

JS_ACTIVE_JOBS_DEFAULT = 1

JS_PASSIVE_JOBS_DEFAULT = 2

# class_id => [skill_id1, skill_id2]
JS_JOB_SKILLS = {
  4 => [69,70,71,72],
  5 => [73,74,75,76],
  6 => [77,78,79,80],
  7 => [1,2,3,4,5,6,53,54],
  8 => [7,11,15,36,38,42,46,52]
}

# skill_id => cost
JS_SKILL_COSTS = {
  1 => 1,
  2 => 2,
  3 => 3,
  4 => 1,
  5 => 2,
  6 => 3,
  7 => 4,
  11 => 4,
  15 => 4,
  36 => 4,
  38 => 4,
  42 => 4,
  46 => 4,
  52 => 4,
  53 => 4,
  54 => 4,
  69 => 2,
  70 => 3,
  71 => 4,
  72 => 5,
  73 => 2,
  74 => 3,
  75 => 4,
  76 => 5,
  77 => 2,
  78 => 3,
  79 => 4,
  80 => 5,
}

# skill_id => level_required
JS_SKILL_LEVEL_REQUIREMENTS = {
  3 => 5,
  6 => 5,
}

# skill_id => [required_skill_id1, required_skill_id2]
JS_SKILL_SKILLS_REQUIREMENTS = {
  2 => [1],
  5 => [4,7,70],
  46 => [36,38,42],
}

# item_id => class_id
JS_ADD_JOB_ITEMS = {
  33 => 7,
  34 => 6,
  35 => 8,
  36 => 5,
  37 => 4,
  38 => 3,
  39 => 2,
  40 => 1,
}

# enemy_id => job_points
JS_ENEMY_JOB_POINTS = {
  1 => 1
}

# Intergration with Charlie Fleed's CTB
REMOVED_ACTORS_JOB_POINTS_QUOTA = 0.5
TRANSFORMED_ACTORS_JOB_POINTS_QUOTA = 0.5
SWITCHED_ACTORS_JOB_POINTS_QUOTA = 0.5

#==============================================================================
# ** END OF CONFIGURATION
#==============================================================================

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :available_jobs
  attr_accessor :active_jobs
  attr_accessor :passive_jobs
  attr_accessor :max_active_jobs
  attr_accessor :max_passive_jobs
  attr_accessor :job_points
  attr_accessor :learned_skills

  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  alias js_initialize initialize
  def initialize(actor_id)
    js_initialize(actor_id)
    @available_jobs = []
    @max_active_jobs = JS_ACTIVE_JOBS_DEFAULT
    @max_passive_jobs = JS_PASSIVE_JOBS_DEFAULT
    @active_jobs = []
    @max_active_jobs.times do @active_jobs.push(nil) end
    @passive_jobs = []
    @max_passive_jobs.times do @passive_jobs.push(nil) end
    @job_points = {}
    @learned_skills = {}
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def add_available_job(job_id)
    @available_jobs.push(job_id)
    # initialize points and skills
    @job_points[job_id] = 0
    @learned_skills[job_id] = []
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def set_passive_job(job_id, position)
    @passive_jobs[position] = job_id
    return if job_id == nil
    for skill_id in @learned_skills[job_id]
      learn_skill(skill_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def remove_passive_job(job_id, position)
    return if job_id == nil
    @passive_jobs[position] = nil
    for skill_id in @learned_skills[job_id]
      forget_skill(skill_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def set_active_job(job_id, position)
    @active_jobs[position] = job_id
    return if job_id == nil
    for skill_id in @learned_skills[job_id]
      learn_skill(skill_id)
    end
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def remove_active_job(job_id, position)
    return if job_id == nil
    @active_jobs[position] = nil
    for skill_id in @learned_skills[job_id]
      forget_skill(skill_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_learn_skill(job_id, skill_id)
    @learned_skills[job_id].push(skill_id)
    learn_skill(skill_id)
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_learn_all_skills
    for job_id in @active_jobs + @passive_jobs
      next if job_id == nil
      for skill_id in @learned_skills[job_id]
        learn_skill(skill_id)
      end
    end
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_skill_learn?(skill_id)
    result = true
    for learned_skills in @learned_skills.values
      if learned_skills.include?(skill_id)
        return true
      end
    end
    return false
  end
  

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_can_learn?(skill_id, job_id)
    if not @learned_skills[job_id].include?(skill_id)
      if @job_points[job_id] >= JS_SKILL_COSTS[skill_id]
        if JS_SKILL_SKILLS_REQUIREMENTS[skill_id] == nil or
          (@learned_skills[job_id] &
          JS_SKILL_SKILLS_REQUIREMENTS[skill_id]).size ==
         JS_SKILL_SKILLS_REQUIREMENTS[skill_id].size
          if JS_SKILL_LEVEL_REQUIREMENTS[skill_id] == nil or
            @level >= JS_SKILL_LEVEL_REQUIREMENTS[skill_id]
            return true
          end
        end
      end
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_get_job_points(value)
    for i in 0 ... @max_active_jobs
      next if @active_jobs[i] == nil
      @job_points[@active_jobs[i]] += job_points
    end
  end
  
end


#==============================================================================
# ** Window_Job_Skills
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Job_Skills < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(320, 128, 320, 352)
    @actor = actor
    @job_id = nil
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  
  #--------------------------------------------------------------------------
  # * Acquiring Skill
  #--------------------------------------------------------------------------
  def skill
    return nil if @job_id == nil or self.index == -1
    return @data[self.index]
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    return if @job_id == nil
    @data = []
    for i in 0 ... JS_JOB_SKILLS[@job_id].size
      skill = $data_skills[JS_JOB_SKILLS[@job_id][i]]
      if skill != nil
        @data.push(skill)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.js_can_learn?(skill.id, @job_id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32 - 4, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 32, y, 204, 32, skill.name, 0)
    if @actor.js_skill_learn?(skill.id)
      self.contents.draw_text(x + 236, y, 48, 32, "Learned", 2)
    else
      self.contents.draw_text(x + 236, y, 48, 32, JS_SKILL_COSTS[skill.id].to_s, 2)
    end
  end
  
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def job_id=(value)
    if @job_id != value
      @job_id = value
      refresh
    end
  end  
end


#==============================================================================
# ** Window_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Jobs < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 320, 128)
    @actor = actor
    @column_max = 1
    refresh
    self.index = 0
  end
  
  #--------------------------------------------------------------------------
  # * Acquiring job_id
  #--------------------------------------------------------------------------
  def job_id
    return @data[self.index]
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    self.contents = Bitmap.new(width - 32, (@actor.max_active_jobs +
      @actor.max_passive_jobs) * 32)
    for i in 0 ... @actor.max_active_jobs
      x = 0
      y = i * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = system_color
      self.contents.font.size = 16
      self.contents.draw_text(4, y, 32, 32, "ACT:", 0)
      self.contents.font.size = 24
      if @actor.active_jobs[i] != nil
        self.contents.font.color = normal_color
        self.contents.draw_text(x + 36, y, 88, 32, $data_classes[@actor.active_jobs[i]].name, 2)
        @data.push(@actor.active_jobs[i])
      else
        @data.push(nil)
      end
    end
    for i in 0 ... @actor.max_passive_jobs
      x = 0
      y = (i + @actor.max_active_jobs) * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = system_color
      self.contents.font.size = 16
      self.contents.draw_text(4, y, 32, 32, "PASS:", 0)
      self.contents.font.size = 24
      if @actor.passive_jobs[i] != nil
        self.contents.font.color = normal_color
        self.contents.draw_text(x + 36, y, 88, 32, $data_classes[@actor.passive_jobs[i]].name, 2)
        @data.push(@actor.passive_jobs[i])
      else
        @data.push(nil)
      end
    end
    @item_max = @data.size
  end
end


#==============================================================================
# ** Window_Available_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Available_Jobs < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 256, 320, 224)
    @actor = actor
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  
  #--------------------------------------------------------------------------
  # * Acquiring job_id
  #--------------------------------------------------------------------------
  def job_id
    return @data[self.index]
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.available_jobs.size
      @data.push(@actor.available_jobs[i])
    end
    @data.push(nil)
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    job_id = @data[index]
    return if job_id == nil
    if @actor.active_jobs.include?(job_id) or @actor.passive_jobs.include?(job_id)
      self.contents.font.color = disabled_color
    else
      self.contents.font.color = normal_color
    end
    x = 0
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 200, 32, $data_classes[job_id].name, 0)
    self.contents.draw_text(x + 204, y, 84, 32, @actor.job_points[job_id].to_s + " JP", 2)
  end  
end


#==============================================================================
# ** Window_Character_Info
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Character_Info < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = nil
    @job_id = nil
  end
  #--------------------------------------------------------------------------
  # * Set Values
  #--------------------------------------------------------------------------
  def set_values(actor, job_id)
    # If at least one value differs from last time
    if @actor != actor or @job_id != job_id
      @actor = actor
      @job_id = job_id
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Redraw text
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 160, 32, @actor.name)
    return if @job_id == nil
    self.contents.font.color = system_color
    self.contents.draw_text(164, 0, 60, 32, "Job:", 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(224, 0, 100, 32, $data_classes[@job_id].name)    
    self.contents.font.color = system_color
    self.contents.draw_text(324, 0, 60, 32, "JP:", 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(384, 0, 60, 32, @actor.job_points[@job_id].to_s)
  end
end


#==============================================================================
# ** Window_Skill_Info
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Skill_Info < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(640, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @skill = nil
  end
  #--------------------------------------------------------------------------
  # * Set Value
  #--------------------------------------------------------------------------
  def set_skill(skill)
    # If the value differs from last time
    if @skill != skill
      @skill = skill
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Redraw text
    self.contents.clear
    return if @skill == nil
    x = 4
    y = 0
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Skill:")
    y += 32
    self.contents.font.color = normal_color
    bitmap = RPG::Cache.icon(@skill.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, self.width - 32 -32, 32, @skill.name)
    y += 32
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Level Required:")
    self.contents.font.color = normal_color
    y += 32
    if JS_SKILL_LEVEL_REQUIREMENTS[@skill.id] != nil
      self.contents.draw_text(x, y, self.width - 40, 32,
        JS_SKILL_LEVEL_REQUIREMENTS[@skill.id].to_s)
    end
    y += 32
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Skills Required:")
    self.contents.font.color = normal_color
    y += 32
    if JS_SKILL_SKILLS_REQUIREMENTS[@skill.id] != nil
      for i in 0 ... JS_SKILL_SKILLS_REQUIREMENTS[@skill.id].size
        req_skill = $data_skills[JS_SKILL_SKILLS_REQUIREMENTS[@skill.id][i]]
        bitmap = RPG::Cache.icon(req_skill.icon_name)
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
        self.contents.draw_text(x + 28, y, self.width - 32 -32, 32, req_skill.name)
        y += 32
      end
    end    
  end
end


#==============================================================================
# ** Scene_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Scene_Jobs
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0)
    @actor_index = actor_index
  end

  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make windows
    @help_window = Window_Help.new
    @character_info_window = Window_Character_Info.new
    @jobs_window = Window_Jobs.new(@actor)
    @available_jobs_window = Window_Available_Jobs.new(@actor)
    @job_skills_window = Window_Job_Skills.new(@actor)
    @skill_info_window = Window_Skill_Info.new

    @jobs_window.title = "Current Jobs"
    @jobs_window.refresh_title
    @available_jobs_window.title = "Available Jobs"
    @available_jobs_window.refresh_title
    @job_skills_window.title = "Job Skills"
    @job_skills_window.refresh_title
    @skill_info_window.title = "Skill Info"
    @skill_info_window.refresh_title
    if $game_party.actors.size > 1
      @character_info_window.title = "<< PAGE UP                                                                                                                 PAGE DOWN >>"
      @character_info_window.refresh_title
    end
    
    @last_window = nil
    @learning = false

    # windows positions
    @jobs_window_x = 0
    @available_jobs_window_x = 0
    @job_skills_window_x = 320
    @skill_info_window_x = 640

    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @character_info_window.dispose
    @jobs_window.dispose
    @available_jobs_window.dispose
    @job_skills_window.dispose
    @skill_info_window.dispose    
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @jobs_window.refresh
    @available_jobs_window.refresh
    @job_skills_window.refresh
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    
    # move windows
    @jobs_window.x -= 16 if @jobs_window.x > @jobs_window_x
    @jobs_window.x += 16 if @jobs_window.x < @jobs_window_x
    @available_jobs_window.x -= 16 if @available_jobs_window.x > @available_jobs_window_x
    @available_jobs_window.x += 16 if @available_jobs_window.x < @available_jobs_window_x
    @job_skills_window.x -= 16 if @job_skills_window.x > @job_skills_window_x
    @job_skills_window.x += 16 if @job_skills_window.x < @job_skills_window_x
    @skill_info_window.x -= 16 if @skill_info_window.x > @skill_info_window_x
    @skill_info_window.x += 16 if @skill_info_window.x < @skill_info_window_x
      
    @available_jobs_window.update
    @job_skills_window.update
    @skill_info_window.set_skill(@job_skills_window.skill)
        
    if @jobs_window.active
      # If R button was pressed
      if Input.trigger?(Input::R)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor_index = (@actor_index + 1) % $game_party.actors.size
        $scene = Scene_Jobs.new(@actor_index)
        return
      end
      # If L button was pressed
      if Input.trigger?(Input::L)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor_index = (@actor_index - 1) % $game_party.actors.size
        $scene = Scene_Jobs.new(@actor_index)
        return
      end
      @jobs_window.update
      update_jobs
      return
    end
    if @available_jobs_window.active
      update_available_jobs
      return
    end
    if @job_skills_window.active
      update_job_skills
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_jobs
    @job_skills_window.job_id = @jobs_window.job_id
    @character_info_window.set_values(@actor, @jobs_window.job_id)
    @help_window.set_text("Press ENTER to change a job, RIGHT or SHIFT to learn skills.")
    
    # If C button was pressed
    if Input.trigger?(Input::C)
      @jobs_window.active = false
      @available_jobs_window.active = true
      @available_jobs_window.index = 0
      return
    end
    # If SHIFT button was pressed
    if Input.trigger?(Input::SHIFT)
      @jobs_window.active = false
      @available_jobs_window.active = true
      @available_jobs_window.index = 0
      @learning = true
      return
    end
    # If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      return if @jobs_window.job_id == nil
      @last_window = @jobs_window
      @jobs_window.active = false
      @job_skills_window.active = true
      @job_skills_window.index = 0
      # Set windows movement
      @jobs_window_x = -320
      @available_jobs_window_x = -320
      @job_skills_window_x = 0
      @skill_info_window_x = 320
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_available_jobs
    @character_info_window.set_values(@actor, @available_jobs_window.job_id)
    @job_skills_window.job_id = @available_jobs_window.job_id
    if @learning
      @help_window.set_text("Press RIGHT to learn skills.")
    else
      @help_window.set_text("Press ENTER to confirm a job, RIGHT to learn skills.")
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      @jobs_window.active = true
      @available_jobs_window.active = false
      @available_jobs_window.index = -1
      @learning = false
    end
    # If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      return if @available_jobs_window.job_id == nil
      @last_window = @available_jobs_window
      @available_jobs_window.active = false
      @job_skills_window.active = true
      @job_skills_window.index = 0
      # Set windows movement
      @jobs_window_x = -320
      @available_jobs_window_x = -320
      @job_skills_window_x = 0
      @skill_info_window_x = 320
      return
    end
    unless @learning
      # If C button was pressed
      if Input.trigger?(Input::C)
        if @jobs_window.index < @actor.max_active_jobs
          job_id = @actor.active_jobs[@jobs_window.index]
          # Remove the current active job
          @actor.remove_active_job(job_id, @jobs_window.index)
          # Remove if active job
          for i in 0 ... @actor.active_jobs.size
            if @actor.active_jobs[i] == @available_jobs_window.job_id
              @actor.remove_active_job(@available_jobs_window.job_id, i)
            end
          end
          # Remove if passive job
          for i in 0 ... @actor.passive_jobs.size
            if @actor.passive_jobs[i] == @available_jobs_window.job_id
              @actor.remove_passive_job(@available_jobs_window.job_id, i)
            end
          end
          @actor.set_active_job(@available_jobs_window.job_id, @jobs_window.index)
          # Needed for skills in more than one job
          @actor.js_learn_all_skills
        else
          job_id = @actor.passive_jobs[@jobs_window.index - @actor.max_active_jobs]
          # Remove the current passive job
          @actor.remove_passive_job(job_id,
            @jobs_window.index - @actor.max_active_jobs)
          # Remove if active job
          for i in 0 ... @actor.active_jobs.size
            if @actor.active_jobs[i] == @available_jobs_window.job_id
              @actor.remove_active_job(@available_jobs_window.job_id, i)
            end
          end
          # Remove if passive job
          for i in 0 ... @actor.passive_jobs.size
            if @actor.passive_jobs[i] == @available_jobs_window.job_id
              @actor.remove_passive_job(@available_jobs_window.job_id, i)
            end
          end
          @actor.set_passive_job(@available_jobs_window.job_id,
            @jobs_window.index - @actor.max_active_jobs)
          # Needed for skills in more than one job
          @actor.js_learn_all_skills
        end
        @available_jobs_window.refresh
        @jobs_window.refresh
        @jobs_window.active = true
        @character_info_window.set_values(@actor, @available_jobs_window.job_id)
        @available_jobs_window.active = false
        @available_jobs_window.index = -1
        # Play equip SE
        $game_system.se_play($data_system.equip_se)
        return
      end
    end

  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_job_skills
    @help_window.set_text(@job_skills_window.skill.description)
    # If B button was pressed
    if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT)
      @last_window.active = true
      @job_skills_window.active = false
      @job_skills_window.index = -1
      # Set windows movement
      @jobs_window_x = 0
      @available_jobs_window_x = 0
      @job_skills_window_x = 320
      @skill_info_window_x = 640
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      skill = @job_skills_window.skill
      if @actor.js_can_learn?(skill.id, @last_window.job_id)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor.js_learn_skill(@last_window.job_id, skill.id)
        @actor.job_points[@last_window.job_id] -= JS_SKILL_COSTS[skill.id]
        @job_skills_window.refresh
        @available_jobs_window.refresh
        @character_info_window.refresh
        return
      end
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
  end
  
end


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_js update
  def update
    update_js
    # If waiting
    if @wait_count > 0
      # Decrease wait count
      @wait_count -= 1
      return
    end
    case @phase
    when 5.1  # after battle phase job points
      update_phase5_1
    end
  end

  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  alias start_phase5_js start_phase5
  def start_phase5
    # Make windows
    @job_points_window = Window_Job_Points.new
    job_points = 0
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP
        if JS_ENEMY_JOB_POINTS[enemy.id] != nil
          job_points += JS_ENEMY_JOB_POINTS[enemy.id]
        else
          job_points += enemy.exp
        end
      end
    end
    # Obtaining JOB POINTS
    # This is processed BEFORE return party in Charlie Fleed's CTB
    @actors_to_check = []
    if $charlie_lee_ctb !=nil # DETECTS Charlie Fleed's CTB
      # Actors removed for summon
      for a in $game_party.removed_actors
        @actors_to_check.push(a)
      end
      # Original form of transformed actors
      for a in $game_party.transformed_actors
        @actors_to_check.push(a)
      end
      # Actors in the backup party
      for a in $game_party.backup_actors
        @actors_to_check.push(a)
      end
    end
    for a in $game_party.actors
      @actors_to_check.push(a)
    end
    job_points_base = job_points
    for actor in @actors_to_check
      job_points = job_points_base
      if actor.cant_get_exp? == false
        if $charlie_lee_ctb !=nil # DETECTS CHARLIE FLEED'S CTB
          # Actors removed for summon
          if $game_party.removed_actors.include?(actor)
            job_points = Integer(job_points_base * REMOVED_ACTORS_JOB_POINTS_QUOTA)
          end
          # Original form of transformed actors
          if $game_party.transformed_actors.include?(actor)
            if $game_party.removed_actors.include?($game_actors[actor.transformed_form_id])
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA * REMOVED_ACTORS_LEARNING_EXP_QUOTA)
            elsif $game_party.backup_actors.include?($game_actors[actor.transformed_form_id])
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA * SWITCHED_ACTORS_LEARNING_EXP_QUOTA)
            else
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA)
            end
          end
          # Actors in the backup party
          if $game_party.backup_actors.include?(actor)
            job_points = Integer(job_points_base * SWITCHED_ACTORS_JOB_POINTS_QUOTA)
          end
        end
        for i in 0 ... actor.max_active_jobs
          next if actor.active_jobs[i] == nil
          actor.job_points[actor.active_jobs[i]] += job_points
          @job_points_window.entries.push(actor.name + " earned " +
            job_points.to_s + " JPs for the job " +  $data_classes[actor.active_jobs[i]].name)  
        end
      end
    end
    if not @job_points_window.entries.empty?
      @job_points_window.index = 0
    end
    # Original call
    start_phase5_js
  end

  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase)
  #--------------------------------------------------------------------------
  alias update_phase5_js update_phase5
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      update_phase5_js
    else
      # If C button was pressed
      if Input.trigger?(Input::C)
        if not @job_points_window.entries.empty?
          @job_points_window.visible = true
          @job_points_window.refresh
          @job_points_window.active = true
          @result_window.visible = false
          if $charlie_lee_ctb != nil and $charlie_lee_ctb_version != nil and $charlie_lee_ctb_version >= 2.11
           @result_window2.visible = false
          end
          @phase = 5.1
          @wait_count = 16
        else
          # Dispose job_points window
          @job_points_window.dispose
          battle_end(0)
        end
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase - JOB POINTS WINDOW)
  #--------------------------------------------------------------------------
  def update_phase5_1
    # Update job points window
    @job_points_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Dispose job points window
      @job_points_window.dispose
      battle_end(0)
      return
    end
  end
end

#==============================================================================
# ** Window_Job_Points
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Job_Points < Window_Selectable
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  attr_accessor :entries
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def initialize()
    @entries = []
    super(80, 0, 480, @entries.size * 32 + 32)
    self.active = false
    self.opacity = 160
    self.back_opacity = 255
    self.contents_opacity = 255
    self.z = 203
    self.visible = false
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def refresh
    self.height = [@entries.size * 32 + 32, 192].min
    @item_max = @entries.size
    self.y = 160 - height / 2
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    self.contents.clear
    x = 4
    y = 4
    for entry in @entries
      self.contents.draw_text(x, y, self.width - 40, 32, entry)
      y += 32
    end
  end
end


#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #     item : item
  #--------------------------------------------------------------------------
  alias item_effect_js item_effect
  def item_effect(item)
    if JS_ADD_JOB_ITEMS[item.id] != nil
      if @available_jobs.include?(JS_ADD_JOB_ITEMS[item.id])
        return false
      else
        add_available_job(JS_ADD_JOB_ITEMS[item.id])
        return true
      end
    else
      return item_effect_js(item)
    end
  end
end


#==============================================================================
# ** Window_Available_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Jobs_2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 304, 224)
    @actor = nil
    @column_max = 1
    self.active = false
    self.index = -1
    self.visible = false
    self.z = 9999
  end
    
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def set_actor(actor)
    if @actor != actor
      @actor = actor
      refresh
    end
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.available_jobs.size
      @data.push(@actor.available_jobs[i])
    end
    @data.push(nil)
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    job_id = @data[index]
    return if job_id == nil
    x = 0
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 90, 32, $data_classes[job_id].name, 0)
  end
  
end


#==============================================================================
# ** Scene Item
#------------------------------------------------------------------------------
#==============================================================================
class Scene_Item
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias js_main main
  def main
    @jobs_window = Window_Jobs_2.new
    @jobs_window.title = "Available Jobs"
    @jobs_window.refresh_title
    # Original call
    js_main
    @jobs_window.dispose
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias js_update update
  def update
    if @target_window.active and @target_window.index >= 0
      @jobs_window.set_actor($game_party.actors[@target_window.index])
      if @target_window.x == 0
        @jobs_window.x = 336
      else
        @jobs_window.x = 0
      end
      @jobs_window.visible = true
    else
      @jobs_window.visible = false
    end
    # Original call
    js_update    
  end

  #--------------------------------------------------------------------------
  # * Update Target
  #--------------------------------------------------------------------------
  alias js_update_target update_target
  def update_target
    # Original call
    js_update_target    
    if Input.trigger?(Input::C)
      @jobs_window.refresh
    end
  end
end  


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # TITLE SUPPORT
  #--------------------------------------------------------------------------
  attr_accessor :title
  alias title_initialize initialize
  def initialize(x, y, width, height)
    # Title support
    @title = ""
    @title_sprite = Sprite.new
    @title_sprite.x = x + 4
    @title_sprite.y = y + 2
    @title_sprite.bitmap = Bitmap.new([1, width - 8].max, 16)
    @title_sprite.bitmap.font.size = 16
    @title_sprite.bitmap.font.bold = true
    title_initialize(x, y, width, height)
  end
  def x=(value)
    super
    @title_sprite.x = self.x + 4
  end
  def y=(value)
    super
    @title_sprite.y = self.y
  end
  def z=(value)
    super
    @title_sprite.z = self.z + 2
  end
  def visible=(value)
    super
    @title_sprite.visible = value
  end
  alias title_dispose dispose
  def dispose
    title_dispose
    @title_sprite.bitmap.dispose
    @title_sprite.dispose
  end
  def refresh_title
    @title_sprite.x = x + 4
    @title_sprite.y = y + 2
    @title_sprite.bitmap.clear
    @title_sprite.bitmap.font.color = system_color
    @title_sprite.bitmap.draw_text(@title_sprite.bitmap.rect, @title)
  end
end
Revenir en haut Aller en bas
shin
Chevalier Dragon (niveau 1)
Chevalier Dragon (niveau 1)
shin

Masculin
Messages postés : 726
Date d'inscription : 18/10/2011
Jauge LPC :
Job System by Charlie Fleed (Résolu) 891527140043 / 10043 / 100Job System by Charlie Fleed (Résolu) 8915271400

Job System by Charlie Fleed (Résolu) Membre10
Job System by Charlie Fleed (Résolu) Altrui10
Job System by Charlie Fleed (Résolu) Script10
Job System by Charlie Fleed (Résolu) Collec10
Job System by Charlie Fleed (Résolu) Collec11
Job System by Charlie Fleed (Résolu) Collec12
Job System by Charlie Fleed (Résolu) Collec13
Job System by Charlie Fleed (Résolu) Zibrop11


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 19:52

J'ai pas XP donc je peut pas test mais dis moi si ça marche.

Code:
#==============================================================================
# ** Job System by Charlie Fleed  
#
# Version:           0.2
# Author:    Charlie Fleed
#==============================================================================

#==============================================================================
# ** CONFIGURATION
#==============================================================================

JS_ACTIVE_JOBS_DEFAULT = 8

JS_PASSIVE_JOBS_DEFAULT = 2

# class_id => [skill_id1, skill_id2]
JS_JOB_SKILLS = {
  4 => [69,70,71,72],
  5 => [73,74,75,76],
  6 => [77,78,79,80],
  7 => [1,2,3,4,5,6,53,54],
  8 => [7,11,15,36,38,42,46,52]
}

# skill_id => cost
JS_SKILL_COSTS = {
  1 => 1,
  2 => 2,
  3 => 3,
  4 => 1,
  5 => 2,
  6 => 3,
  7 => 4,
  11 => 4,
  15 => 4,
  36 => 4,
  38 => 4,
  42 => 4,
  46 => 4,
  52 => 4,
  53 => 4,
  54 => 4,
  69 => 2,
  70 => 3,
  71 => 4,
  72 => 5,
  73 => 2,
  74 => 3,
  75 => 4,
  76 => 5,
  77 => 2,
  78 => 3,
  79 => 4,
  80 => 5,
}

# skill_id => level_required
JS_SKILL_LEVEL_REQUIREMENTS = {
  3 => 5,
  6 => 5,
}

# skill_id => [required_skill_id1, required_skill_id2]
JS_SKILL_SKILLS_REQUIREMENTS = {
  2 => [1],
  5 => [4,7,70],
  46 => [36,38,42],
}

# item_id => class_id
JS_ADD_JOB_ITEMS = {
  33 => 7,
  34 => 6,
  35 => 8,
  36 => 5,
  37 => 4,
  38 => 3,
  39 => 2,
  40 => 1,
}

# enemy_id => job_points
JS_ENEMY_JOB_POINTS = {
  1 => 1
}

# Intergration with Charlie Fleed's CTB
REMOVED_ACTORS_JOB_POINTS_QUOTA = 0.5
TRANSFORMED_ACTORS_JOB_POINTS_QUOTA = 0.5
SWITCHED_ACTORS_JOB_POINTS_QUOTA = 0.5

#==============================================================================
# ** END OF CONFIGURATION
#==============================================================================

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :available_jobs
  attr_accessor :active_jobs
  attr_accessor :passive_jobs
  attr_accessor :max_active_jobs
  attr_accessor :max_passive_jobs
  attr_accessor :job_points
  attr_accessor :learned_skills

  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  alias js_initialize initialize
  def initialize(actor_id)
    js_initialize(actor_id)
    @available_jobs = []
    @max_active_jobs = JS_ACTIVE_JOBS_DEFAULT
    @max_passive_jobs = JS_PASSIVE_JOBS_DEFAULT
    @active_jobs = []
    @max_active_jobs.times do @active_jobs.push(nil) end
    @passive_jobs = []
    @max_passive_jobs.times do @passive_jobs.push(nil) end
    @job_points = {}
    @learned_skills = {}
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def add_available_job(job_id)
    @available_jobs.push(job_id)
    # initialize points and skills
    @job_points[job_id] = 0
    @learned_skills[job_id] = []
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def set_passive_job(job_id, position)
    @passive_jobs[position] = job_id
    return if job_id == nil
    for skill_id in @learned_skills[job_id]
      learn_skill(skill_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def remove_passive_job(job_id, position)
    return if job_id == nil
    @passive_jobs[position] = nil
    for skill_id in @learned_skills[job_id]
      forget_skill(skill_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def set_active_job(job_id, position)
    @active_jobs[position] = job_id
    return if job_id == nil
    for skill_id in @learned_skills[job_id]
      learn_skill(skill_id)
    end
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def remove_active_job(job_id, position)
    return if job_id == nil
    @active_jobs[position] = nil
    for skill_id in @learned_skills[job_id]
      forget_skill(skill_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_learn_skill(job_id, skill_id)
    @learned_skills[job_id].push(skill_id)
    learn_skill(skill_id)
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_learn_all_skills
    for job_id in @active_jobs + @passive_jobs
      next if job_id == nil
      for skill_id in @learned_skills[job_id]
        learn_skill(skill_id)
      end
    end
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_skill_learn?(skill_id)
    result = true
    for learned_skills in @learned_skills.values
      if learned_skills.include?(skill_id)
        return true
      end
    end
    return false
  end
  

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_can_learn?(skill_id, job_id)
  if @job_points[job_id] >= JS_SKILL_COSTS[skill_id]
 if JS_SKILL_SKILLS_REQUIREMENTS[skill_id] == nil or
  (@learned_skills[job_id] &
  JS_SKILL_SKILLS_REQUIREMENTS[skill_id]).size ==
 JS_SKILL_SKILLS_REQUIREMENTS[skill_id].size
  if JS_SKILL_LEVEL_REQUIREMENTS[skill_id] == nil or
 @level >= JS_SKILL_LEVEL_REQUIREMENTS[skill_id]
 return true
  end
 end
      end
 return false
  end
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_get_job_points(value)
    for i in 0 ... @max_active_jobs
      next if @active_jobs[i] == nil
      @job_points[@active_jobs[i]] += job_points
    end
  end
  
end


#==============================================================================
# ** Window_Job_Skills
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Job_Skills < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(320, 128, 320, 352)
    @actor = actor
    @job_id = nil
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  
  #--------------------------------------------------------------------------
  # * Acquiring Skill
  #--------------------------------------------------------------------------
  def skill
    return nil if @job_id == nil or self.index == -1
    return @data[self.index]
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    return if @job_id == nil
    @data = []
    for i in 0 ... JS_JOB_SKILLS[@job_id].size
      skill = $data_skills[JS_JOB_SKILLS[@job_id][i]]
      if skill != nil
        @data.push(skill)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.js_can_learn?(skill.id, @job_id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32 - 4, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 32, y, 204, 32, skill.name, 0)
    if @actor.js_skill_learn?(skill.id)
      self.contents.draw_text(x + 236, y, 48, 32, "Learned", 2)
    else
      self.contents.draw_text(x + 236, y, 48, 32, JS_SKILL_COSTS[skill.id].to_s, 2)
    end
  end
  
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def job_id=(value)
    if @job_id != value
      @job_id = value
      refresh
    end
  end  
end


#==============================================================================
# ** Window_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Jobs < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 320, 128)
    @actor = actor
    @column_max = 1
    refresh
    self.index = 0
  end
  
  #--------------------------------------------------------------------------
  # * Acquiring job_id
  #--------------------------------------------------------------------------
  def job_id
    return @data[self.index]
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    self.contents = Bitmap.new(width - 32, (@actor.max_active_jobs +
      @actor.max_passive_jobs) * 32)
    for i in 0 ... @actor.max_active_jobs
      x = 0
      y = i * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = system_color
      self.contents.font.size = 16
      self.contents.draw_text(4, y, 32, 32, "ACT:", 0)
      self.contents.font.size = 24
      if @actor.active_jobs[i] != nil
        self.contents.font.color = normal_color
        self.contents.draw_text(x + 36, y, 88, 32, $data_classes[@actor.active_jobs[i]].name, 2)
        @data.push(@actor.active_jobs[i])
      else
        @data.push(nil)
      end
    end
    for i in 0 ... @actor.max_passive_jobs
      x = 0
      y = (i + @actor.max_active_jobs) * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = system_color
      self.contents.font.size = 16
      self.contents.draw_text(4, y, 32, 32, "PASS:", 0)
      self.contents.font.size = 24
      if @actor.passive_jobs[i] != nil
        self.contents.font.color = normal_color
        self.contents.draw_text(x + 36, y, 88, 32, $data_classes[@actor.passive_jobs[i]].name, 2)
        @data.push(@actor.passive_jobs[i])
      else
        @data.push(nil)
      end
    end
    @item_max = @data.size
  end
end


#==============================================================================
# ** Window_Available_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Available_Jobs < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 256, 320, 224)
    @actor = actor
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
  
  #--------------------------------------------------------------------------
  # * Acquiring job_id
  #--------------------------------------------------------------------------
  def job_id
    return @data[self.index]
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.available_jobs.size
      @data.push(@actor.available_jobs[i])
    end
    @data.push(nil)
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    job_id = @data[index]
    return if job_id == nil
    if @actor.active_jobs.include?(job_id) or @actor.passive_jobs.include?(job_id)
      self.contents.font.color = disabled_color
    else
      self.contents.font.color = normal_color
    end
    x = 0
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 200, 32, $data_classes[job_id].name, 0)
    self.contents.draw_text(x + 204, y, 84, 32, @actor.job_points[job_id].to_s + " JP", 2)
  end  
end


#==============================================================================
# ** Window_Character_Info
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Character_Info < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = nil
    @job_id = nil
  end
  #--------------------------------------------------------------------------
  # * Set Values
  #--------------------------------------------------------------------------
  def set_values(actor, job_id)
    # If at least one value differs from last time
    if @actor != actor or @job_id != job_id
      @actor = actor
      @job_id = job_id
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Redraw text
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 160, 32, @actor.name)
    return if @job_id == nil
    self.contents.font.color = system_color
    self.contents.draw_text(164, 0, 60, 32, "Job:", 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(224, 0, 100, 32, $data_classes[@job_id].name)    
    self.contents.font.color = system_color
    self.contents.draw_text(324, 0, 60, 32, "JP:", 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(384, 0, 60, 32, @actor.job_points[@job_id].to_s)
  end
end


#==============================================================================
# ** Window_Skill_Info
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Skill_Info < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(640, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @skill = nil
  end
  #--------------------------------------------------------------------------
  # * Set Value
  #--------------------------------------------------------------------------
  def set_skill(skill)
    # If the value differs from last time
    if @skill != skill
      @skill = skill
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Redraw text
    self.contents.clear
    return if @skill == nil
    x = 4
    y = 0
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Skill:")
    y += 32
    self.contents.font.color = normal_color
    bitmap = RPG::Cache.icon(@skill.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, self.width - 32 -32, 32, @skill.name)
    y += 32
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Level Required:")
    self.contents.font.color = normal_color
    y += 32
    if JS_SKILL_LEVEL_REQUIREMENTS[@skill.id] != nil
      self.contents.draw_text(x, y, self.width - 40, 32,
        JS_SKILL_LEVEL_REQUIREMENTS[@skill.id].to_s)
    end
    y += 32
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Skills Required:")
    self.contents.font.color = normal_color
    y += 32
    if JS_SKILL_SKILLS_REQUIREMENTS[@skill.id] != nil
      for i in 0 ... JS_SKILL_SKILLS_REQUIREMENTS[@skill.id].size
        req_skill = $data_skills[JS_SKILL_SKILLS_REQUIREMENTS[@skill.id][i]]
        bitmap = RPG::Cache.icon(req_skill.icon_name)
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
        self.contents.draw_text(x + 28, y, self.width - 32 -32, 32, req_skill.name)
        y += 32
      end
    end    
  end
end


#==============================================================================
# ** Scene_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Scene_Jobs
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0)
    @actor_index = actor_index
  end

  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make windows
    @help_window = Window_Help.new
    @character_info_window = Window_Character_Info.new
    @jobs_window = Window_Jobs.new(@actor)
    @available_jobs_window = Window_Available_Jobs.new(@actor)
    @job_skills_window = Window_Job_Skills.new(@actor)
    @skill_info_window = Window_Skill_Info.new

    @jobs_window.title = "Current Jobs"
    @jobs_window.refresh_title
    @available_jobs_window.title = "Available Jobs"
    @available_jobs_window.refresh_title
    @job_skills_window.title = "Job Skills"
    @job_skills_window.refresh_title
    @skill_info_window.title = "Skill Info"
    @skill_info_window.refresh_title
    if $game_party.actors.size > 1
      @character_info_window.title = "<< PAGE UP                                                                                                                 PAGE DOWN >>"
      @character_info_window.refresh_title
    end
    
    @last_window = nil
    @learning = false

    # windows positions
    @jobs_window_x = 0
    @available_jobs_window_x = 0
    @job_skills_window_x = 320
    @skill_info_window_x = 640

    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @character_info_window.dispose
    @jobs_window.dispose
    @available_jobs_window.dispose
    @job_skills_window.dispose
    @skill_info_window.dispose    
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @jobs_window.refresh
    @available_jobs_window.refresh
    @job_skills_window.refresh
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    
    # move windows
    @jobs_window.x -= 16 if @jobs_window.x > @jobs_window_x
    @jobs_window.x += 16 if @jobs_window.x < @jobs_window_x
    @available_jobs_window.x -= 16 if @available_jobs_window.x > @available_jobs_window_x
    @available_jobs_window.x += 16 if @available_jobs_window.x < @available_jobs_window_x
    @job_skills_window.x -= 16 if @job_skills_window.x > @job_skills_window_x
    @job_skills_window.x += 16 if @job_skills_window.x < @job_skills_window_x
    @skill_info_window.x -= 16 if @skill_info_window.x > @skill_info_window_x
    @skill_info_window.x += 16 if @skill_info_window.x < @skill_info_window_x
      
    @available_jobs_window.update
    @job_skills_window.update
    @skill_info_window.set_skill(@job_skills_window.skill)
        
    if @jobs_window.active
      # If R button was pressed
      if Input.trigger?(Input::R)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor_index = (@actor_index + 1) % $game_party.actors.size
        $scene = Scene_Jobs.new(@actor_index)
        return
      end
      # If L button was pressed
      if Input.trigger?(Input::L)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor_index = (@actor_index - 1) % $game_party.actors.size
        $scene = Scene_Jobs.new(@actor_index)
        return
      end
      @jobs_window.update
      update_jobs
      return
    end
    if @available_jobs_window.active
      update_available_jobs
      return
    end
    if @job_skills_window.active
      update_job_skills
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_jobs
    @job_skills_window.job_id = @jobs_window.job_id
    @character_info_window.set_values(@actor, @jobs_window.job_id)
    @help_window.set_text("Press ENTER to change a job, RIGHT or SHIFT to learn skills.")
    
    # If C button was pressed
    if Input.trigger?(Input::C)
      @jobs_window.active = false
      @available_jobs_window.active = true
      @available_jobs_window.index = 0
      return
    end
    # If SHIFT button was pressed
    if Input.trigger?(Input::SHIFT)
      @jobs_window.active = false
      @available_jobs_window.active = true
      @available_jobs_window.index = 0
      @learning = true
      return
    end
    # If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      return if @jobs_window.job_id == nil
      @last_window = @jobs_window
      @jobs_window.active = false
      @job_skills_window.active = true
      @job_skills_window.index = 0
      # Set windows movement
      @jobs_window_x = -320
      @available_jobs_window_x = -320
      @job_skills_window_x = 0
      @skill_info_window_x = 320
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_available_jobs
    @character_info_window.set_values(@actor, @available_jobs_window.job_id)
    @job_skills_window.job_id = @available_jobs_window.job_id
    if @learning
      @help_window.set_text("Press RIGHT to learn skills.")
    else
      @help_window.set_text("Press ENTER to confirm a job, RIGHT to learn skills.")
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      @jobs_window.active = true
      @available_jobs_window.active = false
      @available_jobs_window.index = -1
      @learning = false
    end
    # If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      return if @available_jobs_window.job_id == nil
      @last_window = @available_jobs_window
      @available_jobs_window.active = false
      @job_skills_window.active = true
      @job_skills_window.index = 0
      # Set windows movement
      @jobs_window_x = -320
      @available_jobs_window_x = -320
      @job_skills_window_x = 0
      @skill_info_window_x = 320
      return
    end
    unless @learning
      # If C button was pressed
      if Input.trigger?(Input::C)
        if @jobs_window.index < @actor.max_active_jobs
          job_id = @actor.active_jobs[@jobs_window.index]
          # Remove the current active job
          @actor.remove_active_job(job_id, @jobs_window.index)
          # Remove if active job
          for i in 0 ... @actor.active_jobs.size
            if @actor.active_jobs[i] == @available_jobs_window.job_id
              @actor.remove_active_job(@available_jobs_window.job_id, i)
            end
          end
          # Remove if passive job
          for i in 0 ... @actor.passive_jobs.size
            if @actor.passive_jobs[i] == @available_jobs_window.job_id
              @actor.remove_passive_job(@available_jobs_window.job_id, i)
            end
          end
          @actor.set_active_job(@available_jobs_window.job_id, @jobs_window.index)
          # Needed for skills in more than one job
          @actor.js_learn_all_skills
        else
          job_id = @actor.passive_jobs[@jobs_window.index - @actor.max_active_jobs]
          # Remove the current passive job
          @actor.remove_passive_job(job_id,
            @jobs_window.index - @actor.max_active_jobs)
          # Remove if active job
          for i in 0 ... @actor.active_jobs.size
            if @actor.active_jobs[i] == @available_jobs_window.job_id
              @actor.remove_active_job(@available_jobs_window.job_id, i)
            end
          end
          # Remove if passive job
          for i in 0 ... @actor.passive_jobs.size
            if @actor.passive_jobs[i] == @available_jobs_window.job_id
              @actor.remove_passive_job(@available_jobs_window.job_id, i)
            end
          end
          @actor.set_passive_job(@available_jobs_window.job_id,
            @jobs_window.index - @actor.max_active_jobs)
          # Needed for skills in more than one job
          @actor.js_learn_all_skills
        end
        @available_jobs_window.refresh
        @jobs_window.refresh
        @jobs_window.active = true
        @character_info_window.set_values(@actor, @available_jobs_window.job_id)
        @available_jobs_window.active = false
        @available_jobs_window.index = -1
        # Play equip SE
        $game_system.se_play($data_system.equip_se)
        return
      end
    end

  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_job_skills
    @help_window.set_text(@job_skills_window.skill.description)
    # If B button was pressed
    if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT)
      @last_window.active = true
      @job_skills_window.active = false
      @job_skills_window.index = -1
      # Set windows movement
      @jobs_window_x = 0
      @available_jobs_window_x = 0
      @job_skills_window_x = 320
      @skill_info_window_x = 640
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      skill = @job_skills_window.skill
      if @actor.js_can_learn?(skill.id, @last_window.job_id)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor.js_learn_skill(@last_window.job_id, skill.id)
        @actor.job_points[@last_window.job_id] -= JS_SKILL_COSTS[skill.id]
        @job_skills_window.refresh
        @available_jobs_window.refresh
        @character_info_window.refresh
        return
      end
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
  end
  
end


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_js update
  def update
    update_js
    # If waiting
    if @wait_count > 0
      # Decrease wait count
      @wait_count -= 1
      return
    end
    case @phase
    when 5.1  # after battle phase job points
      update_phase5_1
    end
  end

  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  alias start_phase5_js start_phase5
  def start_phase5
    # Make windows
    @job_points_window = Window_Job_Points.new
    job_points = 0
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP
        if JS_ENEMY_JOB_POINTS[enemy.id] != nil
          job_points += JS_ENEMY_JOB_POINTS[enemy.id]
        else
          job_points += enemy.exp
        end
      end
    end
    # Obtaining JOB POINTS
    # This is processed BEFORE return party in Charlie Fleed's CTB
    @actors_to_check = []
    if $charlie_lee_ctb !=nil # DETECTS Charlie Fleed's CTB
      # Actors removed for summon
      for a in $game_party.removed_actors
        @actors_to_check.push(a)
      end
      # Original form of transformed actors
      for a in $game_party.transformed_actors
        @actors_to_check.push(a)
      end
      # Actors in the backup party
      for a in $game_party.backup_actors
        @actors_to_check.push(a)
      end
    end
    for a in $game_party.actors
      @actors_to_check.push(a)
    end
    job_points_base = job_points
    for actor in @actors_to_check
      job_points = job_points_base
      if actor.cant_get_exp? == false
        if $charlie_lee_ctb !=nil # DETECTS CHARLIE FLEED'S CTB
          # Actors removed for summon
          if $game_party.removed_actors.include?(actor)
            job_points = Integer(job_points_base * REMOVED_ACTORS_JOB_POINTS_QUOTA)
          end
          # Original form of transformed actors
          if $game_party.transformed_actors.include?(actor)
            if $game_party.removed_actors.include?($game_actors[actor.transformed_form_id])
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA * REMOVED_ACTORS_LEARNING_EXP_QUOTA)
            elsif $game_party.backup_actors.include?($game_actors[actor.transformed_form_id])
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA * SWITCHED_ACTORS_LEARNING_EXP_QUOTA)
            else
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA)
            end
          end
          # Actors in the backup party
          if $game_party.backup_actors.include?(actor)
            job_points = Integer(job_points_base * SWITCHED_ACTORS_JOB_POINTS_QUOTA)
          end
        end
        for i in 0 ... actor.max_active_jobs
          next if actor.active_jobs[i] == nil
          actor.job_points[actor.active_jobs[i]] += job_points
          @job_points_window.entries.push(actor.name + " earned " +
            job_points.to_s + " JPs for the job " +  $data_classes[actor.active_jobs[i]].name)  
        end
      end
    end
    if not @job_points_window.entries.empty?
      @job_points_window.index = 0
    end
    # Original call
    start_phase5_js
  end

  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase)
  #--------------------------------------------------------------------------
  alias update_phase5_js update_phase5
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      update_phase5_js
    else
      # If C button was pressed
      if Input.trigger?(Input::C)
        if not @job_points_window.entries.empty?
          @job_points_window.visible = true
          @job_points_window.refresh
          @job_points_window.active = true
          @result_window.visible = false
          if $charlie_lee_ctb != nil and $charlie_lee_ctb_version != nil and $charlie_lee_ctb_version >= 2.11
           @result_window2.visible = false
          end
          @phase = 5.1
          @wait_count = 16
        else
          # Dispose job_points window
          @job_points_window.dispose
          battle_end(0)
        end
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase - JOB POINTS WINDOW)
  #--------------------------------------------------------------------------
  def update_phase5_1
    # Update job points window
    @job_points_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Dispose job points window
      @job_points_window.dispose
      battle_end(0)
      return
    end
  end
end

#==============================================================================
# ** Window_Job_Points
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Job_Points < Window_Selectable
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  attr_accessor :entries
  
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def initialize()
    @entries = []
    super(80, 0, 480, @entries.size * 32 + 32)
    self.active = false
    self.opacity = 160
    self.back_opacity = 255
    self.contents_opacity = 255
    self.z = 203
    self.visible = false
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def refresh
    self.height = [@entries.size * 32 + 32, 192].min
    @item_max = @entries.size
    self.y = 160 - height / 2
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    self.contents.clear
    x = 4
    y = 4
    for entry in @entries
      self.contents.draw_text(x, y, self.width - 40, 32, entry)
      y += 32
    end
  end
end


#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #     item : item
  #--------------------------------------------------------------------------
  alias item_effect_js item_effect
  def item_effect(item)
    if JS_ADD_JOB_ITEMS[item.id] != nil
      if @available_jobs.include?(JS_ADD_JOB_ITEMS[item.id])
        return false
      else
        add_available_job(JS_ADD_JOB_ITEMS[item.id])
        return true
      end
    else
      return item_effect_js(item)
    end
  end
end


#==============================================================================
# ** Window_Available_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Jobs_2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 304, 224)
    @actor = nil
    @column_max = 1
    self.active = false
    self.index = -1
    self.visible = false
    self.z = 9999
  end
    
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def set_actor(actor)
    if @actor != actor
      @actor = actor
      refresh
    end
  end
  
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.available_jobs.size
      @data.push(@actor.available_jobs[i])
    end
    @data.push(nil)
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    job_id = @data[index]
    return if job_id == nil
    x = 0
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 90, 32, $data_classes[job_id].name, 0)
  end
  
end


#==============================================================================
# ** Scene Item
#------------------------------------------------------------------------------
#==============================================================================
class Scene_Item
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias js_main main
  def main
    @jobs_window = Window_Jobs_2.new
    @jobs_window.title = "Available Jobs"
    @jobs_window.refresh_title
    # Original call
    js_main
    @jobs_window.dispose
  end
  
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias js_update update
  def update
    if @target_window.active and @target_window.index >= 0
      @jobs_window.set_actor($game_party.actors[@target_window.index])
      if @target_window.x == 0
        @jobs_window.x = 336
      else
        @jobs_window.x = 0
      end
      @jobs_window.visible = true
    else
      @jobs_window.visible = false
    end
    # Original call
    js_update    
  end

  #--------------------------------------------------------------------------
  # * Update Target
  #--------------------------------------------------------------------------
  alias js_update_target update_target
  def update_target
    # Original call
    js_update_target    
    if Input.trigger?(Input::C)
      @jobs_window.refresh
    end
  end
end  


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # TITLE SUPPORT
  #--------------------------------------------------------------------------
  attr_accessor :title
  alias title_initialize initialize
  def initialize(x, y, width, height)
    # Title support
    @title = ""
    @title_sprite = Sprite.new
    @title_sprite.x = x + 4
    @title_sprite.y = y + 2
    @title_sprite.bitmap = Bitmap.new([1, width - 8].max, 16)
    @title_sprite.bitmap.font.size = 16
    @title_sprite.bitmap.font.bold = true
    title_initialize(x, y, width, height)
  end
  def x=(value)
    super
    @title_sprite.x = self.x + 4
  end
  def y=(value)
    super
    @title_sprite.y = self.y
  end
  def z=(value)
    super
    @title_sprite.z = self.z + 2
  end
  def visible=(value)
    super
    @title_sprite.visible = value
  end
  alias title_dispose dispose
  def dispose
    title_dispose
    @title_sprite.bitmap.dispose
    @title_sprite.dispose
  end
  def refresh_title
    @title_sprite.x = x + 4
    @title_sprite.y = y + 2
    @title_sprite.bitmap.clear
    @title_sprite.bitmap.font.color = system_color
    @title_sprite.bitmap.draw_text(@title_sprite.bitmap.rect, @title)
  end
end
Revenir en haut Aller en bas
Tedrainbow
Paysan (niveau 3)
Paysan (niveau 3)
Tedrainbow

Masculin
Messages postés : 25
Date d'inscription : 24/02/2012
Jauge LPC :
Job System by Charlie Fleed (Résolu) 89152714000 / 1000 / 100Job System by Charlie Fleed (Résolu) 8915271400


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 19:57

shin a écrit:
J'ai pas XP donc je peut pas test mais dis moi si ça marche.
.
.
Non, sa marche pas
Revenir en haut Aller en bas
shin
Chevalier Dragon (niveau 1)
Chevalier Dragon (niveau 1)
shin

Masculin
Messages postés : 726
Date d'inscription : 18/10/2011
Jauge LPC :
Job System by Charlie Fleed (Résolu) 891527140043 / 10043 / 100Job System by Charlie Fleed (Résolu) 8915271400

Job System by Charlie Fleed (Résolu) Membre10
Job System by Charlie Fleed (Résolu) Altrui10
Job System by Charlie Fleed (Résolu) Script10
Job System by Charlie Fleed (Résolu) Collec10
Job System by Charlie Fleed (Résolu) Collec11
Job System by Charlie Fleed (Résolu) Collec12
Job System by Charlie Fleed (Résolu) Collec13
Job System by Charlie Fleed (Résolu) Zibrop11


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 20:42

Normalement ça devrais être bon.

Code:
#==============================================================================
# ** Job System by Charlie Fleed 
#
# Version:          0.2
# Author:    Charlie Fleed
#==============================================================================

#==============================================================================
# ** CONFIGURATION
#==============================================================================

JS_ACTIVE_JOBS_DEFAULT = 1

JS_PASSIVE_JOBS_DEFAULT = 2

# class_id => [skill_id1, skill_id2]
JS_JOB_SKILLS = {
  4 => [69,70,71,72],
  5 => [73,74,75,76],
  6 => [77,78,79,80],
  7 => [1,2,3,4,5,6,53,54],
  8 => [7,11,15,36,38,42,46,52]
}

# skill_id => cost
JS_SKILL_COSTS = {
  1 => 1,
  2 => 2,
  3 => 3,
  4 => 1,
  5 => 2,
  6 => 3,
  7 => 4,
  11 => 4,
  15 => 4,
  36 => 4,
  38 => 4,
  42 => 4,
  46 => 4,
  52 => 4,
  53 => 4,
  54 => 4,
  69 => 2,
  70 => 3,
  71 => 4,
  72 => 5,
  73 => 2,
  74 => 3,
  75 => 4,
  76 => 5,
  77 => 2,
  78 => 3,
  79 => 4,
  80 => 5,
}

# skill_id => level_required
JS_SKILL_LEVEL_REQUIREMENTS = {
  3 => 5,
  6 => 5,
}

# skill_id => [required_skill_id1, required_skill_id2]
JS_SKILL_SKILLS_REQUIREMENTS = {
  2 => [1],
  5 => [4,7,70],
  46 => [36,38,42],
}

# item_id => class_id
JS_ADD_JOB_ITEMS = {
  33 => 7,
  34 => 6,
  35 => 8,
  36 => 5,
  37 => 4,
  38 => 3,
  39 => 2,
  40 => 1,
}

# enemy_id => job_points
JS_ENEMY_JOB_POINTS = {
  1 => 1
}

# Intergration with Charlie Fleed's CTB
REMOVED_ACTORS_JOB_POINTS_QUOTA = 0.5
TRANSFORMED_ACTORS_JOB_POINTS_QUOTA = 0.5
SWITCHED_ACTORS_JOB_POINTS_QUOTA = 0.5

#==============================================================================
# ** END OF CONFIGURATION
#==============================================================================

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :available_jobs
  attr_accessor :active_jobs
  attr_accessor :passive_jobs
  attr_accessor :max_active_jobs
  attr_accessor :max_passive_jobs
  attr_accessor :job_points
  attr_accessor :learned_skills

  #--------------------------------------------------------------------------
  # * Object Initialization
  #    actor_id : actor ID
  #--------------------------------------------------------------------------
  alias js_initialize initialize
  def initialize(actor_id)
    js_initialize(actor_id)
    @available_jobs = []
    @max_active_jobs = JS_ACTIVE_JOBS_DEFAULT
    @max_passive_jobs = JS_PASSIVE_JOBS_DEFAULT
    @active_jobs = []
    @max_active_jobs.times do @active_jobs.push(nil) end
    @passive_jobs = []
    @max_passive_jobs.times do @passive_jobs.push(nil) end
    @job_points = {}
    @learned_skills = {}
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def add_available_job(job_id)
    @available_jobs.push(job_id)
    # initialize points and skills
    @job_points[job_id] = 0
    @learned_skills[job_id] = []
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def set_passive_job(job_id, position)
    @passive_jobs[position] = job_id
    return if job_id == nil
    for skill_id in @learned_skills[job_id]
      learn_skill(skill_id)
    end
  end
 
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def remove_passive_job(job_id, position)
    return if job_id == nil
    @passive_jobs[position] = nil
    for skill_id in @learned_skills[job_id]
      forget_skill(skill_id)
    end
  end
 
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def set_active_job(job_id, position)
    @active_jobs[position] = job_id
    return if job_id == nil
    for skill_id in @learned_skills[job_id]
      learn_skill(skill_id)
    end
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def remove_active_job(job_id, position)
    return if job_id == nil
    @active_jobs[position] = nil
    for skill_id in @learned_skills[job_id]
      forget_skill(skill_id)
    end
  end
 
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_learn_skill(skill_id)
   JS_JOB_SKILLS.each_key do |x|
      @learned_skills[x].push(skill_id)
   end
    learn_skill(skill_id)
  end
 
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_learn_all_skills
    for job_id in @active_jobs + @passive_jobs
      next if job_id == nil
      for skill_id in @learned_skills[job_id]
        learn_skill(skill_id)
      end
    end
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_skill_learn?(skill_id)
    result = true
    for learned_skills in @learned_skills.values
      if learned_skills.include?(skill_id)
        return true
      end
    end
    return false
  end
 

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_can_learn?(skill_id, job_id)
     if @job_points[job_id] >= JS_SKILL_COSTS[skill_id]
      if JS_SKILL_SKILLS_REQUIREMENTS[skill_id] == nil or
        (@learned_skills[job_id] &
        JS_SKILL_SKILLS_REQUIREMENTS[skill_id]).size ==
       JS_SKILL_SKILLS_REQUIREMENTS[skill_id].size
        if JS_SKILL_LEVEL_REQUIREMENTS[skill_id] == nil or
         @level >= JS_SKILL_LEVEL_REQUIREMENTS[skill_id]
         return true
        end
      end
      end
   return false
  end
 
 #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def js_get_job_points(value)
    for i in 0 ... @max_active_jobs
      next if @active_jobs[i] == nil
      @job_points[@active_jobs[i]] += job_points
    end
  end
 
end


#==============================================================================
# ** Window_Job_Skills
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Job_Skills < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(320, 128, 320, 352)
    @actor = actor
    @job_id = nil
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
 
  #--------------------------------------------------------------------------
  # * Acquiring Skill
  #--------------------------------------------------------------------------
  def skill
    return nil if @job_id == nil or self.index == -1
    return @data[self.index]
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    return if @job_id == nil
    @data = []
    for i in 0 ... JS_JOB_SKILLS[@job_id].size
      skill = $data_skills[JS_JOB_SKILLS[@job_id][i]]
      if skill != nil
        @data.push(skill)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Draw Item
  #    index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.js_can_learn?(skill.id, @job_id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32 - 4, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 32, y, 204, 32, skill.name, 0)
    if @actor.js_skill_learn?(skill.id)
      self.contents.draw_text(x + 236, y, 48, 32, "Learned", 2)
    else
      self.contents.draw_text(x + 236, y, 48, 32, JS_SKILL_COSTS[skill.id].to_s, 2)
    end
  end
 
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def job_id=(value)
    if @job_id != value
      @job_id = value
      refresh
    end
  end 
end


#==============================================================================
# ** Window_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Jobs < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 320, 128)
    @actor = actor
    @column_max = 1
    refresh
    self.index = 0
  end
 
  #--------------------------------------------------------------------------
  # * Acquiring job_id
  #--------------------------------------------------------------------------
  def job_id
    return @data[self.index]
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    self.contents = Bitmap.new(width - 32, (@actor.max_active_jobs +
      @actor.max_passive_jobs) * 32)
    for i in 0 ... @actor.max_active_jobs
      x = 0
      y = i * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = system_color
      self.contents.font.size = 16
      self.contents.draw_text(4, y, 32, 32, "ACT:", 0)
      self.contents.font.size = 24
      if @actor.active_jobs[i] != nil
        self.contents.font.color = normal_color
        self.contents.draw_text(x + 36, y, 88, 32, $data_classes[@actor.active_jobs[i]].name, 2)
        @data.push(@actor.active_jobs[i])
      else
        @data.push(nil)
      end
    end
    for i in 0 ... @actor.max_passive_jobs
      x = 0
      y = (i + @actor.max_active_jobs) * 32
      rect = Rect.new(x, y, self.width - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      self.contents.font.color = system_color
      self.contents.font.size = 16
      self.contents.draw_text(4, y, 32, 32, "PASS:", 0)
      self.contents.font.size = 24
      if @actor.passive_jobs[i] != nil
        self.contents.font.color = normal_color
        self.contents.draw_text(x + 36, y, 88, 32, $data_classes[@actor.passive_jobs[i]].name, 2)
        @data.push(@actor.passive_jobs[i])
      else
        @data.push(nil)
      end
    end
    @item_max = @data.size
  end
end


#==============================================================================
# ** Window_Available_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Available_Jobs < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 256, 320, 224)
    @actor = actor
    @column_max = 1
    refresh
    self.active = false
    self.index = -1
  end
 
  #--------------------------------------------------------------------------
  # * Acquiring job_id
  #--------------------------------------------------------------------------
  def job_id
    return @data[self.index]
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.available_jobs.size
      @data.push(@actor.available_jobs[i])
    end
    @data.push(nil)
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Draw Item
  #    index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    job_id = @data[index]
    return if job_id == nil
    if @actor.active_jobs.include?(job_id) or @actor.passive_jobs.include?(job_id)
      self.contents.font.color = disabled_color
    else
      self.contents.font.color = normal_color
    end
    x = 0
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 200, 32, $data_classes[job_id].name, 0)
    self.contents.draw_text(x + 204, y, 84, 32, @actor.job_points[job_id].to_s + " JP", 2)
  end 
end


#==============================================================================
# ** Window_Character_Info
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Character_Info < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = nil
    @job_id = nil
  end
  #--------------------------------------------------------------------------
  # * Set Values
  #--------------------------------------------------------------------------
  def set_values(actor, job_id)
    # If at least one value differs from last time
    if @actor != actor or @job_id != job_id
      @actor = actor
      @job_id = job_id
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Redraw text
    self.contents.clear
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 160, 32, @actor.name)
    return if @job_id == nil
    self.contents.font.color = system_color
    self.contents.draw_text(164, 0, 60, 32, "Job:", 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(224, 0, 100, 32, $data_classes[@job_id].name)   
    self.contents.font.color = system_color
    self.contents.draw_text(324, 0, 60, 32, "JP:", 0)
    self.contents.font.color = normal_color
    self.contents.draw_text(384, 0, 60, 32, @actor.job_points[@job_id].to_s)
  end
end


#==============================================================================
# ** Window_Skill_Info
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Skill_Info < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(640, 128, 320, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @skill = nil
  end
  #--------------------------------------------------------------------------
  # * Set Value
  #--------------------------------------------------------------------------
  def set_skill(skill)
    # If the value differs from last time
    if @skill != skill
      @skill = skill
      refresh
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Redraw text
    self.contents.clear
    return if @skill == nil
    x = 4
    y = 0
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Skill:")
    y += 32
    self.contents.font.color = normal_color
    bitmap = RPG::Cache.icon(@skill.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, self.width - 32 -32, 32, @skill.name)
    y += 32
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Level Required:")
    self.contents.font.color = normal_color
    y += 32
    if JS_SKILL_LEVEL_REQUIREMENTS[@skill.id] != nil
      self.contents.draw_text(x, y, self.width - 40, 32,
        JS_SKILL_LEVEL_REQUIREMENTS[@skill.id].to_s)
    end
    y += 32
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, self.width - 40, 32, "Skills Required:")
    self.contents.font.color = normal_color
    y += 32
    if JS_SKILL_SKILLS_REQUIREMENTS[@skill.id] != nil
      for i in 0 ... JS_SKILL_SKILLS_REQUIREMENTS[@skill.id].size
        req_skill = $data_skills[JS_SKILL_SKILLS_REQUIREMENTS[@skill.id][i]]
        bitmap = RPG::Cache.icon(req_skill.icon_name)
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
        self.contents.draw_text(x + 28, y, self.width - 32 -32, 32, req_skill.name)
        y += 32
      end
    end   
  end
end


#==============================================================================
# ** Scene_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Scene_Jobs
  #--------------------------------------------------------------------------
  # * Object Initialization
  #    actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0)
    @actor_index = actor_index
  end

  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make windows
    @help_window = Window_Help.new
    @character_info_window = Window_Character_Info.new
    @jobs_window = Window_Jobs.new(@actor)
    @available_jobs_window = Window_Available_Jobs.new(@actor)
    @job_skills_window = Window_Job_Skills.new(@actor)
    @skill_info_window = Window_Skill_Info.new

    @jobs_window.title = "Current Jobs"
    @jobs_window.refresh_title
    @available_jobs_window.title = "Available Jobs"
    @available_jobs_window.refresh_title
    @job_skills_window.title = "Job Skills"
    @job_skills_window.refresh_title
    @skill_info_window.title = "Skill Info"
    @skill_info_window.refresh_title
    if $game_party.actors.size > 1
      @character_info_window.title = "<< PAGE UP                                                                                                                PAGE DOWN >>"
      @character_info_window.refresh_title
    end
   
    @last_window = nil
    @learning = false

    # windows positions
    @jobs_window_x = 0
    @available_jobs_window_x = 0
    @job_skills_window_x = 320
    @skill_info_window_x = 640

    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @character_info_window.dispose
    @jobs_window.dispose
    @available_jobs_window.dispose
    @job_skills_window.dispose
    @skill_info_window.dispose   
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @jobs_window.refresh
    @available_jobs_window.refresh
    @job_skills_window.refresh
  end
 
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
   
    # move windows
    @jobs_window.x -= 16 if @jobs_window.x > @jobs_window_x
    @jobs_window.x += 16 if @jobs_window.x < @jobs_window_x
    @available_jobs_window.x -= 16 if @available_jobs_window.x > @available_jobs_window_x
    @available_jobs_window.x += 16 if @available_jobs_window.x < @available_jobs_window_x
    @job_skills_window.x -= 16 if @job_skills_window.x > @job_skills_window_x
    @job_skills_window.x += 16 if @job_skills_window.x < @job_skills_window_x
    @skill_info_window.x -= 16 if @skill_info_window.x > @skill_info_window_x
    @skill_info_window.x += 16 if @skill_info_window.x < @skill_info_window_x
     
    @available_jobs_window.update
    @job_skills_window.update
    @skill_info_window.set_skill(@job_skills_window.skill)
       
    if @jobs_window.active
      # If R button was pressed
      if Input.trigger?(Input::R)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor_index = (@actor_index + 1) % $game_party.actors.size
        $scene = Scene_Jobs.new(@actor_index)
        return
      end
      # If L button was pressed
      if Input.trigger?(Input::L)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor_index = (@actor_index - 1) % $game_party.actors.size
        $scene = Scene_Jobs.new(@actor_index)
        return
      end
      @jobs_window.update
      update_jobs
      return
    end
    if @available_jobs_window.active
      update_available_jobs
      return
    end
    if @job_skills_window.active
      update_job_skills
      return
    end
  end
 
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_jobs
    @job_skills_window.job_id = @jobs_window.job_id
    @character_info_window.set_values(@actor, @jobs_window.job_id)
    @help_window.set_text("Press ENTER to change a job, RIGHT or SHIFT to learn skills.")
   
    # If C button was pressed
    if Input.trigger?(Input::C)
      @jobs_window.active = false
      @available_jobs_window.active = true
      @available_jobs_window.index = 0
      return
    end
    # If SHIFT button was pressed
    if Input.trigger?(Input::SHIFT)
      @jobs_window.active = false
      @available_jobs_window.active = true
      @available_jobs_window.index = 0
      @learning = true
      return
    end
    # If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      return if @jobs_window.job_id == nil
      @last_window = @jobs_window
      @jobs_window.active = false
      @job_skills_window.active = true
      @job_skills_window.index = 0
      # Set windows movement
      @jobs_window_x = -320
      @available_jobs_window_x = -320
      @job_skills_window_x = 0
      @skill_info_window_x = 320
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end
 
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_available_jobs
    @character_info_window.set_values(@actor, @available_jobs_window.job_id)
    @job_skills_window.job_id = @available_jobs_window.job_id
    if @learning
      @help_window.set_text("Press RIGHT to learn skills.")
    else
      @help_window.set_text("Press ENTER to confirm a job, RIGHT to learn skills.")
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      @jobs_window.active = true
      @available_jobs_window.active = false
      @available_jobs_window.index = -1
      @learning = false
    end
    # If Right button was pressed
    if Input.trigger?(Input::RIGHT)
      return if @available_jobs_window.job_id == nil
      @last_window = @available_jobs_window
      @available_jobs_window.active = false
      @job_skills_window.active = true
      @job_skills_window.index = 0
      # Set windows movement
      @jobs_window_x = -320
      @available_jobs_window_x = -320
      @job_skills_window_x = 0
      @skill_info_window_x = 320
      return
    end
    unless @learning
      # If C button was pressed
      if Input.trigger?(Input::C)
        if @jobs_window.index < @actor.max_active_jobs
          job_id = @actor.active_jobs[@jobs_window.index]
          # Remove the current active job
          @actor.remove_active_job(job_id, @jobs_window.index)
          # Remove if active job
          for i in 0 ... @actor.active_jobs.size
            if @actor.active_jobs[i] == @available_jobs_window.job_id
              @actor.remove_active_job(@available_jobs_window.job_id, i)
            end
          end
          # Remove if passive job
          for i in 0 ... @actor.passive_jobs.size
            if @actor.passive_jobs[i] == @available_jobs_window.job_id
              @actor.remove_passive_job(@available_jobs_window.job_id, i)
            end
          end
          @actor.set_active_job(@available_jobs_window.job_id, @jobs_window.index)
          # Needed for skills in more than one job
          @actor.js_learn_all_skills
        else
          job_id = @actor.passive_jobs[@jobs_window.index - @actor.max_active_jobs]
          # Remove the current passive job
          @actor.remove_passive_job(job_id,
            @jobs_window.index - @actor.max_active_jobs)
          # Remove if active job
          for i in 0 ... @actor.active_jobs.size
            if @actor.active_jobs[i] == @available_jobs_window.job_id
              @actor.remove_active_job(@available_jobs_window.job_id, i)
            end
          end
          # Remove if passive job
          for i in 0 ... @actor.passive_jobs.size
            if @actor.passive_jobs[i] == @available_jobs_window.job_id
              @actor.remove_passive_job(@available_jobs_window.job_id, i)
            end
          end
          @actor.set_passive_job(@available_jobs_window.job_id,
            @jobs_window.index - @actor.max_active_jobs)
          # Needed for skills in more than one job
          @actor.js_learn_all_skills
        end
        @available_jobs_window.refresh
        @jobs_window.refresh
        @jobs_window.active = true
        @character_info_window.set_values(@actor, @available_jobs_window.job_id)
        @available_jobs_window.active = false
        @available_jobs_window.index = -1
        # Play equip SE
        $game_system.se_play($data_system.equip_se)
        return
      end
    end

  end
 
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update_job_skills
    @help_window.set_text(@job_skills_window.skill.description)
    # If B button was pressed
    if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT)
      @last_window.active = true
      @job_skills_window.active = false
      @job_skills_window.index = -1
      # Set windows movement
      @jobs_window_x = 0
      @available_jobs_window_x = 0
      @job_skills_window_x = 320
      @skill_info_window_x = 640
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      skill = @job_skills_window.skill
      if @actor.js_can_learn?(skill.id, @last_window.job_id)
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        @actor.js_learn_skill(skill.id)
        @actor.job_points[@last_window.job_id] -= JS_SKILL_COSTS[skill.id]
        @job_skills_window.refresh
        @available_jobs_window.refresh
        @character_info_window.refresh
        return
      end
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
  end
 
end


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias update_js update
  def update
    update_js
    # If waiting
    if @wait_count > 0
      # Decrease wait count
      @wait_count -= 1
      return
    end
    case @phase
    when 5.1  # after battle phase job points
      update_phase5_1
    end
  end

  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  alias start_phase5_js start_phase5
  def start_phase5
    # Make windows
    @job_points_window = Window_Job_Points.new
    job_points = 0
    # Loop
    for enemy in $game_troop.enemies
      # If enemy is not hidden
      unless enemy.hidden
        # Add EXP
        if JS_ENEMY_JOB_POINTS[enemy.id] != nil
          job_points += JS_ENEMY_JOB_POINTS[enemy.id]
        else
          job_points += enemy.exp
        end
      end
    end
    # Obtaining JOB POINTS
    # This is processed BEFORE return party in Charlie Fleed's CTB
    @actors_to_check = []
    if $charlie_lee_ctb !=nil # DETECTS Charlie Fleed's CTB
      # Actors removed for summon
      for a in $game_party.removed_actors
        @actors_to_check.push(a)
      end
      # Original form of transformed actors
      for a in $game_party.transformed_actors
        @actors_to_check.push(a)
      end
      # Actors in the backup party
      for a in $game_party.backup_actors
        @actors_to_check.push(a)
      end
    end
    for a in $game_party.actors
      @actors_to_check.push(a)
    end
    job_points_base = job_points
    for actor in @actors_to_check
      job_points = job_points_base
      if actor.cant_get_exp? == false
        if $charlie_lee_ctb !=nil # DETECTS CHARLIE FLEED'S CTB
          # Actors removed for summon
          if $game_party.removed_actors.include?(actor)
            job_points = Integer(job_points_base * REMOVED_ACTORS_JOB_POINTS_QUOTA)
          end
          # Original form of transformed actors
          if $game_party.transformed_actors.include?(actor)
            if $game_party.removed_actors.include?($game_actors[actor.transformed_form_id])
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA * REMOVED_ACTORS_LEARNING_EXP_QUOTA)
            elsif $game_party.backup_actors.include?($game_actors[actor.transformed_form_id])
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA * SWITCHED_ACTORS_LEARNING_EXP_QUOTA)
            else
              job_points = Integer(job_points_base * TRANSFORMED_ACTORS_JOB_POINTS_QUOTA)
            end
          end
          # Actors in the backup party
          if $game_party.backup_actors.include?(actor)
            job_points = Integer(job_points_base * SWITCHED_ACTORS_JOB_POINTS_QUOTA)
          end
        end
        for i in 0 ... actor.max_active_jobs
          next if actor.active_jobs[i] == nil
          actor.job_points[actor.active_jobs[i]] += job_points
          @job_points_window.entries.push(actor.name + " earned " +
            job_points.to_s + " JPs for the job " +  $data_classes[actor.active_jobs[i]].name) 
        end
      end
    end
    if not @job_points_window.entries.empty?
      @job_points_window.index = 0
    end
    # Original call
    start_phase5_js
  end

  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase)
  #--------------------------------------------------------------------------
  alias update_phase5_js update_phase5
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      update_phase5_js
    else
      # If C button was pressed
      if Input.trigger?(Input::C)
        if not @job_points_window.entries.empty?
          @job_points_window.visible = true
          @job_points_window.refresh
          @job_points_window.active = true
          @result_window.visible = false
          if $charlie_lee_ctb != nil and $charlie_lee_ctb_version != nil and $charlie_lee_ctb_version >= 2.11
          @result_window2.visible = false
          end
          @phase = 5.1
          @wait_count = 16
        else
          # Dispose job_points window
          @job_points_window.dispose
          battle_end(0)
        end
      end
    end
  end

  #--------------------------------------------------------------------------
  # * Frame Update (after battle phase - JOB POINTS WINDOW)
  #--------------------------------------------------------------------------
  def update_phase5_1
    # Update job points window
    @job_points_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Dispose job points window
      @job_points_window.dispose
      battle_end(0)
      return
    end
  end
end

#==============================================================================
# ** Window_Job_Points
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Job_Points < Window_Selectable
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  attr_accessor :entries
 
  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def initialize()
    @entries = []
    super(80, 0, 480, @entries.size * 32 + 32)
    self.active = false
    self.opacity = 160
    self.back_opacity = 255
    self.contents_opacity = 255
    self.z = 203
    self.visible = false
  end

  #--------------------------------------------------------------------------
  # *
  #--------------------------------------------------------------------------
  def refresh
    self.height = [@entries.size * 32 + 32, 192].min
    @item_max = @entries.size
    self.y = 160 - height / 2
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    self.contents.clear
    x = 4
    y = 4
    for entry in @entries
      self.contents.draw_text(x, y, self.width - 40, 32, entry)
      y += 32
    end
  end
end


#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
#  This class deals with battlers. It's used as a superclass for the Game_Actor
#  and Game_Enemy classes.
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Application of Item Effects
  #    item : item
  #--------------------------------------------------------------------------
  alias item_effect_js item_effect
  def item_effect(item)
    if JS_ADD_JOB_ITEMS[item.id] != nil
      if @available_jobs.include?(JS_ADD_JOB_ITEMS[item.id])
        return false
      else
        add_available_job(JS_ADD_JOB_ITEMS[item.id])
        return true
      end
    else
      return item_effect_js(item)
    end
  end
end


#==============================================================================
# ** Window_Available_Jobs
#------------------------------------------------------------------------------
#
#==============================================================================

class Window_Jobs_2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 304, 224)
    @actor = nil
    @column_max = 1
    self.active = false
    self.index = -1
    self.visible = false
    self.z = 9999
  end
   
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def set_actor(actor)
    if @actor != actor
      @actor = actor
      refresh
    end
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.available_jobs.size
      @data.push(@actor.available_jobs[i])
    end
    @data.push(nil)
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Draw Item
  #    index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    job_id = @data[index]
    return if job_id == nil
    x = 0
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x + 4, y, 90, 32, $data_classes[job_id].name, 0)
  end
 
end


#==============================================================================
# ** Scene Item
#------------------------------------------------------------------------------
#==============================================================================
class Scene_Item
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias js_main main
  def main
    @jobs_window = Window_Jobs_2.new
    @jobs_window.title = "Available Jobs"
    @jobs_window.refresh_title
    # Original call
    js_main
    @jobs_window.dispose
  end
 
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias js_update update
  def update
    if @target_window.active and @target_window.index >= 0
      @jobs_window.set_actor($game_party.actors[@target_window.index])
      if @target_window.x == 0
        @jobs_window.x = 336
      else
        @jobs_window.x = 0
      end
      @jobs_window.visible = true
    else
      @jobs_window.visible = false
    end
    # Original call
    js_update   
  end

  #--------------------------------------------------------------------------
  # * Update Target
  #--------------------------------------------------------------------------
  alias js_update_target update_target
  def update_target
    # Original call
    js_update_target   
    if Input.trigger?(Input::C)
      @jobs_window.refresh
    end
  end
end 


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # TITLE SUPPORT
  #--------------------------------------------------------------------------
  attr_accessor :title
  alias title_initialize initialize
  def initialize(x, y, width, height)
    # Title support
    @title = ""
    @title_sprite = Sprite.new
    @title_sprite.x = x + 4
    @title_sprite.y = y + 2
    @title_sprite.bitmap = Bitmap.new([1, width - 8].max, 16)
    @title_sprite.bitmap.font.size = 16
    @title_sprite.bitmap.font.bold = true
    title_initialize(x, y, width, height)
  end
  def x=(value)
    super
    @title_sprite.x = self.x + 4
  end
  def y=(value)
    super
    @title_sprite.y = self.y
  end
  def z=(value)
    super
    @title_sprite.z = self.z + 2
  end
  def visible=(value)
    super
    @title_sprite.visible = value
  end
  alias title_dispose dispose
  def dispose
    title_dispose
    @title_sprite.bitmap.dispose
    @title_sprite.dispose
  end
  def refresh_title
    @title_sprite.x = x + 4
    @title_sprite.y = y + 2
    @title_sprite.bitmap.clear
    @title_sprite.bitmap.font.color = system_color
    @title_sprite.bitmap.draw_text(@title_sprite.bitmap.rect, @title)
  end
end
Revenir en haut Aller en bas
Tedrainbow
Paysan (niveau 3)
Paysan (niveau 3)
Tedrainbow

Masculin
Messages postés : 25
Date d'inscription : 24/02/2012
Jauge LPC :
Job System by Charlie Fleed (Résolu) 89152714000 / 1000 / 100Job System by Charlie Fleed (Résolu) 8915271400


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptyVen 15 Nov 2013 - 21:04

Merci sa marche parfaitement, ^^

Revenir en haut Aller en bas
Zexion
Administrateur
Administrateur
Zexion

Masculin
Messages postés : 6228
Date d'inscription : 04/01/2012
Jauge LPC :
Job System by Charlie Fleed (Résolu) 891527140097 / 10097 / 100Job System by Charlie Fleed (Résolu) 8915271400

Job System by Charlie Fleed (Résolu) Membre15
Job System by Charlie Fleed (Résolu) Event-10
Job System by Charlie Fleed (Résolu) Altrui10
Job System by Charlie Fleed (Résolu) Action10
Job System by Charlie Fleed (Résolu) Travai10
Job System by Charlie Fleed (Résolu) Collec10
Job System by Charlie Fleed (Résolu) Collec11
Job System by Charlie Fleed (Résolu) Collec12
Job System by Charlie Fleed (Résolu) Staffe11
Job System by Charlie Fleed (Résolu) Dessin10


Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) EmptySam 16 Nov 2013 - 0:42

Et pouf, des points pour Shin, et je classe. Smile
Revenir en haut Aller en bas
Contenu sponsorisé




Job System by Charlie Fleed (Résolu) Empty
MessageSujet: Re: Job System by Charlie Fleed (Résolu)   Job System by Charlie Fleed (Résolu) Empty

Revenir en haut Aller en bas
 
Job System by Charlie Fleed (Résolu)
Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» [RESOLU]demande plutôt étrange [/RESOLU]
» [VX] Omega Map system
» craft system
» Djinn system
» [VX] Neo Save System

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Le Palais Créatif :: ~ APPRENTISSAGE ~ :: Entraide :: Problèmes résolus-
Sauter vers: