Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- # ** FeaR - Element Combination v1.0
- # -- Release date: 21.01.2015
- # -- Level: Normal
- # -- Requires: n/a
- # -- Recommended Scripts: KilloZapit Word Wrapping Message Boxes
- # which can be found here http://www.rpgmakervxace.net/topic/6964-word-wrapping-message-boxes/
- #
- # -- Thanks for helping and understanding some things:
- # shaz, Sixth, BoluBolu, Engr. Adiktuzmiko, Another Fen from http://forums.rpgmakerweb.com/
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["FeaR_ElementCombination"] = true
- #==============================================================================
- # * Changelog
- #==============================================================================
- # # v1.0 - 21.01.2015 - initial release
- # # v1.1 - 22.01.2015 - add some minor bugfixes
- #
- #==============================================================================
- # * Terms of use
- #==============================================================================
- # 1. You can use this script for non-commercial and commercial usage.
- # 2. You can modify this script for your own purposes.
- # 3. If you want to share this script, please refer to this link: http://forums.rpgmakerweb.com/index.php?/topic/36143-element-combination-system/
- # 4. Credits given to me would be nice if you use this script.
- #
- #==============================================================================
- # * Introduction
- #==============================================================================
- # This script allows you to set up new elements that can be created if the
- # player combines two or three elements together. For example, Earth and Water
- # elements combine together a new Plant element. But the choice order is important
- # too, so you can make a new Mud element by combining Water and Earth (not like
- # the other order which creates Plant).
- # This script even provides an own skill leveling system based on elements.
- # Instead of learning dozens of Fire, Water and Earth skills, the actor only learn
- # one skill per element. If the skill is used enough, element points can be
- # earned to level up the element itself and this results in a stronger skill.
- # Users of this script can determine how much a skill have to be used by the
- # player to gain one element point.
- #
- #==============================================================================
- # * Instructions
- #==============================================================================
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below Materials but above Main. Remember to save.
- #
- # -----------------------------------------------------------------------------
- # Skill Notetags - These notetags go in the skills notebox in the database.
- # -----------------------------------------------------------------------------
- # <combination_level: x, y, z>
- # This determines what level the skill is and how often the player have to use
- # it, to level up the skills element.
- # x = current skill level e.g. 1
- # y = maximum skill level e.g. 10
- # z = frequency e.g. 10 => use Fire skill 10 times to gain one element point
- # and level up to Fire II skill or use it for
- # combination with other elements. Next level should
- # have a higher frequency, but its up to you.
- #
- # -----------------------------------------------------------------------------
- # !!! IMPORTANT THINGS, DO NOT FORGET THIS !!!
- # -----------------------------------------------------------------------------
- # 1. This script is designed that only one actor is in the position to use this
- # system, the actor with the index 1.
- # 2. To work properly, every skill must have an element selected in the database!
- # 3. If you say in skill notetags, that the max level is 6, then you have to
- # make 6 skills of this element!
- # 4. In the skills formula box you have to write v[x] += 1; where x is the index
- # of the variable you use to determine how much the element is used.
- # 5. For the last skill level it is not neccessary to write a frequency number
- # into the z position of the notetag, just write a 1, it is the last level.
- # 6. THIS IS VERY IMPORTANT: In the database, the actor mustn't have any
- # skill learned that you want to use this system for. Why? Skills the actor
- # knows at the beginning of a game (the ones in the database) can not be
- # forgotten! So add some Level 1 skills via event at game start.
- #
- #==============================================================================
- # * Compatibility
- #==============================================================================
- # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
- # it will run with RPG Maker VX without adjusting.
- #
- # [Maybe in future: This script is compatible with Yanfly's Ace Menu Engine]
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["FeaR_ElementCombination"] = true
- module FeaR
- Elements = {
- #==============================================================================
- # * EDITABLE REGION
- # Add here your elements.
- #==============================================================================
- "Fire" =>
- {
- :display_name => "Fire", # how the element is displayed in menu
- :element_index => 3, # element index in database
- :consists_of_1 => 0, # this element consists of? element index from database
- :consists_of_2 => 0, # for example Plant consists of Earth
- :consists_of_3 => 0, # and Water.
- :usage_variable => 11, # variable index where skill usage is counted
- :enable_switch => 0, # index of switch which is used so this
- # script hides the element until it is learned
- # make this to 0 for a base element like fire
- :current_level => 0, # have always to be 0!
- :max_level => 0, # have always to be 0!
- :frequency => 0, # have always to be 0!
- :current_skill_id => 0, # have always to be 0!
- :element_point => 0, # have always to be 0!
- # an info text which will be displayed when cursor selects an element
- :info_text => "Fire Element. Burns every Enemy down!"
- },
- "Thunder" =>
- {
- :display_name => "Thunder",
- :element_index => 5,
- :consists_of_1 => 0,
- :consists_of_2 => 0,
- :consists_of_3 => 0,
- :usage_variable => 12,
- :enable_switch => 0,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Thunder Element. Hit the Lights!"
- },
- "Water" =>
- {
- :display_name => "Water",
- :element_index => 6,
- :consists_of_1 => 0,
- :consists_of_2 => 0,
- :consists_of_3 => 0,
- :usage_variable => 13,
- :enable_switch => 0,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Water Element. May the Enemies drown!"
- },
- "Earth" =>
- {
- :display_name => "Earth",
- :element_index => 7,
- :consists_of_1 => 0,
- :consists_of_2 => 0,
- :consists_of_3 => 0,
- :usage_variable => 14,
- :enable_switch => 0,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Earth Element. Hard hitting rocks!"
- },
- "Wind" =>
- {
- :display_name => "Wind",
- :element_index => 8,
- :consists_of_1 => 0,
- :consists_of_2 => 0,
- :consists_of_3 => 0,
- :usage_variable => 15,
- :enable_switch => 0,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Wind Element. Roaring tempests!"
- },
- "Plant" =>
- {
- :display_name => "Plant",
- :element_index => 11,
- :consists_of_1 => 7,
- :consists_of_2 => 6,
- :consists_of_3 => 0,
- :usage_variable => 16,
- :enable_switch => 12,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Wood Element. Used for Protection!"
- },
- "Magma" =>
- {
- :display_name => "Magma",
- :element_index => 12,
- :consists_of_1 => 3,
- :consists_of_2 => 7,
- :consists_of_3 => 6,
- :usage_variable => 17,
- :enable_switch => 13,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Magma Element. Changes battlefield into sea of magma!"
- },
- "Mud" =>
- {
- :display_name => "Mud",
- :element_index => 13,
- :consists_of_1 => 6,
- :consists_of_2 => 7,
- :consists_of_3 => 0,
- :usage_variable => 18,
- :enable_switch => 14,
- :current_level => 0, # have always to be 0
- :max_level => 0, # have always to be 0
- :frequency => 0, # have always to be 0
- :current_skill_id => 0, # have always to be 0
- :element_point => 0, # have always to be 0
- :info_text => "Mud Element. Throws poisonous mud on enemies!"
- },
- #==============================================================================
- # * END OF EDITABLE REGION
- #==============================================================================
- }
- #==============================================================================
- # * Do not edit anything past this point unless you know what you do.
- # I am not responsible for your editings.
- #==============================================================================
- # DO NOT TOUCH THIS!
- REGEX = /<combination_level:[ ](\d+,s* \d+,s* \d+)>/i
- # notetag lvl maxlvl frequency
- MenuCommandText = "Element Combination"
- HelpWindowText1 = "Level up an element"
- HelpWindowText2 = "or combine elements to create a new one."
- module VOCAB
- CURRENT_SKILL = 'Current Skill: '
- NEXT_SKILL = 'Next Skill: '
- NEW_ELEMENT = 'New Element: '
- COMBINE = 'Combine those Elements?'
- LVLUP = 'Level up this Element?'
- end
- end
- $Lvlup_switch = true
- $Combine_switch = false
- #-------------------------------------------------------------------------------
- # Window Combination Category
- #-------------------------------------------------------------------------------
- class Window_CombinationCategory < Window_ItemCategory #Command
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("Level Up", :lvlup)
- add_command("Combine", :combine)
- end
- end # end Window Combination Category
- #-------------------------------------------------------------------------------
- # Window Yes No Option
- #-------------------------------------------------------------------------------
- class Window_YesNoOption < Window_ItemCategory #Command
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Get Digit Count
- #--------------------------------------------------------------------------
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # * Create Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("Yes", :option_yes)
- add_command("No", :option_no)
- end
- end # end Window Yes No Option
- #-------------------------------------------------------------------------------
- # Window Result
- #-------------------------------------------------------------------------------
- class Window_YesNoText < Window_Base
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Draw Text with Control Characters
- #--------------------------------------------------------------------------
- def draw_text_ex(x, y, text)
- #reset_font_settings
- text = convert_escape_characters(text)
- pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- #--------------------------------------------------------------------------
- # * Draw Text for Yes No Options
- #--------------------------------------------------------------------------
- def draw_text_option()
- contents.clear()
- if $Lvlup_switch == true
- contents.draw_text(0,0,width,line_height,FeaR::VOCAB::LVLUP)
- elsif $Combine_switch == true
- contents.draw_text(0,0,width,line_height,FeaR::VOCAB::COMBINE)
- end
- end
- #--------------------------------------------------------------------------
- # * Wait After Output of One Character
- #--------------------------------------------------------------------------
- def wait_for_one_character
- end
- end # end Window Yes No Text
- #-------------------------------------------------------------------------------
- # Window Available Elements
- #-------------------------------------------------------------------------------
- class Window_AvailableElements < Window_Command
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Get Alignment
- #--------------------------------------------------------------------------
- def alignment
- return 0
- end
- #--------------------------------------------------------------------------
- # * Make Command List
- #--------------------------------------------------------------------------
- def make_command_list()
- FeaR::Elements.each_key do |key_name| # iterate over elements
- switch_id = FeaR::Elements[key_name][:enable_switch] # store switch id
- skill_id = FeaR::Elements[key_name][:current_skill_id] # store skill id
- # next unless the switch is true OR the switch is zero AND the skill id is not zero
- next unless $game_switches[switch_id] || switch_id == 0 && skill_id != 0
- enable = true
- if FeaR::Elements[key_name][:element_point] == 0
- enable = false
- end
- add_command(FeaR::Elements[key_name][:display_name] + " Lvl " + FeaR::Elements[key_name][:current_level].to_s,
- key_name.to_sym, enable)
- end
- end
- end # end Window Available Elements
- #-------------------------------------------------------------------------------
- # Window Result
- #-------------------------------------------------------------------------------
- class Window_Result < Window_Base
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Draw Text with Control Characters
- #--------------------------------------------------------------------------
- def draw_text_ex(x, y, text)
- #reset_font_settings
- text = convert_escape_characters(text)
- pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- #--------------------------------------------------------------------------
- # * Draw Text for Combination
- #--------------------------------------------------------------------------
- def draw_skill_combine(chosen_element_1, chosen_element_2, chosen_element_3, new_element)
- contents.clear()
- # write 1.
- contents.draw_text(0,0,width,line_height,"1.")
- # write element 1
- if chosen_element_1 != nil
- icon = $data_skills[FeaR::Elements[chosen_element_1.to_s][:current_skill_id]].icon_index
- draw_icon(icon, 25, 0, true)
- contents.draw_text(55,0,width,line_height,FeaR::Elements[chosen_element_1.to_s][:display_name])
- end
- # write 2.
- contents.draw_text(0,line_height,width,line_height,"2.")
- # write element 2
- if chosen_element_2 != nil
- icon = $data_skills[FeaR::Elements[chosen_element_2.to_s][:current_skill_id]].icon_index
- draw_icon(icon, 25, line_height, true)
- contents.draw_text(55,line_height,width,line_height,FeaR::Elements[chosen_element_2.to_s][:display_name])
- end
- # write 3.
- contents.draw_text(0,line_height*2,width,line_height,"3.")
- # write element 3
- if chosen_element_3 != nil
- icon = $data_skills[FeaR::Elements[chosen_element_3.to_s][:current_skill_id]].icon_index
- draw_icon(icon, 25, line_height*2, true)
- contents.draw_text(55,line_height*2,width,line_height,FeaR::Elements[chosen_element_3.to_s][:display_name])
- end
- # draw horizontal line
- draw_horz_line(line_height * 6)
- # write new element
- contents.draw_text(0,line_height*7,width,line_height,FeaR::VOCAB::NEW_ELEMENT)
- if new_element != nil
- contents.draw_text(FeaR::VOCAB::NEW_ELEMENT.length*10,line_height*7,width,line_height,FeaR::Elements[new_element.to_s][:display_name])
- contents.draw_text(0,line_height*8,width,line_height,FeaR::Elements[new_element.to_s][:info_text])
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Text for Level Up
- #--------------------------------------------------------------------------
- def draw_skill_lvl_up(current_skill_id, next_skill_id)
- # clear window
- contents.clear()
- x_pos_current = FeaR::VOCAB::CURRENT_SKILL.length
- x_pos_next = FeaR::VOCAB::NEXT_SKILL.length
- current_skill = $data_skills[current_skill_id]
- next_skill = $data_skills[next_skill_id]
- # write Current Skill:
- change_color(system_color)
- contents.draw_text(0,0,width,line_height,FeaR::VOCAB::CURRENT_SKILL)
- change_color(normal_color)
- # draw skill icon
- draw_icon(current_skill.icon_index, 0, line_height, true)
- # write skill name
- contents.draw_text(25,line_height,width,line_height,current_skill.name)
- # write skill mp cost
- change_color(mp_cost_color)
- contents.font.size = 18
- contents.draw_text(200,(line_height)+2,width,line_height,current_skill.mp_cost.to_s + " MP")
- change_color(normal_color)
- contents.font.size = Font.default_size
- # write skill description
- contents.draw_text(0, line_height*2,width,line_height,current_skill.description)
- # draw horizontal line
- draw_horz_line(line_height * 5)
- # write Next Skill
- change_color(system_color)
- contents.draw_text(0,line_height*6,width,line_height,FeaR::VOCAB::NEXT_SKILL)
- change_color(normal_color)
- # draw skill icon
- draw_icon(next_skill.icon_index, 0,line_height*7,true)
- # write skill name
- contents.draw_text(25,line_height*7,width,line_height,next_skill.name)
- # write skill mp cost
- change_color(mp_cost_color)
- contents.font.size = 18
- contents.draw_text(200,2+line_height*7,width,line_height,next_skill.mp_cost.to_s + " MP")
- change_color(normal_color)
- contents.font.size = Font.default_size
- # write skill description
- contents.draw_text(0,line_height*8,width,line_height,next_skill.description)
- end
- #--------------------------------------------------------------------------
- # * Displays an horizontal line
- #--------------------------------------------------------------------------
- def draw_horz_line(y)
- line_y = y + line_height / 2 - 1
- color = normal_color
- color.alpha = 50
- contents.fill_rect(0, line_y, contents_width, 2, color)
- end
- #--------------------------------------------------------------------------
- # * Wait After Output of One Character
- #--------------------------------------------------------------------------
- def wait_for_one_character
- end
- end # end Window Result
- #-------------------------------------------------------------------------------
- # Scene Element Combination
- #-------------------------------------------------------------------------------
- class Scene_ElementCombination < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Initializing
- #--------------------------------------------------------------------------
- def start
- super()
- # Setting up Background
- create_background
- check_available_elements()
- # Setting up Help Window
- @help_window = Window_Help.new()
- # Setting up Window Combination Categories
- create_windowCombinationCategory()
- # Setting up Window Available Elements
- create_windowAvailableElements()
- # Setting up Window Results
- create_windowResults()
- @current_symbol = nil
- @choice1_made = false
- @choice2_made = false
- @choice3_made = false
- @element_1 = nil
- @element_2 = nil
- @element_3 = nil
- # Set the handlers
- set_element_handlers()
- (1 ... $data_skills.size).each do |i|
- if $data_skills[i].note.match(FeaR::REGEX)
- # an array to store all skills in database which have the notetag
- (@all_skills_indexes||=[]).push($data_skills[i].id)
- end
- end
- # Setting up Window for Yes/No Option
- create_windowYesNoOption()
- # Setting up Window for Yes/No Option Text
- create_windowYesNoText()
- end
- #--------------------------------------------------------------------------
- # * Post-Start Processing
- #--------------------------------------------------------------------------
- def post_start
- super()
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super()
- update_help_window_text()
- update_message_window_text()
- end
- #--------------------------------------------------------------------------
- # * Pre-Termination Processing
- #--------------------------------------------------------------------------
- def pre_terminate
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- @category_window.dispose() unless @category_window.disposed?
- @ae_window.dispose() unless @ae_window.disposed?
- @result_window.dispose() unless @result_window.disposed?
- @help_window.dispose() unless @help_window.disposed?
- @yesNo_window.dispose() unless @yesNo_window.disposed?
- @yesNoText_window.dispose() unless @yesNoText_window.disposed?
- super()
- end
- #--------------------------------------------------------------------------
- # * Create the window for the categories Level Up and Combination
- #--------------------------------------------------------------------------
- def create_windowCombinationCategory()
- @category_window = Window_CombinationCategory.new
- #@category_window.help_window = @help_window
- @category_window.y = @help_window.height
- @category_window.set_handler(:lvlup, method(:deactivate_category_window_1))
- @category_window.set_handler(:combine, method(:deactivate_category_window_2))
- @category_window.set_handler(:cancel, method(:return_scene))
- end
- #--------------------------------------------------------------------------
- # * Creates the window to choose yes or no when leveling up/combine elements
- #--------------------------------------------------------------------------
- def create_windowYesNoOption()
- @yesNo_window = Window_YesNoOption.new()
- @yesNo_window.x = Graphics.width * 0.25
- @yesNo_window.y = Graphics.height * 0.5
- @yesNo_window.set_handler(:option_yes, method(:execute_yes))
- @yesNo_window.set_handler(:option_no, method(:execute_no))
- @yesNo_window.openness = 0
- @yesNo_window.deactivate()
- end
- #--------------------------------------------------------------------------
- # * Creates the window that shows the text for level up or combine
- #--------------------------------------------------------------------------
- def create_windowYesNoText()
- x = Graphics.width * 0.25
- height = @yesNo_window.height
- y = Graphics.height * 0.5 - @yesNo_window.height
- @yesNoText_window = Window_YesNoText.new(x, y, Graphics.width*0.5, height)
- @yesNoText_window.draw_text_option()
- @yesNoText_window.openness = 0
- end
- #--------------------------------------------------------------------------
- # * Creates the window with the known elements of the actor
- #--------------------------------------------------------------------------
- def create_windowAvailableElements()
- # ae = abbreviation for available elements
- wy = @category_window.height + @help_window.height
- height = Graphics.height - @help_window.height - @category_window.height
- @ae_window = Window_AvailableElements.new(0, wy)
- @ae_window.height = height
- @ae_window.deactivate()
- @ae_window.set_handler(:cancel, method(:activate_category_window))
- end
- #--------------------------------------------------------------------------
- # * Creates the window where the results are shown
- #--------------------------------------------------------------------------
- def create_windowResults()
- x = Graphics.width * 0.5
- y = @help_window.height + @category_window.height
- height = Graphics.height - @help_window.height - @category_window.height
- @result_window = Window_Result.new(x, y, x, height)
- @result_window.openness = 255
- end
- #--------------------------------------------------------------------------
- # * This method turns the lvl up switch true
- # * and activates the available elements window
- #--------------------------------------------------------------------------
- def deactivate_category_window_1()
- $Lvlup_switch = true
- $Combine_switch = false
- @category_window.deactivate()
- @ae_window.clear_command_list()
- check_available_elements()
- @ae_window.make_command_list()
- @ae_window.refresh()
- @ae_window.activate()
- end
- #--------------------------------------------------------------------------
- # * This method turns the combine switch true
- # * and activates the available elements window
- #--------------------------------------------------------------------------
- def deactivate_category_window_2()
- $Combine_switch = true
- $Lvlup_switch = false
- @category_window.deactivate()
- @ae_window.clear_command_list()
- check_available_elements()
- @ae_window.make_command_list()
- @ae_window.refresh()
- @ae_window.activate()
- end
- #--------------------------------------------------------------------------
- # * This method deactivates the available elements window and set
- # * the variables to zero or nil
- #--------------------------------------------------------------------------
- def activate_category_window()
- $Lvlup_switch = false
- $Combine_switch = false
- @element_1 = nil
- @element_2 = nil
- @element_3 = nil
- @choice1_made = false
- @choice2_made = false
- @choice3_made = false
- @chosen_element_1 = nil
- @chosen_element_2 = nil
- @chosen_element_3 = nil
- @new_element = nil
- @category_window.activate()
- @ae_window.deactivate()
- @result_window.contents.clear()
- end
- #--------------------------------------------------------------------------
- # * This method updates the help window text
- #--------------------------------------------------------------------------
- def update_help_window_text()
- # if the category window is active
- if @category_window.active
- @help_window.set_text(FeaR::HelpWindowText1 + "\n" + FeaR::HelpWindowText2)
- # if available elements is active
- elsif @ae_window.active
- if @current_symbol != @ae_window.current_symbol
- @current_symbol = @ae_window.current_symbol
- @help_window.set_text(FeaR::Elements[@current_symbol.to_s][:info_text])
- end
- end
- end
- #--------------------------------------------------------------------------
- # * This method updates the result window texts
- #--------------------------------------------------------------------------
- def update_message_window_text()
- if @ae_window.active # only if the available elements window is active
- if $Lvlup_switch == true # if level up is choosen
- @current_symbol = @ae_window.current_symbol # set current symbol
- # the skill id of the element from actors skill
- actor_skill_id = FeaR::Elements[@current_symbol.to_s][:current_skill_id]
- # element id
- element_id = FeaR::Elements[@current_symbol.to_s][:element_index]
- @all_skills_indexes.each do |skill_id| # iterate over all skills with notetags
- # if one skill have a different id as the known skill from actor AND
- # if the element id's are the same, the skills are from same element
- # and different level
- if skill_id != actor_skill_id && $data_skills[skill_id].damage.element_id == element_id
- # store current level of skill
- current_level = FeaR::Elements[@current_symbol.to_s][:current_level]
- note_tags = []
- text = $data_skills[skill_id].note.match(FeaR::REGEX).to_s
- text.to_s.scan(/\d+/).each {|i| note_tags.push(i.to_i)}
- # if current level + 1 is equal to skills level
- # skill is the next level for element
- # (current level + 1 => 1 + 1 == 2 => next level
- if current_level+1 == note_tags[0]
- # draw in result window the current skill and what the next skill is
- @result_window.draw_skill_lvl_up(actor_skill_id, skill_id)
- break
- # if the current level is equal to the max level, show nothing
- elsif current_level == FeaR::Elements[@current_symbol.to_s][:max_level]
- @result_window.contents.clear()
- break
- end
- end
- end
- elsif $Combine_switch == true # if combine is choosen
- @current_symbol = @ae_window.current_symbol
- @result_window.draw_skill_combine(@chosen_element_1, @chosen_element_2, @chosen_element_3, @new_element)
- end
- end
- if $Combine_switch == true # this repeats here for reasons...
- @current_symbol = @ae_window.current_symbol
- @result_window.draw_skill_combine(@chosen_element_1, @chosen_element_2, @chosen_element_3, @new_element)
- end
- end
- #--------------------------------------------------------------------------
- # * This method set the handlers for all the elements
- #--------------------------------------------------------------------------
- def set_element_handlers()
- FeaR::Elements.each_key do |key_name|
- @ae_window.set_handler(key_name.to_sym, method(:execute_command))
- end
- end
- #--------------------------------------------------------------------------
- # * This method checks what skills and so what elements the actor knows
- # * and writes the skill id and levels and frequency into the hash
- #--------------------------------------------------------------------------
- def check_available_elements()
- $game_actors[1].skills.each do |skill| # iterate over skills from actor 1
- if skill.note.match(FeaR::REGEX) # check if current skill have notetag combination_level
- combination_levels = [] # array to store notetags values (level, usage)
- notetag = skill.note.match(FeaR::REGEX) # store regular expression match
- text = notetag.to_s # store match as text
- # scan over text to store values in array
- text.to_s.scan(/\d+/).each {|i| combination_levels.push(i.to_i)}
- FeaR::Elements.each_key do |key_name|
- # if element index is equal to skill element index,
- # the character knows that element
- if FeaR::Elements[key_name][:element_index] == skill.damage.element_id
- FeaR::Elements[key_name][:current_level] = combination_levels[0]
- FeaR::Elements[key_name][:max_level] = combination_levels[1]
- FeaR::Elements[key_name][:frequency] = combination_levels[2]
- FeaR::Elements[key_name][:current_skill_id] = skill.id
- if FeaR::Elements[key_name][:usage_variable] != 0
- FeaR::Elements[key_name][:element_point] = 0
- variable_value = $game_variables[FeaR::Elements[key_name][:usage_variable]]
- # if the value in variable is higher or equal to elements frequency
- # add one element point so the element can be used
- if variable_value >= FeaR::Elements[key_name][:frequency]
- if $Lvlup_switch == true && FeaR::Elements[key_name][:current_level] != FeaR::Elements[key_name][:max_level]
- FeaR::Elements[key_name][:element_point] = 1
- end
- if $Combine_switch == true
- FeaR::Elements[key_name][:element_point] = 1
- end
- end
- end
- # if the switch id is not zero, turn switch to true
- # because actor knows a skill with this element
- if FeaR::Elements[key_name][:enable_switch] != 0
- $game_switches[FeaR::Elements[key_name][:enable_switch]] = true
- end
- end # if
- end # Elements iteration
- end # if regex
- end # skills iteration
- end # list available elements
- #--------------------------------------------------------------------------
- # * This method execute the level up and combine process
- #--------------------------------------------------------------------------
- def execute_command()
- # if level up is selected, process element level up
- if $Lvlup_switch == true
- element_id = FeaR::Elements[@current_symbol.to_s][:element_index]
- @actor_skill_id = FeaR::Elements[@current_symbol.to_s][:current_skill_id]
- @all_skills_indexes.each do |skill_id| # iterate over all skills with notetag
- # check if skill id from array is different as actors skill id AND
- # check if the element ids are the same
- if skill_id != @actor_skill_id && $data_skills[skill_id].damage.element_id == element_id
- current_level = FeaR::Elements[@current_symbol.to_s][:current_level]
- note_tags = [] # get the notetag from the skill
- text = $data_skills[skill_id].note.match(FeaR::REGEX).to_s
- text.to_s.scan(/\d+/).each {|i| note_tags.push(i.to_i)}
- # check if the skill from array is 1 level above current skill level
- # (actors skill level = 1, next skill level = 2, 1+1 == 2, MATCH!
- if current_level+1 == note_tags[0]
- @next_skill_id = skill_id
- # open yes no window to ask player if he wants to level up
- activate_yes_no_window()
- break
- end
- end
- end
- # if combine is selected, process element combination
- elsif $Combine_switch == true
- if @choice1_made == false # select first element
- @element_1 = FeaR::Elements[@current_symbol.to_s][:element_index]
- @chosen_element_1 = @current_symbol
- @choice1_made = true
- @ae_window.activate()
- elsif @choice1_made == true && @choice2_made == false # select second element
- @element_2 = FeaR::Elements[@current_symbol.to_s][:element_index]
- @chosen_element_2 = @current_symbol
- @choice2_made = true
- @ae_window.activate()
- elsif @choice1_made == true && @choice2_made == true && @choice3_made == false # select third element (optional)
- @element_3 = FeaR::Elements[@current_symbol.to_s][:element_index]
- @chosen_element_3 = @current_symbol
- @choice3_made = true
- @ae_window.activate()
- end
- check_chosen_elements()
- end
- end
- #--------------------------------------------------------------------------
- # * This method checks if the selected elements can combined together
- #--------------------------------------------------------------------------
- def check_chosen_elements()
- @new_element = nil
- # when elements are selected, check if they can combined together
- if @element_1 != nil && @element_2 != nil && @element_3 == nil
- FeaR::Elements.each_key do |key_name| # iterate over elements
- # and check, if the selected elements can create a new one
- if FeaR::Elements[key_name][:consists_of_1] == @element_1 && FeaR::Elements[key_name][:consists_of_2] == @element_2 && FeaR::Elements[key_name][:consists_of_3] == 0
- # MATCH
- @new_element = key_name.to_sym
- # open yes no options for player
- activate_yes_no_window()
- break
- end
- end
- end
- # this is for three elements
- if @element_1 != nil && @element_2 != nil && @element_3 != nil
- FeaR::Elements.each_key do |key_name|
- if FeaR::Elements[key_name][:consists_of_1] == @element_1 && FeaR::Elements[key_name][:consists_of_2] == @element_2 && FeaR::Elements[key_name][:consists_of_3] == @element_3
- @new_element = key_name.to_sym
- activate_yes_no_window()
- break
- elsif
- @ae_window.activate()
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * This method performs if the player select yes
- #--------------------------------------------------------------------------
- def execute_yes()
- if $Lvlup_switch == true
- $game_actors[1].forget_skill(@actor_skill_id) # forget lvl n skill
- $game_actors[1].learn_skill(@next_skill_id) # learn lvl n+1 skill
- # substract the frequency for lvl n skill from variable
- $game_variables[FeaR::Elements[@current_symbol.to_s][:usage_variable]] -= FeaR::Elements[@current_symbol.to_s][:frequency]
- # substract 1 element point
- FeaR::Elements[@current_symbol.to_s][:element_point] = 0
- refresh_available_elements_window()
- elsif $Combine_switch == true
- if @choice1_made == true && @choice2_made == true && @choice3_made == false
- @all_skills_indexes.each do |skill_id|
- if $data_skills[skill_id].damage.element_id == FeaR::Elements[@new_element.to_s][:element_index]
- note_tags = [] # get the notetag from the skill
- text = $data_skills[skill_id].note.match(FeaR::REGEX).to_s
- text.to_s.scan(/\d+/).each {|i| note_tags.push(i.to_i)}
- if note_tags[0] == 1 # if the new element skill is level 1
- $game_actors[1].learn_skill(skill_id)
- $game_variables[FeaR::Elements[@chosen_element_1.to_s][:usage_variable]] -= FeaR::Elements[@chosen_element_1.to_s][:frequency]
- $game_variables[FeaR::Elements[@chosen_element_2.to_s][:usage_variable]] -= FeaR::Elements[@chosen_element_2.to_s][:frequency]
- FeaR::Elements[@chosen_element_1.to_s][:element_point] = 0
- FeaR::Elements[@chosen_element_2.to_s][:element_point] = 0
- @choice1_made = false
- @choice2_made = false
- @element_1 = nil
- @element_2 = nil
- @chosen_element_1 = nil
- @chosen_element_2 = nil
- refresh_available_elements_window()
- break
- end
- end
- end
- end
- if @choice1_made == true && @choice2_made == true && @choice3_made == true
- @all_skills_indexes.each do |skill_id|
- if $data_skills[skill_id].damage.element_id == FeaR::Elements[@new_element.to_s][:element_index]
- note_tags = [] # get the notetag from the skill
- text = $data_skills[skill_id].note.match(FeaR::REGEX).to_s
- text.to_s.scan(/\d+/).each {|i| note_tags.push(i.to_i)}
- if note_tags[0] == 1 # if the new element skill is level 1
- $game_actors[1].learn_skill(skill_id)
- $game_variables[FeaR::Elements[@chosen_element_1.to_s][:usage_variable]] -= FeaR::Elements[@chosen_element_1.to_s][:frequency]
- $game_variables[FeaR::Elements[@chosen_element_2.to_s][:usage_variable]] -= FeaR::Elements[@chosen_element_2.to_s][:frequency]
- $game_variables[FeaR::Elements[@chosen_element_3.to_s][:usage_variable]] -= FeaR::Elements[@chosen_element_3.to_s][:frequency]
- FeaR::Elements[@chosen_element_1.to_s][:element_point] = 0
- FeaR::Elements[@chosen_element_2.to_s][:element_point] = 0
- FeaR::Elements[@chosen_element_3.to_s][:element_point] = 0
- @choice1_made = false
- @choice2_made = false
- @choice3_made = false
- @element_1 = nil
- @element_2 = nil
- @element_3 = nil
- @chosen_element_1 = nil
- @chosen_element_2 = nil
- @chosen_element_3 = nil
- refresh_available_elements_window()
- break
- end
- end
- end
- end
- end
- @yesNo_window.openness = 0
- @yesNo_window.deactivate()
- @yesNoText_window.openness = 0
- @new_element = nil
- end
- #--------------------------------------------------------------------------
- # * This method performes if the player select no
- #--------------------------------------------------------------------------
- def execute_no()
- if $Lvlup_switch == true
- deactivate_yes_no_window()
- elsif $Combine_switch == true
- if @choice1_made == true && @choice2_made == true && @choice3_made == true
- deactivate_yes_no_window()
- @element_1 = nil
- @element_2 = nil
- @element_3 = nil
- @choice1_made = false
- @choice2_made = false
- @choice3_made = false
- @chosen_element_1 = nil
- @chosen_element_2 = nil
- @chosen_element_3 = nil
- @new_element = nil
- elsif
- deactivate_yes_no_window()
- end
- end
- end
- #--------------------------------------------------------------------------
- # * This method deactivates the yes/no window and activates the available
- # * elements window
- #--------------------------------------------------------------------------
- def deactivate_yes_no_window()
- @yesNo_window.openness = 0
- @yesNo_window.deactivate()
- @yesNoText_window.openness = 0
- @ae_window.activate()
- end
- #--------------------------------------------------------------------------
- # * This method activates the yes/no window and deactivates the available
- # * elements window
- #--------------------------------------------------------------------------
- def activate_yes_no_window()
- @yesNo_window.openness = 255
- @yesNoText_window.openness = 255
- @yesNoText_window.draw_text_option()
- @yesNo_window.activate()
- @ae_window.deactivate()
- end
- #--------------------------------------------------------------------------
- # * This method activates the available elements window and refreshes its text
- #--------------------------------------------------------------------------
- def refresh_available_elements_window()
- @ae_window.clear_command_list()
- check_available_elements()
- @ae_window.make_command_list()
- @ae_window.refresh()
- @ae_window.activate()
- end
- end # of Scene Element Combination
- ## Menu inclusion, with Yanfly's Ace Menu Engine
- if $imported["YEA-AceMenuEngine"]
- #==========================================================================
- # * Scene_Menu
- #==========================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Switch to the synthesis scene
- #--------------------------------------------------------------------------
- def command_elemcomb()
- SceneManager.call(Scene_ElementCombination)
- end
- end
- else ## End of Yanfly's Menu inclusion
- #==============================================================================
- # ** Window_MenuCommand
- #------------------------------------------------------------------------------
- # This command window appears on the menu screen.
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Add Formation to Command List
- #--------------------------------------------------------------------------
- alias fear_elementcombination_windowmenucommand_addformationcommand_fg4r add_formation_command
- #--------------------------------------------------------------------------
- def add_formation_command
- fear_elementcombination_windowmenucommand_addformationcommand_fg4r()
- add_command(FeaR::MenuCommandText, :element_combination)
- end
- end
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # This class performs the menu screen processing.
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- alias fear_elementcombination_scenemenu_createcommandwindow_fg4r create_command_window
- #--------------------------------------------------------------------------
- def create_command_window()
- fear_elementcombination_scenemenu_createcommandwindow_fg4r()
- @command_window.set_handler(:element_combination, method(:command_elemcomb))
- end
- #--------------------------------------------------------------------------
- # * Command Element Combination
- #--------------------------------------------------------------------------
- def command_elemcomb()
- SceneManager.call(Scene_ElementCombination)
- end
- end # Scene Menu
- end
Add Comment
Please, Sign In to add comment