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

📄 npc_18.cpp

📁 国内著名网络游戏dragon的客户端登陆用完整源码 配套一起上传的服务端部分可开服 无说明文档
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			int bossid = -1;
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{			
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 500  + (rand()%400);
						
				if( NPC_IsMoving( n ) )
				{		
				}		
				else		
				{		
					int bossid = NPC_WhoIsBoss( n ); // 去磊扼绰 娟扁.
					if( bossid != -1 )	
					{	
						if( bossid != n->id )	// 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙.. 
						{
							n->bossid = bossid;
							n->patterntype = NPC_PATTERN_TOBOSS_18_;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
						}
						else  // 郴啊 Boss捞促. 
						{
							n->bossid = bossid;
							n->patterntype = NPC_PATTERN_IAM_BOSS_18_;
							n->targetid = -1;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
							SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );
						}
					}	
					else 
					{	
						n->patterntype = NPC_PATTERN_WANDER_18_;
						
						n->bossid = -1;
						n->targetid = -1;
						SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
						SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );
					}	
				}		
			}			
		}				
		break;				
						
		case NPC_PATTERN_ACCESS_PC_18_ :
			{			
			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_18_;
								break;
							}
						}
					}	
					else
					{	
//						if( NPC_Hostile( n ) ) // 傍拜葛靛捞搁...
							
						LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
										
						if( !IsDead( tempch ) )
						{
							if( NPC_IsAttackableRange( n ) )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
							{
								SendNPCAttack( n->id );
								n->attackcount ++;
								n->patterntype = NPC_PATTERN_ATTACK_PC_18_;

								break;
							}
							else	// 傍拜啊瓷茄 芭府啊 酒聪搁 辟贸鳖瘤 埃促. 
							{
								int ex, ey;
								if( NPC_NearCh( n, tempch, &ex, &ey ) )
								{
									n->MoveP = 60 + Random(30 );
									NPC_MakePath( n, ex, ey, Random(6) + 2 );
								}
								else
								{
//									n->patterntype = NPC_PATTERN_WANDER_18_;
									
//									n->bossid = -1;
//									n->id = -1;
								}
							}
						}	
						else 
						{
							n->patterntype = NPC_PATTERN_TOBOSS_18_;
							
							n->bossid	= -1;
							n->targetid = -1;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
							SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );

							break;
						}
					}	
				}		
			}			
			break;		
						
		case NPC_PATTERN_ATTACK_PC_18_ :
							
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{			
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = ATTACKACCESS(n)  + (rand()% 600 );
						
				if( NPC_IsMoving(n))
				{		
						LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
						if( tempch )
						if( !IsDead( tempch ) )
						{
							if( NPC_IsAttackableRange( n ) )
							{
								SendNPCAttack( n->id );
								n->attackcount ++;
								break;
							}
						}

					break;
				}		
						
				if( n->bossid != -1)  
				{		
					LPCHARACTER tempch = ReturnCharacterPoint( n->bossid );
						
					if( IsDead( tempch ) ) // 趣矫 Boss啊 磷栏搁....
					{	
						tempch = Hero;
						while( tempch )
						{
							if( tempch->type == SPRITETYPE_MONSTER && !IsDead( tempch ))
							{
								if( tempch->bossid == n->bossid )
								{
									tempch->bossid   = -1;
									tempch->targetid = -1;
									tempch->patterntype = NPC_PATTERN_BACKDRAW_18_;
									SendNPC_parameter( tempch->id, NPC_PARAMETER_BOSSID, n->bossid);
									SendNPC_parameter( tempch->id, NPC_PARAMETER_TARGETID, n->targetid );

								}
							}
							tempch = tempch->lpNext;
						}
						break;
					}	
				}		
						
						
				if( NPC_IsAttackableRange( n )  )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
				{		
					if( NPC_StillAttack(n) )
					{	
						SendNPCAttack(  n->id );
						n->attackcount ++;
					}									
					else							
					{								
						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->MoveP = 0;
						}									
						else						
						{							
							n->patterntype =NPC_PATTERN_TOBOSS_18_;		//WANDER_18_;
						}		
					}			
				}				
				else			
				{				
Attack_access_pc_:
					if( n->targetid != -1 )
					{		
						LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
						int ex, ey;
						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_WANDER_18_;
//								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_TOBOSS_18_;		//WANDER_18_;
							
						}
					}					
					else
					{
						n->targetid = NPC_IsWhoNearPC( n, 10 );
						if( n->targetid != -1 ) goto Attack_access_pc_;
						else 
						{
						}
					}
				}
			}						
			break;					
								
		case NPC_PATTERN_BACKDRAW_18_ :
			{
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1500  + (rand()%1000);
								
					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 鸥老救俊 乐促搁.
							{	
								if( NPC_NearBackCh( n, tempch, &ex, &ey, 7 ) )
								{	
									n->MoveP = 60 + Random(30 );
									NPC_MakePath( n, ex, ey, Random(5)+5 );

								}	
								else 
								{
								
								}
							}
							else	// 面盒洒 钢府乐焙.
							{
								n->patterntype = NPC_PATTERN_WANDER_18_;
								
							}
						}		
						else	
						{		
							n->patterntype = NPC_PATTERN_WANDER_18_;
							
						}		
					}				
				}				
				break;			
			}				
	}
}						
					
						
					
						
					
