Ejemplo n.º 1
0
        internal static void LoadCharInfoReq(User user, Packet pkt)
        {
            string strChar1 = String.Empty, strChar2 = String.Empty, strChar3 = String.Empty, strChar4 = String.Empty;

            Packet result = new Packet(WIZ_ALLCHAR_INFO_REQ);
            result.SetByte(1);

            if (__VERSION >= 1920)
                result.SetByte(1);

            KODatabase db = new KODatabase();
            Debug.WriteLine("Char bilgleri istendi {0}", user.strAccountID);
            var AllCharID = db.ACCOUNT_CHAR.Where(u => u.strAccountID == user.strAccountID).FirstOrDefault();

            if (AllCharID != null)
            {
                Debug.WriteLine("Char bilgileri alındı.");
                LoadCharInfo(AllCharID.strCharID1.TrimEnd(' ', '/'), ref result);
                LoadCharInfo(AllCharID.strCharID2.TrimEnd(' ', '/'), ref result);
                LoadCharInfo(AllCharID.strCharID3.TrimEnd(' ', '/'), ref result);
            }
            else
                Debug.WriteLine("Char bilgileri alınamadı.");

            user.Send(result);
        }
Ejemplo n.º 2
0
 internal static void VersionCheck(User user)
 {
     Packet resut = new Packet(15);
     resut.SetByte(WIZ_VERSION_CHECK);
     resut.SetByte(0);
     resut.SetShort(__VERSION);
     resut.SetInt64(0);
     user.Send(resut);
 }
Ejemplo n.º 3
0
 public void Initialise()
 {
     byUsed = Fame = Level = 0;
     strUserName = strMemo = string.Empty;
     nDonatedNP = 0;
     m_sClass = 0;
     LastLogin = DateTime.Now;
     sSid = -1;
     pSession = null;
 }
Ejemplo n.º 4
0
        private static void ReqLetterSend(Packet pkt, User pUser)
        {
            Packet result = new Packet(WIZ_SHOPPING_MALL, STORE_LETTER);
            User ptUser = null;
            String strRecipient = String.Empty, strSubject = String.Empty, strMessage = String.Empty;
            _ITEM_DATA pItem = null;

            Int32 nItemID = 0, nCoins = 0, nCoinRequirement = 1000;
            Byte bType, bSrcPos;
            SByte bResult = 1;
            Int64 Serial = 0;
            
           //if(pUser.isTrading() || pUser.isMerchanting())
           //{
           //    bResult = -1;
           //    goto send_packet;
           //}

            pkt.SByte();
            strRecipient = pkt.GetString(); strSubject = pkt.GetString(); bType = pkt.GetByte();

            // invalid recipient name lenght
            if (strRecipient == String.Empty || strRecipient.Length > MAX_ID_SIZE
                // Invalid subject lenght
                || strSubject == String.Empty || strSubject.Length > 31
                // Invalid type (as far we're concerned) 
                || bType == 0 || bType > 2)
                bResult = -1;
            else if (STRCMP(strRecipient, pUser.strCharID))
                bResult = -6;

            if (bResult != 1)
                goto send_packet;

            if(bType == 2)
            {
                if (nItemID != 0)
                    nCoinRequirement = 10000;
                else
                    nCoinRequirement = 5000;

                // Item alma fonksiyonu eklenecek
            }
            send_packet:

            result.SetByte(LETTER_SEND).SetByte(bResult);
            pUser.Send(result);
        }
Ejemplo n.º 5
0
        public static void HandleShoppingMall(Packet pkt, User pUser)
        {
            if (pkt.GetByte() != STORE_LETTER)
                return;
            byte opcode = pkt.GetByte();
               
            switch (opcode)
            {
                // Are there any letters to be read?
                // This is for the notification at the top of the screen.
                case LETTER_UNREAD:
                    ReqLetterUnread(pUser);
                    break;

                // Lists all the new mail.
                case LETTER_LIST:
                    ReqLetterList(true,pUser);
                    break;

                // Lists all the old mail.
                case LETTER_HISTORY:
                    ReqLetterList(false, pUser);
                    break;

                // Opens up the letter & marks it as read.
                case LETTER_READ:
                    ReqLetterRead(pkt, pUser);
                    break;

                // Used to send a letter & any coins/items (coins are disabled though)
                case LETTER_SEND:
                    ReqLetterSend(pkt, pUser);
                    break;

                // Used to take an item from a letter. 
                case LETTER_GET_ITEM:
                    ReqLetterGetItem(pkt, pUser);
                    break;

                // Deletes up to 5 old letters at a time.
                case LETTER_DELETE:
                    ReqLetterDelete(pkt, pUser);
                    break;
            }   
        }
Ejemplo n.º 6
0
        internal static void AccountLogin(User user, Packet pkt)
        {
            KODatabase db = new KODatabase();
            // Login işlemleri.
            string AccountID = pkt.GetString();
            string strPassword = pkt.GetString();

            Packet result = new Packet(WIZ_LOGIN);

            result.SetByte(DBAgent.GameLogin(AccountID, strPassword,ref result));
            
            Thread thd = new Thread(() =>
            {
                user.sSid = user.g_pMain.GetNewSocketID();
            });

            thd.Start();

            user.Send(result);

            user.strAccountID = AccountID;
        }
Ejemplo n.º 7
0
        internal static void CreateNewChar(User user, Packet pkt)
        {
            Packet result = new Packet(WIZ_NEW_CHAR);
            byte nHair;
            short sClass;
            byte bCharIndex, bRace, bFace, str, sta, dex, intel, cha, errorCode = 0;
            string strUserID;

            bCharIndex = pkt.GetByte();
            strUserID = pkt.GetString();
            bRace = pkt.GetByte();
            sClass = pkt.GetShort();
            bFace = pkt.GetByte();
            nHair = pkt.GetByte();
            str = pkt.GetByte();
            sta = pkt.GetByte();
            dex = pkt.GetByte();
            intel = pkt.GetByte();
            cha = pkt.GetByte();

            COEFFICIENT p_TableCoefficient = user.g_pMain.GetCoefficientData(sClass);
            
            if (bCharIndex > 2)
                errorCode = NEWCHAR_NO_MORE;
            else if (p_TableCoefficient == null
                || (str + sta + dex + intel + cha) > 300)
                errorCode = NEWCHAR_INVALID_DETAILS;
            else if (str < 50 || sta < 50 || dex < 50 || intel < 50 || cha < 50)
                errorCode = NEWCHAR_STAT_TOO_LOW;
            
            if (errorCode != 0)
            {
                result.SetByte(errorCode);
                user.Send(result);
                return;
            }

            int nRet = new KODatabase().CREATE_NEW_CHAR(user.GetAccountID(), bCharIndex, strUserID, bRace, sClass, nHair, bFace, str, sta, dex, intel, cha);
            result.SetByte((byte)nRet);

            user.Send(result);
        }
Ejemplo n.º 8
0
        internal static void SelCharToAgent(User user, Packet pkt)
        {
            Packet result = new Packet(WIZ_SEL_CHAR);

            byte bInit, bResult = 0;
            string strCharID = string.Empty, strAccountID = string.Empty;

            strAccountID = pkt.GetString();
            user.strCharID = strCharID = pkt.GetString();
            bInit = pkt.GetByte();


            if (user.GetAccountID() == String.Empty || user.GetName() == String.Empty ||
                !DBAgent.LoadUserData(user.GetAccountID(), strCharID, ref user) ||
                !DBAgent.LoadWarehouseData(user.GetAccountID(), user) ||
                !DBAgent.LoadPremiumServiceUser(user.GetAccountID(), user) ||
                !DBAgent.LoadSavedMagic(user))
            {
                Debug.WriteLine("Kullanıcı girişi sırasında hata oluştu");
                bResult = 0;
                goto fail_return;
            }

            bResult = 1;

            fail_return:
            user.SelectCharacter(bResult, bInit);            
        }
Ejemplo n.º 9
0
        private static void ReqLetterList(bool IsHistory, User pUser)
        {
            Packet result = new Packet(WIZ_SHOPPING_MALL, STORE_LETTER);

            result.SetByte(IsHistory ? LETTER_LIST : LETTER_HISTORY);

            if (!DBAgent.GetLetterList(pUser.GetAccountID(), ref result, IsHistory))
                result.SetByte(-1);

            pUser.Send(result);
        }
