This is the current situation
My shard has been running for more than a year,Automatic restart at 11:30 every noon
Whenever championspawn begins to spawn in large numbers, the CPU occupation is very high, and the in-game Ping can reach more than 600 +
Make other players unable to play normally
Because the player's damage is high, there are many monsters killed at one time, and a large number of monsters will continue to be generated
So this situation will continue until the challenge of champion is over
Is there any good solution?

My server configuration
System: Windows Server 2008 R2 SP1
Cpu : Xeon E5-26xx v4 2.39Ghz
Ram: 4GB
NET 10M
 
I'm not sure exactly how much it would help but one thing you could do is go through any creatures that spawn during champs and remove the loot generation process if they are part of a champ spawn since you can't really loot mobs much during a champ like:

C#:
public override void GenerateLoot()
        {
            if (!IsChampionSpawn)
            {
            AddLoot(LootPack.FilthyRich, 2);
            AddLoot(LootPack.Gems, 8);
            }
        }

and same for single drop items in the creatures constructable
C#:
if (!IsChampionSpawn)
            {
            PackReg(3);
            }

You could also boost the gold drop at the end to make up for lost gold during the spawn.
 
I'm not sure exactly how much it would help but one thing you could do is go through any creatures that spawn during champs and remove the loot generation process if they are part of a champ spawn since you can't really loot mobs much during a champ like:

C#:
public override void GenerateLoot()
        {
            if (!IsChampionSpawn)
            {
            AddLoot(LootPack.FilthyRich, 2);
            AddLoot(LootPack.Gems, 8);
            }
        }

and same for single drop items in the creatures constructable
C#:
if (!IsChampionSpawn)
            {
            PackReg(3);
            }

You could also boost the gold drop at the end to make up for lost gold during the spawn.
Thank you very much for your method. This problem that has been giving me a headache has finally been greatly alleviated. Thank you :)
 
You could also do it in general, as in adding it to BaseCreature.

There is.

C#:
        public virtual void GenerateLoot(LootStage stage)
        {
            if (m_NoLootOnDeath || m_Allured)
                return;
...

and you could add to that if, to skip on ChampSpawns in general (maybe needs a condition to not ignore the champ, from what I looked Champs arent tagged as IsChampionSpawn though)
 
Great idea adding it to GenerateLoot in BaseCreature makes it much simpler to edit it. Just checked and on my older version of ServUO it doesn't tag the Champ with IsChampionSpawn so it's most likely still the same way now.

The current repo Championspawn.cs has references to it in 3 locations.

line 337:
C#:
    public bool IsChampionSpawn(Mobile m)
        {
            return m_Creatures.Contains(m);
        }

adds it to the spawn at line 806 and line 1355:
C#:
bc.IsChampionSpawn = true;

It's also in Basecreature in several spots.
 
Last edited:
I'm not sure exactly how much it would help but one thing you could do is go through any creatures that spawn during champs and remove the loot generation process if they are part of a champ spawn since you can't really loot mobs much during a champ like:

C#:
public override void GenerateLoot()
        {
            if (!IsChampionSpawn)
            {
            AddLoot(LootPack.FilthyRich, 2);
            AddLoot(LootPack.Gems, 8);
            }
        }

and same for single drop items in the creatures constructable
C#:
if (!IsChampionSpawn)
            {
            PackReg(3);
            }

You could also boost the gold drop at the end to make up for lost gold during the spawn.
Will this work with Publish 57 and isn't this just creating 2 filthy rich packs and gems? Not sure I understand what you are creating here. Is the point to define the loot better or to remove it to help with latency?
 
it should work with pub 57, I went through every creature that spawned in any of the champ spawns I have on my server and added the
if (!IsChampionSpawn)
to all loot dropped by those creatures, the check doesn't let the loot drop if they are part of a champ spawn but if they are spawned other ways the loot drops as normal.

I didn't actually do this to reduce lag, I just didn't want loot generated at champs, but not creating multiple items every time a champ spawn creature is created should help with lag

C#:
public override void GenerateLoot()   //the loot generation call in most creatures files
{
    if (!IsChampionSpawn)   //if the creature is NOT part of a champ spawn genertate the loot otherwise it won't
    {
        AddLoot(LootPack.FilthyRich, 2);
        AddLoot(LootPack.Gems, 8);
    }
}
 
it should work with pub 57, I went through every creature that spawned in any of the champ spawns I have on my server and added the
if (!IsChampionSpawn)
to all loot dropped by those creatures, the check doesn't let the loot drop if they are part of a champ spawn but if they are spawned other ways the loot drops as normal.

I didn't actually do this to reduce lag, I just didn't want loot generated at champs, but not creating multiple items every time a champ spawn creature is created should help with lag

C#:
public override void GenerateLoot()   //the loot generation call in most creatures files
{
    if (!IsChampionSpawn)   //if the creature is NOT part of a champ spawn genertate the loot otherwise it won't
    {
        AddLoot(LootPack.FilthyRich, 2);
        AddLoot(LootPack.Gems, 8);
    }
}


Super helpful actually. Thank you. Curious... do you think there is a way to make it so all mobs generate loot "on death" versus "on creation" thus reducing the worlds mobiles and items count significantly? I bet it would also help performance.

Have you noticed better performance with the above changes btw? These are the kinda things ServUO in general could really benefit from as a whole. Optimization is important! :)
 
Super helpful actually. Thank you. Curious... do you think there is a way to make it so all mobs generate loot "on death" versus "on creation" thus reducing the worlds mobiles and items count significantly? I bet it would also help performance.

Have you noticed better performance with the above changes btw? These are the kinda things ServUO in general could really benefit from as a whole. Optimization is important! :)

90% of loot is generated on death.
 
90% of loot is generated on death.
In basecreature.cs I see

C#:
        protected override void OnCreate()
        {
            GenerateLoot(LootStage.Spawning);
        }

Is this effecting that stat? Was digging yesterday and saw it so was assuming it was generating before but just hiding from the "main pack". Like for instance if you "steal" off a mob you will get their gold. No items are there unless you are doing special cases. But the Gold is.
 
In basecreature.cs I see

C#:
        protected override void OnCreate()
        {
            GenerateLoot(LootStage.Spawning);
        }

Is this effecting that stat? Was digging yesterday and saw it so was assuming it was generating before but just hiding from the "main pack". Like for instance if you "steal" off a mob you will get their gold. No items are there unless you are doing special cases. But the Gold is.

Doesn't seem to be implemented by anything, it's mainly providing an API for that use-case:
 
Doesn't seem to be implemented by anything, it's mainly providing an API for that use-case:

So if a creature has a "generate loot" on it, but doesn't define lootstage... what is it doing?
It looks to me like it's generating loot on spawning. Me and my friend have been working on this and Eleos put in some Console.WriteLine calls to check it out.
unknown.png
unknown.png

Running ServUO, I see that it's spawning loot on creation:
unknown.png
So I'm not sure why he you are saying it's not implemented by anything. It's calling BaseCreature::OnCreate.

Thoughts?

Also I generated a unicorn and then killed it. It appeared to call GenerateLoot twice.
unknown.png
The mysteries continue.... Looking at a unicorn, after the OnCreate GenerateLoot is called, the unicorn has no gold and no items. Then when it calls GenerateLoot again after their death, it adds the gold and items.

unknown.png
Above the red bar is when the unicorn was created. Below the red bar is when the unicorn was killed. Nothing on them before adding loot.


That's after putting this code in the Unicorn's GenerateLoot:

unknown.png
 
Last edited by a moderator:
So if a creature has a "generate loot" on it, but doesn't define lootstage... what is it doing?
It looks to me like it's generating loot on spawning. Me and my friend have been working on this and Eleos put in some Console.WriteLine calls to check it out.
View attachment 20755
View attachment 20756

Running ServUO, I see that it's spawning loot on creation:
View attachment 20757
So I'm not sure why he you are saying it's not implemented by anything. It's calling BaseCreature::OnCreate.

Thoughts?

Also I generated a unicorn and then killed it. It appeared to call GenerateLoot twice.
View attachment 20758
The mysteries continue.... Looking at a unicorn, after the OnCreate GenerateLoot is called, the unicorn has no gold and no items. Then when it calls GenerateLoot again after their death, it adds the gold and items.

View attachment 20764
Above the red bar is when the unicorn was created. Below the red bar is when the unicorn was killed. Nothing on them before adding loot.


That's after putting this code in the Unicorn's GenerateLoot:

View attachment 20763

There is quite literally no implementation that references the LootStage.Spawning value, therefore, it is not implemented.
 
The mysteries continue.... Looking at a unicorn, after the OnCreate GenerateLoot is called, the unicorn has no gold and no items. Then when it calls GenerateLoot again after their death, it adds the gold and items.
LootStage.Spawning gonna spawn loot only if one of the LootPackEntry will have property AtSpawnTime = true; But by default all LootPack no have these values. Example:
C#:
        public static readonly LootPack LootMeager =
            new LootPack(
                new[]
                {
                    //first argument - it's AtSpawnTime property.
                    new LootPackEntry(false, true, Gold, 100.00, "4d10+40"),
                    new LootPackEntry(false, false, MagicItemsMeagerType1, 20.40, 1, 2, 0, 50, true),
                    new LootPackEntry(false, false, MagicItemsMeagerType2, 10.20, 1, 5, 0, 100, true),
                    new LootPackEntry(false, false, Instruments, 0.10, 1)
                });
So method CanGenerate just will skip generation until creature won't be death where its LootStage will change to LootStage.Death in next generation.
LootPack.cs
C#:
        public bool CanGenerate(LootStage stage, bool hasBeenStolenFrom)
        {
            switch (stage)
            {
                case LootStage.Spawning:
                    if (!AtSpawnTime)
                        return false;
                    break;
                case LootStage.Stolen:
                    if (!OnStolen)
                        return false;
                    break;
                case LootStage.Death:
                    if (OnStolen && hasBeenStolenFrom)
                        return false;
                    break;
            }

            return true;
        }
 
Back