private static void LoadCharInfo(string charID, ref Packet result) { KODatabase db = new KODatabase(); var user = db.USERDATA.Where(u => u.strUserID == charID).First(); int nHair = 0; short sClass = 0; byte bRace = 0, bLevel = 0, bFace = 0, bZone = 0; string strItem = String.Empty; byte[] ItemArray = new byte[INVENTORY_TOTAL * 8];// = ToBytes(strItem); if (user != null) { result.SetString(user.strUserID); result.SetByte(user.Race); result.SetShort(user.Class); result.SetByte(user.Level); result.SetByte(user.Face); result.SetDword(user.HairRGB); result.SetByte(user.Zone); Packet item = new Packet(); item.append(user.strItem, user.strItem.Length); for (int i = 0; i < SLOT_MAX; i++) { int nItemID; short sDurability, sCount; nItemID = item.GetDWORD(); sDurability = item.GetShort(); sCount = item.GetShort(); if (i == HEAD || i == BREAST || i == SHOULDER || i == LEG || i == GLOVE || i == FOOT || i == RIGHTHAND || i == LEFTHAND) { result.SetDword(nItemID); result.SetShort(sDurability); } } } else { result.SetString(charID); result.SetByte(bRace); result.SetShort(sClass); result.SetByte(bLevel); result.SetByte(bFace); result.SetDword(nHair); result.SetByte(bZone); for (int i = 0; i < SLOT_MAX; i++) { if (i == HEAD || i == BREAST || i == SHOULDER || i == LEG || i == GLOVE || i == FOOT || i == RIGHTHAND || i == LEFTHAND) { result.SetDword(0); result.SetShort(0); } } } }
internal static bool GetLetterList(string strAccountID, ref Packet result, bool isHistory) { try { KODatabase db = new KODatabase(); byte bType = isHistory ? (byte)2 : (byte)1; var letterlist = db.MAIL_BOX.Where(i => i.strRecipientID == strAccountID && i.bStatus == bType && !i.bDeleted).Take(10); byte Count = (byte)letterlist.Count(); result.SetByte(1).SetByte(bType); foreach (MAIL_BOX letter in letterlist) { result.SetDword(letter.nLetterID) .SetByte(letter.bStatus) .SetString(letter.strSubject) .SetString(letter.strSenderID) .SetByte(letter.bType); if (letter.bType == 2) { result.SetDword(letter.nItemID).SetShort(letter.sCount).SetDword(letter.nCoins); } int DayDiff = (Int32)UNIXTIME - (Int32)(letter.dtSendDate.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; byte RemainDays = (byte)(DayDiff / 60 / 60 / 24); result.SetDword((int)UNIXTIME).SetByte(RemainDays); } } catch { return(false); } return(true); }
internal void GetUserInfo(ref Packet result) { Knights pKnights = null; result.SByte(); result.SetString(GetName()); result.SetShort(GetNation()); result.SetShort(m_bKnights); result.SetByte(GetFame()); pKnights = g_pMain.GetClanPtr(m_bKnights); if (pKnights == null) { result.SetDword(0); result.SetShort(0); result.SetByte(0); result.SetShort(-1); result.SetDword(0); result.SetByte(0); } else { result.SetShort(pKnights.GetAllianceID()); result.SetString(pKnights.m_strName); result.SetByte(pKnights.m_byGrade); result.SetByte(pKnights.m_byRanking); result.SetShort(pKnights.m_sMarkVersion); result.SetShort(pKnights.m_sCape); result.SetByte(pKnights.m_bCapeR); result.SetByte(pKnights.m_bCapeG); result.SetByte(pKnights.m_bCapeB); result.SetByte(0); result.SetByte(1); } InvisibilityType bInvisibilityType = (InvisibilityType)m_bInvisibilityType; if (bInvisibilityType != InvisibilityType.INVIS_NONE) bInvisibilityType = InvisibilityType.INVIS_DISPEL_ON_MOVE; result.SetByte(GetLevel()); result.SetByte(m_bRace); result.SetShort(m_sClass); result.SetShort(GetSPosX()); result.SetShort(GetSPosZ()); result.SetShort(GetSPosY()); result.SetByte(m_bFace); result.SetDword(m_nHair); result.SetByte(m_bResHpType); result.SetDword(m_bAbnormalType); result.SetByte(m_bNeedParty); result.SetByte(m_bAuthority); result.SetByte(m_bPartyLeader); result.SetByte((byte)bInvisibilityType); result.SetByte(m_teamColour); result.SetByte(m_bIsHidingHelmet); result.SetByte((byte)bInvisibilityType); result.SetShort(m_sDirection); result.SetByte(m_bIsChicken); result.SetByte(m_bRank); result.SetShort(0); result.SetByte(m_bKnightsRank); result.SetByte(m_bPersonalRank); byte[] equippedItems = { BREAST, LEG, HEAD, GLOVE, FOOT, SHOULDER, RIGHTHAND, LEFTHAND, CWING, CHELMET, CRIGHT, CLEFT, CTOP, CFAIRY }; foreach (byte i in equippedItems) { _ITEM_DATA pItem = GetItem(i); if (pItem == null) continue; result.SetDword(pItem.nNum); result.SetShort(pItem.sDuration); result.SetByte(pItem.bFlag); } result.SetByte(GetZoneID()); result.SetShort(-1); result.SetDword(0); result.SetShort(0); result.SetByte(0); result.SetByte(isGenieActive()); if (__VERSION > 2000) { result.SetByte(isRebirth()); result.SetShort(GetAchieveTitle()); result.SetShort(0); result.SetByte(0); result.SetByte(1); } }
public void SendMyInfo() { SetUserAbility(false); Packet result = new Packet(WIZ_MYINFO); result.SByte(); result.SetShort(sSid); result.SetString(GetName()); result.SetShort(Convert.ToInt16(m_curx * 10)); result.SetShort(Convert.ToInt16(m_curz * 10)); result.SetShort(Convert.ToInt16(m_cury * 10)); result.SetByte(m_bNation); result.SetByte(m_bRace); result.SetShort(m_sClass); result.SetByte(m_bFace); result.SetDword(m_nHair); result.SetByte(m_bRank); result.SetByte(m_bTitle); result.SetShort(0); result.SetByte(GetLevel()); result.SetShort(m_sPoints); result.SetInt64(1/*SetMaxExp()*/); result.SetInt64(m_iExp); result.SetDword(m_iLoyalty); result.SetDword(m_iLoyaltyMonthly); result.SetShort(GetClanID()); result.SetByte(GetFame()); Knights pKnights = g_pMain.GetClanPtr(GetClanID()); if (pKnights == null) { result.SetInt64(0); result.SetShort(-1); result.SetDword(0); } else { pKnights.OnLogin(this); Knights pAllyClan = null; if (pKnights.GetAllianceID() > 0) pAllyClan = g_pMain.GetClanPtr(pKnights.GetAllianceID()); result.SetShort(pKnights.GetAllianceID()); result.SetByte(pKnights.m_byFlag); result.SetString(pKnights.m_strName); result.SetByte(pKnights.m_byGrade); result.SetByte(pKnights.m_byRanking); result.SetShort(pKnights.m_sMarkVersion); if (pAllyClan == null) result.SetShort(pKnights.m_sCape); else result.SetShort(pAllyClan.m_sCape); result.SetByte(pKnights.m_bCapeR); result.SetByte(pKnights.m_bCapeG); result.SetByte(pKnights.m_bCapeB); result.SetByte(0); } result.SetByte(2); result.SetByte(3); result.SetByte(4); result.SetByte(5); result.SetShort(m_iMaxHp); result.SetShort(m_sHp); result.SetShort(m_iMaxMp); result.SetShort(m_sMp); result.SetDword(m_sMaxWeight); result.SetDword(m_sItemWeight); result.SetByte(m_bStats[(int)StatType.STAT_STR]); result.SetByte((byte)GetStatItemBonus(StatType.STAT_STR)); result.SetByte(m_bStats[(int)StatType.STAT_STA]); result.SetByte((byte)GetStatItemBonus(StatType.STAT_STA)); result.SetByte(m_bStats[(int)StatType.STAT_DEX]); result.SetByte((byte)GetStatItemBonus(StatType.STAT_DEX)); result.SetByte(m_bStats[(int)StatType.STAT_INT]); result.SetByte((byte)GetStatItemBonus(StatType.STAT_INT)); result.SetByte(m_bStats[(int)StatType.STAT_CHA]); result.SetByte((byte)GetStatItemBonus(StatType.STAT_CHA)); result.SetShort(m_sTotalHit); result.SetShort(m_sTotalAc); result.SetByte((byte)m_sFireR); result.SetByte((byte)m_sColdR); result.SetByte((byte)m_sLightningR); result.SetByte((byte)m_sMagicR); result.SetByte((byte)m_sDiseaseR); result.SetByte((byte)m_sPoisonR); result.SetDword(m_iGold); result.SetByte(m_bAuthority); result.SetByte(m_bKnightsRank); result.SetByte(m_bPersonalRank); result.append(m_bstrSkill, 9); for (int i = 0; i < INVENTORY_TOTAL; i++) { _ITEM_DATA pItem = GetItem(i); if (pItem == null) { pItem = new _ITEM_DATA(); } if (pItem.sRemainingRentalTime < UNIXTIME) pItem.sRemainingRentalTime = 0; if (pItem.nExpirationTime < UNIXTIME) pItem.nExpirationTime = 0; result.SetDword(pItem.nNum); result.SetShort(pItem.sDuration); result.SetShort(pItem.sCount); result.SetByte(pItem.bFlag); // item type flag (e.g. rented) result.SetShort(pItem.sRemainingRentalTime); // remaining time result.SetDword(0); // unknown result.SetDword(pItem.nExpirationTime); // expiration date in unix time } result.SetByte(m_bAccountStatus); result.SetByte(m_bPremiumType); result.SetShort(m_sPremiumTime); result.SetByte(m_bIsChicken); // Yumurta result.SetDword(m_iMannerPoint); result.SetShort(0); result.SetDword(0); // Military Camp result.SetShort(m_sGenieTime);// Genie Send(result); if (!g_pMain.AddUserInGame(GetID(), this)) OnDisconnect(); else bGameStart = true; Console.WriteLine("Send My info Gönderildi."); }
public void StateChangeServerDirect(byte type, int buff) { if (type == 5 && m_bAuthority != 0) return; // Operators only!!! if (type == 1) { m_bResHpType = Convert.ToByte(buff); } else if (type == 2) { m_bNeedParty = Convert.ToByte(buff); } else if (type == 3) { m_bAbnormalType = buff; } else if (type == 6) { m_bPartyLeader = Convert.ToBoolean(buff); } Packet result = new Packet(WIZ_STATE_CHANGE); result.SetShort(GetSocketID()); result.SetByte(type); if (type == 1) { result.SetDword(m_bResHpType); } else if (type == 2) { result.SetDword(m_bNeedParty); } // else if (type == 3) { result.SetDword(m_bAbnormalType); } else { // Just plain echo :) result.SetDword(buff); // N3_SP_STATE_CHANGE_ACTION = 0x04, // 1 - 인사, 11 - 도발 // N3_SP_STATE_CHANGE_VISIBLE = 0x05 }; // 투명 0 ~ 255 } g_pMain.Send_All(result); /* switch (bType) { case 1: m_bResHpType = buff; break; case 2: m_bNeedParty = buff; break; case 3: m_nOldAbnormalType = m_bAbnormalType; // If we're a GM, we need to show ourselves before transforming. // Otherwise the visibility state is completely desynced. if (isGM()) StateChangeServerDirect(5, 1); m_bAbnormalType = buff; break; case 5: m_bAbnormalType = buff; break; case 6: buff = Convert.ToByte(m_bPartyLeader); // we don't set this here. break; case 7: UpdateVisibility((InvisibilityType)buff); break; case 8: // beginner quest break; } Packet result = new Packet(WIZ_STATE_CHANGE); result.SetShort(GetSocketID()); result.SetByte(bType); result.SetByte(buff); SendToRegion(result);*/ }
public void SendItemMove(byte subcommand) { Packet result = new Packet(WIZ_ITEM_MOVE, 0x01); result.SetByte(subcommand); if (m_bAttackAmount == 0) m_bAttackAmount = 100; // If the subcommand is not error, send the stats. if (subcommand != 0) { result.SetShort((short)(m_sTotalHit * m_bAttackAmount / 100)); result.SetShort((short)(m_sTotalAc + m_sACAmount)); result.SetDword(m_sMaxWeight); result.SetShort(m_iMaxHp); result.SetShort(m_iMaxMp); result.SetShort(GetStatBonusTotal(StatType.STAT_STR)); result.SetShort(GetStatBonusTotal(StatType.STAT_STA)); result.SetShort(GetStatBonusTotal(StatType.STAT_DEX)); result.SetShort(GetStatBonusTotal(StatType.STAT_INT)); result.SetShort(GetStatBonusTotal(StatType.STAT_CHA)); result.SetShort((short)(((m_sFireR + m_bAddFireR) * m_bPctFireR / 100) + m_bResistanceBonus)); result.SetShort((short)(((m_sColdR + m_bAddColdR) * m_bPctColdR / 100) + m_bResistanceBonus)); result.SetShort((short)(((m_sLightningR + m_bAddLightningR) * m_bPctLightningR / 100) + m_bResistanceBonus)); result.SetShort((short)(((m_sMagicR + m_bAddMagicR) * m_bPctMagicR / 100) + m_bResistanceBonus)); result.SetShort((short)(((m_sDiseaseR + m_bAddDiseaseR) * m_bPctDiseaseR / 100) + m_bResistanceBonus)); result.SetShort((short)(((m_sPoisonR + m_bAddPoisonR) * m_bPctPoisonR / 100) + m_bResistanceBonus)); } Send(result); }
private static void LoadCharInfo(string charID, ref Packet result) { KODatabase db = new KODatabase(); var user = db.USERDATA.Where(u => u.strUserID == charID).First(); int nHair = 0; short sClass = 0; byte bRace = 0, bLevel = 0, bFace = 0, bZone = 0; string strItem = String.Empty; byte[] ItemArray = new byte[INVENTORY_TOTAL * 8];// = ToBytes(strItem); if (user != null) { result.SetString(user.strUserID); result.SetByte(user.Race); result.SetShort(user.Class); result.SetByte(user.Level); result.SetByte(user.Face); result.SetDword(user.HairRGB); result.SetByte(user.Zone); Packet item = new Packet(); item.append(user.strItem, user.strItem.Length); for (int i = 0; i < SLOT_MAX; i++) { int nItemID; short sDurability, sCount; nItemID = item.GetDWORD(); sDurability = item.GetShort(); sCount = item.GetShort(); if (i == HEAD || i == BREAST || i == SHOULDER || i == LEG || i == GLOVE || i == FOOT || i == RIGHTHAND || i == LEFTHAND) { result.SetDword(nItemID); result.SetShort(sDurability); } } } else { result.SetString(charID); result.SetByte(bRace); result.SetShort(sClass); result.SetByte(bLevel); result.SetByte(bFace); result.SetDword(nHair); result.SetByte(bZone); for (int i = 0; i < SLOT_MAX; i++) { if (i == HEAD || i == BREAST || i == SHOULDER || i == LEG || i == GLOVE || i == FOOT || i == RIGHTHAND || i == LEFTHAND) { result.SetDword(0); result.SetShort(0); } } } }
internal static bool GetLetterList(string strAccountID, ref Packet result, bool isHistory) { try { KODatabase db = new KODatabase(); byte bType = isHistory ? (byte)2 : (byte)1; var letterlist = db.MAIL_BOX.Where(i => i.strRecipientID == strAccountID && i.bStatus == bType && !i.bDeleted).Take(10); byte Count = (byte)letterlist.Count(); result.SetByte(1).SetByte(bType); foreach (MAIL_BOX letter in letterlist) { result.SetDword(letter.nLetterID) .SetByte(letter.bStatus) .SetString(letter.strSubject) .SetString(letter.strSenderID) .SetByte(letter.bType); if (letter.bType == 2) result.SetDword(letter.nItemID).SetShort(letter.sCount).SetDword(letter.nCoins); int DayDiff = (Int32)UNIXTIME - (Int32)(letter.dtSendDate.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; byte RemainDays = (byte)(DayDiff / 60 / 60 / 24); result.SetDword((int)UNIXTIME).SetByte(RemainDays); } } catch { return false; } return true; }