#=======================================================
# Yazik - Skill & State Shop
#=======================================================
$imported = {} if $imported == nil
$imported[:Yazik_Skill_State_Shop] = true
#=======================================================
# Configurations
#=======================================================
module Yazik
module Actor
#--------------------------------------------------
# Script Call:
# 1. Actor's Add Skill Points
# add_skill_points(actor_id, points)
#--------------------------------------------------
# Starting Skill Point (When Actor at Level 1)
StartingSkillPoint = 1
# Skill Point Gain (When Actor Leveled Up)
SkillPointGain = 1
end
module SkillShop
# Command Name in Main Menu
CommandName = 'Temple'
# Command Index in Main Menu
CommandIndex = 1
# Skill Point Symbol
SkillPointSymbol = '\C[16]W\C[0]'
# Total Skill Point Text
TotalSkillPointText = '\C[16]Waves: \C[0]'
# Total Skill Point Text's X & Y position
TotalSkillPointText_X = 216
TotalSkillPointText_Y = 216
# Vocab on Option Window
VocabBuy = 'Acquire'
VocabCancel = 'Cancel'
# Help Window Settings
HelpWindow_Opacity = 0
HelpWindow_LineNumber = 4
# Shop Window Settings
ShopWindow_Opacity = 0
ShopWindow_Column = 4
ShopWindow_X = 0
ShopWindow_Y = 22
ShopWindow_Width = Graphics.width * 3/4
ShopWindow_Height = (6 * 24) + 2 * 12
# Actor's Skill Shop Database
ShopDatabase = {
# actor_id => [[skill_id, price], ..., [skill_id, price]],
#player
1 => [[139, 2], [140, 2], [133, 3], [127, 3], [51, 3], [50, 3], [8, 2], [135, 4], [60, 1], [102, 1], [28, 1], [29, 1], [2, 2], [53, 1], [54, 1], [117, 1],
[55, 1], [56, 1], [57, 1], [44, 1], [124, 1], [97, 1], [75, 4, :state, "Teaches you how to use bows."],
[74, 2, :state, "Teaches you how to use spears."], [88, 4, :state, "Teaches you how to use artifacts."], [112, 1, :state, "Teaches you how to use axes."],
[101, 8, :state, "Doubles maximum magia points (continuously)."], [105, 2, :state, "+2% HP Regen."], [104, 5, :state, "200% Status Recovery Rate"],
[102, 6, :state, "+15% DEF stat"], [68, 4, :state, "Immune to common poisons and venoms."], [4, 4, :state, "+150% TP Charge Rate."],
[110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."], [125, 4, :state, "Immune to stat debuffs."]],
#3 Bran
3 => [[6, 2], [10, 3], [11, 2], [28, 1], [29, 1], [97, 1], [123, 4, :state, "DEF stat is doubled."], [125, 3, :state, "Immune to stat debuffs."]],
#4 Huiliang
4 => [[137, 2], [60, 1], [28, 1], [29, 1], [97, 1], [125, 5, :state, "Immune to stat debuffs."]],
#5 Xia
5 => [[156, 3], [146, 1], [147, 2], [166, 1], [133, 1], [108, 2], [145, 2], [170, 1], [51, 1], [141, 4], [139, 1], [140, 1], [44, 1],
[68, 2, :state, "Immune to common poisons and venoms."], [101, 4, :state, "Doubles maximum magia points."], [125, 1, :state, "Immune to stat debuffs."]],
#7 Hana
7 => [[45, 4], [50, 4], [13, 3], [14, 3], [15, 3], [16, 4], [135, 3], [3, 1], [12, 1], [60, 1], [102, 1], [202, 3], [28, 1], [29, 1], [44, 1],
[75, 2, :state, "Teaches you how to use bows."], [76, 4, :state, "Teaches you how to use swords."],
[87, 1, :state, "Teaches you how to wear magia clothes."], [68, 2, :state, "Immune to common poisons and venoms."],
[101, 8, :state, "Doubles maximum magia points (continuously)."], [4, 3, :state, "+150% TP Charge Rate."],
[100, 6, :state, "60% Frost Resistance, 10% Agility boost, +2 HP Regen, Immune to State: Hypothermia"], [125, 2, :state, "Immune to stat debuffs."],
[110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."]],
#8 Bloodfang
8 => [[59, 5], [22, 3], [24, 4], [25, 2], [45, 2], [60, 1], [28, 1], [29, 1], [165, 1], [90, 1], [88, 5, :state, "Teaches you how to use artifacts."],
[101, 8, :state, "Doubles maximum magia points (continuously)."], [68, 4, :state, "Immune to common poisons and venoms."],
[4, 5, :state, "+150% TP Charge Rate."], [110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."],
[125, 3, :state, "Immune to stat debuffs."]],
#9 Azar
9 => [[81, 2], [82, 3], [84, 4], [56, 3], [59, 4], [60, 1], [90, 1], [101, 8, :state, "Doubles maximum magia points (continuously)."],
[4, 2, :state, "+150% TP Charge Rate."], [68, 2, :state, "Immune to common poisons and venoms."], [125, 4, :state, "Immune to stat debuffs."],
[110, 2, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."]],
#10 Tsei
10 => [[71, 10], [74, 8], [76, 9], [60, 1], [28, 1], [29, 1], [97, 1], [101, 8, :state, "Doubles maximum magia points (continuously)."],
[68, 4, :state, "Immune to common poisons and venoms."], [4, 2, :state, "+150% TP Charge Rate."], [125, 5, :state, "Immune to stat debuffs."],
[110, 3, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."]],
#12 Kaliska
12 => [[38, 7], [39, 7], [51, 2], [60, 1], [101, 2, :state, "Doubles maximum magia points (continuously)."],
[68, 2, :state, "Immune to common poisons and venoms."], [4, 4, :state, "+150% TP Charge Rate."], [125, 4, :state, "Immune to stat debuffs."],
[110, 2, :state, "Any damage you would receive higher than 90% of your max Health is completely nullified."],
[123, 4, :state, "DEF stat is doubled."], [124, 3, :state, "Kaliska received -60% Light and Dark damage, and also +1 HRG"]],
#20 Celeste
20 => [[59, 4], [191, 2], [109, 1], [68, 2, :state, "Immune to common poisons and venoms."], [105, 2, :state, "+2% HP Regen."],
[125, 2, :state, "Immune to stat debuffs."]],
#21 Nuala
21 => [[6, 2], [10, 3], [11, 2], [28, 1], [29, 1], [44, 1], [97, 1], [123, 4, :state, "DEF stat is doubled."], [125, 4, :state, "Immune to stat debuffs."]],
}
# Actor's Skill Shop Group Background
# Place background graphic in Graphics/Pictures folder
ShopBackground = {
# actor_id => "Filename",
# Set "" into filename to disable background.
1 => "nl-scare2",
2 => "nl-scare2",
3 => "nl-scare2",
4 => "nl-scare2",
5 => "nl-scare2",
6 => "nl-scare2",
7 => "nl-scare2",
8 => "nl-scare2",
9 => "nl-scare2",
10 => "nl-scare2",
11 => "nl-scare2",
12 => "nl-scare2",
13 => "nl-scare2",
14 => "nl-scare2",
15 => "nl-scare2",
16 => "nl-scare2",
17 => "nl-scare2",
18 => "nl-scare2",
19 => "nl-scare2",
20 => "nl-scare2",
21 => "nl-scare2",
}
end
end
#==============================================================================
# ** Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Addd Skill Points
#--------------------------------------------------------------------------
def add_skill_points(actor_id, points)
$game_actors[actor_id].skill_point += points
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Variables
#--------------------------------------------------------------------------
attr_accessor :skill_point
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
alias :yazik_lsk_setup :setup
def setup(actor_id)
yazik_lsk_setup(actor_id)
if @level > 1
sp = Yazik::Actor::StartingSkillPoint
@skill_point = sp + Yazik::Actor::SkillPointGain * (@level - 1)
else
@skill_point = Yazik::Actor::StartingSkillPoint
end
end
#--------------------------------------------------------------------------
# * Level Up
#--------------------------------------------------------------------------
alias :lune_sk_level_up :level_up
def level_up
lune_sk_level_up
@skill_point += Yazik::Actor::SkillPointGain
end
end
#==============================================================================
# ** Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def insert_command(index, name, symbol, enabled = true, ext = nil)
cmd = {:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}
@list.insert(index, cmd)
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
alias :yazik_lst_make_command_list :make_command_list
def make_command_list
yazik_lst_make_command_list
cmd_index = Yazik::SkillShop::CommandIndex
cmd_name = Yazik::SkillShop::CommandName
insert_command(cmd_index, cmd_name, :skill_tree, main_commands_enabled)
end
end
#==============================================================================
# ** Window_ShopSkill
#==============================================================================
class Window_ShopSkill < Window_SkillList
#--------------------------------------------------------------------------
# * Variáveis públicas
#--------------------------------------------------------------------------
attr_reader :skill_tree
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, w, h)
super(x, y, w, h)
self.opacity = Yazik::SkillShop::ShopWindow_Opacity
self.contents_opacity = 255
end
#--------------------------------------------------------------------------
# * Get Digit Count
#--------------------------------------------------------------------------
def col_max
return Yazik::SkillShop::ShopWindow_Column
end
#--------------------------------------------------------------------------
# * Include in Skill List?
#--------------------------------------------------------------------------
def include?(item)
return item
end
#--------------------------------------------------------------------------
# * Display Skill in Active State?
#--------------------------------------------------------------------------
def enable?(item)
return item
end
#--------------------------------------------------------------------------
# * Create Skill List
#--------------------------------------------------------------------------
def make_item_list
if @actor
skills = []
db = Yazik::SkillShop::ShopDatabase[@actor.id]
for i in 0...db.size
if db[i][2] == :state
state_id = db[i][0]
if @actor.state_addable?(state_id)
state = $data_states[state_id]
skills.push(state)
end
else
skill = $data_skills[db[i][0]]
if @actor.added_skill_types.include?(skill.stype_id)
skills.push(skill)
end
end
end
@data = skills
else
@data = []
end
end
#--------------------------------------------------------------------------
# * Draw Item
#--------------------------------------------------------------------------
def draw_item(index)
data = @data[index]
if data
rect = item_rect(index)
rect.width -= 4
enabled = data.class == RPG::Skill ? @actor.skill_learn?(data) : @actor.state?(data.id)
draw_skill_icon(index, data, rect.x, rect.y, enabled)
draw_skill_price(rect, index)
end
end
#--------------------------------------------------------------------------
# * Draw Item Name
#--------------------------------------------------------------------------
def draw_skill_icon(index, item, x, y, enabled)
return unless item
draw_icon(item.icon_index, x, y, enabled)
end
#--------------------------------------------------------------------------
# * Draw Skill Price
#--------------------------------------------------------------------------
def draw_skill_price(rect, index)
db = Yazik::SkillShop::ShopDatabase[@actor.id]
price = db[index][1]
draw_text_ex(rect.x + 24 + 4, rect.y, price.to_s + Yazik::SkillShop::SkillPointSymbol)
end
end
#==============================================================================
# ** Window_ShopHelp
#==============================================================================
class Window_ShopHelp < Window_Help
#--------------------------------------------------------------------------
# * Inicialização
#--------------------------------------------------------------------------
def initialize(line_number = Yazik::SkillShop::HelpWindow_LineNumber)
super(line_number)
self.opacity = Yazik::SkillShop::HelpWindow_Opacity
self.contents_opacity = 255
@item_name = ''
end
#--------------------------------------------------------------------------
# * Clear
#--------------------------------------------------------------------------
alias :yazik_ss_clear :clear
def clear
@item_name = ''
yazik_ss_clear
end
#--------------------------------------------------------------------------
# * Set Name
#--------------------------------------------------------------------------
def set_name(item_name)
if item_name != @item_name
@item_name = item_name
refresh
end
end
#--------------------------------------------------------------------------
# * Set Item
#--------------------------------------------------------------------------
alias :yazik_ss_set_item :set_item
def set_item(item)
set_name(item ? item.name : "")
if SceneManager.scene_is?(Scene_SkillShop)
if (item) and (item.class == RPG::State)
set_text(SceneManager.scene.database_item[3])
return
end
end
yazik_ss_set_item(item)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(system_color)
draw_text(4, 0, contents_width - 4, line_height, @item_name)
change_color(normal_color)
draw_text_ex(4, line_height, @text)
reset_font_settings
end
end
#==============================================================================
# ** Window_TotalSkillPoint
#==============================================================================
class Window_TotalSkillPoint < Window_Base
#--------------------------------------------------------------------------
# * Inicialização
#--------------------------------------------------------------------------
def initialize
super(0, 0, Graphics.width, Graphics.height)
@actor = nil
self.z = 200
self.opacity = 0
self.contents_opacity = 255
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Atualização
#--------------------------------------------------------------------------
def refresh
contents.clear
tx = Yazik::SkillShop::TotalSkillPointText_X
ty = Yazik::SkillShop::TotalSkillPointText_Y
txt = Yazik::SkillShop::TotalSkillPointText + @actor.skill_point.to_s
draw_text_ex(tx, ty, txt)
end
end
#==============================================================================
# ** Window_ShopConfirm
#==============================================================================
class Window_ShopConfirm < Window_Command
#--------------------------------------------------------------------------
# * Inicialização do objeto
#--------------------------------------------------------------------------
def initialize
super(0, 0)
self.z = 9999
self.x = (Graphics.width - self.width) / 2
self.y = (Graphics.height - self.height) / 2
self.openness = 0
end
#--------------------------------------------------------------------------
# * Aquisição da largura da janela
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Criação da lista de comandos
#--------------------------------------------------------------------------
def make_command_list
add_main_commands
end
#--------------------------------------------------------------------------
# * Get Alignment
#--------------------------------------------------------------------------
def alignment
return 1
end
#--------------------------------------------------------------------------
# * Adição dos comandos principais
#--------------------------------------------------------------------------
def add_main_commands
add_command(Yazik::SkillShop::VocabBuy, :confirm_buy, true)
add_command(Yazik::SkillShop::VocabCancel, :confirm_cancel, true)
end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
alias :yazik_lst_create_command_window :create_command_window
def create_command_window
yazik_lst_create_command_window
@command_window.set_handler(:skill_tree, method(:command_personal))
end
#--------------------------------------------------------------------------
# * [OK] Personal Command
#--------------------------------------------------------------------------
alias :yazik_lst_on_personal_ok :on_personal_ok
def on_personal_ok
case @command_window.current_symbol
when :skill_tree
SceneManager.call(Scene_SkillShop)
else
yazik_lst_on_personal_ok
end
end
end
#==============================================================================
# ** Scene_SkillShop
#==============================================================================
class Scene_SkillShop < Scene_Skill
#--------------------------------------------------------------------------
# * Inicialização do processo
#--------------------------------------------------------------------------
def start
super
# create_actor_window
create_info_window
create_confirm_window
create_background_image
end
#--------------------------------------------------------------------------
# * Remove Default Scene_Skill Windows
#--------------------------------------------------------------------------
def create_command_window; end
def create_status_window; end
#--------------------------------------------------------------------------
# * Create Help Window
#--------------------------------------------------------------------------
def create_help_window
@help_window = Window_ShopHelp.new(4)
@help_window.viewport = @viewport
@help_window.x = 0
@help_window.y = Graphics.height - @help_window.height
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_window
wx = Yazik::SkillShop::ShopWindow_X
wy = Yazik::SkillShop::ShopWindow_Y
ww = Yazik::SkillShop::ShopWindow_Width
wh = Yazik::SkillShop::ShopWindow_Height
@item_window = Window_ShopSkill.new(wx, wy, ww, wh)
@item_window.actor = @actor
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:return_scene))
@item_window.select(0)
@item_window.activate
end
#--------------------------------------------------------------------------
# * Item [OK]
#--------------------------------------------------------------------------
def on_item_ok
is_skill = item.class == RPG::Skill
is_state = item.class == RPG::State
if (is_skill and !@actor.skill_learn?(item)) or (is_state and !@actor.state?(item.id))
db = Yazik::SkillShop::ShopDatabase[@actor.id]
price = db[@item_window.index][1]
if price <= $game_actors[@actor.id].skill_point
@confirm_window.open
@confirm_window.select(0)
@confirm_window.activate
else
Sound.play_buzzer
@item_window.activate
end
else
@item_window.activate
end
end
#--------------------------------------------------------------------------
# * Criação das Janelas
#--------------------------------------------------------------------------
def create_confirm_window
@confirm_window = Window_ShopConfirm.new
@confirm_window.set_handler(:confirm_buy, method(:buy_item))
@confirm_window.set_handler(:confirm_cancel, method(:activate_shop_window))
@confirm_window.set_handler(:cancel, method(:activate_shop_window))
@confirm_window.close
@confirm_window.deactivate
end
#--------------------------------------------------------------------------
# * Create Info Window
#--------------------------------------------------------------------------
def create_info_window
@info_window = Window_TotalSkillPoint.new
@info_window.actor = @actor
end
#--------------------------------------------------------------------------
# * Activate Shop Window
#--------------------------------------------------------------------------
def activate_shop_window
@confirm_window.close
@confirm_window.deactivate
@item_window.refresh
@item_window.activate
end
#--------------------------------------------------------------------------
# * Create Background Image
#--------------------------------------------------------------------------
def create_background_image
bg = Yazik::SkillShop::ShopBackground[@actor.id]
@background_image = Sprite.new
@background_image.bitmap = Cache.picture(bg)
end
#--------------------------------------------------------------------------
# * Database Item
#--------------------------------------------------------------------------
def database_item
return Yazik::SkillShop::ShopDatabase[@actor.id][@item_window.index]
end
#--------------------------------------------------------------------------
# * Buy Skill or State
#--------------------------------------------------------------------------
def buy_item
db = Yazik::SkillShop::ShopDatabase[@actor.id]
if db[@item_window.index][2] == :state
state_id = db[@item_window.index][0]
state_price = db[@item_window.index][1]
$game_actors[@actor.id].skill_point -= state_price
$game_actors[@actor.id].add_state(state_id)
else
skill_id = db[@item_window.index][0]
skill_price = db[@item_window.index][1]
$game_actors[@actor.id].skill_point -= skill_price
$game_actors[@actor.id].learn_skill(skill_id)
end
@info_window.refresh
@confirm_window.close
@confirm_window.deactivate
@item_window.refresh
@item_window.activate
end
#--------------------------------------------------------------------------
# * Terminate
#--------------------------------------------------------------------------
def terminate
super
@background_image.bitmap.dispose
@background_image.dispose
end
end