L2JMobius

C6 Double NPC spawn

ver · 5 · 2338

Offline ver

  • Knight
  • ***
    • Posts: 70
Hello guys,

I've started adapting LongTimeEvent class from hi5 in interlude. All seems to be working fine, but I have an issue with double npcs spawn.

I have npc which suppose to spawn here x="-84021" y="243774" z="-3728" heading="54690".
I made a simple debug in QuestSpawn.addSpawn() method (which is started by Quest.addSpawn()) to check if this npc spawns single time, or maybe something executes addSpawn multiple times.
Debug displays info about a spawn like:
[28/01 18:48:31] spawning 31864 at: -84021, 243774, -3708, 54690

Nothing fancy. As you probably suspect - there is single line there, so addSpawn method is fired once.

However in game I see two npcs, one has coordinates x="-84021" y="243774" (as in XML), but z="-3708" is different, and 2nd has very similar: x="-84016" y="243778" (not like in XML), z="-3728" (as in XML).

When I change coordinates in XML to: x="-84016" y="243778" z="-3728"  (x,y from 2nd spawn and z from the first one) - npc spawns just once, without problem. Thats why I suspect it might be location related.

This is how it looks like:


Any advice would be appriciated.


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16009
You used something like this?
Code: [Select]
for (NpcSpawn spawn : _spawnList)
{
addSpawn(spawn.npcId, spawn.loc.getX(), spawn.loc.getY(), spawn.loc.getZ(), spawn.loc.getHeading(), false, (int) millisToEventEnd);
}

Adaptation to match changes from subscriber version.
https://pastebin.com/hpDaaThL


Offline ver

  • Knight
  • ***
    • Posts: 70
Sure I can. But there is nothing interesting there. It is all based on that one from Hi5.
I have splitted npc spawning method into two - one for npcs, 2nd for mobs (yes, my version has npcs and mobs in spawnlists).

Code: [Select]
protected void spawnManagers()
{
// dont spawn anything if there is something spawned already
if (!(_managersSpawnedList.isEmpty())) {
return;
}

final Long millisToDespawnManagers = _managersPeriod.getEndDate().getTime() - Chronos.currentTimeMillis();

for (NpcSpawn spawn : _managersSpawnList)
{
_managersSpawnedList.add(addSpawn(spawn.npcId, spawn.loc.getX(), spawn.loc.getY(), spawn.loc.getZ(), spawn.loc.getHeading(), false, millisToDespawnManagers.intValue()));
}

LOGGER.info("Event " + _eventName + " spawning " + _managersSpawnedList.size() + " managers (till: " + _managersPeriod.getEndDate() + ")");
}


The info says:
[28/01 19:09:36] Event Tis The Season spawning 17 managers (till: Mon Feb 14 10:41:00 CET 2022)

And config XML (a bit modified, but not much) contains:
Code: [Select]
<spawnlist>
<npc npc="31864" x="47566" y="51138" z="-3001" heading="33264" /> <!-- Elven Village -->
<npc npc="31864" x="11861" y="16173" z="-4568" heading="18289" /> <!-- Dark Elven Village -->
<npc npc="31864" x="114933" y="-177733" z="-848" heading="52406" /> <!-- Dwarven Village -->
<npc npc="31864" x="-44810" y="-113388" z="-192" heading="15527" /> <!-- Orc Village -->
<npc npc="31864" x="-84021" y="243774" z="-3728" heading="54690" /> <!-- Talking Island Village -->
<npc npc="31863" x="147855" y="26629" z="-2210" heading="19523" />
<npc npc="31863" x="16249" y="142870" z="-2711" heading="12022" />
<npc npc="31863" x="17832" y="170509" z="-3531" heading="48408" />
<npc npc="31863" x="83057" y="149281" z="-3474" heading="31176" />
<npc npc="31863" x="-80858" y="149456" z="-3070" heading="16948" />
<npc npc="31863" x="-12147" y="122760" z="-3102" heading="34490" />
<npc npc="31863" x="110954" y="218935" z="-3548" heading="0" />
<npc npc="31863" x="117158" y="75807" z="-2735" heading="25189" />
<npc npc="31863" x="82494" y="53151" z="-1501" heading="946" />
<npc npc="31863" x="43556" y="-47626" z="-802" heading="42552" />
<npc npc="31863" x="147388" y="-55436" z="-2738" heading="62376" />
<npc npc="31863" x="87775" y="-143216" z="-1298" heading="27295" />
</spawnlist>

I was wondering... maybe there is some collision detected and "something" spawns that npc again?

Additional thing I noticed is that one with incorrect Z has respawn 0 sec, and 2nd one (with correct X and Y) has respawn 10 sec.
I believe respawn 0 is correct one.


Offline ver

  • Knight
  • ***
    • Posts: 70
FFS... I found it.
//recall_npc adds npc to custom_spawnlist table... I must have used recall on santa when I tried to find a best location for him.

Sorry...