void NPC_Pattern_Tammed( CHARACTER *n )
{					
//	int movep;		
//	int ex, ey;			
//	int i;
	CHARACTER *ch;	
					
	switch( n->patterntype )
	{					
	case NPC_PATTERN_TAME_ :
		{															
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1000  + (rand()%1000);
																						
				//	弊成 硅雀茄促.
				if( NPC_IsMoving( n ) )	
				{								
					switch( n->tame_cmd )		
					{							
						case LC_TAME_STOP :		
												if( n->pathcount ) //噶距 捞悼吝捞搁 碍力 Stop矫挪促. 
												{
													SendModifyPositionNPC(  n->id ); // 弊困摹肺 碍力 捞悼矫挪促. 
												}
												n->pathcount = 0;
						break;					
					}								
				}								
				else							
				{								
					switch( n->tame_cmd )
					{							
						case LC_TAME_STOP		:	
							_asm nop;						
							
							
							break;
						case LC_TAME_ATTACK		:	
						{						
							int ex, ey;
								
							ch = NPC_ReturnCharListPoint( n->targetid );
							if( ch ) // 傍拜措惑捞 乐促搁
							{							
								if( strcmp( ch->name, n->TargetName ) == 0 ) // 弊 傍拜措惑狼 捞抚苞 傍拜措惑 ID啊 老摹窍搁.
								{
									if( NPC_IsAttackableRange( n )  ) // 傍拜 措惑捞 傍拜啊瓷裹困俊 乐栏搁..
									{
										SendNPCAttack(  n->id );	// 傍拜茄促. 
										n->attackcount ++;	
										return;
									}
									else	// 傍拜荤沥鼻 观俊 乐促搁.
									{
										// 弊镑栏肺 捞悼茄促. 
										if( NPC_NearCh( n, ch, &ex, &ey ) )
										{
											n->MoveP = 60 + Random(30 );
											if( NPC_MakePath( n, ex, ey, Random(6) + 2 ) )	
											{
												

											}
											else
											{
												if( (rand()%4) == 2 ) n->tame_cmd = LC_TAME_STOP;
												SendNPC_parameter( n->id, NPC_PARAMETER_TAME_CMD, LC_TAME_STOP );
											}
											n->MoveP = 0;
										}
										else 
										{
											if( (rand()%4) == 2 ) n->tame_cmd = LC_TAME_STOP;
											else break;
										}
									}	
								}
								else
								{
									n->tame_cmd = LC_TAME_STOP;
									SendNPC_parameter( n->id, NPC_PARAMETER_TAME_CMD, LC_TAME_STOP );

									return;
								}
							}
							else // 傍拜措惑捞 绝促搁.
							{
								n->tame_cmd = LC_TAME_STOP;
								SendNPC_parameter( n->id, NPC_PARAMETER_TAME_CMD, LC_TAME_STOP );

								return;
							}
						break;
						}	
						case LC_TAME_FOLLOWME : 
						{	
							ch = NPC_ReturnCharListPoint( n->HostId );		// 唱狼 林牢捞 捞 甘俊 乐绊 

							if( ch == NULL )
							{
								n->tame_cmd = LC_TAME_STOP;
								SendNPC_parameter( n->id, NPC_PARAMETER_TAME_CMD, LC_TAME_STOP );
								break;
							}
							else if( strcmp( ch->name, n->HostName ) == 0 )	// 弊 傍拜措惑狼 捞抚苞 傍拜措惑 ID啊 老摹窍搁.
							{
								goto NEXT_FOLLOWME_;
							}
							else 
							{
								LPCHARACTER tempch = Hero;

								while( tempch )
								{
									if( strcmp( n->HostName, tempch->name ) == 0 ) // 唱狼 林牢阑 父车促. 
									{
										if( BoxAndDotCrash( n->x/TILE_SIZE - 12,  n->y/TILE_SIZE - 12, 24,24, tempch->x/TILE_SIZE, tempch->x/TILE_SIZE ) )	// 唱狼 林牢捞 唱狼 矫具裹困郴俊 乐促. 
										{
											n->HostId = tempch->id;
											goto NEXT_FOLLOWME_;
										}
									}
									tempch = tempch->lpNext;
								}

								n->tame_cmd = LC_TAME_STOP;
								SendNPC_parameter( n->id, NPC_PARAMETER_TAME_CMD, LC_TAME_STOP );
								return;
							}
NEXT_FOLLOWME_:

							if( NPC_IsInHostRange( n ) )	// Host救俊 甸绢吭栏搁..
							{
								break;
							}
							else  //  Boss扮栏肺 啊具瘤...
							{
								if( n->HostId != -1 )
								{
									int ex, ey;
									LPCHARACTER tempch = ReturnCharacterPoint( n->HostId );
									if( NPC_NearPosition( n, tempch, &ex, &ey ))
									{
										NPC_MakePath( n, ex, ey, Random(6) + 2 );

											break;
									}
								}
							}
							
						break;
						}		
					}					
				}
			}		
		}		
		break;	
	}		
}			
			
void NPC_Pattern_GUARD(LPCHARACTER n)
{			
	switch (n->patterntype)
	{					
	case NPC_PATTERN_WANDER_GUARD_:
		{	
			if (g_ClientTime - n->aitimedelay > n->aidelayhowmuch)
			{
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1000 + (rand()%1000);
			}
			else
			{
				break;
			}
			
			// 弊成 硅雀茄促.
			if (!NPC_IsMoving(n))
			{		
				int targetid = NPC_IsWhoNearRedPC( n, 10 );
				if( targetid != -1 )
				{			
					n->patterntype = NPC_PATTERN_ACCESS_PC_GUARD_;
					n->targetid = targetid;
					
					if( n->targetid >= 10000 )
					{		
						
					}		
					else 
					{
						if( rand()%100 < 30 )
						{
							LPCHARACTER tch = ReturnCharacterPoint( n->targetid );
							
#ifdef _NATION_APPLY_
							if(  tch->name_status.nation  == MapInfo[ MapNumber].nation || MapNumber == 30  )
#else
								if( 1 )
#endif
								{
									switch( rand()%3 )
									{		
									case 0:	SendNPCChatArea(n->id, lan->OutputMessage(4, 37)); break;//lsw
									case 1:	SendNPCChatArea(n->id, lan->OutputMessage(4, 38));	break;//lsw
									}					
								}
								else if( rand()%100 < 50 )
								{
									LPCHARACTER tch = ReturnCharacterPoint( n->targetid );
									if( tch )
									{
										switch( tch->name_status.nation )		//1004 YGI
										{
										case 3 : SendNPCChatArea( n->id, lan->OutputMessage(4,39) );	break;//lsw
										case 4 : SendNPCChatArea( n->id, lan->OutputMessage(4,40) );	break;//lsw

⌨️ 快捷键说明

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