Advertisement
adiktuzmiko

Ruby Enemy Action Selection v1.01

Apr 10th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.54 KB | None | 0 0
  1. =begin
  2. ======================================================
  3.  
  4.   Ruby Enemy Action Selection v1.01
  5.   by Adiktuzmiko                  
  6.  
  7.   Date Created: 04/11/2014
  8.   Date Last Updated: 04/11/2014
  9.   Requires: N/A
  10.   Difficulty: Easy
  11.  
  12. ======================================================
  13.  Overview
  14. ======================================================
  15.  
  16.  Allows you to use full RGSS3 formulas for determining
  17.  which action an enemy will use.
  18.  
  19. ======================================================
  20.  Usage
  21. ======================================================
  22.  
  23.  Put this script into your scripts editor, probably
  24.  below any other script that might modify Game_Enemy.
  25.  Next thing to do is to tag your enemies. Un-tagged
  26.  enemies will use the default method for selecting
  27.  actions.
  28.  
  29.  <ruby_actions>
  30.  formula
  31.  <end_ruby_actions>
  32.  
  33.  Formula can be any valid RGSS3 formula. Accepts
  34.  multiple lines
  35.  
  36.  example:
  37.  
  38.  Use skill 4 if HP is > 50, else use skill 10
  39.  
  40.  <ruby_actions>
  41.    if self.hp > 50
  42.      return 4
  43.    else
  44.     return 10
  45.    end
  46.  <end_ruby_actions>
  47.  
  48.  It is important that all situations will return a valid
  49.  skill ID.
  50.  
  51. ======================================================
  52.  Compatibility
  53. ======================================================
  54.  
  55.  Aliases Game_Enemy's make_actions method
  56.  
  57. ======================================================
  58.  Terms and Conditions
  59. ======================================================
  60.  
  61.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  62.  
  63. ======================================================
  64. =end
  65.  
  66. #======================================================
  67. #  Do not edit below this line
  68. #======================================================
  69.  
  70.  
  71. module ADIK
  72.   module ENEMY_ACTION
  73.     TAG = /<ruby_actions>(.*)<end_ruby_actions>/im
  74.   end
  75. end
  76.  
  77. class Game_Action
  78.  
  79.   def set_enemy_action_ruby(id)
  80.     set_skill(id)
  81.   end
  82.  
  83. end
  84.  
  85. class Game_Enemy
  86.  
  87.   def action_ruby_adik
  88.     return true if @adik_ruby_action
  89.     if self.enemy.note =~ ADIK::ENEMY_ACTION::TAG
  90.       @adik_ruby_action = $1
  91.       return true
  92.     end
  93.     return nil
  94.   end
  95.  
  96.   alias make_actions_ruby_adik make_actions
  97.   def make_actions
  98.     if action_ruby_adik.nil?
  99.       make_actions_ruby_adik
  100.     else
  101.       super
  102.       return if @actions.empty?
  103.       @actions.each do |action|
  104.         action.set_enemy_action_ruby(action_selection_ruby)
  105.       end
  106.     end
  107.   end
  108.  
  109.   def action_selection_ruby
  110.     return eval(@adik_ruby_action)
  111.     return 1
  112.   end
  113.  
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement