BOOL TMonsterAIElement::ApplyElementNightmareWarp(int iIndex, int iTargetIndex, TMonsterAIState * pAIState)
{
	LPOBJ lpObj = &gObj[iIndex];

	BYTE x = this->m_iX;
	BYTE y = this->m_iY;
	PMSG_MAGICATTACK_RESULT pAttack;

	PHeadSetBE((unsigned char *)&pAttack,0x19,sizeof(pAttack));

	pAttack.MagicNumberH = SET_NUMBERH(AT_SKILL_TELEPORT);
	pAttack.MagicNumberL = SET_NUMBERL(AT_SKILL_TELEPORT);

	pAttack.SourceNumberH = SET_NUMBERH(iIndex);
	pAttack.SourceNumberL = SET_NUMBERL(iIndex);
	pAttack.TargetNumberH = SET_NUMBERH(iIndex);
	pAttack.TargetNumberL = SET_NUMBERL(iIndex);

	if ( lpObj->Type == OBJ_USER )
		DataSend(iIndex,(unsigned char *)&pAttack,pAttack.h.size);

	MsgSendV2(lpObj,(unsigned char*)&pAttack,pAttack.h.size);

	LogAddC(2, "[%s] Warp [%d,%d] -> [%d,%d]",
		lpObj->Name, lpObj->X, lpObj->Y, x, y);

	gObjTeleportMagicUse(iIndex,x,y);
	lpObj->TargetNumber = -1;

	return FALSE;
}
// ----------------------------------------------------------------------------------------------------------------------
void CDarkSpirit::SendAttackMsg(int aIndex, int aTargetIndex, int criticaldamage, int iActionType)
{
	PMSG_PET_ITEM_ATTACK_COMMAND pMsg;

	if ( criticaldamage != 2 )
	{
		pMsg.PetType = 0;
		pMsg.SkillType = (criticaldamage)? 0 : 1;
		pMsg.NumberH = SET_NUMBERH(aIndex);
		pMsg.NumberL = SET_NUMBERL(aIndex);
		pMsg.TargetNumberH = SET_NUMBERH(aTargetIndex);
		pMsg.TargetNumberL = SET_NUMBERL(aTargetIndex);
		pMsg.h.set((LPBYTE)&pMsg, 0xA8, sizeof(pMsg));
		
		gSendProto.DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
		gSendProto.VPMsgSend(&gObj[aIndex], (UCHAR*)&pMsg, pMsg.h.size);

		if ( iActionType == 1 )
		{
			criticaldamage = 0;
			
			if ( (rand()%10) < 3 )
			{
				criticaldamage = TRUE;
			}
		}
	}
	else
	{
		criticaldamage = 0;
	}

	gObjAddAttackProcMsgSendDelay(&gObj[aIndex], 51, aTargetIndex, 600, criticaldamage, iActionType);
}
BOOL TMonsterSkillElement::ApplyElementTeleportSkill(int iIndex, int iTargetIndex)
{
	if ( !OBJMAX_RANGE(iIndex))
		return FALSE;

	if ( gObjCheckUsedBuffEffect(&gObj[iIndex],BUFF_STUN) == TRUE )
		return FALSE;

	if ( gObjCheckUsedBuffEffect(&gObj[iIndex],BUFF_SLEEP) == TRUE )
		return FALSE;

	if ( gObjCheckUsedBuffEffect(&gObj[iIndex],BUFF_EARTHBINDS) == TRUE )
		return FALSE;

	LPOBJ lpObj = &gObj[iIndex];

	BYTE x;
	BYTE y;
	int depth = rand()%4 + 3;
	PMSG_MAGICATTACK_RESULT pAttack;

	if ( (rand()%2) == 0 )
		x = lpObj->X + depth;
	else
		x = lpObj->X - depth;

	if ( (rand()%2) == 0 )
		y = lpObj->Y + depth;
	else
		y = lpObj->Y - depth;

	if ( gObjCheckTeleportArea(iIndex, x, y) == FALSE )
	{
		LogAddC(2, "[%s] Try Teleport Not Move Area [%d,%d]", lpObj->Name,	x, y);
		return FALSE;
	}

	PHeadSetBE((LPBYTE)&pAttack, 0x19, sizeof(pAttack));

	pAttack.MagicNumberH = SET_NUMBERH(AT_SKILL_TELEPORT);
	pAttack.MagicNumberL = SET_NUMBERL(AT_SKILL_TELEPORT);

	pAttack.SourceNumberH = SET_NUMBERH(iIndex);
	pAttack.SourceNumberL = SET_NUMBERL(iIndex);
	pAttack.TargetNumberH = SET_NUMBERH(iIndex);
	pAttack.TargetNumberL = SET_NUMBERL(iIndex);

	if ( lpObj->Type == OBJ_USER )
		DataSend(iIndex, (LPBYTE)&pAttack, pAttack.h.size);	

	MsgSendV2(lpObj, (LPBYTE)&pAttack, pAttack.h.size);	

	LogAddC(2, "[%s] Warp [%d,%d] -> [%d,%d]", lpObj->Name, lpObj->X, lpObj->Y, x, y);

	gObjTeleportMagicUse(iIndex, x, y);
	lpObj->TargetNumber = -1;

	return FALSE;
}
Exemple #4
0
void ShopBoard::GCAnsItemSearch(int UserIndex, WORD ItemID)
{
	LPOBJ lpUser	= &gObj[UserIndex];
	const int Size	= (sizeof(SHOPBOARD_GCANS_SHOPCOUNT) + sizeof(SHOPBOARD_GCANS_SHOPINFO)) * OBJMAXUSER;
	BYTE Temp[Size]	= { 0 };
	int Offset		= sizeof(SHOPBOARD_GCANS_SHOPCOUNT);
	int Count		= 0;
	SHOPBOARD_GCANS_SHOPINFO lpInfo = { 0 };
	// ----
	for( int i = OBJ_STARTUSERINDEX; i < OBJMAX; i++ )
	{
		if(		gObj[i].m_bPShopOpen == false 
			||	gObj[i].Connected < PLAYER_PLAYING 
			||	UserIndex == i )
		{
			continue;
		}
		// ----
		if( ItemID != (WORD)-1 )
		{
			for( int ItemPos = MAIN_INVENTORY_SIZE; ItemPos < INVENTORY_SIZE - 1; ItemPos++ )
			{
				if(		gObj[i].Inventory1[ItemPos].IsItem()
					&&	gObj[i].Inventory1[ItemPos].m_Type == ItemID )
				{
					lpInfo.UserIndexH = SET_NUMBERH(i);
					lpInfo.UserIndexL = SET_NUMBERL(i);
					memcpy(lpInfo.UserName, gObj[i].Name, MAX_ACCOUNT_LEN);
					memcpy(lpInfo.ShopName, gObj[i].m_szPShopText, 36);
					Count++;
					memcpy(&Temp[Offset], (LPBYTE)&lpInfo, sizeof(SHOPBOARD_GCANS_SHOPINFO));
					Offset += sizeof(SHOPBOARD_GCANS_SHOPINFO);
				}
			}
		}
		else
		{
			lpInfo.UserIndexH = SET_NUMBERH(i);
			lpInfo.UserIndexL = SET_NUMBERL(i);
			memcpy(lpInfo.UserName, gObj[i].Name, MAX_ACCOUNT_LEN);
			memcpy(lpInfo.ShopName, gObj[i].m_szPShopText, 36);
			Count++;
			memcpy(&Temp[Offset], (LPBYTE)&lpInfo, sizeof(SHOPBOARD_GCANS_SHOPINFO));
			Offset += sizeof(SHOPBOARD_GCANS_SHOPINFO);
		}
	}
	// ----
	SHOPBOARD_GCANS_SHOPCOUNT lpAnswer = { 0 };
	lpAnswer.h.c		= 0xC2;
	lpAnswer.h.headcode = 0xEC;
	lpAnswer.h.subcode	= 0x31;
	lpAnswer.h.sizeH	= SET_NUMBERH(Offset);
	lpAnswer.h.sizeL	= SET_NUMBERL(Offset);
	lpAnswer.Count		= Count;
	memcpy(&Temp[0], (LPBYTE)&lpAnswer, sizeof(SHOPBOARD_GCANS_SHOPCOUNT));
	// ----
	DataSend(UserIndex, Temp, Offset);
}
void GuildMatch::DGAnsOfferList(LPBYTE lpData)
{
	GUILDMATCH_DGANS_OFFERLIST_COUNT* lpRecvCount = (GUILDMATCH_DGANS_OFFERLIST_COUNT*)lpData;
	// ----
	if(		!OBJMAX_RANGE(lpRecvCount->UserIndex) 
		||	gObj[lpRecvCount->UserIndex].Connected != PLAYER_PLAYING )
	{
		return;
	}
	// ----
	GUILDMATCH_GCANS_OFFERLIST_COUNT lpAnswerCount = { 0 };
	lpAnswerCount.h.c			= 0xC2;
	lpAnswerCount.h.headcode	= 0xED;
	lpAnswerCount.h.subcode		= 0x00;
	lpAnswerCount.h.sizeH		= SET_NUMBERH(sizeof(GUILDMATCH_GCANS_OFFERLIST_COUNT));
	lpAnswerCount.h.sizeL		= SET_NUMBERL(sizeof(GUILDMATCH_GCANS_OFFERLIST_COUNT));
	lpAnswerCount.CurrentPage	= lpRecvCount->CurrentPage;
	lpAnswerCount.MaxPage		= lpRecvCount->MaxPage;
	lpAnswerCount.OfferCount	= lpRecvCount->OfferCount;
	int Offset = sizeof(GUILDMATCH_GCANS_OFFERLIST_COUNT);
	// ----
	if( lpAnswerCount.OfferCount <= 0 )
	{
		DataSend(lpRecvCount->UserIndex, (LPBYTE)&lpAnswerCount, Offset);
		return;
	}
	// ----
	GUILDMATCH_DGANS_OFFERLIST_INFO* lpRecvInfo	= (GUILDMATCH_DGANS_OFFERLIST_INFO*)&lpData[sizeof(GUILDMATCH_DGANS_OFFERLIST_COUNT)];
	const int Size = sizeof(GUILDMATCH_GCANS_OFFERLIST_COUNT) + sizeof(GUILDMATCH_GCANS_OFFERLIST_INFO) * GUILD_MATCH_MAX_PAGELINE;
	BYTE Buffer[Size + 1] = { 0 };
	// ----
	for( int i = 0; i < lpAnswerCount.OfferCount; i++ )
	{
		GUILDMATCH_GCANS_OFFERLIST_INFO lpAnswerInfo = { 0 };
		// ----
		memcpy(lpAnswerInfo.Title, lpRecvInfo[i].Title, sizeof(lpAnswerInfo.Title));
		memcpy(lpAnswerInfo.GuildMaster, lpRecvInfo[i].GuildMaster, sizeof(lpAnswerInfo.GuildMaster));
		memcpy(lpAnswerInfo.GuildName, lpRecvInfo[i].GuildName, sizeof(lpAnswerInfo.GuildName));
		lpAnswerInfo.GuildMemberCount = lpRecvInfo[i].GuildMemberCount;
		lpAnswerInfo.GuildMasterClass = lpRecvInfo[i].GuildMasterClass / 16; //wrong...
		lpAnswerInfo.GuildInterests = lpRecvInfo[i].GuildInterests;
		lpAnswerInfo.GuildReqLevel = lpRecvInfo[i].GuildReqLevel;
		lpAnswerInfo.GuildReqClass = lpRecvInfo[i].GuildReqClass;
		lpAnswerInfo.GuildMasterLevel = lpRecvInfo[i].GuildMasterLevel;
		lpAnswerInfo.GuildGensClass = lpRecvInfo[i].GuildGensClass;
		lpAnswerInfo.OfferNumber = lpRecvInfo[i].OfferNumber;
		memcpy(&Buffer[Offset], (LPBYTE)&lpAnswerInfo, sizeof(GUILDMATCH_GCANS_OFFERLIST_INFO));
		Offset += sizeof(GUILDMATCH_GCANS_OFFERLIST_INFO);
	}
	// ----
	lpAnswerCount.h.sizeH = SET_NUMBERH(Offset);
	lpAnswerCount.h.sizeL = SET_NUMBERL(Offset);
	memcpy(Buffer, (LPBYTE)&lpAnswerCount, sizeof(GUILDMATCH_GCANS_OFFERLIST_COUNT));
	DataSend(lpRecvCount->UserIndex, Buffer, Offset);
}
BOOL TMonsterSkillElement::ApplyElementTeleportSkill(int iIndex, int iTargetIndex)
{
	if ( !OBJMAX_RANGE(iIndex))
		return FALSE;

	if ( gObj[iIndex].m_iSkillStunTime > 0 )
		return FALSE;

	LPOBJ lpObj = &gObj[iIndex];
	BYTE x;
	BYTE y;
	int depth = rand()%4 + 3;
	PMSG_MAGICATTACK_RESULT pAttack;

	if ( (rand()%2) == 0 )
		x = lpObj->X + depth;
	else
		x = lpObj->X - depth;

	if ( (rand()%2) == 0 )
		y = lpObj->Y + depth;
	else
		y = lpObj->Y - depth;

	if ( gObjCheckTeleportArea(iIndex, x, y) == FALSE )
	{
		CLog.LogAddC(TColor.Red(), "[%s][%s] Try Teleport Not Move Area [%d,%d]",
			lpObj->AccountID, lpObj->Name,	x, y);
		
		return FALSE;
	}

	C3HeadSet((LPBYTE)&pAttack, 0x19, sizeof(pAttack));

	pAttack.MagicNumberH = SET_NUMBERH(6);
	pAttack.MagicNumberL = SET_NUMBERL(6);
	pAttack.SourceNumberH = SET_NUMBERH(iIndex);
	pAttack.SourceNumberL = SET_NUMBERL(iIndex);
	pAttack.TargetNumberH = SET_NUMBERH(iIndex);
	pAttack.TargetNumberL = SET_NUMBERL(iIndex);

	if ( lpObj->Type == OBJ_USER )
		gSendProto.DataSend(iIndex, (LPBYTE)&pAttack, pAttack.h.size);	

	gSendProto.VPMsgSend(lpObj, (LPBYTE)&pAttack, pAttack.h.size);	

	CLog.LogAddC(TColor.Red(), "[%s] Warp [%d,%d] -> [%d,%d]",
		lpObj->Name, lpObj->X, lpObj->Y, x, y);

	gObjTeleportMagicUse(iIndex, x, y);
	lpObj->TargetNumber = -1;

	return FALSE;
}
Exemple #7
0
void GCDamageSend(int aIndex,int TargetIndex,int AttackDamage,int MSBFlag,int MSBDamage,int iShieldDamage)
{
    PMSG_ATTACKRESULT pResult;

#if (IS_PROTOCOL_JPN == 0)
    PHeadSetB((LPBYTE)&pResult,0x11,sizeof(pResult));	// (1.03P 1.03.16 main)
#else
    PHeadSetB((LPBYTE)&pResult,0xDC,sizeof(pResult));	// (1.03K 1.03.11 main)
#endif

    pResult.NumberH = SET_NUMBERH(TargetIndex);
    pResult.NumberL = SET_NUMBERL(TargetIndex);
    pResult.DamageH = SET_NUMBERH(AttackDamage);
    pResult.DamageL = SET_NUMBERL(AttackDamage);

    pResult.btShieldDamageH = SET_NUMBERH(iShieldDamage);
    pResult.btShieldDamageL = SET_NUMBERL(iShieldDamage);

    if(MSBFlag != false)
    {
        pResult.NumberH &= 0x7F;
        pResult.NumberH |= 0x80;
    }

    pResult.DamageType = MSBDamage;

    OBJECTSTRUCT * gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
    OBJECTSTRUCT * gTarg = (OBJECTSTRUCT*)OBJECT_POINTER(TargetIndex);

    pResult.Life = gTarg->Life;
    pResult.MaxLife = gTarg->MaxLife + gTarg->AddLife;

    pResult.X = gTarg->X;
    pResult.Y = gTarg->Y;

    if(gTarg->Type == OBJECT_MONSTER)
    {
        pResult.Life = gTarg->Life;
        pResult.MaxLife = gTarg->MaxLife + gTarg->AddLife;
    }

    if(gTarg->Type == OBJECT_USER)
    {
        DataSend(TargetIndex, (LPBYTE)&pResult, pResult.h.size);
    }

    if(gObj->Type == OBJECT_USER)
    {
        DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
    }

    lpGCDamageSend(aIndex, TargetIndex, AttackDamage, MSBFlag, MSBDamage, iShieldDamage);
}
Exemple #8
0
void DGPartyMatchReqList(PARTYMATCH_GDREQ_REQUESTLIST* lpData, int aIndex)
{
	const int MaxSize = sizeof(PARTYMATCH_DGANS_REQUESTLIST_COUNT) + sizeof(PARTYMATCH_DGANS_REQUESTLIST_INFO) * 80;
	BYTE Buffer[MaxSize + 1] = { 0 };
	int Offset = sizeof(PARTYMATCH_DGANS_REQUESTLIST_COUNT);
	// ----
	PARTYMATCH_DGANS_REQUESTLIST_COUNT* lpAnswerCount = (PARTYMATCH_DGANS_REQUESTLIST_COUNT*)Buffer;
	PARTYMATCH_DGANS_REQUESTLIST_INFO* lpAnswerInfo = (PARTYMATCH_DGANS_REQUESTLIST_INFO*)&Buffer[Offset];
	// ----
	lpAnswerCount->h.c = PMHC_WORD;
	lpAnswerCount->h.headcode = 0xEF;
	lpAnswerCount->h.subcode = 0x04;
	lpAnswerCount->h.sizeH = SET_NUMBERH(Offset);
	lpAnswerCount->h.sizeL = SET_NUMBERL(Offset);
	lpAnswerCount->UserIndex = lpData->UserIndex;
	// ----
	char Query[256];
	long Len = 0;
	// ----
	sprintf(Query, "EXEC PartyMatching_GetRequestList '%s'", lpData->PartyLeader);
	// ----
	if( !g_PartyMatchDB.Exec(Query) )
	{
		g_PartyMatchDB.Clear();
		DataSend(aIndex, (LPBYTE)lpAnswerCount, Offset);
		return;
	}
	// ----
	int Result, Count = 0;
	// ----
	while( (Result = g_PartyMatchDB.Fetch()) != SQL_NO_DATA && Result != SQL_ERROR )
	{
		g_PartyMatchDB.GetStr("Name", lpAnswerInfo[Count].Character);
		lpAnswerInfo[Count].Class = g_PartyMatchDB.GetInt("SenderClass");
		lpAnswerInfo[Count].Level = g_PartyMatchDB.GetInt("SenderLevel");
		Offset += sizeof(PARTYMATCH_DGANS_REQUESTLIST_INFO);
		Count++;
	}
	// ----
	while( g_PartyMatchDB.MoreResults() != SQL_NO_DATA )
	{
		
	}
	// ----
	g_PartyMatchDB.Clear();
	// ----
	lpAnswerCount->h.sizeH = SET_NUMBERH(Offset);
	lpAnswerCount->h.sizeL = SET_NUMBERL(Offset);
	lpAnswerCount->Count = Count;
	// ----
	DataSend(aIndex, (LPBYTE)Buffer, Offset);
}
Exemple #9
0
//========================================================================================================================
void COFFTrade::CreateOfflineTrade(int aIndex)
{
	


	int OfftradeMapN = GetPrivateProfileInt("OffTrade","OfftradeMap",0,".\\Config\\OffTrade.cfg");
	int OfftradeSendAll = GetPrivateProfileInt("OffTrade","OfftradeSendAll",0,".\\Config\\OffTrade.cfg");
	char OfftradeShopM[50];
	OBJECTSTRUCT *gObj = (OBJECTSTRUCT*)OBJECT_POINTER(aIndex);
    if(gObj->m_bPShopOpen == false)
    {
        MsgNormal(aIndex,"First Open you Store!");
        return;
    }
	if(gObj->MapNumber != OfftradeMapN)
	{
		MsgNormal(aIndex,"OffTrade can be only in %s",GetMapName(OfftradeMapN));
		return;
	}
	if (gObj->OffTradeCoin == 1)
	{
		char TextShop[36] = "<<COIN SHOP>>";	
			PMSG_ANS_PSHOP_TEXT_CHANGED pMsg;
			PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x10, sizeof(pMsg));
			pMsg.NumberH = SET_NUMBERH(aIndex);
			pMsg.NumberL = SET_NUMBERL(aIndex);
			memcpy(gObj->m_szPShopText, TextShop, sizeof(pMsg.btPShopText));
			memcpy(pMsg.btPShopText, TextShop, sizeof(pMsg.btPShopText));
			memcpy(pMsg.btName, gObj->Name, sizeof(pMsg.btName));
			DataSendB(aIndex, (char*)&pMsg, pMsg.h.size);
			MsgAll("[OffTrade] %s now state in %s X:%d Y:%d Exchange:COIN",gObj->Name,GetMapName(gObj->MapNumber),gObj->X,gObj->Y);
	}
	if (gObj->OffTradeZen == 1)
	{
		char TextShop[36] = "<<ZEN SHOP>>";
			PMSG_ANS_PSHOP_TEXT_CHANGED pMsg;
			PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x10, sizeof(pMsg));
			pMsg.NumberH = SET_NUMBERH(aIndex);
			pMsg.NumberL = SET_NUMBERL(aIndex);
			memcpy(gObj->m_szPShopText, TextShop, sizeof(pMsg.btPShopText));
			memcpy(pMsg.btPShopText, TextShop, sizeof(pMsg.btPShopText));
			memcpy(pMsg.btName, gObj->Name, sizeof(pMsg.btName));
			DataSendB(aIndex, (char*)&pMsg, pMsg.h.size);
			MsgAll("[OffTrade] %s now state in %s:X %d Y:%d Exchange:COIN",gObj->Name,GetMapName(gObj->MapNumber),gObj->X,gObj->Y);
	}

	OfflineShop[aIndex].IsOffTrade=1;
    CloseClient(aIndex);

}
void GuildMatch::DGAnsJoinReqList(LPBYTE lpData)
{
	GUILDMATCH_DGANS_REQUESTLIST_COUNT* lpRecvCount = (GUILDMATCH_DGANS_REQUESTLIST_COUNT*)lpData;
	// ----
	if(		!OBJMAX_RANGE(lpRecvCount->UserIndex) 
		||	gObj[lpRecvCount->UserIndex].Connected != PLAYER_PLAYING )
	{
		return;
	}
	// ----
	GUILDMATCH_GCANS_REQUESTLIST_COUNT lpAnswer = { 0 };
	lpAnswer.h.c			= 0xC2;
	lpAnswer.h.headcode		= 0xED;
	lpAnswer.h.subcode		= 0x07;
	lpAnswer.h.sizeH		= SET_NUMBERH(sizeof(lpAnswer));
	lpAnswer.h.sizeL		= SET_NUMBERL(sizeof(lpAnswer));
	lpAnswer.RequestCount	= lpRecvCount->Count;
	// ----
	GUILDMATCH_DGANS_REQUESTLIST_INFO* lpRecvInfo = (GUILDMATCH_DGANS_REQUESTLIST_INFO*)&lpData[sizeof(GUILDMATCH_DGANS_REQUESTLIST_COUNT)];
	// ----
	for( int i = 0; i < lpAnswer.RequestCount; i++ )
	{
		memcpy(lpAnswer.m_RequestList[i].Character, lpRecvInfo[i].Character, 10);
		lpAnswer.m_RequestList[i].Class = lpRecvInfo[i].Class / 16; //wrong...
		lpAnswer.m_RequestList[i].Level = lpRecvInfo[i].Level;
	}
	// ----
	DataSend(lpRecvCount->UserIndex, (LPBYTE)&lpAnswer, sizeof(lpAnswer));
}
Exemple #11
0
void DGPartyMatchInfo(LPMSG_PARTYMATCHING_INFO_REQ lpMsg,int aIndex)
{
	BYTE cBUFFER[1024];

	int lOfs = sizeof(PMSG_PARTYMATCHING_INFO_ANS);

	LPMSG_PARTYMATCHING_INFO_ANS lpMsgCount = (LPMSG_PARTYMATCHING_INFO_ANS)&cBUFFER[0];
	PARTYMATCH_INFO* lpMsgBody = (PARTYMATCH_INFO*)&cBUFFER[lOfs];

	lpMsgCount->h.c = PMHC_WORD;
	lpMsgCount->h.headcode = 0xEF;
	lpMsgCount->h.subcode = 0x01;
	lpMsgCount->page = lpMsg->RequestPage;
	lpMsgCount->aIndex = lpMsg->aIndex;

	memcpy(lpMsgCount->szName,lpMsg->szName,sizeof(lpMsgCount->szName)-1);
	lpMsgCount->szName[sizeof(lpMsgCount->szName)-1] = '\0';

	lpMsgCount->iResult = PartyMatchInfo(lpMsg,lpMsgBody,lpMsgCount->count,lpMsgCount->totalpage);

	lOfs += lpMsgCount->count*sizeof(PARTYMATCH_INFO);

	lpMsgCount->h.sizeH = SET_NUMBERH(lOfs);
	lpMsgCount->h.sizeL = SET_NUMBERL(lOfs);

	DataSend(aIndex,(LPBYTE)&cBUFFER[0],lOfs);
}
Exemple #12
0
void DGAnsCsLoadTotalGuildInfo(LPCSP_REQ_CSLOADTOTALGUILDINFO lpMsg,int aIndex)
{
	BYTE SendData[sizeof(CSP_ANS_CSLOADTOTALGUILDINFO) + sizeof(CSP_CSLOADTOTALGUILDINFO) * MAX_CS_GUILDLIST] = {0};

	CSP_ANS_CSLOADTOTALGUILDINFO * pMsg = (CSP_ANS_CSLOADTOTALGUILDINFO*)SendData;
	CSP_CSLOADTOTALGUILDINFO * pMsgBody = (CSP_CSLOADTOTALGUILDINFO*)&SendData[sizeof(CSP_ANS_CSLOADTOTALGUILDINFO)];

	pMsg->h.c = 0xC2;
	pMsg->h.headcode = 0x88;
	pMsg->wMapSvrNum = lpMsg->wMapSvrNum;
	pMsg->iResult = TRUE;

	pMsg->iCount = CsLoadTotalGuildInfo(lpMsg->wMapSvrNum,pMsgBody);

	if(pMsg->iCount < 0)
	{
		pMsg->iCount = 0;
		pMsg->iResult = FALSE;
	}

	int size = sizeof(CSP_ANS_CSLOADTOTALGUILDINFO) + sizeof(CSP_CSLOADTOTALGUILDINFO) * pMsg->iCount;

	pMsg->h.sizeH = SET_NUMBERH(size);
	pMsg->h.sizeL = SET_NUMBERL(size);

	DataSend(aIndex,(PBYTE)SendData,size);
}
Exemple #13
0
void DGAnsCalcRegGuildList(LPCSP_REQ_CALCREGGUILDLIST lpMsg,int aIndex)
{
	BYTE SendData[sizeof(CSP_ANS_CALCREGGUILDLIST) + sizeof(CSP_CALCREGGUILDLIST) * MAX_CS_GUILDLIST] = {0};
	
	LPCSP_ANS_CALCREGGUILDLIST pMsg = (LPCSP_ANS_CALCREGGUILDLIST)SendData;
	LPCSP_CALCREGGUILDLIST pMsgBody = (LPCSP_CALCREGGUILDLIST)&SendData[sizeof(CSP_ANS_CALCREGGUILDLIST)];

	pMsg->h.c = PMHC_WORD;
	pMsg->h.headcode = 0x85;
	pMsg->wMapSvrNum = lpMsg->wMapSvrNum;

	pMsg->iResult = TRUE;
	pMsg->iCount = GetCalcRegGuildList(lpMsg->wMapSvrNum,pMsgBody);

	if(pMsg->iCount < 0)
	{
		pMsg->iCount = 0;
		pMsg->iResult = FALSE;
	}

	int size = sizeof(CSP_ANS_CALCREGGUILDLIST) + sizeof(CSP_CALCREGGUILDLIST) * pMsg->iCount;

	pMsg->h.sizeH = SET_NUMBERH(size);
	pMsg->h.sizeL = SET_NUMBERL(size);

	DataSend(aIndex,(PBYTE)SendData,size);
}
Exemple #14
0
void DGAnsCastleInitData(LPCSP_REQ_CSINITDATA lpMsg,int aIndex)
{
	BYTE SendData[sizeof(CSP_ANS_CSINITDATA) + (sizeof(CSP_CSINITDATA) * MAX_CS_NPC)] = {0};

	LPCSP_ANS_CSINITDATA pMsg = (LPCSP_ANS_CSINITDATA)SendData;
	LPCSP_CSINITDATA pMsgBody = (LPCSP_CSINITDATA)&SendData[sizeof(CSP_ANS_CSINITDATA)];

	pMsg->h.c = 0xC2;
	pMsg->h.headcode = 0x81;
	pMsg->wMapSvrNum = lpMsg->wMapSvrNum;
	pMsg->iCount = 0;
	pMsg->iResult = 0;

	if(GetCastleTotalInfo(lpMsg->wMapSvrNum,lpMsg->iCastleEventCycle,pMsg) == TRUE)
	{
		pMsg->iResult = TRUE;
		pMsg->iCount = GetCastleNpcInfo(lpMsg->wMapSvrNum,pMsgBody);
	}

	int size = sizeof(CSP_ANS_CSINITDATA) + (sizeof(CSP_CSINITDATA)*pMsg->iCount);
	pMsg->h.sizeH = SET_NUMBERH(size);
	pMsg->h.sizeL = SET_NUMBERL(size);

	DataSend(aIndex,(LPBYTE)SendData,size);
}
Exemple #15
0
void PHeadSetW(LPBYTE lpBuf, BYTE head,  int size) 
{
	lpBuf[0] = 0xC2;	// Packets Header
	lpBuf[1]= SET_NUMBERH(size);
	lpBuf[2]= SET_NUMBERL(size);
	lpBuf[3]= head;
}
Exemple #16
0
void DGAnsPeriodItemList(LPMSG_REQ_PERIODITEM_LIST lpMsg, int aIndex)
{
	char szName[MAX_IDSTRING+1] = {0};
	memcpy(szName,lpMsg->chCharacterName,MAX_IDSTRING);

	PMSG_ANS_PERIODITEM_LIST pMsg;

	pMsg.head.c = PMHC_WORD;
	pMsg.head.headcode = 0xD0;
	pMsg.head.subcode = 0x06;
	pMsg.head.sizeH = SET_NUMBERH(sizeof( pMsg ));
	pMsg.head.sizeL = SET_NUMBERL(sizeof( pMsg ));

	pMsg.btResult = FALSE;

	pMsg.iUserGuid = lpMsg->iUserGuid;
	pMsg.iUserIndex = lpMsg->iUserIndex;

	pMsg.btCount = GetPeriodItemList(lpMsg->iUserGuid,szName,&pMsg.Items[0]);

	if(pMsg.btCount <= 0)
	{
		pMsg.btResult = -1;
	}

	DataSend(aIndex,(LPBYTE)&pMsg,sizeof(pMsg));
}
Exemple #17
0
void AutoExpClass__AddExp(void * lpParam)
{
	PMSG_KILLPLAYER pkillMsg;
	PHeadSetBE((LPBYTE)&pkillMsg, 0x16, sizeof(pkillMsg));

	while(AutoExp.Enabled)
	{
		Sleep(AutoExp.Time);
		for ( int n = OBJ_STARTUSERINDEX ; n < OBJMAX ; n++)
		{
			if ( gObj[n].Connected == PLAYER_PLAYING )
			{
				if ( gObj[n].Type == OBJ_USER )
				{
					if((gObj[n].Level < ReadConfig.Max_Normal_Level)||(gObj[n].MasterCharacterInfo->MasterLevel < ReadConfig.Max_Master_Level))
					{
						if(gObjItsInSafeZone(gObj[n].m_Index) == 1)//If safezone
						{
							int AddExp = 0;
							AddExp = (int)(AutoExp.BaseExp * gObj[n].Level) ;
						
							if(AddExp > 0x0FFFF)
								AddExp = 65534;

							if(AddExp > 0)
							{
								pkillMsg.NumberH = 0xFF;
								pkillMsg.NumberL = 0xFF;
								pkillMsg.ExpH = SET_NUMBERH(AddExp);
								pkillMsg.ExpL = SET_NUMBERL(AddExp);
								pkillMsg.DamageH = SET_NUMBERH(0x00);
								pkillMsg.DamageL = SET_NUMBERL(0x00);

								DataSend(gObj[n].m_Index, (UCHAR*)&pkillMsg, pkillMsg.h.size);

								gObjSetExpPetItem(n, AddExp);
								int LevelUp = 0;
								gObjLevelUp(&gObj[n],AddExp,gObj[n].Class,EVENT_TYPE_AUTOEXP,LevelUp);
							}
						}
					}
				}
			}
		}
	}
}
Exemple #18
0
void PHeadSubSetW(LPBYTE lpBuf, BYTE head, BYTE sub,  int size)
{
	lpBuf[0]=0xC2;	// packet header
	lpBuf[1]=SET_NUMBERH(size);
	lpBuf[2]=SET_NUMBERL(size);
	lpBuf[3]=head;
	lpBuf[4]=sub;
}
Exemple #19
0
void JGGetCharacterInfo(LPSDHP_DBCHARINFOREQUEST lpMsg,int aIndex)
{
	SDHP_DBCHAR_INFORESULT pResult;

	PHeadSetW((LPBYTE)&pResult, 0x06, sizeof(pResult));

	char szAccountID[MAX_IDSTRING+1]={0};
	char szName[MAX_IDSTRING+1]={0};
	BuxConvert(lpMsg->Name, 10);

	memcpy(szAccountID, lpMsg->AccountID, MAX_IDSTRING);
	memcpy(szName, lpMsg->Name, MAX_IDSTRING);

	memcpy(pResult.AccountID, szAccountID, MAX_IDSTRING);
	memcpy(pResult.Name, szName, MAX_IDSTRING);

	pResult.Number = lpMsg->Number;

	pResult.result = GetCharacterInfo(szAccountID,szName,&pResult);

	if( pResult.result )
	{
		PartyMatchUpdateServerInfo(gSObj[aIndex].ServerCode, szName);
		
		UpdateGameIDC(szAccountID, szName);
	}

	DataSend(aIndex,(LPBYTE)&pResult,sizeof(pResult));

	if(pResult.result == TRUE)
	{
		SDHP_SKILLKEYDATA_SEND pSkillData = {0};

		pSkillData.h.c = PMHC_BYTE;
		pSkillData.h.size = sizeof( pSkillData );
		pSkillData.h.headcode = 0x60;

		memcpy(pSkillData.Name, szName, MAX_IDSTRING);
		pSkillData.aIndex = lpMsg->Number;

		GetOptionData(szName,&pSkillData);

		DataSend(aIndex,(LPBYTE)&pSkillData,pSkillData.h.size);

		MUBOT_SETTINGS_SEND pMuBot = {0};
		pMuBot.h.c = PMHC_WORD;
		pMuBot.h.sizeH = SET_NUMBERH(sizeof(pMuBot));
		pMuBot.h.sizeL = SET_NUMBERL(sizeof(pMuBot));
		pMuBot.h.headcode = 0x61;

		strcpy(pMuBot.szName,szName);
		pMuBot.aIndex = lpMsg->Number;
		GetMuBotData(szName,&pMuBot);
		DataSend(aIndex,(LPBYTE)&pMuBot,sizeof(pMuBot));
	}
}
Exemple #20
0
bool CClientNetWork::send(void* buf)
{
	static unsigned char s_XorBuf[MAX_EXSENDBUF_SIZE]	= {0};
	static unsigned char s_EncBuf[MAX_EXSENDBUF_SIZE]	= {0};
	// ----
	unsigned char* pMsg									= (unsigned char*)buf;
	// ---
	unsigned char uMsgType								= pMsg[0];
	// ----
	// # Get Size
	int len												= pMsg[1];
	// ----
	if ( uMsgType == 0xC2 || uMsgType == 0xC4 )
	{
		len = MAKE_NUMBERW(pMsg[1],pMsg[2]);
	}
	// ----
	// # Enc Xor Data
	// ----
	memcpy(s_XorBuf,buf,len);
	// ----
	pMsg = s_XorBuf;
	// ----
	EncXorData(pMsg,len,(uMsgType==0xC1||uMsgType==0xC3)?2:3);
	// ----
	// # Encrypt C3 C4
	// ---- 
	if((uMsgType == 0xC3) || (uMsgType == 0xC4))
	{
		s_uSerial++;
		// ----
		if(uMsgType == 0xC3)
		{
			pMsg[1]		= s_uSerial;
			// ----
			len			= g_SimpleModulusCS.Encrypt(& s_EncBuf[2], & pMsg[1], len-1) + 2;
			// ----
			s_EncBuf[0] = uMsgType;
			s_EncBuf[1] = len;
		}
		else
		{
			pMsg[2]		= s_uSerial;
			// ----
			len			= g_SimpleModulusCS.Encrypt(& s_EncBuf[3], & pMsg[2], len-2) + 3;
			// ----
			s_EncBuf[0] = uMsgType;
			s_EncBuf[1] = SET_NUMBERH(len);
			s_EncBuf[2] = SET_NUMBERL(len);
		}
		// ----
		pMsg = s_EncBuf;
	}
	// ----
	return CNetWork::DataSend(pMsg,len);
}
Exemple #21
0
void CRaklionUtil::NotifyRaklionWideAreaAttack(int iIndex, int iTargetIndex, int iSkillType) //00647C80 
{
	PMSG_NOTIFY_RAKLION_WIDE_AREA_ATTACK pMsg;

	PHeadSubSetB((LPBYTE)&pMsg, 0xD1, 0x14, sizeof(pMsg));
	pMsg.btObjClassH = SET_NUMBERH(gObj[iIndex].Class);
	pMsg.btObjClassL = SET_NUMBERL(gObj[iIndex].Class);
	pMsg.btType = iSkillType;

	this->SendDataToUser(iTargetIndex, (LPBYTE)&pMsg, sizeof(pMsg));
}
void CKanturuUtil::NotifyKanturuWideAreaAttack(int iIndex, int iTargetIndex, int iSkillType)
{
	PMSG_NOTIFY_KANTURU_WIDE_AREA_ATTACK pMsg;

	PHeadSubSetB((LPBYTE)&pMsg, 0xD1, 0x06, sizeof(pMsg));
	pMsg.btObjClassH = SET_NUMBERH(gObj[iIndex].Class);
	pMsg.btObjClassL = SET_NUMBERL(gObj[iIndex].Class);
	pMsg.btType = iSkillType;

	this->SendDataToUser(iTargetIndex, (LPBYTE)&pMsg, sizeof(pMsg));
}
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::SendPShopDealerClosedShop(int aSourceIndex, int aTargetIndex)
{
	PMSG_REQ_DEALER_CLOSED_SHOP pMsg;
	// ------
	C1SubHeadSet((LPBYTE)&pMsg, 0x3F, 0x12, sizeof(pMsg));
	// ------
	pMsg.NumberH = SET_NUMBERH(aTargetIndex);
	pMsg.NumberL = SET_NUMBERL(aTargetIndex);
	// ------
	gSendProto.DataSend(aSourceIndex, (LPBYTE)&pMsg, pMsg.h.size);
}
Exemple #24
0
//----- (0045F6C0) --------------------------------------------------------
void CLifeStone::SendLifeStoneState(int iIndex)
{
	LPOBJ lpObj = &gObj[iIndex];

	PMSG_LIFESTONE_STATE_STRUCT pSend;
	PHeadSubSetB((LPBYTE)&pSend, 0xB9, 1, sizeof(PMSG_LIFESTONE_STATE_STRUCT));
	pSend.NumberH	= SET_NUMBERH(iIndex);
	pSend.NumberL	= SET_NUMBERL(iIndex);
	pSend.State		= lpObj->m_btCreationState;

	::MsgSendV2(lpObj, (PBYTE)&pSend, pSend.h.size);
}
// ----------------------------------------------------------------------------------------------------------------------
void CDarkSpirit::SetMode(ePetItem_Mode mode, int iTargetindex)
{
	if ( this->m_iMasterIndex == -1 )
	{
		return;
	}

	LPOBJ lpObj = &gObj[this->m_iMasterIndex];

	if ( lpObj->Class != CLASS_DARKLORD )	// DL
	{
		return;
	}

	if ( mode == PetItem_Mode_Attack_Target || this->m_ActionMode != mode)
	{
		if ( mode == PetItem_Mode_Attack_Target )
		{
			if ( OBJMAX_RANGE(iTargetindex) != FALSE )
			{
				this->m_iTargetIndex = iTargetindex;
			}
			else
			{
				return;
			}
		}

		this->m_ActionMode = mode;
		PMSG_SEND_PET_ITEM_COMMAND pMsg;

		pMsg.h.set((LPBYTE)&pMsg, 0xA7, sizeof(pMsg));
		pMsg.PetType = 0;
		pMsg.Command = mode;
		pMsg.NumberH = SET_NUMBERH(this->m_iTargetIndex);
		pMsg.NumberL = SET_NUMBERL(this->m_iTargetIndex);

		gSendProto.DataSend(this->m_iMasterIndex, (UCHAR*)&pMsg, sizeof(pMsg));

		char strMode[4][255] =
		{
			"[Raven Mode Normal]",
			"[Raven Mode Random]",
			"[Raven Mode With Master]",
			"[Raven Mode Attack Target]"
		};
		
		/*char szNormal[256] = "[Raven Mode Normal]";
		char szRandom[256] = "[Raven Mode Random]";
		char szMaster[256] = "[Raven Mode With Master]";
		char szTarget[256] = "[Raven Mode Attack Target]";*/
	}
}
Exemple #26
0
void CDarkSpirit::SendAttackMsg(int aIndex, int aTargetIndex, int criticaldamage, int iActionType)
{
	PMSG_PET_ITEM_ATTACK_COMMAND pMsg;

	if ( criticaldamage != 3 )
	{
		pMsg.PetType = 0;
		pMsg.SkillType = (criticaldamage)? 0 : 1;
		pMsg.NumberH = SET_NUMBERH(aIndex);
		pMsg.NumberL = SET_NUMBERL(aIndex);
		pMsg.TargetNumberH = SET_NUMBERH(aTargetIndex);
		pMsg.TargetNumberL = SET_NUMBERL(aTargetIndex);
		pMsg.h.set((LPBYTE)&pMsg, 0xA8, sizeof(pMsg));
		
		DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
		MsgSendV2(&gObj[aIndex], (UCHAR*)&pMsg, pMsg.h.size);

		if ( iActionType == 1 )
		{
			criticaldamage = 0;
			LPOBJ lpObj = &gObj[aIndex];

			if ( (rand()%100) < (this->m_iCriticalSuccessRate+lpObj->m_MPSkillOpt.MpsDarkSpiritStr2) )
			{
				criticaldamage = 1;
			}

			if( (rand()%100) < (this->m_iExcelentSuccessRate+lpObj->m_MPSkillOpt.MpsDarkSpiritStr3) )
			{
				criticaldamage = 2;
			}
		}
	}
	else
	{
		criticaldamage = 0;
	}

	gObjAddAttackProcMsgSendDelay(&gObj[aIndex], 51, aTargetIndex, 600, criticaldamage, iActionType);
}
BOOL TMonsterAIUtil::SendMonsterMoveMsg(LPOBJ lpObj)
{
	PMSG_RECVMOVE pMove;

	PHeadSetB((LPBYTE)&pMove, PROTOCOL_MOVE, sizeof(pMove));
	pMove.NumberH = SET_NUMBERH(lpObj->m_Index);
	pMove.NumberL = SET_NUMBERL(lpObj->m_Index);
	pMove.X = lpObj->MTX;
	pMove.Y = lpObj->MTY;
	pMove.Path = lpObj->Dir << 4;

	this->SendMonsterV2Msg(lpObj, (LPBYTE)&pMove, pMove.h.size);
	return TRUE;
}
// -----------------------------------------------------------------------------------------------------------------------------------------------------
void CPersonalShop::SendPShopBuyItemResult(int aSourceIndex, int aTargetIndex, int iItemPos, BYTE btResult)
{
	PMSG_ANS_BUYITEM_FROM_PSHOP pMsg;
	// ------
	C1SubHeadSet((LPBYTE)&pMsg, 0x3F, 0x06, sizeof(pMsg));
	// ------
	pMsg.NumberH	= SET_NUMBERH(aTargetIndex);
	pMsg.NumberL	= SET_NUMBERL(aTargetIndex);
	pMsg.btItemPos	= iItemPos;
	pMsg.Result		= btResult;
	// ------
	ItemByteConvert(pMsg.cItemInfo, gObj[aSourceIndex].Inventory1[iItemPos]);
	// ------
	gSendProto.DataSend(aSourceIndex, (LPBYTE)&pMsg, pMsg.h.size);
}
BOOL TMonsterAIElement::ApplyElementAttackArea(int iIndex, int iTargetIndex, TMonsterAIState * pAIState)
{
	LPOBJ lpObj = &gObj[iIndex];
	UTIL.SendCrywolfChattingMsg(iIndex, "Element-영역공격");

	int iTargetX = this->m_iX + (rand()%5) * ((rand()%2==0)?1:-1 ) ;
	int iTargetY = this->m_iY + (rand()%5) * ((rand()%2==0)?1:-1 ) ;

	for (int i= OBJ_STARTUSERINDEX;i<OBJMAX;i++)
	{
		if ( !gObjIsConnected(i))
			continue;

		LPOBJ lpTargetObj = &gObj[i];

		if ( !lpObj->Live )
			continue;

		if ( lpObj->MapNumber != lpTargetObj->MapNumber )
			continue;

		int iTargetDistance = (int)sqrt(double(((lpTargetObj->X - iTargetX)*(lpTargetObj->X - iTargetX)) + ((lpTargetObj->Y - iTargetY)*(lpTargetObj->Y - iTargetY))));

		if ( iTargetDistance < 10 )
		{
			PMSG_NOTIFY_REGION_MONSTER_ATTACK pMsg;

			PHeadSubSetB((LPBYTE)&pMsg, 0xBD, 0x0C, sizeof(pMsg));
			pMsg.btObjClassH = SET_NUMBERH(lpObj->Class);
			pMsg.btObjClassL = SET_NUMBERL(lpObj->Class);
			pMsg.btSourceX = lpObj->X;
			pMsg.btSourceY = lpObj->Y;
			pMsg.btPointX = iTargetX;
			pMsg.btPointY = iTargetY;

			DataSend(lpTargetObj->m_Index, (LPBYTE)&pMsg, sizeof(pMsg));
		}

		if ( iTargetDistance < 6 )
		{
			gObjAttack(lpObj, lpTargetObj, 0, 0, 0, 0, 0,0,0);
		}
	}

	return FALSE;
}
Exemple #30
0
BOOL NpcSiegeMachine_Defense(LPOBJ lpNpc, LPOBJ lpObj)
{
	if ( (lpObj->m_IfState.use ) > 0 )
	{
		return TRUE;
	}

	PMSG_ANS_USE_WEAPON_INTERFACE pResult = {0};

	PHeadSubSetB((LPBYTE)&pResult, 0xB7, 0x00, sizeof(pResult));

	pResult.btResult = 0;
	pResult.btWeaponType = 2;
	pResult.btObjIndexH = SET_NUMBERH(lpNpc->m_Index);
	pResult.btObjIndexL = SET_NUMBERL(lpNpc->m_Index);

	if ( gObjIsConnectedGP(lpNpc->m_iWeaponUser) == FALSE )
	{
		lpNpc->m_iWeaponUser = 0;
		lpNpc->m_btWeaponState = 1;
	}

	lpNpc->m_btWeaponState = 1;


	if ( lpNpc->m_btWeaponState == 1 )
	{
		pResult.btResult = 1;
		lpNpc->m_btWeaponState = 2;
		lpNpc->m_iWeaponUser = lpObj->m_Index;

		DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);

		lpObj->m_IfState.use = 1;
		lpObj->m_IfState.type = 16;
	}
	else
	{
		DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
	}

	return TRUE;
}