class Game_Actor < Game_Battler
attr_reader :ap #Ability Points
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias ajjg_init initialize
def initialize(actor_id)
ajjg_init(actor_id)
@ap = init_ap
end
#--------------------------------------------------------------------------
# * Get Maximum Value of Parameter
#--------------------------------------------------------------------------
def param_max(param_id)
return 9999 if param_id == 0 # MHP
return 999 if param_id == 1 #MMP
return super
end
#--------------------------------------------------------------------------
# * Initialize Actor AP
#--------------------------------------------------------------------------
def init_ap
self.ap = self.max_ap
end
#--------------------------------------------------------------------------
# * Change AP
#--------------------------------------------------------------------------
def ap=(ap)
@ap = [[ap, max_ap].min, 0].max
end
#--------------------------------------------------------------------------
# * Get Maximum Value of AP
#--------------------------------------------------------------------------
def max_ap
return [9 + (self.level / 3) + (self.mmp / 16), 99].min
end
#--------------------------------------------------------------------------
# * Get Percentage of AP
#--------------------------------------------------------------------------
def ap_rate
@ap.to_f / self.max_ap
end
#--------------------------------------------------------------------------
# * Calculate Skill's AP Cost
#--------------------------------------------------------------------------
def skill_ap_cost(skill)
skill.ap_cost
end
#--------------------------------------------------------------------------
# * Get Skill's attached State ID
#--------------------------------------------------------------------------
def skill_st_id(skill)
skill.skill_st
end
end #Game_Actor
#--------------------------------------------------------------------------
class RPG::Skill
#LOAD SKILL NOTETAGS
#------------------------------------------------------------------------------
# * AP-Cost. Set using <ap x> notetag.
#------------------------------------------------------------------------------
def ap_cost
if
@note =~ /<ap (.*)>/i
return $1.to_i
else
return 0
end
end
#--------------------------------------------------------------------------
# * Skill's attached State ID
#--------------------------------------------------------------------------
def skill_st
if
@note =~ /<st (.*)>/i
return $1.to_i
else
return 0
end
end
end #RPG::Skill
class Window_SetSkills < Window_SkillList
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
@stype_id = 15
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
draw_item_name(skill, rect.x + 8, rect.y, set_skill_able(skill))
draw_skill_cost(rect, skill)
draw_item_icon(skill, rect.x + 8, rect.y)
end
end
#--------------------------------------------------------------------------
# * Check if Actor has enough AP for skill
#--------------------------------------------------------------------------
def set_skill_able(skill_id)
if @actor.state?(@actor.skill_st_id(skill_id)) || @actor.ap >= @actor.skill_ap_cost(skill_id)
return true
else
return false
end
end
#--------------------------------------------------------------------------
# * Draw Icon indicating whether a skill is on or not
#--------------------------------------------------------------------------
def draw_item_icon(skill_id, x, y)
if @actor.state?(@actor.skill_st_id(skill_id))
draw_icon(536, x, y)
else
draw_icon(535, x, y)
end
end
#--------------------------------------------------------------------------
# * Overwritten Method: Draw Skill Use Cost
#--------------------------------------------------------------------------
def draw_skill_cost(rect, skill)
draw_text(rect, @actor.skill_ap_cost(skill), 2)
end
#--------------------------------------------------------------------------
# * Overwritten Method: Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
make_item_list
create_contents
draw_all_items
end
end #Window_SetSkills
#--------------------------------------------------------------------------
class Scene_SetSkills < Scene_ItemBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_help_window
create_status_window
create_item_window
end
#--------------------------------------------------------------------------
# * Create Status Window
#--------------------------------------------------------------------------
def create_status_window
y = @help_window.y + (@help_window.height + 4)
@status_window = Window_SkillStatus.new(16, y)
@status_window.x = (Graphics.width - @status_window.width) / 2
@status_window.viewport = @viewport
@status_window.actor = @actor
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_window
wx = 16
wy = @status_window.y + (@status_window.height)
ww = @status_window.width
wh = Graphics.height - (wy + 24)
@item_window = Window_SetSkills.new(wx, wy, ww, wh)
@item_window.x = (Graphics.width - @item_window.width) / 2
@item_window.actor = @actor
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.activate
@item_window.select_last
@item_window.set_handler
🙂ok, method
🙂toggle_skill))
@item_window.set_handler
🙂cancel, method
🙂return_scene))
@item_window.set_handler
🙂pagedown, method
🙂next_actor))
@item_window.set_handler
🙂pageup, method
🙂prev_actor))
end
#--------------------------------------------------------------------------
# * Toggle Currently Highlighted Skill
#--------------------------------------------------------------------------
def toggle_skill
@actor.last_skill.object = item
state_id = @actor.skill_st_id(item)
ap_cost = @actor.skill_ap_cost(item)
if @actor.state?(state_id)
@actor.remove_state(state_id)
@actor.ap += ap_cost
elsif
[email protected]?(state_id) && @actor.ap >= ap_cost
@actor.add_state(state_id)
@actor.ap -= ap_cost
elsif @actor.ap < ap_cost
Sound.play_buzzer
end
@item_window.refresh
@status_window.refresh
@item_window.activate
end
#--------------------------------------------------------------------------
# * Change Actors
#--------------------------------------------------------------------------
def on_actor_change
@status_window.actor = @actor
@item_window.actor = @actor
@item_window.activate
end
end #Scene_SetSkills