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

📄 hero.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				DWORD dwAction;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwAction))
				{
					this->SetIntoneCmd(dwAction);
					return;
				}
			} 
		
			if (0 == strcmp(szCmd, "开除"))
			{
				char szName[256] = "";
				if (2 == sscanf(pszCmdLine, "%s %s", szCmd, szName))
				{
					CNetCmd::SynFireMember(szName);
					return;
				}
			} 
			if (0 == strcmp(szCmd, "armor"))
			{
				int nLevel;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nLevel))
				{
					g_objHero.SetArmor(nLevel);
				}
			} 


			if(0 == stricmp(szCmd, "addeffect"))
			{
				char szIndex[64];
				if (2 == sscanf(pszCmdLine, "%s %s", szCmd, szIndex))
				{
					g_objHero.m_objEffect.Add(szIndex, true, this->GetDir());
				}
			}
			if(0 == stricmp(szCmd, "setmantle"))
			{
				DWORD dwMantle;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &dwMantle))
					g_objHero.SetMantle(dwMantle);
			}
			
			if (0 == stricmp(szCmd, "setrweapon"))
			{
				DWORD dwRWeapon;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwRWeapon))
				{
					g_objHero.SetRWeapon(dwRWeapon);
				}
			}
			if (0 == stricmp(szCmd, "setmount"))
			{
				DWORD dwMount;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwMount))
				{
					g_objHero.SetMount(dwMount);
				}
			}
#ifdef _DEBUG 
			if (0 == stricmp(szCmd, "Status"))
			{
				int nStatus;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &nStatus))
				{
					switch(nStatus) 
					{
					case 0:
						this->ClrStatus(this->GetStatus());
						break;						
					case 1:
						this->SetStatus(USERSTATUS_ATTACK);
						break;
					case 2:
						this->SetStatus(USERSTATUS_ADJUST_XP);
						break;
					default:
						break;
					}
					return;
				}
			} 

			if(0 == stricmp(szCmd, "Emotion"))
			{
				int nEmotion;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nEmotion))
				{
					g_objHero.Emotion(nEmotion);
				}
			}
			if(0 == stricmp(szCmd, "shoot"))
			{
				OBJID idTarget;
				if(2 == sscanf(pszCmdLine, "%s %u", szCmd, &idTarget))
				{
					CMagicEffect* pEffect = CMagicEffect::CreateNew(g_objHero.GetID(), idTarget, this->GetRWeapon(), 0);
					g_objGameMap.AddMagicEffect(pEffect);
				}
			}
			if(0 == stricmp(szCmd, "Action"))
			{
				g_objObserver.SwitchAction();
			}
//			if(0 == stricmp(szCmd, "wound"))
//			{
//				if(this->TestStatus(USERSTATUS_WOUND))
//					this->ReplaceStatus(0);
//				else
//					this->ReplaceStatus(USERSTATUS_WOUND);
//			}
			if(0 == stricmp(szCmd, "item"))
			{
				g_objObserver.Switch();
			}
			if(0 == stricmp(szCmd, "DropMoney"))
			{
				DWORD dwData;
				CMyPos posMouse, posCell;
				::MouseCheck(posMouse.x, posMouse.y);
				g_objGameMap.Screen2Cell(posMouse.x, posMouse.y, posCell.x, posCell.y);
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwData))
					g_objHero.DropMoney(dwData, posMouse.x, posMouse.y);
			}
			if(0 == stricmp(szCmd, "mapitem"))
			{
				CMyPos posMouse, posCell;
				::MouseCheck(posMouse.x, posMouse.y);
				g_objGameMap.Screen2Cell(posMouse.x, posMouse.y, posCell.x, posCell.y);
				DWORD dwData;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwData))
					g_objGameMap.Add3DMapItem(100+::RandGet(99999), dwData, posCell);
			}

			if(0 == stricmp(szCmd, "Radar"))
			{
				int nMode;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nMode))
				{
				//	g_objGameMap.m_objRadar.SetMode(nMode);
				}
			}
			if (0 == stricmp(szCmd, "setpos"))
			{
				CMyPos posHero, posHeroWorld;
				if (3 == sscanf(pszCmdLine, "%s %u %u", szCmd, &posHero.x, &posHero.y))
				{
					g_objHero.SetPos(posHero.x, posHero.y);
					g_objGameMap.Cell2World(posHero.x, posHero.y, posHeroWorld.x, posHeroWorld.y);
					g_objHero.SetAlignPos(posHero.x, posHero.y);

					CMyPos posWorld;
					g_objHero.GetWorldPos(posWorld);
					
					posWorld.x	-=_SCR_WIDTH/2;
					posWorld.y	-=_SCR_HEIGHT/2;
					
					g_objGameMap.SetViewPos(posWorld);
					g_objGameMap.AddInteractiveObj(&g_objHero);

				}
			}
			if (0 == stricmp(szCmd, "killpet"))
			{
				int nAmount = g_objPlayerSet.GetPlayerAmount();
				for(int i = 0; i < nAmount; i ++)
				{
					CPlayer* pPlayer = g_objPlayerSet.GetPlayerByIndex(i);
					if(pPlayer && pPlayer->IsMyPet())
					{
						CMyPos posPet;
						pPlayer->GetPos(posPet);
						CCommand cmd;
						cmd.iType			=_COMMAND_DIE;
						cmd.iStatus			=_CMDSTATUS_BEGIN;
						cmd.posTarget.x		=posPet.x;
						cmd.posTarget.y		=posPet.y;
						
						pPlayer->SetCommand(&cmd);
					}
				}
			}			
			if (0 == stricmp(szCmd, "kill"))
			{
				OBJID idTarget;
				static OBJID idPet = CALLPETID_FIRST;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &idTarget))
				{
					this->SetSpecialTarget(idTarget);
				}
			}

			if (0 == stricmp(szCmd, "callpet"))
			{
				int nLookType;
				static OBJID idPet = CALLPETID_FIRST;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &nLookType))
				{
					idPet++;
					CPet* pPet = CPet::CreateNewPet(idPet, 0,0);
					pPet->SetLook(nLookType);
					pPet->SetRoleType(_ROLE_CALL_PET);
					pPet->Create(nLookType, _ROLE_VIEW_ROLE);
					CMyPos posMouse, posPet;
					MouseCheck(posMouse.x, posMouse.y);
					g_objGameMap.Screen2Cell(posMouse.x, posMouse.y, posPet.x, posPet.y);
					g_objHero.AddPet(idPet);
					pPet->SetPos(posPet);
					g_objPlayerSet.AddPlayer(pPet);
				}
			}
			if (0 == stricmp(szCmd, "die"))
			{
				CMyPos posHero;
				g_objHero.GetPos(posHero);
				CCommand cmd;
				cmd.iType			=_COMMAND_DIE;
				cmd.iStatus			=_CMDSTATUS_BEGIN;
				cmd.posTarget.x		=posHero.x;
				cmd.posTarget.y		=posHero.y;
				
				this->SetCommand(&cmd);
				
			}
			if (0 == stricmp(szCmd, "diefly"))
			{
				CMyPos posHero;
				g_objHero.GetPos(posHero);
				CCommand cmd;
				cmd.iType			=_COMMAND_DIE;
				cmd.iStatus			=_CMDSTATUS_BEGIN;
				cmd.posTarget.x		=posHero.x;
				cmd.posTarget.y		=posHero.y;
				cmd.dwData = 2;
				cmd.nDir = (this->GetDir() + 8) % 8;
				this->SetCommand(&cmd);
			}

			if (0 == stricmp(szCmd, "float"))
			{
				CMyPos posHero;
				g_objHero.GetPos(posHero);
				CCommand cmd;
				cmd.iType			=_COMMAND_FLOAT;
				cmd.iStatus			=_CMDSTATUS_BEGIN;
				cmd.posTarget.x		=posHero.x;
				cmd.posTarget.y		=posHero.y;
				
				this->SetCommand(&cmd);
			}
