if(target == null)
target = activeChar;
if(target != activeChar && activeChar.getAccessLevel().isGm())
target = activeChar;
L2NpcTemplate template1;
if(monsterId.matches("[0-9]*"))
{
//First parameter was an ID number
int monsterTemplate = Integer.parseInt(monsterId);
template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
}
else
{
//First parameter wasn't just numbers so go by name not ID
monsterId = monsterId.replace('_', ' ');
template1 = NpcTable.getInstance().getTemplateByName(monsterId);
}
if(template1 == null){
activeChar.sendMessage("Attention, wrong NPC ID/Name");
return;
}
try
{
L2Spawn spawn = new L2Spawn(template1);
if(Config.SAVE_GMSPAWN_ON_CUSTOM)
spawn.setCustom(true);
spawn.setLocx(target.getX());
spawn.setLocy(target.getY());
spawn.setLocz(target.getZ());
spawn.setAmount(mobCount);
spawn.setHeading(activeChar.getHeading());
spawn.setRespawnDelay(respawnTime);
if(RaidBossSpawnManager.getInstance().isDefined(spawn.getNpcid()) || GrandBossManager.getInstance().isDefined(spawn.getNpcid()))
{
activeChar.sendMessage("Another instance of " + template1.name + " already present into database:");
activeChar.sendMessage("It will be spawned but not saved on Database");
activeChar.sendMessage("After server restart or raid dead, the spawned npc will desappear");
permanent=false;
spawn.set_customBossInstance(true); //for raids, this value is used in order to segnalate to not save respawn time - status for custom instance
}
//else
//{
if(RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getNpcid()) != null)
{
RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template1.getStatsSet().getDouble("baseHpMax"), template1.getStatsSet().getDouble("baseMpMax"), permanent);
}
else
{
SpawnTable.getInstance().addNewSpawn(spawn, permanent);
}