Ventwig

Elemental Charge Field VTS

Jan 5th, 2013
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 15.62 KB | None | 0 0
  1. #============================================================================
  2. #VTS-Elemental Charge Fields (with Charge Skill Evolution)
  3. #By Ventwig
  4. #Version 1.21 - Mar 22 2014
  5. #For RPGMaker VX Ace
  6. #Thanks Selchar and Tsukihime for the help!
  7. #=============================================================================
  8. # Description:
  9. # This script adds an extra dynamic to elements for both players and enemies
  10. # alike. When a skill of an element is used, its "charge" will raise, and,
  11. # if desired, the opposing element's "charge" will drop. That charge counts
  12. # as a damage multiplier, and it can even nullify or drain damage of a certain
  13. # element if its charge drops low enough.
  14. # The new Charge Skill Evolution feature (from Tales of The Abyss's Field
  15. # of Fonons Change) allows a skill to change into a more powerful form
  16. # under certain conditions based on the fields.
  17. #==============================================================================
  18. # Compatability:
  19. # I'd say it's pretty high!
  20. # It works with Battle Symphony, and YEA because it's only an add-on to battles,
  21. # so have fun!
  22. #===============================================================================
  23. # Instructions: Put in materials, above main. You need to set the elements/icons!
  24. #==============================================================================
  25. # Please give Credit to Ventwig if you would like to use one of my scripts!
  26. # Use it commericial or non-commercial, and feel free to tell me if you're using
  27. # it commercially!
  28. # You may edit my scripts, just don't claim as your own!
  29. #===============================================================================
  30.  
  31.  
  32. #===============================================================================
  33. # How to Change Charge Value (Skill Notetags)
  34. #===============================================================================
  35. # <charge_value x>
  36. # x = amount to increase charge (make a negative to decrease) (number)
  37. # If you want to make certain skills worth more in charge fields, this notetag
  38. # lets you make some skills strengthen fields better. Negatives weaken fields.
  39. # These override the default for said skill.
  40. #===============================================================================
  41. # How to Set up a Charge Skill Evolution (Skill Notetags)
  42. #===============================================================================
  43. # If you do not like the CSE idea, simply do not use these notetags
  44. #===============================================================================
  45. # <evolution_element x>
  46. # x = element id (the number)
  47. # Set the element ID for the CSE. This means that this element will
  48. # need the specidic value (or default if you use that) in order to CSE.
  49. # Please be careful and don't set it to an element without a Charge Field,
  50. # as that will have no effect.
  51. #
  52. # <evolution_charge x>
  53. # x = required charge value
  54. # Set a number for the CSE. This means that the element (specified using
  55. # the notetag above or using the default setting) will need a value equal to or
  56. # greater than x in order to FOFChange.
  57. #
  58. # <evolution_skill x>
  59. # x = skill id (the number)
  60. # Set the skill to CSE into. Simple enough, if the conditions are met,
  61. # then this skill will be used instead.
  62. #*******************************************************************************
  63. # IT IS IMPERATIVE to make sure the MP/TP costs are equal to/less than the
  64. # original skill. This script does not check for that and will bug if
  65. # the player doesn't have enough MP to use the new skill.
  66. #===============================================================================
  67.  
  68. module VTS_ECF
  69.   #This means whether or not elements across from each other will "oppose"
  70.   #each other. If set to true, using a fire attack will raise fire charge
  71.   #and lower ice. False will just raise fire.
  72.   #True/False Def:True
  73.   COUNTER_CHARGE = true
  74.  
  75.   #The default amount an attack will raise/lower the fields
  76.   #Def: 10
  77.   CHARGE_VALUE = 10
  78.  
  79.   #The ID number of the desired elements. In "Terms" in the database, there's
  80.   #the area where you can edit elements. The ID is the number beside them.
  81.   #Def: 3,4,5,8,6,7,9,10 (Fire,Ice,Thunder,Wind,Water,Stone,Light,Dark)
  82.   #NOTE:If you are using opposing elements, then the opposing pairs are:
  83.   # 1/2 and 3/4 (so on), 1/2 will not alter 3/4, 3/4 will not alter 1/2.
  84.  
  85.   ELE1 = 3
  86.   ELE2 = 4
  87.   ELE3 = 5
  88.   ELE4 = 8
  89.   #========
  90.   # Don't want 8 elements? Simply change the number to "nil" w/o brackets!
  91.   # (min 4 elements, max 8)
  92.   #=======
  93.   ELE5 = nil
  94.   ELE6 = nil
  95.   ELE7 = nil
  96.   ELE8 = nil
  97.  
  98.   #How wide the window should be.
  99.   #Recommended
  100.   #4 elements: 100
  101.   #6 elements: 160
  102.   #8 elements: 200
  103.   WIDTH = 100
  104.  
  105.   #The icon numbers for the elements. These are in sync with the numbers
  106.   #for element id above, so just shove in the icons you want!
  107.   #Def: 96,97,98,101,99,100,102,103
  108.   EIC1 = 96
  109.   EIC2 = 97
  110.   EIC3 = 98
  111.   EIC4 = 101
  112.   EIC5 = 99
  113.   EIC6 = 100
  114.   EIC7 = 102
  115.   EIC8 = 103
  116.  
  117.   #The icon showing "opposing elements", acting as the connector between them.
  118.   #Put 0 if you don't want one (like if you don't use opposing elements)
  119.   #Def:115
  120.   LIC = 115
  121.  
  122.   #The X and Y placement of the window. Easy enough.
  123.   #Def: Graphics.width - 200, 0
  124.   #I recommend keeping X like this, making the number equal to width. Y can be whatever.
  125.   X = Graphics.width - 100
  126.   Y = 0
  127.  
  128.   #=============================================================================
  129.   #Charge Skill Evolution
  130.   #=============================================================================
  131.   DEF_CSE_ELEMENT = 3
  132.   #If an element is not set to a skill with a CSE,
  133.   #this is the element ID it will be given
  134.  
  135.   DEF_CSE_CHARGE = 120
  136.   #If no charge amount is specified for a skill with a
  137.   #CSE, this is the required amount
  138.  
  139.   CSE_TEXT = "FoF Change!"
  140.   #The text said when announcing the new change
  141.  
  142.   CSE_TEXT_SKILL = false
  143.   #Display the skill name after the text above? True/false
  144.   #(It shows the traditional (Eric used FIREAGA! Afterwards)
  145. end
  146. #############################################################################
  147.  
  148. class Game_Battler < Game_BattlerBase
  149.   def make_damage_value(user, item)
  150.     value = item.damage.eval(user, self, $game_variables)
  151.     value *= item_element_rate(user, item)
  152.     value *= pdr if item.physical?
  153.     value *= mdr if item.magical?
  154.     value *= rec if item.damage.recover?
  155.     value = value*$vts_elechrg1/100 if item.damage.element_id == VTS_ECF::ELE1
  156.     value = value*$vts_elechrg2/100 if item.damage.element_id == VTS_ECF::ELE2
  157.     value = value*$vts_elechrg3/100 if item.damage.element_id == VTS_ECF::ELE3
  158.     value = value*$vts_elechrg4/100 if item.damage.element_id == VTS_ECF::ELE4
  159.     if $vts_elechrg5 != nil
  160.       value = value*$vts_elechrg5/100 if item.damage.element_id == VTS_ECF::ELE5
  161.     end
  162.     if $vts_elechrg6 != nil
  163.       value = value*$vts_elechrg6/100 if item.damage.element_id == VTS_ECF::ELE6
  164.     end
  165.     if $vts_elechrg7 != nil
  166.       value = value*$vts_elechrg7/100 if item.damage.element_id == VTS_ECF::ELE7
  167.     end
  168.     if $vts_elechrg8 != nil
  169.       value = value*$vts_elechrg8/100 if item.damage.element_id == VTS_ECF::ELE8
  170.     end
  171.     value = apply_critical(value) if @result.critical
  172.     value = apply_variance(value, item.damage.variance)
  173.     value = apply_guard(value)
  174.     @result.make_damage(value.to_i, item)
  175.   end
  176. end
  177.  
  178. class Window_ElementCharge < Window_Base
  179.   def initialize(x,y,width,height)
  180.     super
  181.     self.z = 0
  182.     draw_elements
  183.     set_values
  184.     draw_value
  185.   end
  186.   def set_values
  187.     @val1 = $vts_elechrg1
  188.     @val2 = $vts_elechrg2
  189.     @val3 = $vts_elechrg3
  190.     @val4 = $vts_elechrg4
  191.     @val5 = $vts_elechrg5 if $vts_elechrg5 != nil
  192.     @val6 = $vts_elechrg6 if $vts_elechrg6 != nil
  193.     @val7 = $vts_elechrg7 if $vts_elechrg7 != nil
  194.     @val8 = $vts_elechrg8 if $vts_elechrg8 != nil
  195.   end
  196.   def draw_elements
  197.     draw_icon(VTS_ECF::EIC1,0,0,enabled=true) #Fire
  198.     draw_icon(VTS_ECF::EIC2,0,93,enabled=true) #Ice
  199.     draw_icon(VTS_ECF::EIC3,50,0,enabled=true) #Thunder
  200.     draw_icon(VTS_ECF::EIC4,50,93,enabled=true) #Wind
  201.     draw_icon(VTS_ECF::LIC,0,50,enabled=true) #Fire
  202.     draw_icon(VTS_ECF::LIC,50,50,enabled=true) #Fire
  203.    
  204.     draw_icon(VTS_ECF::EIC5,100,0,enabled=true) if $vts_elechrg5 != nil
  205.     draw_icon(VTS_ECF::EIC6,100,93,enabled=true) if $vts_elechrg6 != nil
  206.     draw_icon(VTS_ECF::EIC7,150,0,enabled=true) if $vts_elechrg7 != nil
  207.     draw_icon(VTS_ECF::EIC8,150,93,enabled=true) if $vts_elechrg8 != nil
  208.     draw_icon(VTS_ECF::LIC,100,50,enabled=true) if $vts_elechrg6 != nil
  209.     draw_icon(VTS_ECF::LIC,150,50,enabled=true) if $vts_elechrg8 != nil
  210.   end
  211.   def draw_value
  212.     draw_text(0,20,40,32,@val1)
  213.     draw_text(0,70,40,32,@val2)
  214.     draw_text(45,20,40,32,@val3)
  215.     draw_text(45,70,40,32,@val4)
  216.     draw_text(100,20,40,32,@val5)if $vts_elechrg5 != nil
  217.     draw_text(100,70,40,32,@val6)if $vts_elechrg6 != nil
  218.     draw_text(145,20,40,32,@val7)if $vts_elechrg7 != nil
  219.     draw_text(145,70,40,32,@val8)if $vts_elechrg8 != nil
  220.   end
  221.  
  222.   def refresh
  223.     contents.clear
  224.     draw_elements
  225.     set_values
  226.     draw_value
  227.   end
  228.  
  229.   def update
  230.     refresh if $vts_elechrg1 != @val1
  231.     refresh if $vts_elechrg2 != @val2
  232.     refresh if $vts_elechrg3 != @val3
  233.     refresh if $vts_elechrg4 != @val4
  234.     refresh if $vts_elechrg5 != @val5 and $vts_elechrg5 != nil
  235.     refresh if $vts_elechrg6 != @val6 and $vts_elechrg6 != nil
  236.     refresh if $vts_elechrg7 != @val7 and $vts_elechrg7 != nil
  237.     refresh if $vts_elechrg8 != @val8 and $vts_elechrg8 != nil
  238.   end
  239. end
  240.  
  241. class Scene_Battle < Scene_Base
  242.   alias ele_charge_start start
  243.   def start
  244.     ele_charge_start
  245.     $vts_elechrg1 = 100
  246.     $vts_elechrg2 = 100
  247.     $vts_elechrg3 = 100
  248.     $vts_elechrg4 = 100
  249.     $vts_elechrg5 = 100 if VTS_ECF::ELE5 != nil
  250.     $vts_elechrg6 = 100 if VTS_ECF::ELE6 != nil
  251.     $vts_elechrg7 = 100 if VTS_ECF::ELE7 != nil
  252.     $vts_elechrg8 = 100 if VTS_ECF::ELE8 != nil
  253.   end
  254.   alias element_charge_create_all_windows create_all_windows
  255.   def create_all_windows
  256.     element_charge_create_all_windows
  257.     create_element_window
  258.   end  
  259.  
  260.   def create_element_window
  261.     @element_window = Window_ElementCharge.new(VTS_ECF::X,VTS_ECF::Y,VTS_ECF::WIDTH,150)
  262.   end
  263.  
  264.   alias element_charge_use_item use_item
  265.   def use_item
  266.     item = @subject.current_action.item
  267.     if item.is_a?(RPG::Skill)
  268.       @charge_element = item.damage.element_id
  269.       adjust_element_charge(@charge_element, item)
  270.     end
  271.     element_charge_use_item
  272.   end
  273.  
  274.   def adjust_element_charge(element, skill)
  275.     if element == VTS_ECF::ELE1
  276.       $vts_elechrg1 += skill.charge_value
  277.       if VTS_ECF::COUNTER_CHARGE
  278.         $vts_elechrg2 -= skill.charge_value
  279.       end
  280.     end
  281.     if element == VTS_ECF::ELE2
  282.       $vts_elechrg2 += skill.charge_value
  283.       if VTS_ECF::COUNTER_CHARGE
  284.         $vts_elechrg1 -= skill.charge_value
  285.       end
  286.     end
  287.     if element == VTS_ECF::ELE3
  288.       $vts_elechrg3 += skill.charge_value
  289.       if VTS_ECF::COUNTER_CHARGE
  290.         $vts_elechrg4 -= skill.charge_value
  291.       end
  292.     end
  293.     if element == VTS_ECF::ELE4
  294.       $vts_elechrg4 += skill.charge_value
  295.       if VTS_ECF::COUNTER_CHARGE
  296.         $vts_elechrg3 -= skill.charge_value
  297.       end
  298.     end
  299.     if $vts_elechrg5 != nil
  300.       if element == VTS_ECF::ELE5
  301.         $vts_elechrg5 += skill.charge_value
  302.         if VTS_ECF::COUNTER_CHARGE
  303.           $vts_elechrg6 -= skill.charge_value
  304.         end
  305.       end
  306.     end
  307.     if $vts_elechrg5 != nil
  308.       if element == VTS_ECF::ELE6
  309.         $vts_elechrg6 += skill.charge_value
  310.         if VTS_ECF::COUNTER_CHARGE
  311.           $vts_elechrg5 -= skill.charge_value
  312.         end
  313.       end
  314.     end
  315.     if $vts_elechrg5 != nil
  316.       if element == VTS_ECF::ELE7
  317.         $vts_elechrg7 +=skill.charge_value
  318.         if VTS_ECF::COUNTER_CHARGE
  319.           $vts_elechrg8 -= skill.charge_value
  320.         end
  321.       end
  322.     end
  323.     if $vts_elechrg5 != nil
  324.       if element == VTS_ECF::ELE8
  325.         $vts_elechrg8 += skill.charge_value
  326.         if VTS_ECF::COUNTER_CHARGE
  327.           $vts_elechrg7 -= skill.charge_value
  328.         end
  329.       end
  330.     end
  331.   end
  332. end
  333.  
  334. #===============================================================================
  335. #FOF CHANGE
  336. #===============================================================================
  337.  
  338. module RPG
  339.   class BaseItem
  340.     def fofc_element
  341.       if @fofc_element.nil?
  342.         if @note =~ /<evolution_element (.*)>/i
  343.           @fofc_element= $1.to_i
  344.         else
  345.           @fofc_element = VTS_ECF::DEF_CSE_ELEMENT
  346.         end
  347.       end
  348.       @fofc_element
  349.     end
  350.    
  351.     def fofc_charge
  352.       if @fofc_charge.nil?
  353.         if @note =~ /<evolution_charge (.*)>/i
  354.           @fofc_charge= $1.to_i
  355.         else
  356.           @fofc_charge = VTS_ECF::DEF_CSE_CHARGE
  357.         end
  358.       end
  359.       @fofc_charge
  360.     end
  361.     def fofc_skill
  362.       if @fofc_skill.nil?
  363.         if @note =~ /<evolution_skill (.*)>/i
  364.           @fofc_skill= $1.to_i
  365.         else
  366.           @fofc_skill = 0
  367.         end
  368.       end
  369.       @fofc_skill
  370.     end
  371.     def charge_value
  372.       if @charge_value.nil?
  373.         if @note =~ /<charge_value (.*)>/i
  374.           @charge_value= $1.to_i
  375.         else
  376.           @charge_value = VTS_ECF::CHARGE_VALUE
  377.         end
  378.       end
  379.       @charge_value
  380.     end
  381.   end
  382. end
  383.  
  384. class Game_Action
  385.   attr_accessor :old_skill
  386. end
  387.  
  388. class Game_Battler < Game_BattlerBase
  389.   def get_new_skill
  390.     return unless current_action.item.is_a?(RPG::Skill)
  391.  
  392.     quest_skill = current_action.item
  393.    
  394.     if quest_skill.fofc_skill != 0
  395.       if quest_skill.fofc_element == VTS_ECF::ELE1
  396.         if $vts_elechrg1 >= quest_skill.fofc_charge
  397.             current_action.set_skill(quest_skill.fofc_skill)
  398.             current_action.old_skill = quest_skill
  399.             $vts_elechrg1 = 100
  400.         end
  401.       end
  402.       if quest_skill.fofc_element == VTS_ECF::ELE2
  403.         if $vts_elechrg2 >= quest_skill.fofc_charge
  404.             current_action.set_skill(quest_skill.fofc_skill)
  405.             current_action.old_skill = quest_skill
  406.             $vts_elechrg1 = 100
  407.         end
  408.       end
  409.       if quest_skill.fofc_element == VTS_ECF::ELE3
  410.         if $vts_elechrg3 >= quest_skill.fofc_charge
  411.             current_action.set_skill(quest_skill.fofc_skill)
  412.             current_action.old_skill = quest_skill
  413.             $vts_elechrg1 = 100
  414.         end
  415.       end
  416.       if quest_skill.fofc_element == VTS_ECF::ELE4
  417.         if $vts_elechrg4 >= quest_skill.fofc_charge
  418.             current_action.set_skill(quest_skill.fofc_skill)
  419.             current_action.old_skill = quest_skill
  420.             $vts_elechrg1 = 100
  421.         end
  422.       end
  423.     end
  424.   end
  425. end # Game_Battler
  426.  
  427. class Window_BattleLog < Window_Selectable
  428.   alias vts_fofchange_display_use_item display_use_item
  429.   def display_use_item(subject, item)
  430.     if item.is_a?(RPG::Skill)
  431.       if subject.current_action.old_skill != nil
  432.         name = subject.name
  433.         change_text = VTS_ECF::CSE_TEXT
  434.         skill_name = item.name + '!'
  435.         use_name = subject.current_action.old_skill.message1
  436.         old_skill_text = name + use_name
  437.         add_text(old_skill_text)
  438.         wait
  439.         if VTS_ECF::CSE_TEXT_SKILL == true
  440.           new_skill_text = change_text + skill_name
  441.           else
  442.           new_skill_text = change_text
  443.         end
  444.         add_text(new_skill_text)
  445.         wait
  446.       end
  447.     end    
  448.     vts_fofchange_display_use_item(subject, item)
  449.     subject.current_action.old_skill = nil
  450.   end
  451. end
  452.  
  453. class Scene_Battle < Scene_Base
  454.   alias scene_battle_use_item_new use_item
  455.   def use_item
  456.     @subject.get_new_skill
  457.     scene_battle_use_item_new
  458.   end
  459.  
  460. end # Scene_Battle
Advertisement
Add Comment
Please, Sign In to add comment