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

📄 op_battle.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	else
	{
		strcpy(d->KillerName, a->Name);
	}
	
	switch (NPC_Gen_Ref[d->SprNo].nNpcRace)
	{	//< CSD-031013					
	case HUMAN:
		{
			if (a->name_status.nation == d->name_status.nation)
			{	
				++a->killpc;
				SendServerKillPc(a->GetServerID());
			}

			break;	
		}
	case ANIMAL:
		{
			++a->killanimal;
			break;		
		}
	case NORM_MON:
		{
			if (a->SprType  != SPRITETYPE_NPC)
			{
				++a->killmon;
				SendServerKillMon(a->GetServerID()); //0209 YGI
			}
			
			break;		
		}
	}	//> CSD-031013
	// 家券阁捞 利阑 傍拜茄 饶 惑措规阑 磷菌促搁 林牢阑 蝶扼皑
	if (a && a->IsSummonMonster() && a->ctrlpc < 10000)
	{ 
		const WORD idMaster = a->GetMaster();
		LPCHARLIST pMaster = GetCharListPtr(idMaster);
		
		if (pMaster != NULL)
		{
			pMaster->SetMaster(idMaster);
			pMaster->m_xSummon.Command(FollowSummon);
		}
	} 
	// 家券阁捞 磷菌促搁 林牢狼 府胶飘俊辑 力芭
	if (d && d->IsSummonMonster())
	{ 
		const WORD idMaster = d->GetMaster();
		LPCHARLIST pMaster = GetCharListPtr(idMaster);
		
		if (pMaster != NULL)
		{
			pMaster->m_xSummon.Decrease(d->GetServerID());
		}
	} 
	
	if( d && d->fight_flag )
	{
		EndManToManFight( a, d );
	}
}								

#define PAI   3.141592

BOOL ChangeDirection( DIRECTION* direction, int sx, int sy, int dx, int dy )
//int ReturnDirection( float tx1, float ty1, float tx2, float ty2 )
{			
	double t;
	
	if( dy == sy && sx == dx ) return 0;
	
	t = atan2( (float)(dy - sy) , (float)(dx - sx) );
	if(    PAI*7/8 < t && t <=  PAI + 1   )	{*direction = DIRECTION_LEFT;		return 1; }
	if(   -PAI -1    <=t && t <= -PAI*7/8 )	{*direction = DIRECTION_LEFT;		return 1; }
	
	if(   -PAI*7/8 < t && t <= -PAI*5/8 )	{*direction = DIRECTION_LEFTUP;		return 1; }
	if(   -PAI*5/8 < t && t <= -PAI*3/8 )	{*direction = DIRECTION_UP;			return 1; }
	if(   -PAI*3/8 < t && t <= -PAI  /8 )	{*direction = DIRECTION_RIGHTUP;	return 1; }
	if(   -PAI  /8 < t && t <=  PAI  /8 )	{*direction = DIRECTION_RIGHT;		return 1; }
	if(    PAI  /8 < t && t <=  PAI*3/8 )	{*direction = DIRECTION_RIGHTDOWN; 	return 1; }
	if(    PAI*3/8 < t && t <=  PAI*5/8 )	{*direction = DIRECTION_DOWN; 		return 1; }
	if(    PAI*5/8 < t && t <=  PAI*7/8 )	{*direction = DIRECTION_LEFTDOWN;	return 1; }
	
	return 0;
}		




