じ☆ve冰风 发表于 2026-7-8 14:17:40

Leveled Enemy Lists

Leveled Enemy Lists
Version: 1.0​



Introduction
Have you even thought...my random enemies don't seem to match my heroes when they engage them?Have you ever thought that maybe you could swap out the enemies in your Troops with other enemies if the average party member's level is high enough?Now you can.



Script
Spoiler: Leveled Lists                 Code:        
#============================================================================== # ** Leveled Enemy Lists #------------------------------------------------------------------------------ #    by DerVVulfman #    version 1.0 #    09-12-2019 (MM-DD-YYYY) #    RGSS / RMXP #============================================================================== # #INTRODUCTION: # #Have you even thought...my random enemies don't seem to match my heroes #when they engage them?Have you ever thought that maybe you could swap out #the enemies in your Troops with other enemies if the average party member's #level is high enough?Now you can. #   # #============================================================================== # #LEVELED ENEMIES: #   #The feature examines each enemy from the troops database, and checks to#see if it is the 'key' to one of the lists in the LeveledEnemies module. #If it is to be replaced, it uses the enemy within the array (or arrays) #that the entry supplies. # #IF... (hehehe)... the replacement enemy is actually a 'key' to another #list in the LeveledEnemies module, it TOO can get replaced.Yes, dear #reader... recusion abouds so you can make very detailed level lists! # #                              *   *   * # #Each Entry within the LIST hash array is as follows: # #LIST[ key ]= [ leveled enemies ] # #As stated above, the 'key' is the ID of an enemy that will be replaced #within yourtroops database.   In our default script,the first list #replaces theGHOST (enemy #1)while thesecond listin the default #script replaces the SAGAHIN (#3) # #                              *   *   * # #The leveled lists are a collection of arrays.There must be at least #one array like this: # #LIST = [ , ,... ] # #Types of 'list of enemies': #1)Array of enemy IDs:                        [ id, id, id, id, ... id ]   #2)Array with a min level & list of enemy IDs:[ lvl, [ id, id, id....] ] # # #Style #1)This is just a list of enemy IDs.It will randomly select from #             this list. # #Style #2)This is a level-based list.It has a level to test against the #             average level* of the party.And only IF the party's average is #             higher than this test value will it use the enemies in the list #             of enemies next to it. #               #             IF an enemy list has a required level and the party has not #             reached that minimum level, no substitution will occur. ##============================================================================== # #TERMS OF USE # #Free for use, even in commercial works.Only due credit is required. # #==============================================================================    module LeveledEnemies      LIST = {}    #         ID    # LIST OF MONSTERS   #============   ==================   LIST = [, ] ]   LIST = [ ]]   LIST = []    # NOTES FROM A WEREWOLF:   #-------------------------------------------------------------------------   # LIST ...Any ghost can be replaced by enemies 2,3 or 4 under normal   #            circumstances   But if the level of the party is level 5,   #            then the ghost is replaced by enemies 5, 6, 7 or 8.   #   #            IF the ghost is replaced by a Basilisk or Sagahin, look at   #            the next two lists!THEY DO COUNT!   #   # LIST ...If a Basilisk is encountered, it can only be replaced by   #            enemies if the level of the party as a while is at least 15.   #            Otherwise, the basilisk remains in the troop.   #               # LIST ...If a Sagahin is encountered, it can be replaced with no   #            problems with enemies 10, 11, 18 and 19.   #   #-------------------------------------------------------------------------    end#============================================================================== # ** Game_Enemy #------------------------------------------------------------------------------ #This class handles enemies. It's used within the Game_Troop class #($game_troop). #==============================================================================class Game_Enemy < Game_Battler   #--------------------------------------------------------------------------   # * Public Instance Variables   #--------------------------------------------------------------------------   attr_accessor :member_index             # Member index (position in troop)   #--------------------------------------------------------------------------   # * Alias Listings   #--------------------------------------------------------------------------   alias meebers initialize   #--------------------------------------------------------------------------   # * Object Initialization   #   troop_id   : troop ID   #   member_index : troop member index   #--------------------------------------------------------------------------   def initialize(troop_id, member_index, enemy_id=nil)   # Perform a normal initialize   meebers(troop_id, member_index)   # Exit if no custom enemy ID sent   return if enemy_id.nil?   # Re-perform the initialize with the new enemy ID   @troop_id   = troop_id   @member_index = member_index   troop         = $data_troops[@troop_id]   @enemy_id   = enemy_id   enemy         = $data_enemies[@enemy_id]   @battler_name = enemy.battler_name   @battler_hue= enemy.battler_hue   @hp         = maxhp   @sp         = maxsp   @hidden       = troop.members[@member_index].hidden   @immortal   = troop.members[@member_index].immortal   end   end    #============================================================================== # ** Game_Troop #------------------------------------------------------------------------------ #This class deals with troops. Refer to "$game_troop" for the instance of #this class. #==============================================================================class Game_Troop   #--------------------------------------------------------------------------   # * Alias Listings   #--------------------------------------------------------------------------   alias moobers setup   #--------------------------------------------------------------------------   # * Setup   #   troop_id : troop ID   #--------------------------------------------------------------------------   def setup(troop_id)   # Perform the original call   moobers(troop_id)   # Obtain party level   @level = setup_level   # Replace   setup_replace(troop_id)   end   #--------------------------------------------------------------------------   # * Setup : Acquiring average level of all party members   #--------------------------------------------------------------------------   def setup_level   level = 0   for actor in $game_party.actors       level += actor.level   end   level /= $game_party.actors.size   return level.to_i   end   #--------------------------------------------------------------------------   # * Setup : Loop through and replace enemy as needed   #   troop_id : troop ID   #--------------------------------------------------------------------------   def setup_replace(troop_id)   # Create a temp array   temp = []   # Cycle through each enemy   for enemy in @enemies       # Get new enemy ID based on old enemy       enemy_id = setup_individual(enemy)       # Push into temp array       temp.push(Game_Enemy.new(troop_id, enemy.member_index, enemy_id))   end   # Replace the enemy array with the temp array   @enemies = temp   end   #--------------------------------------------------------------------------   # * Setup : Loop through and replace enemy as needed   #   troop_id : troop ID   #--------------------------------------------------------------------------   def setup_individual(enemy)   # Perform a loop   loop do       # Get the enemy's ID       e_id = enemy.id       # Perform only if enemy list has the enemy ID as a key       if LeveledEnemies::LIST.has_key?(e_id)         result = setup_listchoice(e_id)         enemy = result unless result.nil?       end       # Break if list doesn't supply proper content       break if result.nil?       # Oooh... only exit loop if no matching enemy ID as a key       break unless LeveledEnemies::LIST.has_key?(enemy.id)   end   # Return the new enemy ID   return enemy.id   end   #--------------------------------------------------------------------------   # * Setup : Loop individual sets to choose   #   troop_id : troop ID   #--------------------------------------------------------------------------   def setup_listchoice(e_id)   array_list = LeveledEnemies::LIST   enemy = nil   # Cycle through each set   for set in array_list       # Reset temp list       temp_list = []       # Determine if has set level or not       if set.size == 2         min_level= set         temp_list = set       else         min_level= nil         temp_list = set       end       # If there's no minimum       if min_level.nil?         rand_size   = temp_list.size         choice      = temp_list         enemy       = $data_enemies       # or if player level is exceeding min required level for set       elsif @level >= min_level         rand_size   = temp_list.size         choice      = temp_list         enemy       = $data_enemies       end   end       return enemy   end end




Instructions
They're inside the script.



FAQ
They may generally look like the Leveled Lists from the Elder Scrolls games from Morrowind on up.



Compatibility
Designed for RPGMaker XP.



Terms of Use
Free for use, even in Commercial products.Due credit is required.


本贴来自国际rpgmaker官方论坛作者:DerVVulfman处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/leveled-enemy-lists.113239/
页: [1]
查看完整版本: Leveled Enemy Lists