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

📄 op_chr_status.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 2 页
字号:

#include "..\stdafx.h"
#include "DefaultHeader.h"
#include "CItem.h"
#include "Map.h"
#include "OP_Magic.h"
#include "ChrLog.h"
#include "teambattle.h"
#include "ArenaManager.h"

#define NUM_OF_RACE	9
#define NUM_OF_KIND 8

extern NPCLev_to_Exp		NPC_Lev_Ref[] ;
extern NPC_Generation		NPC_Gen_Ref[];	// 010129 KHS
extern CItem_Weapon			CWeapon[] ;
extern inline int IsNKNation( LPCHARLIST ch );
extern inline int IsHeNK(  LPCHARLIST ch , int nation );

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
///		User Functions Declaration...
///

int InitPartyMemberServerToServer( CHARLIST *ch );		//  捞抚父 叼厚俊 历厘窍绊 捞抚父 波郴柯促.
int EndsetPartyMenberForUpdate( CHARLIST *ch );
int SetMySkill( CHARLIST *ch );		// 老窜 扁夯利栏肺 舅酒具窍绰 胶懦 悸



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///
///		User Functions.
///

void SendLevelUpMsgAndPoint( CHARLIST *chr )		// 1217
{
	t_packet p;
	p.h.header.type = CMD_LEVELUP_POINT;
	p.h.header.size = sizeof(t_server_levelup_point);
	p.u.server_levelup_point.idServer = chr->GetServerID();
	p.u.server_levelup_point.nPoint	= chr->GetReservedPoint();
	p.u.server_levelup_point.nLevel = chr->GetLevel(); // CSD-030806
	p.u.server_levelup_point.nLife = chr->Hp;
	chr->GetStepInfo(p.u.server_levelup_point.aStepInfo, sizeof(p.u.server_levelup_point.aStepInfo));
	QueuePacket(connections, chr->GetServerID(), &p, 1);
	CastMe2Other( chr->GetServerID(), &p );
}

void RecvLevelUpPoint(int cn, t_client_levelup_point *p)
{		
	t_packet packet;
	
	CHARLIST *ch = &connections[cn].chrlst;
	int t = 0;
	int i;
	
	for( i = 0 ; i < 11 ; i ++)	t += p->aPoint[i];
	
	if (t == ch->GetReservedPoint())
	{	
		ch->Str		+= p->aPoint[0];				//  塞
		ch->Dex		+= p->aPoint[1];				//  扒碍
		ch->Con		+= p->aPoint[2];				//	刮酶己
		ch->Wis		+= p->aPoint[3];				//	瘤驱
		ch->Int		+= p->aPoint[4];				//	瘤瓷
		ch->Char	+= p->aPoint[5];				//	捞悼仿
		ch->MoveP	+= p->aPoint[6];				//	概仿
		ch->Endu	+= p->aPoint[7];				//  历氢仿
		ch->Moral	+= p->aPoint[8];				//	眉仿
		ch->wsps	+= p->aPoint[9];				//	荤扁
		ch->Luck	+= p->aPoint[10];			  //	青款
		
		packet.h.header.type = CMD_LEVELUP_POINT_OK;
		packet.h.header.size = 0;
		QueuePacket(connections, cn, &packet, 1);
	}													
	else										
	{										
		packet.h.header.type = CMD_LEVELUP_POINT_NO;
		packet.h.header.size = 0;
		QueuePacket(connections, cn, &packet, 1);
	}															
}	

void DropItem(CHARLIST* pTarget)
{	//< CSD-031210
	for (int i = 0; i < 5; i++)
	{	
		const int t1 = rand()%3;
		const int t2 = rand()%3;
		const int t3 = rand()%8;
		ItemAttr* pItem = &pTarget->inv[t1][t2][t3];
		ItemAttr	SaveItem = *pItem;

		if (pItem->item_no)
		{
			POS pos;
			SetItemPos(INV, t1, t2, t3 , &pos);

			if (SendDeleteItem(pItem, &pos, pTarget))
			{	// 020428 YGI acer
				AddItemList(SaveItem.item_no, SaveItem.attr, 0, 
							pTarget->X + (rand()%64) + 16, 
							pTarget->Y + (rand()%64) + 16, 
							0, 0, 0, 0, 0, 0);
				SendItemEventLog(&SaveItem,
								 pTarget->GetServerID(), 
								 SN_NOT_USER, 
								 SILT_DROP_BY_PK, 
								 1);
			}
		}
	}
}	//> CSD-031210

extern bool IsActiveDugeon();

