Advertisement
gerkrt

RPGXP - ENG - Buff/Debuff dragon quest style skills

Sep 14th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 19.88 KB | None | 0 0
  1. #==============================================================================
  2. # Buff/Debuff dragon quest style skills
  3. # By gerkrt/gerrtunk
  4. # Version: 1.1
  5. # License: GPL, credits
  6. # Date: 23/12/2010
  7. # IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
  8. # script check here: http://usuarios.multimania.es/kisap/english_list.html
  9. #==============================================================================
  10.  
  11. =begin
  12.  
  13. --------Introduction-----------
  14.  
  15. This script returns a function that was in old rpgmakers and in games like dragon
  16. quest: the option to reduce or sum battlers atributes temporally in combat based
  17. in a fixed number and not using %.
  18.  
  19. You can ask for bugs, suggerences, compatibilitzations and any other things.
  20.  
  21. -------In the future------------
  22.  
  23. -The option to use fixed values with very small variance and not traditional skill
  24. formula
  25. -A max uses for each skill. In this way, a skill can lose its effects after a
  26. number of uses. In this way you can control overbuffering.
  27. -A max % of buffering for atributes. Another way of dealing with extreme buffs.
  28.  
  29. ------Instructions-------------
  30.                     skill_id1 effect type    skillid2 effect type, etc
  31. Atribute_mod_skills = { 7=> [-777, 'maxhp'], 8=> [777, 'maxhp']}
  32.  
  33. For selecting buf or debuf you only need to put a positive or negative number.
  34.  
  35.  
  36. Tags for the type(like in database ones)
  37.  
  38. maxhp
  39. maxsp
  40.  
  41. str
  42. dex
  43. agi
  44. int
  45.  
  46. atk
  47. pdef
  48. mdef
  49. eva
  50.  
  51. ---------Syntax notes--------------
  52.  
  53. '' delimites words in ruby
  54. You can divide long linges like this:
  55.  
  56. Atribute_mod_skills = { 7=> [-777, 'maxhp'],
  57. 8=> [777, 'maxhp'],
  58. 9=> [777, 'maxhp']}
  59.  
  60. See that the new line have to be after a , and that the final one dont put a
  61. final ,.
  62.  
  63. ---------Other notes-----------------
  64.  
  65. -Is applied the skill variance, and force and intelligence influences
  66. that you normally select in the database. It uses the same formula.
  67.  
  68. -The effects are acumulative.
  69.  
  70. -The effects are reset after combat.
  71.  
  72. =end
  73.  
  74. module Wep
  75.   Atribute_mod_skills = { 7=> [-777, 'maxhp'], 8=> [777, 'maxhp']}
  76. end
  77.  
  78.  
  79.  
  80.  
  81.  
  82. class Scene_Battle
  83.   #--------------------------------------------------------------------------
  84.   # * Battle Ends
  85.   #     result : results (0:win 1:lose 2:escape)
  86.   #     moded to reset actors atributes
  87.   #--------------------------------------------------------------------------
  88.   def battle_end(result)
  89.    
  90.     # Reset actors atributes modifiers  
  91.     for actor in $game_party.actors
  92.       actor.reset_atr_mod_list
  93.     end
  94.  
  95.     # Clear in battle flag
  96.     $game_temp.in_battle = false
  97.     # Clear entire party actions flag
  98.     $game_party.clear_actions
  99.     # Remove battle states
  100.     for actor in $game_party.actors
  101.       actor.remove_states_battle
  102.     end
  103.     # Clear enemies
  104.     $game_troop.enemies.clear
  105.     # Call battle callback
  106.     if $game_temp.battle_proc != nil
  107.       $game_temp.battle_proc.call(result)
  108.       $game_temp.battle_proc = nil
  109.     end
  110.     # Switch to map screen
  111.     $scene = Scene_Map.new
  112.   end
  113. end
  114.  
  115.  
  116.  
  117.  
  118.  
  119. class Game_Battler
  120. #--------------------------------------------------------------------------
  121.   # * Apply Skill Effects
  122.   #     user  : the one using skills (battler)
  123.   #     skill : skill
  124.   #--------------------------------------------------------------------------
  125.   def skill_effect(user, skill)
  126.     # Clear critical flag
  127.     self.critical = false
  128.     # If skill scope is for ally with 1 or more HP, and your own HP = 0,
  129.     # or skill scope is for ally with 0, and your own HP = 1 or more
  130.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  131.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  132.       # End Method
  133.       return false
  134.     end
  135.     # Clear effective flag
  136.     effective = false
  137.     # Set effective flag if common ID is effective
  138.     effective |= skill.common_event_id > 0
  139.     # First hit detection
  140.     hit = skill.hit
  141.     if skill.atk_f > 0
  142.       hit *= user.hit / 100
  143.     end
  144.     hit_result = (rand(100) < hit)
  145.     # Set effective flag if skill is uncertain
  146.     effective |= hit < 100
  147.     # If hit occurs
  148.     if hit_result == true
  149.       # Check for atribute modifier
  150.       if Wep::Atribute_mod_skills[skill.id] != nil
  151.        
  152.         # Extract and calculate effect
  153.         # Calculate power
  154.         ef = Wep::Atribute_mod_skills[skill.id][0] + user.atk * skill.atk_f / 100
  155.         ef -= self.pdef * skill.pdef_f / 200
  156.         ef -= self.mdef * skill.mdef_f / 200
  157.         # Calculate rate
  158.         ra = 20
  159.         ra += (user.str * skill.str_f / 100)
  160.         ra += (user.dex * skill.dex_f / 100)
  161.         ra += (user.agi * skill.agi_f / 100)
  162.         ra += (user.int * skill.int_f / 100)
  163.         # Calculate total effect
  164.         total_ef = ef * ra / 20
  165.         # Apply dispersion
  166.         if skill.variance > 0
  167.           amp = [total_ef * skill.variance / 100, 1].max
  168.           total_ef += rand(amp+1) + rand(amp+1) - amp
  169.         end
  170.        
  171.         # Apply if exist
  172.         case Wep::Atribute_mod_skills[skill.id][1]
  173.          
  174.           when 'maxhp':
  175.             self.atr_mod_list.maxhp += total_ef
  176.           when 'maxsp':
  177.             self.atr_mod_list.maxsp += total_ef
  178.            
  179.           when 'str':
  180.             self.atr_mod_list.str += total_ef
  181.           when 'dex':
  182.             self.atr_mod_list.dex += total_ef
  183.           when 'int':
  184.             self.atr_mod_list.int += total_ef
  185.           when 'agi':
  186.             self.atr_mod_list.agi += total_ef
  187.            
  188.           when 'atk':
  189.             self.atr_mod_list.atk += total_ef
  190.           when 'pdef':
  191.             self.atr_mod_list.pdef += total_ef
  192.           when 'mdef':
  193.             self.atr_mod_list.mdef += total_ef
  194.           when 'eva':
  195.             self.atr_mod_list.eva += total_ef
  196.            
  197.         end
  198.        
  199.       end
  200.      
  201.      
  202.       # Calculate power
  203.       power = skill.power + user.atk * skill.atk_f / 100
  204.       if power > 0
  205.         power -= self.pdef * skill.pdef_f / 200
  206.         power -= self.mdef * skill.mdef_f / 200
  207.         power = [power, 0].max
  208.       end
  209.       # Calculate rate
  210.       rate = 20
  211.       rate += (user.str * skill.str_f / 100)
  212.       rate += (user.dex * skill.dex_f / 100)
  213.       rate += (user.agi * skill.agi_f / 100)
  214.       rate += (user.int * skill.int_f / 100)
  215.       # Calculate basic damage
  216.       self.damage = power * rate / 20
  217.       # Element correction
  218.       self.damage *= elements_correct(skill.element_set)
  219.       self.damage /= 100
  220.       # If damage value is strictly positive
  221.       if self.damage > 0
  222.         # Guard correction
  223.         if self.guarding?
  224.           self.damage /= 2
  225.         end
  226.       end
  227.       # Dispersion
  228.       if skill.variance > 0 and self.damage.abs > 0
  229.         amp = [self.damage.abs * skill.variance / 100, 1].max
  230.         self.damage += rand(amp+1) + rand(amp+1) - amp
  231.       end
  232.       # Second hit detection
  233.       eva = 8 * self.agi / user.dex + self.eva
  234.       hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
  235.       hit = self.cant_evade? ? 100 : hit
  236.       hit_result = (rand(100) < hit)
  237.       # Set effective flag if skill is uncertain
  238.       effective |= hit < 100
  239.     end
  240.     # If hit occurs
  241.     if hit_result == true
  242.       # If physical attack has power other than 0
  243.       if skill.power != 0 and skill.atk_f > 0
  244.         # State Removed by Shock
  245.         remove_states_shock
  246.         # Set to effective flag
  247.         effective = true
  248.       end
  249.       # Substract damage from HP
  250.       last_hp = self.hp
  251.       self.hp -= self.damage
  252.       effective |= self.hp != last_hp
  253.       # State change
  254.       @state_changed = false
  255.       effective |= states_plus(skill.plus_state_set)
  256.       effective |= states_minus(skill.minus_state_set)
  257.       # If power is 0
  258.       if skill.power == 0
  259.         # Set damage to an empty string
  260.         self.damage = ""
  261.         # If state is unchanged
  262.         unless @state_changed
  263.           # Set damage to "Miss"
  264.           self.damage = "Miss"
  265.         end
  266.       end
  267.     # If miss occurs
  268.     else
  269.       # Set damage to "Miss"
  270.       self.damage = "Miss"
  271.     end
  272.     # If not in battle
  273.     unless $game_temp.in_battle
  274.       # Set damage to nil
  275.       self.damage = nil
  276.     end
  277.     # End Method
  278.     return effective
  279.   end
  280. end
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289. # Struct used to save the atributes modifiers for each actor
  290.  
  291. AtrList = Struct.new( :maxhp, :maxsp, :str, :dex, :int, :agi, :atk, :pdef,
  292. :mdef, :eva )
  293.  
  294. #==============================================================================
  295. # ** Game_Battler (part 1)
  296. #------------------------------------------------------------------------------
  297. #  This class deals with battlers. It's used as a superclass for the Game_Actor
  298. #  and Game_Enemy classes.
  299. #==============================================================================
  300.  
  301. class Game_Battler
  302.   #--------------------------------------------------------------------------
  303.   # * Public Instance Variables
  304.   #--------------------------------------------------------------------------
  305.   attr_accessor :atr_mod_list                    
  306.   #--------------------------------------------------------------------------
  307.   # * Object Initialization
  308.   #--------------------------------------------------------------------------
  309.   alias gb_wep_dq_init initialize
  310.   def initialize
  311.      @atr_mod_list = AtrList.new(0,0,0,0,0,0,0,0,0,0)
  312.      return gb_wep_dq_init
  313.   end
  314.    
  315.   #--------------------------------------------------------------------------
  316.   # * Reset atr mod list (for when combat ends)
  317.   #--------------------------------------------------------------------------
  318.   def reset_atr_mod_list
  319.       @atr_mod_list = AtrList.new(0,0,0,0,0,0,0,0,0,0)
  320.   end
  321. end
  322.  
  323.  
  324.  
  325.  
  326. #==============================================================================
  327. # ** Game_Enemy
  328. #------------------------------------------------------------------------------
  329. #==============================================================================
  330.  
  331. class Game_Enemy < Game_Battler
  332.  
  333.   #--------------------------------------------------------------------------
  334.   # * Get Basic Maximum HP
  335.   #--------------------------------------------------------------------------
  336.   alias wep_dq_base_maxhp base_maxhp
  337.   def base_maxhp
  338.     # Max is 9999 and min is 0
  339.     if wep_dq_base_maxhp + @atr_mod_list.maxhp > 9999
  340.       return 9999
  341.     elsif wep_dq_base_maxhp + @atr_mod_list.maxhp <= 0
  342.       return 1
  343.     else
  344.       return wep_dq_base_maxhp + @atr_mod_list.maxhp
  345.     end
  346.   end
  347.   #--------------------------------------------------------------------------
  348.   # * Get Basic Maximum SP
  349.   #--------------------------------------------------------------------------
  350.   alias wep_dq_base_maxsp base_maxsp
  351.   def base_maxsp
  352.     # Max is 9999 and min is 0
  353.     if wep_dq_base_maxsp + @atr_mod_list.maxsp > 9999
  354.       return 9999
  355.     elsif wep_dq_base_maxsp + @atr_mod_list.maxsp <= 0
  356.       return 1
  357.     else
  358.       return wep_dq_base_maxsp + @atr_mod_list.maxsp
  359.     end
  360.   end
  361.   #--------------------------------------------------------------------------
  362.   # * Get Basic Strength
  363.   #--------------------------------------------------------------------------
  364.   alias wep_dq_base_str base_str
  365.   def base_str
  366.     # Max is 999 and min is 0
  367.     if wep_dq_base_str + @atr_mod_list.str > 999
  368.       return 999
  369.     elsif wep_dq_base_str + @atr_mod_list.str <= 0
  370.       return 1
  371.     else
  372.       return wep_dq_base_str + @atr_mod_list.str
  373.     end
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # * Get Basic Dexterity
  377.   #--------------------------------------------------------------------------
  378.   alias wep_dq_base_dex base_dex
  379.   def base_dex
  380.     # Max is 999 and min is 0
  381.     if wep_dq_base_dex + @atr_mod_list.dex > 999
  382.       return 999
  383.     elsif wep_dq_base_dex + @atr_mod_list.dex <= 0
  384.       return 1
  385.     else
  386.       return wep_dq_base_dex + @atr_mod_list.dex
  387.     end
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # * Get Basic Agility
  391.   #--------------------------------------------------------------------------
  392.   alias wep_dq_base_agi base_agi
  393.   def base_agi
  394.     # Max is 999 and min is 0
  395.     if wep_dq_base_agi + @atr_mod_list.agi > 999
  396.       return 999
  397.     elsif wep_dq_base_agi + @atr_mod_list.agi <= 0
  398.       return 1
  399.     else
  400.       return wep_dq_base_agi + @atr_mod_list.agi
  401.     end
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # * Get Basic Intelligence
  405.   #--------------------------------------------------------------------------
  406.   alias wep_dq_base_int base_int
  407.   def base_int
  408.     # Max is 999 and min is 0
  409.     if wep_dq_base_int + @atr_mod_list.int > 999
  410.       return 999
  411.     elsif wep_dq_base_int + @atr_mod_list.int <= 0
  412.       return 1
  413.     else
  414.       return wep_dq_base_int + @atr_mod_list.int
  415.     end
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # * Get Basic Attack Power
  419.   #--------------------------------------------------------------------------
  420.   alias wep_dq_base_atk base_atk
  421.   def base_atk
  422.     # Max is 999 and min is 0
  423.     if wep_dq_base_atk + @atr_mod_list.atk > 999
  424.       return 999
  425.     elsif wep_dq_base_atk + @atr_mod_list.atk <= 0
  426.       return 1
  427.     else
  428.       return wep_dq_base_atk + @atr_mod_list.atk
  429.     end
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # * Get Basic Physical Defense
  433.   #--------------------------------------------------------------------------
  434.   alias wep_dq_base_pdef base_pdef
  435.   def base_pdef
  436.     # Max is 999 and min is 0
  437.     if wep_dq_base_pdef + @atr_mod_list.pdef > 999
  438.       return 999
  439.     elsif wep_dq_base_pdef + @atr_mod_list.pdef <= 0
  440.       return 1
  441.     else
  442.       return wep_dq_base_pdef + @atr_mod_list.pdef
  443.     end
  444.   end
  445.   #--------------------------------------------------------------------------
  446.   # * Get Basic Magic Defense
  447.   #--------------------------------------------------------------------------
  448.   alias wep_dq_base_mdef base_mdef
  449.   def base_mdef
  450.     # Max is 999 and min is 0
  451.     if wep_dq_base_mdef + @atr_mod_list.mdef > 999
  452.       return 999
  453.     elsif wep_dq_base_mdef + @atr_mod_list.mdef <= 0
  454.       return 1
  455.     else
  456.       return wep_dq_base_mdef + @atr_mod_list.mdef
  457.     end
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # * Get Basic Evasion Correction
  461.   #--------------------------------------------------------------------------
  462.   alias wep_dq_base_eva base_eva
  463.   def base_eva
  464.     # Max is 999 and min is 0
  465.     if wep_dq_base_eva + @atr_mod_list.eva > 999
  466.       return 999
  467.     elsif wep_dq_base_eva + @atr_mod_list.eva <= 0
  468.       return 1
  469.     else
  470.       return wep_dq_base_eva + @atr_mod_list.eva
  471.     end
  472.   end
  473. end
  474.  
  475.  
  476.  
  477. #==============================================================================
  478. # ** Game_Actor
  479. #------------------------------------------------------------------------------
  480. #  This class handles the actor. It's used within the Game_Actors class
  481. #  ($game_actors) and refers to the Game_Party class ($game_party).
  482. #==============================================================================
  483.  
  484. class Game_Actor < Game_Battler
  485.  
  486.   #--------------------------------------------------------------------------
  487.   # * Get Basic Maximum HP
  488.   #--------------------------------------------------------------------------
  489.   alias wep_dq_base_maxhp base_maxhp
  490.   def base_maxhp
  491.     # Max is 9999 and min is 0
  492.     if wep_dq_base_maxhp + @atr_mod_list.maxhp > 9999
  493.       return 9999
  494.     elsif wep_dq_base_maxhp + @atr_mod_list.maxhp <= 0
  495.       return 1
  496.     else
  497.       return wep_dq_base_maxhp + @atr_mod_list.maxhp
  498.     end
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # * Get Basic Maximum SP
  502.   #--------------------------------------------------------------------------
  503.   alias wep_dq_base_maxsp base_maxsp
  504.   def base_maxsp
  505.     # Max is 9999 and min is 0
  506.     if wep_dq_base_maxsp + @atr_mod_list.maxsp > 9999
  507.       return 9999
  508.     elsif wep_dq_base_maxsp + @atr_mod_list.maxsp <= 0
  509.       return 1
  510.     else
  511.       return wep_dq_base_maxsp + @atr_mod_list.maxsp
  512.     end
  513.   end
  514.   #--------------------------------------------------------------------------
  515.   # * Get Basic Strength
  516.   #--------------------------------------------------------------------------
  517.   alias wep_dq_base_str base_str
  518.   def base_str
  519.     # Max is 999 and min is 0
  520.     if wep_dq_base_str + @atr_mod_list.str > 999
  521.       return 999
  522.     elsif wep_dq_base_str + @atr_mod_list.str <= 0
  523.       return 1
  524.     else
  525.       return wep_dq_base_str + @atr_mod_list.str
  526.     end
  527.   end
  528.   #--------------------------------------------------------------------------
  529.   # * Get Basic Dexterity
  530.   #--------------------------------------------------------------------------
  531.   alias wep_dq_base_dex base_dex
  532.   def base_dex
  533.     # Max is 999 and min is 0
  534.     if wep_dq_base_dex + @atr_mod_list.dex > 999
  535.       return 999
  536.     elsif wep_dq_base_dex + @atr_mod_list.dex <= 0
  537.       return 1
  538.     else
  539.       return wep_dq_base_dex + @atr_mod_list.dex
  540.     end
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # * Get Basic Agility
  544.   #--------------------------------------------------------------------------
  545.   alias wep_dq_base_agi base_agi
  546.   def base_agi
  547.     # Max is 999 and min is 0
  548.     if wep_dq_base_agi + @atr_mod_list.agi > 999
  549.       return 999
  550.     elsif wep_dq_base_agi + @atr_mod_list.agi <= 0
  551.       return 1
  552.     else
  553.       return wep_dq_base_agi + @atr_mod_list.agi
  554.     end
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # * Get Basic Intelligence
  558.   #--------------------------------------------------------------------------
  559.   alias wep_dq_base_int base_int
  560.   def base_int
  561.     # Max is 999 and min is 0
  562.     if wep_dq_base_int + @atr_mod_list.int > 999
  563.       return 999
  564.     elsif wep_dq_base_int + @atr_mod_list.int <= 0
  565.       return 1
  566.     else
  567.       return wep_dq_base_int + @atr_mod_list.int
  568.     end
  569.   end
  570.   #--------------------------------------------------------------------------
  571.   # * Get Basic Attack Power
  572.   #--------------------------------------------------------------------------
  573.   alias wep_dq_base_atk base_atk
  574.   def base_atk
  575.     # Max is 999 and min is 0
  576.     if wep_dq_base_atk + @atr_mod_list.atk > 999
  577.       return 999
  578.     elsif wep_dq_base_atk + @atr_mod_list.atk <= 0
  579.       return 1
  580.     else
  581.       return wep_dq_base_atk + @atr_mod_list.atk
  582.     end
  583.   end
  584.   #--------------------------------------------------------------------------
  585.   # * Get Basic Physical Defense
  586.   #--------------------------------------------------------------------------
  587.   alias wep_dq_base_pdef base_pdef
  588.   def base_pdef
  589.     # Max is 999 and min is 0
  590.     if wep_dq_base_pdef + @atr_mod_list.pdef > 999
  591.       return 999
  592.     elsif wep_dq_base_pdef + @atr_mod_list.pdef <= 0
  593.       return 1
  594.     else
  595.       return wep_dq_base_pdef + @atr_mod_list.pdef
  596.     end
  597.   end
  598.   #--------------------------------------------------------------------------
  599.   # * Get Basic Magic Defense
  600.   #--------------------------------------------------------------------------
  601.   alias wep_dq_base_mdef base_mdef
  602.   def base_mdef
  603.     # Max is 999 and min is 0
  604.     if wep_dq_base_mdef + @atr_mod_list.mdef > 999
  605.       return 999
  606.     elsif wep_dq_base_mdef + @atr_mod_list.mdef <= 0
  607.       return 1
  608.     else
  609.       return wep_dq_base_mdef + @atr_mod_list.mdef
  610.     end
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # * Get Basic Evasion Correction
  614.   #--------------------------------------------------------------------------
  615.   alias wep_dq_base_eva base_eva
  616.   def base_eva
  617.     # Max is 999 and min is 0
  618.     if wep_dq_base_eva + @atr_mod_list.eva > 999
  619.       return 999
  620.     elsif wep_dq_base_eva + @atr_mod_list.eva <= 0
  621.       return 1
  622.     else
  623.       return wep_dq_base_eva + @atr_mod_list.eva
  624.     end
  625.   end
  626. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement