Пример #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);
            }
        }
Пример #2
0
        public void UseLotteryItem(short nPOS, int nItemID)
        {
            if (Parent.Stats.nHP <= 0)
            {
                return;
            }

            var pItemRaw = InventoryManipulator.GetItem(Parent, ItemConstants.GetInventoryType(nItemID), nPOS);             // TODO determine if we can hardcode the inventory type

            var itemResult = MasterManager.CreateItem(RandomBoxes.GetRandom(nItemID));

            if (itemResult != null && pItemRaw is GW_ItemSlotBundle pItem)
            {
                if (InventoryManipulator.CountFreeSlots(Parent, InventoryType.Equip) > 0 && InventoryManipulator.CountFreeSlots(Parent, InventoryType.Consume) > 0)
                {
                    InventoryManipulator.RemoveFrom(Parent, pItemRaw.InvType, nPOS);
                    InventoryManipulator.InsertInto(Parent, itemResult);
                }
                else
                {
                    Parent.SendMessage("Please make some room in your inventory.");
                }
            }
            else
            {
                Parent.SendMessage("This item has not been implemented yet. If you believe this to be an error, please report it on the discord server.");
            }
        }
Пример #3
0
        public static void Attempt(Character c)
        {
            if (Constants.Rand.NextDouble() > Constants.MobDeathRoulette_Odds)
            {
                return;
            }

            var roulette = new MobDeathRoulette();

            for (int i = -1; i < 3; i++)
            {
                var effect = new FieldEffectPacket(FieldEffect.Screen)
                {
                    sName = roulette.GetEffectString(i)
                };

                effect.Broadcast(c, true);
            }

            var pItem = MasterManager.CreateItem(roulette.nScrollItemID);

            pItem.nNumber = 1;

            // todo delay this
            InventoryManipulator.InsertInto(c, pItem);
        }
        public bool AddRandomMasteryBook(int nJobID = -1)
        {
            int bookid;

            if (nJobID == -1)
            {
                bookid = MasterManager.ItemTemplates
                         .MasteryBooks()
                         .Random()                // grab random set
                         .Random();               // grab random item from set
            }
            else
            {
                bookid = MasterManager.ItemTemplates
                         .MasteryBooksByJob(PlayerJob)
                         .Random();
            }

            if (bookid <= 0)
            {
                return(false);
            }

            var item = MasterManager.CreateItem(bookid);

            var slot = InventoryManipulator.InsertInto(Character, item);

            return(slot != 0);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pStartPos"></param>
        /// <param name="dwOwnerID"></param>
        /// <param name="bMeso"></param>
        /// <param name="nOption">ItemID or amount of meso, depending on drop type.</param>
        /// <returns></returns>
        public static CDrop CreateDropFromMob(CMovePath pStartPos, int dwOwnerID, bool bMeso, int nOption)
        {
            var drop = new CDrop(pStartPos, dwOwnerID)
            {
                bIsMoney = (byte)(bMeso ? 1 : 0),

                Item   = bMeso ? null : MasterManager.CreateItem(nOption),
                ItemId = nOption
            };

            return(drop);
        }
Пример #6
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);
     }
 }
Пример #7
0
        public void OnLostQuestItem(CInPacket p, short nQuestID)
        {
            var nLostCount = p.Decode4();

            var pAct = MasterManager.QuestTemplates[nQuestID].StartAct;

            if (pAct is null)
            {
                return;                           // invalid quest ID
            }
            if (nLostCount <= 0 || pAct.Items.Length <= 0)
            {
                return;                                                        // TODO trigger AB, close socket
            }
            var aLostItem = p.DecodeIntArray(nLostCount);

            foreach (var item in pAct.Items)
            {
                if (!aLostItem.Contains(item.Item.ItemID))
                {
                    continue;                                                        // TODO trigger AB?
                }
                if (ItemConstants.GetInventoryType(item.Item.ItemID) == InventoryType.Equip)
                {
                    Parent.SendMessage("Not currently supported. Check again later.");
                    return;                     // TODO
                }

                if (!MasterManager.ItemTemplates[item.Item.ItemID]?.Quest ?? true)
                {
                    continue;
                }

                if (InventoryManipulator.HasSpace(Parent, item.Item.ItemID, (short)item.Item.Count))
                {
                    var itemToAdd = MasterManager.CreateItem(item.Item.ItemID);
                    itemToAdd.nNumber = (short)item.Item.Count;
                    InventoryManipulator.InsertInto(Parent, itemToAdd);
                }
                else
                {
                    // TODO proper response packet
                    Parent.SendMessage("Please make space in your inventory.");
                    return;
                }
            }

            // TODO
            // if ( aChangedItem.a && *(aChangedItem.a - 1) > 0u )
            //		CUser::PostQuestEffect(&v16->vfptr, 1, &aChangedItem, 0, 0);
        }
Пример #8
0
        public override void OnUserDamaged(Character pUser, CMob pMob, int nDamage)
        {
            // TODO override drop expiration timer with template dropExpire attribute (10 sec on this map)

            if (!aTeams.ContainsKey(pUser.dwId) && pUser.Account.AccountData.Admin <= 0)
            {
                pUser.Action.SetField(ReturnMapId);
                return;
            }

            var nItemID = (int)(aTeams[pUser.dwId] == BattlefieldData.BattlefieldTeams.Wolves
                                ? BattlefieldData.BattleItems.ShepherdBoysLunch
                                : BattlefieldData.BattleItems.FineWool);

            if (nItemID == (int)BattlefieldData.BattleItems.ShepherdBoysLunch && Constants.Rand.Next() % 100 > 10)
            {
                return;
            }

            if (nItemID == (int)BattlefieldData.BattleItems.FineWool)
            {
                if (aSheepPoints[pUser.dwId] > 0)
                {
                    if (--aSheepPoints[pUser.dwId] == 0)
                    {
                        ChangePlayerTeam(pUser.dwId, BattlefieldData.BattlefieldTeams.SheepNaked);
                        BroadcastNotice($"{pUser.Stats.sCharacterName} has lost all their wool!");
                    }
                }
                else
                {
                    return;                     // cant drop wool if u already dropped all of it
                }
            }

            var item = MasterManager.CreateItem(nItemID);

            var drop = new CDrop(pUser.Position.CurrentXY, 0)
            {
                Item   = item,
                ItemId = item.nItemID,
                QR     = pUser.dwId.ToString()
            };

            drop.Position.X = drop.StartPosX;
            drop.CalculateY(this, drop.StartPosY);

            Drops.Add(drop);
        }
        public void AddItem(int itemId, short amount = 1)
        {
            var item = MasterManager.CreateItem(itemId);

            if (item is GW_ItemSlotBundle isb)
            {
                if (item.IsRechargeable == false)
                {
                    isb.nNumber = Math.Max((short)1, amount);
                }
            }

            InventoryManipulator.InsertInto(Character, item);

            Character.SendPacket(CPacket.DropPickUpMessage_Item(itemId, amount, true));
        }
Пример #10
0
        private void Handle_CashShopCheckCouponRequest(WvsShopClient c, CInPacket p)
        {
            p.Decode2();             // something

            var code = p.DecodeString();

            var coupon = new CouponCode(code, c);

            if (coupon.Invalid)
            {
                c.SendPacket(CPacket.CCashShop.CouponFail(CashItemFailed.InvalidCoupon));
            }
            else if (coupon.Used)
            {
                c.SendPacket(CPacket.CCashShop.CouponFail(CashItemFailed.UsedCoupon));
            }
            else if (coupon.IncorrectAccount)
            {
                c.SendPacket(CPacket.CCashShop.CouponFail(CashItemFailed.NotAvailableCoupon));
            }
            else if (coupon.Expired)
            {
                c.SendPacket(CPacket.CCashShop.CouponFail(CashItemFailed.ExpiredCoupon));
            }
            else if (coupon.Items != null && !InventoryManipulator.HasSpace(c.Character, coupon.Items))
            {
                c.SendPacket(CPacket.CCashShop.CouponFail(CashItemFailed.NoEmptyPos));                 // TODO fix this
            }
            else
            {
                if (coupon.Items != null)
                {
                    foreach (var item in coupon.Items)
                    {
                        InventoryManipulator.InsertInto(c.Character, MasterManager.CreateItem(item, false));
                        CPacket.CCashShop.CouponAddItem(item);
                    }
                }

                c.Account.AccountData.NX_Prepaid += coupon.NX;
                coupon.Dispose();
                c.Account.Save();
            }

            c.EnableActions();
        }
Пример #11
0
        public override void Execute(CommandCtx ctx)
        {
            var itemId = ctx.NextInt();

            var sCount = !ctx.Empty ? ctx.NextString() : null;
            var nCount = 1;

            if (sCount is object)
            {
                if (!int.TryParse(sCount, out nCount))
                {
                    ctx.Character.SendMessage("Unable to parse count.");
                    return;
                }
            }

            var character = ctx.Character;

            var nInvType = ItemConstants.GetInventoryType(itemId);

            if (InventoryManipulator.CountFreeSlots(character, nInvType) > 0)
            {
                var item = MasterManager.CreateItem(itemId);

                if (item is null)
                {
                    return;
                }

                if (item is GW_ItemSlotBundle isb)
                {
                    isb.nNumber = (short)Math.Min(nCount, item.SlotMax);
                }

                InventoryManipulator.InsertInto(character, item);
                character.SendPacket(CPacket.DropPickUpMessage_Item(itemId, nCount, true));
            }
        }
