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

📄 cgamedata.cpp

📁 一个个人开发的rpg游戏<亚特兰蒂斯传奇>的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	LOA_ASSERT(pdbData);
	if(!(*pdbData))
	{
		(*pdbData)=IDataBase<STGood>::ForeCreate();
	}
	char strID[4096];
	memset(strID,0,4096);
	::GetPrivateProfileString("ALLGOODSID","IDS","",strID,4096,szDataFile); //得到所有ID
	if(strcmp("",strID)==0)
	{
		m_pLog->WriteMessage("错误的物品数据文件!\n");
		return false;
	}
	char temp[128];
	int i=0;
	int j=0;
	int goodID;
	STGood *pGood;
	while(strID[i])
	{
		pGood=new STGood;
		memset(temp,0,128);
		j=0;
		while(strID[i]!=',' && strID[i]!='\0')								//得到string类型的一个ID
		{
			temp[j++]=strID[i];
			i++;
		}
		i++;																//跳过逗号
		sscanf(temp,"%d",&goodID);											//得到ID
		if(!LoadGoodsFromFile(szDataFile,goodID,pGood))
		{
			m_pLog->WriteMessage("Can't Get Data(%d) While Init Good DataBase!\n",goodID);
		}
		else
		{
			(*pdbData)->AddData(goodID,pGood);							//添加该物品
		}
	}
	return true;
}
////////////////////////////////////////////////////////////////////////////////////////////
//创建特效数据库
////////////////////////////////////////////////////////////////////////////////////////////
BOOL CGameData::CreateEffectDataBase(CGame*pGame,char*szDataFile,IDataBase<STEffect>**pdbEffect)
{
	LOA_ASSERT(pGame);
	LOA_ASSERT(szDataFile!=NULL);
	LOA_ASSERT(pdbEffect);

	if(!(*pdbEffect))
	{
		(*pdbEffect)=IDataBase<STEffect>::ForeCreate();
	}

	char strID[4096];
	memset(strID,0,4096);
	::GetPrivateProfileString("ALLEffectID","IDS","",strID,4096,szDataFile); //得到所有ID
	if(strcmp("",strID)==0)
	{
		m_pLog->WriteMessage("错误的特效数据文件!\n");
		return false;
	}
	char temp[128];
	int i=0;
	int j=0;
	int EffectID;
	STEffect *pEffect;
	while(strID[i])
	{
		pEffect=new STEffect;
		memset(temp,0,128);
		j=0;
		while(strID[i]!=',' && strID[i]!='\0')								//得到string类型的一个ID
		{
			temp[j++]=strID[i];
			i++;
		}
		i++;																//跳过逗号
		sscanf(temp,"%d",&EffectID);											//得到ID
		if(!LoadEffectFromFile(pGame,szDataFile,EffectID,pEffect))
		{
			m_pLog->WriteMessage("Can't Get Data(%d) While Init Effect DataBase!\n",EffectID);
		}
		else
		{
			(*pdbEffect)->AddData(EffectID,pEffect);							//添加该物品
		}
	}
	return true;
}
////////////////////////////////////////////////////////////////////////////////////////////
//读取角色数据
////////////////////////////////////////////////////////////////////////////////////////////
BOOL CGameData::LoadRoleFromIni(char*szFile,char*szName,CRole*pRole)
{
	LOA_ASSERT(pRole);
	LOA_ASSERT(szName);
	LOA_ASSERT(szFile);

	pRole->nID=::GetPrivateProfileInt(szName,"id",0,szFile);
	if(0==pRole->nID)
	{
		m_pLog->WriteMessage("Get Role<%s>'s ID From File<%s>...Failed!\n",szName,szFile);
		return false;
	}
	memset(pRole->szSegmentName,0,32);
	strncpy(pRole->szSegmentName,szName,32);

	pRole->nRolePicStyle=::GetPrivateProfileInt(szName,"PicStyle",0,szFile);
	if(pRole->nRolePicStyle==0)
	{
		for(int m=0;m<3;m++)
		{
			for(int n=0;n<4;n++)
			{
				::SetRect(&pRole->rect[n][m],m*32,n*48,m*32+32,n*48+48);
			}
		}
	}
	else
	{
		for(int n=0;n<3;n++)
		{
			for(int m=0;m<4;m++)
			{
				::SetRect(&pRole->rect[m][n],m*32,n*48,m*32+32,n*48+48);
			}
		}
	}

	pRole->bDead=false;
	pRole->Attack=::GetPrivateProfileInt(szName,"Attack",0,szFile);
	pRole->BasicAttack=::GetPrivateProfileInt(szName,"BasicAttack",0,szFile);
	pRole->BasicDefend=::GetPrivateProfileInt(szName,"BasicDefend",0,szFile);
	pRole->bShow=true;
	pRole->Defend=::GetPrivateProfileInt(szName,"Defend",0,szFile);
	pRole->DefendDefend=::GetPrivateProfileInt(szName,"DefendDefend",0,szFile);
	pRole->DefendExp=::GetPrivateProfileInt(szName,"DefendExp",0,szFile);
	pRole->DefendLevel=::GetPrivateProfileInt(szName,"DefendLevel",0,szFile);
	pRole->DefendMaxExp=::GetPrivateProfileInt(szName,"DefendMaxExp",0,szFile);
	pRole->dwFramsDelay=::GetPrivateProfileInt(szName,"FrameDelay",0,szFile);
	pRole->Exp=::GetPrivateProfileInt(szName,"Exp",0,szFile);
	pRole->Hp=::GetPrivateProfileInt(szName,"Hp",0,szFile);
	pRole->Kidney=::GetPrivateProfileInt(szName,"Kidney",LOA_KIDNEY_ATTACK,szFile);
	pRole->Level=::GetPrivateProfileInt(szName,"Level",0,szFile);;
	pRole->dwOldTime=0;
	pRole->MaxExp=::GetPrivateProfileInt(szName,"MaxExp",0,szFile);
	pRole->MaxHp=::GetPrivateProfileInt(szName,"MaxHp",0,szFile);
	pRole->MaxMp=::GetPrivateProfileInt(szName,"MaxMp",0,szFile);
	pRole->Money=::GetPrivateProfileInt(szName,"Money",0,szFile);
	pRole->Mp=::GetPrivateProfileInt(szName,"Mp",0,szFile);
	pRole->nCurrentStepFrames=0;
	pRole->nDirection=::GetPrivateProfileInt(szName,"Direction",0,szFile);
	pRole->nKinds=::GetPrivateProfileInt(szName,"Kinds",0,szFile);
	pRole->nMaxStepFrames=2;										//总共3帧,从0开始
	pRole->Smart=::GetPrivateProfileInt(szName,"Smart",0,szFile);
	pRole->Speed=::GetPrivateProfileInt(szName,"Speed",0,szFile);
	pRole->bStandNPC=::GetPrivateProfileInt(szName,"bStandNPC",false,szFile);
	pRole->dwOldPlanTime=0;
	pRole->dwFindRoadDelay=::GetPrivateProfileInt(szName,"FindRoadDelay",((rand()%8)+5)*1000,szFile);

	strcpy(pRole->szName,szName);

	pRole->WeaponAttack=::GetPrivateProfileInt(szName,"WeaponAttack",0,szFile);
	pRole->WeaponExp=::GetPrivateProfileInt(szName,"WeaponExp",0,szFile);
	pRole->WeaponLevel=::GetPrivateProfileInt(szName,"WeaponLevel",0,szFile);
	pRole->WeaponMaxExp=::GetPrivateProfileInt(szName,"WeaponMaxExp",0,szFile);
	pRole->x=::GetPrivateProfileInt(szName,"x",0,szFile);
	pRole->y=::GetPrivateProfileInt(szName,"y",0,szFile);
	pRole->x=pRole->x<<5;
	pRole->y=(pRole->y<<5);
	pRole->DeltaX=0;
	pRole->DeltaY=0;

	pRole->bMoving=false;
	pRole->bOffsiteOk=true;

	pRole->OldDestPosX=0xffffffff;
	pRole->OldDestPosY=0xffffffff;
	pRole->GoodsNum=0;
	for(int n=0;n<LOA_MAX_CARRY_GOODS;n++)
	{
		pRole->GoodsData[n]=0;
	}
	for(n=0;n<LOA_MAX_MAGIC;n++)
	{
		pRole->MagicData[n]=0;
	}
	char strID[1024];
	memset(strID,0,1024);
	memset(pRole->szNpcScriptFile,0,128);
	::GetPrivateProfileString(szName,"ScriptFile","script\\null.lsr",pRole->szNpcScriptFile,128,szFile);

	::GetPrivateProfileString(szName,"GoodsData","",strID,1024,szFile);

	char temp[128];
	int i=0;
	int j=0;
	int goodID;
	while(strID[i])
	{
		memset(temp,0,128);
		j=0;
		while(strID[i]!=',' && strID[i]!='\0')								//同上
		{
			temp[j++]=strID[i];
			i++;
		}
		i++;																//跳过逗号
		sscanf(temp,"%d",&goodID);											//得到ID
		pRole->AddGoods(goodID);
	}

	pRole->MagicNum=0;

	memset(strID,0,1024);
	::GetPrivateProfileString(szName,"MagicData","",strID,1024,szFile);
	i=0;
	j=0;
	int MagicID;
	while(strID[i])
	{
		memset(temp,0,128);
		j=0;
		while(strID[i]!=',' && strID[i]!='\0')
		{
			temp[j++]=strID[i];
			i++;
		}
		i++;																//跳过逗号
		sscanf(temp,"%d",&MagicID);											//得到ID
		pRole->AddMagic(MagicID);
	}
	return true;
}

⌨️ 快捷键说明

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