Example #1
0
        private void TryDropDojoItem(TagPoint pos)
        {
            // 50% chance to drop a dojo powerup
            if (Constants.Rand.NextDouble() < 0.50)
            {
                var randBuffItem = Constants.Rand.Next(2022359, 2022422);

                var item = MasterManager.CreateItem(randBuffItem);

                if (item is null)
                {
                    return;
                }

                CDropFactory.CreateDropItem(this, pos, 0, item);
            }

            // 50% chance to drop a dojo hp/mp pot
            if (Constants.Rand.NextDouble() < 0.50)
            {
                var randPotItem = Constants.Rand.Next(2022430, 2022433);

                var item = MasterManager.CreateItem(randPotItem);

                if (item is null)
                {
                    return;
                }

                CDropFactory.CreateDropItem(this, pos, 0, item);
            }
        }
Example #2
0
        public static void UnEquip(Character pChar, short slotFrom, short slotTo)
        {
            //20:40:35[INFO] Recv[CP_UserChangeSlotPositionRequest] [4D 00] [1D A8 02 01] [01] [B3 FB] [01 00] [FF FF]
            //20:40:38[INFO] Recv[CP_UserChangeSlotPositionRequest] [4D 00] [7B B3 02 01] [01] [B3 FB] [01 00] [FF FF]

            var srcEquipInv = GetInventory(pChar, slotFrom);

            var source = srcEquipInv.GetKvp(slotFrom);

            if (slotTo != 0)             //Not dropping
            {
                if (!pChar.InventoryEquip.IsFreeSlot(slotTo))
                {
                    return;                                                           // PE
                }
            }

            if (!srcEquipInv.Remove(slotFrom))
            {
                return;                                            // false means they passed an empty slot
            }
            var pItem = source.Value;

            if (-slotFrom == (int)BodyPart.BP_SADDLE || -slotFrom == (int)BodyPart.BP_TAMINGMOB)
            {
                pChar.Buffs.Remove(pChar.Stats.SecondaryStats.rRideVehicle);
            }
            else
            {
                // taming stuff cant have option skills
                pChar.Skills.ModifyOptionSkills(pItem, false);
            }

            if (slotTo == 0)             //Dropping Item
            {
                pChar.Modify.Inventory(ctx =>
                {
                    ctx.Remove(InventoryType.Equip, slotFrom);
                });

                if (ItemConstants.GetInventoryType(pItem.nItemID) == InventoryType.Equip)
                {
                    CDropFactory.CreateDropItem(pChar.Field, pChar.Position.CurrentXY, pChar.dwId, pItem);
                }
                else
                {
                    //Should never happen????
                    pChar.SendMessage($"You unequipped and dropped a non-equip item. Please report to staff: {pItem.nItemID}");
                }
            }
            else             //Unequip to inventory
            {
                pChar.InventoryEquip.Add(slotTo, source.Value);

                pChar.Modify.Inventory(ctx =>
                {
                    ctx.Move(InventoryType.Equip, slotFrom, slotTo);
                });
            }
        }
Example #3
0
 public void DropItemOnGroundBelow(int nItemID, bool bMeso = false)
 {
     if (!bMeso)
     {
         var item = MasterManager.CreateItem(nItemID);
         CDropFactory.CreateDropItem(Reactor.Field, Reactor.Position.CurrentXY, 0, item);
     }
     else
     {
         CDropFactory.CreateDropMeso(Reactor.Field, Reactor.Position.CurrentXY, 0, nItemID);
     }
 }
Example #4
0
        public static void Drop(Character pChar, InventoryType nInvType, short invSlot, short amount)
        {
            // validate raw input
            if (amount <= 0)
            {
                return;                          // PE
            }
            if ((byte)nInvType > 5)
            {
                return;                                 // cant drop things out of equipped inventories
            }
            var pItem = GetItem(pChar, nInvType, invSlot);

            if (pItem is null)
            {
                return;                            // PE or lag
            }
            if (amount < 1)
            {
                amount = 1;                         // not neccessarily PE
            }
            if (amount > pItem.nNumber)             // TODO maybe anticheat here
            {
                amount = pItem.nNumber;
            }

            if (ItemConstants.is_treat_singly(pItem.nItemID) || amount < 1)
            {
                RemoveFrom(pChar, nInvType, invSlot, -1);

                CDropFactory.CreateDropItem(pChar.Field, pChar.Position.CurrentXY.Clone(), pChar.dwId, pItem);
            }
            else
            {
                var cNewDropItem = pItem.DeepCopy();
                cNewDropItem.nNumber = amount;

                RemoveFrom(pChar, nInvType, invSlot, amount);

                CDropFactory.CreateDropItem(pChar.Field, pChar.Position.CurrentXY.Clone(), pChar.dwId, cNewDropItem);
            }
        }