-
Seibur
-
-
Вне сайта
-
Просветлённый
-
- Сообщений: 371
- Спасибо получено: 308
-
-
|
#==============================================================================
# Rbahamut's Custom scene before title screen V1.0
#-----------------------------------------------------------------------------------------------------------------------------
# ABOVE SCRIPT
#------------------------------------------------------------------------------
# This module takes you to where the START POSITION MAP is...
# so wherever you want your scene to start you make it here
# this can be easily skipped by creating anywhere on the map,
# an event that runs in parallel process that has a conditional
# branch that will return to title screen when C button is pushed
# or whatever button you wanna use to skip to the title screen.
# * if you are using default key inputs C is bound to ENTER SPACE and Z
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
# * Execute
#--------------------------------------------------------------------------
def self.run
RPGDM.init
Audio.setup_midi if use_midi?
self.run_map
@scene.main while @scene
end
#--------------------------------------------------------------------------
# * Run Map
#--------------------------------------------------------------------------
def self.run_map
RPGDM.setup_new_game
$game_map.autoplay
SceneManager.goto(Scene_Map)
end
end
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# This module manages the database and game objects. Almost all of the
# global variables used by the game are initialized by this module.
#==============================================================================
module RPGDM
#--------------------------------------------------------------------------
# * Module Instance Variables
#--------------------------------------------------------------------------
@last_savefile_index = 0 # most recently accessed file
#--------------------------------------------------------------------------
# * Initialize Module
#--------------------------------------------------------------------------
def self.init
@last_savefile_index = 0
load_database
create_game_objects
setup_battle_test if $BTEST
end
#--------------------------------------------------------------------------
# * Load Database
#--------------------------------------------------------------------------
def self.load_database
if $BTEST
load_battle_test_database
else
load_normal_database
check_player_location
end
end
#--------------------------------------------------------------------------
# * Load Normal Database
#--------------------------------------------------------------------------
def self.load_normal_database
$data_actors = load_data("Data/Actors.rvdata2")
$data_classes = load_data("Data/Classes.rvdata2")
$data_skills = load_data("Data/Skills.rvdata2")
$data_items = load_data("Data/Items.rvdata2")
$data_weapons = load_data("Data/Weapons.rvdata2")
$data_armors = load_data("Data/Armors.rvdata2")
$data_enemies = load_data("Data/Enemies.rvdata2")
$data_troops = load_data("Data/Troops.rvdata2")
$data_states = load_data("Data/States.rvdata2")
$data_animations = load_data("Data/Animations.rvdata2")
$data_tilesets = load_data("Data/Tilesets.rvdata2")
$data_common_events = load_data("Data/CommonEvents.rvdata2")
$data_system = load_data("Data/System.rvdata2")
$data_mapinfos = load_data("Data/MapInfos.rvdata2")
end
#--------------------------------------------------------------------------
# * Load Battle Test Database
#--------------------------------------------------------------------------
def self.load_battle_test_database
$data_actors = load_data("Data/BT_Actors.rvdata2")
$data_classes = load_data("Data/BT_Classes.rvdata2")
$data_skills = load_data("Data/BT_Skills.rvdata2")
$data_items = load_data("Data/BT_Items.rvdata2")
$data_weapons = load_data("Data/BT_Weapons.rvdata2")
$data_armors = load_data("Data/BT_Armors.rvdata2")
$data_enemies = load_data("Data/BT_Enemies.rvdata2")
$data_troops = load_data("Data/BT_Troops.rvdata2")
$data_states = load_data("Data/BT_States.rvdata2")
$data_animations = load_data("Data/BT_Animations.rvdata2")
$data_tilesets = load_data("Data/BT_Tilesets.rvdata2")
$data_common_events = load_data("Data/BT_CommonEvents.rvdata2")
$data_system = load_data("Data/BT_System.rvdata2")
end
#--------------------------------------------------------------------------
# * Check Player Start Location Existence
#--------------------------------------------------------------------------
def self.check_player_location
if $data_system.start_map_id == 0
msgbox(Vocab::PlayerPosError)
exit
end
end
#--------------------------------------------------------------------------
# * Create Game Objects
#--------------------------------------------------------------------------
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
end
#--------------------------------------------------------------------------
# * Set Up New Game
#--------------------------------------------------------------------------
def self.setup_new_game
create_game_objects
$game_party.setup_starting_members
$game_map.setup($data_system.start_map_id)
$game_player.moveto($data_system.start_x, $data_system.start_y)
$game_player.refresh
Graphics.frame_count = 0
end
#--------------------------------------------------------------------------
# * Set Up Battle Test
#--------------------------------------------------------------------------
def self.setup_battle_test
$game_party.setup_battle_test
BattleManager.setup($data_system.test_troop_id)
BattleManager.play_battle_bgm
end
#--------------------------------------------------------------------------
# * Determine Existence of Save File
#--------------------------------------------------------------------------
def self.save_file_exists?
!Dir.glob('Save*.rvdata2').empty?
end
#--------------------------------------------------------------------------
# * Maximum Number of Save Files
#--------------------------------------------------------------------------
def self.savefile_max
return 16
end
#--------------------------------------------------------------------------
# * Create Filename
# index : File Index
#--------------------------------------------------------------------------
def self.make_filename(index)
sprintf("Save%02d.rvdata2", index + 1)
end
#--------------------------------------------------------------------------
# * Execute Save
#--------------------------------------------------------------------------
def self.save_game(index)
begin
save_game_without_rescue(index)
rescue
delete_save_file(index)
false
end
end
#--------------------------------------------------------------------------
# * Execute Load
#--------------------------------------------------------------------------
def self.load_game(index)
load_game_without_rescue(index) rescue false
end
#--------------------------------------------------------------------------
# * Load Save Header
#--------------------------------------------------------------------------
def self.load_header(index)
load_header_without_rescue(index) rescue nil
end
#--------------------------------------------------------------------------
# * Execute Save (No Exception Processing)
#--------------------------------------------------------------------------
def self.save_game_without_rescue(index)
File.open(make_filename(index), "wb") do |file|
$game_system.on_before_save
Marshal.dump(make_save_header, file)
Marshal.dump(make_save_contents, file)
@last_savefile_index = index
end
return true
end
#--------------------------------------------------------------------------
# * Execute Load (No Exception Processing)
#--------------------------------------------------------------------------
def self.load_game_without_rescue(index)
File.open(make_filename(index), "rb") do |file|
Marshal.load(file)
extract_save_contents(Marshal.load(file))
reload_map_if_updated
@last_savefile_index = index
end
return true
end
#--------------------------------------------------------------------------
# * Load Save Header (No Exception Processing)
#--------------------------------------------------------------------------
def self.load_header_without_rescue(index)
File.open(make_filename(index), "rb") do |file|
return Marshal.load(file)
end
return nil
end
#--------------------------------------------------------------------------
# * Delete Save File
#--------------------------------------------------------------------------
def self.delete_save_file(index)
File.delete(make_filename(index)) rescue nil
end
#--------------------------------------------------------------------------
# * Create Save Header
#--------------------------------------------------------------------------
def self.make_save_header
header = {}
header[:characters] = $game_party.characters_for_savefile
header[:playtime_s] = $game_system.playtime_s
header
end
#--------------------------------------------------------------------------
# * Create Save Contents
#--------------------------------------------------------------------------
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
end
#--------------------------------------------------------------------------
# * Extract Save Contents
#--------------------------------------------------------------------------
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]
end
#--------------------------------------------------------------------------
# * Reload Map if Data Is Updated
#--------------------------------------------------------------------------
def self.reload_map_if_updated
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
$game_player.make_encounter_count
end
end
#--------------------------------------------------------------------------
# * Get Update Date of Save File
#--------------------------------------------------------------------------
def self.savefile_time_stamp(index)
File.mtime(make_filename(index)) rescue Time.at(0)
end
#--------------------------------------------------------------------------
# * Get File Index with Latest Update Date
#--------------------------------------------------------------------------
def self.latest_savefile_index
savefile_max.times.max_by {|i| savefile_time_stamp(i) }
end
#--------------------------------------------------------------------------
# * Get Index of File Most Recently Accessed
#--------------------------------------------------------------------------
def self.last_savefile_index
@last_savefile_index
end
end
#==============================================================================
# Rbahamut's Custom start after title screen V1.0
#-----------------------------------------------------------------------------------------------------------------------------
# BELOW SCRIPT
#------------------------------------------------------------------------------
# This script makes the title screen take you to the start of your game which is different from the
# players start position... you need to know the MAP ID and x, y coords to say where you want
# your actor/s to start when selecting NEW GAME from title screen, those places are marked with
# #COMMENT and located at end of script
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
SceneManager.clear
Graphics.freeze
create_background
create_foreground
create_command_window
play_title_music
end
#--------------------------------------------------------------------------
# * Get Transition Speed
#--------------------------------------------------------------------------
def transition_speed
return 20
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
SceneManager.snapshot_for_background
dispose_background
dispose_foreground
end
#--------------------------------------------------------------------------
# * Create Background
#--------------------------------------------------------------------------
def create_background
@sprite1 = Sprite.new
@sprite1.bitmap = Cache.title1($data_system.title1_name)
@sprite2 = Sprite.new
@sprite2.bitmap = Cache.title2($data_system.title2_name)
center_sprite(@sprite1)
center_sprite(@sprite2)
end
#--------------------------------------------------------------------------
# * Create Foreground
#--------------------------------------------------------------------------
def create_foreground
@foreground_sprite = Sprite.new
@foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
@foreground_sprite.z = 100
draw_game_title if $data_system.opt_draw_title
end
#--------------------------------------------------------------------------
# * Draw Game Title
#--------------------------------------------------------------------------
def draw_game_title
@foreground_sprite.bitmap.font.size = 48
rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)
@foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1)
end
#--------------------------------------------------------------------------
# * Free Background
#--------------------------------------------------------------------------
def dispose_background
@sprite1.bitmap.dispose
@sprite1.dispose
@sprite2.bitmap.dispose
@sprite2.dispose
end
#--------------------------------------------------------------------------
# * Free Foreground
#--------------------------------------------------------------------------
def dispose_foreground
@foreground_sprite.bitmap.dispose
@foreground_sprite.dispose
end
#--------------------------------------------------------------------------
# * Move Sprite to Screen Center
#--------------------------------------------------------------------------
def center_sprite(sprite)
sprite.ox = sprite.bitmap.width / 2
sprite.oy = sprite.bitmap.height / 2
sprite.x = Graphics.width / 2
sprite.y = Graphics.height / 2
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_TitleCommand.new
@command_window.set_handler(:new_game, method(:command_new_game))
@command_window.set_handler(:continue, method(:command_continue))
@command_window.set_handler(:shutdown, method(:command_shutdown))
end
#--------------------------------------------------------------------------
# * Close Command Window
#--------------------------------------------------------------------------
def close_command_window
@command_window.close
update until @command_window.close?
end
#--------------------------------------------------------------------------
# * [New Game] Command
#--------------------------------------------------------------------------
def command_new_game
DataManager.setup_new_game
close_command_window
fadeout_all
$game_map.autoplay
SceneManager.goto(Scene_Map)
end
#--------------------------------------------------------------------------
# * [Continue] Command
#--------------------------------------------------------------------------
def command_continue
close_command_window
SceneManager.call(Scene_Load)
end
#--------------------------------------------------------------------------
# * [Shut Down] Command
#--------------------------------------------------------------------------
def command_shutdown
close_command_window
fadeout_all
SceneManager.exit
end
#--------------------------------------------------------------------------
# * Play Title Screen Music
#--------------------------------------------------------------------------
def play_title_music
$data_system.title_bgm.play
RPG::BGS.stop
RPG::ME.stop
end
end
#==============================================================================
# ** DataManager
#------------------------------------------------------------------------------
# This module manages the database and game objects. Almost all of the
# global variables used by the game are initialized by this module.
#==============================================================================
module DataManager
#--------------------------------------------------------------------------
# * Module Instance Variables
#--------------------------------------------------------------------------
@last_savefile_index = 0 # most recently accessed file
#--------------------------------------------------------------------------
# * Initialize Module
#--------------------------------------------------------------------------
def self.init
@last_savefile_index = 0
load_database
create_game_objects
setup_battle_test if $BTEST
end
#--------------------------------------------------------------------------
# * Set Up New Game
#--------------------------------------------------------------------------
def self.setup_new_game
create_game_objects
$game_party.setup_starting_members
$game_map.setup(3) # this is where u choose which map u want the new game to start on (map_id)
$game_player.moveto(22, 14) # This is where u put in the coords of the map u want the new game to start on (x, y)
$game_player.refresh
Graphics.frame_count = 0
end
end
=begin
================================================================================
KURO DEMO EFFECT V3.0
================================================================================
Introduction :
On screen effect that could be called anywhere anytime.
================================================================================
Changelog :
V.1.0 (11-06-2010)
* Awal pembuatan, dan selesainya script.
* Jenis text
* Bisa edit color, font, bold, italic, position, size, dan windowskin
V.1.1 (16-06-2010)
* Menghilangkan windowskin yang katanya (saya?) cukup mengganggu
* Memperbaiki sedikit BUG pada text align....
V.2.0 (30-06-2010)
* Rekonstruksi ulang! Langsung, plug and play!
* Nambahin random text position dengan men set align = 0
* Nambahin text opacity
* Nambahin demo ga jelas....
V.3.0 BETA (15-07-2012)
* EVOLUSI !!!!! Dari Kuro Demo Text menjadi Kuro Demo Effect.
* Sekarang pake picture yang ditaruh di folder System.
* Terlalu advanced dan masih kasar....
* Memiliki 4 jenis efek. Shakey, Blink, Spin, Frame Animation.
V.3.0 (26-07-2013)
* INFINTY EFFECT! (Hindari pemakaian berlebihan kalo ga mau LAG)
* Rapihin.
* Sekarang bisa diaktif/nonaktif kan melalui event.
================================================================================
How to use :
Insert this script below ▼ Materials, but above ▼ Main Process.
Call this script via event
To activate : Kuro::Effect.create(ID)
To dispose : Kuro::Effect.delete(ID)
ID is the preset id you create on the configuration module.
================================================================================
=end
module Kuro
module Effect
PRESET = []
#===============================================================================
# CONFIGURATION START
#===============================================================================
# Filename : The graphic file name in system folder.
# Effect : Up to 4 effects.
# 0 = No effect (fixed picture)
# 1 = Shakey2 Effect
# 2 = Frame Animation Effect
# 3 = Blink Effect
# 4 = Spin Effect
# Power : Effect rate of power. Effect 2 power is the number of frame.
# Position : 1 = upper left 2 = upper center 3 = upper right
# 4 = center left 5 = center 6 = center right
# 7 = lower left 8 = lower center 9 = lower right
# Set it to 0 will cause it to random position each call.
#===============================================================================
# Default animation delay for effect 2. Bigger is slower
ANIM = 6
# PRESET[ID] = [Filename, Effect, Power, Position]
PRESET[5] = ["glow",1,6,5] # ID 0 to 2 started from title screen
#PRESET[1] = ["demo",3,20,0] # ID 0 to 2 started from title screen
#PRESET[3] = ["old",2,5,5]
#===============================================================================
# CONFIGURATION END
#===============================================================================
def self.create(id)
$kde[id] = DemoEffect.new(PRESET[id])
end
def self.delete(id)
$kde[id].dispose
$kde[id] = nil
end
end
end
class DemoEffect
def initialize(id)
@file = id[0]
@type = id[1]
@pow = id[2]
@pos = id[3]
create
end
def create
@sp = Sprite.new
@sp.bitmap = Cache.system(@file)
@sp.src_rect.set(0,0,@sp.bitmap.width/@pow,@sp.bitmap.height) if @type == 2
@sp.z = 99999
@pos = 1 + rand(9) if @pos == 0
get_position
end
def update
case @type
when 0; @sp.update
when 1; shakey
when 2; animate
when 3; blink
when 4; spin
end
end
def get_position
wx = Graphics.width-@sp.width
hy = Graphics.height-@sp.height
case @pos
when 1; @sp.x=0; @sp.y=0
when 2; @sp.x=wx/2; @sp.y=0
when 3; @sp.x=wx; @sp.y=0
when 4; @sp.x=0; @sp.y=hy/2
when 5; @sp.x=wx/2; @sp.y=hy/2
when 6; @sp.x=wx; @sp.y=hy/2
when 7; @sp.x=0; @sp.y=hy
when 8; @sp.x=wx/2; @sp.y=hy
when 9; @sp.x=wx; @sp.y=hy
end
@ix=@sp.x; @iy=@sp.y
end
def shakey
@sp.x = [[@ix-@pow+rand(@pow*2),@ix-@pow].max,@ix+@pow].min
@sp.y = [[@iy-@pow+rand(@pow*2),@iy-@pow].max,@iy+@pow].min
end
def animate
a = Kuro::Effect::ANIM
b = Graphics.frame_count % (@pow*a)
@sp.src_rect.x = b/a*@sp.bitmap.width/@pow
end
def blink
@pow *= -1 if (@sp.opacity >= 255) or (@sp.opacity <= 0)
@sp.opacity += @pow
end
def spin
@sp.angle += @pow
end
def dispose
@sp.bitmap.dispose
@sp.dispose
end
end
class Scene_Title < Scene_Base
def start
super
SceneManager.clear
$kde = []
Kuro::Effect.create(0) if Kuro::Effect::PRESET[0]!=nil
Kuro::Effect.create(1) if Kuro::Effect::PRESET[1]!=nil
Kuro::Effect.create(2) if Kuro::Effect::PRESET[2]!=nil
Graphics.freeze
create_background
create_foreground
create_command_window
play_title_music
end
end
class Scene_Base
alias potato update
def update
potato
for i in 0...$kde.length
$kde[i].update unless $kde[i] == nil
end
end
end
В скрипте Кюро возникает ошибка после установки 2 предыдущих. Помогите ее решить.
|