///////////////////////// 0525 lkh 荐沥 ///////////////////////////////
bool	YouCanBackdraw( CHARLIST *a, CHARLIST *d, int how )
{		
	DIRECTION dir;
	int x, y;
	int	t_X=0, t_Y=0;
	
	ChangeDirection( &dir, d->MoveSx, d->MoveSy, a->MoveSx, a->MoveSy );
	
	x = d->MoveSx;
	y = d->MoveSy;
	
	switch( dir )
	{	
	case DIRECTION_UP		:				t_Y=how;		break;
	case DIRECTION_RIGHTUP	:	t_X=-how;	t_Y=how;		break;
	case DIRECTION_LEFTUP	:	t_X=how;	t_Y=how;		break;
	case DIRECTION_RIGHT	:	t_X=-how;      				break;
	case DIRECTION_LEFT		:	t_X=how;      				break;	
	case DIRECTION_RIGHTDOWN:	t_X=-how;	t_Y=-how;		break;
	case DIRECTION_LEFTDOWN	:	t_X=how;	t_Y=-how;		break;
	case DIRECTION_DOWN		:				t_Y=-how;		break;
	}	
	x += t_X;
	y += t_Y;
	
	if( FreeTile( d, x, y, x, y ) )			//角力 哎荐 乐绰 瘤痢牢啊?
	{	
		d->MoveLength = d->MovePathCount = 0;
		d->MoveSx	= x;
		d->MoveSy	= y;
		d->X		= x*TILE_SIZE;
		d->Y		= y*TILE_SIZE;
		d->Tox		= t_X;
		d->Toy		= t_Y;
		
		if( d->SprType == SPRITETYPE_NPC )
		{
			SetArea( MOVE_NPC_AREA, d->GetServerID());
		}
		else
		{
			SetArea( MOVE_PC_AREA, d->GetServerID());
		}
		
		return true;
	}	
	
	d->Tox = 0;
	d->Toy = 0;
	return false;
}

inline int IsNKNation(LPCHARLIST ch)
{		
	switch (MapInfo[MapNumber].nation)
	{	
	case N_VYSEUS:
	case N_YILSE:
	case N_ZYPERN:
		{
			return MapInfo[ MapNumber].nation;
		}
	default:
		{
			switch( ch->name_status.nation )
			{
			case N_VYSEUS:
			case N_YILSE:
			case N_ZYPERN:
				{
					return ch->name_status.nation;
				}
			}

			break;
		}
	}	
	
	return 0;
}		

inline int IsHeNK( LPCHARLIST ch, int nation )
{	// 泅犁 甘俊 措秦辑 PK荐摹啊 乐促.
	switch (nation)
	{
	case N_VYSEUS:
	case N_ZYPERN:
	case N_YILSE:
		{
			return ch->nk[ nation];
		} 
	}

	return 0;
}	

void CheckElapsedTime_NK_Down( void )
{	//< CSD-CN-031213
	static DWORD time = 0;
	
	if( g_curr_time - time > 1000  )
	{
		time = g_curr_time;
	}	
	else 
	{
		return;
	}	

	CUserManager::HASH_USER mpUser = g_pUserManager->GetUserSet();

	for (CUserManager::ITOR_USER i = mpUser.begin(); i != mpUser.end(); ++i)
	{
		const int idUser = i->second;
		CHARLIST* pUser = CheckServerId(idUser);
		
		if (pUser != NULL)
		{
			if (pUser->nk[N_VYSEUS] > 0)
			{
				InNK(pUser, N_VYSEUS, -1);
			}

			if (pUser->nk[N_ZYPERN] > 0)
			{
				InNK(pUser, N_ZYPERN, -1);
			}

			if (pUser->nk[N_YILSE ] > 0)
			{
				InNK(pUser, N_YILSE , -1);
			}
		}
	}
}	//> CSD-CN-031213

#define MAX_NK_		30000
#define MAX_ULTRA_NK_	100
#define PK_START_LIMIT_		5
static int nCaseOfNK[3][3] = {{0,1,1},{ 4,3,3},{4,2,2}};

inline int OutNK( LPCHARLIST ch, int nation )
{	
	switch( nation )
	{
	case N_VYSEUS :	
	case N_ZYPERN : 
	case N_YILSE :  return ch->nk[ nation];  
		
	default : return ch->nk[ ch->name_status.nation ];	
	}

	return 0;
}	

