Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module DMTK
- module EQUIPMENTS
- WEAPONS = []
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- WEAPONS[1] = {#Dagger
- :icon => 150,
- :param6 => [nil, 2,3,4,5,6,7,8,9],
- :learn => [nil,nil,3,4,5,6,7,8],
- }
- WEAPONS[2] = {#Sword
- :icon => 147
- }
- WEAPONS[3] = {#Bow
- :icon => 149
- }
- WEAPONS[4] = {#Staff
- :icon => 152
- }
- WEAPONS[5] = {#Claw
- :icon => 145
- }
- WEAPONS[6] = {#Spear
- :icon => 146
- }
- WEAPONS[7] = {#Gun
- :icon => 153
- }
- WEAPONS[8] = {#Book
- :icon => 226
- }
- WEAPONS[9] = {#Scythe
- :icon => 155
- }
- WEAPONS[10]= {#Axe
- :icon => 144
- }
- WEAPONS[11]= {#Throw
- :icon => 154
- }
- WEAPONS[12]= {#Mace
- :icon => 151
- }
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- W_LEVEL_MAX = 8
- # 0 1 2 3 4 5 6 7 8
- W_LEVEL = ['F','E','D','C','B','A','S','SS','SSS']
- WL_COLOR= [ 8, 7, 30, 13, 9, 11, 17, 12, 18]
- end
- end
- #==============================================================================
- # * Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias dmtk_mastery_initialize initialize
- def initialize(*arg)
- dmtk_mastery_initialize(*arg)
- dmtk_mastery_init
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def dmtk_mastery_init
- @w_mastery = [0] * mastery_size
- @mastery_rank = [0] * mastery_size
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def mastery_size
- [DMTK::EQUIPMENTS::WEAPONS.size,$data_system.weapon_types.size].min
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def gain_mastery_exp(id, amount)
- return if @mastery_rank[id] == mastery_rank_max
- @w_mastery[id] += amount
- while @w_mastery[id] >= mastery_exp_next(id) && @mastery_rank[id] < mastery_rank_max
- mastery_rank_lvlup(id)
- if @mastery_rank[id] == mastery_rank_max
- @w_mastery[id] = mastery_exp_next(id)
- end
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def mastery_rank_lvlup(id)
- @mastery_rank[id] += 1
- arr = DMTK::EQUIPMENTS::WEAPONS[id][:learn]
- return if arr.nil?
- return if arr[@mastery_rank[id]].nil?
- learn_skill(arr[@mastery_rank[id]])
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def mastery_exp_for_rank(rank)
- (2 ** rank) * 10
- end
- def mastery_exp_next(w_id)
- mastery_exp_for_rank(@mastery_rank[w_id])
- end
- def mastery_exp_need(w_id)
- mastery_exp_next(w_id) - mastery_exp(w_id)
- end
- def mastery_exp_current(w_id)
- mastery_exp(w_id) - mastery_exp_for_rank(mastery_rank(w_id) - 1)
- end
- def mastery_exp_rate(w_id)
- mastery_exp_current(w_id).to_f / mastery_exp_next(w_id).to_f
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def mastery_exp(w_id)
- @w_mastery[w_id]
- end
- def mastery_rank(w_id)
- @mastery_rank[w_id]
- end
- def mastery_rank_txt(w_id)
- DMTK::EQUIPMENTS::W_LEVEL[mastery_rank(w_id)]
- end
- def mastery_rank_max
- DMTK::EQUIPMENTS::W_LEVEL_MAX
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def wtypes_equipped
- (1..mastery_size).to_a.select {|i| wtype_equipped?(i)}
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias dmtk_mastery_param_plus param_plus
- def param_plus(param_id)
- dmtk_mastery_param_plus(param_id) + mastery_param(param_id)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def mastery_param(param_id)
- sym = ("param" + param_id.to_s).to_sym
- wtypes_equipped.inject(0) {|r,wtype|
- arr = DMTK::EQUIPMENTS::WEAPONS[wtype][sym]
- if arr
- r += arr[mastery_rank(wtype)]
- else
- r
- end
- }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias dmtk_mastery_added_skills added_skills
- def added_skills
- dmtk_mastery_added_skills | mastery_added_skills
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def mastery_added_skills
- wtypes_equipped.inject([]) {|r,wtype|
- arr = DMTK::EQUIPMENTS::WEAPONS[wtype][:added_skills]
- if arr && arr[mastery_rank(wtype)]
- r |= arr[0..mastery_rank(wtype)].compact
- else
- r
- end
- }
- end
- end
- #==============================================================================
- # * Window_EquipSlot
- #==============================================================================
- class Window_EquipSlot < Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @actor = nil
- refresh
- @last_index = 0
- end
- #--------------------------------------------------------------------------
- # * Deselect Item
- #--------------------------------------------------------------------------
- def unselect
- @last_index = index
- super
- end
- #--------------------------------------------------------------------------
- # * Select Last
- #--------------------------------------------------------------------------
- def select_last
- select(@last_index) unless @last_index < 0
- @last_index = -1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def activate
- select_last
- super
- end
- #--------------------------------------------------------------------------
- # * Set Status Window
- #--------------------------------------------------------------------------
- def status_window=(status_window)
- @status_window = status_window
- call_update_help
- end
- #--------------------------------------------------------------------------
- # * Set Item Window
- #--------------------------------------------------------------------------
- def item_window=(item_window)
- @item_window = item_window
- update
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- super
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def process_handling
- super
- return unless open? && active
- call_handler(:shift) if Input.repeat?(:SHIFT)
- end
- end
- #==============================================================================
- # * Window_EquipItem
- #==============================================================================
- class Window_EquipItem < Window_ItemList
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_writer :status_window
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def temp_actor
- @status_window.temp_actor
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def call_update_help
- update_help if active && @status_window
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- super
- if @actor && @status_window
- temp_actor.force_change_equip(@slot_id, item)
- call_handler(:refresh_all)
- @active = true
- end
- end
- end
- #==============================================================================
- # * Window_ActorMastery
- #==============================================================================
- class Window_ActorMastery < Window_Selectable
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(0,0,160,Graphics.height)
- @actor = actor
- refresh
- activate
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def actor=(actor)
- @actor = actor
- refresh
- end
- def help_window=(help_window)
- @help_window = help_window
- @help_window.select(index)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def update
- last_index = index
- super
- if last_index != index && @help_window
- @help_window.select(index)
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_weapons if @actor
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def size
- DMTK::EQUIPMENTS::WEAPONS.size - (include_barehand? ? 0 : 1)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- alias item_max size
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def col_max
- 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def include_barehand?
- !DMTK::EQUIPMENTS::WEAPONS[0].nil?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def draw_weapons
- DMTK::EQUIPMENTS::WEAPONS.size.times {|idx|
- if include_barehand?
- i = idx
- else
- next if idx == 0
- i = idx - 1
- end
- contents.fill_rect(icon_x(i), icon_y(i), table_width - 4, table_height - 4, fill_color)
- draw_level(i,idx)
- draw_icon(w_icon(idx), icon_x(i), icon_y(i))
- change_color(system_color)
- draw_text(icon_x(i) + 26, icon_y(i), table_width-24, line_height, w_text(idx))
- }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def draw_level(i,idx)
- lvl = @actor.mastery_rank(idx)
- change_color(text_color(DMTK::EQUIPMENTS::WL_COLOR[lvl]))
- txt = @actor.mastery_rank_txt(idx)
- draw_text(icon_x(i)+2, icon_y(i), table_width-4, line_height, txt, 2)
- draw_gauge(icon_x(i)+2, gauge_y(i), table_width-8, exprate(idx), text_color(0), text_color(1))
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def exprate(idx)
- @actor.mastery_exp_rate(idx)
- end
- #--------------------------------------------------------------------------
- # * Get Color of Vertical Line
- #--------------------------------------------------------------------------
- def fill_color
- color = text_color(0)
- color.alpha = 48
- color
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def w_icon(i)
- return DMTK::EQUIPMENTS::WEAPONS[i][:icon]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def w_text(i)
- return $data_system.weapon_types[i]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def icon_x(i)
- 2
- end
- def icon_y(i)
- 2 + line_height * 2 * i
- end
- def gauge_y(i)
- 16 + line_height * 2 * i
- end
- def table_width
- contents_width
- end
- def table_height
- line_height*2
- end
- def contents_height
- table_height * size
- end
- alias item_width table_width
- alias item_height table_height
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def select(idx)
- super(idx)
- @weaponmastery_window.set_w_id(idx) if @weaponmastery_window
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def weaponmastery_window=(w)
- @weaponmastery_window = w
- end
- #--------------------------------------------------------------------------
- # * Actor Settings
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- end
- #==============================================================================
- # * Window_WeaponMastery
- #==============================================================================
- class Window_WeaponMastery < Window_Selectable
- def initialize(x,y)
- @lines = 1
- super(x, y, Graphics.width - x, Graphics.height - y)
- clear_texts
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def contents_height
- line_height * @lines
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def clear_texts
- @lines = level_max
- @texts = Array.new(level_max, '')
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def level_max
- DMTK::EQUIPMENTS::W_LEVEL_MAX + 1
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def set_w_id(id)
- @w_id = id
- refresh
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def w_id
- if include_barehand?
- @w_id
- else
- @w_id + 1
- end
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def include_barehand?
- !DMTK::EQUIPMENTS::WEAPONS[0].nil?
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_informations if @index
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def draw_informations
- create_texts
- create_contents
- draw_text_ex(0,0,texts)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def create_texts
- clear_texts
- arr = DMTK::EQUIPMENTS::WEAPONS[w_id]
- #--------------------------------------------------------------------------
- learn = arr[:learn]
- if learn
- level_max.times {|i|
- next unless learn[i]
- skill = $data_skills[learn[i]]
- @texts[i] += sprintf(" Learn Skill: \eI[%d]%s\n",skill.icon_index,skill.name)
- @lines += 1
- }
- end
- #--------------------------------------------------------------------------
- added_skills = arr[:added_skills]
- if added_skills
- level_max.times {|i|
- next unless added_skills[i]
- skill = $data_skills[added_skills[i]]
- @texts[i] += sprintf(" Enable to use Skill: \eI[%d]%s\n",skill.icon_index,skill.name)
- @lines += 1
- }
- end
- #--------------------------------------------------------------------------
- 8.times {|param_id|
- sym = ("param" + param_id.to_s).to_sym
- param_plus = arr[sym]
- next unless param_plus
- level_max.times {|i|
- if param_plus[i]
- @texts[i] += sprintf(" %s + %d when equip %s\n",Vocab::param(param_id),param_plus[i],w_text)
- @lines += 1
- end
- }
- }
- #--------------------------------------------------------------------------
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def texts
- i = -1
- @texts.inject("") {|r,t|
- i += 1
- r += sprintf("At Rank %s:\n%s",rank_text(i),t)
- }
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def rank_text(rank)
- sprintf("\eC[%d]%s\eC[0]", rank_color(rank), DMTK::EQUIPMENTS::W_LEVEL[rank])
- end
- def rank_color(rank)
- DMTK::EQUIPMENTS::WL_COLOR[rank]
- end
- def w_text
- $data_system.weapon_types[w_id]
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def item_max
- @lines
- end
- end
- #==============================================================================
- # * Scene_Mastery
- #==============================================================================
- class Scene_Mastery < Scene_MenuBase
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def start
- super
- create_actormastery_window
- create_status_window
- create_weaponmastery_window
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def create_actormastery_window
- @actormastery_window = Window_ActorMastery.new(@actor)
- @actormastery_window.set_handler(:ok, method(:on_weapon_ok))
- @actormastery_window.set_handler(:cancel, method(:return_scene))
- @actormastery_window.set_handler(:pagedown, method(:next_actor))
- @actormastery_window.set_handler(:pageup, method(:prev_actor))
- @actormastery_window.viewport = @viewport
- end
- #--------------------------------------------------------------------------
- # * Create Status Window
- #--------------------------------------------------------------------------
- def create_status_window
- @status_window = Window_SkillStatus.new(160, 0)
- @status_window.viewport = @viewport
- @status_window.actor = @actor
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def create_weaponmastery_window
- x = @actormastery_window.width
- y = @status_window.height
- @weaponmastery_window = Window_WeaponMastery.new(x,y)
- @weaponmastery_window.viewport = @viewport
- @weaponmastery_window.set_handler(:cancel, method(:on_weapon_cancel))
- @actormastery_window.weaponmastery_window = @weaponmastery_window
- @actormastery_window.select(0)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def on_weapon_ok
- @weaponmastery_window.activate
- @weaponmastery_window.select(0)
- end
- #--------------------------------------------------------------------------
- # *
- #--------------------------------------------------------------------------
- def on_weapon_cancel
- @actormastery_window.activate
- @weaponmastery_window.unselect
- end
- #--------------------------------------------------------------------------
- # * Change Actors
- #--------------------------------------------------------------------------
- def on_actor_change
- @actormastery_window.actor = @actor
- @status_window.actor = @actor
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement