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

📄 npc_18.cpp

📁 国内著名网络游戏dragon的客户端登陆用完整源码 配套一起上传的服务端部分可开服 无说明文档
💻 CPP
📖 第 1 页 / 共 4 页
字号:
										}
									}
								}
						}
					}
				}							
				else											
				{						
					if (rand()%100 < 90)  //  硅雀绰 喊肺 窍瘤 臼绊 力磊府俊 乐绰促. 
					{							
						return;				
					}							
					
					int dir;						
					int how;								
					int tx, ty;							
					
					dir = Random(8);						
					how = Random(2)+2;						
					tx = n->x/TILE_SIZE;	
					ty = n->y/TILE_SIZE;			
					
					switch (dir)
					{									
					case 0:	ty +=how; break;
					case 1: tx -=how; ty +=how; break;
					case 2: tx -=how; break;
					case 3: tx -=how; ty -=how; break;
					case 4:	ty -=how; break;
					case 5: tx +=how; ty -=how; break;
					case 6: tx +=how; break;
					case 7: tx +=how; ty +=how; break;
					}
					
					NPC_MakePathGuard(n, tx, ty, how);
				}							
			}											
			
			break;							
		}
	case NPC_PATTERN_ACCESS_PC_GUARD_ :
		{						
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{						
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = PCFINDACCESS(n); // 0813 NPC KHS
				if( NPC_IsMoving( n ) )
				{				
					LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
					if( tempch )
						if( !IsDead( tempch )) 
						{			
							if( NPC_IsAttackableRange( n ) )
							{		
								SendModifyPositionNPC( n->id );
								SendNPCAttack(  n->id );
								n->attackcount ++;
								n->patterntype = NPC_PATTERN_ATTACK_PC_GUARD_;
								break;
							}		
						}			
				}				
				else			
				{				
					//						if( NPC_Hostile( n ) ) // 傍拜葛靛捞搁...
					int ex,ey;	
					LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
					if( tempch )
					{			
						if( !IsDead( tempch ) )
						{		
							if( NPC_IsAttackableRange( n ) )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
							{	
								SendNPCAttack(  n->id );
								n->attackcount ++;
								n->patterntype = NPC_PATTERN_ATTACK_PC_GUARD_;
								break;
							}	
							else	// 傍拜啊瓷茄 芭府啊 酒聪搁 辟贸鳖瘤 埃促..................
							{	
								if( NPC_NearCh( n, tempch, &ex, &ey ) )
								{
									n->MoveP = 100 + Random(80);
									NPC_MakePath( n, ex, ey, Random(6) + 2 );
									n->patterntype = NPC_PATTERN_ATTACK_PC_GUARD_;
								}
								else
								{
									n->patterntype = NPC_PATTERN_WANDER_GUARD_;
									n->targetid = -1;
									//									n->bossid = -1;
									//									n->id = -1;
								}
							}	
						}		
						else	
						{		
							n->patterntype = NPC_PATTERN_WANDER_GUARD_;
							n->targetid = -1;
							SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );
							break;
						}		
					}			
					else		
					{			
						n->patterntype = NPC_PATTERN_WANDER_GUARD_;
						n->targetid = -1;
						break;	
					}			
				}				
			}			
		}				
		break;			
								
	case NPC_PATTERN_ATTACK_PC_GUARD_ :
		
		if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
		{	
			n->aitimedelay = g_ClientTime;
			n->aidelayhowmuch = ATTACKACCESS(n)  + (rand()%250);
		}
		else break;
		
		if( NPC_IsAttackableRange( n ) )	// 捞悼 档吝 傍拜措惑某腐甫 傍拜且荐 乐促搁 傍拜茄促. 
		{
			goto ATTACK_GUARD_NEXT__;
		}
		
		if( NPC_IsMoving(n))	break;
		
		if( NPC_IsAttackableRange( n ) )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
		{					
ATTACK_GUARD_NEXT__:
		if( 1 ) // if( NPC_StillAttack(n) ) 0430
		{
			SendNPCAttack(  n->id );
			n->attackcount ++;
		}								
		else							
		{								
			int ex,ey;
			LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
			if( NPC_NearBackCh( n, tempch, &ex, &ey, 5 ) )
			{
				n->MoveP = 60 + Random(30 );
				NPC_MakePath( n, ex, ey, Random(2)+2 );
				n->patterntype =NPC_PATTERN_ACCESS_PC_GUARD_;		//WANDER_8_;
			}
			else
			{
				n->patterntype =NPC_PATTERN_ACCESS_PC_GUARD_;		//WANDER_8_;
				//Debug( "%d :  patterntype :%d ", n->id, n->patterntype );
			}
		}
		}
		else
		{
			if( n->targetid != -1 )
			{
				int ex,ey;
				LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
				if( !IsDead( tempch ) )
				{		
					if( NPC_NearCh( n, tempch, &ex, &ey ) )
					{		
						//if( NPC_EnemyOnMyWay( 		
						// 聪刀匙 傍拜惑措俊霸 立辟窍扁 困茄 风凭阑 持绰促. ( 'ぁ' 'い'栏肺 
						n->MoveP = 60 + Random(30 );
						NPC_MakePath( n, ex, ey, Random(6)+2 );
						
					}			
					else		
					{	
						n->patterntype =NPC_PATTERN_ACCESS_PC_GUARD_;		//WANDER_8_;
						//								n->patterntype = NPC_PATTERN_WANDER_8_;
						//								Debug( "%d :  patterntype :%d ", n->id, n->patterntype );
						//								n->bossid	 = -1;
						//								n->id = -1;
						//								JustMessage( " %d狼 Pattern锅龋 %d ", n->id, n->patterntype );
						//								JustMessage( " %d狼 Pattern锅龋 %d ", n->patterntype );
					}				
				}
				else 
				{
					n->patterntype =NPC_PATTERN_WANDER_GUARD_;		//WANDER_8_;
					n->targetid = -1;
					SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );
				}
			}					
			else 
			{
				n->patterntype =NPC_PATTERN_WANDER_GUARD_;		//WANDER_8_;
				n->targetid = -1;
			}
		}
		break;					
		
	case NPC_PATTERN_BACKDRAW_PC_GUARD_ :
		{					
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 500  + (rand()%500);
				
				if( NPC_IsMoving( n ) )
				{			
					
				}			
				else		
				{			
					if( n->targetid != -1 )
					{		
						
						int ex,ey;
						LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
						
						if( InDistance( n, tempch,  TILE_SIZE * 10 ) )	// 弊 PC啊  10 鸥老救俊 乐促搁.
						{	
							n->patterntype = NPC_PATTERN_WANDER_GUARD_;
							if( NPC_NearBackCh( n, tempch, &ex, &ey, 10 ) )
							{	
								NPC_MakePath( n, ex, ey, Random(10)+5 );
							}	
							else 
							{
							}
						}
						else	// 面盒洒 钢府乐焙.
						{
							n->patterntype = NPC_PATTERN_WANDER_GUARD_;
							
						}
					}
					else
					{
						n->patterntype = NPC_PATTERN_WANDER_GUARD_;
						
					}
				}
			}
			break;			
		}
	}
}