Ejemplo n.º 10
0
        private void OnDeath(User pAttacker)
        {
            if (m_bResHpType == USER_DEAD)
                return;

            m_bResHpType = USER_DEAD;

            // Player is dead stop other process.
            ResetWindows();

            
        }
Ejemplo n.º 11
0
 internal void OnLoginAlliance(User user)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        public static bool LoadUserData(string AccountID, string strCharID, ref User pUser)
        {
            KODatabase db = new KODatabase();
            try
            {
                USERDATA pData = db.USERDATA.Where(user => user.strUserID == strCharID).FirstOrDefault();

                if (pData == null)
                    return false;

                pUser.m_bNation = pData.Nation;
                pUser.m_bRace   = pData.Race   ;
                pUser.m_sClass  = pData.Class  ;
                pUser.m_nHair   = pData.HairRGB;
                pUser.m_bRank   = pData.Rank   ;
                pUser.m_bTitle  = pData.Title  ;
                pUser.m_bLevel  = pData.Level  ;
                pUser.m_iExp    = pData.Exp    ;
                pUser.m_iLoyalty= pData.Loyalty;
                pUser.m_bFace   = pData.Face   ;
                pUser.m_bCity   = (sbyte)pData.City   ;
                pUser.m_bKnights= pData.Knights;
                pUser.m_bFame   = pData.Fame   ;
                pUser.m_sHp     = pData.Hp     ;
                pUser.m_sMp     = pData.Mp     ;
                pUser.m_sSp     = pData.Sp     ;
                pUser.m_bStats[(int)StatType.STAT_STR] = pData.Strong;
                pUser.m_bStats[(int)StatType.STAT_STA] = pData.Sta;
                pUser.m_bStats[(int)StatType.STAT_DEX] = pData.Dex;
                pUser.m_bStats[(int)StatType.STAT_INT] = pData.Intel;
                pUser.m_bStats[(int)StatType.STAT_CHA] = pData.Cha;
                pUser.m_bAuthority= pData.Authority;
                pUser.m_sPoints   = pData.Points   ;
                pUser.m_iGold     = pData.Gold     ;
                pUser.m_bZone     = pData.Zone     ;
                pUser.m_sBind     = (long)pData.Bind;

                pUser.m_curx = (float)(pData.PX / 100.0f);
                pUser.m_curz = (float)(pData.PZ / 100.0f);
                pUser.m_cury = (float)(pData.PY / 100.0f);
                pUser.m_oldx = pUser.m_curx;
                pUser.m_oldy = pUser.m_cury;
                pUser.m_oldz = pUser.m_curz;

                pUser.m_dwTime = pData.dwTime;

                pUser.m_bstrSkill = pData.strSkill.ToCharArray();

                Packet itemBuffer = new Packet(pData.strItem);
                Packet serialBuffer = new Packet(pData.strSerial);
                Packet itemTimeBuffer = new Packet(pData.strItemTime);
                for (int i = 0; i < INVENTORY_TOTAL; i++)
                {
                    Int64 nSerialNum;
                    Int32 nItemID;
                    Int16 sDurability, sCount, nRentalTime;
                    Int32 nItemTime;

                    nItemID = itemBuffer.GetDWORD();
                    sDurability = itemBuffer.GetShort();
                    sCount = itemBuffer.GetShort();
                    nSerialNum = serialBuffer.GetInt64();
                    nItemTime = itemTimeBuffer.GetDWORD();
                    nRentalTime = itemTimeBuffer.GetShort();

                    _ITEM_DATA pItem = new _ITEM_DATA();

                    pItem.nNum = nItemID;
                    pItem.sCount = sCount;
                    pItem.sDuration = sDurability;
                    pItem.nSerialNum = nSerialNum;
                    pItem.nExpirationTime = nItemTime;
                    pItem.sRemainingRentalTime = nRentalTime;

                    pUser.m_sItemArray[i] = pItem;
                }

                return true;
            }
            catch(Exception ex)
            {
                Debug.WriteLine("Karakter bilgileri alınırken özel durum oluştu : " + ex.Message);

                return false; 
            }
        }