void ExpDown(CHARLIST* pCaster, CHARLIST* pTarget, bool bDrop)
{	//< CSD-030930
	if (g_pArenaManager->IsColossusArena()){return;}
	if (IsActiveDugeon()){return;}
	if (pTarget == NULL){return;}

	if (pTarget->IsPlayer())
	{
		if (pCaster == NULL)
		{	// 傍拜磊啊 绝捞 磷篮 版快
			if (IsHeNK(pTarget, MapInfo[MapNumber].nation))
			{	// NK牢 版快俊 磷菌阑 版快 
				if (bDrop)
				{	
					DropItem(pTarget);
				}

				if (!pTarget->DecExperience(true))
				{
					const int nKind = pTarget->GetTacticsKind() - TACTICS_Crapple;
					pTarget->DecTacticExp(nKind, true);
				}
				
				return;
			}

			pTarget->DecExperience(false);
			return;
		}
		
		if (IsManToManFight(pCaster, pTarget))
		{	
			return;
		}	

		if (IsHeNK(pTarget, MapInfo[MapNumber].nation))
		{	// NK牢 版快俊 磷菌阑 版快 
			if (bDrop)
			{	
				DropItem(pTarget);
			}

			if (!pTarget->DecExperience(true))
			{
				const int nKind = pTarget->GetTacticsKind() - TACTICS_Crapple;
				pTarget->DecTacticExp(nKind, true);
			}

			return;
		}

		if (pCaster->IsNpc() && !pCaster->IsTamedNpc())
		{
			pTarget->DecExperience(false);
			return;	
		}
	}
}	//> CSD-030930

bool isLevelUp(CHARLIST *chr)		
{	//< CSD-020809
	if (chr && chr->LevelUpAbility())
	{
		SendLevelUpMsgAndPoint(chr);
		SendLog2ChrLogDB(connections, chr->GetServerID(), CHR_LOG_LEVELUP_);
		::SaveLevelUp(chr);
		return true;
	}
	
	return false;
}	//> CSD-020809	

//  to俊霸 from狼 Data甫 焊辰促..
void UserAddBasicData( t_connection c[], int from, int to, t_server_user_add *p )
{
	CHARLIST *ch = &c[ from].chrlst;
	
	p->namelen = strlen( ch->Name );
	memcpy(p->name, ch->Name, NM_LENGTH);
	
	p->server_id  = from;
	
	p->spr_no		= ch->SprNo;
	p->spell		= ch->Spell;
	p->face			= ch->Face;
	
	p->body_r		= ch->BodyR>>3;
	p->body_g		= ch->BodyG>>3;
	p->body_b		= ch->BodyB>>3;
	p->cloth_r		= ch->ClothR>>3;
	p->cloth_g		= ch->ClothG>>3;
	p->cloth_b		= ch->ClothB>>3;
	
	p->equip0		= ch->accessory[0];
	p->equip1		= ch->accessory[1];
	p->equip2		= ch->accessory[2];
	p->equip3		= ch->accessory[3];
	p->mantle		= ch->mantle;   // 011018 KHS 噶肚 
	p->jjing        = ((RareMain*)&(ch->equip[ WT_ARMOR].attr[ IATTR_RARE_MAIN]))->grade; // 011030 KHS JJING
	
	p->peacests		= ch->Peacests;
	
	p->bAlive		= ch->bAlive;
	
	p->x			= ch->MoveSx;
	p->y			= ch->MoveSy;
	
	p->viewtype		= ch->viewtype;
	
	p->lv			= ch->GetLevel(); // CSD-030806
	p->class_type	= ch->Class;
	
	// 1014 YGI -----------------------------------
	p->nation		= ch->name_status.nation;
	p->guild_master	= ch->name_status.guild_master;
	p->king			= ch->name_status.king;
	p->guild_code	= ch->GetGuildCode(); // CSD-030324
	p->counselor	= ch->name_status.counselor;
	//---------------------------------------------
	
	p->nk3		= IsHeNK( ch, N_VYSEUS );
	p->nk4		= IsHeNK( ch, N_ZYPERN );
	p->nk6		= IsHeNK( ch, N_YILSE );
	
	p->SquadNo			=	ch->NWCharacter.SquadNo;				// 011019 LTS
	p->isCommander		=	ch->NWCharacter.isCommander;			// 010904 LTS
	p->isSquadLeader	=	ch->NWCharacter.isSquadLeader;			// LTS CHAR
	p->YL_JoinNation	=	ch->NWCharacter.YL_JoinNation;
	
	p->nDualCls = ch->GetDualClass();
	p->nClsStep = ch->GetClassStep();
	p->idWeaponItem = ch->equip[WT_WEAPON].item_no; // CSD-031001
	
	p->reporter = ch->name_status.reporter;
	p->nCurrentAction	=	ch->nCurrentAction;
	p->ChairNum			=	ch->ChairNum; //旧扁 眠饶 富鸥扁 勉眠扁殿..			// LTS SITDOWN BUG
	p->JoinLocalWar		=	ch->JoinLocalWar;						// 011214 LTS
	
	p->HorseNo			=	ch->HorseNo;							// LTS HORSERIDER
	p->RiderNo			=	ch->RiderNo;							// LTS HORSERIDER
	p->HorseGrade		=	ch->HorseGrade;							// LTS HORSERIDER
	p->RiderGrade		=	ch->RiderGrade;							// LTS HORSERIDER
	p->DragonLordWarTeam = ch->DragonLordWarTeam;					// LTS DRAGONLORD
}	

