Ventwig

VTS-Reserves Assist

Jun 23rd, 2014
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.46 KB | None | 0 0
  1. #============================================================================
  2. #VTS Reserves Assist
  3. #By Ventwig
  4. #Version 1.02 - Jun 24 2014
  5. #For RPGMaker VX Ace
  6. #=============================================================================
  7. # Description:
  8. # When the player chooses to do a normal attack, there is a chance that a
  9. # character currently out of battle will butt in and, instead, cast their own
  10. # skill. Actors can have a selection of skills, and the current skill that
  11. # will be used is based off of a variable, so that stronger skills can be
  12. # used as assists later on in the game
  13. # Compatible with Mr.Bubble's party guests script
  14. #===============================================================================
  15. # Instructions: Put in materials, above main.
  16. # Customization features below, as well as notetags
  17. #==============================================================================
  18. # Please give credit to Ventwig if you would like to use one of my scripts!
  19. # Use it commericial or non-commercial, and feel free to tell me if you're using
  20. # it commercially!
  21. # You may edit my scripts, just don't claim as your own!
  22. #===============================================================================
  23.  
  24. #===============================================================================
  25. #Notetags
  26. #===============================================================================
  27. # All notetags go inside the actor notebox
  28. # If the actor will be used as a party guest, then these notetags
  29. # MUST be used. Defaults do not work for guest characters.
  30. #
  31. # <assist_skills x, x, x, x>
  32. # <assist_var x>
  33. #================
  34. # The first notetag determines which skills the actor can use to assist.
  35. # Only one will be used at a time, and which one is based upon a variable.
  36. # Add as many x-es as you like, but make sure to put a space after the comma!
  37. # The variable is assigned by the second notetag, x being the variable id.
  38. # A variable equalling to zero means that the first skill in the list is chosen.
  39. # =1 means the second in the list. Please keep this in mind.
  40. #
  41. # <assist_text "xxxxxx">
  42. # <assist_message "xxxx","xxxxx","xxxxx">
  43. #================
  44. # The first notetage indicates the first line the actor will say when assisting.
  45. # This is the same regardless of which skill is used. The user's name will be
  46. # added automatically.
  47. # The second notetag indicates the second line used for each skill. This follows
  48. # the same index as the assist_skills notetag above. This quote
  49. # is said right after the assist_text quote
  50. #
  51. # <no_assist>
  52. #================
  53. # Place this inside an actor's notetag and they'll never assist.
  54. # Normally, an actor will use the default settings if no notetags are assigned.
  55. # However, if this notetag is used, then the actor will never assist.
  56. #===============================================================================
  57.  
  58. module VTS_RESERVES #Do not touch
  59. #================
  60. # CUSTOMIZATION
  61. #================
  62.  
  63.   #Switch ID. Turn this switch ON to disable assisting
  64.   DISABLE_ASSIST = 0
  65.  
  66.   #Default Settings. These are the assist settings if no notetags
  67.   #are applied.
  68.   DEFAULT_SKILL = 1
  69.   DEFAULT_TEXT = "'I'll fight, too!'"
  70.   DEFAULT_MESSAGE = "'Here we go!'"
  71.  
  72.   #Percentage in which assists occur
  73.   #Does not work alonside ASSIST_VARRATE
  74.   ASSIST_RATE = 50
  75.  
  76.   #Variable to determine assist rate. Set to -1 if you do not want
  77.   #to use. Whatever # the assigned variable is, that is the percentage
  78.   ASSIST_VARRATE = -1
  79.  
  80.   #Add to the assist rate based on amount of reserve members
  81.   ASSIST_ADD = true
  82.   #Percent to add
  83.   ASSIST_ADD_AMOUNT = 5
  84.  
  85. #================
  86. # BELOW HERE IS CODE
  87. #================
  88.  
  89. end
  90.  
  91.  
  92. module RPG
  93.   class Actor
  94.     def assist_skills
  95.       if @assist_skills.nil?
  96.         if @note =~ /<assist_skills (.*)>/i
  97.           @assist_skills= $1.split(",")
  98.         else
  99.           @assist_skills = [VTS_RESERVES::DEFAULT_SKILL]
  100.         end
  101.       end
  102.       @assist_skills
  103.     end
  104.     def assist_var
  105.       if @assist_var.nil?
  106.         if @note =~ /<assist_var (.*)>/i
  107.           @assist_var= $1.to_i
  108.         else
  109.           @assist_var = 0
  110.         end
  111.       end
  112.       @assist_var
  113.     end
  114.     def assist_text
  115.       if @assist_text.nil?
  116.         if @note =~ /<assist_text (.*)>/i
  117.           @assist_text = $1
  118.         else
  119.           @assist_text = VTS_RESERVES::DEFAULT_TEXT
  120.         end
  121.       end
  122.       @assist_text
  123.     end
  124.     def assist_message
  125.       if @assist_message.nil?
  126.         if @note =~ /<assist_message (.*)>/i
  127.           @assist_message= $1.split(",")
  128.         else
  129.           @assist_message = [VTS_RESERVES::DEFAULT_MESSAGE]
  130.         end
  131.       end
  132.       @assist_message
  133.     end
  134.     def no_assist
  135.       if @no_assist.nil?
  136.         if @note =~ /<no_assist>/i
  137.           @no_assist = true
  138.         else
  139.           @no_assist = false
  140.         end
  141.       end
  142.       @no_assist
  143.     end
  144.   end
  145. end
  146.  
  147. class Game_Action
  148.   attr_accessor :reserves_old_skill
  149.   attr_accessor :assist_id
  150. end
  151.  
  152. class Game_Actor < Game_Battler
  153.   def assist_skills
  154.     return actor.assist_skills
  155.   end
  156.   def assist_var
  157.     return actor.assist_var
  158.   end
  159.   def assist_text
  160.     return actor.assist_text
  161.   end
  162.   def assist_message
  163.     return actor.assist_message
  164.   end
  165.   def no_assist
  166.     return actor.no_assist
  167.   end
  168.   def actor_id
  169.      return @actor_id
  170.   end
  171. end
  172.  
  173. class Game_Battler < Game_BattlerBase
  174.   def reserve_assist_action(a)
  175.     return unless current_action.item.is_a?(RPG::Skill)
  176.     curr_skill = current_action.item
  177.    
  178.     if curr_skill == $data_skills[1]
  179.       if a.actor? == true
  180.         j = rand(101)
  181.        # puts(j)
  182.        
  183.         if VTS_RESERVES::ASSIST_VARRATE == -1
  184.           w = VTS_RESERVES::ASSIST_RATE
  185.           if VTS_RESERVES::ASSIST_ADD == true
  186.             x = $game_party.all_members.size-$game_party.battle_members.size
  187.             y = x*VTS_RESERVES::ASSIST_ADD_AMOUNT
  188.             w += y
  189.           end
  190.         else
  191.           w = $game_variables[VTS_RESERVES::ASSIST_VARRATE]
  192.           if VTS_RESERVES::ASSIST_ADD == true
  193.             x = $game_party.all_members.size-$game_party.battle_members.size
  194.             y = x*VTS_RESERVES::ASSIST_ADD_AMOUNT
  195.             w += y
  196.           end
  197.         end
  198.            
  199.         #puts(w)
  200.         if j < w
  201.           b = $game_party.battle_members.size
  202.           if $imported["BubsPartyGuests"] == true
  203.             c = $game_party.guests.size
  204.           else
  205.             c = 0
  206.           end
  207.           d = $game_party.all_members.size
  208.           puts(b)
  209.           puts(c)
  210.           puts(d)
  211.           if d > b
  212.             h = rand(d+c-b)+b
  213.             puts(h)
  214.             if h >= d
  215.               k = $game_party.guests[h-d]
  216.             else
  217.               k = $game_party.all_members[h]
  218.             end
  219.             puts(k.name)
  220.             puts("-")
  221.             if k.no_assist == false
  222.               if $game_variables[k.assist_var] > k.assist_skills.size-1
  223.                 assist_skill = k.assist_skills[k.assist_skills.size-1].to_i
  224.               else
  225.                 assist_skill = k.assist_skills[$game_variables[k.assist_var]].to_i
  226.               end
  227.               current_action.set_skill(assist_skill)
  228.               current_action.reserves_old_skill = curr_skill
  229.               current_action.item.mp_cost = curr_skill.mp_cost
  230.               current_action.assist_id = k
  231.              
  232.               if current_action.item.for_friend? == true and current_action.item.for_one? == true
  233.                 current_action.decide_random_target
  234.               end
  235.            #   puts(current_action.assist_id)
  236.               return
  237.             end
  238.           end
  239.         end
  240.       end
  241.     end
  242.     current_action.assist_id = 0
  243.   end
  244.   alias reserves_assist_original_make_damage_value make_damage_value
  245.   def make_damage_value(user, item)
  246.     if item.is_a?(RPG::Skill) and user.actor? == true
  247.       if user.current_action.reserves_old_skill != nil
  248.         user.current_action.reserves_old_skill = nil
  249.         user = user.current_action.assist_id
  250.       # puts(">" + user.name)
  251.       end
  252.     end
  253.     reserves_assist_original_make_damage_value(user, item)
  254.   end
  255. end # Game_Battler
  256.  
  257. class Window_BattleLog < Window_Selectable
  258.   alias vts_reserves_assist_display_use_item display_use_item
  259.   def display_use_item(subject, item)
  260.     if item.is_a?(RPG::Skill)
  261.       if subject.current_action.reserves_old_skill != nil
  262.         name = subject.name
  263.         rm = subject.current_action.assist_id
  264.      #   rm = $game_party.all_members[p]
  265.         change_text = rm.assist_text
  266.         pre_text = rm.name + ": "
  267.         if $game_variables[rm.assist_var] > rm.assist_skills.size-1
  268.           new_text = rm.assist_message[rm.assist_skills.size-1]
  269.         else
  270.           new_text = rm.assist_message[$game_variables[rm.assist_var]]
  271.         end
  272.         skill_name = item.name + '!'
  273.         use_name = subject.current_action.reserves_old_skill.message1
  274.         old_skill_text = name + use_name
  275.         add_text(old_skill_text)
  276.         wait
  277.         add_text(pre_text + change_text)
  278.         wait
  279.         add_text(pre_text + new_text)
  280.         return
  281.       end
  282.     end
  283.   vts_reserves_assist_display_use_item(subject, item)
  284.   subject.current_action.reserves_old_skill = nil
  285.   end
  286. end
  287.  
  288. class Scene_Battle < Scene_Base
  289.   alias scene_battle_use_reserve_new use_item
  290.   def use_item
  291.     @subject.reserve_assist_action(@subject) unless $game_switches[VTS_RESERVES::DISABLE_ASSIST] == true
  292.     scene_battle_use_reserve_new
  293.   end
  294. end # Scene_Battle
  295. #End of Script
Advertisement
Add Comment
Please, Sign In to add comment