コード例 #1
0
ファイル: Poisoning.cs プロジェクト: rberiot/imaginenation
                protected override void OnTarget(Mobile from, object targeted)
                {
                    bool releaseLock = true;

                    if (m_Potion.Deleted)
                    {
                        if (releaseLock && from is PlayerMobile)
                        {
                            ((PlayerMobile)from).EndPlayerAction();
                        }

                        return;
                    }

                    bool startTimer = false;

                    if (targeted is Food || targeted is FukiyaDarts || targeted is Shuriken)
                    {
                        startTimer = true;
                    }
                    else if (targeted is BaseWeapon)
                    {
                        BaseWeapon weapon = (BaseWeapon)targeted;

                        if (Core.AOS)
                        {
                            startTimer = (weapon.PrimaryAbility == WeaponAbility.InfectiousStrike || weapon.SecondaryAbility == WeaponAbility.InfectiousStrike);
                        }
                        else if (weapon.Layer == Layer.OneHanded && !(weapon is SuperiorDiamondKatana || weapon is DiamondKatana || weapon is HellsHalberd || weapon is SuperiorDragonsBlade || weapon is DragonsBlade || weapon is HeavensFury || weapon is SoV)) //Loki edit: 1H blades only
                        {
                            startTimer = (weapon.Type == WeaponType.Slashing || weapon.Type == WeaponType.Piercing);
                        }
                    }

                    if (startTimer)
                    {
                        releaseLock = false;
                        new InternalTimer(from, (Item)targeted, m_Potion).Start();

                        from.PlaySound(0x4F);

                        if (!m_Potion.EventItem) //Loki edit: Event pots are not consumed and don't create empty bottles
                        {
                            m_Potion.Consume();

                            Bottle bottle = new Bottle();

                            #region Add to pack or ground if overweight
                            //Taran: Check to see if player is overweight. If they are and the item drops to the
                            //ground then a check is made to see if it can be stacked. If it can't and  more than
                            //20 items of the same type exist in the same tile then the last item gets removed. This
                            //check is made so thousands of items can't exist in 1 tile and crash people in the same area.
                            if (from.AddToBackpack(bottle))
                            {
                                from.SendAsciiMessage("You put the {0} in your pack.", bottle.Name ?? CliLoc.LocToString(bottle.LabelNumber));
                            }
                            else if (!bottle.Deleted)
                            {
                                IPooledEnumerable eable = from.Map.GetItemsInRange(from.Location, 0);
                                int  amount             = 0;
                                Item toRemove           = null;

                                foreach (Item i in eable)
                                {
                                    if (i != bottle && i.ItemID == bottle.ItemID)
                                    {
                                        if (i.StackWith(from, bottle, false))
                                        {
                                            toRemove = bottle;
                                            break;
                                        }

                                        amount++;
                                    }
                                }

                                from.SendAsciiMessage("You are overweight and put the {0} on the ground.", bottle.Name ?? CliLoc.LocToString(bottle.LabelNumber));

                                if (toRemove != null)
                                {
                                    toRemove.Delete();
                                }
                                else if (amount >= 5 && amount < 20)
                                {
                                    from.LocalOverheadMessage(MessageType.Regular, 906, true, string.Format("{0} identical items on the ground detected, no more than 20 is allowed!", amount));
                                }
                                else if (amount >= 20)
                                {
                                    from.LocalOverheadMessage(MessageType.Regular, 906, true, "Too many identical items on the ground, removing!");
                                    bottle.Delete();
                                }

                                eable.Free();
                            }
                            #endregion
                        }
                    }
                    else                     // Target can't be poisoned
                    {
                        if (Core.AOS)
                        {
                            from.SendLocalizedMessage(1060204);                               // You cannot poison that! You can only poison infectious weapons, food or drink.
                        }
                        else
                        {
                            //from.SendLocalizedMessage( 502145 ); // You cannot poison that! You can only poison bladed or piercing weapons, food or drink.
                            from.SendAsciiMessage("You cannot poison that! You can only poison certain weapons, food or drink.");
                        }
                    }

                    if (releaseLock && from is PlayerMobile)
                    {
                        ((PlayerMobile)from).EndPlayerAction();
                    }
                }