⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recallmanager.cpp

📁 墨香最新私服
💻 CPP
字号:
// RecallManager.cpp: implementation of the CRecallManager class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "RecallManager.h"
#include "..\[CC]Header\GameResourceStruct.h"
#include "Monster.h"
#include "RegenManager.h"
#include "AISystem.h"
#include "RegenPrototype.h"
#include "CharMove.h"
#include "ChannelSystem.h"
#include "UserTable.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CRecallManager::CRecallManager()
{
}

CRecallManager::~CRecallManager()
{

}

//¹«Áö´À¸®°ÚÁö¸¸.. ÀÚÁÖ »ç¿ëµÇ´Â °ÍÀÌ ¾Æ´Ï¹Ç·Î..
void CRecallManager::DeleteEventRecallMonster()
{
	g_pUserTable->SetPositionUserHead();
	CObject* pObject;
	while( pObject = g_pUserTable->GetUserData() )
	{
		if( pObject->GetObjectKind() & eObjectKind_Monster )
		{
			if( pObject->GetObjectKind() == eObjectKind_Monster )
			{
				if( ((CMonster*)pObject)->GetMonsterGroupNum() == (WORD)EVENTRECALL_GROUP_ID )
				{
					g_pServerSystem->RemoveMonster( pObject->GetID() );
				}
			}
			else if( pObject->GetObjectKind() == eObjectKind_BossMonster )
			{
				if( ((CMonster*)pObject)->GetMonsterGroupNum() == (WORD)EVENTRECALL_GROUP_ID )
				{
					g_pServerSystem->RemoveBossMonster( pObject->GetID() );
				}
			}
		}
	}
}

//es
void CRecallManager::EventRecall(CObject * pRecaller, WORD MonsterKind, BYTE cbMonsterCount, BYTE cbChannel, VECTOR3* pPos, WORD wRadius, WORD DropItemID, DWORD dwDropRatio )
{
	// ºñ¾î ÀÖ´Â AddPrototype
	// ID»ý¼º
	DWORD dwID, dwSubID;
	DWORD dwChannelID;
	
	VECTOR3 vRecallPos;
	
	for( int i = 0 ; i < cbMonsterCount ; ++i )
	{
		if( cbChannel == 0 )
		{
			for( int j = 0 ; j < CHANNELSYSTEM->GetChannelCount() ; ++j )
			{
				dwChannelID = CHANNELSYSTEM->GetChannelID( j );
				if( dwChannelID )
				{
					
					dwID = g_pAISystem->GeneraterMonsterID();
					dwSubID = g_pAISystem->GeneraterMonsterID();
					
					if( wRadius != 0 )
					{
						vRecallPos.x = pPos->x + (rand()%(wRadius*2)) - wRadius;
						vRecallPos.z = pPos->z + (rand()%(wRadius*2)) - wRadius;
					}
					else
					{
						vRecallPos.x = pPos->x;
						vRecallPos.z = pPos->z;
					}
					
					if( vRecallPos.x < 0 )				vRecallPos.x = 0;
					else if( vRecallPos.x > 51199 )		vRecallPos.x = 51199;

					if( vRecallPos.z < 0 )				vRecallPos.z = 0;
					else if( vRecallPos.z > 51199 )		vRecallPos.z = 51199;
		
					
					
					if( MonsterKind < 1000 ) //º¸½º¸÷ÀÌ ¾Æ´Ï¸é
						REGENMGR->RegenObject( dwID, dwSubID, dwChannelID, eObjectKind_Monster, MonsterKind, &vRecallPos, EVENTRECALL_GROUP_ID, DropItemID, dwDropRatio, FALSE );
					else
						REGENMGR->RegenObject( dwID, dwSubID, dwChannelID, eObjectKind_BossMonster, MonsterKind, &vRecallPos, EVENTRECALL_GROUP_ID, DropItemID, dwDropRatio, FALSE );
				}
			}
		}
		else if( cbChannel > 0 )
		{
			dwChannelID = CHANNELSYSTEM->GetChannelID( cbChannel - 1 );
			
			if( dwChannelID )
			{
				
				dwID = g_pAISystem->GeneraterMonsterID();
				dwSubID = g_pAISystem->GeneraterMonsterID();
				
				if( wRadius != 0 )
				{
					vRecallPos.x = pPos->x + (rand()%(wRadius*2)) - wRadius;
					vRecallPos.z = pPos->z + (rand()%(wRadius*2)) - wRadius;
				}
				else
				{
					vRecallPos.x = pPos->x;
					vRecallPos.z = pPos->z;
				}
				
				if( vRecallPos.x < 0 )				vRecallPos.x = 0;
				else if( vRecallPos.x > 51199 )		vRecallPos.x = 51199;

				if( vRecallPos.z < 0 )				vRecallPos.z = 0;
				else if( vRecallPos.z > 51199 )		vRecallPos.z = 51199;
								
				if( MonsterKind < 1000 ) //º¸½º¸÷ÀÌ ¾Æ´Ï¸é
					REGENMGR->RegenObject( dwID, dwSubID, dwChannelID, eObjectKind_Monster, MonsterKind, &vRecallPos, EVENTRECALL_GROUP_ID, DropItemID, dwDropRatio, FALSE );
				else
					REGENMGR->RegenObject( dwID, dwSubID, dwChannelID, eObjectKind_BossMonster, MonsterKind, &vRecallPos, EVENTRECALL_GROUP_ID, DropItemID, dwDropRatio, FALSE );
			}
		}
	}
}

