public static COutPacket UserQuestResult(QuestResultType op, QuestEntry pQuest, int nNpcTemplateId = 0, short usNextQuestID = 0)
            {
                var p = new COutPacket(SendOps.LP_UserQuestResult);

                p.Encode1(op);

                switch (op)
                {
                case QuestResultType.Failed_Equipped:
                case QuestResultType.Failed_Meso:
                case QuestResultType.Failed_OnlyItem:
                case QuestResultType.Failed_Unknown:
                    return(p);

                case QuestResultType.Failed_Inventory:
                case QuestResultType.Reset_QuestTimer:
                case QuestResultType.Failed_TimeOver:
                    p.Encode2(pQuest.nQuestID);
                    return(p);

                case QuestResultType.Success:
                    p.Encode2(pQuest.nQuestID);
                    p.Encode4(nNpcTemplateId);
                    p.Encode2(usNextQuestID);                             // 0 if no next
                    break;
                }

                return(p);
            }
Exemple #2
0
 public void EncodeRingRecords(COutPacket p)
 {
     p.Encode2(0);
     p.Encode2((short)lFriendRecord.Count);
     lFriendRecord.ForEach(ring => ring.Encode(p));
     p.Encode2(0);
 }
Exemple #3
0
        public void EncodeInitData(COutPacket p)
        {
            p.Encode4(dwId);
            p.Encode4(nSkillID);
            p.Encode1(nCharLevel);
            p.Encode1(nSLV);
            Position.EncodePos(p);
            p.Encode1(Position.MoveAction);
            p.Encode2(Position.Foothold);
            p.Encode1((byte)nMoveAbility);
            p.Encode1((byte)nAssistType);
            p.Encode1((byte)nEnterType);

            var mirrorTarget = nSkillID == (int)Skills.DUAL5_DUMMY_EFFECT;

            p.Encode1(mirrorTarget);
            if (mirrorTarget)
            {
                Parent.GetLook().Encode(p);
            }
            else if (nSkillID == (int)Skills.MECHANIC_TESLA_COIL)
            {
                p.Encode1((byte)nTeslaCoilState);

                if (nTeslaCoilState == TeslaCoilType.Leader)
                {
                    foreach (var item in Field.Summons
                             .Where(item => item.nSkillID == (int)Skills.MECHANIC_TESLA_COIL && dwParentID == item.dwParentID))
                    {
                        p.Encode2(item.Position.X);
                        p.Encode2(item.Position.Y);
                    }
                }
            }
        }
Exemple #4
0
        public void EncodeItems(COutPacket p)
        {
            var nCount = (byte)Inventory.GetAll().Count;

            p.Encode1(nCount);

            if (nCount <= 0)
            {
                p.Encode1(0);
                return;
            }

            foreach (var item in Inventory.GetAll())
            {
                var bundles = 1;

                if (item.Item is GW_ItemSlotBundle isb)
                {
                    bundles = item.NumberOfBundles; // there is some sort of extra handling here but f**k that rn
                }

                p.Encode2(item.NumberOfBundles);
                p.Encode2(item.ItemsInBundle);
                p.Encode4(item.Price);
                item.Item.RawEncode(p);
            }
        }
        public override void RawEncode(COutPacket p, bool bFromCS = false)
        {
            p.Encode1(3);

            p.Encode4(nItemID);

            var bCashItem = liCashItemSN != 0;

            p.Encode1(bCashItem);

            if (bCashItem)             // arent all pets cash items?? o__o
            {
                p.Encode8(liCashItemSN);
            }

            p.EncodeDateTime(tDateExpire);

            p.EncodeStringFixed(sPetName, 13);
            p.Encode1(nLevel);
            p.Encode2(nTameness);
            p.Encode1(nRepleteness);
            if (tDateDead == DateTime.MaxValue)
            {
                p.Encode8(0);
            }
            else
            {
                p.EncodeDateTime(tDateDead);
            }
            p.Encode2(nPetAttribute);
            p.Encode2(usPetSkill);
            p.Encode4(nRemainLife);
            p.Encode2(nAttribute);
        }
Exemple #6
0
        public void Encode(COutPacket p)
        {
            switch ((MobStatType)MobStatTypeID)
            {
            case MobStatType.Burned:
                p.Encode4(0);                         // size
                //tCur = (int)v45;
                //do
                //{
                //    v47 = ZList < MobStat::BURNED_INFO >::AddTail(&v4->lBurnedInfo);
                //    v47->dwCharacterID = CInPacket::Decode4(v8);
                //    v47->nSkillID = CInPacket::Decode4(v8);
                //    v47->nDamage = CInPacket::Decode4(v8);
                //    v47->tInterval = CInPacket::Decode4(v8);
                //    v47->tEnd = CInPacket::Decode4(v8);
                //    v48 = CInPacket::Decode4(v8);
                //    v49 = tCur-- == 1;
                //    v47->nDotCount = v48;
                //    v47->tLastUpdate = v7;
                //}
                //while (!v49);
                break;

            case MobStatType.Disable:
                p.Encode1(false);                         // bInvincible
                p.Encode1(false);                         // bDisable
                break;

            default:
                p.Encode2(nOption);
                p.Encode4(rOption);
                p.Encode2(nDurationSeconds);                         // seconds
                break;
            }
        }
Exemple #7
0
        public void EncodeInitData(COutPacket p)
        {
            p.Encode4(dwMobId);
            p.Encode1(5); //  nCalcDamageIndex | Controller
            p.Encode4(dwTemplateId);

            //CMob::SetTemporaryStat
            CPacket.MobStat__EncodeTemporary(p, 0, 0, 0);

            //CMob::Init
            p.Encode2(Position.Position.X); //m_ptPosPrev.x
            p.Encode2(Position.Position.Y); //m_ptPosPrev.y
            p.Encode1(0 & 1 | 2 * 2);       //mob.Position.Stance); //m_nMoveAction
            p.Encode2(Position.Foothold);   //  m_nFootholdSN
            p.Encode2(Position.Foothold);   //  m_nHomeFoothold

            var m_nSummonType = unchecked ((byte)-2);

            p.Encode1(m_nSummonType); //m_nSummonType

            //if(m_nSummonType == -3 || m_nSummonType >= 0)
            //   p.Encode4(0); //m_dwSummonOption

            p.Encode1(0); //m_nTeamForMCarnival
            p.Encode4(0); //nEffectItemID
            p.Encode4(0); //m_nPhase
        }
        //Eventually move this out of socket
        public void Initialize(ushort version)
        {
            m_version = version;

            m_siv = new MapleIV(0xBADF00D);
            m_riv = new MapleIV(0XDEADBEEF);

            //m_siv = new MapleIV(0x52616A61); //Raja
            //m_riv = new MapleIV(0x6E523078); //nR0x

            using (var p = new COutPacket())
            {
                p.Encode2(0x0E);
                p.Encode2((short)version);
                p.EncodeString("1");
                p.Encode4((int)m_riv.Value);
                p.Encode4((int)m_siv.Value);
                p.Encode1(8);

                var buffer = p.ToArray();

                SendRaw(buffer);
            }

            Receive();
        }
Exemple #9
0
            public static COutPacket WorldInformation(byte nWorldID, string sName, byte nChannelNo, CLoginBalloon[] balloons)
            {
                var p = new COutPacket();

                //v6 = ZArray<CLogin::WORLDITEM>
                p.Encode2((short)SendOps.LP_WorldInformation);
                p.Encode1(nWorldID);              //v4 [Server ID]
                p.EncodeString(sName);            //WORLDITEM->sName
                p.Encode1(1);                     //v6->nWorldState | 0 = normal 1 = hot? 2 = new
                p.EncodeString("Event Message?"); //sWorldEventDesc
                p.Encode2(100);                   //v6->nWorldEventEXP_WSE
                p.Encode2(100);                   //v6->nWorldEventDrop_WSE
                p.Encode1(0);                     //v6->nBlockCharCreation

                p.Encode1(nChannelNo);            //v9

                for (byte i = 0; i < nChannelNo; i++)
                {
                    //v11 =  ZArray<CLogin::CHANNELITEM>
                    p.EncodeString($"{sName}-{i + 1}");
                    p.Encode4(0);                     //v11->nUserNo
                    p.Encode1(nWorldID);              //v11->nWorldID
                    p.Encode1(i);                     //v11->nChannelID
                    p.Encode1(0);                     //v11->bAdultChannel
                }

                p.Encode2((short)balloons.Length);                  //v2->m_nBalloonCount

                foreach (var b in balloons)
                {
                    b.Encode(p);
                }

                return(p);
            }
        private COutPacket OpenGate(short ptX, short ptY)
        {
            var p = new COutPacket(SendOps.LP_OpenGate);

            p.Encode2(ptX);
            p.Encode2(ptY);
            return(p);
        }
        public void EncodeCards(COutPacket p)
        {
            p.Encode2((short)Count);

            foreach (var card in this)
            {
                p.Encode2(card.usCardID);
                p.Encode1(card.nCardCount);
            }
        }
Exemple #12
0
        public static void Encode(COutPacket p)
        {
            aLimitGoods.Add(new LimitGoods()
            {
                nItemID         = 1040077,
                nState          = -1,
                nOriginCount    = 100,
                nRemainCount    = 100,
                dwConditionFlag = 3,
                nDateStart      = 10,
                nDateEnd        = 25,
                nHourStart      = 0,
                nHourEnd        = 0,
            });

            aLimitGoods[1].nSN[0] = 20400012;

            //for (int i = 0; i < 7; i++)
            //{
            //	aLimitGoods[0].abWeek[i] = 1;
            //}

            var stockItems = new List <KeyValuePair <int, int> >();

            foreach (var item in aLimitGoods)
            {
                foreach (var itemSerialNumber in item.nSN)
                {
                    if (itemSerialNumber != 0)
                    {
                        stockItems.Add(new KeyValuePair <int, int>(itemSerialNumber, -1));
                    }
                }
            }

            //p.Encode2((short)stockItems.Count);

            //foreach (var item in stockItems)
            //{
            //	p.Encode4(item.Key);
            //	p.Encode4(item.Value);
            //}

            p.Encode2(1);
            p.Encode4(20400012);
            p.Encode4(-1);

            p.Encode2((short)aLimitGoods.Count);

            foreach (var item in aLimitGoods)
            {
                item.Encode(p);
            }
        }
Exemple #13
0
            }             // DONE

            /// <summary>
            /// Broadcasted to every character in every map that contains a member of the guild
            /// </summary>
            /// <param name="dwCharID"></param>
            /// <param name="g"></param>
            /// <returns></returns>
            public static COutPacket GuildMarkChanged(int dwCharID, Guild g)             // CUserRemote::OnGuildNameChanged
            {
                var p = new COutPacket(SendOps.LP_UserGuildMarkChanged);

                p.Encode4(dwCharID);
                p.Encode2(g.GuildMarkBg);
                p.Encode1(g.GuildMarkBgColor);
                p.Encode2(g.GuildMark);
                p.Encode1(g.GuildMarkColor);
                return(p);
            }             // DONE
        public void EncodeMedalQuests(COutPacket p)
        {
            var list         = this.Where(q => q.nQuestID >= 29000 && q.nQuestID <= 30000);
            var questEntries = list as QuestEntry[] ?? list.ToArray();

            p.Encode2((short)questEntries.Length);
            foreach (var item in questEntries)
            {
                p.Encode2(item.nQuestID);
            }
        }
Exemple #15
0
            }             // DONE

            /// <summary>
            /// Sent to all guild members after the guild mark is changed
            /// </summary>
            /// <returns></returns>
            public static COutPacket SetMark_Done(Guild g)
            {
                var p = new COutPacket(SendOps.LP_GuildResult);

                EncodeHeader(p, GuildOps.GuildRes_SetMark_Done);
                p.Encode4(g.GuildID);
                p.Encode2(g.GuildMarkBg);
                p.Encode1(g.GuildMarkBgColor);
                p.Encode2(g.GuildMark);
                p.Encode1(g.GuildMarkColor);
                return(p);
            }             // DONE
