Kain Nobel
Member
Before we get started, I will tell you first hand that this is an early script in progress. A couple people have PMed me telling me this would get more attention in the submitted scripts section, although I personally don't think it belongs here yet. There are still many things being worked out, but this script will be updated regularly.
You can feel free to beta test it for me and tell me how to improve the work thus far, it does somewhat what its supposed to do, but its still 'beta' so don't expect anything great yet. If you make any fixes or anything, let me know so I can update the script.
You can feel free to beta test it for me and tell me how to improve the work thus far, it does somewhat what its supposed to do, but its still 'beta' so don't expect anything great yet. If you make any fixes or anything, let me know so I can update the script.
-Going to fix the module and Game_System class.
-Need to re-write the random code gen method, because its not-so-random.
-Need to figure out how to translate from one code to another.
-Some other stuff to fix :P
-Need to re-write the random code gen method, because its not-so-random.
-Need to figure out how to translate from one code to another.
-Some other stuff to fix :P
-Writting methods that'll shut game down after user-defined time.
-Game authors will be able to disable use of certain items, skills and equipment for 'trial version' of their game.
-Re-writes default classes, I'll make compatibility patches for certain scripts upon request
-More attention to detail :P
-Game authors will be able to disable use of certain items, skills and equipment for 'trial version' of their game.
-Re-writes default classes, I'll make compatibility patches for certain scripts upon request
-More attention to detail :P
Code:
#===============================================================================
# ~** Activate Product Code **~
#===============================================================================
# Written by : Kain Nobel
# Version : 0.06 (Beta)
# Last Update : 5/14/2008
# Date Created: 4/28/2008
#===============================================================================
# Activation_Debug
# true : Enabled for Playtest
# false: Disabled for Playtest
#------------------------------------------
# Activation_Required
# true : Enabled for Game.exe
# false: Disabled for Game.exe
#------------------------------------------
# Activation_TL_Hour
# nil : Doesn't calculate hours
# 0..? : Calculates to set max hours
#------------------------------------------
# Activation_TL_Min
# nil : Doesn't calculate minutes
# 0..59 : Calculates to set max minutes
#------------------------------------------
# Activation_TL_Sec
# nil : Doesn't calculate seconds
# 0..59 : Calculates to set max seconds
#------------------------------------------
# Serial_Digits_Max
# How many keys long is the Serial #?
#------------------------------------------
# Product_Digits_Max
# How many keys long is the Product #?
#------------------------------------------
# Activation_Digits_Max (Don't touch)
# Adds Product and Serial digits together
#------------------------------------------
# Activation_Menu_Disable
# true : disable menu in trial version
# false : menu isn't disabled by script
#------------------------------------------
# Activation_Save_Disabled
# true : disable save in trial version
# false : save isn't disabled by script
#------------------------------------------
# Activation_Load_Disabled
# true : disable load in trial version
# false : load isn't disabled by script
#===============================================================================
# Activation File
Activation_File = "Activation"
# Script and Debug
Activation_Debug = true
Activation_Required = false
# Time Limit
Activation_TL_Hour = nil
Activation_TL_Min = nil
Activation_TL_Sec = nil
# Digits Max
Serial_Digits_Max = 25
Product_Digits_Max = 25
# Function Restrictions
New_Game_Disabled = false
Continue_Disabled = true
Activation_Menu_Disabled = false
Activation_Save_Disabled = false
Activation_Load_Disabled = false
# Do Not Touch Last Constant, script will malfunction
Activation_Digits_Max = Serial_Digits_Max + Product_Digits_Max
################################################################################
#===============================================================================
# ** Module RPG::Activation
#===============================================================================
module RPG
class Serial_Number
def initialize
key = []
end
end
class Product_Code
def initialize
key = []
end
end
end
################################################################################
#===============================================================================
# ** Game_System
#===============================================================================
class Game_System
#[Attributes]-----------------------------------------------------------------
attr_reader :serial_number
attr_reader :product_code
#-----------------------------------------------------------------------------
alias_method :activation_game_system_initialize, :initialize
#--------------------
# * Initialize Method
#--------------------
def initialize
serial_number = RPG::Serial_Number
product_code = RPG::Product_Code
register_codes
activation_game_system_initialize
end
#-----------------
# * Code Generator
#-----------------
def code_generator
if @code_type.is_a?(RPG::Serial_Number)
code = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '0']
serial_number.key = code
elsif @code_type.is_a?(RPG::Product_Code)
code = ['0', '9', '8', '7', '6', '5', '4', '3', '2', '1', 'Z', 'Y', 'X',
'W', 'V', 'U', 'T', 'S', 'R', 'Q', 'P', 'O', 'N', 'M', 'L', 'K', 'J', 'I',
'H', 'G', 'F', 'E', 'D', 'C', 'B', 'A']
product_code.key = code
end
end
#-----------------
# * Register Codes
#-----------------
def register_codes
if serial_number == nil
@code_type = serial_number
code_generator
end
if product_code == nil
@code_type = product_code
code_generator
end
# KN: Test-----------------
if $DEBUG == true and Activation_Debug == true
codes_valid?
if codes_valid?
print "Codes Valid!"
record_numbers
else
print "Codes Invalid!"
record_numbers
end
end
# KN: Test-----------------
end
#---------------
# * Codes Valid?
#---------------
def codes_valid?
if serial_number != nil and product_code != nil
if serial_number == product_code
@valid = true
else
@valid = false
end
end
return @valid
end
#-----------------
# * Record Numbers
#-----------------
def record_numbers
filename = "Data/" + Activation_File + ".rxdata"
if FileTest.exist?(filename) == true
code_generator
end
file = File.open(filename, "wb")
Marshal.dump($game_system, file)
file.close
end
end
################################################################################
#===============================================================================
# ** Window_Activation
#-------------------------------------------------------------------------------
# This Window is called at the title screen if the user's activation validation
# code hasn't been entered.
#===============================================================================
class Window_Activation < Window_Base
#--------------------
# * Initialize Method
#--------------------
def initialize
super(160, 56, 320, 224)
self.contents = Bitmap.new(width - 32, height - 32)
@reg_serial = 0 # $game_system.serial_number #error
@reg_product = 0 # $game_system.product_number #error
@activation = []
self.back_opacity = 160
refresh
end
#-----------------
# * Refresh Method
#-----------------
def refresh
@reg_serial = $game_system.serial_number
@reg_product = $game_system.product_code
# Refresh Window
self.contents.clear
# Draw Code Names
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 128, 32, "Serial Number")
self.contents.draw_text(0, 64, 160, 32, "Product Number")
self.contents.draw_text(0, 128, 160, 32, "Activation Code")
# Draw Code Values
self.contents.font.color = normal_color
self.contents.draw_text(0, 32, 128, 32, @reg_serial.to_s, 2)
self.contents.draw_text(0, 96, 128, 32, @reg_product.to_s, 2)
self.contents.draw_text(0, 160, 128, 32, @reg_activ.to_s, 2)
end
#----------------
# * Update Method
#----------------
def dispose
super
end
end
################################################################################
#===============================================================================
# ** Scene_Title (Aliased)
#-------------------------------------------------------------------------------
# This scene is aliased to include the Activation scene when entering either
# command_new_game, or command_continue (provided a save file is present.)
#===============================================================================
class Scene_Title
#-----------------------------------------------------------------------------
# * Aliased Methods
#-----------------------------------------------------------------------------
alias_method :activation_scene_title_main, :main
alias_method :activation_scene_title_new_game, :command_new_game
alias_method :activation_scene_title_continue, :command_continue
#------------------------
# * Main Method (Aliased)
#------------------------
def main
# Create Activation Window, make it invisible and inactive.
serial_number = $game_system.serial_number
product_code = $game_system.product_code
if $activation == false
@activ_window = Window_Activation.new
@activ_window.visible = true
@activ_window.active = true
end
# Alias method
activation_scene_title_main
end
#---------------------
# * New Game (Aliased)
#---------------------
def command_new_game
# Open Activation window if purchase registration not completed
if New_Game_Disabled == false
# Alias method
activation_scene_title_new_game
elsif $activation == false and New_Game_Disabled == true
# Goto: Enter Registration Method
enter_registration
end
end
#---------------------
# * Continue (Aliased)
#---------------------
def command_continue
if $activation #serial_number == product_code
# Alias method
activation_scene_title_continue
elsif $activation == false and Continue_Disabled == true
# Goto: Enter Registration method
enter_registration
end
end
#---------------------
# * Enter Registration
#---------------------
def enter_registration
# Coming soon...
print("Coming Soon...")
end
end
################################################################################
#===============================================================================
# ** Scene Save
#===============================================================================
class Scene_Save
#--------------------------------
# * Initialize Method (Overwrite)
#--------------------------------
def initialize
@serial_number = $game_system.serial_number
@product_code = $game_system.product_code
# If you haven't entered product key...?
if @serial_number == @product_code
# Prints message, save disabled flag is true
super("You cannot save without activation key.")
@flag_save_disable = true
else
# Prints message, save disabled flag is false
super("Which file would you like to save to?")
@flag_save_disable = false
end
# Goto: Save Enabled? Method
save_enabled?
end
#--------------
# * On Decision
#--------------
def on_decision(filename)
if save_enabled? == true # KN: false
# Play Buzzer SE
$game_system.se_play($data_system.buzzer_se)
# Print Message
print("Sorry, you must first enter a Product Code")
else
# Play save SE
$game_system.se_play($data_system.save_se)
# Write save data
file = File.open(filename, "wb")
write_save_data(file)
file.close
# If called from event
if $game_temp.save_calling
# Clear save call flag
$game_temp.save_calling = false
# Switch to map screen
$scene = Scene_Map.new
return
end
# Switch to menu screen
$scene = Scene_Menu.new(4)
end
end
#---------------
# * Disable Save
#---------------
def save_enabled?
if @flag_save_disabled == true
$game_system.save_disabled = true
else
$game_system.save_disabled = false
end
end
end
################################################################################