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

📄 cscript.cpp

📁 一个个人开发的rpg游戏<亚特兰蒂斯传奇>的源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		talk.AddTalk(str);
		if(iv1==1)
			talk.ShowTalk(m_pGame->GetPlayer() ,m_pGame,false);
		else 
			talk.ShowTalk(m_pGame->GetPlayer(),m_pGame,true);
/*		
		if(iv1==1)
			msg.ID=LOA_MSG_SHOW_TALK_UP;
		else 
			msg.ID=LOA_MSG_SHOW_TALK_DOWN;
		msg.cParam=(void*)m_pGame;
		msg.pParam1=(void*)m_pGame->GetPlayer();
		msg.pParam2=new char[1024];
		msg.dwNewFlag=LOA_MSG_NEW_P2PARAM_A;
		strncpy((char*)msg.pParam2,str,1024);
		m_pMsgQueue->AddMessage(msg);
*/
		return true;
	}
//ShowMessage(int delay,char*str)
	else if(strcmp(szFunction,"showmessage")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		CTalk talk;
		talk.ShowMessage(m_pGame,
						str,
						iv1,
						250,220,NULL,
						RGB(255,255,255),RGB(0,0,0),
						16,20,false);
/*		
		msg.ID=LOA_MSG_SHOW_MESSAGE;
		msg.cParam=(void*)m_pGame;
		msg.pParam1=(void*)iv1;
		msg.pParam2=new char[1024];
		msg.dwNewFlag=LOA_MSG_NEW_P2PARAM_A;
		strncpy((char*)msg.pParam2,str,1024);
		m_pMsgQueue->AddMessage(msg);
*/
		return true;
	}
//Delay(int time);
	else if(strcmp(szFunction,"delay")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->Delay(iv1);
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetStandNPC(int id,bool bStand)
	else if(strcmp(szFunction,"setstandnpc")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);


		STRenderRole*pRole;
		if(m_pGame->GetNpcList()->FindData(iv1,pRole))
		{
			pRole->pRole->bStandNPC=iv2;
		}

		return true;
	}
//-----------------------------------------------------------------------------------------
//LoadRoleIni(char*str);
	else if(strcmp(szFunction,"loadroleini")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		
		m_pGame->InitRoleGraphData(str);
		return true;
	}
//-----------------------------------------------------------------------------------------
//AddNpc(char*name,char*nameInGame,int idInGame,int x,int y);
	else if(strcmp(szFunction,"addnpc")==0)
	{
		ScriptStr str2;
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;										//跳过逗号
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str2);
		m_pBufCur++;		
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);

		m_pGame->AddNpc(str,str2,iv1,iv2,iv3);
		return true;
	}
//-----------------------------------------------------------------------------------------
//DelNpc(int idInGame);
	else if(strcmp(szFunction,"delnpc")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->DelNpc(iv1);
		return true;
	}
//-----------------------------------------------------------------------------------------
//AddPlayer(char*name,int x,int y);
	else if(strcmp(szFunction,"addplayer")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);

		m_pGame->AddPlayer(str,iv1,iv2);
		return true;
	}
//AddPlayerWithIniData(char*szFile,char*szSegment)
	else if(strcmp(szFunction,"addplayerwithinidata")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;

		ScriptStr str2;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str2);
		m_pGame->AddPlayerWithIniData(str,str2);
		return true;
	}
//-----------------------------------------------------------------------------------------
//LoadMap(char*name)
	else if(strcmp(szFunction,"loadmap")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pGame->LoadMap(str);
		return true;
	}
//-----------------------------------------------------------------------------------------
//ShowShop(char*szFile,char*szSegment);
	else if(strcmp(szFunction,"showshop")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;

		ScriptStr str2;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str2);
		
		m_pGame->ShowShop(str,str2);
		return true;
	}
//showPicAndMessage(char*szPic,char*szMsg);
	else if(strcmp(szFunction,"showpicandmessage")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;

		ScriptStr str2;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str2);
		m_pGame->ShowStaticPictureWithMessage(str,str2);
		return true;
	}
//SetDither(BOOL bDither)
	else if(strcmp(szFunction,"setdither")==0)
	{
		iv1=false;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->SetDither(iv1);
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetBlock(int x,int Y);
	else if(strcmp(szFunction,"setblock")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].bCross=false;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//ClearBlock(int x,int y)
	else if(strcmp(szFunction,"clearblock")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].bCross=true;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetTileObj1(int tileX,int TileY,int surfID,int x,int y);
	else if(strcmp(szFunction,"settileobj1")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv4);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv5);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height
			&& (iv3==255 || (iv3>=0 && iv3<=9)) &&
			iv4>=0 && iv4<m_pGame->GetMap()->m_head.Width && iv5>=0 && iv5<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].IDObj_1=iv3;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].xObj_1=iv4;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].yObj_1=iv5;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetLayerObj1(int tileX,int tileY,int layer)
	else if(strcmp(szFunction,"setlayerobj1")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{ 
			m_pGame->GetMap()->m_ppTile[iv1][iv2].Layer1=iv3;
		}
	}