Exemple #16
0
        public override COutPacket MakeEnterFieldPacket()
        {
            var p = new COutPacket(SendOps.LP_DragonEnterField);

            p.Encode4(dwParentId);
            p.Encode4(Position.X);
            p.Encode4(Position.Y);
            p.Encode1(Position.MoveAction);
            p.Encode2(0);             //Not used from what it seems
            p.Encode2(Parent.Stats.nJob);
            return(p);
        }
Exemple #17
0
            public static COutPacket MobCtrlAck(int dwMobId, short nMobCtrlSN, bool bNextAttackPossible, short nMP, byte nSkillCommand, byte nSLV)
            {
                var p = new COutPacket(SendOps.LP_MobCtrlAck);

                p.Encode4(dwMobId);
                p.Encode2(nMobCtrlSN);
                p.Encode1(bNextAttackPossible);
                p.Encode2(nMP);                 //CMob->nMP lol
                p.Encode1(nSkillCommand);
                p.Encode1(nSLV);
                return(p);
            }
Exemple #18
0
            public static COutPacket MobMoveAck(int dwMobID, short nMobCtrlSN, bool bNextAttackPossible, int nMP, SkillCommand pCommand)
            {
                var p = new COutPacket(SendOps.LP_MobCtrlAck);

                p.Encode4(dwMobID);
                p.Encode2(nMobCtrlSN);
                p.Encode1(bNextAttackPossible);
                p.Encode2((short)Math.Min(short.MaxValue, nMP));
                p.Encode1((byte)pCommand.nSkillID);
                p.Encode1((byte)pCommand.nSLV);
                return(p);
            }
Exemple #19
0
 public void Encode(COutPacket p)
 {
     p.Encode4(dwTemplateID);
     p.EncodeString(sName ?? "Nameless Pet");
     p.Encode8(liPetLockerSN);
     p.Encode2(Position.X);
     p.Encode2(Position.Y);
     p.Encode1(Position.MoveAction);
     p.Encode2(Position.Foothold);
     p.Encode1(nNameTag);
     p.Encode1(nChatBalloon);
 }
Exemple #20
0
        public void EncodeInitData(COutPacket p)
        {
            p.Encode2(X);             //m_ptPosPrev.x
            p.Encode2(Cy);            //m_ptPosPrev.y

            p.Encode1(!F);            // & 1 | 2 * 2); //m_nMoveAction | life.getF() == 1 ? 0 : 1
            p.Encode2(Foothold);      //dwSN Foothold

            p.Encode2(Rx0);           //m_ptPosPrev.x
            p.Encode2(Rx1);           //m_ptPosPrev.y

            p.Encode1(true);          //I hope this works lol | //mplew.write((show && !life.isHidden()) ? 1 : 0);
        }
