L2JMobius

Classic Seven Signs L2Monster Random Spawn Multiplier

friendlyfire · 5 · 7803

Offline friendlyfire

  • Vassal
  • *
    • Posts: 9
Hello
Mb it would be instresting for ppl who wants to randomly increase spawn amount of monsters.

Code: [Select]
L2J_Mobius_Classic_2.3_SevenSigns\java\com\l2jmobius\gameserver\model\spawns\NpcSpawnTemplate.java

public NpcSpawnTemplate(SpawnTemplate spawnTemplate, SpawnGroup group, StatsSet set)

// Replace
-               _count = set.getInt("count", 1);
+               _count = getSpawnMultiplier(_id, set);

 // Add
  private int getSpawnMultiplier(int id, StatsSet set)
  {
    final L2NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(id);

    if (!npcTemplate.isType("L2Monster"))
    {
      return set.getInt("count", 1);
    }

    if (Config.MONSTER_SPAWN_MULTIPLIER_ENABLE)
    {
      int rnd = new Random().nextInt((Config.MONSTER_SPAWN_MULTIPLIER_RANGE - 1) + 1) + 1;

      if (Config.MONSTER_SPAWN_MULTIPLIER_LIST.size() > 0)
      {
        if (Config.MONSTER_SPAWN_MULTIPLIER_LIST.contains(id))
        {
          return rnd;
        }
      }

      return rnd;
    }
             return set.getInt("count", 1);
  }

L2J_Mobius_Classic_2.3_SevenSigns\java\com\l2jmobius\Config.java

+import java.util.Collections;

+       private static final String CUSTOM_MONSTER_MULTIPLIER_CONFIG_FILE = "./config/Custom/MonsterMultiplier.ini";

+       public static boolean MONSTER_SPAWN_MULTIPLIER_ENABLE;
+       public static int MONSTER_SPAWN_MULTIPLIER_RANGE;
+       public static List<Integer> MONSTER_SPAWN_MULTIPLIER_LIST;


+       // Load MonsterMultiplier config file (if exists)
+       final PropertiesParser MonsterMultiplier = new PropertiesParser(CUSTOM_MONSTER_MULTIPLIER_CONFIG_FILE);
+
+       MONSTER_SPAWN_MULTIPLIER_ENABLE = MonsterMultiplier.getBoolean("MonsterSpawnMultiplier", false);
+       MONSTER_SPAWN_MULTIPLIER_RANGE = MonsterMultiplier.getInt("MonsterSpawnMultiplierRange", 2);
+
+       if (MONSTER_SPAWN_MULTIPLIER_ENABLE)
+       {
+             final List<String> monsterMultiplierList = getIds(ChampionMonster.getString("MonsterSpawnMultiplierList", ""), ",");
+             MONSTER_SPAWN_MULTIPLIER_LIST = new ArrayList<>(monsterMultiplierList.size());
+             for (String s : monsterMultiplierList)
+             {
+                 MONSTER_SPAWN_MULTIPLIER_LIST.add(Integer.parseInt(s));
+             }
+         }


+       public static List<String> getIds(String str, String separator)
+       {
+           List<String> list = new ArrayList<>(Arrays.asList(str.split(separator)));
+           list.removeAll(Collections.singletonList(""));
+
+           return list;
+       }


Create L2J_Mobius_Classic_2.3_SevenSigns\dist\game\config\Custom\MonsterSpawnMultiplier.ini

# ---------------------------------------------------------------------------
# MonsterSpawnMultiplier randomly set the spawn amount of L2Monster
# ---------------------------------------------------------------------------

# Enable/Disable
MonsterSpawnMultiplier = True

# Randomly increase amount of spawned NPC of type L2Monster
# Default: 1
MonsterSpawnMultiplierRange = 1

# Specify ids of L2Monster to be affected
# Empty to affect of L2Monster
# Set ids to affect specific L2Monster
# Example
# MonsterMultiplierList = 1045,2019
# Default:
MonsterSpawnMultiplierList =


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16041


Offline mithrilmines

  • Viscount
  • *****
    • Posts: 385

Offline friendlyfire

  • Vassal
  • *
    • Posts: 9
Mobius
I add a mode (static/dynamic)

https://pastebin.com/1QFHd1YQ


mithrilmines - not sure that I got what you mean

Monsters spawn time depend on respawnTime defined in npc description