Advertisement
AngryPacman

[VXA] Enemy Summon Skill

Jan 29th, 2012
2,975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.34 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Enemy Summon Skill (1.0)
  4. # 30/1/12
  5. # By modern algebra and (ported to VXA) Pacman
  6. # This script allows you to make skills for enemies where they can summon or
  7. # call additional enemies to the battlefield. This is NOT a summon skill that
  8. # can be used by actors - it can ONLY be used by enemies.
  9. # You can set up some basic configuration at line 44. Please check the comments
  10. # to see what each option does.
  11. # To create a summoning skill (which can only be used by enemies), simply put
  12. # the following code in the skill's notebox:
  13. #
  14. # \SUMMON_ENEMY[id, x, y, n]
  15. #
  16. #   id : the ID of the enemy it can summon.
  17. #   x  : the additional pixels along the axis the summoned creature is from
  18. #       its summoner. If omitted, it defaults to the value at line 64.
  19. #   y  : the additional pixels along the axis the summoned creature is from
  20. #       its summoner. If omitted, it defaults to the value at line 67.
  21. #   n  : of the potential candidates for summoning, how likely this one
  22. #       will be chosen over the others. If omitted, this defaults to 1.
  23. #
  24. # As you can probably tell, you can place a number of these codes in the
  25. # same notebox and thus you can make the same skill potentially summon
  26. # different enemies, and you can control that through the chance.
  27. #
  28. #  EXAMPLES:
  29. #
  30. #    A skill with its notebox set up like this:
  31. #      \summon_enemy[1, 35, 45, 3]
  32. #      \summon_enemy[2, 25, 35, 1]
  33. #
  34. # Would, when it succeeds (which is governed directly by the hit ratio of the
  35. # skill) summon the enemy with ID 1 (Default: Slime) 75% of the time and the
  36. # enemy with ID 2 (Default: Bat) 25% of the time, and the position, if it is
  37. # a slime would be 35 pixels to the right of the summoner and 45 pixels down,
  38. # or if it is the bat, then 25 pixels to the right of the summoner and 35
  39. # pixels down. The chances are 75-25 because 3 + 1 = 4, which means that 3/4
  40. # times the slime will be summoned and 1/4 times the bat will be summoned.
  41. #
  42. #=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です==
  43. #
  44. # CONFIGURATION
  45. #
  46. module MA_ESS # Don't touch this.
  47.   SUMMON_FAILURE = "%s failed to summon ally!" # Message shown when skill fails.
  48.   MAX_TROOP_SIZE = 8  # Maximum number of enemies in a troop (caps summons)
  49.   DEFAULT_X_PLUS = 35 # The default x offset for a summoned enemy from its
  50.                       # summoner. If you manually set this in the note box,
  51.                       # this value will not be used.
  52.   DEFAULT_Y_PLUS = 25 # The default y offset for a summoned enemy from its
  53.                       # summoner. If you manually set this in the note box,
  54.                       # this value will not be used.
  55. end           # Don't touch this either.
  56. #
  57. # END CONFIGURATION
  58. #
  59. #=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です==
  60.  
  61. #==============================================================================
  62. # ** RPG::Skill
  63. #------------------------------------------------------------------------------
  64. #  Data class for skills. Subclass of RPG::UsableItem. Some Japanese twaddle.
  65. #==============================================================================
  66.  
  67. class RPG::Skill < RPG::UsableItem
  68.   #--------------------------------------------------------------------------
  69.   # * 味方のスキルを呼んでいるのか?
  70.   #--------------------------------------------------------------------------
  71.   def ma_call_ally?
  72.     self.note[/\\SUMMON[_ ]?ENEMY\[\d+.*?\]/i] != nil
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * 同盟国統計情報を呼び出す
  76.   #--------------------------------------------------------------------------
  77.   def ma_call_ally
  78.     miss = rand(100)
  79.     return nil if self.success_rate < miss
  80.     possibilities = []
  81.     note = self.note.dup
  82.     note.gsub!(/\\SUMMON[_ ]?ENEMY\[(\d+)[,;]?\s*(-?\d*)[,;]?\s*(-?\d*)[,;]?\s*(\d*)\]/i) { |match|
  83.       i = $1.to_i
  84.       x = $2.empty? ? MA_ESS::DEFAULT_X_PLUS : $2.to_i
  85.       y = $3.empty? ? MA_ESS::DEFAULT_Y_PLUS : $3.to_i
  86.       n = $4.empty? ? 1 : $4.to_i
  87.       (n).times do possibilities.push([i, x, y]) end
  88.       ""
  89.     }
  90.     return *possibilities[rand(possibilities.size)]
  91.   end
  92. end
  93.  
  94. #==============================================================================
  95. # ** Game_Enemy
  96. #------------------------------------------------------------------------------
  97. #  見て、いずれにしてもこれを読んでするつもりはない、ので、私は基本的に私が好きなこの発言を行うことができます。
  98. #==============================================================================
  99.  
  100. class Game_Enemy < Game_Battler
  101.   #--------------------------------------------------------------------------
  102.   # 公開インスタンス変数
  103.   #--------------------------------------------------------------------------
  104.   attr_accessor :ma_summon_count
  105.   #--------------------------------------------------------------------------
  106.   # * オブジェクトの初期化
  107.   #--------------------------------------------------------------------------
  108.   alias maess_initialize initialize
  109.   def initialize(*args)
  110.     @ma_summon_count = 0
  111.     maess_initialize(*args)
  112.   end
  113. end
  114.  
  115. #==============================================================================
  116. # ** Game_BattlerBase
  117. #------------------------------------------------------------------------------
  118. #  私は本当にエンターブレインが同時に、英語版と日本語版をリリースしたところは思った。
  119. #==============================================================================
  120.  
  121. class Game_BattlerBase
  122.   #--------------------------------------------------------------------------
  123.   # エイリアスのリスト
  124.   #--------------------------------------------------------------------------
  125.   alias maess_sklconditionsmet? skill_conditions_met?
  126.   #--------------------------------------------------------------------------
  127.   # * スキルの条件が満たさ?
  128.   #--------------------------------------------------------------------------
  129.   def skill_conditions_met?(skill, *args)
  130.     return false if skill.ma_call_ally? && (self.is_a?(Game_Actor) ||
  131.     $game_troop.members.size >= MA_ESS::MAX_TROOP_SIZE)
  132.     maess_sklconditionsmet?(skill, *args)
  133.   end
  134. end
  135.  
  136. #==============================================================================
  137. # ** Game_Troop
  138. #------------------------------------------------------------------------------
  139. #  戦闘シーンのクラスはすべての場所を超えているため、このスクリプトでは、予想よりもはるかに困難だった。
  140. #==============================================================================
  141.  
  142. class Game_Troop < Game_Unit
  143.   #--------------------------------------------------------------------------
  144.   # * コールの味方のスキル
  145.   #--------------------------------------------------------------------------
  146.   def ma_call_ally(user, id, x, y)
  147.     user.ma_summon_count += 1
  148.     enemy = Game_Enemy.new(@enemies.size, id)
  149.     good_position = false
  150.     while !good_position
  151.       enemy.screen_x = user.screen_x + (x * user.ma_summon_count)
  152.       enemy.screen_y = user.screen_y + (y * user.ma_summon_count)
  153.       good_position = true
  154.       @enemies.each { |baddie|
  155.         if baddie.screen_x == enemy.screen_x && baddie.screen_y == enemy.screen_y
  156.           user.ma_summon_count += 1
  157.           good_position = false
  158.         end
  159.       }
  160.     end
  161.     @enemies.push(enemy)
  162.     make_unique_names
  163.     return enemy
  164.   end
  165. end
  166.  
  167. #==============================================================================
  168. # ** Spriteset_Battle
  169. #------------------------------------------------------------------------------
  170. #  この水は実際に青であることをご存知ですか?
  171. #==============================================================================
  172.  
  173. class Spriteset_Battle
  174.   #--------------------------------------------------------------------------
  175.   # * コールの敵のスキル
  176.   #--------------------------------------------------------------------------
  177.   def ma_call_enemy(battler)
  178.     @enemy_sprites.push(Sprite_Battler.new(@viewport1, battler))
  179.   end
  180. end
  181.  
  182. #==============================================================================
  183. # ** Scene_Battle
  184. #------------------------------------------------------------------------------
  185. #  彼らはこの1つを作ったとき、私はエンターブレインのプログラマーたちが、考えていたのか見当がつかない。
  186. # レッツだけでこの作品を願って、えっ?
  187. #==============================================================================
  188.  
  189. class Scene_Battle < Scene_Base
  190.   #--------------------------------------------------------------------------
  191.   # エイリアスのリスト
  192.   #--------------------------------------------------------------------------
  193.   alias maess_use_item use_item
  194.   #--------------------------------------------------------------------------
  195.   # * アイテムを使用してください
  196.   #--------------------------------------------------------------------------
  197.   def use_item(*args)
  198.     item = @subject.current_action.item
  199.     if item.is_a?(RPG::Skill)
  200.       skill = item
  201.       if skill.ma_call_ally?
  202.         id, x, y = skill.ma_call_ally
  203.         if id.nil?
  204.           text = sprintf(MAESS::SUMMON_FAILURE, @subject.name)
  205.           @log_window.add_text(text)
  206.           wait(30)
  207.           return
  208.         else
  209.           target = $game_troop.ma_call_ally(@subject, id, x, y)
  210.           @spriteset.ma_call_enemy(target)
  211.           show_animation([target], skill.animation_id)
  212.         end
  213.       end
  214.     end
  215.     maess_use_item(*args)
  216.   end
  217. end
  218.  
  219. $imported ||= {}
  220. $imported[:pac_maess]
  221.  
  222. #===============================================================================
  223. #
  224. # スクリプトの最後
  225. # それは、このスクリプトは日本語で書かれていることに思えるかもしれません。
  226. # しかし、実際に、私はちょうど退屈し、すべてのコメントを翻訳しまった。
  227. # 悪い。
  228. #
  229. #=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です=です==
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement