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,52 +1,59 @@
using System;
namespace Server {
public sealed class BloodRose : PowerFactionItem {
public override string DefaultName => "blood rose";
namespace Server
{
public sealed class BloodRose : PowerFactionItem
{
public BloodRose()
: base(Utility.RandomList(6378, 9035))
{
Hue = 2118;
}
public BloodRose()
: base( Utility.RandomList( 6378, 9035 ) ) {
Hue = 2118;
}
public BloodRose(Serial serial)
: base(serial)
{
}
public BloodRose( Serial serial )
: base( serial ) {
}
public override string DefaultName => "blood rose";
public override bool Use( Mobile from ) {
if ( from.GetStatMod( "blood-rose" ) == null ) {
from.PlaySound( Utility.Random( 0x3A, 3 ) );
public override bool Use(Mobile from)
{
if (from.GetStatMod("blood-rose") == null)
{
from.PlaySound(Utility.Random(0x3A, 3));
if ( from.Body.IsHuman && !from.Mounted ) {
from.Animate( 34, 5, 1, true, false, 0 );
}
if (from.Body.IsHuman && !from.Mounted) from.Animate(34, 5, 1, true, false, 0);
int amount = Utility.Dice( 3, 3, 3 );
int time = Utility.RandomMinMax( 5, 30 );
int amount = Utility.Dice(3, 3, 3);
int time = Utility.RandomMinMax(5, 30);
from.FixedParticles( 0x373A, 10, 15, 5018, EffectLayer.Waist );
from.FixedParticles(0x373A, 10, 15, 5018, EffectLayer.Waist);
from.PlaySound( 0x1EE );
from.AddStatMod( new StatMod( StatType.All, "blood-rose", amount, TimeSpan.FromMinutes( time ) ) );
from.PlaySound(0x1EE);
from.AddStatMod(new StatMod(StatType.All, "blood-rose", amount, TimeSpan.FromMinutes(time)));
return true;
}
return true;
}
from.SendLocalizedMessage( 1062927 ); // You have eaten one of these recently and eating another would provide no benefit.
from.SendLocalizedMessage(
1062927); // You have eaten one of these recently and eating another would provide no benefit.
return false;
}
return false;
}
public override void Serialize( GenericWriter writer ) {
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt( ( int ) 0 ); // version
}
writer.WriteEncodedInt(0); // version
}
public override void Deserialize( GenericReader reader ) {
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
}
int version = reader.ReadEncodedInt();
}
}
}

View file

@ -1,62 +1,67 @@
using System;
namespace Server {
public sealed class ClarityPotion : PowerFactionItem {
public override string DefaultName => "clarity potion";
namespace Server
{
public sealed class ClarityPotion : PowerFactionItem
{
public ClarityPotion()
: base(3628)
{
Hue = 1154;
}
public ClarityPotion()
: base( 3628 ) {
Hue = 1154;
}
public ClarityPotion(Serial serial)
: base(serial)
{
}
public ClarityPotion( Serial serial )
: base( serial ) {
}
public override string DefaultName => "clarity potion";
public override bool Use( Mobile from ) {
if ( from.BeginAction( typeof( ClarityPotion ) ) ) {
int amount = Utility.Dice( 3, 3, 3 );
int time = Utility.RandomMinMax( 5, 30 );
public override bool Use(Mobile from)
{
if (from.BeginAction(typeof(ClarityPotion)))
{
int amount = Utility.Dice(3, 3, 3);
int time = Utility.RandomMinMax(5, 30);
from.PlaySound( 0x2D6 );
from.PlaySound(0x2D6);
if ( from.Body.IsHuman ) {
from.Animate( 34, 5, 1, true, false, 0 );
}
if (from.Body.IsHuman) from.Animate(34, 5, 1, true, false, 0);
from.FixedParticles( 0x375A, 10, 15, 5011, EffectLayer.Head );
from.PlaySound( 0x1EB );
from.FixedParticles(0x375A, 10, 15, 5011, EffectLayer.Head);
from.PlaySound(0x1EB);
StatMod mod = from.GetStatMod( "Concussion" );
StatMod mod = from.GetStatMod("Concussion");
if ( mod != null ) {
from.RemoveStatMod( "Concussion" );
from.Mana -= mod.Offset;
}
if (mod != null)
{
from.RemoveStatMod("Concussion");
from.Mana -= mod.Offset;
}
from.PlaySound( 0x1EE );
from.AddStatMod( new StatMod( StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes( time ) ) );
from.PlaySound(0x1EE);
from.AddStatMod(new StatMod(StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes(time)));
Timer.DelayCall( TimeSpan.FromMinutes( time ), delegate {
from.EndAction( typeof( ClarityPotion ) );
} );
Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction(typeof(ClarityPotion)); });
return true;
}
return true;
}
return false;
}
return false;
}
public override void Serialize( GenericWriter writer ) {
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt( ( int ) 0 ); // version
}
writer.WriteEncodedInt(0); // version
}
public override void Deserialize( GenericReader reader ) {
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
}
int version = reader.ReadEncodedInt();
}
}
}

