01-08-2012, 01:08 PM
Hi Save-Point:
I've been working on a script that functions as a Skill menu, similar to skills in Dungeons and Dragons, Elder Scrolls, Fallout, or even Star Wars Knights of the Old Republic. I have the menu displaying, but I've run into a slight snag- I don't know how to add a movable selection cursor to the scene that specifically affects the window, how to load up another window on top of it (and pass in relevant information), and how to scroll the view, as I can only display 11 entries right now.
The code I'm using is designed for RPG Maker VXAce, however, the only Ace functionality that I really make use of is the DataManager (which handles marshall.dump), and SceneManager (calls scenes), so this script can be easily ported to VX, and should be compatible in its current form.
I've been working on a script that functions as a Skill menu, similar to skills in Dungeons and Dragons, Elder Scrolls, Fallout, or even Star Wars Knights of the Old Republic. I have the menu displaying, but I've run into a slight snag- I don't know how to add a movable selection cursor to the scene that specifically affects the window, how to load up another window on top of it (and pass in relevant information), and how to scroll the view, as I can only display 11 entries right now.
The code I'm using is designed for RPG Maker VXAce, however, the only Ace functionality that I really make use of is the DataManager (which handles marshall.dump), and SceneManager (calls scenes), so this script can be easily ported to VX, and should be compatible in its current form.
Content Hidden
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
def self.create_game_objects
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_timer = Game_Timer.new
$game_message = Game_Message.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_skillpoints = Game_SkillPoints.new
end
#--------------------------------------------------------------------------
# ● セーブ内容の作成
#--------------------------------------------------------------------------
def self.make_save_contents
contents = {}
contents[:system] = $game_system
contents[:timer] = $game_timer
contents[:message] = $game_message
contents[:switches] = $game_switches
contents[:variables] = $game_variables
contents[:self_switches] = $game_self_switches
contents[:actors] = $game_actors
contents[:party] = $game_party
contents[:troop] = $game_troop
contents[:map] = $game_map
contents[:player] = $game_player
contents[:skillpoints] = $game_skillpoints
contents
end
#--------------------------------------------------------------------------
# ● セーブ内容の展開
#--------------------------------------------------------------------------
def self.extract_save_contents(contents)
$game_system = contents[:system]
$game_timer = contents[:timer]
$game_message = contents[:message]
$game_switches = contents[:switches]
$game_variables = contents[:variables]
$game_self_switches = contents[:self_switches]
$game_actors = contents[:actors]
$game_party = contents[:party]
$game_troop = contents[:troop]
$game_map = contents[:map]
$game_player = contents[:player]
$game_skillpoints = contents[:skillpoints]
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 = [] #empty skill point array
@skillboost = [] #empty skill buff array
@freepoints = 0
for iter in 0...Tenseiten::SKILLS::SKILLNAME.size
@skillpoint[iter] = 0
@skillboost[iter] = 0
end
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
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_title_window
create_counter_window
create_skill_window
@skillwindow.active = true
end
def create_title_window
@titlewindow = Window_SkillComponents.new()
end
def create_counter_window
@counterwindow = Window_SkillFree.new()
end
def create_skill_window
@skillwindow = Window_SkillSelections.new()
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