//			if (0 == stricmp(szCmd, "takeoff"))
//			{
//				CMyPos posHero;
//				g_objHero.GetPos(posHero);
//				CCommand cmd;
//				cmd.iType			=_COMMAND_TAKEOFF;
//				cmd.iStatus			=_CMDSTATUS_BEGIN;
//				cmd.posTarget.x		=posHero.x;
//				cmd.posTarget.y		=posHero.y;
//				
//				this->SetCommand(&cmd);
//				this->ReplaceStatus(USERSTATUS_FLY);
//			}
//			if (0 == stricmp(szCmd, "landing"))
//			{
//				CMyPos posHero;
//				g_objHero.GetPos(posHero);
//				CCommand cmd;
//				cmd.iType			=_COMMAND_LANDING;
//				cmd.iStatus			=_CMDSTATUS_BEGIN;
//				cmd.posTarget.x		=posHero.x;
//				cmd.posTarget.y		=posHero.y;
//				
//				this->SetCommand(&cmd);
//				this->ReplaceStatus(USERSTATUS_NORMAL);
//			}
			if (0 == stricmp(szCmd, "scale"))
			{
				DWORD dwScale = 10000;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwScale))
				{
					g_objGameMap.SetScale(dwScale);
				}
			}
			if (0 == stricmp(szCmd, "setmantle"))
			{
				DWORD dwMantle;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwMantle))
				{
					g_objHero.SetMantle(dwMantle);
				}
			}

			if (0 == stricmp(szCmd, "setrweapon"))
			{
				DWORD dwRWeapon;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwRWeapon))
				{
					g_objHero.SetRWeapon(dwRWeapon);
				}
			}

			if (0 == stricmp(szCmd, "setlweapon"))
			{
				DWORD dwLWeapon;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwLWeapon))
				{
					g_objHero.SetLWeapon(dwLWeapon);
				}
			}
			
			if (0 == stricmp(szCmd, "setmount"))
			{
				DWORD dwMount;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &dwMount))
				{
					g_objHero.SetMount(dwMount);
				}
			}

			if (0 == stricmp(szCmd, "dir"))
			{
				int nDir;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nDir))
				{
					g_objHero.SetDir(nDir);
				}
			}
			if (0 == stricmp(szCmd, "addplayer"))
			{
				CPlayer* pPlayer	=new CPlayer;
				MYASSERT (pPlayer);
				pPlayer->SetDir(this->GetDir());
				pPlayer->SetID(99999+::RandGet(10000));
				pPlayer->SetName("LocalTest");
				pPlayer->Create(2, _ROLE_VIEW_ROLE);
				pPlayer->SetRoleType(_ROLE_MONSTER);

				CMyPos posMouse;
				::MouseCheck(posMouse.x, posMouse.y);
				CMyPos posNpc;
				g_objGameMap.Screen2Cell(posMouse.x, posMouse.y, posNpc.x, posNpc.y);
				
				pPlayer->SetPos(posNpc);
				pPlayer->SetRoleType(_ROLE_MONSTER);
				g_objPlayerSet.AddPlayer(pPlayer);
			}
			if (0 == stricmp(szCmd, "addnpc"))
			{
				int nLook = 5;
				//if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nLook))
				{
						nLook = nLook * 10 + this->GetDir();
						CPlayer* pPlayer	=new CPlayer;
						MYASSERT (pPlayer);
						pPlayer->SetDir(this->GetDir());
						pPlayer->SetID(99999+::RandGet(10000));
						pPlayer->SetName("LocalTest");
						pPlayer->Create(nLook, _ROLE_VIEW_TASKNPC);
						pPlayer->SetRoleType(2);
						CMyPos posMouse;
						::MouseCheck(posMouse.x, posMouse.y);
						CMyPos posNpc;
						g_objGameMap.Screen2Cell(posMouse.x, posMouse.y, posNpc.x, posNpc.y);

						pPlayer->SetPos(posNpc);
						pPlayer->SetRoleType(_ROLE_TARGET_NPC);
						g_objPlayerSet.AddPlayer(pPlayer);
				}
			}
			if (0 == stricmp(szCmd, "delnpc"))
			{
				OBJID idNpc;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &idNpc))
				{
					g_objPlayerSet.DelPlayer(idNpc);
				}
			}
			if (0 == stricmp(szCmd, "createbooth"))
			{
				g_objHero.m_objBoothManager.Open();
			}
			if (0 == stricmp(szCmd, "destroybooth"))
			{
				g_objHero.m_objBoothManager.Close();
			}
			if(0 == stricmp(szCmd, "addboothitem"))
			{
				OBJID id, price;
				if (3 == sscanf(pszCmdLine, "%s %u %u", szCmd, &id, &price))
					g_objHero.m_objBoothManager.AddItem(id, price);
			}
			if(0 == stricmp(szCmd, "delboothItem"))
			{
				OBJID id;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &id))
					g_objHero.m_objBoothManager.DelItem(id);
			}
			if(0 == stricmp(szCmd, "openbooth"))
			{
				OBJID id;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &id))
					g_objHero.m_objBooth.Open(id);
			}
			if(0 == stricmp(szCmd, "closebooth"))
			{
				OBJID id;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &id))
					g_objHero.m_objBooth.Close();
			}
			if(0 == stricmp(szCmd, "buyboothitem"))
			{
				OBJID id;
				if (2 == sscanf(pszCmdLine, "%s %u", szCmd, &id))
					g_objHero.m_objBooth.BuyItem(id);
			}
			if(0 == stricmp(szCmd, "SendBulletin"))
			{
				int nChannel;
				char szMsg[512];
				if (3 == sscanf(pszCmdLine, "%s %s %d", szCmd, szMsg, &nChannel))
				{
					g_objHero.m_objBulletin.SendBulletin(szMsg, nChannel);
				}

			}
			if(0 == stricmp(szCmd, "Emotion"))
			{
				int nEmotion;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nEmotion))
				{
					g_objHero.Emotion(nEmotion);
				}
			}

			if(0 == stricmp(szCmd, "DelBulletin"))
			{
				int nChannel;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nChannel))
				{
					g_objHero.m_objBulletin.DelBulletin(nChannel);
				}
			}
			if(0 == stricmp(szCmd, "QueryList"))
			{
				int nChannel, nIndex;
				if (3 == sscanf(pszCmdLine, "%s %d %d", szCmd, &nIndex, &nChannel))
				{
					g_objHero.m_objBulletin.QueryList(nIndex, nChannel);
				}
			}
			if(0 == stricmp(szCmd, "QueryNote"))
			{
				int nChannel;
				char szSenderName[64];
				if (3 == sscanf(pszCmdLine, "%s %s %d", szCmd, szSenderName, &nChannel))
				{
					g_objHero.m_objBulletin.QueryNote(szSenderName, nChannel);
				}
			}
			if(0 == stricmp(szCmd, "setlife"))
			{
				OBJID idNpc;
				int nLife;
				if (3 == sscanf(pszCmdLine, "%s %u %d", szCmd, &idNpc, &nLife))
				{
					CPlayer* pPlayer = g_objPlayerSet.GetPlayer(idNpc);
					if(pPlayer)
						pPlayer->SetLife(nLife);
				}
			}
			if(0 == stricmp(szCmd, "setpk"))
			{
				int nData;
				if (2 == sscanf(pszCmdLine, "%s %d", szCmd, &nData))
				{
					g_objHero.SetPk(nData);
				}
			}
			if(0 == stricmp(szCmd, "addfriend"))
			{
				if (1 == sscanf(pszCmdLine, "%s", szCmd))
				{
					for(int i = 0; i < 40; i ++)
					{
						char szName[64];
						sprintf(szName, "f%d", i);
						
						CFriend* pFriend =CFriend::CreateNew(9999999+i,
												 szName, 
												 2,
												 ::RandGet(2));
						if (pFriend)
						{				
							g_objHero.AddFriend(pFriend);
						}
					}
				}
			}
			if(0 == stricmp(szCmd, "test1"))
			{
				g_objHero.AddMoneyEffect(100);
				//this->ReplaceStatus(USERSTATUS_NORMAL);
			}

			if(0 == stricmp(szCmd, "FixNpc"))
				g_objHero.FixMousePlayer();
						
			if(0 == stricmp(szCmd, "screenshake"))
				g_objGameMap.BeginShakeEffect();

			if(0 == stricmp(szCmd, "screenscale"))
				g_objGameMap.BeginScaleEffect();

			if(0 == stricmp(szCmd, "screencolor"))
				g_objGameMap.BeginColorEffect();
			if(0 == stricmp(szCmd, "screeneffect"))
			{
				g_objGameMap.BeginShakeEffect();
				g_objGameMap.BeginScaleEffect();
				g_objGameMap.BeginColorEffect();
			}

⌨️ 快捷键说明

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