Пример #1
0
void Exec_MSG_ReqTradeList(int conn, char *pMsg)
{
	MSG_STANDARDPARM *m = (MSG_STANDARDPARM*)pMsg;

	int autoID = m->Parm;

	if (pMob[conn].MOB.CurrentScore.Hp == 0 || pUser[conn].Mode != USER_PLAY)
	{
		SendHpMode(conn);
		AddCrackError(conn, 10, 87);
		return;
	}

	if (autoID <= 0 || autoID >= MAX_USER)
		return;

	if (pUser[autoID].TradeMode == 0)
		return;

	if (pMob[conn].TargetX >= pMob[autoID].TargetX - VIEWGRIDX && pMob[conn].TargetX <= pMob[autoID].TargetX + VIEWGRIDX
		&& pMob[conn].TargetY >= pMob[autoID].TargetY - VIEWGRIDY && pMob[conn].TargetY <= pMob[autoID].TargetY + VIEWGRIDY)
		SendAutoTrade(conn, autoID);

	else
		Log("err,too far from autotrade - _MSG_ReqTradeList", pUser[conn].AccountName, pUser[conn].IP);
}
Пример #2
0
void Exec_MSG_Restart(int conn, char *pMsg)
{
	MSG_STANDARD *m = (MSG_STANDARD*)pMsg;

	if (pUser[conn].Mode == USER_PLAY)
	{
		pMob[conn].MOB.CurrentScore.Hp = 2;

		pUser[conn].NumError = 0;

		SendScore(conn);
		SendSetHpMp(conn);

		if(pMob[conn].TargetX >= 1017 && pMob[conn].TargetX <= 1290 && pMob[conn].TargetY >= 1911 && pMob[conn].TargetY <= 2183 && pMob[conn].MOB.Clan == 7)
			DoTeleport(conn, 1061+ rand()%3, 2129+rand()%3);
			
		else if(pMob[conn].TargetX >= 1017 && pMob[conn].TargetX <= 1290 && pMob[conn].TargetY >= 1911 && pMob[conn].TargetY <= 2183 && pMob[conn].MOB.Clan == 8)
			DoTeleport(conn, 1237+ rand()%3, 1966+rand()%3);
			
		else
			DoRecall(conn);

		sprintf(temp, "etc,restart char:%s hp:%d", pMob[conn].MOB.MobName, pMob[conn].MOB.CurrentScore.Hp);
		Log(temp, pUser[conn].AccountName, pUser[conn].IP);

		SendEtc(conn);
	}
	else
		SendHpMode(conn);
}
Пример #3
0
void Exec_MSG_QuitTrade(int conn, char *pMsg)
{
	if(pMob[conn].MOB.CurrentScore.Hp <= 0 || pUser[conn].Mode != USER_PLAY)
	{
		SendHpMode(conn);
		AddCrackError(conn, 10, 17);
		return; 
	}
						   
	RemoveTrade(pUser[conn].Trade.OpponentID);
	RemoveTrade(conn);

	MSG_STANDARDPARM sm;
	memset(&sm, 0, sizeof(MSG_STANDARDPARM));

	sm.Size = sizeof(MSG_STANDARDPARM);
	sm.Type = _MSG_PKInfo;
	sm.ID = conn;

	if (NewbieEventServer == 0)
	{
		int guilty = GetGuilty(conn);

		int state = 0;

		if (guilty || pUser[conn].PKMode || RvRState && pMob[conn].TargetX >= 1023 && pMob[conn].TargetY >= 1919 && pMob[conn].TargetX <= 1280 && pMob[conn].TargetY <= 2179 || CastleState && pMob[conn].TargetX >= 1024 && pMob[conn].TargetY >= 1664 && pMob[conn].TargetX <= 1153 && pMob[conn].TargetY <= 1793 || GTorreState && pMob[conn].TargetX >= 2430 && pMob[conn].TargetY >= 1825 && pMob[conn].TargetX <= 2560 && pMob[conn].TargetY <= 1925)
			state = 1;

		sm.Parm = state;
	}
	else
		sm.Parm = 1;

	GridMulticast(pMob[conn].TargetX, pMob[conn].TargetY, (MSG_STANDARD*)&sm, 0);
}
Пример #4
0
void Exec_MSG_Withdraw(int conn, char *pMsg)
{
	MSG_STANDARDPARM *m = (MSG_STANDARDPARM*)pMsg;

	if (pMob[conn].MOB.CurrentScore.Hp == 0 || pUser[conn].Mode != USER_PLAY)
	{
		SendHpMode(conn);
		AddCrackError(conn, 10, 2);
		return;
	}

	int coin = m->Parm;

	if (pUser[conn].Coin >= coin && coin >= 0 && coin <= 2000000000)
	{
		int tcoin = coin + pMob[conn].MOB.Coin;

		if (tcoin >= 0 && tcoin <= 2000000000)
		{
			pMob[conn].MOB.Coin = tcoin;
			pUser[conn].Coin -= coin;

			m->ID = 30000;

			pUser[conn].cSock.AddMessage((char*)m, sizeof(MSG_STANDARDPARM));
			SendCargoCoin(conn);

			sprintf(temp, "etc,retirada do bau V:%d R:%d", coin, pUser[conn].Coin);
			Log(temp, pUser[conn].AccountName, pUser[conn].IP);
		}
		else
			SendClientMessage(conn, g_pMessageStringTable[_NN_Cant_get_more_than_2G]);
	}
	else
		SendClientMessage(conn, g_pMessageStringTable[_NN_Cant_Withdraw_That_Much]);
}
Пример #5
0
void Exec_MSG_SendAutoTrade(int conn, char *pMsg)
{
	MSG_SendAutoTrade *m = (MSG_SendAutoTrade*)pMsg;

	if (pMob[conn].MOB.CurrentScore.Hp <= 0 || pUser[conn].Mode != USER_PLAY)
	{
		SendHpMode(conn);
		AddCrackError(conn, 10, 88);
		RemoveTrade(conn);
		return;
	}

	if (pUser[conn].Trade.OpponentID)
	{
		RemoveTrade(pUser[conn].Trade.OpponentID);
		RemoveTrade(conn);
		return;
	}

	if (pUser[conn].TradeMode)
	{
		SendClientMessage(conn, g_pMessageStringTable[_NN_CantWhenAutoTrade]);
		return;
	}

	if (NewbieEventServer == 0)
	{
		SendClientMessage(conn, g_pMessageStringTable[_NN_NEWBIEEVENTSERVER]);
		return;
	}

	int targetx = pMob[conn].TargetX;
	int targety = pMob[conn].TargetY;

	int Village = BASE_GetVillage(targetx, targety);

	if (targetx >= 2123 && targetx <= 2148 && targety >= 2139 && targety <= 2157)
	{
		RemoveTrade(conn);
		SendClientMessage(conn, g_pMessageStringTable[_NN_OnlyVillage]);
		return;
	}

	if (Village < 0 || Village >= 5)
	{
		RemoveTrade(conn);
		SendClientMessage(conn, g_pMessageStringTable[_NN_OnlyVillage]);
		return;
	}

	if (conn <= 0 || conn >= MAX_USER)
		return;

	for (int i = 0; i < MAX_AUTOTRADE; i++)
	{
		if (m->Coin[i] < 0 || (m->Coin[i] > 1999999999) || !m->Item[i].sIndex && m->Coin[i])
			return;

		if (m->Item[i].sIndex)
		{
			if (!m->Coin[i] || m->Item[i].sIndex == 508 || m->Item[i].sIndex == 3993 || m->Item[i].sIndex == 747 || m->Item[i].sIndex == 509 || m->Item[i].sIndex == 522
				|| m->Item[i].sIndex >= 526 && m->Item[i].sIndex <= 531 || m->Item[i].sIndex == 446 || m->CarryPos[i] < 0 || m->CarryPos[i] >= MAX_CARGO)
				return;

			if (BASE_GetItemAbility(&m->Item[i], EF_NOTRADE) != 0)
			{
				SendClientMessage(conn, g_pMessageStringTable[_NN_Cant_MoveItem]);									   
				return;
			}

			if (memcmp(&pUser[conn].Cargo[m->CarryPos[i]], &m->Item[i], sizeof(STRUCT_ITEM)))
			{
				RemoveTrade(conn);
				return;
			}
		}
	}

	m->Tax = g_pGuildZone[Village].CityTax;

	m->Title[MAX_AUTOTRADETITLE-1] = 0;
	m->Title[MAX_AUTOTRADETITLE-2] = 0;

	strncpy(pUser[conn].AutoTrade.Title, m->Title, MAX_AUTOTRADETITLE);
							   
	pUser[conn].TradeMode = 1;
							   
	memcpy(&pUser[conn].AutoTrade, m, sizeof(MSG_SendAutoTrade));
							   
	m->Size = sizeof(MSG_SendAutoTrade);

	MSG_CreateMobTrade sm_cmt;
	memset(&sm_cmt, 0, sizeof(MSG_CreateMobTrade));

	SendAutoTrade(conn, conn);
	GetCreateMobTrade(conn, &sm_cmt);

	sm_cmt.Score.Con = 0;

	GridMulticast(targetx, targety, (MSG_STANDARD*)&sm_cmt, 0);
}
Пример #6
0
void Exec_MSG_UpdateItem(int conn, char *pMsg)
{
	MSG_UpdateItem *m = (MSG_UpdateItem*)pMsg;

	if (pMob[conn].MOB.CurrentScore.Hp == 0 || pUser[conn].Mode != USER_PLAY)
	{
		SendHpMode(conn);
		AddCrackError(conn, 1, 16);
		return;
	}
	if(m->State < 0 || m->State > 5)
	{
		AddCrackError(conn, 50, 50);
		return;
	}

	if(m->ItemID < 10000 || m->ItemID >= 10000 + MAX_ITEM)
	{
		AddCrackError(conn, 50, 50);
		return;
	}

	int gateid = m->ItemID - 10000;
	int gatestate = m->State;

	if(gateid < 0 || gateid >= MAX_ITEM)
	{
		AddCrackError(conn, 50, 50);
		return;
	}

	if (CCastleZakum::OpenCastleGate(conn, gateid, m) == TRUE)
		return;
		
	int state = pItem[gateid].State;
	int gatestate2 = m->State;

	int gatekey = BASE_GetItemAbility(&pItem[gateid].ITEM, EF_KEYID);

	if (state != 3 && gatestate2 != 3)
		goto NoNeedKey;

	if (gatekey == 0)
		goto NoNeedKey;

	int key = 0;
	int Quest = -1;
	
	int i = 0;
	for (i = 0; i < MAX_CARRY; i++)
	{
		key = BASE_GetItemAbility(&pMob[conn].MOB.Carry[i], EF_KEYID);

		if (key != gatekey)
			continue;

		Quest = BASE_GetItemAbility(&pMob[conn].MOB.Carry[i], EF_QUEST);

		break;
	}

	if (gatekey != key)
	{
		if (pItem[gateid].ITEM.sIndex != 773)
			SendClientMessage(conn, g_pMessageStringTable[_NN_No_Key]);

		return;
	}
	
	memset(&pMob[conn].MOB.Carry[i], 0, sizeof(STRUCT_ITEM));
	SendItem(conn, ITEM_PLACE_CARRY, i, &pMob[conn].MOB.Carry[i]);
NoNeedKey:

	if (CEncampment::OpenTreasureBox(conn, gateid) == TRUE)
		return;

	int heigth = 0;

	int isUpdate = UpdateItem(gateid, STATE_OPEN, &heigth);

	if (isUpdate)
		GridMulticast(pItem[gateid].PosX, pItem[gateid].PosY, (MSG_STANDARD*)m, 0);

	sprintf(temp, "etc,opengate gateid:%d X:%d Y:%d", gateid, pItem[gateid].PosX, pItem[gateid].PosY);
	Log(temp, pUser[conn].AccountName, pUser[conn].IP);
	return;
}
Пример #7
0
void Exec_MSG_DropItem(int conn, char *pMsg)
{
	MSG_DropItem *m = (MSG_DropItem*)pMsg;

	if (pMob[conn].MOB.CurrentScore.Hp <= 0 || pUser[conn].Mode != USER_PLAY)
	{
		AddCrackError(conn, 1, 14);
		SendHpMode(conn);
		return;
	}

	if (pUser[conn].Trade.OpponentID)
	{
		RemoveTrade(pUser[conn].Trade.OpponentID);
		RemoveTrade(conn);
		return;
	}
 
	if (pUser[conn].TradeMode)
	{
		SendClientMessage(conn, g_pMessageStringTable[_NN_CantWhenAutoTrade]);
		return;
	}

	if (m->GridX >= MAX_GRIDX || m->GridY >= MAX_GRIDY)
	{
		sprintf(temp, "err,wrong drop pos %d %d", m->GridX, m->GridY);
		Log(temp, pUser[conn].AccountName, pUser[conn].IP);
		return;
	}

	if (isDropItem == 0)
		return;

	int gridx = m->GridX;
	int gridy = m->GridY;

	int titem = GetEmptyItemGrid(&gridx, &gridy);

	m->GridX = gridx;
	m->GridY = gridy;

	if (titem == 0)
	{
		SendClientMessage(conn, g_pMessageStringTable[_NN_Cant_Drop_Here]);
		return;
	}

	if (m->SourType == ITEM_PLACE_EQUIP)
	{
		Log("err,dropitem - sourtype", pUser[conn].AccountName, pUser[conn].IP);
		return;
	}

	if (m->SourType)
	{
		if (m->SourType == ITEM_PLACE_CARRY)
		{
			if (m->SourPos < 0 || m->SourPos >= pMob[conn].MaxCarry)
			{
				Log("err,dropitem - carry equip", pUser[conn].AccountName, pUser[conn].IP);
				return;
			}
		}
		else
		{
			if (m->SourType != ITEM_PLACE_CARGO)
			{
				Log("err,dropitem - sourtype", pUser[conn].AccountName, pUser[conn].IP);
				return;
			}
			if (m->SourPos < 0 || m->SourPos >= MAX_CARGO)
			{
				Log("err,dropitem - sourpos cargo", pUser[conn].AccountName, pUser[conn].IP);
				return;
			}
		}
	}

	STRUCT_ITEM *SrcItem = GetItemPointer(&pMob[conn].MOB, pUser[conn].Cargo, m->SourType, m->SourPos);
	STRUCT_ITEM *BackupItem = GetItemPointer(&pMob[conn].MOB, pUser[conn].Cargo, m->SourType, m->SourPos);


	if (SrcItem == NULL || BackupItem == NULL)
		return;

	if (SrcItem->sIndex <= 0 || SrcItem->sIndex >= MAX_ITEMLIST)
		return;

	if (SrcItem->sIndex != 508 && SrcItem->sIndex != 509 && SrcItem->sIndex != 522
		&& (SrcItem->sIndex < 526 || SrcItem->sIndex > 537) && SrcItem->sIndex != 446 && SrcItem->sIndex != 747 && SrcItem->sIndex != 3993 && SrcItem->sIndex != 3994)
	{
		int drop = CreateItem(m->GridX, m->GridY, SrcItem, m->Rotate, 1);

		if (drop <= 0 || drop >= MAX_ITEM)
		{
			SendClientMessage(conn, "Can't create object(item)");
			return;
		}

		char tmplog[2048];
		BASE_GetItemCode(SrcItem, tmplog);
		sprintf(temp, "dropitem, %s", tmplog);
		ItemLog(temp, pUser[conn].AccountName, pUser[conn].IP);	

		memset(SrcItem, 0, sizeof(STRUCT_ITEM));
							 
		MSG_CNFDropItem sm_ditem;
		memset(&sm_ditem, 0, sizeof(MSG_CNFDropItem));

		sm_ditem.Type = _MSG_CNFDropItem;
		sm_ditem.Size = sizeof(MSG_CNFDropItem);

		sm_ditem.SourType = m->SourType;
		sm_ditem.SourPos = m->SourPos;
		sm_ditem.Rotate = m->Rotate;
		sm_ditem.GridX = m->GridX;
		sm_ditem.GridY = m->GridY;

		pUser[conn].cSock.SendOneMessage((char*)&sm_ditem, sizeof(MSG_CNFDropItem));
	}
	else
	{
		SendClientMessage(conn, g_pMessageStringTable[_NN_Guild_Medal_Cant_Be_Droped]);
		return;
	}
}
Пример #8
0
void Exec_MSG_PutoutSeal(int conn, char *pMsg)
{
	MSG_PutoutSeal *m = (MSG_PutoutSeal*)pMsg;

	if (pUser[conn].Mode != USER_PLAY)
	{
		SendHpMode(conn);
		return;
	}

	if (pUser[conn].Trade.OpponentID)
	{
		RemoveTrade(conn);
		return;
	}

	if (pMob[conn].MOB.CurrentScore.Hp == 0)
	{
		SendHpMode(conn);
		AddCrackError(conn, 1, 15);

		if (m->SourType == ITEM_PLACE_CARRY)
			SendItem(conn, m->SourType, m->SourPos, &pMob[conn].MOB.Carry[m->SourPos]);

		else if (m->SourType == ITEM_PLACE_CARGO)
			SendItem(conn, m->SourType, m->SourPos, &pUser[conn].Cargo[m->SourPos]);

		else
			SendItem(conn, m->SourType, m->SourPos, &pMob[conn].MOB.Equip[m->SourPos]);

		return;
	}

	if (m->GridX >= MAX_GRIDX || m->GridY >= MAX_GRIDY)
	{
		CrackLog(conn, " Drop grid, out of range");
		return;
	}

	STRUCT_ITEM *item = GetItemPointer(&pMob[conn].MOB, pUser[conn].Cargo, m->SourType, m->SourPos);

	if (item == NULL)
	{
		sprintf(temp, "err,use item fail source %d %d", m->SourType, m->SourPos);
		Log(temp, "-system", 0);
		return;
	}

	if(item->sIndex != 3443)
	{
		CrackLog(conn, "outseal no 3443");
		return;
	}

	if(item->stEffect[0].cEffect == 0)
	{
		CrackLog(conn, "outseal no effect");
		return;
	}

	m->MobName[NAME_LENGTH - 1] = 0;
	m->MobName[NAME_LENGTH - 2] = 0;

	if (BASE_CheckValidString(m->MobName) == 0)
	{
		SendItem(conn, m->SourType, m->SourPos, item);
		return;
	}
	CharLogOut(conn);

	MSG_DBOutCapsule sm_outc;
	memset(&sm_outc, 0, sizeof(MSG_DBOutCapsule));

	sm_outc.Size = sizeof(MSG_DBOutCapsule);
	sm_outc.Type = _MSG_DBOutCapsule;
	sm_outc.ID = conn;

	sm_outc.Slot = pUser[conn].Slot;
	sm_outc.SourType = m->SourType;
	sm_outc.SourPos = m->SourPos;
	sm_outc.DestType = m->DestType;
	sm_outc.DestPos = m->DestPos;
	sm_outc.GridX = m->GridX;
	sm_outc.GridY = m->GridY;
	sm_outc.WarpID = m->WarpID;

	strncpy(sm_outc.MobName, m->MobName, 12);

	sprintf(temp, "etc,outcapsule srctype:%d srcslot:%d name:%s", m->SourType, m->SourPos, m->MobName);
	Log(temp, pMob[conn].MOB.MobName, pUser[conn].IP);

	DBServerSocket.SendOneMessage((char*)&sm_outc, sizeof(MSG_DBOutCapsule));
}