Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2011
890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.48 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Shanghai Simple Script - Weapon Attack Replace
  4. # Last Date Updated: 2010.05.30
  5. # Level: Normal
  6. #
  7. # If an actor's weapons contain skills and the actor attacks, the actor will use
  8. # that skill instead as a replacement for the regular attack. Makes things like
  9. # Fire Wands actually cast fire.
  10. #===============================================================================
  11. # Instructions
  12. # -----------------------------------------------------------------------------
  13. # To install this script, open up your script editor and copy/paste this script
  14. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  15. #
  16. # <attack skill: x>
  17. # <attack skill: x, x, x>
  18. # This belongs in a weapon's notebox. x is the skill ID use for what skill will
  19. # replace the regular attack when the actor attacks with the weapon. If more
  20. # than one tag is used or the multiple x tag is used, then the regular attack
  21. # will choose randomly which of the skills to use.
  22. #===============================================================================
  23.  
  24. $imported = {} if $imported == nil
  25. $imported["WeaponAttackReplace"] = true
  26.  
  27. #==============================================================================
  28. # RPG::Weapon
  29. #==============================================================================
  30.  
  31. class RPG::Weapon < RPG::BaseItem
  32.   #--------------------------------------------------------------------------
  33.   # # Attack Skills
  34.   #--------------------------------------------------------------------------
  35.   def attack_skills
  36.     return @attack_skills if @attack_skills != nil
  37.     @attack_skills = []
  38.     self.note.split(/[\r\n]+/).each { |line|
  39.       case line
  40.       when /<(?:ATTACK_SKILL|attack skill):[ ](\d+(?:\s*,\s*\d+)*)>/i
  41.         $1.scan(/\d+/).each { |num| @attack_skills.push(num.to_i) }
  42.       end
  43.     }
  44.     return @attack_skills
  45.   end
  46. end
  47.  
  48. #==============================================================================
  49. # ** Game_Actor
  50. #==============================================================================
  51.  
  52. class Game_Actor < Game_Battler
  53.   #--------------------------------------------------------------------------
  54.   # * Attack Skills
  55.   #--------------------------------------------------------------------------
  56.   def attack_skills
  57.     n = []
  58.     for weapon in weapons.compact do n += weapon.attack_skills end
  59.     return n
  60.   end
  61. end
  62.  
  63. #==============================================================================
  64. # ** Scene_Battle
  65. #==============================================================================
  66.  
  67. class Scene_Battle < Scene_Base
  68.   #--------------------------------------------------------------------------
  69.   # * Execute Battle Action: Attack
  70.   #--------------------------------------------------------------------------
  71.   alias execute_action_attack_sss_weapon_replace execute_action_attack unless $@
  72.   def execute_action_attack
  73.     if @active_battler.actor? and not @active_battler.attack_skills.empty?
  74.       attack_skills = @active_battler.attack_skills
  75.       skill_id = attack_skills[rand(attack_skills.size)]
  76.       @active_battler.action.set_skill(skill_id)
  77.       execute_action_skill
  78.     else
  79.       execute_action_attack_sss_weapon_replace
  80.     end
  81.   end
  82. end
  83.  
  84. #===============================================================================
  85. #
  86. # END OF FILE
  87. #
  88. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement