コード例 #1
0
ファイル: LifeStone.cpp プロジェクト: Hagaib/p4f-free-emu
void CLifeStone::LifeStoneAct(int iIndex)
{
	if ( !gObjIsConnected(iIndex))
		return;

	LPOBJ lpObj = &gObj[iIndex];

	lpObj->m_iCreatedActivationTime++;
	BYTE btCreationState = lpObj->m_btCreationState;

	if ( lpObj->m_iCreatedActivationTime < 60 )
		lpObj->m_btCreationState = lpObj->m_iCreatedActivationTime / 12;
	else
		lpObj->m_btCreationState = 5;

	if ( btCreationState != lpObj->m_btCreationState )
		GCSendObjectCreationState(iIndex);

	if ( lpObj->m_btCreationState < 5 )
		return;

	if ( lpObj->VPCount < 1 ) 
		return;

	int tObjNum = -1;

	for (int i=0;i<MAX_VIEWPORT;i++)
	{
		tObjNum = lpObj->VpPlayer[i].number;

		if ( tObjNum >= 0 )
		{
			if ( gObj[tObjNum].Type == OBJ_USER && gObj[tObjNum].Live )
			{
				if ( gObj[tObjNum].m_btCsJoinSide == lpObj->m_btCsJoinSide )
				{
					if ( abs(lpObj->Y - gObj[tObjNum].Y) <= 3 &&
						 abs(lpObj->X - gObj[tObjNum].X) <= 3 )
					{
						BOOL bLifeChange = FALSE;
						BOOL bManaChange = FALSE;
						BOOL bBpChange = FALSE;

						/*gObj[tObjNum].Life += 100.0f;
						gObj[tObjNum].Mana += 100.0f;
						gObj[tObjNum].BP += 100;*/

						if ( gObj[tObjNum].Life < (gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife))
						{
							gObj[tObjNum].Life += ( gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife ) / 100.0f;

							if ( gObj[tObjNum].Life > (gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife))
								gObj[tObjNum].Life = gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife;

							bLifeChange = TRUE;
						}

						if ( gObj[tObjNum].Mana < (gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana))
						{
							gObj[tObjNum].Mana += ( gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana ) / 100.0f;

							if ( gObj[tObjNum].Mana > (gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana))
								gObj[tObjNum].Mana = gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana;

							bManaChange = TRUE;
						}

						if ( gObj[tObjNum].BP < (gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP))
						{
							gObj[tObjNum].BP += ( gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP ) / 100;

							if ( gObj[tObjNum].BP > (gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP))
								gObj[tObjNum].BP = gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP;

							bBpChange = TRUE;
						}

						if (bLifeChange )
							GCReFillSend(tObjNum, (WORD)gObj[tObjNum].Life, 0xFF, 1, gObj[tObjNum].iShield);

						if (bManaChange ||bBpChange ) 
							GCManaSend(tObjNum, (short)gObj[tObjNum].Mana, 0xFF, 0, gObj[tObjNum].BP);
					}
				}
			}
		}
	}
}
コード例 #2
0
void CLifeStone::LifeStoneAct(int iIndex)
{
	if(gObjIsConnected(iIndex) == FALSE)
		return;

	LPOBJ lpObj = &gObj[iIndex];
	lpObj->m_iCreatedActivationTime++;

	BYTE btCreationState = lpObj->m_btCreationState;

	if(lpObj->m_iCreatedActivationTime < 60)
	{
		lpObj->m_btCreationState = lpObj->m_iCreatedActivationTime / 12;
	}
	else
	{
		lpObj->m_btCreationState = 5;
	}

	if(btCreationState != lpObj->m_btCreationState)
	{
		GCSendObjectCreationState(iIndex);
	}

	if(lpObj->m_btCreationState < 5)
		return;

	if(lpObj->VPCount < 1)
		return;

	int tObjNum = -1;

	for(int i = 0; i < MAX_VIEWPORT; i++)
	{
		tObjNum = lpObj->VpPlayer[i].number;

		if(tObjNum >= 0 
			&& gObj[tObjNum].Type == OBJ_USER
			&& gObj[tObjNum].Live != FALSE 
			&& gObj[tObjNum].m_btCsJoinSide == lpObj->m_btCsJoinSide
			&& abs(lpObj->Y - gObj[tObjNum].Y) <= 3
			&& abs(lpObj->X - gObj[tObjNum].X) <= 3)
		{
			int bLifeChange = FALSE;
			int bManaChange = FALSE;
			int bBpChange = FALSE;

			if(gObj[tObjNum].Life < gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife)
			{
				gObj[tObjNum].Life += (gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife) / 100.0f;// + gObj[tObjNum].Life;

				if(gObj[tObjNum].Life > gObj[tObjNum].MaxLife + gObj[tObjNum].AddLife)
				{
					gObj[tObjNum].Life = gObj[tObjNum].MaxLife + + gObj[tObjNum].AddLife;
				}

				bLifeChange = TRUE;
			}

			if(gObj[tObjNum].Mana < gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana)
			{
				gObj[tObjNum].Mana += (gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana) / 100.0f;// + gObj[tObjNum].Mana;

				if(gObj[tObjNum].Mana > gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana)
				{
					gObj[tObjNum].Mana = gObj[tObjNum].MaxMana + gObj[tObjNum].AddMana;
				}

				bManaChange = TRUE;
			}

			if(gObj[tObjNum].BP < gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP)
			{
				gObj[tObjNum].BP += (gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP) / 100;// + gObj[tObjNum].BP;

				if(gObj[tObjNum].BP > gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP)
				{
					gObj[tObjNum].BP = gObj[tObjNum].MaxBP + gObj[tObjNum].AddBP;
				}

				bBpChange = TRUE;
			}

			if(bLifeChange != FALSE)
			{
				GCReFillSend(tObjNum,(WORD)gObj[tObjNum].Life,0xFF,1,gObj[tObjNum].iShield);
			}

			if(bManaChange != FALSE || bBpChange != FALSE)
			{
				GCManaSend(tObjNum,(WORD)gObj[tObjNum].Mana,0xFF,0,gObj[tObjNum].BP);
			}
		}
	}
}