int CRecallManager::RecallRange(CObject * pRecaller, DWORD dwGridID, VECTOR3 * vPos, WORD wRecallMonsterKind, DWORD wRecallNum, DWORD dwRange, int GroupID,BOOL bRandomPos)
{
	VECTOR3 vRecallPos;

	float dx = 0, dz = 0;
	int ran = 0;

	int regencount = 0;

	for( WORD i = 0 ; i < wRecallNum ; ++i)
	{
		if(dwRange)
		{		
			ran = rand();
			dx = float(ran%dwRange) * (ran%2?1:-1);
			ran = rand();
			dz = float(ran%dwRange) * (ran%2?1:-1);
			vRecallPos.x = vPos->x + dx;
			vRecallPos.z = vPos->z + dz;
		}
		else
		{
			vRecallPos.x = vPos->x;
			vRecallPos.z = vPos->z;
		}

		DWORD dwID = g_pAISystem->GeneraterMonsterID();
		DWORD dwSubID = g_pAISystem->GeneraterMonsterID();

		CMonster* pMonster = REGENMGR->RegenObject(dwID, dwSubID, dwGridID, eObjectKind_Monster, 
						wRecallMonsterKind, &vRecallPos, RECALL_GROUP_ID,
						0,100,bRandomPos);
		if(pMonster)
		{
			++regencount;
			pMonster->SetSuryunGroup(GroupID);
		}
	}

	return regencount;
}

void CRecallManager::RecallObject(CMonster * pRecaller, RECALLINFO * pRecallInfo)
{
	//RECALLINFO * pRecallInfo = ((SMONSTER_LIST*)pRecaller->GetSMonsterList())->RecallInfoClass.GetRecallInfo(0);
	switch(pRecallInfo->RecallType)
	{
	case RECALL_GROUP:
		{
			REGENMGR->RegenGroup(pRecallInfo->RecallID, pRecaller->GetGridID());
		}
		break;
	case RECALL_RECALLERRANGE:
		{
			VECTOR3 vRecallPos;
			pRecaller->GetPosition(&vRecallPos);
			RecallRange(pRecaller, pRecaller->GetGridID(), &vRecallPos, pRecallInfo->RecallID, 
				pRecallInfo->RecallMonsterNum, pRecallInfo->RecallRange, 0 );
		}
		break;
	case RECALL_RECALLERPOSITION:
		{
			VECTOR3 vRecallPos;
			pRecaller->GetPosition(&vRecallPos);
			RecallRange(pRecaller, pRecaller->GetGridID(), &vRecallPos, pRecallInfo->RecallID, 1, 0, 0 );
		}
		break;
	case RECALL_TARGETRANGE:
		{
			VECTOR3 vRecallPos;
			if(!pRecaller->GetTObject()) return;
			pRecaller->GetTObject()->GetPosition(&vRecallPos);
			RecallRange(pRecaller, pRecaller->GetGridID(), &vRecallPos, pRecallInfo->RecallID, 
				pRecallInfo->RecallMonsterNum, pRecallInfo->RecallRange, 0 );
		}
		break;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -