Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Minor changes used to build the demo. Please ignore
- =end
- class Scene_Title < Scene_Base
- def draw_game_title
- @foreground_sprite.bitmap.font.size = 48
- rect = Rect.new(0, -25, Graphics.width, Graphics.height / 2)
- txt = $data_system.game_title.split(" ")
- for t in txt
- @foreground_sprite.bitmap.draw_text(rect, t, 1)
- rect.y+=50
- end
- end
- end
- class Window_NameInput < Window_Selectable
- def table
- return [LATIN1, LATIN2]
- end
- end
- class CharConfig
- attr_accessor :Races
- attr_accessor :RaceAppearanceNames
- attr_accessor :RaceFaceImage
- attr_accessor :RaceFaceIndex
- attr_accessor :RaceChara
- attr_accessor :RaceIndex
- attr_accessor :GenderVar
- attr_accessor :RaceDescription
- attr_accessor :ClassList
- attr_accessor :AppearanceVariable
- attr_accessor :RaceVariable
- def initialize
- @Races = Array.new
- @RaceAppearanceNames = Array.new
- @RaceFaceImage = Array.new
- @RaceFaceIndex = Array.new
- @RaceChara = Array.new
- @RaceIndex = Array.new
- @GenderVar = Array.new
- @RaceDescription = Array.new
- @ClassList = Array.new
- #############CONFIG######################
- #Here list all the names of all races in the game
- # Example:
- # Races = ["Human","Elf","Dwarf"]
- # Creates three races, called Human, Elf and Dwarf
- @Races = ["Hiệp Sĩ ","Pháp Sư","Cung Thủ","Ninja"]
- Font.default_name = ["UTM DaxBold"] # Edit as you see fit.
- Font.default_size = 18# Edit as you see fit.
- Font.default_bold = true
- #Which race the player chooses will be stored in a variable, which is defined
- #below. This can be used later create effects that only affect, say, Dwarves,
- #such as giving them the ability to use heavy armour, regardless of class.
- #This can be acheived by having an event check that variable, then run actions
- #accordingly
- @RaceVariable = 25
- #Additionally a variable can store information depending on the appearance of the
- #character. This can be used so that events can check information related to the
- #appearance, such as gender.
- @AppearanceVariable = 26
- #The default is to store the Race in variable 25. By default this will mean that
- #if the player is human that varible will be 1, 2 if an elf, and 3 if a dwarf.
- #
- #Then we need to do some setup for each race
- #Example:
- #RaceAppearanceNames << ["Female","Male"]
- #RaceFaceImage << ["Actor3.png","Actor3.png"]
- #RaceFaceIndex << [6,5]
- #RaceChara << ["Actor3.png","Actor3.png"]
- #RaceIndex << [6,5]
- #GenderVar << [1,0]
- #ClassList << [6,-1,2,-4]
- #RaceDescription <<
- #["Industrious and smart, although most
- #lead mundane lives, among Humanity walk
- #the most powerful mages and warrior
- #on this earth."]
- #
- #The first row shows that the first race we typed in at the start has two
- #different Appearances. One called Female, one called Male.
- #
- #The second row shows the File name for that appearances face. So both Male and
- #Female humans use Actor1.png
- #The third row shows which face in the file to use, as each image has 8 faces,
- #so female humans use the first face in the Actor1.png Image, and Males use the
- #second image.
- #
- #The fourth and fifth line work like the Faces, appart from for defining the
- #Character image that is seen walking around the screen. In the example above
- #both Male and Female humans have characters to match their faces.
- #
- #The 6th line is used to set the Appearance variable. In this case having the
- #"Male" apperance will set the Appearance variable (Default 26) to 0, while the
- #"Female" will set it to 1. This way you can have NPCs react depending on Gender
- #
- #The seventh line lists all classes, in order, that that class can take.
- #Listing a class as negitive (I.e. -3) will mean that it is listed, but you cannot
- #select it. This can be used to clearly show what class can and cannot take certain
- #classes, but without confusing the player by hiding information
- #
- #Finally we have a description for the race. This is at max four lines, and each line
- #should not be longer than the in the example Races.
- #
- #For each race you defined at the start, copy paste these lines, and customize
- #as you wish.
- #Race 1:
- @RaceAppearanceNames << [" Gro"," Ken"," Yumi"," Nu"]
- @RaceFaceImage << ["Actor7.png","Actor9.png","Actor20.png","Actor25.png"]
- @RaceFaceIndex << [1,2,3,4]
- @RaceChara << ["$Actor7.png","$Actor9.png","$Actor20.png","$Actor_etc6.png"]
- @RaceIndex << [1,1,1,1]
- @GenderVar << [0,1,0,1]
- @ClassList << [1,2,3,4,5]
- @RaceDescription <<
- ["Hiệp sĩ Là người sẽ đem lại công lý cho
- người dân hoặc có khi họ là những người luôn
- phục vụ cho chủ nhân của họ và hi sinh cả
- tính mạng."]
- #Race 2:
- @RaceAppearanceNames << [" Sakura"," Meta IU"]
- @RaceFaceImage << ["Actor95.png","Actor103.png"]
- @RaceFaceIndex << [6,5]
- @RaceChara << ["$Actor95.png","$Actor103.png"]
- @RaceIndex << [1,1]
- @GenderVar << [1,0]
- @ClassList << [1,2,3,4,5]
- @RaceDescription <<
- ["Pháp Sư Là những người nắm giữ phép thuật
- trong tay như là ma pháp trận, ma pháp viên,
- vòng tròn ma thuật hay kết giới."]
- #Race 3:
- @RaceAppearanceNames << [" Jun"]
- @RaceFaceImage << ["Actor101.png"]
- @RaceFaceIndex << [1]
- @RaceChara << ["$Actor101.png"]
- @RaceIndex << [1]
- @GenderVar << [0]
- @ClassList << [1,2,3,4,5]
- @RaceDescription <<
- ["Cung Thủ Là những người chuyển về những vũ
- khí ảnh hưởng xa những vũ khí của họ thường
- là Súng , Cung , Nỏ."]
- #Race 4:
- @RaceAppearanceNames << [" Javed Iqbal"," Thug Behram"]
- @RaceFaceImage << ["Actor42.png","Actor44.png"]
- @RaceFaceIndex << [1,1]
- @RaceChara << ["$Actor42.png","$Actor44.png"]
- @RaceIndex << [1,1]
- @GenderVar << [1,1]
- @ClassList << [1,2,3,4,5]
- @RaceDescription <<
- ["Ninja Hay còn gọi là shinobi là danh xưng để
- chỉ những cá nhân hay tổ chức đánh thuê chuyên
- về hoạt động bí mật "]
- #####################ADVANCED CONFIG####################
- #It is assumed that the code will only be called once, near
- #start of the game to create the main character, and that
- #all other party members are precreated. If this is NOT the case,
- #the script can be called to create an actor with a specific
- #actor ID in the following way:
- #
- #CharCreationManager.setActorID(N)
- #SceneManager.call(Scene_CharacterCreation)
- #
- #Otherwise the character at the FRONT of the party will be selected
- #
- #Note that the '#'s should both be removed from the start, and the N
- #should be replaced with the id of the actor being edited.
- #
- #Secondly, whenever this script is called, it will use the options defined
- #above. You can define an alterate set of options for
- #character creation in your game. This will be useful
- #if you want to, at somepoint throughout the game, to
- #allow the player to customize an actor being added to
- #the party. You may have, for example, one set of options
- #the 'Friendly Bandit' who joins the player near the start
- #of the game, a differnt set for the 'Demigod Ally' who
- #joins right before the final battle, and a differnt set
- #still for the 'Mages Apprentice' which the player is rewarded
- #for completing all the quests in the Mages Guild
- #
- #Please refer back to the Forums on how to create this altenate set
- #of options. Once it is created, it can be called using
- #
- #CharCreationManager.setOptions(
- #YOUR_OPTIONS_NAME_HERE.new
- #)
- #SceneManager.call(Scene_CharacterCreation)
- #
- #Again, the '#'s must be removed and the YOUR_OPTIONS_NAME_HERE
- #should be replaced with the name of your options set. For more on
- #having multiple Character Options check the Forums or message
- #Kaimonkey
- #
- ############END CONFIG############################
- end
- end
- class Scene_CharacterCreation < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- @charConfig = CharCreationManager.getOptions
- if(CharCreationManager.getActorID!=nil)
- @actor = $game_actors[CharCreationManager.getActorID]
- end
- create_status_window
- @status_window.width = @status_window.height
- @desc_window = Window_Desc.new(Graphics.width-@status_window.width, @status_window.height)
- @desc_window.x = @status_window.width
- @stage = 1
- @finished = false
- @class_window = Window_Create.new(@actor,@charConfig )
- @race_window = Window_Race.new(@actor,@charConfig )
- @look_window = Window_Appearance.new(@actor,1,@charConfig)
- @class_window.index = (@actor.class.id - 1)
- @class_window.width = Graphics.width / 3
- @class_window.active = false
- @class_window.visible = false
- @class_window.id = 0
- @look_window.active = false
- @look_window.visible = false
- @race_window.width = Graphics.width / 3
- @look_window.width = Graphics.width / 3
- @class_window.set_handler(:class,method(:changeActorClass))
- @class_window.set_handler(:cancel, method(:back))
- @look_window.set_handler(:cancel, method(:back))
- @look_window.set_handler(:look, method(:finish))
- @race_window.set_handler(:race,method(:changeActorRace))
- @prevClassID = 0;
- end
- alias oldupdate update
- def update()
- oldupdate()
- if @finished == true
- return_scene
- end
- raceID = @race_window.index
- appID = @look_window.index
- @actor.set_graphic(@charConfig.RaceChara[raceID][appID],@charConfig.RaceIndex[raceID][appID]-1 ,@charConfig.RaceFaceImage[raceID][appID],@charConfig.RaceFaceIndex[raceID][appID]-1)
- if(@stage!=2)
- str = @charConfig.RaceDescription[raceID][0]
- str.gsub("\n", " ")
- @desc_window.setText(reformat_wrapped(str,37))
- else
- classID = @charConfig.ClassList[raceID][@class_window.index].abs
- if(@prevClassID!=classID)
- @desc_window.setText(getDesc($data_classes[classID]))
- @prevClassID = classID
- end
- end
- #@actor.set_graphic("Animal.png" ,3,RaceFaceImage[raceID][appID],RaceFaceIndex[raceID][appID]-1)
- $game_player.refresh
- classID = @charConfig.ClassList[raceID][@class_window.index]
- @actor.change_class(classID)
- @actor.hp = @actor.mhp
- @actor.mp = @actor.mmp
- @actor.init_exp
- @actor.init_skills
- @status_window.refresh
- end
- def getDesc(charClass)
- unless charClass.note.include?("<desc")
- bestStat = getBestStat(charClass)
- skillType = getSkillType(charClass)
- example = getSkill(charClass)
- str = "As a "+charClass.name+" you use your "+bestStat+" and your "+skillType+" skills, such as "+example+", to defeat foes"
- str = reformat_wrapped(str,40)
- return str
- end
- str = charClass.note
- str = str.split("<desc")[1].split("/>")[0].strip!
- return str
- end
- def getSkill(charClass)
- str = $data_skills[charClass.learnings[0].skill_id].name
- str += " and eventually "
- str += $data_skills[charClass.learnings[charClass.learnings.length-1].skill_id].name
- return str
- end
- def getSkillType(charClass)
- tally = Hash.new(0)
- for l in charClass.learnings
- id = l.skill_id
- stype_id = $data_skills[id].stype_id
- tally[$data_system.skill_types[stype_id]] += 1
- end
- highestCount = 0
- type = "no"
- for t in tally
- if(t[1]>highestCount)
- highestCount = t[1]
- type = t[0].to_s
- end
- end
- return type
- end
- def getBestStat(charClass)
- bestParam = 0
- bestScore = 0
- for i in 2..5
- if charClass.params()[i,99] > bestScore
- bestScore = charClass.params()[i,99]
- bestParam = i;
- end
- end
- return Vocab::param(bestParam)
- end
- def reformat_wrapped(s, width=78)
- lines = []
- line = ""
- s.split(/\s+/).each do |word|
- if line.size + word.size >= width
- lines << line
- line = word
- elsif line.empty?
- line = word
- else
- line << " " << word
- end
- end
- lines << line if line
- return lines.join "\n"
- end
- def finish()
- raceID = @race_window.index
- $game_variables[@charConfig.AppearanceVariable] = @charConfig.GenderVar[raceID][@look_window.index]
- @finished = true
- end
- def back()
- @class_window.active = false
- @race_window.active = false
- @look_window.active = false
- if @stage == 2
- @look_window.index = 0
- @class_window.index = 0
- @race_window.active = true
- @stage = 1
- elsif @stage == 3
- @stage = 2
- @class_window.active = true
- end
- end
- def changeActorClass()
- classID = @class_window.index
- @stage = 3
- @look_window.active = true
- @look_window.visible = true
- @status_window.refresh
- end
- def changeActorRace()
- raceID = @race_window.index
- @actor.set_graphic(@charConfig.RaceFaceImage[raceID][0],@charConfig.RaceFaceIndex[raceID][0],@charConfig.RaceFaceImage[raceID][0],@charConfig.RaceFaceIndex[raceID][0]-1)
- @status_window.refresh
- @stage = 2
- @class_window.activate
- @class_window.visible = true
- @look_window.id=raceID
- @class_window.id=raceID
- @look_window.index = 0
- $game_variables[@charConfig.RaceVariable] = raceID +1
- end
- def create_status_window
- y = 0
- @status_window = Window_SkillStatus.new(0,0)
- @status_window.viewport = @viewport
- @status_window.actor = @actor
- end
- end
- #==============================================================================
- # ** Window_Status
- #------------------------------------------------------------------------------
- # This window displays full status specs on the status screen.
- #==============================================================================
- class Window_Create < Window_Command
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(actor,charConfig)
- @charConfig = charConfig
- @actor = actor
- super(Graphics.width / 3, fitting_height(4))
- self.height = Graphics.height - fitting_height(4)
- # create_help_window
- end
- #--------------------------------------------------------------------------
- # * Set Actor
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- for i in @charConfig.ClassList[@id.to_i]
- if(i<0)
- add_command($data_classes[-i].name, :class,false)
- else
- add_command($data_classes[i].name, :class,true)
- end
- end
- end
- #------------------------------------------------------------------------
- def id=(id)
- @id = id
- refresh
- end
- end
- ############################################################
- #
- #
- # RACE MEANU
- #####
- class Window_Race < Window_Command
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(actor,charConfig )
- @charConfig = charConfig
- # create_help_window
- @actor = actor
- super(0, fitting_height(4))
- self.height = Graphics.height - fitting_height(4)
- end
- #--------------------------------------------------------------------------
- # * Set Actor
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- count = 0
- for i in @charConfig.Races
- add_command(i, :race)
- end
- end
- end
- class Window_Appearance < Window_Command
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(actor,id,charConfig )
- @actor = actor
- @id = id
- @charConfig = charConfig
- super(Graphics.width / 1.5, fitting_height(4))
- self.height = Graphics.height - fitting_height(4)
- # create_help_window
- #item_height = 36
- end
- #--------------------------------------------------------------------------
- # * Set Actor
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- # self.item_height = 36
- end
- def id=(id)
- @id = id
- refresh
- # self.item_height = 36
- count = 0
- i_id = @id.to_i
- lookArray = @charConfig.RaceAppearanceNames#[@id]
- for i in (0...(lookArray[i_id].length))
- #add_command(" "+lookArray[i_id][i], :look)
- #draw_item(i,RaceChara[i_id][i],RaceIndex[i_id][i])
- draw_character(@charConfig.RaceChara[i_id][i], @charConfig.RaceIndex[i_id][i]-1,16,36*(i+1)-2)
- end
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- alias oldCommand make_command_list
- def make_command_list
- oldCommand
- count = 0
- i_id = @id.to_i
- lookArray = @charConfig.RaceAppearanceNames#[@id]
- for i in (0...(lookArray[i_id].length))
- add_command(" "+lookArray[i_id][i], :look)
- #draw_item(i,RaceChara[i_id][i],RaceIndex[i_id][i])
- #draw_character(RaceChara[i_id][i], RaceIndex[i_id][i],16,36*(i+1)-2)
- end
- #draw_character(RaceChara[i_id][i], RaceIndex[i_id][i], 0, 0)
- end
- def draw_item(index,chara="Actor1.png",chaIndex = 1)
- change_color(normal_color, command_enabled?(index))
- draw_text(item_rect_for_text(index), command_name(index), alignment)
- #draw_character(chara,chaIndex,16,36*(index+1)-2)
- end
- def item_rect(index)
- rect = Rect.new
- rect.width = item_width
- rect.height = 36#item_height
- rect.x = index % col_max * (item_width + spacing)
- rect.y = index / col_max * 36#item_height
- rect
- end
- def update_cursor
- if @cursor_all
- cursor_rect.set(0, 0, contents.width, row_max * 36)
- self.top_row = 0
- elsif @index < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- cursor_rect.set(item_rect(@index))
- end
- end
- def contents_height
- [super - super % 36, row_max * 36].max
- end
- def update_padding_bottom
- surplus = (height - standard_padding * 2) % 36
- self.padding_bottom = padding + surplus
- end
- def top_row
- oy / 36
- end
- def page_row_max
- (height - padding - padding_bottom) / 36
- end
- def top_row=(row)
- row = 0 if row < 0
- row = row_max - 1 if row > row_max - 1
- self.oy = row * 36
- end
- end
- class Window_Desc < Window_Base
- @text
- def initialize(w,h)
- super(0,0,w,h)
- self.width = w
- self.height = h
- end
- def setText(text)
- if(text!=@text)
- @text = text
- refresh
- end
- end
- def refresh()
- contents.clear
- draw_text_ex(4, 0, @text)
- end
- end
- module CharCreationManager
- def self.setActorID(id)
- @actorID = id
- end
- def self.setOptions(opt)
- @options = opt
- end
- def self.getActorID
- return @actorID
- end
- def self.getOptions
- if(@options != nil)
- return @options
- end
- return CharConfig.new
- end
- end
- #######CONFIG#########################
- #
- #Here we can define an alterate set of options for
- #character creation in your game. This will be useful
- #if you want to, at somepoint throughout the game, to
- #allow the player to customize an actor being added to
- #the party. You may have, for example, one set of options
- #the 'Friendly Bandit' who joins the player near the start
- #of the game, a differnt set for the 'Demigod Ally' who
- #joins right before the final battle, and a differnt set
- #still for the 'Mages Apprentice' which the player is rewarded
- #for completing all the quests in the Mages Guild
- #
- #On the line below you MUST give your set of options a name.
- #For example:
- #
- #class MagesGuildOptions < CharConfig
- #
- #will create a set of options called "MagesGuildOptions". Make
- #sure to remember this name, as you will need to use it to tell
- #the game to switch the options
- #
- class MagesGuildOptions < CharConfig
- ##############END CONFIG##############
- def initialize
- super
- @RaceAppearanceNames = Array.new
- @RaceFaceImage = Array.new
- @RaceFaceIndex = Array.new
- @RaceChara = Array.new
- @RaceIndex = Array.new
- @GenderVar = Array.new
- @RaceDescription = Array.new
- @ClassList = Array.new
- #############CONFIG######################
- #Here list all the names of all races in this set of options
- # Example:
- # Races = ["Human","Elf","Dwarf"]
- # Creates three races, called Human, Elf and Dwarf
- @Races = ["Trợ Thủ","Đỡ Đòn"]
- #Which race the player chooses will be stored in a variable, which is defined
- #below. This can be used later create effects that only affect, say, Dwarves,
- #such as giving them the ability to use heavy armour, regardless of class.
- #This can be acheived by having an event check that variable, then run actions
- #accordingly
- @RaceVariable = 27
- #Additionally a variable can store information depending on the appearance of the
- #character. This can be used so that events can check information related to the
- #appearance, such as gender.
- @AppearanceVariable = 28
- #The default is to store the Race in variable 25. By default this will mean that
- #if the player is human that varible will be 1, 2 if an elf, and 3 if a dwarf.
- #
- #Then we need to do some setup for each race
- #Example:
- #RaceAppearanceNames << ["Female","Male"]
- #RaceFaceImage << ["Actor3.png","Actor3.png"]
- #RaceFaceIndex << [6,5]
- #RaceChara << ["Actor3.png","Actor3.png"]
- #RaceIndex << [6,5]
- #GenderVar << [1,0]
- #ClassList << [6,-1,2,-4]
- #RaceDescription <<
- #["Industrious and smart, although most
- #lead mundane lives, among Humanity walk
- #the most powerful mages and warrior
- #on this earth."]
- #
- #The first row shows that the first race we typed in at the start has two
- #different Appearances. One called Female, one called Male.
- #
- #The second row shows the File name for that appearances face. So both Male and
- #Female humans use Actor1.png
- #The third row shows which face in the file to use, as each image has 8 faces,
- #so female humans use the first face in the Actor1.png Image, and Males use the
- #second image.
- #
- #The fourth and fifth line work like the Faces, appart from for defining the
- #Character image that is seen walking around the screen. In the example above
- #both Male and Female humans have characters to match their faces.
- #
- #The 6th line is used to set the Appearance variable. In this case having the
- #"Male" apperance will set the Appearance variable (Default 26) to 0, while the
- #"Female" will set it to 1. This way you can have NPCs react depending on Gender
- #
- #The seventh line lists all classes, in order, that that class can take.
- #Listing a class as negitive (I.e. -3) will mean that it is listed, but you cannot
- #select it. This can be used to clearly show what class can and cannot take certain
- #classes, but without confusing the player by hiding information
- #
- #Finally we have a description for the race. This is at max four lines, and each line
- #should not be longer than the in the example Races.
- #
- #For each race you defined at the start, copy paste these lines, and customize
- #as you wish.
- #Race 1:
- @RaceAppearanceNames << [" Huna"]
- @RaceFaceImage << ["Actor34.png"]
- @RaceFaceIndex << [1]
- @RaceChara << ["$Actor34.png"]
- @RaceIndex << [1]
- @GenderVar << [0]
- @ClassList << [6,7]
- @RaceDescription <<
- ["Trợ Thủ Hay gọi là người hộ thể , người nắm
- sinh mạng và sự tái sinh của vạn vật "]
- #Race 2:
- @RaceAppearanceNames << [" Kun"]
- @RaceFaceImage << ["Actor31.png"]
- @RaceFaceIndex << [1]
- @RaceChara << ["$Actor31.png"]
- @RaceIndex << [2]
- @GenderVar << [1]
- @ClassList << [6,7]
- @RaceDescription <<
- ["Đỡ đòn là những người bảo vệ chủ nhân của mình
- dù khá năng tấn công của họ rất yếu nhưng họ đc coi
- là nhưng con cờ của tính mạng"]
- #####################END CONFIG##################################
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment