Advertisement
ICF-Soft

ICF-Soft Enemy Selector for RPG Maker XP

Sep 7th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.12 KB | None | 0 0
  1. #===============================================================================
  2. # ICF-Soft Enemy Selector for XP Version 1.0
  3. #-------------------------------------------------------------------------------
  4. # Scripted by ICF-Soft [http://icfsoft.blogspot.com.es/]
  5. # Commercial use avaiable. Credit to ICF-Soft
  6. #===============================================================================
  7. # This header must be included with script, in english or spanish.
  8. #===============================================================================
  9.  
  10. #===============================================================================
  11. module ICFSOFT
  12. #===============================================================================
  13.  
  14.   #Configuration
  15.  
  16.   #Game Variable where store selector.
  17.   $EnemyVar = 40
  18.  
  19.   #Conversion type:
  20.   #   true: change enemy if equal to selector. For diversity purposes.
  21.   #   false: change enemy according to the highest one that is lower than
  22.   #        selector. Usefull for difficulty purposes.
  23.   $EnemyVarAbsolute = false
  24.  
  25.   #Selector table format
  26.   #
  27.   #   A hash with key numbers that stores arrays.
  28.   #   Those arrays store 2 element arrays.
  29.   #   First element is the selector and second is id from enemy that sustitutes
  30.   #   actual enemy. Selectors must be in ascending order.
  31.   #
  32.   #   You can init as an empty hash $EnemySelector = {}
  33.   #   Or give initial values like this
  34.  
  35.   $EnemySelector = {1=>[[1,2],[2,3],[3,4]], 2=>[[2,3],[3,4]], 3=>[[3,4]]}
  36.  
  37.   #   You can add more keys like these
  38.  
  39.   $EnemySelector[5]  = [[3,6]]
  40.   $EnemySelector[7]  = [[1,8],[2,9],[3,10]]
  41.   $EnemySelector[11] = [[1,12],[2,13],[3,14]]
  42.  
  43.  
  44.   #This way enemies are config to change according to selector
  45.   #Non configured enemies will have no effect
  46.  
  47. #-------------------------------------------------------------------------------
  48.   def self.EnemySelector(enemyid)
  49.     conver = enemyid
  50.     ary = $EnemySelector[conver]
  51.     x = -1
  52.     if $EnemySelector[conver] == nil
  53.       return conver
  54.     end
  55.     if $EnemyVarAbsolute
  56.       for i in 0..(ary.length - 1)
  57.         if ary[i][0] == $game_variables[$EnemyVar]
  58.           x = i
  59.           break
  60.         end
  61.       end
  62.     else
  63.       i = ary.length - 1
  64.       while (i >= 0) do
  65.         if ary[i][0] <= $game_variables[$EnemyVar]
  66.           x = i
  67.           break
  68.         end
  69.         i -= 1
  70.       end
  71.     end
  72.     if x >= 0
  73.       conver = ary[x][1]
  74.     end
  75.     return conver
  76.   end
  77.  
  78. end
  79. #===============================================================================
  80. #===============================================================================
  81. class Game_Enemy < Game_Battler
  82.   def initialize(troop_id, member_index)
  83.     super()
  84.     @troop_id = troop_id
  85.     @member_index = member_index
  86.     troop = $data_troops[@troop_id]
  87.     @enemy_id = ICFSOFT::EnemySelector(troop.members[@member_index].enemy_id)
  88.     enemy = $data_enemies[@enemy_id]
  89.     @battler_name = enemy.battler_name
  90.     @battler_hue = enemy.battler_hue
  91.     @hp = maxhp
  92.     @sp = maxsp
  93.     @hidden = troop.members[@member_index].hidden
  94.     @immortal = troop.members[@member_index].immortal
  95.   end
  96. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement