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

📄 resourcemanager.cpp

📁 墨香最新私服
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		return FALSE;
#else
	if(!file.Init("./Resource/AbilityBaseInfo.txt", "rt"))
		return FALSE;
#endif

	while(1)
	{
		if(file.IsEOF())
			break;

		CAbilityInfo* pInfo = new CAbilityInfo(&file);
		m_AbilityInfoList.Add(pInfo,pInfo->GetIdx());
	}

	file.Release();

	return TRUE;
}

BOOL CGameResourceManager::LoadNpcList()
{
	CMHFile file;
#ifdef _FILE_BIN_
	if( !file.Init("./Resource/StaticNpc.bin", "rb") )
		return FALSE;
#else
	if( !file.Init("./Resource/StaticNpc.txt", "rt") )
		return FALSE;
#endif

	while(1)
	{
		if(file.IsEOF())
			break;

		NPC_LIST* pInfo = new NPC_LIST;
		file.GetDword();
		pInfo->NpcKind = file.GetWord();
		file.GetString(pInfo->Name);
		pInfo->ModelNum = file.GetWord();
		pInfo->JobKind = file.GetWord();
		file.GetDword();
		file.GetDword();

		if( pInfo->ModelNum < 1000 )
			m_NpcList.Add(pInfo,pInfo->ModelNum);
		else
			delete pInfo;
	}

	file.Release();
	
	return TRUE;	
}

BOOL CGameResourceManager::LoadMonsterList()
{
	char filename[64];
	char value[64] = {0,};
	CMHFile file;

#ifdef _FILE_BIN_
	sprintf(filename,"./Resource/MonsterList.bin");	
	if(!file.Init(filename, "rb"))
		return FALSE;
#else
	sprintf(filename,"./Resource/MonsterList.txt");	
	if(!file.Init(filename, "rt"))
		return FALSE;
#endif

	int n =0;
	MONSTEREX_LIST * pList = NULL;
	while(1)
	{
		if(n == MAX_MONSTER_NUM)
			break;

		if(file.IsEOF())
			break;
		
		pList = new MONSTEREX_LIST;
		memset(pList, 0, sizeof(MONSTEREX_LIST));
		pList->MonsterKind				= file.GetWord();		// 锅龋
		file.GetString(pList->Name);						// 阁胶磐捞抚	
		file.GetString(pList->EngName);						// 康绢捞抚
		pList->Level					= file.GetLevel();		// 阁胶磐饭骇	
		file.GetString();	
		pList->MotionID					= file.GetDword();	
		file.GetString(pList->ChxName);
		pList->Scale					= file.GetFloat();// 阁胶磐 农扁	
		pList->Gravity					= file.GetDword();
		pList->Weight					= file.GetFloat();// 阁胶磐 公霸
		pList->MonsterRadius			= file.GetWord();// 阁胶磐 	
		pList->Life						= file.GetDword();
		pList->Shield					= file.GetDword();
		pList->ExpPoint					= file.GetExpPoint();// 版氰摹
		pList->Tall						= file.GetWord();

		pList->AttackPhysicalMin		= file.GetWord();// 傍拜 弥家拱府 傍拜仿	
		pList->AttackPhysicalMax		= file.GetWord();// 傍拜 弥措拱府 傍拜仿	
		pList->CriticalPercent			= file.GetWord();// 农府萍拿 欺季飘
		pList->PhysicalDefense			= file.GetWord();// 拱府 规绢仿	
		pList->AttribResist.SetElement_Val(ATTR_FIRE,file.GetFloat());// 加己历亲仿(拳)% 	
		pList->AttribResist.SetElement_Val(ATTR_WATER,file.GetFloat());// 加己历亲仿(荐)% 	
		pList->AttribResist.SetElement_Val(ATTR_TREE,file.GetFloat());// 加己历亲仿(格)% 	
		pList->AttribResist.SetElement_Val(ATTR_IRON,file.GetFloat());// 加己历亲仿(陛)% 	
		pList->AttribResist.SetElement_Val(ATTR_EARTH,file.GetFloat());// 加己历亲仿(配)% 

		pList->WalkMove					= file.GetWord();// 阁胶磐叭扁捞悼仿	
		pList->RunMove					= file.GetWord();// 阁胶磐顿扁捞悼仿	
		pList->RunawayMove				= file.GetWord();// 阁胶磐档噶捞悼仿
		
		file.GetString();// 嘎澜 1 楷免 锅龋	
		file.GetString();// 磷澜 1 楷免 锅龋	
		file.GetString();// 磷澜 2 楷免 锅龋	

		pList->StandTime				= file.GetDword();
		pList->StandRate				= file.GetByte();
		pList->WalkRate					= file.GetByte();
		pList->RunRate					= file.GetByte();
		pList->DomainRange				= file.GetDword();		// 康开 裹困 : 馆瘤抚
		pList->PursuitForgiveTime		= file.GetDword();
		pList->PursuitForgiveDistance	= file.GetDword();
		
		pList->bForeAttack				= file.GetBool();					// 急傍拜
		pList->SearchPeriodicTime		= file.GetDword();				// 沤祸 林扁
		pList->TargetSelect				= file.GetWord();					// 鸥百 急琶 : FIND_CLOSE, FIND_FIRST
		pList->SearchRange				= file.GetWord();
		pList->SearchAngle				= file.GetByte();
		pList->TargetChange				= file.GetWord();

		pList->AttackNum				= file.GetWord();
		pList->AttackIndex				= new DWORD[2];
		pList->AttackRate				= new DWORD[2];
		pList->SkillInfo				= new CSkillInfo*[2];
			
		pList->AttackIndex[0]			= file.GetWord();
		pList->AttackIndex[1]			= file.GetWord();
//		pList->SkillInfo[0]				= SKILLMGR->GetSkillInfo((WORD)pList->AttackIndex[0]);
//		pList->SkillInfo[1]				= SKILLMGR->GetSkillInfo((WORD)pList->AttackIndex[1]);
		pList->AttackRate[0]			= file.GetWord();
		pList->AttackRate[1]			= file.GetWord();

		pList->MinDropMoney				= file.GetDword();// 弥家捣 咀荐	
		pList->MaxDropMoney				= file.GetDword();// 弥措 捣 咀荐	
		ASSERT(pList->MaxDropMoney >= pList->MinDropMoney);
		pList->DropRate[eMONEY]			= file.GetWord();// 捣 犬伏(%)	
		pList->DropRate[eITEM1]			= file.GetWord();// 酒捞袍 犬伏(%)	
		pList->DropRate[eITEM2]			= file.GetWord();// 酒捞袍 犬伏(%)	
		pList->DropRate[eITEM3]			= file.GetWord();// 酒捞袍 犬伏(%)	
		pList->DropRate[eNOITEM]		= file.GetWord();// 畴袍 犬伏(%)	

		for(int n=0;n<eDROPITEMKIND_MAX;++n)
			pList->CurDropRate[n] = pList->DropRate[n];

		pList->ItemListNum1				= file.GetWord();// 秦寸酒捞袍府胶飘钎锅龋	
		pList->ItemListNum2				= file.GetWord();// 秦寸酒捞袍府胶飘钎锅龋	
		pList->ItemListNum3				= file.GetWord();// 秦寸酒捞袍府胶飘钎锅龋	

		pList->MaxDropItemNum			= file.GetByte();// 弥措酒捞袍 肮荐

		pList->fRunawayLifeRate			= file.GetFloat();
		pList->RunawayRate				= file.GetWord();
		pList->RunawayHelpRate			= file.GetWord();
		pList->RunawayDistance			= file.GetWord();	//????

		pList->Talk1					= file.GetWord();				// 措荤 1
		pList->Talk2					= file.GetWord();				
		pList->Talk3					= file.GetWord();

		pList->HelpRequestCondition		= file.GetWord();
		pList->HelpRequestDistance		= file.GetWord();
		pList->HelpRequestTargetNum		= file.GetWord();

		pList->RecallCondition			= file.GetWord();
		pList->RecallObjectID			= file.GetWord();
		pList->RecallObjectNum			= file.GetWord();

		pList->InitHelpType				= file.GetWord();
		pList->bHearing					= file.GetBool();
		pList->HearingDistance			= file.GetDword();

//		ASSERT(!m_SMonsterListTable.GetData(pList->MonsterKind));
		m_MonsterList.Add(pList, pList->MonsterKind);

		++n;
	}

	return TRUE;	
}

BOOL CGameResourceManager::IsDupItem( WORD wItemIdx )
{
	ITEM_INFO* pItemInfo = GetItemInfo(wItemIdx);

	switch(pItemInfo->ItemKind)
	{
	case eYOUNGYAK_ITEM:
	case eEXTRA_ITEM_JEWEL:
	case eEXTRA_ITEM_MATERIAL:
	case eEXTRA_ITEM_METAL:
	case eEXTRA_ITEM_BOOK:
	case eEXTRA_ITEM_HERB:
	case eEXTRA_ITEM_ETC:
		return TRUE;
	}
	return FALSE;
}

WORD CGameResourceManager::GetItemIdx_ByItemName(char* name)
{
	ITEM_INFO * pItemInfo = NULL;
	m_ItemInfoList.SetPositionHead();
	while(pItemInfo = m_ItemInfoList.GetData())
	{
		if( strcmp(pItemInfo->ItemName, name) == 0)
			return pItemInfo->ItemIdx;
	}

	return 0;
}


