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

📄 op_chr_status.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	
	packet.h.header.type = CMD_CHR_ITEM_INFO_2;
	{
		memcpy( (unsigned char *)packet.u.chr_item_info2.quick, 
			(unsigned char *)c[ cn].chrlst.quick,	sizeof( ItemAttr ) * 6 );
	}
	packet.h.header.size = sizeof(t_chr_item_info2 );
	QueuePacket( c, cn, &packet, 1);
}

void SendCharInfoMagic( t_connection c[], int cn )
{
	t_packet packet;
	
	packet.h.header.type = CMD_CHAR_INFO_MAGIC;
	{
		if( c[cn].chrlst.Spell == 0 ) // Wizard Spell..
			memcpy( packet.u.char_info_magic.magic, c[ cn].chrlst.Ws, 200 );
		else 
			memcpy( packet.u.char_info_magic.magic, c[ cn].chrlst.Ps, 200 );
	}
	packet.h.header.size = sizeof( t_char_info_magic );
	QueuePacket( c, cn, &packet, 1);
}

void SendCharInfoSkill( t_connection c[], int cn )
{
	t_packet packet;
	
	packet.h.header.type = CMD_CHAR_INFO_SKILL;
	{
		memcpy( packet.u.char_info_skill.skill, c[ cn].chrlst.Skill, 200 );
	}
	packet.h.header.size = sizeof( t_char_info_skill);
	QueuePacket( c, cn, &packet, 1);
}

void SendCharInfotac_skillEXP( t_connection c[], int cn )
{
	t_packet packet;
	CHARLIST *ch = CheckServerId( cn );
	if( !ch ) return;
	
	packet.h.header.type = CMD_CHAR_INFO_TAC_SKILL_EXP;
	{
		memcpy( packet.u.char_info_tac_skillexp.tac_skillEXP, ch->tac_skillEXP, 13 * sizeof( DWORD ) );
		ch->GetStepInfo( packet.u.char_info_tac_skillexp.aStepInfo, 20 );
	}
	packet.h.header.size = sizeof( t_char_info_tac_skillexp );
	QueuePacket( c, cn, &packet, 1);
}

extern void SendCMD_LOCALWAR_STARTUP_STATUS(CHARLIST* ch); // 011215 LTS
// 011101 YGI
void CheckCharacterWhenJoinGame( CHARLIST *ch )
{
	CheckInitSkill( ch );
	InitPartyMemberServerToServer( &connections[ch->GetServerID()].chrlst );
	SendCMD_LOCALWAR_STARTUP_STATUS(ch);				// 011215 LTS
	return;
}

int InitPartyMemberServerToServer( CHARLIST *ch )		//  捞抚父 叼厚俊 历厘窍绊 捞抚父 波郴柯促.		// 0620 YGI
{
	for( int i=0; i<MAX_PARTY_MEMBER; i++ )
	{
		if( *ch->party_str[i] ) 
		{
			strcpy( ch->party[i].Name, ch->party_str[i] );
			ch->party[i].On = true;
		}
	}
	for( i=0; i<3; i++ )
	{
		if( *ch->relation_str[i] )
		{
			strcpy( ch->relation[i].Name, ch->relation_str[i] );
			ch->relation[i].On = true;
		}
	}
	for( i=0; i<6; i++ )
	{
		if( *ch->employment_str[i] )
		{
			strcpy( ch->employment[i].Name, ch->employment_str[i] );
			ch->employment[i].On = true;
		}
	}
	return 1;
}

int EndsetPartyMenberForUpdate( CHARLIST *ch )
{
	for( int i=0; i<MAX_PARTY_MEMBER; i++ )
	{
		strcpy( ch->party_str[i] ,ch->party[i].Name );
	}
	for( i=0; i<3; i++ )
	{
		strcpy( ch->relation_str[i], ch->relation[i].Name );
	}
	for( i=0; i<6; i++ )
	{
		strcpy( ch->employment_str[i], ch->employment[i].Name );
	}
	return 1;
}






//######################## login server 侩 ##########################

void SendItemIndex( t_connection c[], int cn )		// 硅款 酒捞袍 焊郴林扁
{
	CHARLIST *ch = &c[cn].chrlst;
	t_packet packet;
	packet.h.header.type = CMD_ITEM_INDEX;
	{
		memcpy( packet.u.kein.server_item_index.item, ch->Item, c[cn].chrlst.ItemMax  * sizeof( short int ) );
	}
	packet.h.header.size = sizeof(k_server_item_index);
	QueuePacket(c, cn, &packet, 1);
}

void SendEmployment( t_connection c[], int cn )		// employment 焊郴林扁 //1229
{
	return;
}

