public override void OnResponse(NetState sender, RelayInfo info) { int index = info.ButtonID - 1; if (index >= 0 && index < m_Entries.Length) { SummonFamiliarEntry entry = m_Entries[index]; double necro = m_From.Skills.Necromancy.Value; double spirit = m_From.Skills.SpiritSpeak.Value; if ((m_From as PlayerMobile)?.DuelContext?.AllowSpellCast(m_From, m_Spell) == false) { } else if (SummonFamiliarSpell.Table.TryGetValue(m_From, out BaseCreature check) && check?.Deleted == false) { m_From.SendLocalizedMessage(1061605); // You already have a familiar. } else if (necro < entry.ReqNecromancy || spirit < entry.ReqSpiritSpeak) { // That familiar requires ~1_NECROMANCY~ Necromancy and ~2_SPIRIT~ Spirit Speak. m_From.SendLocalizedMessage(1061606, $"{entry.ReqNecromancy:F1}\t{entry.ReqSpiritSpeak:F1}"); m_From.CloseGump <SummonFamiliarGump>(); m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries, m_Spell)); } else if (entry.Type == null) { m_From.SendMessage("That familiar has not yet been defined."); m_From.CloseGump <SummonFamiliarGump>(); m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries, m_Spell)); } else { try { BaseCreature bc = (BaseCreature)ActivatorUtil.CreateInstance(entry.Type); // TODO: Is this right? bc.Skills.MagicResist.Base = m_From.Skills.MagicResist.Base; if (BaseCreature.Summon(bc, m_From, m_From.Location, -1, TimeSpan.FromDays(1.0))) { m_From.FixedParticles(0x3728, 1, 10, 9910, EffectLayer.Head); bc.PlaySound(bc.GetIdleSound()); SummonFamiliarSpell.Table[m_From] = bc; } } catch { // ignored } } } else { m_From.SendLocalizedMessage(1061825); // You decide not to summon a familiar. } }
public override void OnResponse(NetState sender, RelayInfo info) { int index = info.ButtonID - 1; if (index >= 0 && index < m_Entries.Length) { SummonFamiliarEntry entry = m_Entries[index]; double necro = m_From.Skills[SkillName.Necromancy].Value; double spirit = m_From.Skills[SkillName.SpiritSpeak].Value; BaseCreature check = (BaseCreature)SummonFamiliarSpell.Table[m_From]; if (check != null && !check.Deleted) { m_From.SendLocalizedMessage(1061605); // You already have a familiar. } else if (necro < entry.ReqNecromancy || spirit < entry.ReqSpiritSpeak) { // That familiar requires ~1_NECROMANCY~ Necromancy and ~2_SPIRIT~ Spirit Speak. m_From.SendLocalizedMessage(1061606, String.Format("{0:F1}\t{1:F1}", entry.ReqNecromancy, entry.ReqSpiritSpeak)); m_From.CloseGump(typeof(SummonFamiliarGump)); m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries, m_Spell)); } else if (entry.Type == null) { m_From.SendMessage("That familiar has not yet been defined."); m_From.CloseGump(typeof(SummonFamiliarGump)); m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries, m_Spell)); } else { try { BaseCreature bc = (BaseCreature)Activator.CreateInstance(entry.Type); bc.Skills.MagicResist = m_From.Skills.MagicResist; if (BaseCreature.Summon(bc, m_From, m_From.Location, -1, TimeSpan.FromDays(1.0))) { m_From.FixedParticles(0x3728, 1, 10, 9910, EffectLayer.Head); bc.PlaySound(bc.GetIdleSound()); SummonFamiliarSpell.Table[m_From] = bc; } } catch (Exception e) { Server.Diagnostics.ExceptionLogging.LogException(e); } } } else { m_From.SendLocalizedMessage(1061825); // You decide not to summon a familiar. } }
public override void OnResponse(NetState sender, RelayInfo info) { int index = info.ButtonID - 1; if (index >= 0 && index < m_Entries.Length) { SummonFamiliarEntry entry = m_Entries[index]; double necro = m_From.Skills[SkillName.Necromancy].Base; double spirit = m_From.Skills[SkillName.SpiritSpeak].Base; BaseCreature check = (BaseCreature)SummonFamiliarSpell.Table[m_From]; if (check != null && !check.Deleted) { } else if (necro < entry.ReqNecromancy || spirit < entry.ReqSpiritSpeak) { m_From.CloseGump(typeof(SummonFamiliarGump)); m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries)); } else if (entry.Type == null) { m_From.SendMessage("That familiar has not yet been defined."); m_From.CloseGump(typeof(SummonFamiliarGump)); m_From.SendGump(new SummonFamiliarGump(m_From, SummonFamiliarSpell.Entries)); } else { try { BaseCreature bc = (BaseCreature)Activator.CreateInstance(entry.Type); bc.Skills.MagicResist = m_From.Skills.MagicResist; if (BaseCreature.Summon(bc, m_From, m_From.Location, -1, TimeSpan.FromDays(1.0))) { m_From.FixedParticles(0x3728, 1, 10, 9910, EffectLayer.Head); bc.PlaySound(bc.GetIdleSound()); SummonFamiliarSpell.Table[m_From] = bc; } } catch { } } } else { } }
public SummonFamiliarGump( Mobile from, SummonFamiliarEntry[] entries, SummonFamiliarSpell spell ) : base(200, 100) { m_From = from; m_Entries = entries; m_Spell = spell; AddPage( 0 ); AddBackground( 10, 10, 250, 178, 9270 ); AddAlphaRegion( 20, 20, 230, 158 ); AddImage( 220, 20, 10464 ); AddImage( 220, 72, 10464 ); AddImage( 220, 124, 10464 ); AddItem( 188, 16, 6883 ); AddItem( 198, 168, 6881 ); AddItem( 8, 15, 6882 ); AddItem( 2, 168, 6880 ); AddHtmlLocalized( 30, 26, 200, 20, 1060147, EnabledColor16, false, false ); // Chose thy familiar... double necro = from.Skills[SkillName.Necromancy].Base; double spirit = from.Skills[SkillName.SpiritSpeak].Base; for ( int i = 0; i < entries.Length; ++i ) { object name = entries[i].Name; bool enabled = ( necro >= entries[i].ReqNecromancy && spirit >= entries[i].ReqSpiritSpeak ); AddButton( 27, 53 + (i * 21), 9702, 9703, i + 1, GumpButtonType.Reply, 0 ); if ( name is int ) AddHtmlLocalized( 50, 51 + (i * 21), 150, 20, (int)name, enabled ? EnabledColor16 : DisabledColor16, false, false ); else if ( name is string ) AddHtml( 50, 51 + (i * 21), 150, 20, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", enabled ? EnabledColor32 : DisabledColor32, name ), false, false ); } }