void NPC_Pattern_MAUL( LPCHARACTER n )
{		
	switch( n->patterntype )
	{	
	case NPC_PATTERN_EVENTING_MAUL_ :
					
		//if(  n俊	措茄 胶农赋飘啊 柳青吝捞搁..
		break;		
					
	case NPC_PATTERN_ACCESS_PC_MAUL_ : 
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = PCFINDACCESS(n); // 0813 NPC KHS
			}
			else break;

			if( NPC_IsMoving( n ) )
			{		
			}		
			else		
			{		
//-------------------
				/*
				int targetid = NPC_IsWhoNearRedPC( n, 15 );
				if( targetid != -1 )
				{	
					n->patterntype = NPC_PATTERN_ACCESS_PC_MAUL_;
					n->targetid = targetid;
					

					switch( n->SprNo )
					{

					switch( rand()%10 )
					{
						case 0 :	SendNPCChatArea( n->id, "恐 弊矾技夸.." );									break;
						case 1 :	SendNPCChatArea( n->id, "弊矾瘤 付矫绊 观俊乐绰 阁胶磐甫 绝局林技夸." );		break;
						case 2 :	SendNPCChatArea( n->id, "磊操 弊矾矫搁 寸脚俊霸 拱扒阑 给迫霸 窍摆绢夸." );	break;
						case 3 :	SendNPCChatArea( n->id, "呈公窍绰焙夸.. 酒.. 塞捞 巢酒倒搁..." );				break;
						case 4 :	SendNPCChatArea( n->id, "轿快绰巴阑 夯捞惑 侩辑 且荐 绝促." );				break;
					}
				}					
				else			
				{					
					int dir;
					int how;
					int tx, ty;
					
					dir = Random(8);
					how = Random(2)+2;
					tx = n->x/TILE_SIZE;
					ty = n->y/TILE_SIZE;
					switch( dir )
					{
						case 0 :			ty +=how; break;
						case 1 : tx -=how;	ty +=how; break;
						case 2 : tx -=how;            break;
						case 3 : tx -=how;	ty -=how; break;
						case 4 :			ty -=how; break;
						case 5 : tx +=how;	ty -=how; break;
						case 6 : tx +=how;		      break;
						case 7 : tx +=how;	ty +=how; break;
					}
					
					if( NPC_MakePathBumn( n, tx, ty, how ) )
					SendMoveNPCArea(  n->id );
					
					//  PK茄 某腐磐啊 绝促搁 啊父洒 乐绰促. 
				}				
			}					
								
		break;				
//-------------------------
				*/
			}
	
		break;


	case NPC_PATTERN_ATTACK_MAUL_	:
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = ATTACKACCESS(n)  + (rand()%1000);
			}
			else break;

			if( NPC_IsMoving( n ) )
			{
			}
			else 
			{

			}

		
		break;
	case NPC_PATTERN_BACKDRAW_MAUL_	:
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1000  + (rand()%1000);
			}
			else break;


		break;
			
	case NPC_PATTERN_WANDER_MAUL_	:


			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1000  + (rand()%400);
			}
			else break;

				// 弊成 硅雀茄促. 
			if( NPC_IsMoving( n ) )
			{
			}
			else 
			{
				return;
				if( rand()%100 < 90 )  //  硅雀绰 喊肺 窍瘤 臼绊 力磊府俊 乐绰促. 
				{
					return;
				}

				int dir;
				int how;
				int tx, ty;

				dir = Random(8);
				how = Random(3)+1;
				tx = n->x/TILE_SIZE;
				ty = n->y/TILE_SIZE;
				switch( dir )
				{
					case 0 :			ty +=how; break;
					case 1 : tx -=how;	ty +=how; break;
					case 2 : tx -=how;            break;
					case 3 : tx -=how;	ty -=how; break;
					case 4 :			ty -=how; break;
					case 5 : tx +=how;	ty -=how; break;
					case 6 : tx +=how;		      break;
					case 7 : tx +=how;	ty +=how; break;
				}

				if( tx >= 0 && ty >= 0 && tx < g_Map.file.wWidth && ty < g_Map.file.wHeight )
				if( TileMap[n->x/TILE_SIZE][ n->y/TILE_SIZE].attr_inside == TileMap[ tx][ ty].attr_inside )
				{
					NPC_MakePathMaul( n, tx, ty, how );
				}
			}

		break;

	}
}	
	
	
void Recv_FaceDirections( t_face_directions *tp )
{
	LPCHARACTER ch = ReturnCharacterPoint( tp->id );
	if( ch == NULL ) return;
	ch->todir = (DIRECTION) tp->dir;
}
	
