Random Monster Groups
by RPG Advocate
saved from Phylomortis.Com
v 1.1 Revision by DerVVulfman
Introduction
This script allows you to set up monster groups composed of random enemies.
Normally, when you create a monster group, what you set up in the TROOPS database will appear as shown. But when using this script, a monster group with three numbers between 1 and 8 as the first three characters of its name will generate a random number of monsters within the ranges you setup. The number meanings are as follows:
First number: The minimum no. of monsters in the random monster group.
Second number: The maximum number of monsters generated in the random monster group.*
Third number: The id number of monsters that will be randomly generated in the group. **
Now again... the three numbers used in this random monster group must be between 1 and 8, so a monster party named: 146
Will generate a random group of 1 to 4 monsters, and the troop has a variety of 6 types of monsters.
* You must have at least as many monsters loaded into the troop as set in your troop name.
** Each monster loaded into the troop has an member ID number. The first one loaded is #1, the second is #2, regardless of their individual enemy ID. So, in the above example... by adding a 'Ghost', 'Basilisk, 'Cobold', 'Imp', 'Angel' and 'Ogre' into the troop will let the system use any of these '6' in the creation of the random troop. Adding any more enemies will just create placeholders in the troop where they may appear on the screen.
Troop: 146 could generate...
Ghost, Ogre
Imp, Angel, Angel
Ghost, Basilisk
Imp
Angel, Angel, Angel, Angel
and etc
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemies. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Object Initialization
# troop_id : troop ID
# member_index : troop member index
# random_index : random troop index
#--------------------------------------------------------------------------
alias rmg_initialize initialize
def initialize(troop_id, member_index, random_index = -1)
rmg_initialize(troop_id, member_index)
@random_index = member_index
@random_index = member_index
if random_index >= 0
@member_index = random_index
@random_index = random_index
end
end
#--------------------------------------------------------------------------
# * Get Battle Screen X-Coordinate
#--------------------------------------------------------------------------
def screen_x
return $data_troops[@troop_id].members[@random_index].x
end
#--------------------------------------------------------------------------
# * Get Battle Screen Y-Coordinate
#--------------------------------------------------------------------------
def screen_y
return $data_troops[@troop_id].members[@random_index].y
end
end
#==============================================================================
# ** Game_Troop
#------------------------------------------------------------------------------
# This class deals with troops. Refer to "$game_troop" for the instance of
# this class.
#==============================================================================
class Game_Troop
#--------------------------------------------------------------------------
# * Setup
# troop_id : troop ID
#--------------------------------------------------------------------------
def setup(troop_id)
# Set array of enemies who are set as troops
@enemies = []
troop = $data_troops[troop_id]
# Split array name for random troop system
first = troop.name[0]
second = troop.name[1]
third = troop.name[2]
# Create troop error messages
error1 = "Error: Minimum size for random groups "
error2 = "must not exceed maxmimum size."
error3 = error1 + error2
error4 = "Error: There must be at least as many "
error5 = "monsters in the monster group as "
error6 = "the maximum number of monsters that can "
error7 = "appear in the random monster group."
error8 = error4 + error5 + error6 + error7
error9 = "Error: Number of monsters to use in "
error10 = "random generation is greater than "
error11 = "the size of the monster group."
error12 = error9 + error10 + error11
# Compare troop data and apply accordingly
if first >= 49 && first <= 56
if second >= 49 && second <= 56
if third >= 49 && third <= 56
min = first - 48
max = second - 48
used = third - 48
difference = second - first
if min > max
print(error3)
exit
end
if max > troop.members.size
print(error8)
exit
end
if used > troop.members.size
print(error12)
exit
end
if difference != 0
troop_size = rand(difference + 1) + min
else
troop_size = min
end
for j in 0..troop_size - 1
enemy_number = rand(used)
@enemies.push(Game_Enemy.new(troop_id, enemy_number, j))
end
return
end
end
end
# Apply troop data
for j in 0...troop.members.size
enemy = $data_enemies[troop.members[j].enemy_id]
if enemy != nil
@enemies.push(Game_Enemy.new(troop_id, j))
end
end
end
end