Ejemplo n.º 13
0
        public static void UserInOut(InOutType inOutType, User m_pUser)
        {

        }
Ejemplo n.º 14
0
 private static void ReqLetterGetItem(Packet pkt, User pUser)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 private static void ReqLetterUnread(User pUser)
 {
     Packet result = new Packet(WIZ_SHOPPING_MALL, STORE_LETTER);
     result.SetByte(LETTER_UNREAD).SetByte(DBAgent.GetUnreadLetter(pUser.GetAccountID()));
     pUser.Send(result);
 }
Ejemplo n.º 16
0
 internal static bool LoadWarehouseData(string AccountID, User pUser)
 {
     return true;
 }
Ejemplo n.º 17
0
 internal static bool LoadPremiumServiceUser(string AccountID, User pUser)
 {
     return true;
 }
Ejemplo n.º 18
0
 public void OnLogin(User pUser)
 {
     //Packet result = new Packet();
     //
     //bool byUsed = false;
     //int i = 0;
     //// Set the active session for this user
     //foreach (_KNIGHTS_USER p in m_arKnightsUser)
     //{
     //    i++;
     //    if (STRCMP(p.strUserName, pUser.GetName()) == false)
     //        continue;
     //    byUsed = true;
     //
     //    m_arKnightsUser[i - 1].pSession = pUser;
     //    // p.pSession = pUser;
     //
     //    pUser.m_pKnightsUser = p;
     //
     //    break;
     //}
     ///*
     //if (!byUsed && m_arKnightsUser.Count < MAX_CLAN_USERS)
     //{
     //    _KNIGHTS_USER pKnightUser = new _KNIGHTS_USER();
     //
     //    pKnightUser.byUsed = 1;
     //    pKnightUser.nDonatedNP = 0;
     //    pKnightUser.pSession = pUser;
     //    pKnightUser.strUserName = pUser.GetName();
     //
     //    pUser.m_pKnightsUser = pKnightUser;
     //
     //    m_arKnightsUser.Add(pKnightUser);
     //}*/
     //
     //// Send login notice
     //// TODO: Shift this to SERVER_RESOURCE
     //string buffer = string.Format("{0} is online.", pUser.GetName());
     ////pUser.ChatHandler.Construct(ref result, (byte)ChatType.KNIGHTS_CHAT, buffer);
     ////pUser.SendClan(result);
     //
     //// Construct the clan notice packet to send to the logged in player
     //if (m_strClanNotice != String.Empty)
     //{
     //    ConstructClanNoticePacket(ref result);
     //    pUser.Send(result);
     //}
 }
Ejemplo n.º 19
0
 internal static bool LoadSavedMagic(User pUser)
 {
     return true;
 }