void SendRelation( t_connection c[], int cn )		// 荤力 包拌焊郴林扁		//1229
{
	return;
}
void SendParty( t_connection c[], int cn )			// 颇萍盔 焊郴林扁	//0213 YGI
{
	CHARLIST *ch = &c[cn].chrlst;
	t_packet packet;
	
	memset( &packet, 0, sizeof( t_packet ) );
	packet.h.header.type = CMD_PARTY;
	{
		for( int i=0; i<MAX_PARTY_MEMBER; i++ )
		{
			if( ch->party[i].On ) 
			{
				packet.u.kein.server_party.Level[i]	= ch->party[i].Level;
				packet.u.kein.server_party.Gender[i]= ch->party[i].Gender;
				packet.u.kein.server_party.Face[i]	= ch->party[i].Face;
				packet.u.kein.server_party.Str[i]	= ch->party[i].Str;
				packet.u.kein.server_party.Class[i]	= ch->party[i].Class;
				memcpy( packet.u.kein.server_party.name[i], ch->party[i].Name, sizeof( char ) *31 );
			}
		}
	}
	packet.h.header.size = sizeof(k_server_party );
	QueuePacket(c, cn, &packet, 1);
}



//011012 lsw >
void makemyjobexpsetting( int skillno , CHARLIST *ch )
{
	int kind = SkillTbl[skillno].MotherSkillType;
	if( ch->skillexp[kind].skillexp < 50000 ) ch->skillexp[kind].skillexp = 50000;
}
//011012 lsw <


/// 0212 YGI
int SetMySkill( CHARLIST *ch )		// 老窜 扁夯利栏肺 舅酒具窍绰 胶懦 悸
{
	int i;
	switch( ch->Class ) 
	{
	case WARRIOR :	for(  i=0; i<MAX_SKILLMAIN;i++ )	
						if( SkillTbl[i].Class_Warrior == 1 )
							ch->Skill[i] = 1;
						break;
	case THIEF :	for(  i=0; i<MAX_SKILLMAIN;i++ )
						if( SkillTbl[i].Class_Thief == 1 )
							ch->Skill[i] = 1;
						break;
	case ARCHER :	for(  i=0; i<MAX_SKILLMAIN;i++ )
						if( SkillTbl[i].Class_Archery == 1 )
							ch->Skill[i] = 1;
						break;
	case WIZARD :	for(  i=0; i<MAX_SKILLMAIN;i++ )
						if( SkillTbl[i].Class_Wizard == 1 )
							ch->Skill[i] = 1;
						break;
	case PRIEST :	for(  i=0; i<MAX_SKILLMAIN;i++ )
						if( SkillTbl[i].Class_Priest == 1 )
							ch->Skill[i] = 1;
						break;
	}
	
	switch( ch->Job )
	{
	case J_FAMER		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Farmer		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_MINNER		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_miner		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_FISHER		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_fisher		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_LUMBERJACK	:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Lumberjack	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_BUTCHER		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Butcher		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_HERB_DIGGER	:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Herbdigger	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_HERDSMAN		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_herdman		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_CARPENTER	:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Carpenter	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_BLACKSMITH	:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Blacksmith	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_COOKER		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Cooking		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_TAILOR		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Tailoring	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_BOWCRAFT		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Bowcraft_Fletcher == 1 ){ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_ALCHEMIST	:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Alchemy		== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_CANDLEMAKER	:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Candlemaker	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	case J_MERCHANT		:	for(  i=0; i<MAX_SKILLMAIN;i++ ) if( SkillTbl[i].Select_Merchant	== 1 )		{ ch->Skill[i] = 1; makemyjobexpsetting( i, ch ); }break;
	}
	return 1;
}

// 0224 YGI
void SendCreateAbility( short int cn )
{
	CHARLIST *ch = &connections[cn].chrlst;
	if( !ch ) return;
	
	t_packet p;
	p.h.header.type = CMD_CREATE_ABILITY;
	{
	/*
	for( int i=STR; i<= LUCK; i++ )
	{
	plus[i] = rand() % 4;
	}
	p.u.kein.start_create_ability.str  = plus[STR];
	p.u.kein.start_create_ability.dex  = plus[DEX];
	p.u.kein.start_create_ability.con  = plus[CON];
	p.u.kein.start_create_ability.wis  = plus[WIS];
	p.u.kein.start_create_ability.inte = plus[INT_];
	p.u.kein.start_create_ability.cha  = plus[CHA];
	p.u.kein.start_create_ability.movp = plus[MOVP];
	p.u.kein.start_create_ability.endu = plus[ENDU];
	p.u.kein.start_create_ability.mor  = plus[MOR];
	p.u.kein.start_create_ability.wsps = plus[WSPS];
	p.u.kein.start_create_ability.luck = plus[LUCK];
		*/
	}
	p.h.header.size = 0  ;
	QueuePacket(connections, cn, &p, 1);
}




