Hey liebe Communty
Hier möchte ich das erste Script hochladen, welches ich voll funktionsfähig verallgemeinert habe und in jedes Projekt passt...
Durch dieses Script können die Skills der Charaktere verbessert werden.. Leicht einzugbauen und zu konfigurieren...
Aber zuerst einmal dieses Script: Es ermöglicht das hinzufügen von Command-Punkten in die Commands..
class Window_Command < Window_Selectable
unless method_defined?(:add_command)
def add_command(command)
@commands << command
@item_max = @commands.size
item_index = @item_max - 1
refresh_command
draw_item(item_index)
return item_index
end
def refresh_command
buf = self.contents.clone
self.height = [self.height, row_max * WLH + 32].max
create_contents
self.contents.blt(0, 0, buf, buf.rect)
buf.dispose
end
def insert_command(index, command)
@commands.insert(index, command)
@item_max = @commands.size
refresh_command
refresh
end
def remove_command(command)
@commands.delete(command)
@item_max = @commands.size
refresh
end
end
end
So nun zum eigentlichen Script...
#==============================================================================
# ** Sartekk's Skill Upgrade System
#------------------------------------------------------------------------------
# scripted by Sartekk
#==============================================================================
module Datas
UPGRADE_MAX = 15 # Maximale Upgrade Stufe
POINTS_PER_LEVEL = 1 # Punkte durch Level Up erhalten
UPGRADE_TYPES = {
#typ => [base_damage, attack_f, spirit_f, upgradekosten, downgradekosten],
"typ_1" => [10,15,0,4,2], # Physical normal
"typ_2" => [20,30,0,6,3], # Phiysical strong
"typ_3" => [10,0,15,4,2], # Mental normal
"typ_4" => [20,0,30,6,3], # Mental strong
"typ_5" => [10,15,15,4,2], # Allround normal
"typ_6" => [20,30,30,6,3], # Allround strong
"typ_7" => [30,40,40,10,5], # High-End
}
TAG = "Skill Upgrade" # Menü Anzeige
POINT_CUR = "Upgrade Punkte: " # Anzeige in der Skill Auswahl
end
class Skill_Upgrade < Scene_Base
def initialize(actor_index = 0, menu_point = 0)
@actor_index = actor_index
@menu_point = menu_point
end
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@help_window = Window_Help.new
@help_window.viewport = @viewport
@skill_win = Skill_Upgrade_Win.new(0, 56, 544, 360, $game_party.members[@actor_index])
@skill_win.viewport = @viewport
@skill_win.help_window = @help_window
@points_win = Window_U_Points.new(0,360,@actor_index)
@points_win.opacity = 130
@costs = Window_Costs.new(360)
@costs.opacity = 130
decision_win
@skill_win.active = true
@dec_win.active = false
@dec_win.visible = false
end
def update
super
update_menu_background
@points_win.update
@help_window.update
$skills.costs = Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][3]+$skills.skill_up[@skill.id]
if @skill_win.active
update_skill_selection
elsif @dec_win.active
update_dec_selection
end
@skill_win.update
@dec_win.update
@costs.refresh
end
def terminate
super
dispose_menu_background
@points_win.dispose
@help_window.dispose
@skill_win.dispose
@dec_win.dispose
@costs.dispose
end
def update_skill_selection
@skill = @skill_win.skill
if Input.trigger?(Input::C)
Sound.play_decision
@skill_win.active = false
@dec_win.active = true
@dec_win.visible = true
elsif Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Menu.new(@menu_point)
end
end
def upgrade
$data_skills[@skill.id].name = $skills.old_name[@skill.id]+" [upgrade "+($skills.skill_up[@skill.id]+1).to_s+"]"
if $data_skills[@skill.id].base_damage <= 0
$data_skills[@skill.id].base_damage -= Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][0]
else
$data_skills[@skill.id].base_damage += Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][0]
end
$data_skills[@skill.id].atk_f += Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][1]
$data_skills[@skill.id].spi_f += Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][2]
$game_actors[$game_party.members[@actor_index].id].upgrade_points -= Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][3] + $skills.skill_up[@skill.id]
$skills.skill_up[@skill.id] += 1
@skill_win.refresh
@points_win.refresh
end
def downgrade
if $skills.skill_up[@skill.id] != 1
$data_skills[@skill.id].name = $skills.old_name[@skill.id]+" [upgrade "+($skills.skill_up[@skill.id]-1).to_s+"]"
else
$data_skills[@skill.id].name = $skills.old_name[@skill.id]
end
if $data_skills[@skill.id].base_damage <= 0
$data_skills[@skill.id].base_damage += Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][0]
else
$data_skills[@skill.id].base_damage -= Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][0]
end
$data_skills[@skill.id].atk_f -= Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][1]
$data_skills[@skill.id].spi_f -= Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][2]
$game_actors[$game_party.members[@actor_index].id].upgrade_points += Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][4] + $skills.skill_up[@skill.id]
$skills.skill_up[@skill.id] -= 1
@skill_win.refresh
@points_win.refresh
end
def decision_win
s1 = "Upgrade"
s2 = "Downgrade"
s3 = "Abbrechen"
@dec_win = Window_Command.new(250,[s1,s2,s3])
@dec_win.x = (544-@dec_win.width)/2
@dec_win.y = (416-@dec_win.height)/2
end
def update_dec_selection
if Input.trigger?(Input::C)
case @dec_win.index
when 0
if $skills.skill_up[@skill.id] == Datas::UPGRADE_MAX
Sound.play_buzzer
dispose_dec_win
else
if $game_actors[$game_party.members[@actor_index].id].upgrade_points >= Datas::UPGRADE_TYPES[$data_skills[@skill.id].upgrade_type][3] + $skills.skill_up[@skill.id]
Sound.play_use_item
upgrade
dispose_dec_win
else
Sound.play_buzzer
dispose_dec_win
end
end
when 1
if $skills.skill_up[@skill.id] == 0
Sound.play_buzzer
dispose_dec_win
else
Sound.play_use_item
downgrade
dispose_dec_win
end
when 2
Sound.play_cancel
dispose_dec_win
end
elsif Input.trigger?(Input::B)
Sound.play_cancel
dispose_dec_win
end
end
def dispose_dec_win
@dec_win.index = 0
@skill_win.active = true
@dec_win.active = false
@dec_win.visible = false
end
end
class Skills
attr_accessor :skill_up
attr_accessor :old_name
attr_accessor :costs
def initialize
@skill_up = {}
@old_name = {}
@costs = costs
setup
end
def setup
for all in 1..$data_skills.size
@skill_up[all] = 0
end
for all2 in 1..$data_skills.size-1
@old_name[all2] = $data_skills[all2].name
end
end
end
class Scene_Title < Scene_Base
alias create_skills create_game_objects
def create_game_objects
create_skills
$skills = Skills.new
end
end
class Skill_Upgrade_Win < Window_Selectable
def initialize(x,y,width,height,actor)
super(x, y, width, height)
@actor = actor
@column_max = 2
self.index = 0
refresh
end
def skill
return @data[self.index]
end
def refresh
@data = []
for skill in @actor.skills
@data.push(skill)
if skill.id == @actor.last_skill_id
self.index = @data.size - 1
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
skill = @data[index]
if skill != nil
rect.width -= 4
enabled = @actor.skill_can_use?(skill)
draw_item_name(skill, rect.x, rect.y, enabled)
self.contents.draw_text(rect, @actor.calc_mp_cost(skill), 2)
end
end
def update_help
@help_window.set_text(skill == nil ? "" : skill.description)
end
end
module RPG
class BaseItem
def upgrade_type
self.note.each_line { |line|
return line.gsub('Upgrade_Typ = ', '').chomp.to_s if line.include?('Upgrade_Typ = ')
}
return "typ_1"
end
end
end
class Game_Actor < Game_Battler
attr_accessor :upgrade_points
alias new_things initialize
def initialize(actor_id)
new_things(actor_id)
@upgrade_points = 0
end
alias new_levelup level_up
def level_up
new_levelup
@upgrade_points += Datas::POINTS_PER_LEVEL
end
end
class Scene_Menu < Scene_Base
alias create_menu_point create_command_window
def create_command_window
create_menu_point
@skill_upgrade_command =
@command_window.add_command(Datas::TAG)
if @command_window.oy > 0
@command_window.oy -= Window_Base::WLH
end
@command_window.index = @menu_index
end
alias update_menu_point update_command_selection
def update_command_selection
call_s_upgrade_flag = false
if Input.trigger?(Input::C)
case @command_window.index
when @skill_upgrade_command
call_s_upgrade_flag = true
end
end
if call_s_upgrade_flag
if $game_party.members.size == 0
Sound.play_buzzer
return
end
Sound.play_decision
start_actor_selection
return
end
update_menu_point
end
alias update_actor_selection_skill_u update_actor_selection
def update_actor_selection
if Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when @skill_upgrade_command
$scene = Skill_Upgrade.new(
@status_window.index,
@skill_upgrade_command)
return
end
end
update_actor_selection_skill_u
end
end
class Window_U_Points < Window_Base
def initialize(x, y,actor)
super(x, y, 215, WLH + 32)
@actor = actor
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(2,-3,215,32 , Datas::POINT_CUR + $game_actors[$game_party.members[@actor].id].upgrade_points.to_s)
end
end
class Window_Costs < Window_Base
def initialize(y)
super(544 - 215, y, 215, WLH + 32)
refresh
end
def refresh
self.contents.clear
self.contents.draw_text(2,-3,215,32 , "Kosten: " + $skills.costs.to_s)
end
end
Changelog:
-Kosten erhöhen sich bei upgrade
-Neues Fenster welches die Kosten des aktuellen Scripts anzeigt
Und bei Veränderungen der Upgrade Points außer der Reihe ist diese nette call Script Commando Zeile gut:
$game_actors[Actor ID].upgrade_points = neue Zahl
Bei Verwendung wäre ein Credit Eintrag nett :)
mfG Juggernaut aka Sartekk