void PutPacketCharDB( t_connection c[], int cn, t_packet *packet )
{	
	CHARLIST *ch = &c[cn].chrlst;
	
	t_server_user_db_data* p = &packet->u.server_user_db_data;
	p->lev = ch->GetLevel(); // CSD-030806
	p->exp = ch->Exp;
	
	p->Attr[0] = ch->Gender;
	p->Attr[1] = ch->Face;
	p->Attr[2] = ch->GetGuildCode(); // CSD-030324
	p->Attr[3] = ch->Class;
	p->Attr[4] = ch->Spell;
	p->Attr[5] = ch->Tactics;
	
	p->Avility[STR]	= ch->Str;		// 1118
	p->Avility[CON]	= ch->Con;
	p->Avility[DEX]	= ch->Dex;
	p->Avility[WIS]	= ch->Wis;
	p->Avility[INT_] = ch->Int;
	p->Avility[MOVP] = ch->MoveP;
	p->Avility[CHA]	= ch->Char;
	p->Avility[ENDU] = ch->Endu;
	p->Avility[MOR]	= ch->Moral;
	p->Avility[LUCK] = ch->Luck;
	p->Avility[WSPS] = ch->wsps;
	
	p->money = ch->Money;
	p->nLife = ch->Hp;
	p->nMaxHp = ch->HpMax;
	p->nMana = ch->Mana;
	p->nMaxMp = ch->ManaMax;
	p->nHungry = ch->Hungry;
	p->nMaxHungry = ch->HungryMax;
	p->condition = ch->GetState();
	p->sprno = ch->SprNo;
	p->x = ch->X;
	p->y = ch->Y;
	
	p->acc_equip1 = ch->accessory[0];
	p->acc_equip2 = ch->accessory[1];
	p->acc_equip3 = ch->accessory[2];
	p->acc_equip4 = ch->accessory[3];
							
	ch->MoveSx = ch->X/TILE_SIZE;
	ch->MoveSy = ch->Y/TILE_SIZE;
	
	memcpy(p->mapname, ch->MapName, 20);

	p->sight = ch->Sight;
	
	p->bodyr = (unsigned char)ch->BodyR;
	p->bodyg = (unsigned char)ch->BodyG;
	p->bodyb = (unsigned char)ch->BodyB;
	
	p->clothr = (unsigned char)ch->ClothR;
	p->clothg = (unsigned char)ch->ClothG;
	p->clothb = (unsigned char)ch->ClothB;
	
	p->Age = (unsigned char)ch->Age;			// 1118	
	p->openhouse = ch->openhouse;
	p->reserved_point = ch->GetReservedPoint();				// 1221
	p->viewtype	= ch->viewtype;
	
	p->social_status = ch->social_status;
	memcpy(&p->nation, &ch->name_status, sizeof(DWORD));	// 1004 YGI
	
	p->fame = ch->fame;
	p->NWCharacter = ch->NWCharacter;					// 011019 LTS
	p->nk3 = IsHeNK(ch, N_VYSEUS);
	p->nk4 = IsHeNK(ch, N_ZYPERN);
	p->nk6 = IsHeNK(ch, N_YILSE);
	ch->GetStepInfo(p->aStepInfo, sizeof(p->aStepInfo));
}	

void SendItemInventory( int count, t_connection c[], int cn )		//1218
{
	int i = count /3;
	int j = count %3;
	
	t_packet packet;
	packet.h.header.type = CMD_CHR_ITEM_INFO_0;
	packet.h.header.size = sizeof(t_chr_item_info0 );
	
	packet.u.chr_item_info0.ar0 = i;
	packet.u.chr_item_info0.ar1 = j;
	memcpy( (unsigned char *)packet.u.chr_item_info0.inv, 
		(unsigned char *)c[ cn].chrlst.inv[i][j],	sizeof( ItemAttr ) * 8 );
	
	QueuePacket( c, cn, &packet, 1);
}

// 8俺..
void SendItemEquip( t_connection c[], int cn )
{
	t_packet packet;
	
	packet.h.header.type = CMD_CHR_ITEM_INFO_1;
	{
		memcpy( (unsigned char *)packet.u.chr_item_info1.equip, 
			(unsigned char *)c[ cn].chrlst.equip,	sizeof( ItemAttr ) * 8 );
	}
	packet.h.header.size = sizeof(t_chr_item_info1 );
	QueuePacket( c, cn, &packet, 1);
}

void SendItemQuick( t_connection c[], int cn )
{
	t_packet packet;

⌨️ 快捷键说明

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