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

📄 skill.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	{	
		if(iTryRare/10)
		{
			ItemMgr.MakeRareAttr(iAttr3,1,RareType,0,0,0,true);	
		}
		else
		{
			ItemMgr.MakeRareAttr(iAttr3,1,RareType,0,0,0,false);	
		}
	}

	if(sp->s.p1)
	{
		if(!RareType)
		{
			SendSkillResultFail( cn, skillno );
	 		return;
		}
	}

	for ( int iResultCount = 0 ; iResultCount< SuccessMuch; iResultCount++ ) 			
	{	// 扁贱狼 搬苞拱阑 积己矫挪促. 

		CItem *ii = ItemUnit( target_id );
		if( !ii ){return;}
		int iAmount = 0;
		if( ii->GetRbutton() == DIVIDE_ITEM )
		{	iAmount  = 1;	}
		else 
		{	iAmount = join.item_amount;	}

		for(int c = 0; c< iAmount;c++)
		{
			item = GenerateItem( target_id );//010618 lsw

			//011013 lsw <
			if(iAttr3)
			{
				ItemAttr *inv = SearchInv(ch);
				item.attr[IATTR_RARE_MAIN] = iAttr3;
				if(ii->GetRbutton() == DIVIDE_ITEM )
				{//酒捞袍 肺弊 巢扁扁 
					Send_RareItemMakeLog( cn, join.item_id, 
					((t_skillexp2*)&ch->skillexp[SkillTbl[skillno].MotherSkillType-14])->makecount
					,1, RareType,0,0,0,0,0,0,item.attr[IATTR_LIMIT],
					item.attr[IATTR_DURATION],0,100);
				}
				else
				{
					Send_RareItemMakeLog( cn, join.item_id, 
					((t_skillexp2*)&ch->skillexp[SkillTbl[skillno].MotherSkillType-14])->makecount
					,1, RareType,0,0,0,0,0,0,item.attr[IATTR_LIMIT],
					LOWORD(item.attr[IATTR_DURATION]),HIWORD(item.attr[IATTR_DURATION]),100);
				}
				
				if(inv)//牢亥配府啊 厚菌栏搁 
				{
					*inv = item;
					SendItemEventLog( inv, cn, SN_NOT_USER, SILT_MAKE_BY_SKILL, 1 ); //YGI acer
					SendServerEachItem( inv,ch);
					OutMessage(cn,2,524);
					continue;//酒捞袍阑 持绢 玲栏聪 官蹿俊绰 酒捞袍阑 冻绢哆府瘤 臼绰促 
				}
			}
			SendItemEventLog( &item, cn, SN_NOT_USER, SILT_MAKE_TO_GROUND_BY_SKILL, 1 ); //YGI acer	// 蝶肺 肺弊 鸥涝阑 沥狼茄促.
			DropItem(	ch->X + (rand()%100) - 50, ch->Y + (rand()%100) - 50, &item);
		}
	}

	if(SuccessMuch)//己傍 肮荐 绝栏搁 救焊晨//020603 lsw
	{
		p.h.header.type = CMD_SKILL_ITEMMAKE_RESULT;
		{
			p.u.server_skill_itemmake_result.skillno = skillno;
			p.u.server_skill_itemmake_result.item = item;
			p.u.server_skill_itemmake_result.MakeItemCount  = SuccessMuch;
			p.u.server_skill_itemmake_result.TryItemCount	= iTryMakeCount;
		}							
		p.h.header.size = sizeof( t_server_skill_itemmake_result );
		QueuePacket( connections, cn, &p, 1);	
	}	
}
lpMAPSKILLTABLE	skill_ReturnProbablityFromSkillTable( int *probablity,  int skillno, int x, int y )
{			
			
	lpMAPSKILLTABLE	 s;
	int range = 0;	
	int pro;		
	int dx, dy;		
			
	x = x / TILE_SIZE;
	y = y / TILE_SIZE;
			
	dx = (g_Map.file.wWidth +7 ) / 8;
	dy = (g_Map.file.wHeight+7 ) / 8;
			
	dx = x / dx;	
	dy = y / dy;	
			
//	for( i = 0 ; i < 8 ; i ++ )
	{				
//		for( j = 0 ; j < 8 ; j ++ )
		{			
			s = g_Header[dx][dy];
					
			while( s != NULL )
			{		
				if( s->skillno == skillno )
				{	
					range = s->tile_Range +1;
					if( s->x == x && s->y == y ) 
					{
						*probablity = s->probability;
						return s;
					}
					else if( BoxAndDotCrash( s->x - range, s->y - range, range*2, range*2, x, y ) )
					{
						pro =  abs(range - abs(s->x-x));
						pro = s->probability * pro / range;
						*probablity = pro;
						return s;
					}
				}	
				s = s->next;
			}		
		}			
	}				
	return NULL;	
}					
void SendSkillGauge(const int cn, int skillno, int x, int y )
{
	t_packet p;
	lpMAPSKILLTABLE	 ms; 
	int probablity;
	t_earthpower *ep = &EarthPower;

	switch(skillno )
	{
			// Reclain..
		case 21 : 
			// mining
		case 26 : 
			// cutting
		case 32 : 
			// digging..
		case 36 : 
			// Tamming..
		case 75 :	
		case 28:	//fish
		case 30:	//netting

			break;

		default : return;
	}

	p.h.header.type = CMD_SKILL_GAUGE;
	p.h.header.size = sizeof( t_server_skill_gauge );
				
	p.u.server_skill_gauge.skillno =  skillno;
	p.u.server_skill_gauge.x		= x;
	p.u.server_skill_gauge.y		= y;

	
	//	mining/cutting俊 10栏肺 唱传捞蜡绰 蔼捞 焊烹 0 - 1000狼 蔼捞绊 霸捞瘤狼 钎泅裹困绰 1/100捞扁 锭巩..
	switch( skillno )
	{				
		// 俺埃...	
	case 21 :	ms = skill_ReturnProbablityFromSkillTable( &probablity,  TOOL_FARMING, x, y );
				if( ms )
				{	

					p.u.server_skill_gauge.min = ep->reclaim[ ms->type_Num ]/100;
					QueuePacket( connections, cn, &p, 1 );
				}
		break;
		// mining
	case 26 :	ms = skill_ReturnProbablityFromSkillTable( &probablity,  TOOL_MINING, x, y );
				if( ms )
				{
					
					p.u.server_skill_gauge.min = ep->mining[ ms->type_Num ]/10;
					QueuePacket( connections, cn, &p, 1 );
				}
				//1018 zhh
				break;

		// cutting
	case 32 : ms = skill_ReturnProbablityFromSkillTable( &probablity,  TOOL_CHOPPING, x, y );
				if( ms )
				{
					p.u.server_skill_gauge.min = ep->cutting[ ms->type_Num ]/10;
					QueuePacket( connections, cn, &p, 1 );
				}
				//1018 zhh
				break;

		// digging..
	case 36 : ms = skill_ReturnProbablityFromSkillTable( &probablity,  TOOL_HUB, x, y );
				if( ms )
				{
					p.u.server_skill_gauge.min = ep->digging[ ms->type_Num ]/10;
					QueuePacket( connections, cn, &p, 1 );		
				}
				//1018 zhh
				break;

	//1018 zhh
	case 28 :
	case 30 : ms = skill_ReturnProbablityFromSkillTable( &probablity,  TOOL_FISHING, x, y );
				if( ms )
				{
					p.u.server_skill_gauge.min = ep->fishing[ ms->type_Num ]/10;
					QueuePacket( connections, cn, &p, 1 );
				}				
				break;

	}
}
void RecvSkillInfo(const int cn, t_client_skill_info *sp)//020531 lsw 
{
	const int	skillno			= sp->skillno;
	const int	x				= sp->x;
	const int	y				= sp->y;
	const int	targettype		= sp->targettype;
	const int	target_id		= sp->target_id;
	
	char TargetName[31]={0,};
	memcpy(TargetName,sp->TargetName,30);

	int temp	= 0;
	int hitrate = 0;

	const int iTryRare		= sp->s.p1;
	const int iRareGroup	= sp->s.p2;
	int iTryMakeCount	= sp->s.p3;

	// 020428 YGI acer
	if( iTryMakeCount > 10 ) iTryMakeCount = 10;
	
	// acer5		// 阁胶磐 酒捞叼啊 逞绢 坷搁 绢痘霸 登扼绊
	CHARLIST *ch= CheckServerId(cn);
	if( !ch )					{return;}
	if( ch->cur_skillno )		{return;} // 泅犁 矫傈吝牢 扁贱捞 乐促搁 罐瘤 臼绰促. 
	if( ch->bAlive != ALIVE_ )	{return;}

	SaveBallancingSkill( ch, skillno );
		
	if( !ch->Hungry ) 
	{
		SendSkillResultFail( cn, skillno, ITEMMAKE_TIRED ); 
		return;
	}

	if(  timeGetTime() > ch->dwSkillTime)
	{
		ch->dwSkillTime = timeGetTime()+2000;
	}
	else
	{
		return;
	}

	//	郴啊 啊柳 扁贱捞 嘎促搁 逞绢啊绊 酒聪搁 府畔茄促.
	if(!SkillMgr.CheckIsYourSkill( ch, skillno )) 
	{
//		MyLog(LOG_NORMAL,"RecvSkillInfo() Recved Error SKillNo\n");
//		MyLog(LOG_NORMAL,"Name : %s Skill NO : %d\n",ch->Name, skillno);
		return;
	}
	HungryMuchAdd( ch , HT_SKILL );
	
	switch( sp->targettype )// 角菩啊 酒聪扼 肋给等 Data甫	吧矾辰促. 
	{		
	case SKILLTARGETTYPE_MAP_ :	
		{
			if( x < 0 ) goto FAIL_;
			if( y < 0 ) goto FAIL_;
			if( x / TILE_SIZE >= g_Map.file.wWidth )	goto FAIL_;
			if( y / TILE_SIZE >= g_Map.file.wHeight )	goto FAIL_;
		//	DecreaseEquipDuration(ch,rand()%6+1,WT_WEAPON,0,true);//020720 lsw
		}
		break;										
	case SKILLTARGETTYPE_TABLE_ :	//剧檬 父甸扁唱 捍父甸扁甫 困茄 何盒
		{
			if( target_id/1000 < 0 || target_id/1000 >ETC ) goto FAIL_;
		}
		break;
														
	case SKILLTARGETTYPE_ITEM_ :	//鸥百捞 酒捞袍牢巴
		{
			if( target_id < 0 || target_id >= MAX_ITEM_LIST ) goto FAIL_;
			if( ItemList[ target_id].bAlive == REMOVE_ ) goto FAIL_;

			temp = ItemList[ target_id].item_no;
			// 趣矫 扁贱阑 荤侩且荐 乐绰 Item寇狼 锅龋啊 坷绰巴阑 阜绰促.
			if( temp / 1000 < 0 || temp /1000 > 10 ) goto FAIL_;
		}
		break;
			     
	case SKILLTARGETTYPE_CHAR_ :	
		{
			if( target_id >= 10000 )	
			{
				if( target_id -10000 < NPC_LIST_START || target_id -10000 >= MAX_NPC_LIST ) goto FAIL_;
			}
			else
			{
				if( target_id < DRAGON_CONNECTIONS_START || target_id >= DRAGON_MAX_CONNECTIONS ) goto FAIL_;
			}
			
			CHARLIST *targetch = CheckServerId(target_id);
			if(targetch)
			{
				if(strcmp(TargetName,targetch->Name))//捞抚捞 促福促搁//020531 lsw
				{
					goto FAIL_;
				}
			}
		}
		break;
	}	
	
	hitrate = ReturnSkillProbablityNoExpAdd( cn, skillno, x, y, targettype, target_id );

	switch( targettype )
	{												
		case SKILLTARGETTYPE_TABLE_ : //SkillTargetTypeItemMake
			{
				SkillTargetTypeItemMake( cn, sp);
			}
			break;
			
		default : 
		{	
			t_packet p;
			p.h.header.type = CMD_SKILL_INFO;
			{
				p.u.server_skill_info.server_id = cn;
				p.u.server_skill_info.skillno	= skillno;
				p.u.server_skill_info.x			= x;
				p.u.server_skill_info.y			= y;
				p.u.server_skill_info.targettype= targettype;
				p.u.server_skill_info.target_id = target_id;
			}
						
			p.h.header.size = sizeof( t_server_skill_info );
			CastMe2Other( cn, &p );	
			QueuePacket( connections, cn, &p, 1);
		}			
				
		// 秦寸窍绰 扁贱老版快 努扼捞攫飘俊辑 霸捞瘤甫 免仿窍霸 茄促. 
		SendSkillGauge( cn, skillno, x, y );
		// Pre Check....//恐 刚历 眉农 窍绰单??
		switch( skillno )
		{	// MakeFire
			case  SKILL_MAKEFIRE :	
				{
					if( skill_Makefire_preCheck	( cn, skillno, x, y, targettype, target_id ) == 0 )	return;
				}break;
		}	
					
		ch->cur_skillno				= sp->skillno;				
		ch->cur_skillx				= sp->x;					
		ch->cur_skilly				= sp->y;							
		ch->cur_skilltargettype		= sp->targettype;				
		ch->cur_skilltarget_id		= sp->target_id;
		ch->cur_skillKey			= sp->iKey;//030102 lsw
		ch->cur_skillPOS			= sp->s;
		//020531 lsw		>
		memcpy(ch->cur_skillTargetName	,sp->TargetName,30);
		ch->cur_skillTargetName[30] = 0;//strcmp且锭 NtDll俊辑 欢唱绰芭 抗规
		//020531 lsw		<
		ch->exetime_skill			= g_curr_time + SkillTbl[ skillno].Time_judge / 10;
		break;						
	}
	return;
FAIL_:	
	SendSkillResultFail( cn, skillno );		
	return ;
}		

void ReduceTame()		//老沥 矫埃捞 儒福搁 tame阑 憋绰促.void CheckNPCTammingTimeElapsed( CHARLIST *ch )阑 汗荤秦辑 荤侩.
{	
	static int min;				
	
	if( g_curr_time - min > 900 )
	{		
		min = g_curr_time;
		for(int i = NPC_LIST_START ; i < MAX_NPC_LIST; i ++)
		{	
			if( NPCList[i].bAlive == ALIVE_ )
			if( NPCList[i].tame > 0 )
			{					
				CHARLIST *n = &NPCList[i];

				if (n->IsTamedNpc() == true)
				{	
					n->tame -= NPC_Gen_Ref[n->SprNo].ValueSP * 15;
					if(n->tame<0)	n->tame=0;
				}	
				else
				{	
					n->tame -= (NPC_Gen_Ref[n->SprNo].ValueHP * 15);
					if(n->tame<0)	n->tame=0;
				}				
								
				if (n->IsTamedNpc() && n->tame <= NPC_Gen_Ref[n->SprNo].Taming_min)
				{				
					n->SetTamed(false);		// LTS TAME
					n->HostName[0] = 0;
					n->tame_cmd = LC_TAME_STOP;
					n->patterntype = n->oldpatterntype;
								
					t_packet p;	
					p.h.header.type= CMD_TAME_END;
					p.u.tame_end.id = n->GetServerID() + 10000;
					p.h.header.size = sizeof( t_tame_host_name );
					CastNPC2Other( n->GetServerID(), &p );
								
					SendNPC_Parameter( n->GetServerID(), NPC_PARAMETER_TAME_CMD,	n->tame_cmd );

⌨️ 快捷键说明

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