WORD CGameResourceManager::GetMugongIdx_ByMugongName(char* name)
{
	SKILLINFO* pSkillInfo = NULL;
	m_SkillInfoList.SetPositionHead();
	while(pSkillInfo = m_SkillInfoList.GetData())
	{
		if( strcmp(pSkillInfo->SkillName, name) == 0 )
			return pSkillInfo->SkillIdx;
	}

	return 0;
}

BOOL CGameResourceManager::IsOptionItem( WORD wItemIdx, WORD wDurability )
{
	if(wDurability != 0 && !IsDupItem(wItemIdx))
		return TRUE;
	return FALSE;
}

void CGameResourceManager::LoadQuestString()
{
	CMHFile file;
#ifdef _FILE_BIN_
	if( !file.Init( "./Resource/QuestString.bin", "rb") )
		return;
#else
	if( !file.Init( "./Resource/QuestString.bin", "rt") )
		return;
#endif

	char Token[256];
	DWORD Key=0;
	DWORD Key_1=0;
	DWORD Key_2=0;
	CQuestString* pQuestString = NULL;
	
	while( !file.IsEOF() )
	{
		file.GetString(Token);

		if(strcmp(Token,"$SUBQUESTSTR") == 0)	
		{
			Key_1 = file.GetDword();
			Key_2 = file.GetDword();
			COMBINEKEY(Key_1, Key_2, Key);
			pQuestString = ReadQuestString(&file);
			if(pQuestString)
			{
				m_QuestStringTable.Add(pQuestString, Key);
				pQuestString->SetIndex(Key_1, Key_2);				
			}
		}
	}
}

CQuestString* CGameResourceManager::ReadQuestString(CMHFile* pFile)
{
	CQuestString* pQStr = new CQuestString;

	char buf[1024];
	char Token[256];
	int	tline=0;
	int dline=0;

	while( !pFile->IsEOF() )
	{
		pFile->GetString(Token);

		if(Token[0] ==  '}')
			break;
		
		if(strcmp(Token,"#TITLE") == 0)
		{
			pFile->GetLine(buf, 1024);
			pQStr->AddLine(buf, tline, TRUE);
		}
		if(strcmp(Token,"#DESC") == 0)
		{
			while( !pFile->IsEOF() ) 
			{
				pFile->GetLine(buf, 1024);

				if( buf[1] == '{' )				continue;
				else if( buf[1] == '}' )		break;

				pQStr->AddLine(buf, dline);
				++dline;
			}
		}
	}

	return pQStr;
}

char* CGameResourceManager::GetQuestTitle( DWORD dwQuestIdx )
{
	DWORD Key = 0;
	COMBINEKEY(dwQuestIdx, 0, Key);
	CQuestString* pQuestString = m_QuestStringTable.GetData( Key );
	if( pQuestString )
	{
		QString* pStr = (QString*)(pQuestString->GetTitle()->GetHead());
		return pStr->Str;
	}
	return "";
}

char* CGameResourceManager::GetSubQuestTitle( DWORD dwQuestIdx, DWORD dwSubQuestIdx )
{
	DWORD Key = 0;
	COMBINEKEY(dwQuestIdx, dwSubQuestIdx, Key);
	CQuestString* pQuestString = m_QuestStringTable.GetData( Key );
	if( pQuestString )
	{
		QString* pStr = (QString*)(pQuestString->GetTitle()->GetHead());
		return pStr->Str;
	}
	return "";
}

BOOL CGameResourceManager::LoadMapNameList()
{
	CMHFile file;
//#ifdef _FILE_BIN_
//	if( !file.Init( "./Resource/MapName.bin", "rb") )
//		return FALSE;
//#else
	if( !file.Init( "./Resource/MapName.txt", "rt") )
		return FALSE;
//#endif

	DWORD dwMax = file.GetDword();

	DWORD dwMapNum = 0;
	for( DWORD i = 0; i < dwMax; ++i )
	{
		dwMapNum = file.GetInt();
		char* pMapName = new char[128];
		file.GetStringInQuotation( pMapName );

		m_MapNameTable.Add( pMapName, dwMapNum );		
	}

	file.Release();

	return TRUE;
}

char* CGameResourceManager::GetMapName( DWORD dwMapNum )
{
	char* pData = m_MapNameTable.GetData( dwMapNum );
	return pData;
}

DWORD CGameResourceManager::GetMapNum( char* sMapName )
{
	if( !sMapName )
		return 0;

	DWORD mapnum = 0;
	char* pName = NULL;
	m_MapNameTable.SetPositionHead();
	while( pName = m_MapNameTable.GetData() )
	{		
		++mapnum;
		if( strcmp( pName, sMapName ) == 0 )
			return mapnum;
	}

	return mapnum;
}

⌨️ 快捷键说明

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