/******************************************/ /* Created by Saint_C */ /* Original Purpose: To clone an */ /* AD&D Magic item I created */ /* Date Created: June 8th, 2004 15:03(pm) */ /* Updated: June 11th, 2004 16:00 (pm) */ /* Altered: June 15th, 2004 16:00 (pm) */ /******************************************/ /* Released to be used as an Autoequip */ /* Template others could use to create */ /* cursed type items. */ /******************************************/ using System; using System.Net; using System.Net.Sockets; using System.Collections; using Server; using Server.Items; using Server.Gumps; using Server.Spells; using Server.Mobiles; using Server.Network; using Server.Accounting; namespace Server.Items { public enum SoulGemType { None, //0 Red, //1 Green, //2 Blue, //3 Purple, //4 Yellow, //5 White, //6 Black, //7 Special //8 } public class SoulGem : BaseJewel { Mobile m_Owner = null; Mobile m_From = null; private bool m_CanUse; private Timer m_Timer; private SoulGemType m_SoulType; public override int ArtifactRarity{ get{ return 25; } } [CommandProperty(Server.AccessLevel.GameMaster)] public Mobile Owner { get { if ( m_Owner == null && this.IsChildOf(((Mobile)this.Parent).Backpack) && !((Mobile)this.Parent).Player ) { CheckCanUse((Mobile)this.Parent); if ( m_CanUse ) m_Owner = ((Mobile)this.Parent); } return m_Owner; } set { m_Owner = value; } } [CommandProperty( AccessLevel.GameMaster )] public SoulGemType SoulType { get{ return m_SoulType; } set{ m_SoulType = value; InvalidateProperties(); } } public Mobile From { get { return m_From; } set { m_From = value; } } public bool CanUse { get { return m_CanUse; } set { m_CanUse = value; } } [Constructable] public SoulGem() : base( 0x0E73, Layer.Unused_xF ) { Name = "Soul Gem"; m_SoulType = SoulGemType.None; ItemID = 0x0E73; // Unneeded? Layer = Layer.Unused_xF; // Unneeded? m_Timer = new InternalTimer( this, TimeSpan.FromSeconds( 3.0 ) ); } public SoulGem( Serial serial ) : base( serial ) { } public override void Serialize( GenericWriter writer ) { base.Serialize( writer ); writer.Write( (int) 0 ); // version writer.Write( (Mobile) m_Owner); writer.Write( (Mobile) m_From); writer.Write( (bool) m_CanUse); writer.WriteEncodedInt( (int) m_SoulType ); } public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch ( version ) { case 0: { m_Owner = reader.ReadMobile(); m_From = reader.ReadMobile(); m_CanUse = reader.ReadBool(); m_SoulType = (SoulGemType)reader.ReadEncodedInt(); if ( m_Owner != m_From ) { TimeSpan duration = TimeSpan.FromSeconds( 3.0 ); m_Timer = new InternalTimer( this, duration ); m_Timer.Start(); } break; } } } private bool CheckCanUse( Mobile from ) { if ( ( from.FindItemOnLayer( Layer.Unused_xF ) as SoulGem ) == null ) { if ( from != m_Owner) { if( from.Player ) { if (from.AccessLevel == AccessLevel.Administrator) { m_SoulType = SoulGemType.Special; } else if ( from.Karma >= 10500 ) m_SoulType = SoulGemType.White; else if ( from.Karma <= -10500 ) m_SoulType = SoulGemType.Black; else { switch(Utility.Random( 10 )) { case 0: { m_SoulType = SoulGemType.Red; break; } case 1: { m_SoulType = SoulGemType.Green; break; } case 2: { m_SoulType = SoulGemType.Blue; break; } case 3: { m_SoulType = SoulGemType.Yellow; break; } case 4: { m_SoulType = SoulGemType.Purple; break; } default: { switch(Utility.Random(100)) { case 99: { m_SoulType = SoulGemType.Special; break; } default: { m_SoulType = SoulGemType.None; break; } } break; } } } } else { switch (Utility.Random(1000)) { case 10: { m_SoulType = SoulGemType.Red; break; } case 20: { m_SoulType = SoulGemType.Green; break; } case 30: { m_SoulType = SoulGemType.Blue; break; } case 40: { m_SoulType = SoulGemType.Purple; break; } case 50: { m_SoulType = SoulGemType.Yellow; break; } case 100: { m_SoulType = SoulGemType.Red; break; } case 200: { m_SoulType = SoulGemType.Green; break; } case 300: { m_SoulType = SoulGemType.Blue; break; } case 400: { m_SoulType = SoulGemType.Purple; break; } case 500: { m_SoulType = SoulGemType.Yellow; break; } case 750: { switch ( Utility.Random (2)) { case 0: {m_SoulType = SoulGemType.White; break;} case 1: {m_SoulType = SoulGemType.Black;break;} default: {m_SoulType = SoulGemType.None;break;} } break; } case 999: { m_SoulType = SoulGemType.Special; break; } default: { switch (Utility.Random( 6 )) { case 1: { m_SoulType = SoulGemType.Red; break; } case 2: { m_SoulType = SoulGemType.Green; break; } case 3: { m_SoulType = SoulGemType.Blue; break; } case 4: { m_SoulType = SoulGemType.Purple; break; } case 5: { m_SoulType = SoulGemType.Yellow; break; } default: { m_SoulType = SoulGemType.None; break; } } break; } } } } switch (m_SoulType) { case SoulGemType.None: { Name = "Soul Gem"; Attributes.BonusHits = 30; Attributes.RegenHits = 10; Attributes.RegenStam = 10; Attributes.ReflectPhysical = 25; ItemID = 0x0E73; break; } case SoulGemType.Red: { Name = "Red Soul Gem"; Attributes.BonusStam = 30; Attributes.BonusHits = Utility.Random( 30 ); Attributes.RegenHits = Utility.Random( 10 ); Attributes.RegenStam = 20; Attributes.ReflectPhysical = 25; Attributes.BonusStr = Utility.Random( 1, 4 ); Attributes.BonusDex = Utility.Random( 1, 4 ); Attributes.BonusInt = -1 * (Utility.Random( 1, 4 )); Resistances.Fire = Utility.Random( 50, 100 ); ItemID = 0x186E; break; } case SoulGemType.Green: { Name = "Green Soul Gem"; Attributes.BonusStam = Utility.Random( 30 ); Attributes.BonusHits = Utility.Random( 30 ); Attributes.RegenHits = Utility.Random( 10 ); Attributes.RegenStam = Utility.Random( 20 ); Attributes.ReflectPhysical = 25; Attributes.BonusStr = Utility.Random( 1, 4 ); Attributes.BonusDex = Utility.Random( 1, 4 ); Attributes.BonusInt = -1 * (Utility.Random( 1, 4 )); Resistances.Poison = Utility.Random( 50, 100 ); ItemID = 0x186B; break; } case SoulGemType.Blue: { Name = "Blue Soul Gem"; Attributes.BonusMana = 30; Attributes.BonusStam = Utility.Random( 30 ); Attributes.RegenStam = Utility.Random( 10 ); Attributes.RegenMana = 20; Attributes.ReflectPhysical = 25; Attributes.BonusStr = -1 * (Utility.Random( 1, 4 )); Attributes.BonusDex = Utility.Random( 1, 4 ); Attributes.BonusInt = Utility.Random( 1, 4 ); Resistances.Cold = Utility.Random( 50, 100 ); ItemID = 0x186A; break; } case SoulGemType.Purple: { Name = "Purple Soul Gem"; Attributes.BonusMana = Utility.Random( 30 ); Attributes.BonusHits = Utility.Random( 30 ); Attributes.BonusStam = Utility.Random( 30 ); Attributes.RegenStam = Utility.Random( 10 ); Attributes.RegenHits = Utility.Random( 10 ); Attributes.RegenMana = Utility.Random( 10 ); Attributes.ReflectPhysical = 25; Attributes.BonusStr = Utility.Random( 1, 4 ); Attributes.BonusDex = Utility.Random( 1, 4 ); Attributes.BonusInt = Utility.Random( 1, 4 ); Resistances.Fire = Utility.Random( 1, 35 ); Resistances.Cold = Utility.Random( 1, 35 ); if ( ( Resistances.Fire + Resistances.Cold ) != 50 ) { Resistances.Fire = 25; Resistances.Cold = 25; } ItemID = 0x186D; break; } case SoulGemType.Yellow: { Name = "Yellow Soul Gem"; Attributes.BonusHits = 30; Attributes.RegenHits = 20; Attributes.BonusStam = Utility.Random( 30 ); Attributes.RegenStam = Utility.Random( 20 ); Attributes.ReflectPhysical = 25; Attributes.BonusStr = Utility.Random( 1, 4 ); Attributes.BonusDex = -1 * (Utility.Random( 1, 4 )); Attributes.BonusInt = Utility.Random( 1, 4 ); Resistances.Energy = Utility.Random( 50, 100 ); ItemID = 0x1870; break; } case SoulGemType.White: { Name = "White Soul Gem"; Attributes.BonusMana = Utility.Random( 20, 30 ); Attributes.BonusHits = Utility.Random( 20, 30 ); Attributes.BonusStam = Utility.Random( 20, 30 ); Attributes.RegenStam = Utility.Random( 10, 20 ); Attributes.RegenHits = Utility.Random( 10, 20 ); Attributes.RegenMana = Utility.Random( 10, 20 ); Attributes.LowerManaCost = 50; Attributes.LowerRegCost = 50; Attributes.ReflectPhysical = 25; Attributes.BonusStr = -1 * (Utility.Random( 1, 4 )); Attributes.BonusDex = Utility.Random( 1, 4 ); Attributes.BonusInt = Utility.Random( 1, 4 ); SkillBonuses.SetValues( 0, SkillName.Healing, 25 ); SkillBonuses.SetValues( 1, SkillName.Anatomy, 25 ); SkillBonuses.SetValues( 2, SkillName.Magery, 25 ); Resistances.Energy = Utility.Random( 15, 25 ); Resistances.Fire = Utility.Random( 15, 25 ); Resistances.Cold = Utility.Random( 15, 25 ); Resistances.Poison = Utility.Random( 15, 25 ); Resistances.Physical = Utility.Random( 15, 25 ); ItemID = 0x186F; break; } case SoulGemType.Black: { Name = "Black Soul Gem"; Attributes.BonusMana = Utility.Random( 20, 30 ); Attributes.BonusHits = Utility.Random( 20, 30 ); Attributes.BonusStam = Utility.Random( 20, 30 ); Attributes.RegenStam = Utility.Random( 10, 20 ); Attributes.RegenHits = Utility.Random( 10, 20 ); Attributes.RegenMana = Utility.Random( 10, 20 ); Attributes.WeaponDamage = 50; Attributes.BonusStr = Utility.Random( 1, 4 ); Attributes.BonusDex = Utility.Random( 1, 4 ); Attributes.BonusInt = -1 * (Utility.Random( 1, 4 )); Attributes.ReflectPhysical = 25; SkillBonuses.SetValues( 0, SkillName.Tactics, 25 ); SkillBonuses.SetValues( 1, SkillName.Swords, 25 ); SkillBonuses.SetValues( 2, SkillName.Anatomy, 25 ); SkillBonuses.SetValues( 3, SkillName.Parry, 25 ); Resistances.Energy = Utility.Random( 5, 25 ); Resistances.Fire = Utility.Random( 15, 25 ); Resistances.Cold = Utility.Random( 15, 25 ); Resistances.Poison = Utility.Random( 15, 25 ); Resistances.Physical = Utility.Random( 15, 25 ); ItemID = 0x1869; break; } case SoulGemType.Special: { Name = "Immortal Gem"; Resistances.Poison = 100; Resistances.Fire = 35; Resistances.Cold = 35; Attributes.RegenHits = 75; Attributes.BonusStr = Utility.Random( 4 ); Attributes.BonusDex = Utility.Random( 4 ); Attributes.BonusInt = Utility.Random( 4 ); SkillBonuses.SetValues( 0, SkillName.Swords, 45 ); SkillBonuses.SetValues( 1, SkillName.Parry, 45 ); SkillBonuses.SetValues( 2, SkillName.Healing, 45 ); SkillBonuses.SetValues( 3, SkillName.Anatomy, 45 ); ItemID = 0x186C; break; } default: { Name = "Soul Gem"; Attributes.BonusHits = 30; Attributes.RegenHits = 10; Attributes.RegenStam = 10; Attributes.ReflectPhysical = 25; ItemID = 0x0E73; break; } } m_CanUse = true; return true; } else { m_CanUse = false; return false; } } public override bool OnDroppedInto( Mobile from, Container target, Point3D p ) { if ( from != null && target == from.Backpack && from != m_Owner ) { CheckCanUse( from ); if(target.IsChildOf(from.Backpack)) { from.SendMessage( "You can not put that into a container in your backpack!" ); return false; } else { if ( m_CanUse ) { if (m_SoulType != SoulGemType.Special) m_Timer.Start(); } } m_From = from; return base.OnDroppedInto( from, target, p ); } else if ( m_Owner == from && m_CanUse ) { from.AddItem(this); return true; } else if (target == from.BankBox) return base.OnDroppedInto( from, target, p ); else return false; } public override bool OnDroppedOnto( Mobile from, Item target ) { if ( from != null && target == from.Backpack && from != m_Owner ) { CheckCanUse( from ); if ( m_CanUse ) { if (m_SoulType != SoulGemType.Special) m_Timer.Start(); } m_From = from; return base.OnDroppedOnto( from, target ); } else if ( m_Owner == from && m_CanUse ) { from.AddItem(this); return true; } else if ( m_Owner == from && !m_CanUse ) { return base.OnDroppedOnto( from, target ); } else if (target == from.BankBox) return base.OnDroppedOnto( from, target ); else return false; } public override bool OnDroppedToMobile( Mobile from, Mobile target ) { if ( from != null && target != null && target == from && from != m_Owner ) { CheckCanUse( from ); if ( m_CanUse ) { if (m_SoulType != SoulGemType.Special) m_Timer.Start(); } m_From = from; return base.OnDroppedToMobile( from, target); } else if ( m_Owner == from && m_CanUse ) { from.AddItem(this); return true; } else if ( m_Owner == from && !m_CanUse ) { return base.OnDroppedToMobile( from, target); } else { from.SendMessage("You can not give this item to someone!"); return false; } } public override void OnAfterDelete() { base.OnAfterDelete(); if ( m_Timer != null ) m_Timer.Stop(); } public override void OnRemoved( object parent ) { base.OnRemoved(parent); if( parent is PlayerMobile ) { // ((Mobile)parent).SendMessage("Removing Gem"); if (((PlayerMobile)parent).IsAttackable) ((PlayerMobile)parent).IsAttackable = false; if (((PlayerMobile)parent).IsKiller) ((PlayerMobile)parent).IsKiller = false; } } public override void OnAdded( object parent ) { base.OnAdded( parent ); if( parent is BaseMobile ) { // ((Mobile)parent).SendMessage("Adding Gem"); if ( m_SoulType != SoulGemType.Black || m_SoulType != SoulGemType.None ) { ((BaseMobile)parent).IsAttackable = true; } if ( m_SoulType == SoulGemType.Black ) { ((BaseMobile)parent).IsKiller = true; } } } public override void OnDoubleClick( Mobile from ) { if ( ( from != m_Owner || m_Owner == null ) && this.IsChildOf( from.Backpack ) ) { CheckCanUse( from ); if ( m_CanUse ) { m_Owner = from; from.AddItem(this); } m_From = from; } else if ( from == m_Owner && m_CanUse ) { from.AddItem( this ); } else if ( from != m_Owner || !this.IsChildOf( from.Backpack ) ) { from.SendMessage( "Your Can not do that from there." ); return; } else { if ( !m_CanUse ) from.SendMessage( "Your Can not use this at the moment." ); return; } } /* public override DeathMoveResult OnParentDeath( Mobile parent ) { if ( parent is PlayerMobile && !parent.Alive && parent == m_Owner && m_SoulType == SoulGemType.Special ) { parent.PlaySound( 0x214 ); parent.FixedEffect( 0x376A, 10, 16 ); parent.Resurrect(); // parent.AddItem(this); return DeathMoveResult.RemainEquiped; } else return base.OnParentDeath( parent ); } */ } public class InternalTimer : Timer { private SoulGem m_Item; public InternalTimer( SoulGem item, TimeSpan duration ) : base( duration ) { Priority = TimerPriority.OneSecond; m_Item = item; } protected override void OnTick() { m_Item.Owner = m_Item.From; if ( m_Item.CanUse ) ((Mobile)m_Item.Owner).AddItem(m_Item); } } } /******************************************************** // To make this script work you need to add // the following to your PlayerMobile.cs private bool m_Attackable; private bool m_Red; [CommandProperty( AccessLevel.Administrator )] public bool IsKiller { get{ return m_Red; } set{ m_Red = value; } } [CommandProperty( AccessLevel.Administrator )] public bool IsAttackable { get{ return m_Attackable; } set{ m_Attackable = value; } } //Add the above near all the other properties //ie somewhere around [CommandProperty( AccessLevel.GameMaster )] public int Profession { get{ return m_Profession; } set{ m_Profession = value; } } //i put it right above that..... This section of Notoriety.cs is what I changed to make this work public static int MobileNotoriety( Mobile source, Mobile target ) { if ( Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier) ) return Notoriety.Invulnerable; // // if ( target.AccessLevel > AccessLevel.Player ) // return Notoriety.CanBeAttacked; // // Section I added to make my soulgems work if ( target is PlayerMobile ) { if ( ((PlayerMobile)target).IsAttackable ) return Notoriety.CanBeAttacked; else if ( ((PlayerMobile)target).IsKiller ) return Notoriety.Murderer; } //end of addition if ( source.Player && !target.Player && source is PlayerMobile && target is BaseCreature ) { BaseCreature bc = (BaseCreature)target; if ( !bc.Summoned && !bc.Controled && ((PlayerMobile)source).EnemyOfOneType == target.GetType() ) return Notoriety.Enemy; } if ( target.Kills >= 5 || (target.Body.IsMonster && IsSummoned( target as BaseCreature ) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)) ) return Notoriety.Murderer; if ( target.Criminal ) return Notoriety.Criminal; Guild sourceGuild = GetGuildFor( source.Guild as Guild, source ); Guild targetGuild = GetGuildFor( target.Guild as Guild, target ); if ( sourceGuild != null && targetGuild != null ) { if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) ) return Notoriety.Ally; else if ( sourceGuild.IsEnemy( targetGuild ) ) return Notoriety.Enemy; } if ( SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains( source ) ) return Notoriety.CanBeAttacked; if ( target is BaseCreature && ((BaseCreature)target).AlwaysAttackable ) return Notoriety.CanBeAttacked; if ( CheckHouseFlag( source, target, target.Location, target.Map ) ) return Notoriety.CanBeAttacked; if ( !(target is BaseCreature && ((BaseCreature)target).InitialInnocent) ) { if ( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( target as BaseCreature ) ) return Notoriety.CanBeAttacked; } if ( CheckAggressor( source.Aggressors, target ) ) return Notoriety.CanBeAttacked; if ( CheckAggressed( source.Aggressed, target ) ) return Notoriety.CanBeAttacked; if ( target is BaseCreature ) { BaseCreature bc = (BaseCreature)target; if ( bc.Controled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source ) return Notoriety.CanBeAttacked; } return Notoriety.Innocent; } *********************************************************/