Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -1,105 +1,103 @@
using System;
using Server.Misc;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
using Server.Regions;
namespace Server.SkillHandlers
{
public class Snooping
{
public static void Configure()
{
Container.SnoopHandler = Container_Snoop;
}
public class Snooping
{
public static void Configure()
{
Container.SnoopHandler = Container_Snoop;
}
public static bool CheckSnoopAllowed( Mobile from, Mobile to )
{
Map map = from.Map;
public static bool CheckSnoopAllowed(Mobile from, Mobile to)
{
Map map = from.Map;
if ( to.Player )
return from.CanBeHarmful( to, false, true ); // normal restrictions
if (to.Player)
return from.CanBeHarmful(to, false, true); // normal restrictions
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
return true; // felucca you can snoop anybody
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
return true; // felucca you can snoop anybody
GuardedRegion reg = (GuardedRegion) to.Region.GetRegion( typeof( GuardedRegion ) );
GuardedRegion reg = (GuardedRegion)to.Region.GetRegion(typeof(GuardedRegion));
if ( reg == null || reg.IsDisabled() )
return true; // not in town? we can snoop any npc
if (reg == null || reg.IsDisabled())
return true; // not in town? we can snoop any npc
BaseCreature cret = to as BaseCreature;
BaseCreature cret = to as BaseCreature;
if ( to.Body.IsHuman && (cret == null || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) )
return false; // in town we cannot snoop blue human npcs
if (to.Body.IsHuman && (cret == null || !cret.AlwaysAttackable && !cret.AlwaysMurderer))
return false; // in town we cannot snoop blue human npcs
return true;
}
return true;
}
public static void Container_Snoop( Container cont, Mobile from )
{
if ( from.AccessLevel > AccessLevel.Player || from.InRange( cont.GetWorldLocation(), 1 ) )
{
Mobile root = cont.RootParent as Mobile;
public static void Container_Snoop(Container cont, Mobile from)
{
if (from.AccessLevel > AccessLevel.Player || from.InRange(cont.GetWorldLocation(), 1))
{
Mobile root = cont.RootParent as Mobile;
if ( root != null && !root.Alive )
return;
if (root != null && !root.Alive)
return;
if ( root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player )
{
from.SendLocalizedMessage( 500209 ); // You can not peek into the container.
return;
}
if (root != null && root.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player)
{
from.SendLocalizedMessage(500209); // You can not peek into the container.
return;
}
if ( root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed( from, root ) )
{
from.SendLocalizedMessage( 1001018 ); // You cannot perform negative acts on your target.
return;
}
if (root != null && from.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root))
{
from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target.
return;
}
if ( root != null && from.AccessLevel == AccessLevel.Player && from.Skills[SkillName.Snooping].Value < Utility.Random( 100 ) )
{
Map map = from.Map;
if (root != null && from.AccessLevel == AccessLevel.Player &&
from.Skills[SkillName.Snooping].Value < Utility.Random(100))
{
Map map = from.Map;
if ( map != null )
{
string message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings.";
if (map != null)
{
string message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings.";
IPooledEnumerable<NetState> eable = map.GetClientsInRange( from.Location, 8 );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(from.Location, 8);
foreach ( NetState ns in eable )
{
if ( ns.Mobile != from )
ns.Mobile.SendMessage( message );
}
foreach (NetState ns in eable)
if (ns.Mobile != from)
ns.Mobile.SendMessage(message);
eable.Free();
}
}
eable.Free();
}
}
if ( from.AccessLevel == AccessLevel.Player )
Titles.AwardKarma( from, -4, true );
if (from.AccessLevel == AccessLevel.Player)
Titles.AwardKarma(from, -4, true);
if ( from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill( SkillName.Snooping, cont, 0.0, 100.0 ) )
{
if ( cont is TrappableContainer && ((TrappableContainer)cont).ExecuteTrap( from ) )
return;
if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0))
{
if (cont is TrappableContainer && ((TrappableContainer)cont).ExecuteTrap(from))
return;
cont.DisplayTo( from );
}
else
{
from.SendLocalizedMessage( 500210 ); // You failed to peek into the container.
cont.DisplayTo(from);
}
else
{
from.SendLocalizedMessage(500210); // You failed to peek into the container.
if ( from.Skills[SkillName.Hiding].Value / 2 < Utility.Random( 100 ) )
from.RevealingAction();
}
}
else
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
}
}
}
}
if (from.Skills[SkillName.Hiding].Value / 2 < Utility.Random(100))
from.RevealingAction();
}
}
else
{
from.SendLocalizedMessage(500446); // That is too far away.
}
}
}
}