#include "stdafx.h" #include "Character.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include bool CCharacter::DropItem(unsigned short usProtoTypeID, unsigned char cNum) { Item::CItem* lpItem = Item::CItemFactory::GetInstance().CreateItem(usProtoTypeID); if (NULL != lpItem) { lpItem->SetNumOrDurability(min(cNum, lpItem->GetMaxNumOrDurability())); // edith 2009.08.19 DropItem ¾îµå¹Î ¸í·É¾î·Î Àåºñ µå¶ø½Ã ½ÃÁð·¹ÄÚµå ¼öÁ¤. Item::CEquipment* lpEquip = Item::CEquipment::DowncastToEquipment(lpItem); if(lpEquip && lpEquip->GetSeasonRecord() == 0) lpEquip->SetNewEquip(); if (false == GiveItem(lpItem)) { ERRLOG2(g_Log, "CID:%10u %dÁ¾·ùÀÇ ¾ÆÀÌÅÛÀ» ¶³±¸Áö ¸øÇß½À´Ï´Ù.", GetCID(), usProtoTypeID); DELETE_ITEM(lpItem); return false; } // GievItem À¸·Î ½ºÅÃµÈ °æ¿ì if (lpItem->IsSet(Item::DetailData::STACKABLE) && 0 == lpItem->GetNumOrDurability()) { DELETE_ITEM(lpItem); } } return true; } bool CCharacter::MovePos(Position Pos, char cZone, const bool bSitDown) { if (0 != CCellManager::GetInstance().GetCell(m_CellPos.m_wMapIndex, Pos.PositionToPOS())) { DETLOG5(g_Log, "CID:%10u ¿öÇÁ ¸í·ÉÀ» »ç¿ëÇÏ¿´½À´Ï´Ù. NewPos : %.1f, %.1f, %.1f, Zone : %d", m_dwCID, Pos.m_fPointX, Pos.m_fPointY, Pos.m_fPointZ, cZone); // edith 2009.07.21 ¿öÇÁ³ª Æ÷Å» »ç¿ë½Ã ÇöÀç ÁÂÇ¥°»½ÅÇϱâ (ºÒ¹ýÀ̵¿ ¹æÁö °ËÃâ ÇÇÇϱâ À§Çؼ­) m_CurrentPos.m_fPointX = Pos.m_fPointX; m_CurrentPos.m_fPointZ = Pos.m_fPointZ; return GameClientSendPacket::SendCharBindPosition(*this, 0, PktBP::BP_WARP, Pos, cZone, 0); } return false; } bool CCharacter::MoveZone(POS NewPos, char cZone, char Channel) { if (IsOperationFlagSet(CCharacter::MOVEZONE_PROCESSED)) { return true; } // BG_TODO : ¹èƲ ±×¶ó¿îµå Àü¿ë ¼­¹ö±º ÀÛ¾÷½Ã Ãß°¡ÇØ¾ß ÇÑ´Ù. /* if (cZone == SERVER_ID::ZONE3) { SYSTEMTIME systemTime; GetSystemTime(&systemTime); // ¹èƲ ±×¶ó¿îµå ÈÞ½Ä ½Ã°£µ¿¾È¿¡´Â ÁøÀÔÀ» ÇÒ¼ö ¾ø´Ù. if ((systemTime.wMinute >= CCreatureManager::STATUE_REST_TIME_1ST_START && systemTime.wMinute <= CCreatureManager::STATUE_REST_TIME_1ST_END) || (systemTime.wMinute >= CCreatureManager::STATUE_REST_TIME_2ND_START && systemTime.wMinute <= CCreatureManager::STATUE_REST_TIME_2ND_END)) { return false; } } */ if (NULL != m_lpGameClientDispatch) { CDBRequest DBRequest(*m_lpGameClientDispatch, 600); if (DBRequest.IsValid()) { if (GameClientSendPacket::SendMoveZoneToDBAgent(DBRequest.GetSendStream(), NewPos, DBRequest.GetRequestKey(), GetUID(), cZone, Channel)) { char* szPeaceMode = (true == IsPeaceMode()) ? "ÆòÈ­¸ðµå" : "ÀüÀï¸ðµå"; DETLOG5(g_Log, "UID:%d/CID:%10u(0x%p)/RequestKey:%d/DispatchPointer:0x%p Á¸ À̵¿ ¸í·ÉÀ» »ç¿ëÇÏ¿´½À´Ï´Ù.", m_dwUID, m_dwCID, this, DBRequest.GetRequestKey(), m_lpGameClientDispatch); DETLOG8(g_Log, "UID:%d/CID:%10u/ Á¸À̵¿ ´ç½ÃÀÇ Á¤º¸ÀÔ´Ï´Ù. NewPos : (%.1f, %.1f, %.1f), Zone : %d, Channel : %d (%s)", m_dwUID, m_dwCID, NewPos.fPointX, NewPos.fPointY, NewPos.fPointZ, cZone, Channel, szPeaceMode); GAMELOG::LogZoneMove(*this, cZone, Channel, 0); SetOperationFlag(CCharacter::MOVEZONE_PROCESSED); m_lpGameClientDispatch->PushRequestKey(DBRequest.GetRequestKey()); return true; } DBRequest.CancelRequest(); } } return false; } // ±æµåÀü, ±¹°¡Àü¿¡ ÇØ´çÇÏ´Â Á¸À¸·Î À̵¿ void CCharacter::MoveToGuildWarZone() { const Position targetPos = CCharRespawnMgr::GetInstance().GetTownRespawnPos(SERVER_ID::CAPITAL, GetNation()); if (CServerSetup::GetInstance().GetServerZone() == SERVER_ID::CAPITAL) { MoveTo(targetPos, false); POS pos; pos.fPointX = targetPos.m_fPointX; pos.fPointY = targetPos.m_fPointY; pos.fPointZ = targetPos.m_fPointZ; GameClientSendPacket::SendCharBindPosition(*this, 0, PktBP::BP_WARP, pos, CServerSetup::GetInstance().GetServerZone(), 0); } else { POS pos; pos.fPointX = targetPos.m_fPointX; pos.fPointY = targetPos.m_fPointY; pos.fPointZ = targetPos.m_fPointZ; MoveZone(pos, SERVER_ID::CAPITAL, -1); } } void CCharacter::MoveToRealmWarZone() { const int iLevel = GetLevel(); int iZone = SERVER_ID::STONE_WAR1; // edith 2009.06.13 °í·¾Àï°ú Àú·¾Àï ±¸ºÐ if(iLevel <= 60) iZone = SERVER_ID::STONE_WAR1; else //if(iLevel <= 80) iZone = SERVER_ID::STONE_WAR2; // else // iZone = SERVER_ID::STONE_WAR3; const Position targetPos = CCharRespawnMgr::GetInstance().GetTownRespawnPos(iZone, GetNation()); if (CServerSetup::GetInstance().GetServerZone() == iZone) { MoveTo(targetPos, false); POS pos; pos.fPointX = targetPos.m_fPointX; pos.fPointY = targetPos.m_fPointY; pos.fPointZ = targetPos.m_fPointZ; GameClientSendPacket::SendCharBindPosition(*this, 0, PktBP::BP_WARP, pos, CServerSetup::GetInstance().GetServerZone(), 0); } else { POS pos; pos.fPointX = targetPos.m_fPointX; pos.fPointY = targetPos.m_fPointY; pos.fPointZ = targetPos.m_fPointZ; MoveZone(pos, iZone, -1); } } bool CCharacter::Kill(CAggresiveCreature* lpAttacker) { if (true == Dead(NULL)) { AtType Type = {0,}; Type.m_wType = 1; const unsigned short wDamage = m_CreatureStatus.m_nNowHP; m_CreatureStatus.m_nNowHP = 0; // °ø°ÝÀÚ°¡ NULL ÀÌ¸é ¿î¿µÀÚ°¡ ´Ù¸¥ Á¸¿¡ Àִ ij¸¯Å͸¦ ¿î¿µÀÚ ¸í·ÉÀ¸·Î Á×ÀÎ °æ¿ìÀÌ´Ù. // ÀÌ·²¶§´Â ÀڱⰡ Á×ÀΰÍÀ¸·Î ó¸®ÇÑ´Ù. if (NULL == lpAttacker) lpAttacker = this; if (NULL != m_lpGameClientDispatch) { return GameClientSendPacket::SendCharAttacked(m_lpGameClientDispatch->GetSendStream(), lpAttacker, this, Type, 0, wDamage, 0, 0, PktBase::NO_SERVER_ERR); } return true; } return false; } bool CCharacter::NotifyInfo(unsigned long dwAdminCID) { char szMessage[PktChat::PktChatMaxSize] = ""; int nLen = _snprintf(szMessage, PktChat::PktChatMaxSize, "Name:%s, Class:%d, HP:%3d%%, MP:%3d%%, Zone:%d, X:%.1f, Y:%.1f, Z:%.1f, " "MinD:%d, MaxD:%d, HitRate:%d, Evade:%d, Armor:%d", GetCharacterName(), m_DBData.m_Info.Class, m_CreatureStatus.m_nNowHP * 100 / m_CreatureStatus.m_StatusInfo.m_nMaxHP, m_CreatureStatus.m_nNowMP * 100 / m_CreatureStatus.m_StatusInfo.m_nMaxMP, CServerSetup::GetInstance().GetServerZone(), m_CurrentPos.m_fPointX, m_CurrentPos.m_fPointY, m_CurrentPos.m_fPointZ, m_CreatureStatus.m_StatusInfo.m_lMinDamage, m_CreatureStatus.m_StatusInfo.m_lMaxDamage, m_CreatureStatus.m_StatusInfo.m_wHitRate, m_CreatureStatus.m_StatusInfo.m_wEvade, m_CreatureStatus.m_StatusInfo.m_wArmor); if (0 < nLen) { szMessage[PktChat::PktChatMaxSize - 1] = 0; // äÆÃ ¼­¹ö·Î Á¤º¸¸¦ º¸³½´Ù. GET_SINGLE_DISPATCH(lpChatDispatch, CChatDispatch, CChatDispatch::GetDispatchTable()); if (0 != lpChatDispatch) { const Position& pos = GetCurrentPos(); char strAdminCID[CHAR_INFOST::MAX_NAME_LEN] = ""; strcpy(strAdminCID, "0x"); char* strHexPos = (strAdminCID + 2); Math::Convert::Hex32ToStr(strHexPos, dwAdminCID); CChatRequestPacket chatReqPacket(szMessage, PktChat::NOTIFY_CHAR_INFO, 0, GetUID(), GetCID(), static_cast(pos.m_fPointX), static_cast(pos.m_fPointY), static_cast(pos.m_fPointZ), strAdminCID, 1); if (chatReqPacket.IsValid()) { return lpChatDispatch->GetSendStream().PutBuffer( chatReqPacket.GetCompressedPacket(), chatReqPacket.GetCompressedSize(), CmdCharChat); } } return true; } return false; } bool CCharacter::DuelInit(unsigned char cCmd) { // µà¾óÁßÀ̶ó¸é µà¾ó Ãë¼Ò CCharacter* lpDuelOpponent = static_cast(GetDuelOpponent()); if (NULL != lpDuelOpponent) { CGameClientDispatch* lpOpponentDispatch = lpDuelOpponent->GetDispatcher(); if (NULL != lpOpponentDispatch) { GameClientSendPacket::SendCharDuelCmd(lpOpponentDispatch->GetSendStream(), m_dwCID, lpDuelOpponent->GetCID(), cCmd, PktDuC::NO_SERVER_ERR); } if (NULL != m_lpGameClientDispatch) { GameClientSendPacket::SendCharDuelCmd(m_lpGameClientDispatch->GetSendStream(), m_dwCID, lpDuelOpponent->GetCID(), cCmd, PktDuC::NO_SERVER_ERR); } lpDuelOpponent->SetDuelOpponent(NULL); SetDuelOpponent(NULL); } // ÆÀ¹èƲ¿¡¼­ ºüÁü if (NULL != m_pParty) { if (NULL != reinterpret_cast(m_pParty)->GetHostileParty()) { if (PktDuC::DUC_CANCEL == cCmd || 0 == reinterpret_cast(m_pParty)->DropMember(this, static_cast(cCmd))) { reinterpret_cast(m_pParty)->GetHostileParty()->EndTeamBattle(); reinterpret_cast(m_pParty)->EndTeamBattle(); } } } return true; }