L2JMobius

Free Users => Shares/Contributions => Topic started by: friendlyfire on March 12, 2019, 10:28:52 PM

Title: L2Monster Random Spawn Multiplier
Post by: friendlyfire on March 12, 2019, 10:28:52 PM
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 =
Title: Re: L2Monster Random Spawn Multiplier
Post by: Mobius on March 13, 2019, 05:19:15 PM
Nice idea. I would go with something like this.
https://pastebin.com/gDjqMNvS
Title: Re: L2Monster Random Spawn Multiplier
Post by: friendlyfire on March 13, 2019, 07:47:18 PM
Nice idea. I would go with something like this.
https://pastebin.com/gDjqMNvS

  :)
Title: Re: L2Monster Random Spawn Multiplier
Post by: mithrilmines on March 13, 2019, 07:55:59 PM
Nice idea. I would go with something like this.
https://pastebin.com/gDjqMNvS

  :)


if many players into a x zone .. monsters close to them resoawn fast like off ?
Title: Re: L2Monster Random Spawn Multiplier
Post by: friendlyfire on March 13, 2019, 08:31:22 PM
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