AdamD
Member
So back in 2014 I posted a thread here about client crashes on a non servuo shard I ran for a few years.
It got pretty bad and I never did find out what was causing it, it seemed to ruin a perfectly fun shard for many, including myself.
I thought I'd nailed it down to the guards I put in which would teleport in when vendors were attacked, but never looked into it further
So for the last few days I've been adding older scripts from my shard to the latest ServUO install, all was going ok, until I added the same code from the old shard, to the basevendor file, then I got a client crash, then another, then a few more.
I basically made vendors vulnerable, but gave them the isenemy chunk of code (I don't know the proper term) And also the ability to call a guard, using code copy/pasted from the barracoon champ.
So, can someone see anything obvious which might be causing it?
Meant to add, the crashing doesn't happen when the vendors are attacking, or if the guard is present
It usually happens when porting into a town, or logging in, in a vendor area/town.
It got pretty bad and I never did find out what was causing it, it seemed to ruin a perfectly fun shard for many, including myself.
I thought I'd nailed it down to the guards I put in which would teleport in when vendors were attacked, but never looked into it further
So for the last few days I've been adding older scripts from my shard to the latest ServUO install, all was going ok, until I added the same code from the old shard, to the basevendor file, then I got a client crash, then another, then a few more.
I basically made vendors vulnerable, but gave them the isenemy chunk of code (I don't know the proper term) And also the ability to call a guard, using code copy/pasted from the barracoon champ.
So, can someone see anything obvious which might be causing it?
Meant to add, the crashing doesn't happen when the vendors are attacking, or if the guard is present
It usually happens when porting into a town, or logging in, in a vendor area/town.
Code:
public override bool IsEnemy(Mobile m)
{
if (m is PlayerVendor || m is TownCrier || m is MonsterNestGoodEntity || m is BaseGuardian || m is AntiRMSGuard || m is BaseEnraged ) return false;
else if (m is PlayerMobile)
{
PlayerMobile pm = (PlayerMobile)m;
if (pm.Account.Username == "Xenomorph") return true;
if (!pm.Criminal && (pm.Kills < 6)) return false;
if (pm.BodyMod > 0) return false;
return true;
}
else if (m is BaseVendor)
{
BaseVendor pm = (BaseVendor)m;
if (pm.Controlled && !pm.Criminal) return false;
if (!pm.Controlled && pm.Criminal) return true;
if (pm.BodyMod > 0) return false;
return false;
}
else if (m is BaseGuardian)
{
BaseGuardian pm = (BaseGuardian)m;
if (!pm.Criminal && (pm.Kills == 0)) return false;
if (pm.BodyMod > 0) return false;
return true;
}
else if (m is BaseCreature)
{
BaseCreature pm = (BaseCreature)m;
if (pm.Controlled && !pm.Criminal) return false;
if (!pm.Controlled && pm.Criminal) return true;
if ((pm.FightMode == FightMode.Closest) || (pm.FightMode == FightMode.Weakest) || (pm.FightMode == FightMode.Strongest)) return true;
return false;
}
else return false;
//return true;
}
public override void OnKilledBy( Mobile mob )
{
bool chance = Utility.RandomBool();
if ( chance )
{
mob.Kills++;
mob.SendMessage( "You have been reported for a murder" );
}
base.OnKilledBy( mob );
}
public override void AlterMeleeDamageTo(Mobile to, ref int damage)
{
if (to.RawName == "RMS Carpathia")
damage *= 10;
}
public void SpawnRatmen(Mobile target)
{
Map map = this.Map;
if (map == null)
return;
int rats = 0;
foreach (Mobile m in this.GetMobilesInRange(20))
{
if (m is AntiRMSGuard)
++rats;
}
if (rats < 1)
{
PlaySound(0x3D);
int newRats = 1;
for (int i = 0; i < newRats; ++i)
{
BaseCreature rat;
rat = new AntiRMSGuard();
rat.Team = this.Team;
bool validLocation = false;
Point3D loc = this.Location;
for (int j = 0; !validLocation && j < 10; ++j)
{
int x = X + Utility.Random(7) - 3;
int y = Y + Utility.Random(7) - 3;
int z = map.GetAverageZ(x, y);
if (validLocation = map.CanFit(x, y, this.Z, 16, false, false))
loc = new Point3D(x, y, Z);
else if (validLocation = map.CanFit(x, y, z, 16, false, false))
loc = new Point3D(x, y, z);
}
rat.MoveToWorld(loc, map);
rat.Combatant = target;
}
}
}
public void DoSpecialAbility(Mobile target)
{
if (target == null || target.Deleted) //sanity
return;
if (0.1 >= Utility.RandomDouble()) // 20% chance to more ratmen
SpawnRatmen(target);
}
public override void OnGotMeleeAttack(Mobile attacker)
{
base.OnGotMeleeAttack(attacker);
attacker.Stam -= Utility.Random(5, 10);
attacker.Mana -= Utility.Random(5, 10);
DoSpecialAbility(attacker);
}
public override void OnGaveMeleeAttack(Mobile defender)
{
base.OnGaveMeleeAttack(defender);
defender.Stam -= Utility.Random(5, 10);
defender.Mana -= Utility.Random(5, 10);
}
public override bool ReacquireOnMovement { get { return true; } }