void Send_JustAni( int id, int anino )
{	
	t_packet packet;
	
	packet.h.header.type = CMD_JUST_ANI;
	packet.h.header.size = sizeof( t_just_ani );
		packet.u.just_ani.id  = id;
		packet.u.just_ani.ani = anino;
		
	QueuePacket( &packet, 1 );
}
		
void Recv_JustAni( t_just_ani *p )
{		
	LPCHARACTER ch = ReturnCharacterPoint( p->id );
	if( ch == NULL ) return;
		
	if( p->id >= 10000 )
	{	
		ch->just_ani = true;
		CharDoAni( ch, ch->direction, p->ani );
	}	
}		
		
void NPC_Pattern_SealStone( LPCHARACTER n )
{
	int nation;

						
	switch( n->patterntype )
	{					
	case NPC_PATTERN_SEALSTONE_NO_OPERATE_ :
							
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
			{
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 5000 + (rand()%1000);
			}
			else break;

			if( n->attacked > 30 )
				if( rand()%2 == 0 )
				{
					n->attacked = 0;
				}
				else
				{
					n->attacked = 0;

					switch( n->sprno ) // 搬拌籍狼 惫啊内靛..
					{
						case 98 : nation = 3;	break;
						case 99 : nation = 4;	break;
						case 91 : nation = 6;	break;
					}

					int targetid = 	NPC_IsWhoNearOtherNationPc( nation, n, 10);
					if( targetid != -1 )
					{
						n->patterntype = NPC_PATTERN_SEALSTONE_ATTACK_;
						n->targetid = targetid;
						Send_JustAni( n->id, 1 );
						n->aitimedelay = g_ClientTime;
						n->aidelayhowmuch = 1000;
					}
				}
		break;

	case NPC_PATTERN_SEALSTONE_ATTACK_:
			
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay		= g_ClientTime;
				n->aidelayhowmuch	= 3000;
			}
			else break;
			
			LPCHARACTER ch = ReturnCharacterPoint( n->targetid );
			if( ch )	
			{
				n->patterntype = NPC_PATTERN_SEALSTONE_NO_OPERATE_;
			}
			break;					
	}

}

⌨️ 快捷键说明

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