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,257 +1,260 @@
using System;
using Server.Network;
using Server.Factions;
using Server.Items;
using Server.Targeting;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
using Server.Targeting;
namespace Server.Spells.Seventh
{
public class GateTravelSpell : MagerySpell
{
private static SpellInfo m_Info = new SpellInfo(
"Gate Travel", "Vas Rel Por",
263,
9032,
Reagent.BlackPearl,
Reagent.MandrakeRoot,
Reagent.SulfurousAsh
);
public class GateTravelSpell : MagerySpell
{
private static SpellInfo m_Info = new SpellInfo(
"Gate Travel", "Vas Rel Por",
263,
9032,
Reagent.BlackPearl,
Reagent.MandrakeRoot,
Reagent.SulfurousAsh
);
public override SpellCircle Circle => SpellCircle.Seventh;
private RunebookEntry m_Entry;
private RunebookEntry m_Entry;
public GateTravelSpell(Mobile caster, Item scroll) : this(caster, scroll, null)
{
}
public GateTravelSpell( Mobile caster, Item scroll ) : this( caster, scroll, null )
{
}
public GateTravelSpell(Mobile caster, Item scroll, RunebookEntry entry) : base(caster, scroll, m_Info)
{
m_Entry = entry;
}
public GateTravelSpell( Mobile caster, Item scroll, RunebookEntry entry ) : base( caster, scroll, m_Info )
{
m_Entry = entry;
}
public override SpellCircle Circle => SpellCircle.Seventh;
public override void OnCast()
{
if ( m_Entry == null )
Caster.Target = new InternalTarget( this );
else
Effect( m_Entry.Location, m_Entry.Map, true );
}
public override void OnCast()
{
if (m_Entry == null)
Caster.Target = new InternalTarget(this);
else
Effect(m_Entry.Location, m_Entry.Map, true);
}
public override bool CheckCast()
{
if ( Factions.Sigil.ExistsOn( Caster ) )
{
Caster.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
return false;
}
public override bool CheckCast()
{
if (Sigil.ExistsOn(Caster))
{
Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
return false;
}
if ( Caster.Criminal )
{
Caster.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
return false;
}
if ( SpellHelper.CheckCombat( Caster ) )
{
Caster.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
return false;
}
if (Caster.Criminal)
{
Caster.SendLocalizedMessage(1005561, "", 0x22); // Thou'rt a criminal and cannot escape so easily.
return false;
}
return SpellHelper.CheckTravel( Caster, TravelCheckType.GateFrom );
}
if (SpellHelper.CheckCombat(Caster))
{
Caster.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
return false;
}
private bool GateExistsAt(Map map, Point3D loc )
{
bool _gateFound = false;
return SpellHelper.CheckTravel(Caster, TravelCheckType.GateFrom);
}
IPooledEnumerable<Item> eable = map.GetItemsInRange( loc, 0 );
foreach ( Item item in eable )
{
if ( item is Moongate || item is PublicMoongate )
{
_gateFound = true;
break;
}
}
eable.Free();
private bool GateExistsAt(Map map, Point3D loc)
{
bool _gateFound = false;
return _gateFound;
}
IPooledEnumerable<Item> eable = map.GetItemsInRange(loc, 0);
foreach (Item item in eable)
if (item is Moongate || item is PublicMoongate)
{
_gateFound = true;
break;
}
public void Effect( Point3D loc, Map map, bool checkMulti )
{
if ( Factions.Sigil.ExistsOn( Caster ) )
{
Caster.SendLocalizedMessage( 1061632 ); // You can't do that while carrying the sigil.
}
else if ( map == null || (!Core.AOS && Caster.Map != map) )
{
Caster.SendLocalizedMessage( 1005570 ); // You can not gate to another facet.
}
else if ( !SpellHelper.CheckTravel( Caster, TravelCheckType.GateFrom ) )
{
}
else if ( !SpellHelper.CheckTravel( Caster, map, loc, TravelCheckType.GateTo ) )
{
}
else if ( map == Map.Felucca && Caster is PlayerMobile && ((PlayerMobile)Caster).Young )
{
Caster.SendLocalizedMessage( 1049543 ); // You decide against traveling to Felucca while you are still young.
}
else if ( Caster.Kills >= 5 && map != Map.Felucca )
{
Caster.SendLocalizedMessage( 1019004 ); // You are not allowed to travel there.
}
else if ( Caster.Criminal )
{
Caster.SendLocalizedMessage( 1005561, "", 0x22 ); // Thou'rt a criminal and cannot escape so easily.
}
else if ( SpellHelper.CheckCombat( Caster ) )
{
Caster.SendLocalizedMessage( 1005564, "", 0x22 ); // Wouldst thou flee during the heat of battle??
}
else if ( !map.CanSpawnMobile( loc.X, loc.Y, loc.Z ) )
{
Caster.SendLocalizedMessage( 501942 ); // That location is blocked.
}
else if ( (checkMulti && SpellHelper.CheckMulti( loc, map )) )
{
Caster.SendLocalizedMessage( 501942 ); // That location is blocked.
}
else if ( Core.SE && ( GateExistsAt( map, loc ) || GateExistsAt( Caster.Map, Caster.Location ) ) ) // SE restricted stacking gates
{
Caster.SendLocalizedMessage( 1071242 ); // There is already a gate there.
}
else if ( CheckSequence() )
{
Caster.SendLocalizedMessage( 501024 ); // You open a magical gate to another location
eable.Free();
Effects.PlaySound( Caster.Location, Caster.Map, 0x20E );
return _gateFound;
}
InternalItem firstGate = new InternalItem( loc, map );
firstGate.MoveToWorld( Caster.Location, Caster.Map );
public void Effect(Point3D loc, Map map, bool checkMulti)
{
if (Sigil.ExistsOn(Caster))
{
Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
}
else if (map == null || !Core.AOS && Caster.Map != map)
{
Caster.SendLocalizedMessage(1005570); // You can not gate to another facet.
}
else if (!SpellHelper.CheckTravel(Caster, TravelCheckType.GateFrom))
{
}
else if (!SpellHelper.CheckTravel(Caster, map, loc, TravelCheckType.GateTo))
{
}
else if (map == Map.Felucca && Caster is PlayerMobile && ((PlayerMobile)Caster).Young)
{
Caster.SendLocalizedMessage(1049543); // You decide against traveling to Felucca while you are still young.
}
else if (Caster.Kills >= 5 && map != Map.Felucca)
{
Caster.SendLocalizedMessage(1019004); // You are not allowed to travel there.
}
else if (Caster.Criminal)
{
Caster.SendLocalizedMessage(1005561, "", 0x22); // Thou'rt a criminal and cannot escape so easily.
}
else if (SpellHelper.CheckCombat(Caster))
{
Caster.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
}
else if (!map.CanSpawnMobile(loc.X, loc.Y, loc.Z))
{
Caster.SendLocalizedMessage(501942); // That location is blocked.
}
else if (checkMulti && SpellHelper.CheckMulti(loc, map))
{
Caster.SendLocalizedMessage(501942); // That location is blocked.
}
else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location))
) // SE restricted stacking gates
{
Caster.SendLocalizedMessage(1071242); // There is already a gate there.
}
else if (CheckSequence())
{
Caster.SendLocalizedMessage(501024); // You open a magical gate to another location
Effects.PlaySound( loc, map, 0x20E );
Effects.PlaySound(Caster.Location, Caster.Map, 0x20E);
InternalItem secondGate = new InternalItem( Caster.Location, Caster.Map );
secondGate.MoveToWorld( loc, map );
}
InternalItem firstGate = new InternalItem(loc, map);
firstGate.MoveToWorld(Caster.Location, Caster.Map);
FinishSequence();
}
Effects.PlaySound(loc, map, 0x20E);
[DispellableField]
private class InternalItem : Moongate
{
public override bool ShowFeluccaWarning => Core.AOS;
InternalItem secondGate = new InternalItem(Caster.Location, Caster.Map);
secondGate.MoveToWorld(loc, map);
}
public InternalItem( Point3D target, Map map ) : base( target, map )
{
Map = map;
FinishSequence();
}
if ( ShowFeluccaWarning && map == Map.Felucca )
ItemID = 0xDDA;
[DispellableField]
private class InternalItem : Moongate
{
public InternalItem(Point3D target, Map map) : base(target, map)
{
Map = map;
Dispellable = true;
if (ShowFeluccaWarning && map == Map.Felucca)
ItemID = 0xDDA;
InternalTimer t = new InternalTimer( this );
t.Start();
}
Dispellable = true;
public InternalItem( Serial serial ) : base( serial )
{
}
InternalTimer t = new InternalTimer(this);
t.Start();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
}
public InternalItem(Serial serial) : base(serial)
{
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override bool ShowFeluccaWarning => Core.AOS;
Delete();
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
}
private class InternalTimer : Timer
{
private Item m_Item;
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
public InternalTimer( Item item ) : base( TimeSpan.FromSeconds( 30.0 ) )
{
Priority = TimerPriority.OneSecond;
m_Item = item;
}
Delete();
}
protected override void OnTick()
{
m_Item.Delete();
}
}
}
private class InternalTimer : Timer
{
private Item m_Item;
private class InternalTarget : Target
{
private GateTravelSpell m_Owner;
public InternalTimer(Item item) : base(TimeSpan.FromSeconds(30.0))
{
Priority = TimerPriority.OneSecond;
m_Item = item;
}
public InternalTarget( GateTravelSpell owner ) : base( 12, false, TargetFlags.None )
{
m_Owner = owner;
protected override void OnTick()
{
m_Item.Delete();
}
}
}
owner.Caster.LocalOverheadMessage( MessageType.Regular, 0x3B2, 501029 ); // Select Marked item.
}
private class InternalTarget : Target
{
private GateTravelSpell m_Owner;
protected override void OnTarget( Mobile from, object o )
{
if ( o is RecallRune )
{
RecallRune rune = (RecallRune)o;
public InternalTarget(GateTravelSpell owner) : base(12, false, TargetFlags.None)
{
m_Owner = owner;
if ( rune.Marked )
m_Owner.Effect( rune.Target, rune.TargetMap, true );
else
from.SendLocalizedMessage( 501803 ); // That rune is not yet marked.
}
else if ( o is Runebook )
{
RunebookEntry e = ((Runebook)o).Default;
owner.Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501029); // Select Marked item.
}
if ( e != null )
m_Owner.Effect( e.Location, e.Map, true );
else
from.SendLocalizedMessage( 502354 ); // Target is not marked.
}
/*else if ( o is Key && ((Key)o).KeyValue != 0 && ((Key)o).Link is BaseBoat )
{
BaseBoat boat = ((Key)o).Link as BaseBoat;
protected override void OnTarget(Mobile from, object o)
{
if (o is RecallRune)
{
RecallRune rune = (RecallRune)o;
if ( !boat.Deleted && boat.CheckKey( ((Key)o).KeyValue ) )
m_Owner.Effect( boat.GetMarkedLocation(), boat.Map, false );
else
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object.
}*/
else if ( o is HouseRaffleDeed && ((HouseRaffleDeed)o).ValidLocation() )
{
HouseRaffleDeed deed = (HouseRaffleDeed)o;
if (rune.Marked)
m_Owner.Effect(rune.Target, rune.TargetMap, true);
else
from.SendLocalizedMessage(501803); // That rune is not yet marked.
}
else if (o is Runebook)
{
RunebookEntry e = ((Runebook)o).Default;
m_Owner.Effect( deed.PlotLocation, deed.PlotFacet, true );
}
else
{
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object.
}
}
if (e != null)
m_Owner.Effect(e.Location, e.Map, true);
else
from.SendLocalizedMessage(502354); // Target is not marked.
}
/*else if ( o is Key && ((Key)o).KeyValue != 0 && ((Key)o).Link is BaseBoat )
{
BaseBoat boat = ((Key)o).Link as BaseBoat;
protected override void OnNonlocalTarget( Mobile from, object o )
{
}
if ( !boat.Deleted && boat.CheckKey( ((Key)o).KeyValue ) )
m_Owner.Effect( boat.GetMarkedLocation(), boat.Map, false );
else
from.Send( new MessageLocalized( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name, "" ) ); // I can not gate travel from that object.
}*/
else if (o is HouseRaffleDeed && ((HouseRaffleDeed)o).ValidLocation())
{
HouseRaffleDeed deed = (HouseRaffleDeed)o;
protected override void OnTargetFinish( Mobile from )
{
m_Owner.FinishSequence();
}
}
}
}
m_Owner.Effect(deed.PlotLocation, deed.PlotFacet, true);
}
else
{
from.Send(new MessageLocalized(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 501030, from.Name,
"")); // I can not gate travel from that object.
}
}
protected override void OnNonlocalTarget(Mobile from, object o)
{
}
protected override void OnTargetFinish(Mobile from)
{
m_Owner.FinishSequence();
}
}
}
}