//-----------------------------------------------------------------------------------------
//SetLayerObj2(int tileX,int tileY,int layer)
	else if(strcmp(szFunction,"setlayerobj2")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{ 
			m_pGame->GetMap()->m_ppTile[iv1][iv2].Layer2=iv3;
		}
	}
//-----------------------------------------------------------------------------------------
//SetTileObj2(int tileX,int TileY,int surfID,int x,int y);
	else if(strcmp(szFunction,"settileobj2")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv4);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv5);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height
			&& (iv3==255 || (iv3>=0 && iv3<=9)) &&
			iv4>=0 && iv4<m_pGame->GetMap()->m_head.Width && iv5>=0 && iv5<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].IDObj_2=iv3;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].xObj_2=iv4;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].yObj_2=iv5;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetTileAniObj1(int tileX,int TileY,int AniID);
	else if(strcmp(szFunction,"settileaniobj1")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].IDObj_1=10;//AniSurfaceID
			m_pGame->GetMap()->m_ppTile[iv1][iv2].xObj_1=iv3 % 20;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].yObj_1=iv3 / 20;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetTileAniObj2(int tileX,int TileY,int AniID);
	else if(strcmp(szFunction,"settileaniobj2")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].IDObj_2=10;//AniSurfaceID
			m_pGame->GetMap()->m_ppTile[iv1][iv2].xObj_2=iv3 % 20;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].yObj_2=iv3 / 20;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetMapTileChangeMap(int x,int y,int mapid);
	else if(strcmp(szFunction,"setmaptilechangemap")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].flag=LOA_MAP_FLAG_CHANGE_MAP;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].flagdata=iv3;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetMapTileLoadScript(int x,int y,int scriptid);
	else if(strcmp(szFunction,"setmaptileloadscript")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv3);
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].flag=LOA_MAP_FLAG_LOAD_SCRIPT;
			m_pGame->GetMap()->m_ppTile[iv1][iv2].flagdata=iv3;
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//ClearMapTileFlag(int x,int y)
	else if(strcmp(szFunction,"clearmaptileflag")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetMap()->m_ppTile[iv1][iv2].flag=0;
		}
		return true;
	}
//SetRandomBattle(BOOL bRandBattle,int Frequency)
	else if(strcmp(szFunction,"setrandombattle")==0)
	{
		iv1=true;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);

		m_pBufCur++;
		iv2=15;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);

		m_pGame->SetRandomBattle(iv1);
		m_pGame->SetBattleFrequency(iv2);

		return true;
	}
//fightboss(char*szBattleMap,char*szBattleMusic,char*szBossGraphIni,char*szBossRoleIni,char*szBossRoleSegment,BOOL bNeedWin);
	else if(strcmp(szFunction,"fightboss")==0)
	{
		ScriptStr str2,str3,str4,str5;
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str2);
		m_pBufCur++;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str3);
		m_pBufCur++;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str4);
		m_pBufCur++;

		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str5);
		m_pBufCur++;

		iv1=true;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
	
		if(-1==m_pGame->BossBattle(str,str2,str3,str4,str5,iv1))
			return -1;
	}
//-----------------------------------------------------------------------------------------
//exitGame(int exitcode);
	else if(strcmp(szFunction,"exitgame")==0)
	{	
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->QuitGame(iv1);
//		msg.ID=LOA_MSG_QUIT;
//		msg.pParam1=(void*)iv1;
//		m_pMsgQueue->AddMessage(msg);
		return false;
	}
	else
	{
		m_pLog->WriteMessage("Unkown Script Command:<%s> In ScriptFile<%s>\n",szFunction,m_szScriptFile);
		return true;
	}
	return true;
}
BOOL CScript::WaitForNextChar(char*&pBufCur)
{
	while(pBufCur<=m_pBufEnd)
	{
		if(*pBufCur=='"')
		{
			pBufCur++;										//跳过"号
			return true;
		}
		if(*pBufCur==' ' || *pBufCur=='\t' || *pBufCur=='\n')
		{
			pBufCur++;								
			continue;
		}
		else												//如果是其他符号
		{
			return false;
		}
	}
	return false;
}
BOOL CScript::WaitForNextNum(char*&pBufCur)
{
	while(pBufCur<=m_pBufEnd)
	{
		if(IsNum(*pBufCur))
			return true;
		if(*pBufCur==' ' || *pBufCur=='\t' || *pBufCur=='\n')
		{
			pBufCur++;								
			continue;
		}
		else												//如果是其他符号
		{
			return false;
		}
	}
	return false;
}

⌨️ 快捷键说明

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