Пример #12
0
        public static void CreateCharacter(WvsLoginClient c, CInPacket p)
        {
            var newChar = Default();

            // create explorer:   Recv [CP_CreateNewCharacter] 16 00 06 00 70 6F 6F 70 69 65 01 00 00 00 00 00 24 4E 00 00 [4E 75 00 00] [03 00 00 00] [03 00 00 00] [86 DE 0F 00] [2F 2D 10 00] [85 5B 10 00] [8B DE 13 00] [00]
            // create resistance: Recv [CP_CreateNewCharacter] 16 00 06 00 64 6F 6F 64 6F 6F 00 00 00 00 00 00 84 4E 00 00 [30 75 00 00] [07 00 00 00] [01 00 00 00] [47 06 10 00] [00 00 00 00] [74 5D 10 00] [8C DE 13 00] [00]

            newChar.Stats.sCharacterName = p.DecodeString();

            var job = (short)p.Decode4();

            newChar.Stats.nJob = GameConstants.GetRealJobFromCreation(job);

            bool subJob = p.Decode2() > 0;                   //whether dual blade = 1 or adventurer = 0

            newChar.Stats.nSubJob = (short)(subJob ? 1 : 0); // doing it this way to reduce potential packet editing fuckery

            newChar.Stats.nFace = p.Decode4();
            var hairColor = p.Decode4();

            newChar.Stats.nHair = p.Decode4() + hairColor;
            newChar.Stats.nSkin = (byte)p.Decode4();

            var top    = p.Decode4();
            var bottom = p.Decode4();
            var shoes  = p.Decode4();
            var weapon = p.Decode4();

            newChar.Stats.nGender = p.Decode1();

            if (newChar.Stats.nSubJob == 1)
            {
                newChar.Stats.nJob = 400; // thief job
            }

            newChar.Stats.dwPosMap = GameConstants.GetStartingMap(newChar.Stats.nJob, newChar.Stats.nSubJob);

            newChar.Look.CopyStats(newChar.Stats);

            // TODO validate these against wz files
            newChar.Look.aEquip[5]  = top;
            newChar.Look.aEquip[6]  = bottom;
            newChar.Look.aEquip[7]  = shoes;
            newChar.Look.aEquip[11] = weapon;

            newChar.Insert(c.Account.ID);

            // create empty entries in mapping tables
            InitDefaultMappings(newChar.Stats.dwCharacterID);

            if (newChar.Stats.dwCharacterID < 0)
            {
                c.SendPacket(CreateCharacterPacket(false, null));
            }
            else
            {
                // add equips  // todo figure out if overalls have their own slot ID
                MasterManager.CreateNormalStatEquip(top)
                .SaveToDB(newChar.Stats.dwCharacterID, (short)(bottom > 0 ? -5 : -5));

                if (bottom > 0) // will be zero if its a champ that starts with an overall
                {
                    MasterManager.CreateNormalStatEquip(bottom)
                    .SaveToDB(newChar.Stats.dwCharacterID, -6);
                }

                MasterManager.CreateNormalStatEquip(shoes)
                .SaveToDB(newChar.Stats.dwCharacterID, -7);

                MasterManager.CreateNormalStatEquip(weapon)
                .SaveToDB(newChar.Stats.dwCharacterID, -11);

                var nWhitePot    = 2000002;
                var nManaPot     = 2000006;
                var nPotQuantity = (short)100;

                var item1 = MasterManager.CreateItem(nWhitePot) as GW_ItemSlotBundle;
                item1.nNumber = nPotQuantity;

                item1.SaveToDB(newChar.Stats.dwCharacterID, 1);

                var item2 = MasterManager.CreateItem(nManaPot) as GW_ItemSlotBundle;
                item2.nNumber = nPotQuantity;

                item2.SaveToDB(newChar.Stats.dwCharacterID, 2);

                c.SendPacket(CreateCharacterPacket(true, newChar));
            }
        }
Пример #13
0
        public QuestResultType TryExchange(int nIncMoney, QuestAct.ActItem[] aActItem)
        {
            if (nIncMoney == 0 && aActItem.Length <= 0)
            {
                return(QuestResultType.Success);
            }

            if (nIncMoney < 0 &&
                Parent.Stats.nMoney < nIncMoney)
            {
                return(QuestResultType.Failed_Meso);
            }

            foreach (var item in aActItem)
            {
                if (item.Item.Count > 0)
                {
                    if (!InventoryManipulator.HasSpace(Parent, item.Item.ItemID, (short)item.Item.Count))
                    {
                        return(QuestResultType.Failed_Inventory);                        // -> Etc inventory is full
                    }
                }
                else
                {
                    if (!InventoryManipulator.ContainsItem(Parent, item.Item.ItemID, (short)item.Item.Count))
                    {
                        return(QuestResultType.Failed_Unknown);                        // idk what code to give them
                    }
                }
            }

            Parent.Modify.GainMeso(nIncMoney);

            var weight = 0;

            foreach (var item in aActItem)
            {
                if (item.ProbRate != 0)
                {
                    weight += item.ProbRate;
                }
            }

            var itemGiven = false;

            foreach (var item in aActItem.Shuffle())
            {
                if (item.Item.Count < 0)
                {
                    InventoryManipulator.RemoveQuantity(Parent, item.Item.ItemID, (short)item.Item.Count);
                }
                else
                {
                    if (item.ProbRate == 0)
                    {
                        var newItem = MasterManager.CreateItem(item.Item.ItemID, false);
                        if (!newItem.IsEquip)
                        {
                            newItem.nNumber = (short)item.Item.Count;
                        }

                        InventoryManipulator.InsertInto(Parent, newItem);
                    }
                    else if (!itemGiven)
                    {
                        var rand = Constants.Rand.Next(0, weight);

                        if (rand < item.ProbRate)
                        {
                            var newItem = MasterManager.CreateItem(item.Item.ItemID, false);
                            if (!newItem.IsEquip)
                            {
                                newItem.nNumber = (short)item.Item.Count;
                            }

                            InventoryManipulator.InsertInto(Parent, newItem);
                            itemGiven = true;
                        }
                        else
                        {
                            weight -= item.ProbRate;
                        }
                    }
                }
            }

            return(QuestResultType.Success);
        }