View file

@ -1,42 +1,51 @@
using Server.Factions;
using Server.Network;
namespace Server {
public sealed class GemOfEmpowerment : PowerFactionItem {
public override string DefaultName => "gem of empowerment";
namespace Server
{
public sealed class GemOfEmpowerment : PowerFactionItem
{
public GemOfEmpowerment()
: base(7955)
{
Hue = 1154;
}
public GemOfEmpowerment()
: base( 7955 ) {
Hue = 1154;
}
public GemOfEmpowerment(Serial serial)
: base(serial)
{
}
public GemOfEmpowerment( Serial serial )
: base( serial ) {
}
public override string DefaultName => "gem of empowerment";
public override bool Use( Mobile from ) {
if ( Faction.ClearSkillLoss( from ) ) {
from.LocalOverheadMessage( Network.MessageType.Regular, 2219, false, "The gem shatters as you invoke its power." );
from.PlaySound( 909 );
public override bool Use(Mobile from)
{
if (Faction.ClearSkillLoss(from))
{
from.LocalOverheadMessage(MessageType.Regular, 2219, false, "The gem shatters as you invoke its power.");
from.PlaySound(909);
from.FixedEffect( 0x373A, 10, 30 );
from.PlaySound( 0x209 );
from.FixedEffect(0x373A, 10, 30);
from.PlaySound(0x209);
return true;
}
return true;
}
return false;
}
return false;
}
public override void Serialize( GenericWriter writer ) {
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt( ( int ) 0 ); // version
}
writer.WriteEncodedInt(0); // version
}
public override void Deserialize( GenericReader reader ) {
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
int version = reader.ReadEncodedInt();
}
}
}

View file

@ -1,151 +1,186 @@
using System;
using Server.Mobiles;
using Server.Factions;
using System.IO;
using Server.Factions;
using Server.Mobiles;
using Server.Network;
namespace Server {
public abstract class PowerFactionItem : Item {
public abstract bool Use( Mobile mob );
namespace Server
{
public abstract class PowerFactionItem : Item
{
private static WeightedItem[] _items =
{
new WeightedItem(30, typeof(GemOfEmpowerment)),
new WeightedItem(25, typeof(BloodRose)),
new WeightedItem(20, typeof(ClarityPotion)),
new WeightedItem(15, typeof(UrnOfAscension)),
new WeightedItem(10, typeof(StormsEye))
};
private sealed class DestructionTimer : Timer {
private Mobile _mobile;
public PowerFactionItem(int itemId)
: base(itemId)
{
}
private bool _screamed;
public PowerFactionItem(Serial serial)
: base(serial)
{
}
public DestructionTimer( Mobile mob )
: base( TimeSpan.FromSeconds( 5 ), TimeSpan.FromSeconds( 0.1 ), 10 ) {
_mobile = mob;
}
public abstract bool Use(Mobile mob);
protected override void OnTick() {
if ( _mobile.Alive ) {
if ( !_screamed ) {
_screamed = true;
public static void CheckSpawn(Mobile killer, Mobile victim)
{
if (killer != null && victim != null)
{
PlayerState ps = PlayerState.Find(victim);
_mobile.PlaySound( _mobile.Female ? 814 : 1088 );
_mobile.PublicOverheadMessage( Network.MessageType.Regular, 2118, false, "Aaaaah!" );
}
if (ps != null)
{
int chance = ps.Rank.Rank;
_mobile.Damage( Utility.Dice( 2, 6, 0 ) );
}
}
}
if (chance > Utility.Random(100))
{
int weight = 0;
private sealed class WeightedItem {
public int Weight { get; }
foreach (WeightedItem item in _items) weight += item.Weight;
public Type Type { get; }
weight = Utility.Random(weight);
public WeightedItem( int weight, Type type ) {
Weight = weight;
Type = type;
}
foreach (WeightedItem item in _items)
{
if (weight < item.Weight)
{
Item obj = item.Construct();
public Item Construct() {
return Activator.CreateInstance( Type ) as Item;
}
}
if (obj != null)
{
killer.AddToBackpack(obj);
private static WeightedItem[] _items = {
new WeightedItem( 30, typeof( GemOfEmpowerment ) ),
new WeightedItem( 25, typeof( BloodRose ) ),
new WeightedItem( 20, typeof( ClarityPotion ) ),
new WeightedItem( 15, typeof( UrnOfAscension ) ),
new WeightedItem( 10, typeof( StormsEye ) )
};
killer.SendSound(1470);
killer.LocalOverheadMessage(
MessageType.Regular, 2119, false,
"You notice a strange item on the corpse, and decide to pick it up."
);
public static void CheckSpawn( Mobile killer, Mobile victim ) {
if ( killer != null && victim != null ) {
PlayerState ps = PlayerState.Find( victim );
try
{
using (StreamWriter op = new StreamWriter("faction-power-items.log", true))
{
op.WriteLine("{0}\t{1}\t{2}\t{3}", DateTime.UtcNow, killer, victim, obj);
}
}
catch
{
}
}
if ( ps != null ) {
int chance = ps.Rank.Rank;
break;
}
if ( chance > Utility.Random( 100 ) ) {
int weight = 0;
weight -= item.Weight;
}
}
}
}
}
foreach ( WeightedItem item in _items ) {
weight += item.Weight;
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
}
else if (from is PlayerMobile mobile && mobile.DuelContext != null)
{
mobile.SendMessage("You can't use that.");
}
else if (Faction.Find(from) == null)
{
from.LocalOverheadMessage(MessageType.Regular, 2119, false,
"The object vanishes from your hands as you touch it.");
weight = Utility.Random( weight );
Timer.DelayCall(TimeSpan.FromSeconds(1.0),
delegate
{
from.LocalOverheadMessage(MessageType.Regular, 2118, false,
"You feel a strange tingling sensation throughout your body.");
});
foreach ( WeightedItem item in _items )
{
if ( weight < item.Weight ) {
Item obj = item.Construct();
Timer.DelayCall(TimeSpan.FromSeconds(4.0),
delegate { from.LocalOverheadMessage(MessageType.Regular, 2118, false, "Your skin begins to burn."); });
if ( obj != null ) {
killer.AddToBackpack( obj );
new DestructionTimer(from).Start();
Delete();
killer.SendSound( 1470 );
killer.LocalOverheadMessage(
Network.MessageType.Regular, 2119, false,
"You notice a strange item on the corpse, and decide to pick it up."
);
//from.SendMessage( "You must be in a faction to use this item." );
}
else if (Use(from))
{
from.RevealingAction();
Consume();
}
}
try {
using ( StreamWriter op = new StreamWriter( "faction-power-items.log", true ) ) {
op.WriteLine( "{0}\t{1}\t{2}\t{3}", DateTime.UtcNow, killer, victim, obj );
}
} catch {
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
break;
}
writer.WriteEncodedInt(0); // version
}
weight -= item.Weight;
}
}
}
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
public override void OnDoubleClick( Mobile from ) {
if ( !IsChildOf( from.Backpack ) ) {
from.SendLocalizedMessage( 1042038 ); // You must have the object in your backpack to use it.
} else if ( from is PlayerMobile mobile && mobile.DuelContext != null ) {
mobile.SendMessage( "You can't use that." );
} else if ( Faction.Find( from ) == null ) {
from.LocalOverheadMessage( Network.MessageType.Regular, 2119, false, "The object vanishes from your hands as you touch it." );
int version = reader.ReadEncodedInt();
}
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate {
from.LocalOverheadMessage( Network.MessageType.Regular, 2118, false, "You feel a strange tingling sensation throughout your body." );
} );
private sealed class DestructionTimer : Timer
{
private Mobile _mobile;
Timer.DelayCall( TimeSpan.FromSeconds( 4.0 ), delegate {
from.LocalOverheadMessage( Network.MessageType.Regular, 2118, false, "Your skin begins to burn." );
} );
private bool _screamed;
new DestructionTimer( from ).Start();
Delete();
public DestructionTimer(Mobile mob)
: base(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(0.1), 10)
{
_mobile = mob;
}
//from.SendMessage( "You must be in a faction to use this item." );
} else if ( Use( from ) ) {
from.RevealingAction();
Consume();
}
}
protected override void OnTick()
{
if (_mobile.Alive)
{
if (!_screamed)
{
_screamed = true;
public PowerFactionItem( int itemId )
: base( itemId ) {
}
_mobile.PlaySound(_mobile.Female ? 814 : 1088);
_mobile.PublicOverheadMessage(MessageType.Regular, 2118, false, "Aaaaah!");
}
public PowerFactionItem( Serial serial )
: base( serial ) {
}
_mobile.Damage(Utility.Dice(2, 6, 0));
}
}
}
public override void Serialize( GenericWriter writer ) {
base.Serialize( writer );
private sealed class WeightedItem
{
public WeightedItem(int weight, Type type)
{
Weight = weight;
Type = type;
}
writer.WriteEncodedInt( ( int ) 0 ); // version
}
public int Weight{ get; }
public override void Deserialize( GenericReader reader ) {
base.Deserialize( reader );
public Type Type{ get; }
int version = reader.ReadEncodedInt();
}
}
}
public Item Construct()
{
return Activator.CreateInstance(Type) as Item;
}
}
}
}

View file

@ -1,106 +1,115 @@
using System;
using System.Collections.Generic;
using Server.Spells;
using Server.Factions;
using Server.Spells;
using Server.Targeting;
namespace Server {
public sealed class StormsEye : PowerFactionItem {
public override string DefaultName => "storms eye";
namespace Server
{
public sealed class StormsEye : PowerFactionItem
{
public StormsEye()
: base(3967)
{
Hue = 1165;
}
public StormsEye()
: base( 3967 ) {
Hue = 1165;
}
public StormsEye(Serial serial)
: base(serial)
{
}
public StormsEye( Serial serial )
: base( serial ) {
}
public override string DefaultName => "storms eye";
public override bool Use( Mobile user ) {
if ( Movable ) {
user.BeginTarget( 12, true, Targeting.TargetFlags.None, delegate( Mobile from, object obj ) {
if ( Movable && !Deleted ) {
if ( obj is IPoint3D pt ) {
SpellHelper.GetSurfaceTop( ref pt );
public override bool Use(Mobile user)
{
if (Movable)
user.BeginTarget(12, true, TargetFlags.None, delegate(Mobile from, object obj)
{
if (Movable && !Deleted)
if (obj is IPoint3D pt)
{
SpellHelper.GetSurfaceTop(ref pt);
Point3D origin = new Point3D( pt );
Map facet = from.Map;
Point3D origin = new Point3D(pt);
Map facet = from.Map;
if ( facet != null && facet.CanFit( pt.X, pt.Y, pt.Z, 16, false, false, true ) ) {
Movable = false;
if (facet != null && facet.CanFit(pt.X, pt.Y, pt.Z, 16, false, false, true))
{
Movable = false;
Effects.SendMovingEffect(
from, new Entity( Serial.Zero, origin, facet ),
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1, 0
);
Effects.SendMovingEffect(
from, new Entity(Serial.Zero, origin, facet),
ItemID & 0x3FFF, 7, 0, false, false, Hue - 1, 0
);
Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), delegate {
Delete();
Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate
{
Delete();
Effects.PlaySound( origin, facet, 530 );
Effects.PlaySound( origin, facet, 263 );
Effects.PlaySound(origin, facet, 530);
Effects.PlaySound(origin, facet, 263);
Effects.SendLocationEffect(
origin, facet,
14284, 96, 1, 0, 2
);
Effects.SendLocationEffect(
origin, facet,
14284, 96, 1, 0, 2
);
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), delegate {
List<Mobile> targets = new List<Mobile>();
Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate
{
List<Mobile> targets = new List<Mobile>();
foreach ( Mobile mob in facet.GetMobilesInRange( origin, 12 ) ) {
if ( from.CanBeHarmful( mob, false ) && mob.InLOS( new Point3D( origin, origin.Z + 1 ) ) ) {
if ( Faction.Find( mob ) != null ) {
targets.Add( mob );
}
}
}
foreach (Mobile mob in facet.GetMobilesInRange(origin, 12))
if (from.CanBeHarmful(mob, false) &&
mob.InLOS(new Point3D(origin, origin.Z + 1)))
if (Faction.Find(mob) != null)
targets.Add(mob);
foreach ( Mobile mob in targets ) {
int damage = ( mob.Hits * 6 ) / 10;
foreach (Mobile mob in targets)
{
int damage = mob.Hits * 6 / 10;
if ( !mob.Player && damage < 10 ) {
damage = 10;
} else if ( damage > 75 ) {
damage = 75;
}
if (!mob.Player && damage < 10)
damage = 10;
else if (damage > 75) damage = 75;
Effects.SendMovingEffect(
new Entity( Serial.Zero, new Point3D( origin, origin.Z + 4 ), facet ), mob,
14068, 1, 32, false, false, 1111, 2
);
Effects.SendMovingEffect(
new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob,
14068, 1, 32, false, false, 1111, 2
);
from.DoHarmful( mob );
from.DoHarmful(mob);
SpellHelper.Damage( TimeSpan.FromSeconds( 0.50 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
SpellHelper.Damage( TimeSpan.FromSeconds( 0.70 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
SpellHelper.Damage( TimeSpan.FromSeconds( 1.00 ), mob, from, damage / 3, 0, 0, 0, 0, 100 );
SpellHelper.Damage(TimeSpan.FromSeconds(0.50), mob, from, damage / 3, 0, 0, 0, 0,
100);
SpellHelper.Damage(TimeSpan.FromSeconds(0.70), mob, from, damage / 3, 0, 0, 0, 0,
100);
SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3, 0, 0, 0, 0,
100);
Timer.DelayCall( TimeSpan.FromSeconds( 0.50 ), delegate {
mob.PlaySound( 0x1FB );
} );
}
} );
} );
}
}
}
} );
}
Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); });
}
});
});
}
}
});
return false;
}
return false;
}
public override void Serialize( GenericWriter writer ) {
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt( ( int ) 0 ); // version
}
writer.WriteEncodedInt(0); // version
}
public override void Deserialize( GenericReader reader ) {
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
}
int version = reader.ReadEncodedInt();
}
}
}