// 0410
int GetDiceAbility( int DiceNumber )		// 促捞胶 倒府扁
{
	int dice_count, dice_max;
	dice_count = DiceNumber / 1000;
	dice_max = DiceNumber % 1000;
	
	int ret = 0;
	for( int i=0; i<dice_count ; i++ )
	{
		ret += rand()%dice_max + 1;
	}
	return ret;
}

// 0410 YGI
void SendThrowDice( char type, short int cn )
{
	if( type < 0 || type > 5 ) return;
	
	CHARLIST *ch = &connections[cn].chrlst;
	if( !ch ) return;
	
	ch->Class = type;
	int nAbility[LUCK+1] = {0,};
	
	int num_to_rate[2] = { 1003, 1002 };
	int	class_ability[5][5] = { 
								{ STR,	CON }, 
								{ DEX,	MOVP},
								{ DEX,	CON },
								{ INT_,	WSPS},
								{ WIS,	WSPS} 
	};
	
	for( int i=0; i<2; i++ )
	{
		int ability = GetDiceAbility( num_to_rate[i] );		
		nAbility[ class_ability[ch->Class][i] ] = ability;
	}
	
	t_packet p;
	memset(&p, 0, sizeof(t_packet));
	p.h.header.type = CMD_THROW_DICE;
	{
		p.u.kein.start_throw_dice.ability1 = nAbility[ class_ability[ch->Class][0] ];
		p.u.kein.start_throw_dice.ability2 = nAbility[ class_ability[ch->Class][1] ];
	}
	p.h.header.size = sizeof( k_start_throw_dice );
	QueuePacket(connections, cn, &p, 1);
	
	
	int basic_ability[5][11] = 
	{
		{ 50, 10, 30, 10, 10, 10, 10, 10, 10, 10, 10 },
		{ 10, 40, 20, 10, 10, 10, 20, 10, 10, 10, 20 },
		{ 10, 50, 20, 10, 10, 10, 20, 10, 10, 10, 10 },
		{ 10, 10, 15, 10, 40, 10, 10, 20, 10, 25, 10 },
		{ 10, 10, 20, 35, 10, 10, 10, 20, 10, 25, 10 },
	};
	
	ch->Str		= basic_ability[type][STR];			// 0229 YGI
	ch->Con		= basic_ability[type][CON];
	ch->Dex		= basic_ability[type][DEX];
	ch->Wis		= basic_ability[type][WIS];
	ch->Int		= basic_ability[type][INT_];
	ch->MoveP	= basic_ability[type][MOVP];
	ch->Char	= basic_ability[type][CHA];
	ch->Endu	= basic_ability[type][ENDU];
	ch->Moral	= basic_ability[type][MOR];
	ch->Luck	= basic_ability[type][LUCK];
	ch->wsps	= basic_ability[type][WSPS];
	
	ch->Str		+= nAbility[STR];			// 0229 YGI
	ch->Con		+= nAbility[CON];
	ch->Dex		+= nAbility[DEX];
	ch->Wis		+= nAbility[WIS];
	ch->Int		+= nAbility[INT_];
	ch->MoveP	+= nAbility[MOVP];
	ch->Char	+= nAbility[CHA];
	ch->Endu	+= nAbility[ENDU];
	ch->Moral	+= nAbility[MOR];
	ch->Luck	+= nAbility[LUCK];
	ch->wsps	+= nAbility[WSPS];
}

///////////////////////////////////////////////////////////////////////////////
//		
//		矫埃俊 狼茄 某腐磐狼 硅绊悄 荐摹 临捞扁	//###1213_2 荐沥
//		
///////////////////////////////////////////////////////////////////////////////
void HungryMuchAdd( CHARLIST *ch, const int iType)//020214 lsw
{		
	double iValue	= 0	;		
	if( ch->bAlive != ALIVE_ ) //磷菌扁 锭巩俊
	{
		ch->Hungry = 0;	
		return;
	}	
	
	switch(iType)
	{
	case HT_NORMAL:      iValue = HT_NORMAL_CHANGE_VALUE;      break;
	case HT_WALK:        iValue = HT_WALK_CHANGE_VALUE;        break;			
	case HT_RUN:         iValue = HT_RUN_CHANGE_VALUE;         break;
	case HT_BATTLE_WALK: iValue = HT_BATTLE_WALK_CHANGE_VALUE; break;
	case HT_BATTLE_RUN:	 iValue = HT_BATTLE_RUN_CHANGE_VALUE;	 break;
	case HT_ATTACK:      iValue = HT_ATTACK_CHANGE_VALUE;  		 break;
	case HT_MAGIC:       iValue = HT_MAGIC_CHANGE_VALUE; 		   break;
	case HT_SKILL:       iValue = HT_SKILL_CHANGE_VALUE; 		   break;
	case HT_COMBAT:      iValue = 5; 		                       break;
	default:                 
		{	
			return;
		}break;
	}
	ch->fChangeHungry += (float)iValue;
}

⌨️ 快捷键说明

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