Пример #14
0
        public override void Execute(CommandCtx ctx)
        {
            if (ctx.Empty)
            {
                ctx.Character.SendMessage("!test <ftype | event | makerskill>");
            }
            else
            {
                switch (ctx.NextString().ToLowerInvariant())
                {
                case "instance":
                    ctx.Character.SendMessage($"Instance: {ctx.Character.Field.nInstanceID}");
                    break;

                case "potential":
                    if (ctx.Empty)
                    {
                        return;
                    }

                    var itemid = ctx.NextInt();

                    var pots = new int[3];

                    var i = 0;
                    while (!ctx.Empty)
                    {
                        pots[i] = ctx.NextInt();
                        i      += 1;
                    }

                    var pItem = MasterManager.CreateItem(itemid, false) as GW_ItemSlotEquip;

                    if (pItem is null)
                    {
                        return;
                    }

                    pItem.nGrade = PotentialGradeCode.Visible_Unique;

                    pItem.nOption1 = (short)pots[0];
                    pItem.nOption2 = (short)pots[1];
                    pItem.nOption3 = (short)pots[2];

                    InventoryManipulator.InsertInto(ctx.Character, pItem);

                    break;

                case "sheepranch":
                    ctx.Character.Action.SetFieldInstance(BattlefieldData.BattleMap, 1);
                    break;

                case "sethorns":
                    ctx.Character.Buffs.AddSkillBuff((int)Skills.BOWMASTER_SHARP_EYES, 30);
                    ctx.Character.Buffs.AddSkillBuff((int)Skills.DUAL5_THORNS_EFFECT, 30);
                    break;

                case "makerskill":
                    ctx.Character.Skills.Add(new SkillEntry(1007)
                    {
                        nSLV = 1
                    });
                    break;

                case "ftype":
                    ctx.Character.SendMessage("Map Field Type: " + Enum.GetName(typeof(FieldType), ctx.Character.Field.Template.FieldType));
                    break;

                case "event":
                    MasterManager.EventManager.TryDoEvent(true);
                    break;

                case "shop":
                {
                    var pShop = new CShop(69);

                    pShop.Items.Add(new CShopItem(0));

                    pShop.AddDefaultItems();

                    MasterManager.ShopManager.InitUserShop(ctx.Character, 9900000, pShop);
                }
                break;

                case "balloon":
                    ctx.SendPacket(CPacket.BalloonMessage("Hello World!", 96));
                    break;

                default:
                    ctx.Character.SendMessage("No test command with that argument.");
                    break;
                }
            }

            return;

            foreach (var mob in ctx.Character.Field.Mobs)
            {
                ctx.Character.SendMessage($"{mob.nMobTemplateId}");
            }
            return;

            int imob = 0;

            foreach (var mob in ctx.Character.Field.Mobs.aMobGen)
            {
                if (mob.FH == 0)
                {
                    imob += 1;
                }
            }
            ctx.Character.SendMessage($"Mobs with FH 0: {imob}");
            ctx.Character.SendMessage($"Mobs In Map: {ctx.Character.Field.Mobs.Count} || Spawns: {ctx.Character.Field.Mobs.aMobGen.Count}");
            return;

            //foreach(var reactor in ctx.Character.Field.Reactors)
            //{
            //	reactor.IncreaseReactorState(0, 0);
            //}

            //return;
            ctx.Character.Action.SetFieldInstance(240060200, Constants.Rand.Next(), 0);

            return;

            var drop = new CDrop(ctx.Character.Position, ctx.Character.dwId)
            {
                ItemId = 100
            };

            drop.Position.X = drop.StartPosX;
            drop.CalculateY(ctx.Character.Field, drop.StartPosY);

            ctx.Character.Field.Drops.Add(drop);

            return;

            ctx.Character.SendMessage("" + Enum.GetName(typeof(FieldType), ctx.Character.Field.Template.FieldType));

            return;

            var p    = new COutPacket(SendOps.LP_Clock);
            var type = ctx.NextInt();

            p.Encode1((byte)type);
            switch (type)
            {
            case 0:                       // OnEventTimer
                p.Encode4(ctx.NextInt()); // nDuration

                break;

            case 1:                             // Clock
                p.Encode1((byte)ctx.NextInt()); // nHour
                p.Encode1((byte)ctx.NextInt()); // nMin
                p.Encode1((byte)ctx.NextInt()); // nSec

                break;

            case 2:                       // Timer
                p.Encode4(ctx.NextInt()); // tDuration (0 to disable the clock)

                break;

            case 3:                             // some kind of event timer also
                p.Encode1((byte)ctx.NextInt()); // bool (on/off)
                p.Encode4(ctx.NextInt());       // tDuration

                break;

            case 100:                           // cakepie event timer
                p.Encode1((byte)ctx.NextInt()); // bool (timer on/off)
                p.Encode1((byte)ctx.NextInt()); // nTimerType
                p.Encode4(ctx.NextInt());       // tDuration

                break;
            }

            ctx.Character.SendPacket(p);

            for (int i = 0; i < 2; i++)
            {
                var p2 = new COutPacket(SendOps.LP_CakePieEventResult);
                p2.Encode1(1);                         // bool -> continue while loop
                p2.Encode4(ctx.Character.Field.MapId); // fieldid
                p2.Encode4(4220176);                   // itemid
                p2.Encode1(25);                        // percentage
                p2.Encode1((byte)ctx.NextInt());       // eventstatus
                p2.Encode1((byte)(i + 1));             // nwinnerteam
                p2.Encode1(0);                         // end while loop

                ctx.SendPacket(p2);
            }

            return;

            //var poo = ctx.Character.Pets.Pets[0];

            //if (poo != null)
            //{
            //	ctx.Character.SendMessage($"{poo.Position.X} || {poo.Position.Y}");
            //}

            //var p = new COutPacket(SendOps.LP_AvatarMegaphoneUpdateMessage);
            //var x = new AvatarMegaphone
            //{
            //	nItemID = 05390000,
            //	sName = "pooodop",
            //	sMsgs = new string[5] { "one", "  two", " three", "    four", " five" },
            //	nChannelNumber = 1,
            //	bWhisper = true,
            //	alSender = ctx.Character.GetLook()
            //};

            //x.Encode(p);

            //MasterManager.CharacterPool.Broadcast(p);

            //var nItemID = ctx.NextInt();

            //ctx.Character.Modify.Inventory(inv =>
            //{
            //	for (short i = 1; i <= ctx.Character.InventoryEquip.SlotLimit; i++)
            //	{
            //		ctx.Character.InventoryEquip.Remove(i);
            //		var newItem = MasterManager.CreateItem(nItemID) as GW_ItemSlotEquip;
            //		newItem.nGrade = PotentialGradeCode.Visible_Unique;
            //		newItem.nOption1 = (int)PotentialLineIDs.LEARN_SKILL_HASTE;
            //		ctx.Character.InventoryEquip.Add(i, newItem);
            //		inv.Add(InventoryType.Equip, i, newItem);
            //	}

            //	var magnifyingGlass = MasterManager.CreateItem(02460003) as GW_ItemSlotBundle;
            //	magnifyingGlass.nNumber = 500; // pretty sure i can override the 100 slotmax lol
            //	ctx.Character.InventoryConsume.Remove(15);
            //	ctx.Character.InventoryConsume.Add(15, magnifyingGlass);

            //	inv.Remove(InventoryType.Consume, 15);
            //	inv.Add(InventoryType.Consume, 15, magnifyingGlass);

            //});

            //return;

            //foreach (var item in ctx.Character.InventoryEquip)
            //{
            //	ctx.Character.Action.ConsumeItem.UseMagnifyingGlass(15, item.Key);
            //	item.Value.sTitle = $"{item.Value.nOption1}|{item.Value.nOption2}";
            //}

            //ctx.Character.InventoryEquip.RemoveAllItems(ctx.Character); // gotta cc for this to take effect so we can look then cc to clean inv

            // ctx.Character.SendPacket(CPacket.UserOpenUI((UIWindow)ctx.NextInt()));

            //ctx.Character.Field.bPauseSpawn = !ctx.Character.Field.bPauseSpawn;

            //ctx.Character.Modify.Stats(mod => mod.SP += (short)ctx.NextInt());

            //var p = new COutPacket(SendOps.LP_UserEffectLocal);

            //for (int i = 8; i >= 1; i--)
            //{
            //    p.Encode4(i == statup.getPosition() ? statup.getValue() : 0);
            //}

            //p.Encode1(1); // skill use
            //p.Encode4(22160000); // skillID
            //p.Encode1(100); // nCharLevel
            //p.Encode1(1); // nSLV
            //p.Encode1(1);

            //ctx.SendPacket(p);

            //ctx.Character.SendMessage($"You have {ctx.Character.Buffs.Count} buffs.");

            //var pChar = ctx.Character;

            //if (pChar.PlayerGuild == null)
            //{
            //    var name = ctx.NextString();
            //    MasterManager.GuildManager.Add(new Guild(name, pChar.dwId));
            //}
            //else
            //{
            //    var p = new COutPacket(SendOps.LP_GuildResult);
            //    p.Encode1((byte)ctx.NextInt());

            //    pChar.SendPacket(p);
            //}
            //var storage = ServerApp.Container.Resolve<CenterStorage>();
            //var sub = storage.Multiplexer().GetSubscriber();

            //sub.Publish("donate", $"{character.AccId}/5000");

            // character.Modify.GainNX(1000);

            // character.SendPacket(CPacket.OpenClassCompetitionPage());

            //var stat = new SecondaryStat();

            //var entry = new SecondaryStatEntry()
            //{
            //    nValue = 10,
            //    rValue = 2001002,
            //    tValue = 110000,
            //};

            //stat.Add(SecondaryStatType.MagicGuard, entry);
            //stat.Add(SecondaryStatType.Flying, entry);

            //character.SendPacket(CPacket.TemporaryStatSetLocal(stat));
            //character.Field.Broadcast(CPacket.UserTemporaryStatSet(stat, character.CharId));

            //var summon = new CSummon();
            //summon.Parent = character;
            //summon.dwSummonedId = 2330810;
            //summon.nSkillID = 14001005;

            //summon.Position.Position.X = character.Position.Position.X;
            //summon.Position.Position.Y = character.Position.Position.Y;
            //summon.Position.Foothold = character.Position.Foothold;

            //summon.nCharLevel = character.Stats.nLevel;
            //summon.nSLV = 1;
            //summon.bMoveAbility = 1;
            //summon.bAssistType = 1;
            //summon.nEnterType = 1;

            //character.Summons.Add(summon);

            //character.SendPacket(CPacket.TradeMoneyLimit(true));
            //character.SendPacket(CPacket.WarnMessage("YEOOOOOO THIS IS A WARNING BOY"));
            //character.SendPacket(CPacket.AdminShopCommodity(9900000));
            //character.SendPacket(CPacket.StandAloneMode(true));
            //character.SendPacket(CPacket.LogoutGift());

            //character.SendPacket(CPacket.UserHireTutor(true));
            //character.SendPacket(CPacket.UserTutorMsg(Constants.ServerMessage2,400,60000));

            //character.SendPacket(CPacket.HontaleTimer(0,5));
            //character.SendPacket(CPacket.HontaleTimer(1, 5));
            //character.SendPacket(CPacket.HontaleTimer(2, 5));
            //character.SendPacket(CPacket.HontaleTimer(3, 5));

            //character.SendPacket(CPacket.HontailTimer(0,69));
            //character.SendPacket(CPacket.HontailTimer(1, 69));
            //character.SendPacket(CPacket.HontailTimer(0, 0));

            //var town = new CTownPortal();
            //town.dwCharacterID = character.dwId;
            //town.Position.X = character.Position.X;
            //town.Position.Y = character.Position.Y;

            //character.Field.TownPortals.Add(town);

            //character.SendPacket(CPacket.DragonEnterField(character.dwId, character.Position.X, character.Position.Y, 0, 2218));
            //character.Dragon = new CDragon(character);
            //character.Dragon.JobCode = 2218;
            //character.Dragon.Position.X = character.Position.X;
            //character.Dragon.Position.Y = character.Position.Y;


            //    var gate1 = new COpenGate()
            //    {
            //        dwCharacterID = character.dwId,
            //    };

            //    gate1.Position.X = character.Position.X;
            //    gate1.Position.Y = character.Position.Y;

            //    character.Field.OpenGates1.Add(gate1);

            //    var gate2 = new COpenGate()
            //    {
            //        dwCharacterID = character.dwId,
            //    };

            //    gate2.Position.X = character.Position.X;
            //    gate2.Position.X -= 250;

            //    gate2.Position.Y = character.Position.Y;

            //    character.Field.OpenGates2.Add(gate2);


            //character.SendPacket(CPacket.StageChange("ThemeBack1.img", 0));

            //character.Field.Employees.RemoveAt(0);

            //character.SendPacket(CPacket.SetBackgroundEffect(2, 100000000, 1, 30 * 1000));

            //character.SendPacket(CPacket.Desc(true));

            //character.SendPacket(CPacket.StalkResult(character.dwId, character.Stats.sCharacterName, character.Position.X, character.Position.Y));

            //character.SendPacket(CPacket.PlayJukeBox("Hydromorph"));
            //character.SendPacket(CPacket.BlowWeather(0, 5120000, "Hello Twitch!!!"));

            //character.SendPacket(CPacket.AntiMacroResult(6, "SnitchNigga")); //Crash
            //character.SendPacket(CPacket.AntiMacroResult(7, "SnitchNigga")); //This dude reported you !

            //Diemension mirror reeeeeeeeeeeeeee
            //var p = NpcScript.ScriptMessageHeader(0, 9900000, ScriptMsgType.AskSlideMenu);
            //p.Encode4(0); //dlg type
            //p.Encode4(0); //index?
            //p.EncodeString("Hello World");
            //character.SendPacket(p);

            //var pet = new CPet(ctx.Character);
            //pet.nIdx = 0;
            //pet.liPetLockerSN = 9001;
            //pet.dwTemplateID = 5000102;
            //pet.sName = "Charlie";
            //pet.Position.X = character.Position.X;
            //pet.Position.Y = character.Position.Y;

            //ctx.Character.Pets.Add(pet.liPetLockerSN, pet);
        }
