Esempio n. 1
0
void cLuckyPenny::Exchange(int aIndex,BYTE Count)
{
	if(OBJMAX_RANGE(aIndex) == 0)
	{
		return;
	}

	if(this->Enabled == TRUE)
	{
		if ( gObj[aIndex].m_IfState.type != 97 )
		{
			ANTI_HACK_LOG.Output("[ANTI-HACK][Coins][Exchange] User in map(%d) [%s][%s] State(u:%d,t:%d,s:%d)",
				gObj[aIndex].MapNumber, gObj[aIndex].AccountID, gObj[aIndex].Name,
				gObj[aIndex].m_IfState.use,gObj[aIndex].m_IfState.type,gObj[aIndex].m_IfState.state);
			return;
		}

		if(Count != 10 && Count != 20 && Count != 30)
			return;

		int pos = gObjCheckItemPosByDur(aIndex,ITEMGET(14,100),Count);

		if(pos >= 0)
		{
			if ( ReadConfig.MAIN_INVENTORY_RANGE(aIndex,pos,false) != FALSE )
			{
				if(this->GetReward(aIndex,Count) == true)
				{
					gObj[aIndex].pInventory[pos].m_Durability -= Count;
				
					if(gObj[aIndex].pInventory[pos].m_Durability <= 0)
					{
						gObjInventoryItemSet(aIndex, pos, -1);
						gObj[aIndex].pInventory[pos].Clear();
						GCInventoryItemDeleteSend(aIndex, pos, 1);
					}else
					{
						GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
					}

					LogAddTD("[LuckyPenny] [%s][%s][%d] LuckyPenny Item Buy Exchange Success",
						gObj[aIndex].AccountID, gObj[aIndex].Name,Count);
				}else
				{
					LogAddTD("[LuckyPenny] [%s][%s] LuckyPenny Item Buy Exchange Failed : No Room to Get Item",
						gObj[aIndex].AccountID, gObj[aIndex].Name);
					GCServerMsgStringSend("No Room in Inventory to Get Item!!",aIndex, 1);
				}
			}
		}else
		{
			char LackPacket[5] = {0xC1,0x05,0xBF,0x0C,0x00};
			DataSend(aIndex ,(UCHAR*)LackPacket, sizeof(LackPacket));
		}
	}
}
Esempio n. 2
0
void cLuckyPenny::RegisterSend(int aIndex)
{
	if(OBJMAX_RANGE(aIndex) == 0)
	{
		return;
	}

	if(this->Enabled == TRUE)
	{
		if ( gObj[aIndex].m_IfState.type != 97 )
		{
			ANTI_HACK_LOG.Output("[ANTI-HACK][Coins][Register] User in map(%d) [%s][%s] State(u:%d,t:%d,s:%d)",
				gObj[aIndex].MapNumber, gObj[aIndex].AccountID, gObj[aIndex].Name,
				gObj[aIndex].m_IfState.use,gObj[aIndex].m_IfState.type,gObj[aIndex].m_IfState.state);
			return;
		}

		int pos = gObjCheckItemPos(aIndex,ITEMGET(14,100));
		if(pos >= 0)
		{
			if ( ReadConfig.MAIN_INVENTORY_RANGE(aIndex,pos,false) != FALSE )
			{
				gObj[aIndex].pInventory[pos].m_Durability -= 1;
				gObj[aIndex].LuckyCoins++;
				
				PMSG_LUCKYCOINSCOUNT result;
				PHeadSubSetB((LPBYTE)&result, 0xBF, 0x0B, sizeof(result));
				result.Count = gObj[aIndex].LuckyCoins;
				DataSend(gObj[aIndex].m_Index,(BYTE*)&result,sizeof(result));
				
				if(gObj[aIndex].pInventory[pos].m_Durability <= 0)
				{
					gObjInventoryItemSet(aIndex, pos, -1);
					gObj[aIndex].pInventory[pos].Clear();
					GCInventoryItemDeleteSend(aIndex, pos, 1);
				}else
				{
					GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
				}
				
				char RegisterButton[4] = {0xC1,0x04,0xBF,0x0C};
				DataSend(aIndex ,(UCHAR*)RegisterButton, sizeof(RegisterButton));

				gObj[aIndex].AccountExtraInfoModified = 1;
			}
		}else
		{
			char LackPacket[5] = {0xC1,0x05,0xBF,0x0C,0x00};
			DataSend(aIndex ,(UCHAR*)LackPacket, sizeof(LackPacket));
		}
	}
}
BOOL TMonsterSkillElement::ApplyElementDurability(int iIndex, int iTargetIndex)
{
	LPOBJ lpObj = &gObj[iIndex];
	LPOBJ lpTargetObj = &gObj[iTargetIndex];

	if ( lpTargetObj->Type != OBJ_USER )
		return FALSE;

	int iEquipmentPos = rand()%6+2;	// Armors
	CItem * lpEquipment = &lpTargetObj->pInventory[iEquipmentPos];

	if ( lpEquipment == NULL || lpEquipment->IsItem() == FALSE )
		return FALSE;

	int iDurEquipment = (int)(lpEquipment->m_Durability);
	int iIncDecValue = 0;

	if ( this->m_iIncAndDecType != MSE_INCDEC_TYPE_NONE )
	{
		if ( this->m_iIncAndDecType < MSE_INCDEC_TYPE_CONSTANTINC )
		{
			iIncDecValue = iDurEquipment * this->m_iIncAndDecValue / 100;

			if ( this->m_iIncAndDecType == MSE_INCDEC_TYPE_PERCENTDEC )
				iIncDecValue = -iIncDecValue;
		}	

		if ( this->m_iIncAndDecType >= MSE_INCDEC_TYPE_CONSTANTINC )
		{
			iIncDecValue = this->m_iIncAndDecValue;

			if ( this->m_iIncAndDecType == MSE_INCDEC_TYPE_CONSTANTDEC )
				iIncDecValue = -iIncDecValue;
		}
	}

	iDurEquipment += iIncDecValue;

	if ( lpEquipment )
	{
		lpEquipment->m_Durability = (float)iDurEquipment;

		if ( lpEquipment->m_Durability < 0.0f )
			lpEquipment->m_Durability = 0;

		GCItemDurSend(lpTargetObj->m_Index, iEquipmentPos, (BYTE)lpEquipment->m_Durability, 0);
	}

	return FALSE;
}
Esempio n. 4
0
//0051d8a0	-> Checked
BOOL CObjBaseAttack::DecreaseArrow(LPOBJ lpObj)
{
	if (lpObj->Class == CLASS_ELF && lpObj->Type == OBJ_USER )
	{
		CItem * Right = &lpObj->pInventory[0];
		CItem * Left  = &lpObj->pInventory[1];

		if ( (Right->m_Type >= ITEMGET(4,8) && Right->m_Type <= ITEMGET(4,14)) ||
			  Right->m_Type == ITEMGET(4,16) || Right->m_Type == ITEMGET(4,18) ||
			  Right->m_Type == ITEMGET(4,19) )
		{
			if ( Left->m_Type == ITEMGET(4,7) )
			{
				if ( Left->m_Durability < 1.0f )
				{
					return FALSE;
				}

				Left->m_Durability -= 1.0f;
				GCItemDurSend(lpObj->m_Index, 1, Left->m_Durability, 0);

				if ( Left->m_Durability < 1.0f )
				{
					lpObj->pInventory[1].Clear();
					GCInventoryItemDeleteSend(lpObj->m_Index, 1, 0);
				}
			}
			else
			{
				return FALSE;
			}
		}
		else if ( (Left->m_Type >= ITEMGET(4,0) && Left->m_Type <= ITEMGET(4,6) ) ||
				   Left->m_Type == ITEMGET(4,17) ||
				   Left->m_Type == ITEMGET(4,20) ||
				   Left->m_Type == ITEMGET(4,21) ||
				   Left->m_Type == ITEMGET(4,22) ||
				   Left->m_Type == ITEMGET(4,23) ||
				   Left->m_Type == ITEMGET(4,24)) //season4.6 add-on
		{
			if ( Right->m_Type == ITEMGET(4,15) )
			{
				if ( Right->m_Durability < 1.0f )
				{
					return FALSE;
				}

				Right->m_Durability -= 1.0f;
				GCItemDurSend(lpObj->m_Index, 0, Right->m_Durability, 0);

				if ( Right->m_Durability < 1.0f )
				{
					lpObj->pInventory[0].Clear();
					GCInventoryItemDeleteSend(lpObj->m_Index, 0, 0);
				}
			}
			else
			{
				return FALSE;
			}
		}
	}

	return TRUE;
}
Esempio n. 5
0
int CIllusionTempleEvent::Enter(int aIndex,BYTE Temple,BYTE Pos)
{
	if( g_bIllusionTemple == FALSE )
	{
		return FALSE;
	}

	if( IT_TEMPLE_RANGE(Temple) == FALSE )
	{
		return FALSE;
	}

	LPOBJ lpObj = &gObj[aIndex];

	PMSG_ILLUSIONTEMPLE_ENTER_RESULT pMsg;

	PHeadSubSetB((LPBYTE)&pMsg,0xBF,0,sizeof( pMsg ));
	pMsg.result = 0;

	if( lpObj->Type != OBJ_USER || lpObj->Connected <= PLAYER_LOGGED )
	{
		return FALSE;
	}

	if ( lpObj->m_IfState.use != 0 && lpObj->m_IfState.type != 12 )
	{
		return FALSE;
	}

	if ( lpObj->m_bPShopOpen == TRUE )
	{
		CGPShopReqClose(lpObj->m_Index);
	}

	int bFail = FALSE;
	int iLevel;
	int iSerial;

#if (ENABLE_FIX_PARTYPK == 0)

	if ( lpObj->PartyNumber >= 0 )
	{
		if( gParty.GetPartyPkLevel(lpObj->PartyNumber) >= 5 )
		{
			bFail = TRUE;
		}
	}
	else if( lpObj->m_PK_Level >= 4 )
	{
		bFail = TRUE;
	}

	if( bFail == TRUE )
	{
		pMsg.result = 7;
		DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
		return FALSE;
	}

#endif

	if( IsTransformEquipment(aIndex) )
	{
		pMsg.result = 8;
		DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
		return FALSE;
	}

	if( m_TempleData[Temple].GetState() != IT_STATE_CLOSED ||
		m_TempleData[Temple].OpenState() == FALSE )
	{
		pMsg.result = 2;
		DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
		return FALSE;
	}

	if( gObj[aIndex].pInventory[Pos].IsItem() == TRUE )
	{
		if( gObj[aIndex].pInventory[Pos].m_Type == ITEMGET(13,51) )
		{
			iLevel = gObj[aIndex].pInventory[Pos].m_Level;
			iSerial = gObj[aIndex].pInventory[Pos].m_Number;

			if( IT_TEMPLE_RANGE(iLevel-1) == FALSE && gObj[aIndex].pInventory[Pos].m_Durability != 1.0f )
			{
				pMsg.result = 1;
				DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
				return FALSE;
			}
		}
		else if( gObj[aIndex].pInventory[Pos].m_Type == ITEMGET(13,61) )
		{
			iSerial = gObj[aIndex].pInventory[Pos].m_Number;
			iLevel = GetEnterLevel(aIndex);

			if( iLevel <= 0 )
			{
				pMsg.result = 1;
				DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
				return FALSE;
			}
		}
		else
		{
			pMsg.result = 1;
			DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
			return FALSE;
		}
	}
	else
	{
		pMsg.result = 1;
		DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
		return FALSE;
	}

	if( RankingCheck(aIndex,Temple,Pos,iLevel) != FALSE )
	{
		return TRUE;
	}

	if( CheckCanEnter(aIndex,iLevel) == FALSE )
	{
		pMsg.result = 3;
		DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
		return FALSE;
	}

	m_TempleData[iLevel-1].CheckUsers();

	int bResult = m_TempleData[iLevel-1].EnterUser(aIndex,Temple,Pos);

	if( bResult == TRUE )
	{
		if( lpObj->PartyNumber >= 0 )
		{
			PMSG_PARTYDELUSER pMsg;
			int PartyIndex;
			PartyIndex = gParty.GetIndex(lpObj->PartyNumber,lpObj->m_Index,lpObj->DBNumber);

			if( PartyIndex >= 0 )
			{
				
				pMsg.Number = PartyIndex;

				CGPartyDelUser(&pMsg,lpObj->m_Index);
			}
		}

		if( lpObj->pInventory[Pos].m_Type == ITEMGET(13,51) )
		{
			lpObj->pInventory[Pos].m_Durability = 0;
			GCItemDurSend(lpObj->m_Index,Pos,(BYTE)lpObj->pInventory[Pos].m_Durability,0);
		}
		else if( lpObj->pInventory[Pos].m_Type == ITEMGET(13,61) )
		{
			if( lpObj->pInventory[Pos].m_Durability > 0.0f )
			{
				lpObj->pInventory[Pos].m_Durability -= 1.0f;
				GCItemDurSend(lpObj->m_Index,Pos,(BYTE)lpObj->pInventory[Pos].m_Durability,0);
			}
		}

		LogAddTD("[Illusion Temple] (%d) EnterUser: (%s)(%s) class:%d (Serial:%u).",
			iLevel,lpObj->AccountID,lpObj->Name,lpObj->DbClass,lpObj->pInventory[Pos].m_Number);

		DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
		gObjMoveGate(lpObj->m_Index,141 + iLevel);
	}

	m_TempleData[Temple].SendState(0,lpObj->m_Index);
	SendInfo();
return TRUE;
}
BOOL CIllusionTempleEvent::EnterIllusionTemple(int aIndex, BYTE btTempleIndex, BYTE btItemPos)
{
	if( !g_bIllusionTempleEvent )	
	{
		return FALSE;
	}
	// ----
	if(!CHECK_LIMIT(btTempleIndex, MAX_ILLUSIONTEMPLE_TEMPLE_COUNT)) 
	{
		return FALSE;
	}
	LPOBJECTSTRUCT lpObj = (LPOBJECTSTRUCT)&gObj[aIndex];

	PMSG_RESULT_ENTER_ILLUSION_TEMPLE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0xBF, 0x00, sizeof(pResult));
	pResult.Result = 0;

	if( lpObj->Type != OBJ_USER || lpObj->Connected <= 2 )
	{
		return FALSE;
	}

	if( lpObj->m_IfState.use && lpObj->m_IfState.type != 12 )
	{
		return FALSE;
	}

	if( lpObj->m_bPShopOpen == true )
	{
		CGPShopReqClose(lpObj->m_Index);
	}

	BOOL PKFlag = FALSE;

	if(lpObj->PartyNumber >= 0)
	{
		if( (gParty.GetPKPartyPenalty(lpObj->PartyNumber)) >= 5)
		{
			PKFlag = TRUE;
		}
	}
	else if( lpObj->m_PK_Level >= 4 )
	{
		PKFlag = TRUE;
	}

	if( PKFlag == TRUE )
	{
		pResult.Result = 7;
		DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
		return FALSE;
	}

	if( CheckWearingMOPH(aIndex) )
	{
		pResult.Result = 8;
		DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
		return FALSE;
	}

	if( m_cIllusionTempleProc[btTempleIndex].GetIllusionTempleState() != 0 
		|| !m_cIllusionTempleProc[btTempleIndex].GetEntrance() )
	{
		pResult.Result = 2;
		DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
		return FALSE;
	}

	int iITEM_LEVEL;
	DWORD dwITEM_SERIAL;

	if(gObj[aIndex].pInventory[btItemPos].IsItem() == TRUE)
	{
		if(gObj[aIndex].pInventory[btItemPos].m_Type == (ITEM_HELPER+51))
		{
			iITEM_LEVEL = gObj[aIndex].pInventory[btItemPos].m_Level;
			dwITEM_SERIAL = gObj[aIndex].pInventory[btItemPos].m_Number;

			if( !CHECK_LIMIT( iITEM_LEVEL-1, MAX_ILLUSIONTEMPLE_TEMPLE_COUNT ) && gObj[aIndex].pInventory[btItemPos].m_Durability != 1.0f)
			{
				pResult.Result = 1;
				DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
				return FALSE;
			}
		}
		else if(gObj[aIndex].pInventory[btItemPos].m_Type == (ITEM_HELPER+61))
		{
			dwITEM_SERIAL = gObj[aIndex].pInventory[btItemPos].m_Number;
			iITEM_LEVEL = CheckCanEnterLevel(aIndex);
			
			if(iITEM_LEVEL <= 0)
			{
				pResult.Result = 1;
				DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
				return FALSE;
			}
		}
		else
		{
			pResult.Result = 1;
			DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
			return FALSE;
		}
	}
	else
	{
		pResult.Result = 1;
		DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
		return FALSE;
	}

#pragma message("#### Enable me after time ####")
	//if( GEReqIllusionTempleEnterCountCheck(aIndex, btTempleIndex, btItemPos, iITEM_LEVEL) )
	//{
	//	LogAddC(2, "[DEBUG] [IT] Enter R12");
	//	return TRUE;
	//}
	if( !CheckEnterLevel(aIndex, iITEM_LEVEL) )
	{
		pResult.Result = 3;
		DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);
		return FALSE;
	}

	m_cIllusionTempleProc[iITEM_LEVEL-1].CheckUsersOnConnect();

	BOOL bRet = m_cIllusionTempleProc[iITEM_LEVEL-1].EnterUserIllusionTemple(aIndex, btTempleIndex, btItemPos);

	if(bRet == TRUE)
	{
		if(lpObj->PartyNumber >= 0)
		{
			PMSG_PARTYDELUSER pMsg;

			int pindex = gParty.GetIndex(lpObj->PartyNumber, lpObj->m_Index, lpObj->DBNumber);
			if(pindex >= 0)
			{
				pMsg.Number = pindex;
				CGPartyDelUser(&pMsg, lpObj->m_Index);
			}
		}

		if( lpObj->pInventory[btItemPos].m_Type == (ITEM_HELPER+51) )
		{
			lpObj->pInventory[btItemPos].m_Durability = 0;
			GCItemDurSend(lpObj->m_Index, btItemPos, lpObj->pInventory[btItemPos].m_Durability, 0);
		}
		else if(lpObj->pInventory[btItemPos].m_Type == (ITEM_HELPER+61) && lpObj->pInventory[btItemPos].m_Durability > 0.0f)
		{
			lpObj->pInventory[btItemPos].m_Durability -= 1.0f;
			GCItemDurSend(lpObj->m_Index, btItemPos, lpObj->pInventory[btItemPos].m_Durability, 0);
		}

#ifdef OPT
		LogAddTD("[Illusion Temple] (%d) EnterUser: (%s)(%s) class:%d (Serial:%u). PCRoom:%d", iITEM_LEVEL, lpObj->AccountID, lpObj->Name, lpObj->DbClass, lpObj->pInventory[btItemPos].m_Number, lpObj->m_iPcBangRoom);
#else
		LogAddTD("[Illusion Temple] (%d) EnterUser: (%s)(%s) class:%d (Serial:%u)", iITEM_LEVEL, lpObj->AccountID, lpObj->Name, lpObj->DbClass, lpObj->pInventory[btItemPos].m_Number);
#endif
		DataSend(aIndex,(LPBYTE)&pResult,pResult.h.size);

		gObjMoveGate(lpObj->m_Index, iITEM_LEVEL+141);
	}

	m_cIllusionTempleProc[btTempleIndex].SendIllusionTempleState(0, lpObj->m_Index);
	SendIllusionTempleUserCount();

#if(TESTSERVER==1)
	GCServerMsgStringSend("CIllusionTempleEvent::EnterIllusionTemple", lpObj->m_Index, 0);
#endif
	return FALSE;
}