Advertisement
gerkrt

% based weapons states rates

Sep 14th, 2011
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.05 KB | None | 0 0
  1. #==============================================================================
  2. # % based weapons states rates
  3. # By gerkrt/gerrtunk
  4. # Version: 1.0
  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. Normally you can add any combination of states for weapons,
  16. but you dont have any other control. With this you can use any state based on %.
  17.  
  18. You can ask for bugs, suggerences, compatibilitzations and any other things.
  19.  
  20. -------In the future------------
  21.  
  22. Im going to add complete armors suport, and also, a elements equivalent.
  23.  
  24. ------Instructions-------------
  25.  
  26. The % means the posibilities that have the state to impact the enemy. After that
  27. impact, the traditional formula(versus random+abdce) is applied. It works like
  28. old rpgmakers state affliction.
  29.  
  30.  
  31. weapon_id=>[[state_id1, posibility], [state_id2, posibility]]
  32.  
  33. Weap_state_rates = {3=>[[2, 100], [4,100]], 11=>[[2, 100], [4,100]] }
  34.  
  35. You can add any number of states for weapon, and weapons, just add a , before these.
  36. and respect the {}.
  37.  
  38. ---------Syntax notes--------------
  39.  
  40. You can divide long linges like this:
  41.  
  42. Weap_state_rates = {3=>[[2, 100], [4,100]],
  43. 11=>[[2, 100], [4,100]] ,
  44. 15=>[[2, 100], [4,100]] }
  45.  
  46. See that the new line have to be after a , and that the final one dont put a
  47. final ,.
  48.  
  49. =end
  50.  
  51.  
  52. module Wep
  53.     Weap_state_rates = {3=>[[2, 100], [4,100]], 11=>[[2, 100], [4,100]] }
  54. end
  55.  
  56. class Game_Battler
  57.   #--------------------------------------------------------------------------
  58.   # * Applying Normal Attack Effects
  59.   #     attacker : battler
  60.   #     moded to use unique states rates
  61.   #--------------------------------------------------------------------------
  62.   def attack_effect(attacker)
  63.     # Clear critical flag
  64.     self.critical = false
  65.     # First hit detection
  66.     hit_result = (rand(100) < attacker.hit)
  67.     # If hit occurs
  68.     if hit_result == true
  69.       # Calculate basic damage
  70.       atk = [attacker.atk - self.pdef / 2, 0].max
  71.       self.damage = atk * (20 + attacker.str) / 20
  72.       # Element correction
  73.       self.damage *= elements_correct(attacker.element_set)
  74.       self.damage /= 100
  75.       # If damage value is strictly positive
  76.       if self.damage > 0
  77.         # Critical correction
  78.         if rand(100) < 4 * attacker.dex / self.agi
  79.           self.damage *= 2
  80.           self.critical = true
  81.         end
  82.         # Guard correction
  83.         if self.guarding?
  84.           self.damage /= 2
  85.         end
  86.       end
  87.       # Dispersion
  88.       if self.damage.abs > 0
  89.         amp = [self.damage.abs * 15 / 100, 1].max
  90.         self.damage += rand(amp+1) + rand(amp+1) - amp
  91.       end
  92.       # Second hit detection
  93.       eva = 8 * self.agi / attacker.dex + self.eva
  94.       hit = self.damage < 0 ? 100 : 100 - eva
  95.       hit = self.cant_evade? ? 100 : hit
  96.       hit_result = (rand(100) < hit)
  97.     end
  98.     # If hit occurs
  99.     if hit_result == true
  100.       # State Removed by Shock
  101.       remove_states_shock
  102.       # Substract damage from HP
  103.       self.hp -= self.damage
  104.       # State change
  105.       @state_changed = false
  106.       # Check to add unique states for weapons
  107.       if attacker.is_a? Game_Actor and Wep::Weap_state_rates[attacker.weapon_id] != nil
  108.         state_list = []
  109.         # Loop over state rates and check the posibiltys. Create a state list.
  110.         for state_rate in Wep::Weap_state_rates[attacker.weapon_id]
  111.             if rand(100) < state_rate[1]
  112.               state_list.push(state_rate[0])
  113.             end
  114.         end
  115.         states_plus(state_list)  
  116.       else
  117.         states_plus(attacker.plus_state_set)
  118.         states_minus(attacker.minus_state_set)
  119.       end
  120.     # When missing
  121.     else
  122.       # Set damage to "Miss"
  123.       self.damage = "Miss"
  124.       # Clear critical flag
  125.       self.critical = false
  126.     end
  127.     # End Method
  128.     return true
  129.   end
  130.  
  131.  
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement