Diego
Member
Hi,
I modded the OnEnemy function of a particular guard adding this:
and this is the ForceMove function:
The problem is that when ForceMove() is executed the server crashes for this reason:
System.InvalidOperationException: Collection was modified: enumeration operation may not execute.
in System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
in System.Collections.Generic.List`1.Enumerator.MoveNextRare()
in System.Linq.Enumerable.WhereListIterator`1.MoveNext()
in System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
in Server.Mobiles.BaseAI.AcquireFocusMob(Int32 iRange, FightMode acqType, Boolean bPlayerOnly, Boolean bFacFriend, Boolean bFacFoe)
in Server.Mobiles.MageAI.DoActionWander()
in Server.Mobiles.BaseAI.AITimer.OnTick()
in Server.Timer.Slice() in C:\Users\Notebook\Documents\RunUO_Core\Server\Timer.cs:riga 387
in Server.Core.Main(String[] args) in C:\Users\Notebook\Documents\RunUO_Core\Server\Main.cs:riga 577
I modded the OnEnemy function of a particular guard adding this:
Code:
if( m_CityStone.Check(1) )
{
((BaseGuardian)this).ForceMove( m, "jail");
this.Say( "You're under arrest!" );
}
else if( m_CityStone.Check(2) )
{
((BaseGuardian)this).ForceMove( m, m_CityStone.Town.ToString() );
this.Say( "Stop!" );
}
else if( m_CityStone.Check(3) )
{
this.Say( "Die!" );
}
return true;
and this is the ForceMove function:
Code:
public void ForceMove( Mobile from, string where )
{
string name = where;
Map map;
for ( int i = 0; i < Map.AllMaps.Count; ++i )
{
map = Map.AllMaps[i];
if ( map.MapIndex == 0x7F || map.MapIndex == 0xFF )
continue;
if ( Insensitive.Equals( name, map.Name ) )
{
from.Map = map;
return;
}
}
Dictionary<string, Region> list = from.Map.Regions;
foreach( KeyValuePair<string, Region> kvp in list )
{
Region r = kvp.Value;
if ( Insensitive.Equals( r.Name, name ) )
{
from.Location = new Point3D( r.GoLocation );
return;
}
}
for( int i = 0; i < Map.AllMaps.Count; ++i )
{
Map m = Map.AllMaps[i];
if( m.MapIndex == 0x7F || m.MapIndex == 0xFF || from.Map == m )
continue;
foreach( Region r in m.Regions.Values )
{
if( Insensitive.Equals( r.Name, name ) )
{
from.MoveToWorld( r.GoLocation, m );
return;
}
}
}
}
The problem is that when ForceMove() is executed the server crashes for this reason:
System.InvalidOperationException: Collection was modified: enumeration operation may not execute.
in System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
in System.Collections.Generic.List`1.Enumerator.MoveNextRare()
in System.Linq.Enumerable.WhereListIterator`1.MoveNext()
in System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
in Server.Mobiles.BaseAI.AcquireFocusMob(Int32 iRange, FightMode acqType, Boolean bPlayerOnly, Boolean bFacFriend, Boolean bFacFoe)
in Server.Mobiles.MageAI.DoActionWander()
in Server.Mobiles.BaseAI.AITimer.OnTick()
in Server.Timer.Slice() in C:\Users\Notebook\Documents\RunUO_Core\Server\Timer.cs:riga 387
in Server.Core.Main(String[] args) in C:\Users\Notebook\Documents\RunUO_Core\Server\Main.cs:riga 577
Last edited: