void CDevilSquare::gDevilSquareMonsterRegen(LPOBJ lpObj)
{
    BYTE devilsquareindex = lpObj->m_bDevilSquareIndex;

    if ( devilsquareindex < 0 || devilsquareindex >= MAX_DEVILSQUARE_GROUND )
    {
        LogAddTD("[DevilSquare] Invalid DevilSquareIndex [%d]", devilsquareindex);
        return;
    }

    if ( lpObj->m_PosNum == -1 )
    {
        gObjDel(lpObj->m_Index);
        return;
    }

    WORD monstertype = this->m_DevilSquareGround[devilsquareindex].GetMonsterType(this->m_iPlaytime - this->m_iRemainTime );

    if ( monstertype == (BYTE)-1 )
    {
        LogAddTD("[DevilSquare] [%d] Invalid MonterType", monstertype);
        return;
    }

    for ( int n=0; n<MAX_MAGIC; n++)
    {
        lpObj->Magic[n].Clear();
    }

    gObjSetMonster(lpObj->m_Index, monstertype);
    lpObj->DieRegen = FALSE;
    gObjMonsterRegen(lpObj);
    CreateFrustrum(lpObj->X, lpObj->Y, lpObj->m_Index);
    lpObj->m_bDevilSquareIndex = devilsquareindex;
    lpObj->MaxRegenTime = 1000;

    LogAddTD("[DevilSquare] Monter Regen [%d][%d][%d,%d]",
             monstertype, devilsquareindex, lpObj->X, lpObj->Y);
}
BOOL TMonsterSkillElement::ApplyElementSummon(int iIndex, int iTargetIndex)
{
	LPOBJ lpObj = &gObj[iIndex];
	LPOBJ lpTargetObj = &gObj[iTargetIndex];

	if ( lpTargetObj->Connected < PLAYER_PLAYING ||
		 lpTargetObj->Type != OBJ_MONSTER )
		 return FALSE;

	lpTargetObj->Life = lpTargetObj->MaxLife + lpTargetObj->AddLife;
	lpTargetObj->Mana = lpTargetObj->MaxMana + lpTargetObj->AddMana;
	lpTargetObj->Live = TRUE;
	lpTargetObj->m_PoisonBeattackCount = 0;
	lpTargetObj->m_ColdBeattackCount = 0;
	lpTargetObj->m_ViewState = 0;
	lpTargetObj->Teleport = 0;

	memset(lpTargetObj->m_ViewSkillState,0,sizeof(lpTargetObj->m_ViewSkillState));

	for ( int i=0;i<MAX_SELF_DEFENSE;i++)
		lpTargetObj->SelfDefenseTime[i] = 0;

	gObjTimeCheckSelfDefense(lpTargetObj);
	gObjViewportListProtocolDestroy(lpTargetObj);
	gObjViewportClose(lpTargetObj);
	lpTargetObj->m_ActState.Attack = 0;
	lpTargetObj->m_ActState.EmotionCount = 0;
	lpTargetObj->m_ActState.Escape = 0;
	lpTargetObj->m_ActState.Move = 0;
	lpTargetObj->m_ActState.Rest = 0;
	lpTargetObj->m_ActState.Emotion = 0;
	lpTargetObj->TargetNumber = -1;
	lpTargetObj->NextActionTime = 5000;

	if ( this->m_iIncAndDecValue < 0 )
		this->m_iIncAndDecValue = 10;

	BYTE cX;
	BYTE cY;
	BOOL bGetPosition = FALSE;
	int iCount = 100;


	while ( iCount-- != 0 )
	{
		cX = ( rand() % (this->m_iIncAndDecValue+1) ) * (((rand()%2==0)?-1:1)) + lpObj->X;
		cY = ( rand() % (this->m_iIncAndDecValue+1) ) * (((rand()%2==0)?-1:1)) + lpObj->Y;

		BYTE btMapAttr = MapC[lpObj->MapNumber].GetAttr(cX, cY);

		if ( btMapAttr == 0 )
		{
			bGetPosition = TRUE;
			break;
		}
	}

	if ( bGetPosition == FALSE )
	{
		lpObj->Live = FALSE;
		lpObj->m_State = 4;
		lpObj->RegenTime = GetTickCount();
		lpObj->DieRegen = 1;

		return FALSE;
	}

	lpTargetObj->X = cX;
	lpTargetObj->Y = cY;
	lpTargetObj->MTX = lpTargetObj->X;
	lpTargetObj->MTY = lpTargetObj->Y;
	lpTargetObj->TX = lpTargetObj->X;
	lpTargetObj->TY = lpTargetObj->Y;
	lpTargetObj->StartX = (BYTE)lpTargetObj->X;
	lpTargetObj->StartY = (BYTE)lpTargetObj->Y;

	gObjMonsterHitDamageInit(lpTargetObj);
	CreateFrustrum(lpTargetObj->X, lpTargetObj->Y, lpTargetObj->m_Index);
	lpTargetObj->DieRegen = 0;
	lpTargetObj->m_State = 1;
	lpTargetObj->m_Agro.ResetAll();
	gObjViewportListCreate(lpTargetObj->m_Index);

	return FALSE;
}
Esempio n. 3
0
BOOL TMonsterSkillElement::ApplyElementSummon(int iIndex, int iTargetIndex)
{
	LPOBJ lpObj = &gObj[iIndex];
	LPOBJ lpTargetObj = &gObj[iTargetIndex];

	if( lpObj->Class == 459 &&
		lpObj->Connected == PLAYER_PLAYING &&
		lpObj->MapNumber == MAP_INDEX_RAKLIONBOSS &&
		iIndex == iTargetIndex)
	{
		LogAddTD("[TMonsterSkillElement][ApplyElementSummon] Selupan use summon.");
		return FALSE;
	}

	if ( lpTargetObj->Connected < PLAYER_PLAYING ||
		 lpTargetObj->Type != OBJ_MONSTER )
		 return FALSE;

	lpTargetObj->Life = lpTargetObj->MaxLife + lpTargetObj->AddLife;
	lpTargetObj->Mana = lpTargetObj->MaxMana + lpTargetObj->AddMana;
	lpTargetObj->Live = TRUE;

	gObjRemoveBuffEffect(lpTargetObj,BUFF_POISON);
	gObjRemoveBuffEffect(lpTargetObj,BUFF_ICE);
	gObjRemoveBuffEffect(lpTargetObj,BUFF_ICEARROW);

	lpTargetObj->m_ViewState = 0;
	lpTargetObj->Teleport = 0;

	gObjClearBuffEffect(lpTargetObj,CLEAR_TYPE_LOGOUT);

	for ( int i=0;i<MAX_SELF_DEFENSE;i++)
		lpTargetObj->SelfDefenseTime[i] = 0;

	gObjTimeCheckSelfDefense(lpTargetObj);
	gObjViewportListProtocolDestroy(lpTargetObj);
	gObjViewportClose(lpTargetObj);
	lpTargetObj->m_ActState.Attack = 0;
	lpTargetObj->m_ActState.EmotionCount = 0;
	lpTargetObj->m_ActState.Escape = 0;
	lpTargetObj->m_ActState.Move = 0;
	lpTargetObj->m_ActState.Rest = 0;
	lpTargetObj->m_ActState.Emotion = 0;
	lpTargetObj->TargetNumber = -1;
	lpTargetObj->NextActionTime = 5000;

	if ( this->m_iIncAndDecValue < 0 )
		this->m_iIncAndDecValue = 10;

	BYTE cX;
	BYTE cY;
	BOOL bGetPosition = FALSE;
	int iCount = 100;


	while ( iCount-- != 0 )
	{
		cX = ( rand() % (this->m_iIncAndDecValue+1) ) * (((rand()%2==0)?-1:1)) + lpObj->X;
		cY = ( rand() % (this->m_iIncAndDecValue+1) ) * (((rand()%2==0)?-1:1)) + lpObj->Y;

		BYTE btMapAttr = MapC[lpObj->MapNumber].GetAttr(cX, cY);

		if ( btMapAttr == 0 )
		{
			bGetPosition = TRUE;
			break;
		}
	}

	if ( bGetPosition == FALSE )
	{
		lpObj->Live = FALSE;
		lpObj->m_State = 4;
		lpObj->RegenTime = GetTickCount();
		lpObj->DieRegen = 1;

		return FALSE;
	}

	lpTargetObj->X = cX;
	lpTargetObj->Y = cY;
	lpTargetObj->MTX = lpTargetObj->X;
	lpTargetObj->MTY = lpTargetObj->Y;
	lpTargetObj->TX = lpTargetObj->X;
	lpTargetObj->TY = lpTargetObj->Y;
	lpTargetObj->StartX = lpTargetObj->X;
	lpTargetObj->StartY = lpTargetObj->Y;

	gObjMonsterHitDamageInit(lpTargetObj);
	CreateFrustrum(lpTargetObj->X, lpTargetObj->Y, lpTargetObj->m_Index);
	lpTargetObj->DieRegen = 0;
	lpTargetObj->m_State = 1;
	lpTargetObj->m_Agro.ResetAll();
	gObjViewportListCreate(lpTargetObj->m_Index);

	return FALSE;
}
Esempio n. 4
0
static void ARX_PORTALS_Frustrum_ComputeRoom(size_t roomIndex,
                                             const EERIE_FRUSTRUM & frustrum) {
	
	arx_assert(roomIndex < portals->rooms.size());
	
	if(RoomDraw[roomIndex].count == 0) {
		RoomDrawList.push_back(roomIndex);
	}
	
	RoomFrustrumAdd(roomIndex, frustrum);
	RoomDraw[roomIndex].count++;

	float fClippZFar = ACTIVECAM->cdepth * (fZFogEnd*1.1f);
	
	EERIE_ROOM_DATA & room = portals->rooms[roomIndex];
	
	// Now Checks For room Portals !!!
	for(long lll = 0; lll < room.nb_portals; lll++) {
		EERIE_PORTALS *po = &portals->portals[room.portals[lll]];
		
		if(po->useportal)
			continue;
		
		EERIEPOLY & epp = po->poly;
	
		//clipp NEAR & FAR
		unsigned char ucVisibilityNear=0;
		unsigned char ucVisibilityFar=0;

		for(size_t i=0; i<ARRAY_SIZE(epp.v); i++) {
			float fDist0 = efpPlaneNear.getDist(epp.v[i].p);

			if(fDist0 < 0.f)
				ucVisibilityNear++;
			if(fDist0 > fClippZFar)
				ucVisibilityFar++;
		}

		if((ucVisibilityFar & 4) || (ucVisibilityNear & 4)) {
			po->useportal=2;
			continue;
		}

		Vec3f pos = epp.center - ACTIVECAM->orgTrans.pos;
		float fRes = glm::dot(pos, epp.norm);

		EERIERTPPoly2(epp);

		if(!IsSphereInFrustrum(epp.center, frustrum, epp.v[0].rhw)) {
			continue;
		}

		bool Cull = !(fRes<0.f);
		
		EERIE_FRUSTRUM fd;
		CreateFrustrum(fd, ACTIVECAM->orgTrans.pos, epp, Cull);

		size_t roomToCompute = 0;
		bool computeRoom = false;

		if(po->room_1 == roomIndex && !Cull) {
			roomToCompute = po->room_2;
			computeRoom = true;
		}else if(po->room_2 == roomIndex && Cull) {
			roomToCompute = po->room_1;
			computeRoom = true;
		}

		if(computeRoom) {
			po->useportal=1;
			ARX_PORTALS_Frustrum_ComputeRoom(roomToCompute, fd);
		}
	}
}
Esempio n. 5
0
void TMonsterAI::MonsterMove(int iIndex)
{
	LPOBJ lpObj = &gObj[iIndex];

	if ( MONSTER_UTIL.CheckMovingCondition(lpObj) == FALSE )
	{
		lpObj->PathCur = 0;
		lpObj->PathCount = 0;
		lpObj->PathStartEnd = 0;
		memset(lpObj->PathX, 0, sizeof(lpObj->PathX));
		memset(lpObj->PathY, 0, sizeof(lpObj->PathY));
		memset(lpObj->PathDir, 0, sizeof(lpObj->PathY)); //check this out

		return ;
	}

	if ( lpObj->PathCount != 0 )
	{
		DWORD dwMoveTime = 0;
		DWORD dwDelayTime = 0;

		if ( lpObj->DelayLevel != 0 )
			dwDelayTime = 300;
		else
			dwDelayTime = 0;

		lpObj->m_MoveSpeed = 300;
		
		if ( (lpObj->PathDir[lpObj->PathCur] % 2 ) == 0 )
			dwMoveTime = (DWORD)((double)(lpObj->m_MoveSpeed + dwDelayTime) * 1.3);
		else
			dwMoveTime = lpObj->m_MoveSpeed + dwDelayTime;

		if ( (GetTickCount() - lpObj->PathTime) > dwMoveTime )
		{
			if ( lpObj->PathCur < 15 )
			{
				lpObj->X = lpObj->PathX[lpObj->PathCur];
				lpObj->Y = lpObj->PathY[lpObj->PathCur];
				lpObj->Dir = lpObj->PathDir[lpObj->PathCur];
				lpObj->PathTime = GetTickCount();
				lpObj->PathCur++;

				if ( lpObj->PathCur >= lpObj->PathCount )
				{
					lpObj->PathCur = 0;
					lpObj->PathCount = 0;
					lpObj->PathStartEnd = 0;
				}
			}

			CreateFrustrum(lpObj->X, lpObj->Y, iIndex);
		}

		return;

	}

	lpObj->PathCur = 0;
	lpObj->PathCount = 0;
	lpObj->PathStartEnd = 0;
	memset(lpObj->PathX, 0, sizeof(lpObj->PathX));
	memset(lpObj->PathY, 0, sizeof(lpObj->PathY));
	memset(lpObj->PathDir, 0, sizeof(lpObj->PathY)); //check this out
}
Esempio n. 6
0
BOOL MonsterHerd::MonsterRegenAction(LPOBJ lpObj)
{
	if ( lpObj == NULL )
	{
		return FALSE;
	}

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

	MonsterHerd * lpMH = (MonsterHerd *)lpObj->m_lpMonsterHerd;

	if ( lpMH == NULL )
	{
		return FALSE;
	}

	_MONSTER_HERD_DATA * lpMHD = lpMH->GetMonsterData(lpObj->m_Index);

	if ( lpMHD == NULL || lpMHD->m_bRegen == FALSE )
	{
		return FALSE;
	}

	lpObj->Life = lpObj->AddLife + lpObj->MaxLife;
	lpObj->Mana = lpObj->AddMana + lpObj->MaxMana;
	lpObj->Live = TRUE;
	lpObj->m_PoisonBeattackCount = 0;
	lpObj->m_ColdBeattackCount = 0;
	lpObj->m_ViewState = 0;
	lpObj->Teleport = 0;

	for ( int i=0;i<MAX_SELF_DEFENSE;i++)
	{
		lpObj->SelfDefenseTime[i] = 0;
	}

	gObjTimeCheckSelfDefense(lpObj);

	lpObj->m_ViewSkillState[eVS_POISON] = 0;
	lpObj->m_ViewSkillState[eVS_ICE] = 0;

	gObjClearViewport(lpObj);
	gObjViewportListProtocolDestroy(lpObj);
	gObjViewportClose(lpObj);

	lpObj->m_ActState.Attack = 0;
	lpObj->m_ActState.EmotionCount = 0;
	lpObj->m_ActState.Escape = 0;
	lpObj->m_ActState.Move = 0;
	lpObj->m_ActState.Rest = 0;
	lpObj->m_ActState.Emotion = 0;
	lpObj->TargetNumber = -1;
	lpObj->NextActionTime = 5000;

	BYTE cX;
	BYTE cY;
	int iCount = 100;
	BOOL bGetPosition = FALSE;

	while ( iCount-- != 0 )
	{
		if ( lpMH->GetRandomLocation(cX, cY) != FALSE )
		{
			bGetPosition = TRUE;
			break;
		}
	}

	if ( bGetPosition == FALSE )
	{
		lpObj->Live = FALSE;
		lpObj->m_State = 4;
		lpObj->RegenTime = GetTickCount();
		lpObj->DieRegen = TRUE;

		return FALSE;
	}

	lpObj->X = cX;
	lpObj->Y = cY;
	lpObj->MTX = lpObj->X;
	lpObj->MTY = lpObj->Y;
	lpObj->TX = lpObj->X;
	lpObj->TY = lpObj->Y;
	lpObj->StartX = lpObj->X;
	lpObj->StartY = lpObj->Y;

	gObjMonsterHitDamageInit(lpObj);
	CreateFrustrum(lpObj->X, lpObj->Y, lpObj->m_Index);

	lpObj->DieRegen = FALSE;
	lpObj->m_State = 1;

	return TRUE;
}