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

📄 cscript.cpp

📁 一个个人开发的rpg游戏<亚特兰蒂斯传奇>的源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		}
		return true;
	}
//SetNpcPos(int id,int x,int y)
	else if(strcmp(szFunction,"setnpcpos")==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(iv2>=0 && iv2<m_pGame->GetMap()->m_head.Width && iv3>=0 && iv3<m_pGame->GetMap()->m_head.Height)
		{
			STRenderRole*pNpc;
			if(m_pGame->GetNpcList()->FindData(iv1,pNpc))
			{
				pNpc->pRole->x=iv2<<5;
				pNpc->pRole->y=iv3<<5;
			}
		}
		return true;
	}
//SetPlayerPos(int x,int y)
	else if(strcmp(szFunction,"setplayerpos")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;
		if(iv1>=0 && iv1<m_pGame->GetMap()->m_head.Width && iv2>=0 && iv2<m_pGame->GetMap()->m_head.Height)
		{
			m_pGame->GetPlayer()->pRole->x=iv1<<5;
			m_pGame->GetPlayer()->pRole->y=iv2<<5;
		}
		return true;
	}
//SetNpcToMapRole(int ID)
	else if(strcmp(szFunction,"setnpctomaprole")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);

		STRenderRole*pNpc;
		
		if(m_pGame->GetNpcList()->FindData(iv1,pNpc))
		{
			m_pGame->SetMapRole(pNpc);
		}

		return true;
	}
//SetPlayerToMapRole()
	else if(strcmp(szFunction,"setplayertomaprole")==0)
	{
		m_pGame->SetMapRole(m_pGame->GetPlayer());
		return true;
	}
//ShowNpc(int id,bool bShow)
	else if(strcmp(szFunction,"shownpc")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);


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

		return true;
	}
//ShowAllNpc(Bool bShow)
	else if(strcmp(szFunction,"showallnpc")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);

		STRenderRole*pNpc;
		DWORD dwTempAddr=m_pGame->GetNpcList()->GetCurAddress();
		while(m_pGame->GetNpcList()->GetAndMovePointToNext(pNpc))
		{
			pNpc->pRole->bShow=iv1;
		}
		m_pGame->GetNpcList()->SetCurAddress(dwTempAddr);
		return true;
	}
//ShowPlayer(bool bShow)
	else if(strcmp(szFunction,"showplayer")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->GetPlayer()->pRole->bShow=iv1;
		return true;
	}
//-----------------------------------------------------------------------------------------
//SetFlag(int index,int flag);
	else if(strcmp(szFunction,"setflag")==0)				//setflag指令			
	{
		WaitForNextNum(m_pBufCur);
		if(!GetInt(m_pBufCur,iv1))
		{
			m_pLog->WriteMessage("Get Command<setflag>'s Param1 failed!\n");
			return false;
		}
		m_pBufCur++;													//跳过逗号
		if(!WaitForNextNum(m_pBufCur))
		{
			m_pLog->WriteMessage("Command<setflag>'s Param2 Error!\n");
			return false;
		}
		if(!GetInt(m_pBufCur,iv2))
		{
			m_pLog->WriteMessage("Get Command<setflag>'s Param2 failed!\n");
			return false;
		}
		if(iv1>=0 && iv1<m_pScriptData->GetFlagCount())
			m_pScriptData->SetFlag(iv1,iv2);
		return true;
	}
//ScrollScreenTo(int x,int y)
	else if(strcmp(szFunction,"scrollscreento")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pGame->ScrollScreenTo(iv1,iv2);
		return true;
	}
//ScrollScreenToPlayer()
	else if(strcmp(szFunction,"scrollscreentoplayer")==0)
	{
		m_pGame->ScrollScreenToPlayer();
		return true;
	}
//ScrollScreenToNpc(int id);
	else if(strcmp(szFunction,"scrollscreentonpc")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->ScrollScreenToNpc(iv1);
		return true;
	}
//-----------------------------------------------------------------------------------------
//CmpJe(int flagindex,int state,char*jmpto);
	else if(strcmp(szFunction,"cmpje")==0)					//cmpje指令
	{
		WaitForNextNum(m_pBufCur);
		if(!GetInt(m_pBufCur,iv1))
		{
			m_pLog->WriteMessage("Get Command<cmpje>'s Param1 failed!\n");
			return false;
		}
		m_pBufCur++;								//跳过逗号
		if(!WaitForNextNum(m_pBufCur))
		{
			m_pLog->WriteMessage("Command<cmpje>'s Param2 Error!\n");
			return false;
		}
		if(!GetInt(m_pBufCur,iv2))
		{
			m_pLog->WriteMessage("Get Command<cmpje>'s Param2 failed!\n");
			return false;
		}
		m_pBufCur++;								//跳过逗号
		if(!WaitForNextChar(m_pBufCur))
		{
			m_pLog->WriteMessage("Command<cmpje>'s Param3 Error!\n");
			return false;
		}
		
		GetString(m_pBufCur,str);					//得到要跳转的行号
		if(m_pScriptData->IsFlagEquel(iv1,iv2))		//如果满足条件
		{
			m_pBufCur=m_pBuffer;					//重新定位
			while(m_pBufCur<=m_pBufEnd)				//搜索整个文件
			{
				if(!GetNextIndexPositon(m_pBufCur))		//找#开头的
				{
					return false;
				}
				ScriptStr temp;
				GetIndex(m_pBufCur,temp);				//得到本行的索引
			
				if(strcmp(temp,str)==0)					//对索引作判断,如果相等则位置指针保留在这个位置
				{
					return true;
				}
				else
				{
					m_pBufCur++;
				}
			}
			return false;
		}
		else
		{
			return true;
		}
	}
//-----------------------------------------------------------------------------------------
//CmpJne(int flagindex,int state,char*jmpto);
	else if(strcmp(szFunction,"cmpjne")==0)					//cmpjne指令
	{
		WaitForNextNum(m_pBufCur);
		if(!GetInt(m_pBufCur,iv1))
		{
			m_pLog->WriteMessage("Get Command<cmpjne>'s Param1 failed!\n");
			return false;
		}
		m_pBufCur++;								//跳过逗号
		if(!WaitForNextNum(m_pBufCur))
		{
			m_pLog->WriteMessage("Command<cmpjne>'s Param2 Error!\n");
			return false;
		}
		if(!GetInt(m_pBufCur,iv2))
		{
			m_pLog->WriteMessage("Get Command<cmpjne>'s Param2 failed!\n");
			return false;
		}
		m_pBufCur++;								//跳过逗号
		if(!WaitForNextChar(m_pBufCur))
		{
			m_pLog->WriteMessage("Command<cmpjne>'s Param3 Error!\n");
			return false;
		}
			
		GetString(m_pBufCur,str);					//得到要跳转的行号
		if(!m_pScriptData->IsFlagEquel(iv1,iv2))	//如果满足条件
		{
			m_pBufCur=m_pBuffer;					//重新定位
			while(m_pBufCur<=m_pBufEnd)				//搜索整个文件
			{
				if(!GetNextIndexPositon(m_pBufCur))		//找#开头的
				{
					return false;
				}
				ScriptStr temp;
				GetIndex(m_pBufCur,temp);				//得到本行的索引
			
				if(strcmp(temp,str)==0)					//对索引作判断,如果相等则位置指针保留在这个位置
				{
					return true;
				}
				else
				{
					m_pBufCur++;
				}
			}
			return false;
		}
		else
		{
			return true;
		}
	}
//goto
	else if(strcmp(szFunction,"goto")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur=m_pBuffer;					//重新定位
		while(m_pBufCur<=m_pBufEnd)				//搜索整个文件
		{
			if(!GetNextIndexPositon(m_pBufCur))		//找#开头的
			{
				m_pLog->WriteMessage("Script:Get Index<%s> Failed!\n",str);
				return false;
			}
			ScriptStr temp;
			GetIndex(m_pBufCur,temp);				//得到本行的索引
		
			if(strcmp(temp,str)==0)					//对索引作判断,如果相等则位置指针保留在这个位置
			{
				return true;
			}
			else
			{
				m_pBufCur++;
			}
		}
		return false;
	}
//-----------------------------------------------------------------------------------------
//FadeIn();
	else if(strcmp(szFunction,"fadein")==0)
	{
		m_pGame->FadeIn();
		return true;
	}
//FadeInRestore();
	else if(strcmp(szFunction,"fadeinrestore")==0)
	{
		m_pGame->FadeInRestore();
		return true;
	}
//FadeOut();
	else if(strcmp(szFunction,"fadeout")==0)
	{
		m_pGame->FadeOut();
		return true;
	}
//FadeOutRestore();
	else if(strcmp(szFunction,"fadeoutrestore")==0)
	{
		m_pGame->FadeOutRestore();
		return true;
	}
//ClearScreen();
	else if(strcmp(szFunction,"clearscreen")==0)
	{
		m_pGame->ClearScreen();
		return true;
	}
//SetNight();
	else if(strcmp(szFunction,"setnight")==0)
	{
		m_pGame->SetNight();
		return true;
	}
//SetDay();
	else if(strcmp(szFunction,"setday")==0)
	{
		m_pGame->SetDay();
		return true;
	}
//SetGray(BOOL bGray);
	else if(strcmp(szFunction,"setgray")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pGame->SetGray(iv1);
		return true;
	}
//-----------------------------------------------------------------------------------------
//PlayMedia(char*szFile);
	else if(strcmp(szFunction,"playmedia")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;

		m_pGame->PlayMedia(str);
		return true;
	}
	else if(strcmp(szFunction,"pausemedia")==0)
	{
		m_pGame->PauseMedia();
		return true;
	}
	else if(strcmp(szFunction,"resumemedia")==0)
	{
		m_pGame->ResumeMedia();
		return true;
	}
//-----------------------------------------------------------------------------------------
//PlayMediaOnce(char*szFile);
	else if(strcmp(szFunction,"playmediaonce")==0)
	{
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		m_pBufCur++;

		m_pGame->PlayMedia(str,false);
		return true;
	}
//ShowEffect(int id,int x,int y)
	else if(strcmp(szFunction,"showeffect")==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);

		STEffect*pEffect;
		if(m_pGame->GetEffectDataBase()->FindData(iv1,&pEffect))
		{
			CRenderEffect*pRenderEffect=new CRenderEffect;
			pRenderEffect->InitEffect(m_pGame,iv2,iv3,pEffect);
			pRenderEffect->CreateTask();
			m_pGame->GetRender()->AddTask(pRenderEffect);
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//ShowMagic(int id,int x,int y);
	else if(strcmp(szFunction,"showmagic")==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);

		STMagic*pMagic;
		if(m_pGame->GetMagicDataBase()->FindData(iv1,&pMagic))
		{
 			CMagic*mgc=new CMagic();
			mgc->ShowMagic(m_pGame,pMagic,iv2,iv3,0);
		}
		return true;
	}
//-----------------------------------------------------------------------------------------
//BeginMoveRole();
	else if(strcmp(szFunction,"beginmoverole")==0)
	{
		return true;
	}
//EndMoveRole();
	else if(strcmp(szFunction,"endmoverole")==0)
	{
		m_pMoveRole->BeginMove(m_pGame);
		return true;
	}
//MovePlayerTo(int x,int y);
	else if(strcmp(szFunction,"moveplayerto")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		
		m_pMoveRole->AddRole(m_pGame->GetPlayer(),iv1,iv2);
		return true;

	}
//MoveNpcTo(int id,int x,int y);
	else if(strcmp(szFunction,"movenpcto")==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);


		
		STRenderRole*pRole;
 		if(m_pGame->GetNpcList()->FindData(iv1,pRole))
		{
			m_pMoveRole->AddRole(pRole,iv2,iv3);
			return true;
		}

		return true;
	}
//ShowNpcTalk(int pos,int id,char*str);
	else if(strcmp(szFunction,"shownpctalk")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv2);
		m_pBufCur++;
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		

		STRenderRole*pRole;

		if(m_pGame->GetNpcList()->FindData(iv2,pRole))
		{
			CTalk talk;
			talk.AddTalk(str);
			if(iv1==1)
				talk.ShowTalk(pRole,m_pGame,false);
			else 
				talk.ShowTalk(pRole,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*)pRole;
			msg.pParam2=new char[1024];
			msg.dwNewFlag=LOA_MSG_NEW_P2PARAM_A;
			strncpy((char*)msg.pParam2,str,1024);
			m_pMsgQueue->AddMessage(msg);
*/
		}

		return true;
	}
//ShowPlayerTalk(int pos,char*str);
	else if(strcmp(szFunction,"showplayertalk")==0)
	{
		WaitForNextNum(m_pBufCur);
		GetInt(m_pBufCur,iv1);
		m_pBufCur++;										//跳过逗号
		WaitForNextChar(m_pBufCur);
		GetString(m_pBufCur,str);
		CTalk talk;

⌨️ 快捷键说明

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