Example #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!m_Crystal.IsAccessibleTo(from))
                {
                    return;
                }

                if (from.Map != m_Crystal.Map || !from.InRange(m_Crystal.GetWorldLocation(), 2))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    return;
                }

                if (targeted == m_Crystal)
                {
                    if (m_Crystal.Active)
                    {
                        m_Crystal.Active = false;
                        from.SendLocalizedMessage(500672); // You turn the crystal off.
                    }
                    else
                    {
                        m_Crystal.Active = true;
                        from.SendLocalizedMessage(500673); // You turn the crystal on.
                    }
                }
                else if (targeted == from)
                {
                    if (m_Crystal.Sender != null)
                    {
                        m_Crystal.Sender = null;
                        from.SendLocalizedMessage(1010044); // You unlink the receiver crystal.
                    }
                    else
                    {
                        from.SendLocalizedMessage(1010045); // That receiver crystal is not linked.
                    }
                }
                else
                {
                    Item targItem = targeted as Item;

                    if (targItem != null && targItem.VerifyMove(from))
                    {
                        CrystalRechargeInfo info = CrystalRechargeInfo.Get(targItem.GetType());

                        if (info != null)
                        {
                            from.SendLocalizedMessage(500677); // This crystal cannot be recharged.
                            return;
                        }
                    }

                    from.SendLocalizedMessage(1010045); // That receiver crystal is not linked.
                }
            }
Example #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!m_Crystal.IsAccessibleTo(from))
                {
                    return;
                }

                if (from.Map != m_Crystal.Map || !from.InRange(m_Crystal.GetWorldLocation(), 2))
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                    return;
                }

                if (targeted == m_Crystal)
                {
                    if (m_Crystal.Active)
                    {
                        m_Crystal.Active = false;
                        from.SendLocalizedMessage(500672); // You turn the crystal off.
                    }
                    else
                    {
                        if (m_Crystal.Charges > 0)
                        {
                            m_Crystal.Active = true;
                            from.SendLocalizedMessage(500673); // You turn the crystal on.
                        }
                        else
                        {
                            from.SendLocalizedMessage(500676); // This crystal is out of charges.
                        }
                    }
                }
                else if (targeted is ReceiverCrystal)
                {
                    ReceiverCrystal receiver = (ReceiverCrystal)targeted;

                    if (m_Crystal.Receivers.Count >= 10)
                    {
                        from.SendLocalizedMessage(1010042); // This broadcast crystal is already linked to 10 receivers.
                    }
                    else if (receiver.Sender == m_Crystal)
                    {
                        from.SendLocalizedMessage(500674); // This crystal is already linked with that crystal.
                    }
                    else if (receiver.Sender != null)
                    {
                        from.SendLocalizedMessage(1010043); // That receiver crystal is already linked to another broadcast crystal.
                    }
                    else
                    {
                        receiver.Sender = m_Crystal;
                        from.SendLocalizedMessage(500675); // That crystal has been linked to this crystal.
                    }
                }
                else if (targeted == from)
                {
                    foreach (ReceiverCrystal receiver in new List <ReceiverCrystal>(m_Crystal.Receivers))
                    {
                        receiver.Sender = null;
                    }

                    from.SendLocalizedMessage(1010046); // You unlink the broadcast crystal from all of its receivers.
                }
                else
                {
                    Item targItem = targeted as Item;

                    if (targItem != null && targItem.VerifyMove(from))
                    {
                        CrystalRechargeInfo info = CrystalRechargeInfo.Get(targItem.GetType());

                        if (info != null)
                        {
                            if (m_Crystal.Charges >= MaxCharges)
                            {
                                from.SendLocalizedMessage(500678); // This crystal is already fully charged.
                            }
                            else
                            {
                                targItem.Consume();

                                if (m_Crystal.Charges + info.Amount >= MaxCharges)
                                {
                                    m_Crystal.Charges = MaxCharges;
                                    from.SendLocalizedMessage(500679); // You completely recharge the crystal.
                                }
                                else
                                {
                                    m_Crystal.Charges += info.Amount;
                                    from.SendLocalizedMessage(500680); // You recharge the crystal.
                                }
                            }

                            return;
                        }
                    }

                    from.SendLocalizedMessage(500681); // You cannot use this crystal on that.
                }
            }