01-09-2012, 02:17 AM
Optimized some of the code, and reduced conflicts, thanks to Zeriab! Still stuck on the main issue though. 前進あるのみ!
Code:
#===============================================================================
# ■ Character Skills
# Version 0.00
#-------------------------------------------------------------------------------
# Author: Tenseiten/Tensei/Kirotan/Tohsaka
# Last Updated: 2012/01/06 JST
#===============================================================================
module Tenseiten
#--------------------------------------------------------------------------
# * Interchange Module
#--------------------------------------------------------------------------
# Allows other scripts using the Tenseiten module to share components with
# this script. This script must be placed before other interchange compliant
# scripts bearing the Tenseiten module.
#--------------------------------------------------------------------------
module INTERCHANGE
USINGSKILLS = true
end
module SKILLS
# BEGIN CONFIG
LEVELGAIN = 5 # Base Value for Points Per Level
TEST = "A test"
SKILLNAME = []
#SKILLNAME[id] = "skill name"
SKILLNAME[0] = "Alchemy"
SKILLNAME[1] = "Thaumatology"
SKILLNAME[2] = "Hacking"
SKILLNAME[3] = "Yanderehood"
SKILLNAME[4] = "Art"
SKILLNAME[5] = "Scripting"
SKILLNAME[6] = "Cooking"
SKILLNAME[7] = "Trolling"
SKILLNAME[8] = "Testing"
SKILLNAME[9] = "Double Rainbow"
SKILLNAME[10] = "All the way"
SKILLNAME[11] = "Across the Sky"
SKILLNAME[12] = "What does it mean?"
# END CONFIG
end # End Skills
end # End Tenseiten
module DataManager
class << self
alias_method :aliased_create_game_objects, :create_game_objects
def create_game_objects
aliased_create_game_objects
$game_skillpoints = Game_SkillPoints.new
end
#--------------------------------------------------------------------------
# ● セーブ内容の作成
#--------------------------------------------------------------------------
alias_method :aliased_make_save_contents, :make_save_contents
def make_save_contents
contents = aliased_make_save_contents
contents[:skillpoints] = $game_skillpoints
contents
end
#--------------------------------------------------------------------------
# ● セーブ内容の展開
#--------------------------------------------------------------------------
alias_method :aliased_extract_save_contents, :extract_save_contents
def extract_save_contents(contents)
aliased_extract_save_contents
$game_skillpoints = contents[:skillpoints]
end
end
end
#==============================================================================
# ■ Game_SkillPoints
#------------------------------------------------------------------------------
# Uses Game_SkillPoints to save data
#==============================================================================
class Game_SkillPoints
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :skillpoint
attr_accessor :skillboost
attr_accessor :freepoints
#--------------------------------------------------------------------------
# ● Initialization
#--------------------------------------------------------------------------
def initialize
@skillpoint = Array.new(Tenseiten::SKILLS::SKILLNAME.size, 0)
@skillboost = Array.new(Tenseiten::SKILLS::SKILLNAME.size, 0)
@freepoints = 0
end
def modpoint(id, value)
@skillpoint[id] = @skillpoint[id] + value
end
def modboost(id, value)
@skillboost[id] = @skillboost[id] + value
end
end
#==============================================================================
# ■ Window_SkillComponents
#------------------------------------------------------------------------------
# Displays the header window
#==============================================================================
class Window_SkillComponents < Window_Base
#--------------------------------------------------------------------------
# ● Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 397, 54)
self.opacity = 255
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(-1, -2, 144, 24, 'Skills')
end
end
#==============================================================================
# ■ Window_SkillFree
#------------------------------------------------------------------------------
# Displays the header window
#==============================================================================
class Window_SkillFree < Window_Base
#--------------------------------------------------------------------------
# ● Initialization
#--------------------------------------------------------------------------
def initialize
super(397, 0, 148, 54)
self.opacity = 255
refresh
end
def display_free_points
pointhack = $game_skillpoints.freepoints
return "%03d" % pointhack
end
def refresh
self.contents.clear
fsize = self.contents.font.size
self.contents.font.size = 15
self.contents.draw_text(4, -5, 264, 24, "Free Points")
self.contents.font.size = 20
self.contents.draw_text(80, 2, 264, 24, display_free_points)
self.contents.font.size = fsize
end
end
#==============================================================================
# ■ Window_SkillSelections
#------------------------------------------------------------------------------
# Displays the the main window
#==============================================================================
class Window_SkillSelections < Window_Selectable
#--------------------------------------------------------------------------
# ● Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 55, 544, 362)
self.opacity = 255
@item_max = Tenseiten::SKILLS::SKILLNAME.size
refresh
end
def draw_horz_line(y)
line_y = y + line_height / 2 - 1
contents.fill_rect(0, line_y, contents_width, 2, line_color)
end
def line_color
color = normal_color
color.alpha = 48
color
end
def create_heading
self.contents.draw_text(0, 0, 168, 24, "Skill")
self.contents.draw_text(260, 0, 168, 24, "Level")
self.contents.draw_text(360, 0, 168, 24, "Buff")
self.contents.draw_text(460, 0, 168, 24, "Total")
draw_horz_line(line_height * 1)
end
def create_list
for skilltemp in 0...Tenseiten::SKILLS::SKILLNAME.size
skill_point = $game_skillpoints.skillpoint[skilltemp]
skill_boost = $game_skillpoints.skillboost[skilltemp]
skill_total = $game_skillpoints.skillpoint[skilltemp] + $game_skillpoints.skillboost[skilltemp]
self.contents.draw_text(0, line_height * (skilltemp + 2), 168, 24, Tenseiten::SKILLS::SKILLNAME[skilltemp])
self.contents.draw_text(260, line_height * (skilltemp + 2), 168, 24, skill_point)
self.contents.draw_text(360, line_height * (skilltemp + 2), 168, 24, skill_boost)
self.contents.draw_text(460, line_height * (skilltemp + 2), 168, 24, skill_total)
end
end
def refresh
self.contents.clear
create_heading
create_list
end
end
#==============================================================================
# ■ Scene_CharSkills
#------------------------------------------------------------------------------
# Character Skills Scene
#==============================================================================
class Scene_CharSkills < Scene_Base
#--------------------------------------------------------------------------
# ● Start
#--------------------------------------------------------------------------
def start
super
create_windows
init_selection
end
def create_windows
@titlewindow = Window_SkillComponents.new()
@counterwindow = Window_SkillFree.new()
@skillwindow = Window_SkillSelections.new()
end
def init_selection
end
def update
super
@titlewindow.update
@counterwindow.update
@skillwindow.update
if Input.trigger?(Input::B)
@skillwindow.active = false
SceneManager.call(Scene_Map)
end
end
def terminate
super
end
end