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

📄 npc_18.cpp

📁 国内著名网络游戏dragon的客户端登陆用完整源码 配套一起上传的服务端部分可开服 无说明文档
💻 CPP
📖 第 1 页 / 共 4 页
字号:
#include "StdAfx.h"

#include "Dragon.h"	
#include "Path.h"
#include "NetWork.h"
#include "Hong_Sub.h"
#include "CharDataTable.h"
#include "NPC_Pattern.h"
#include "Map.h"
#include "lineCommand.h"

extern CHARACTER *NPC_ReturnCharListPoint( int id );
extern void calcNewAbility(CHARACTER *) ;
extern int getMaxHungry(CHARACTER *chr) ;

void NPC_Pattern_8( CHARACTER *n )
{
	switch( n->patterntype )
	{
	case NPC_PATTERN_WANDER_8_ :
		{
			int bossid;
						
			int attacker = NPC_WhoIsAttackMyBaby( n );
				
			if( n->attacked != -1 ) 
			{
				n->patterntype = NPC_PATTERN_ATTACK_PC_8_;
				break;
			}
					
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 200  + (rand()%500);
				// 弊成 硅雀茄促. 
				if( NPC_IsMoving( n ) )
				{
				}
				else 
				{
					bossid = NPC_WhoIsBoss( n );
					if( bossid != -1 )	// Yes.. 焊胶甫 茫疽绢!!
					{	
						if( bossid != n->id )	// 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙.. 
						{
							n->bossid = bossid;
							n->patterntype = NPC_PATTERN_TOBOSS_8_;
							n->targetid = -1;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
							SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1 );

							break;
						}
						else  // 郴啊 Boss捞促. 
						{
							n->bossid = bossid;
							n->patterntype = NPC_PATTERN_IAM_BOSS_8_;
							n->targetid = -1;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
							SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1 );

							break;
						}
					}
					else	// 雷. 焊胶啊 绝绢...
					{
						int dir;
						int how;
						int tx, ty;

						dir = Random(8);
						how = Random(4)+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_MakePathBumn( n, tx, ty, how );
					}
				}
			}
		}
		break;



	case NPC_PATTERN_IAM_BOSS_8_ :
		{
			int bossid;


			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1000  + (rand()%500);
				if( NPC_IsMoving( n ) )
				{
				}
				else 
				{
					int attacker = NPC_WhoIsAttackMyBaby( n );
					if( attacker != -1) // 郴 酒啊甸吝 嘎绰局啊 乐栏搁..
					{
						
						LPCHARACTER tch = Hero;
						while( tch )
						{
							if( tch != n && !IsDead( tch ) && tch->type == SPRITETYPE_MONSTER )
							{

								if( tch->bossid == n->bossid  )
								{
									tch->targetid			= attacker;
									tch->patterntype	= NPC_PATTERN_ATTACK_PC_8_;
								}
							}
							tch = tch->lpNext;
						}
					}
					else
					{
					}


					bossid = NPC_WhoIsBoss( n );
					if( bossid == -1 )	 // 唱去磊焙..
					{	
						n->patterntype	= NPC_PATTERN_WANDER_8_;

						n->targetid		= -1;
						n->bossid		= -1;
						SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, -1 );
						SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1 );

						break;
					}
					else if( bossid != n->id )	// dld澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙.. 
					{
							n->bossid		= bossid;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
							n->patterntype	= NPC_PATTERN_TOBOSS_8_;

							break;
					}
					else  // 开浆 郴啊 Boss促 !  弊烦 焊胶狼 老阑 秦具瘤.
					{
						n->bossid = bossid;
						n->targetid = NPC_IsWhoNearPC( n, 10 );

						SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
						SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );


						if( n->targetid != -1 )
						{
							LPCHARACTER tch = ReturnCharacterPoint( n->targetid );

							if( InDistance( n, tch,  TILE_SIZE * 10 ) )	// 弊 PC啊  5 鸥老救俊 乐促搁.
							{	
								LPCHARACTER tch = Hero;
								while( tch )
								{
									if( tch != n && !IsDead( n ) && tch->type == SPRITETYPE_MONSTER )
									{
										if( tch->bossid == n->bossid  )
										{
											tch->targetid    = n->targetid;
											tch->patterntype = NPC_PATTERN_ACCESS_PC_8_;
										}
									}
									tch = tch->lpNext;
								}
								break;
							}
							else if( InDistance( n, ReturnCharacterPoint( n->targetid),  TILE_SIZE * 15 ) )	// 弊 PC啊  10 鸥老救俊 乐促搁.
							{				
								LPCHARACTER tch = Hero;
								while( tch )
								{			
									if( tch != n && !IsDead( n ) && tch->type == SPRITETYPE_MONSTER )
									{		
										if( tch->bossid == n->id  )
										{	
											int ex, ey;
											ex = n->x/TILE_SIZE, ey = n->y/TILE_SIZE;
											//LPCHARACTER targetch = ReturnCharacterPoint( n->id );
											NPC_NearCh( n, tch, &ex, &ey );
											tch->targetid = n->targetid;
											tch->patterntype = NPC_PATTERN_TOBOSS_8_;
											n->MoveP = 60 + Random(80 );
											NPC_MakePath( n, ex, ey, Random(6) + 2 );
										}	
									}		
									tch = tch->lpNext;
								}			
							}				
							else
							{
								if( Random(5) == 0 )
								{// 焊胶瘤父 距埃究 巩流牢促. 
									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_MakePathBumn( n, tx, ty, how );
								}

								// 澜.. 酒穿巴档 窍瘤臼绰促. 
							}
						}
						else	// 促矫 焊胶俊霸肺 葛捞扼绊 茄促. 
						{
						}
					}
				}
			}
		}
		break;

	case NPC_PATTERN_TOBOSS_8_ :
		{
			int ex, ey;
			int bossid;

			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1500  + (rand()%500);

				if( NPC_IsMoving( n ) )
				{

				}
				else 
				{
					if( NPC_IsInBossRange( n ) )	// Boss救俊 甸绢吭栏搁..
					{
						bossid = NPC_WhoIsBoss( n );
						if( bossid != -1 )	
						{	
							if( bossid != n->id )	// 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙.. 
							{
								n->bossid = bossid;
								n->patterntype = NPC_PATTERN_TOBOSS_8_;
								SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
		


								goto TO_BOSS_;
							}
							else  // 郴啊 Boss捞促. 
							{
								n->bossid = bossid;
								n->patterntype = NPC_PATTERN_IAM_BOSS_8_;
								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_8_;

							n->targetid = -1;
							n->bossid = -1;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
							SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );

							break;
						}
					}
					else //  Boss扮栏肺 啊具瘤...
					{
TO_BOSS_:
						if( n->bossid != -1 )
						{
							LPCHARACTER tempch = ReturnCharacterPoint( n->bossid );
							if( tempch )
							{
								if( NPC_NearPosition( n, tempch, &ex, &ey ))
								{
									NPC_MakePath( n, ex, ey, Random(6) + 2 );
										break;
								}
							}
							else
							{
								n->patterntype = NPC_PATTERN_WANDER_8_;
								n->bossid = -1;
								n->targetid = -1;
								SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
								SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );
							}
						}
						else
						{

							int targetid = NPC_IsWhoNearPC( n, 10 );
							if( targetid != -1 )
							{
								if (n->bossid != -1 )
								{
									LPCHARACTER tch = Hero;

									while( tch )
									{
										if( !IsDead( tch ) && tch->type ==SPRITETYPE_MONSTER )
										{
											if( tch->bossid == n->bossid )
											{
												tch->targetid	= targetid;
												tch->patterntype= NPC_PATTERN_ATTACK_PC_8_;
											}
										}
									}
									tch = tch->lpNext;
								}
								else 
								{
									n->patterntype = NPC_PATTERN_WANDER_8_;
									n->bossid = -1;
									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_8_;
									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;
			
		//	公府瘤绢促囱促... 8
		case NPC_PATTERN_MURI_8_ :
		{	
			int bossid = -1;
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = 1000  + (rand()%500);

				if( NPC_IsMoving( n ) )
				{
				}
				else
				{
					bossid = NPC_WhoIsBoss( n ); // 去磊扼绰 娟扁.
					if( bossid != -1 )	
					{	
						if( bossid != n->id )	// 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙.. 
						{
							n->bossid = bossid;
							SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, n->bossid);
							n->patterntype = NPC_PATTERN_TOBOSS_8_;

						}
						else  // 郴啊 Boss捞促. 
						{
							n->bossid = bossid;
							n->patterntype = NPC_PATTERN_IAM_BOSS_8_;
							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_8_;

						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_8_ :
			{			
			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_8_;
								break;
							}
						}
					}	
					else
					{	
						LPCHARACTER tch = ReturnCharacterPoint( n->targetid );
						if( tch )
						if( !IsDead( tch ) )
						{
							if( NPC_IsAttackableRange( n ) )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
							{
								SendNPCAttack( n->id );
								n->attackcount ++;
								n->patterntype = NPC_PATTERN_ATTACK_PC_8_;
								break;
							}
							else	// 傍拜啊瓷茄 芭府啊 酒聪搁 辟贸鳖瘤 埃促. 
							{
								int ex,ey;
								LPCHARACTER tch = ReturnCharacterPoint( n->targetid );
								if( NPC_NearCh( n, tch, &ex, &ey ) )
								{
									n->MoveP = 60 + Random(30 );
									NPC_MakePath( n, ex, ey, Random(6) + 2 );
								}
								else
								{
//									n->patterntype = NPC_PATTERN_WANDER_8_;

//									n->bossid = -1;
//									n->id = -1;
								}
							}
						}	
						else 
						{
							n->patterntype = NPC_PATTERN_TOBOSS_8_;

							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_8_ :
			if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch ) 
			{	
				n->aitimedelay = g_ClientTime;
				n->aidelayhowmuch = ATTACKACCESS(n)  + (rand()%200);
				
				if( NPC_IsMoving(n))	
				{		
					LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
					if( tempch )
					if( !IsDead( tempch ) )
					if( NPC_IsAttackableRange( n ) )	// 捞悼 档吝 傍拜措惑某腐甫 傍拜且荐 乐促搁 傍拜茄促. 
					{
						goto ATTACK_8_NEXT__;

⌨️ 快捷键说明

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