Exemple #21
0
        protected override void OnUserEnter(Character pUser)
        {
            base.OnUserEnter(pUser);

            if (nState == 1)
            {
                var entryPacket = new COutPacket(SendOps.LP_SnowBallState);
                EncodeState(entryPacket);
                entryPacket.Encode2(DAMAGE_SNOWBALL);
                entryPacket.Encode2((short)nDamageSnowMan[0]);
                entryPacket.Encode2((short)nDamageSnowMan[1]);
                pUser.SendPacket(entryPacket);
            }
        }
            public static COutPacket CouponAddItem(int itemId)
            {
                var p = new COutPacket(SendOps.LP_CashShopCashItemResult);

                p.Encode1((byte)CashItemOps.CashItemRes_UseCoupon_Done);
                p.Encode4(0);
                p.Encode4(1);
                p.Encode2(1);
                p.Encode2(0x1A);
                p.Encode4(itemId);
                p.Encode4(0);

                return(p);
            }
        public void EncodeForRemote(COutPacket packet)
        {
            EncodeMask(packet);

            EncodeIf(SecondaryStatFlag.Speed, s => packet.Encode1((byte)s.nValue));        //Confirmed
            EncodeIf(SecondaryStatFlag.ComboCounter, s => packet.Encode1((byte)s.nValue)); //Confirmed
            EncodeIf(SecondaryStatFlag.WeaponCharge, s => packet.Encode4(s.rValue));       //Confirmed
            EncodeIf(SecondaryStatFlag.Stun, s => packet.Encode4(s.rValue));               //Confirmed
            EncodeIf(SecondaryStatFlag.Darkness, s => packet.Encode4(s.rValue));           //Confirmed
            EncodeIf(SecondaryStatFlag.Seal, s => packet.Encode4(s.rValue));               //Confirmed
            EncodeIf(SecondaryStatFlag.Weakness, s => packet.Encode4(s.rValue));           //Confirmed
            EncodeIf(SecondaryStatFlag.Curse, s => packet.Encode4(s.rValue));              //Confirmed
            EncodeIf(SecondaryStatFlag.Poison, s =>                                        //Confirmed
            {
                packet.Encode2((short)s.nValue);
                packet.Encode4(s.rValue);
            });

            EncodeIf(SecondaryStatFlag.ShadowPartner, s => packet.Encode4(s.rValue));    //Confirmed
            EncodeIf(SecondaryStatFlag.Morph, s => packet.Encode2((short)s.nValue));     //Confirmed
            EncodeIf(SecondaryStatFlag.Ghost, s => packet.Encode2((short)s.nValue));     //Confirmed
            EncodeIf(SecondaryStatFlag.Attract, s => packet.Encode4(s.rValue));          //Confirmed
            EncodeIf(SecondaryStatFlag.SpiritJavelin, s => packet.Encode4(s.nValue));    //Confirmed
            EncodeIf(SecondaryStatFlag.BanMap, s => packet.Encode4(s.rValue));           //Confirmed
            EncodeIf(SecondaryStatFlag.Barrier, s => packet.Encode4(s.rValue));          //Confirmed
            EncodeIf(SecondaryStatFlag.DojangShield, s => packet.Encode4(s.rValue));     //Confirmed
            EncodeIf(SecondaryStatFlag.ReverseInput, s => packet.Encode4(s.rValue));     //Confirmed
            EncodeIf(SecondaryStatFlag.RespectPImmune, s => packet.Encode4(s.nValue));   //Confirmed
            EncodeIf(SecondaryStatFlag.RespectMImmune, s => packet.Encode4(s.nValue));   //Confirmed
            EncodeIf(SecondaryStatFlag.DefenseAtt, s => packet.Encode4(s.nValue));       //Confirmed
            EncodeIf(SecondaryStatFlag.DefenseState, s => packet.Encode4(s.nValue));     //Confirmed
            EncodeIf(SecondaryStatFlag.RepeatEffect, s => packet.Encode4(s.rValue));     //Confirmed
            EncodeIf(SecondaryStatFlag.StopPortion, s => packet.Encode4(s.rValue));      //Confirmed
            EncodeIf(SecondaryStatFlag.StopMotion, s => packet.Encode4(s.rValue));       //Confirmed
            EncodeIf(SecondaryStatFlag.Fear, s => packet.Encode4(s.rValue));             //Confirmed
            EncodeIf(SecondaryStatFlag.MagicShield, s => packet.Encode4(s.nValue));      //Confirmed
            EncodeIf(SecondaryStatFlag.Frozen, s => packet.Encode4(s.rValue));           //Confirmed
            EncodeIf(SecondaryStatFlag.SuddenDeath, s => packet.Encode4(s.rValue));      //Confirmed
            EncodeIf(SecondaryStatFlag.FinalCut, s => packet.Encode4(s.rValue));         //Confirmed
            EncodeIf(SecondaryStatFlag.Cyclone, s => packet.Encode1((byte)s.nValue));    //Confirmed
            EncodeIf(SecondaryStatFlag.Mechanic, s => packet.Encode4(s.rValue));         //Confirmed
            EncodeIf(SecondaryStatFlag.DarkAura, s => packet.Encode4(s.rValue));         //Confirmed
            EncodeIf(SecondaryStatFlag.BlueAura, s => packet.Encode4(s.rValue));         //Confirmed
            EncodeIf(SecondaryStatFlag.YellowAura, s => packet.Encode4(s.rValue));       //Confirmed

            packet.Encode1(nDefenseAtt);
            packet.Encode1(nDefenseState);

            EncodeTwoStates(packet);
        }