View file

@ -1,61 +1,69 @@
using Server.Factions;
using Server.Gumps;
using Server.Multis;
using Server.Factions;
using Server.Network;
namespace Server {
public sealed class UrnOfAscension : PowerFactionItem {
public override string DefaultName => "urn of ascension";
namespace Server
{
public sealed class UrnOfAscension : PowerFactionItem
{
public UrnOfAscension()
: base(9246)
{
}
public UrnOfAscension()
: base( 9246 ) {
}
public UrnOfAscension(Serial serial)
: base(serial)
{
}
public UrnOfAscension( Serial serial )
: base( serial ) {
}
public override string DefaultName => "urn of ascension";
public override bool Use( Mobile from ) {
Faction ourFaction = Faction.Find( from );
public override bool Use(Mobile from)
{
Faction ourFaction = Faction.Find(from);
bool used = false;
bool used = false;
foreach ( Mobile mob in from.GetMobilesInRange( 8 ) ) {
if ( mob.Player && !mob.Alive && from.InLOS( mob ) ) {
if ( Faction.Find( mob ) != ourFaction ) {
continue;
}
foreach (Mobile mob in from.GetMobilesInRange(8))
if (mob.Player && !mob.Alive && from.InLOS(mob))
{
if (Faction.Find(mob) != ourFaction) continue;
BaseHouse house = BaseHouse.FindHouseAt( mob );
BaseHouse house = BaseHouse.FindHouseAt(mob);
if ( house == null || ( house.IsFriend( from ) || house.IsFriend( mob ) ) ) {
Faction.ClearSkillLoss( mob );
if (house == null || house.IsFriend(from) || house.IsFriend(mob))
{
Faction.ClearSkillLoss(mob);
mob.SendGump( new ResurrectGump( mob, from, ResurrectMessage.Generic ) );
used = true;
}
}
}
mob.SendGump(new ResurrectGump(mob, from, ResurrectMessage.Generic));
used = true;
}
}
if ( used ) {
from.LocalOverheadMessage( Network.MessageType.Regular, 2219, false, "The urn shatters as you invoke its power." );
from.PlaySound( 64 );
if (used)
{
from.LocalOverheadMessage(MessageType.Regular, 2219, false, "The urn shatters as you invoke its power.");
from.PlaySound(64);
Effects.PlaySound( from.Location, from.Map, 1481 );
}
Effects.PlaySound(from.Location, from.Map, 1481);
}
return used;
}
return used;
}
public override void Serialize( GenericWriter writer ) {
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.WriteEncodedInt( ( int ) 0 ); // version
}
writer.WriteEncodedInt(0); // version
}
public override void Deserialize( GenericReader reader ) {
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadEncodedInt();
}
}
int version = reader.ReadEncodedInt();
}
}
}