Пример #15
0
        private static void BuyItem(Character pChar, short nPos, int nItemId, short nCount)
        {
            var cShop = pChar.Socket.ActiveShop;

            // price is 0 for invis items
            if (!cShop.ContainsItem(nItemId) ||
                cShop.GetItemPrice(nItemId) <= 0 ||
                cShop.GetItemLevelLimited(nItemId) > pChar.Stats.nLevel)
            {
                pChar.SendMessage("Trying to buy an item that doesn't exist in the shop.");
                pChar.SendPacket(CPacket.CShopDlg.ShopResult(ShopRes.BuyUnknown));
                return;
            }

            nCount = ItemConstants.is_treat_singly(nItemId) ? (short)1 : nCount;

            var nPricePerCount = cShop.GetItemPrice(nItemId);
            var nFinalPrice    = nPricePerCount * nCount;

            if (nFinalPrice > pChar.Stats.nMoney)
            {
                pChar.SendMessage("Trying to buy an item without enough money.");
                pChar.SendPacket(CPacket.CShopDlg.ShopResult(ShopRes.BuyNoMoney));
                return;
            }

            var nInvType = ItemConstants.GetInventoryType(nItemId);

            if (InventoryManipulator.CountFreeSlots(pChar, nInvType) < 1)
            {
                pChar.SendMessage("Please make some space in your inventory.");
                pChar.SendPacket(CPacket.CShopDlg.ShopResult(ShopRes.BuyUnknown));
                return;
            }

            var pItem = MasterManager.CreateItem(nItemId, false);

            var slotmax = pItem.SlotMax;

            if (pChar.Skills.Get(false,
                                 (int)Skills.NIGHTWALKER_JAVELIN_MASTERY,
                                 (int)Skills.ASSASSIN_JAVELIN_MASTERY) is SkillEntry se)
            {
                slotmax += (short)se.Y_Effect;
            }

            if (slotmax < nCount * cShop.GetItemQuantity(nItemId))
            {
                pChar.SendMessage("Unable to purchase more than one slot of items at a time.");
                pChar.SendPacket(CPacket.CShopDlg.ShopResult(ShopRes.BuyUnknown));
                return;
            }

            pChar.SendPacket(CPacket.CShopDlg.ShopResult(ShopRes.BuySuccess));

            pItem.nNumber = (short)(pItem.IsRechargeable ? slotmax : nCount * cShop.GetItemQuantity(nItemId));

            pChar.SendMessage("final price: " + nFinalPrice);

            InventoryManipulator.InsertInto(pChar, pItem);
            pChar.Modify.GainMeso(-nFinalPrice, false);
        }