void InNK( LPCHARLIST ch, int nation, short int add_nk )
{	
	if( add_nk == 0 ) return;
	if( ch->SprType == SPRITETYPE_NPC ) return;
	
	short int oldnk;
	short int *ch_nk;
	switch( nation )
	{
	case N_VYSEUS	:
	case N_ZYPERN	:
	case N_YILSE	:   oldnk = ch->nk[ nation];
		ch_nk = &ch->nk[ nation];  break;
	default			:  return;
	}
	*ch_nk += add_nk;
	
	if( *ch_nk > MAX_NK_ ) *ch_nk = MAX_NK_;
	if( *ch_nk < 0       ) *ch_nk = 0;
	
	if( *ch_nk == 0 )
	{
		switch( nation )
		{
		case N_VYSEUS :	ch->name_status.ultra_nk3 = 0;	break;
		case N_ZYPERN : ch->name_status.ultra_nk4 = 0;	break;
		case N_YILSE :  ch->name_status.ultra_nk6 = 0;	break;
		default : return;
		}
	}
	else if( *ch_nk >= MAX_ULTRA_NK_ )
	{
		switch( nation )
		{
		case N_VYSEUS :	ch->name_status.ultra_nk3 = 1;	break;
		case N_ZYPERN : ch->name_status.ultra_nk4 = 1;	break;
		case N_YILSE :  ch->name_status.ultra_nk6 = 1;	break;
		default : return;
		}
	}
	
	SendNK( ch->GetServerID(), ch->nk[ N_VYSEUS], ch->nk[ N_ZYPERN], ch->nk[ N_YILSE] );
}	


// 阿 惫啊啊 背傈惑怕捞搁 true甫 府畔茄促. 
inline bool IsWarfare( int anation, int bnation )
{
	if( anation < 0 || anation >= MAX_NATION )	return false;
	if( bnation < 0 || bnation >= MAX_NATION )	return false;
	
	switch( NationRelationStatus[ anation][ bnation] )
	{
	case NATION_RELATION_ENEMY_	: return true;
	default : return false;
	}
	
	return false;
}


int GetCaseOfNK( int cur_nation, int a_nation, int d_nation, int a_nk, int d_nk ) 
{
	bool warfare;
	int step2flag = 0, step3flag = 0;
	
	warfare = IsWarfare( cur_nation, d_nation );
	
	//step 2
	if( warfare )
	{
		step2flag = 0;
	}
	else if( d_nk )
	{
		step2flag = 2;
	}
	else
	{
		step2flag = 1;
	}
	
	//step3
	warfare = IsWarfare( cur_nation, a_nation );
	
	if( warfare )
	{
		step3flag = 0;
	}
	else if( d_nk )
	{	
		step3flag = 2;
	}	
	else
	{	
		step3flag = 1;
	}	
	
	int tcase = nCaseOfNK[ step2flag][ step3flag];
	
	return tcase;
}

#define NK_TYPE_STEAL_		0
#define NK_TYPE_KILL_		1
#define NK_TYPE_NO_KILL_	2

static int NationNkNum[5][3][3] = 
{	
	{{0, 0, 0},	{ 0, 0, 0},	{0, 0, 0}},
	{{0, 0, 0},	{ 0, -5,10},{0, 0, 0}},
	{{0, 0, 0},	{ 0, 0, 0},	{0, 0, 0}},
	{{0, 5, 5},	{ 0,20,20}, {0, 1, 1}},
	{{0, 0, 0},	{-5, 0,10},	{0, 0, 0}}
};

extern int g_isLocalWarServer;
extern int g_LocalWarBegin;

void CheckNK( int a_id, int d_id, int type )
{	//< CSD-030509
	switch (MapInfo[MapNumber].forrookie)
	{
	case 0:
	case 3: return;
	}

	LPCHARLIST attacker = GetCharListPtr(a_id);
	
	if (attacker == NULL) 
	{
		return;
	}

	LPCHARLIST defender = GetCharListPtr(d_id);

	if (defender == NULL)
	{
		return;
	}
	// 泅惑裹牢 版快
	if (defender->GetWanted()) 
	{
		return;
	}
	// 惫瘤傈牢 版快
	if (g_LocalWarBegin && g_isLocalWarServer)
	{
		if (attacker->JoinLocalWar && defender->JoinLocalWar)
		{	
			return;
		}
	}

	if (g_pArenaManager->IsColossusArena())
	{
		if (attacker->IsJoinArenaGame() && defender->IsJoinArenaGame())
		{
			if (attacker->IsJoinArenaTeam() && defender->IsJoinArenaTeam())
			{
				return;
			}
		}
	}
	
	switch (type)
	{

⌨️ 快捷键说明

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