Exemple #24
0
        // CWvsContext::OnTownPortal(CWvsContext *this, CInPacket *iPacket)
        // CWvsContext::OnPacket() OpCode 0x45
        public COutPacket TownPortalResponse(int dwTownID, int dwFieldID, int nSkillID, short nPosX, short nPosY)
        {
            var p = new COutPacket(SendOps.LP_TownPortal);

            p.Encode4(dwTownID);
            p.Encode4(dwFieldID);
            if (dwTownID != 999999999 && dwFieldID != 999999999)
            {
                p.Encode4(nSkillID);
                p.Encode2(nPosX);
                p.Encode2(nPosY);
            }
            return(p);
        }
        public override void RawEncode(COutPacket p, bool bFromCS = false)
        {
            p.Encode1(2);

            base.RawEncode(p, bFromCS);

            p.Encode2(nNumber);
            p.EncodeString(sTitle);
            p.Encode2(nAttribute);

            if (ItemConstants.IsRechargeableItem(nItemID))
            {
                p.Encode8(liSN);
            }
        }
Exemple #26
0
        public string sTitle = string.Empty; //char sTitle[13];

        public override void RawEncode(COutPacket p)
        {
            p.Encode1(2);

            base.RawEncode(p);

            p.Encode2(nNumber);
            p.EncodeString(sTitle);
            p.Encode2(nAttribute);

            if (nItemID / 10000 == 207)
            {
                p.Encode8(liSN);
            }
        }
Exemple #27
0
            public static COutPacket CreateNewParty_Done(Party party)
            {
                var p = new COutPacket(SendOps.LP_PartyResult);

                p.Encode1((byte)PartyOps.PartyRes_CreateNewParty_Done);
                p.Encode4(party.PartyID);
                p.Encode4(0);                 //Town Id
                p.Encode4(0);                 //Field Id
                p.Encode4(0);                 //nSkillId

                p.Encode2(0);                 //No Clue
                p.Encode2(0);                 //No Clue

                return(p);
            }
            public static COutPacket UserQuestResult_Timer(short dwQuestId, int tRemain, bool bRemove)
            {
                var p = new COutPacket(SendOps.LP_UserQuestResult);

                p.Encode1(bRemove ? QuestResultType.End_QuestTimer : QuestResultType.Start_QuestTimer);
                p.Encode2(1);                 // count
                p.Encode2(dwQuestId);

                if (!bRemove)
                {
                    p.Encode4(tRemain);
                }

                return(p);
            }
Exemple #29
0
            public static COutPacket CheckPasswordResult(int reason)
            {
                // 3: ID deleted or blocked
                // 4: Incorrect password
                // 5: Not a registered id
                // 6: System error
                // 7: Already logged in
                // 8: System error
                // 9: System error
                // 10: Cannot process so many connections
                // 11: Only users older than 20 can use this channel
                // 13: Unable to log on as master at this ip
                // 14: Wrong gateway or personal info and weird korean button
                // 15: Processing request with that korean button!
                // 16: Please verify your account through email...
                // 17: Wrong gateway or personal info
                // 21: Please verify your account through email...
                // 23: License agreement
                // 25: Maple Europe notice
                // 27: Some weird full client notice, probably for trial versions
                // 32: IP blocked
                // 84: please revisit website for pass change --> 0x07 recv with response 00/01

                var p = new COutPacket(SendOps.LP_CheckPasswordResult);

                p.Encode4(reason);
                p.Encode2(0);
                return(p);
            }
Exemple #30
0
 private static void EncodeLook(int index, COutPacket p, Character c)
 {
     p.Encode1((byte)index);
     c.GetLook().Encode(p);
     p.EncodeString(c.Stats.sCharacterName);
     p.Encode2(c.Stats.nJob);
 }