Ejemplo n.º 20
0
        public void HpChange(int amount, User pAttacker = null)
        {
            Packet result = new Packet(WIZ_HP_CHANGE);
            short tid = (pAttacker != null ? pAttacker.GetID() : (short)-1);
            short oldHP = m_sHp;
            int originalAmount = amount;
            int mirrorDamage = 0;

            // No cheats allowed
            if (pAttacker != null && pAttacker.GetZoneID() != GetZoneID())
                return;

            // Implement damage/HP cap.
            if (amount < -MAX_DAMAGE)
                amount = -MAX_DAMAGE;
            else if (amount > MAX_DAMAGE)
                amount = MAX_DAMAGE;

            // If we're taking damage...
            if (amount < 0)
            {
                if (isGM())
                    return;

                RemoveStealth();

                // Handle the mirroring of damage.
                //if (m_bMirrorDamage > 0 && isInParty() && GetZoneID() != ZONE_CHAOS_DUNGEON)
                //{
                //    _PARTY_GROUP* pParty = nullptr;
                //    CUser* pUser = nullptr;
                //    mirrorDamage = (m_byMirrorAmount * amount) / 100;
                //    amount -= mirrorDamage;
                //    pParty = g_pMain->GetPartyPtr(GetPartyID());
                //    if (pParty != nullptr)
                //    {
                //        mirrorDamage = mirrorDamage / (GetPartyMemberAmount(pParty) - 1);
                //        for (int i = 0; i < MAX_PARTY_USERS; i++)
                //        {
                //            pUser = g_pMain->GetUserPtr(pParty->uid[i]);
                //            if (pUser == nullptr || pUser == this)
                //                continue;
                //
                //            pUser->HpChange(mirrorDamage);
                //        }
                //    }
                //}

                // Handle mana absorb skills
                //if (m_bManaAbsorb > 0 && GetZoneID() != ZONE_CHAOS_DUNGEON)
                //{
                //    int toBeAbsorbed = 0;
                //    toBeAbsorbed = (originalAmount * m_bManaAbsorb) / 100;
                //    amount -= toBeAbsorbed;
                //
                //    if (m_bManaAbsorb == 15)
                //        toBeAbsorbed *= 4;
                //
                //    MSpChange(toBeAbsorbed);
                //}

                // Handle mastery passives
                //if (isMastered() && GetZoneID() != ZONE_CHAOS_DUNGEON)
                //{
                //    // Matchless: [Passive]Decreases all damages received by 15%
                //    if (CheckSkillPoint(SkillPointMaster, 10, MAX_LEVEL))
                //        amount = (85 * amount) / 100;
                //    // Absoluteness: [Passive]Decrease 10 % demage of all attacks
                //    else if (CheckSkillPoint(SkillPointMaster, 5, 9))
                //        amount = (90 * amount) / 100;
                //}
            }
            // If we're receiving HP and we're undead, all healing must become damage.
            //else if (m_bIsUndead)
            //{
            //    amount = -amount;
            //    originalAmount = amount;
            //}

            if (amount < 0 && -amount >= m_sHp)
                m_sHp = 0;
            else if (amount >= 0 && m_sHp + amount > m_iMaxHp)
                m_sHp = m_iMaxHp;
            else
                m_sHp += (short)amount;

            result.SetShort(m_iMaxHp).SetShort(m_sHp).SetShort(tid);

            if (GetHealth() > 0
            && isMastered()
            && !isMage() && GetZoneID() != ZONE_CHAOS_DUNGEON)
                {
                    short hp30Percent = (short)((30 * GetMaxHealth()) / 100);
                    if ((oldHP >= hp30Percent && m_sHp < hp30Percent)
                        || (m_sHp > hp30Percent))
                    {
                        SetUserAbility();

                        if (m_sHp < hp30Percent)
                            ShowEffect(106800); // skill ID for "Boldness", shown when a player takes damage.
                    }
                }

            Send(result);

            if (isInParty() && GetZoneID() != ZONE_CHAOS_DUNGEON)
                SendPartyHPUpdate();

            if (pAttacker != null)
                    SendTargetHP(0, GetID(), originalAmount);

            if (m_sHp == 0)
                OnDeath(pAttacker);
        }
Ejemplo n.º 21
0
        internal static void SelectNation(User user, Packet pkt)
        {
            Packet result = new Packet(WIZ_SEL_NATION);

            byte nation = pkt.GetByte();

            DBAgent.SelectNation(ref result,nation,user.strAccountID);

            user.Send(result);
        }
Ejemplo n.º 22
0
 public void SendToRegion(Packet result, User pExceptUser = null, short m_sEventRoom = -1)
 {
     g_pMain.Send_Region(result, GetRegionX(), GetRegionZ(), pExceptUser, m_sEventRoom);
 }
Ejemplo n.º 23
0
        private static void ReqLetterRead(Packet pkt, User pUser)
        {
            Packet result = new Packet(WIZ_SHOPPING_MALL, STORE_LETTER);
            Int32 nLetterID = pkt.GetDWORD();
            String strMessage = String.Empty;

            result.SetByte(LETTER_READ);
            if (!DBAgent.ReadLetter(pUser.GetAccountID(), nLetterID, strMessage))
                result.SetByte(0);
            else
            {
                result.SByte();
                result.SetByte(1).SetDword(nLetterID).SetString(strMessage);
            }

            pUser.Send(result);
        }