Пример #16
0
        private static void HandleCreateItemOp(Character pChar, int nItemID, bool bStimulantUsed, List <int> aGems)
        {
            // BEGIN VERIFICATION

            //var pMakerItem = MasterManager.EtcTemplates.MakerData(nItemID);
            var makerItem = MasterManager.ItemMakeTemplates[nItemID];

            // verify maker item exists
            if (makerItem is null)
            {
                pChar.SendMessage("Null item maker template.");
                return;
            }

            // verify player is high enough level to use recipe
            if (makerItem.ReqLevel > pChar.Stats.nLevel + 6)
            {
                pChar.SendMessage("Verify the item level you're trying to craft is no more than 6 above your own.");
                return;
            }

            // verify player has enough meso
            if (makerItem.Meso > pChar.Stats.nMoney)
            {
                pChar.SendMessage("Verify you have the correct amount of mesos.");
                return;
            }

            var pCharMakerSkill = pChar.Skills.Get(Common.GameLogic.SkillLogic.get_novice_skill_as_race(Common.GameLogic.SkillLogic.NoviceSkillID.MakerSkill, pChar.Stats.nJob));

            // verify player maker skill level is high enough
            if (makerItem.ReqSkillLevel > (pCharMakerSkill?.nSLV ?? 0))
            {
                pChar.SendMessage($"Verify maker skill level. {makerItem.ReqSkillLevel} < {(pCharMakerSkill?.nSLV ?? 0)}");
                return;
            }

            var(nStimulantItemSlot, pStimulantItem) = InventoryManipulator.GetAnyItem(pChar, InventoryType.Etc, makerItem.CatalystID);

            // verify stimulant (catalyst) exists in player inventory
            if (bStimulantUsed && pStimulantItem is null)
            {
                pChar.SendMessage("Verify you possess the correct stimulant item.");
                return;
            }

            // verify equip slot availability
            if (InventoryManipulator.CountFreeSlots(pChar, InventoryType.Equip) < 1)
            {
                pChar.SendMessage("Please make more room in your equip inventory.");
                return;
            }

            if (InventoryManipulator.CountFreeSlots(pChar, InventoryType.Etc) < makerItem.RandomReward.Length)
            {
                pChar.SendMessage("Please make more room in your etc inventory.");
                return;
            }

            // verify required items exist in player inventory
            if (makerItem.Recipe.Any(item => !InventoryManipulator.ContainsItem(pChar, item.ItemID, (short)item.Count)))
            {
                pChar.SendMessage("Verify you possess all the required components.");
                return;
            }

            var aGemItemIds   = new List <int>();
            var aGemItemTypes = new List <int>();

            // remove duplicate items/types and get item slots for gems
            foreach (var entry in aGems)
            {
                var(nGemSlot, pGemItem) = InventoryManipulator.GetAnyItem(pChar, InventoryType.Etc, entry);

                if (pGemItem is null || nGemSlot == 0 || !(pGemItem.Template is GemEffectTemplate))
                {
                    continue;
                }

                // idk how it would be 0 but we check anyway
                if (!aGemItemTypes.Contains(entry / 100) &&
                    !aGemItemIds.Contains(pGemItem.nItemID) &&
                    pGemItem.nNumber > 0)
                {
                    aGemItemIds.Add(pGemItem.nItemID);
                    aGemItemTypes.Add(entry / 100);
                }
            }

            // END VERIFICATION

            // BEGIN RECIPE PROCESSING

            // remove meso cost from inventory
            if (makerItem.Meso > 0)
            {
                pChar.Modify.GainMeso(-makerItem.Meso);
            }

            // remove stimulant from inventory
            if (bStimulantUsed)
            {
                InventoryManipulator.RemoveQuantity(pChar, pStimulantItem.nItemID, 1);
            }

            // remove recipe items from inventory
            foreach (var item in makerItem.Recipe)
            {
                InventoryManipulator.RemoveQuantity(pChar, item.ItemID, (short)item.Count);
            }

            var bSuccess = true;

            if (bStimulantUsed && Constants.Rand.Next(100) >= 90)
            {
                bSuccess = false;
            }
            else
            {
                // BEGIN MAKER ITEM CREATION

                var pNewItemRaw = MasterManager.CreateItem(makerItem.TemplateId);

                if (pNewItemRaw is GW_ItemSlotEquip pNewItemEquip)
                {
                    pNewItemEquip.RemainingUpgradeCount = (byte)makerItem.TUC;

                    // remove gems from inventory
                    foreach (var nGemItemId in aGemItemIds)
                    {
                        var pGemItemRaw = InventoryManipulator.GetAnyItem(pChar, InventoryType.Etc, nGemItemId).Item2;

                        if (pGemItemRaw.Template is GemEffectTemplate pGemItem)
                        {
                            // gems only have one modifier each
                            if (pGemItem.incPAD > 0)
                            {
                                pNewItemEquip.niPAD += (short)(pGemItem.incPAD * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incPDD > 0)
                            {
                                pNewItemEquip.niPDD += (short)(pGemItem.incPDD * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incMAD > 0)
                            {
                                pNewItemEquip.niMAD += (short)(pGemItem.incMAD * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incMDD > 0)
                            {
                                pNewItemEquip.niMDD += (short)(pGemItem.incMDD * (bStimulantUsed ? 2 : 1));
                            }

                            else if (pGemItem.incSTR > 0)
                            {
                                pNewItemEquip.niSTR += (short)(pGemItem.incSTR * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incINT > 0)
                            {
                                pNewItemEquip.niINT += (short)(pGemItem.incINT * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incDEX > 0)
                            {
                                pNewItemEquip.niDEX += (short)(pGemItem.incDEX * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incLUK > 0)
                            {
                                pNewItemEquip.niLUK += (short)(pGemItem.incLUK * (bStimulantUsed ? 2 : 1));
                            }

                            else if (pGemItem.incACC > 0)
                            {
                                pNewItemEquip.niACC += (short)(pGemItem.incACC * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incEVA > 0)
                            {
                                pNewItemEquip.niEVA += (short)(pGemItem.incEVA * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incMaxHP > 0)
                            {
                                pNewItemEquip.niMaxHP += (short)(pGemItem.incMaxHP * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incMaxMP > 0)
                            {
                                pNewItemEquip.niMaxMP += (short)(pGemItem.incMaxMP * (bStimulantUsed ? 2 : 1));
                            }

                            else if (pGemItem.incJump > 0)
                            {
                                pNewItemEquip.niJump += (short)(pGemItem.incJump * (bStimulantUsed ? 2 : 1));
                            }
                            else if (pGemItem.incSpeed > 0)
                            {
                                pNewItemEquip.niSpeed += (short)(pGemItem.incSpeed * (bStimulantUsed ? 2 : 1));
                            }

                            else if (pGemItem.incReqLevel < 0)
                            {
                                pNewItemEquip.nLevel = (byte)(pNewItemEquip.nLevel + (pGemItem.incReqLevel * (bStimulantUsed ? 2 : 1)));
                            }

                            else if (pGemItem.RandOption > 0)
                            {
                                var gX = new GaussianRandom();

                                var nRange = pGemItem.RandOption * (bStimulantUsed ? 2 : 1);

                                if (pNewItemEquip.niMaxHP > 0)
                                {
                                    pNewItemEquip.niMaxHP = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niMaxHP, nRange, false));
                                }
                                if (pNewItemEquip.niMaxMP > 0)
                                {
                                    pNewItemEquip.niMaxMP = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niMaxMP, nRange, false));
                                }

                                if (pNewItemEquip.niPAD > 0)
                                {
                                    pNewItemEquip.niPAD = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niPAD, nRange, false));
                                }
                                if (pNewItemEquip.niMAD > 0)
                                {
                                    pNewItemEquip.niMAD = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niMAD, nRange, false));
                                }
                                if (pNewItemEquip.niPDD > 0)
                                {
                                    pNewItemEquip.niPDD = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niPDD, nRange, false));
                                }
                                if (pNewItemEquip.niMDD > 0)
                                {
                                    pNewItemEquip.niMDD = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niMDD, nRange, false));
                                }

                                if (pNewItemEquip.niSpeed > 0)
                                {
                                    pNewItemEquip.niSpeed = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niSpeed, nRange, false));
                                }
                                if (pNewItemEquip.niJump > 0)
                                {
                                    pNewItemEquip.niJump = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niJump, nRange, false));
                                }
                            }
                            // pNewItemEquip.ApplyRandStatOption(pGemItem.RandOption * (bStimulantUsed ? 2 : 1), false);
                            else if (pGemItem.RandStat > 0)
                            {
                                var gX = new GaussianRandom();

                                var nRange = pGemItem.RandStat * (bStimulantUsed ? 2 : 1);

                                if (pNewItemEquip.niSTR > 0)
                                {
                                    pNewItemEquip.niSTR = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niSTR, nRange, false));
                                }
                                if (pNewItemEquip.niLUK > 0)
                                {
                                    pNewItemEquip.niLUK = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niLUK, nRange, false));
                                }
                                if (pNewItemEquip.niINT > 0)
                                {
                                    pNewItemEquip.niINT = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niINT, nRange, false));
                                }
                                if (pNewItemEquip.niDEX > 0)
                                {
                                    pNewItemEquip.niDEX = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niDEX, nRange, false));
                                }

                                if (pNewItemEquip.niACC > 0)
                                {
                                    pNewItemEquip.niACC = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niACC, nRange, false));
                                }
                                if (pNewItemEquip.niEVA > 0)
                                {
                                    pNewItemEquip.niEVA = (short)Math.Max(0, gX.GaussianDistributionVariation(pNewItemEquip.niEVA, nRange, false));
                                }
                            }
                        }
                    }

                    InventoryManipulator.InsertInto(pChar, pNewItemEquip);
                }
                else
                {
                    pNewItemRaw.nNumber = (short)makerItem.ItemNum;
                    InventoryManipulator.InsertInto(pChar, pNewItemRaw);
                }

                // remove gems if any
                foreach (var nGemItemId in aGemItemIds)
                {
                    InventoryManipulator.RemoveQuantity(pChar, nGemItemId, 1);                     //InventoryManipulator.RemoveFrom(pChar, (byte)InventoryType.Etc, itemSlot, 1);
                }

                foreach (var entry in makerItem.RandomReward)
                {
                    if (Constants.Rand.Next(100) >= entry.Prob)
                    {
                        continue;
                    }

                    var pRandRewardItem = MasterManager.CreateItem(entry.ItemID);

                    pRandRewardItem.nNumber = (short)entry.ItemNum;

                    InventoryManipulator.InsertInto(pChar, pRandRewardItem);
                }

                // END MAKER ITEM CREATION
            }

            // END RECIPE PROCESSING

            // SEND RESPONSE PACKETS

            pChar.SendPacket(CreateItemResponse(bSuccess, bStimulantUsed, makerItem, aGemItemIds));

            pChar.SendPacket(MakerItemEffectLocal(bSuccess));
            pChar.Field.Broadcast(MakerItemEffectRemote(pChar.dwId, bSuccess));
        }