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

📄 skillmgr.cpp

📁 国内著名网络游戏dragon的服务端完整源码 内附完整数据库结构
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	const int iItemMax = ch->ItemMax;
	for( int ct=0 ; ct < iItemMax ; ct++ )
	{
		if( ch->Item[ct] )
		{
			if( ch->Item[ct] == item_no )		// 捞固 硅款霸 乐澜...
				return -1;
		}	
	}
	return ct;
}

extern int TotalItemJoinTableCount;
int CSkillMgr::CheckYouCanSkillIt( const int cn, CItem_Join &join, const int skillno, const int x, const int y, const int target_id )
{
	int iCheck = 0;
	bool bJoinFlag = false;
	CHARLIST *ch = ::CheckServerId(cn);

	// 匙啊 舅绊 乐绰 Item牢啊?
	iCheck = FindLearnItem( ch, target_id );		// 硅款霸 乐栏搁 -1阑 府畔, 绝栏搁 item_max甫 府畔
	if( iCheck != -1 ){ return ITEMMAKE_UNKNOWN; }	// 郴啊 葛福绰 酒捞袍...

	for(int i = 0 ; i < TotalItemJoinTableCount ; i ++)
	{		
		if( item_join[i].item_id == target_id && item_join[i].need_skill1 == skillno )
		{		
			join = item_join[i];
			bJoinFlag = true;
			break;
		}	
	}
	
	if(!bJoinFlag){ return ITEM_MAKE_NO_JOIN;}

	// 档备绰 利例茄啊?
	iCheck = CheckSkillTool( ch, join, skillno, target_id );
	if( iCheck ){ return iCheck;}//咯扁辑 皋技瘤甫 林带啊 秦具 且 淀
	
	return ITEMMAKE_YOUCAN;
}

/*
48				档备 俺埃侩
49				档备 眠荐侩
50				档备 盲堡侩
51				档备 力访侩
52				档备 超矫侩
53				档备 国格侩
54				档备 格犁啊傍侩
55				档备 档绵侩
56				档备 距檬盲笼侩
57				档备 距犁父甸扁侩
58				档备 啊困幅
59				档备 格傍侩
60				档备 枚傍侩
61				档备 措快绰夸府侩(捻目)
62				档备 结绰夸府侩
63				档备 官疵幅
64				档备 劝力累侩
65				档备 阂措
66				档备 剧檬力累侩
67				档备 剐吵啊傍侩
68				档备 抛捞怪侩
69				档备 弊拱幅
70				档备 何剿倒幅
71				累诀措 侩堡肺
72				累诀措 硅撇
73				累诀措 急馆
74				累诀措 葛风
75				累诀措 拳傣
76				累诀措 矫氰包幅
77				累诀措 拱饭
78				累诀措 阂措 
*/
// 扁瓷 : 累馒茄 档备客 夸备窍绰  档备啊 老摹窍绰啊甫 犬牢窍绊 
//        档备啊 厘馒登绢 乐阑版快 付葛矫挪促. 
//	档备啊 嘎栏搁 0 阑 府畔茄促
int CSkillMgr::CheckSkillTool( LPCHARLIST ch, CItem_Join &join, const int iSkillNo, const int target_id )
{	
	const int iToolNo = ch->equip[WT_WEAPON].item_no;;
	CItem *ii  = ItemUnit(iToolNo);
	int iNowToolKind = 0;
	int iNeedToolKind = 0;

	// SkillMain.Tool == -1  :  酒捞袍 炼牢抛捞喉阑 曼炼茄促. 
	// SkillMain.Tool ==  0  :  档备甫 鞘夸肺 窍瘤 臼绰促. 
	// SkillMain.Tool >   0  :  SkillMain.Tool狼 鸥涝苞 厘馒茄 酒捞袍狼 鸥涝苞 厚绊茄促. 
	switch( SkillTbl[ iSkillNo].Tool )
	{
	case 0	:{  return 0;	}break;// Tool阑 鞘夸肺 窍瘤 臼绰促. 
	case -1 :// ItemJoin 抛捞喉阑 曼炼茄促. 
		{
			if( !join.Tool_kind )  {return 0;}	// 档备啊 鞘夸绝栏搁..
			
			if( !ii ){return join.Tool_kind;}
			iNowToolKind = ii->GetItemKind();
			iNeedToolKind = join.Tool_kind;
			if( iNeedToolKind == iNowToolKind )
			{	//扁夯 利栏肺 荤侩 窍搁 郴备档 皑家
				DecreaseEquipDuration( ch, rand()%5+3, WT_WEAPON, 0 ,true); 
				return 0; // 沥犬茄 档备捞促. 
			}
			else
			{
				return iNeedToolKind;
			}
		}break; 
	
	default :	
		{
			if( !ii ){return 1;}
			iNowToolKind = ii->GetItemKind();
			iNeedToolKind = SkillTbl[iSkillNo].Tool;//眉农 秦具 窍匙
			if( iNeedToolKind == iNowToolKind )
			{	//扁夯 利栏肺 荤侩 窍搁 郴备档 皑家
				DecreaseEquipDuration( ch, rand()%5+3, WT_WEAPON, 0 ,true);
				return 0;
			}
			else
			{
				return iNeedToolKind;
			}
		}break;
	}
	return 0;	// 档备啊 嘎瘤 臼绰促.   // 档备甫 鞘夸肺 窍瘤 臼绰促. 
}

bool CSkillMgr::CanLearnItem( CHARLIST *ch, const int join_num )const
{
	if(	 item_join[join_num].need_skill1? (ch->Skill[item_join[join_num].need_skill1]&& ch->skillexp[SkillTbl[item_join[join_num].need_skill1].inclusive].skillexp/10000 >= ( unsigned int )item_join[join_num].skill1_minimum ):true )
	{
		if(	 item_join[join_num].need_skill2? (ch->Skill[item_join[join_num].need_skill1]&& ch->skillexp[SkillTbl[item_join[join_num].need_skill2].inclusive].skillexp/10000 >= ( unsigned int )item_join[join_num].skill2_minimum ):true ) 
		{
			return true;
		}
	}
	return false;
}

void CSkillMgr::CharacterToAlive(CHARLIST *ch, const int iType)//混妨林绰 窃荐
{
	if( iType )//乐栏搁 钱肺
	{
		ch->Hp		= ch->HpMax;
		ch->Hungry  = ch->HungryMax;
		ch->Mana	= ch->ManaMax;
		ch->Cp = 0;
	}
	else//绝栏搁 叼弃飘肺
	{
		ch->Hp		= ch->HpMax		* 20 / 100;
		ch->Hungry  = ch->HungryMax * 30 / 100;
		ch->Mana	= 0;
		ch->Cp = 0;
	}

	ch->MoveGox = ch->X;//030102 lsw
	ch->MoveGoy = ch->Y;
	
	aliveCharacter( ch );
	t_packet packet;
	packet.h.header.type = CMD_PLEASE_GIVE_LIFE;
	packet.h.header.size = sizeof( t_please_give_life );
	packet.u.please_give_life.id		= ch->GetServerID();
	packet.u.please_give_life.who		= -1;
	packet.u.please_give_life.nLife	= ch->Hp;
	packet.u.please_give_life.nMana	= ch->Mana;
	packet.u.please_give_life.nHungry	= ch->Hungry;
	QueuePacket( connections, ch->GetServerID(), &packet,1 );
	CastMe2Other( ch->GetServerID(), &packet );
	CheckAndSendChangeEquip(ch,true); // CSD-021216
}

void CSkillMgr::CharacterToGhost(CHARLIST *ch, const int iType)//蜡飞栏肺 父甸绢 林绰 窃荐
{
	ch->deadcount	= 0;
	if (ch->Hp <= 0)  ch->Hp = 0;
	if (ch->Cp <= 0)  ch->Cp = 0;
	ch->viewtype = VIEWTYPE_GHOST_;
	ch->InitCurse();  
	SendViewTypeChange( ch->GetServerID(), VIEWTYPE_GHOST_ );
	ch->MoveGox = ch->X;//030102 lsw
	ch->MoveGoy = ch->Y;
}

bool CSkillMgr::SetCanViewGhost(CHARLIST *ch, const int iTime)//檬窜困
{
	if(iTime)
	{
		const DWORD dwTargetTime = (global_time + (iTime*1000));
		if( ch->dwCanViewGhostTime > dwTargetTime )
		{
			return false;
		}

		ch->bCanViewGhost = true;
		ch->dwCanViewGhostTime = dwTargetTime;//檬窜困
		ch->SendCharInfoBasic(  VIEWGHOST, iTime);//020704 lsw
	}
	else
	{
		ch->bCanViewGhost = false;
		ch->SendCharInfoBasic( VIEWGHOST, iTime);//020704 lsw
	}
	return true;
}

bool CSkillMgr::SetCanViewBomb(CHARLIST *ch, const int iTime)//檬窜困
{
	if(iTime)
	{
		const DWORD dwTargetTime = (global_time + (iTime*1000));
		if( ch->dwCanViewBombTime > dwTargetTime )
		{
			return false;
		}

		ch->bCanViewBomb = true;
		ch->dwCanViewBombTime = dwTargetTime;//檬窜困
		ch->SendCharInfoBasic(  VIEWBOMB, iTime);//020704 lsw
	}
	else
	{
		ch->bCanViewBomb = false;
		ch->SendCharInfoBasic( VIEWBOMB, iTime);//020704 lsw
	}
	return true;
}

bool CSkillMgr::SetCanViewTrap(CHARLIST *ch, const int iTime)//檬窜困
{
	if(iTime)
	{
		const DWORD dwTargetTime = (global_time + (iTime*1000));
		if( ch->dwCanViewTrapTime > dwTargetTime )
		{
			return false;
		}

		ch->bCanViewTrap = true;
		ch->dwCanViewTrapTime = dwTargetTime;//檬窜困
		ch->SendCharInfoBasic(  VIEWTRAP, iTime);//020704 lsw
	}
	else
	{
		ch->bCanViewTrap = false;
		ch->SendCharInfoBasic( VIEWTRAP, iTime);//020704 lsw
	}
	return true;
}

bool CSkillMgr::IncSkillCount(CHARLIST *ch, const int iType, const int iKind, const int iPoint)//020815 lsw
{

	if (!ch->IsPayedUser())
	{
		return false;
	}

	short nCount=0, nBeforeCount = 0;
	switch(iType)
	{
	case	SADONIX_NO:
		{
			nBeforeCount = ch->nSkillSadCount;
			(ch->nSkillSadCount) += iPoint;
			if( ch->nSkillSadCount > MAX_ITEM_SKILL_COUNT)
			{
				ch->nSkillSadCount = MAX_ITEM_SKILL_COUNT;
			}
			nCount = (ch->nSkillSadCount);
		}break;
	case	BLESSLEAF_NO:
		{
			nBeforeCount = ch->nSkillBlessLeaf;
			(ch->nSkillBlessLeaf) += iPoint;
			if( ch->nSkillBlessLeaf > MAX_ITEM_SKILL_COUNT)
			{
				ch->nSkillBlessLeaf = MAX_ITEM_SKILL_COUNT;
			}
			nCount = (ch->nSkillBlessLeaf);
		}break;
	default:
		{
			return false;
		}break;
	}
	
	if( (nCount/100) != (nBeforeCount/100) )
	{
		t_packet p;
		p.h.header.type = CMD_NOW_SKILL_POINT;
		p.h.header.size = sizeof(t_NowSkillPoint);

		p.u.NowSkillPoint.item.item_no	=	iType;
		p.u.NowSkillPoint.iNowPoint		=	nCount;
				
		::QueuePacket(connections,ch->GetServerID(),&p,1);
	}

	if(MAX_ITEM_SKILL_COUNT <= nCount)
	{
		const int r = rand()%1000;//1%肺 秦具 矫埃俊 嘎苗辑 府哩捞 登绰巴 贸烦 焊捞绰吧 阜阑 荐 乐促
		if(10 > r)//漂荐 酒捞袍阑 掘阑 荐 乐促
		{
			SendCMD_CONFORM_SADONIX(ch->GetServerID(), iType, iKind, ch->X, ch->Y);//荤靛电 构电 拎夸 
		}
	}
	return true;
}

void CSkillMgr::SendSkillExp( const int iType, const t_skillexp exp, const int cn)
{
	if( !::CheckServerId( cn ) ) return;
	
	t_packet packet;
	packet.h.header.type = CMD_SKILL_EXP;
	packet.h.header.size = sizeof( k_server_skill_exp );
	
	packet.u.kein.server_skill_exp.type			= iType;
	packet.u.kein.server_skill_exp.exp.skillexp = exp.skillexp;
	packet.u.kein.server_skill_exp.exp.rare		= exp.rare;
	
	::QueuePacket( connections, cn, &packet, 1 );		// 努扼捞攫飘 傈价	罐篮芭 绊措肺 焊郴霖促.
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CSkillMgr::Skill_Detect_ghost					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Talk_with_ghost				(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Poisoning						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Detect_poison					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Find_traps						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Remove_traps					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Entrapment						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Detect_bomb					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Bomb_in_box					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Remove_bomb					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Stealing						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Reclaim						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Sow							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Havest							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Mining							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Refine							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Fish_hooking					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Netting						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Cutting						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Lumbering						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Butchering						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Digging						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Makepowder						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Shear							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Carpentry						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Blacksmithy					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Cooking						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Clothing						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Tailoring						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Bowcrafting					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Fletching						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Makepotion						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Makemetal						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Makebottle						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Candlemaking					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Snooping						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Makefire						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Taming							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Evaluate_inteligence			(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Evaluate_wisdom				(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Anatomy_judgement				(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Item_identification			(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Tactics_crapple						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_swordmanship					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_archery						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_fencing						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_mace_fighting				(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_pierce						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_whirl						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_hurl							(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_parrying						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_double_swordmanship			(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_double_macefighting			(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_magery						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Tactics_orison						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Ghost_resurrection				(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}	
int CSkillMgr::Skill_Gm_carpenter					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}		
int CSkillMgr::Skill_Gm_blacksmith					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}		
int CSkillMgr::Skill_Gm_cook						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}		
int CSkillMgr::Skill_Gm_tailor						(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Gm_bowcraft					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Gm_alchemist					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}
int CSkillMgr::Skill_Gm_candlemaker					(const int iCn, const int iSkillNo, const int iX, const int iY, const int targettype, const int iTargetID ){return 0;}

void CSkillMgr::SkillMapper( const int cn, const int iSkillNo, const int x, const int y, const int targettype, const int target_id, const POS s )
{
	//acer7
	CHARLIST *ch = CheckServerId(cn);
	if( !ch ) return;


	if( target_id < 0 ) return;

	switch(iSkillNo)
	{
	case	SKILL_DETECT_GHOST						:
	case	SKILL_TALK_WITH_GHOST					:
	case	SKILL_POISONING							:
	case	SKILL_DETECT_POISON						:
	case	SKILL_FIND_TRAPS						:
	case	SKILL_REMOVE_TRAPS						:
	case	SKILL_ENTRAPMENT						:
	case	SKILL_DETECT_BOMB						:
	case	SKILL_BOMB_IN_BOX						:
	case	SKILL_REMOVE_BOMB						:
	case	SKILL_STEALING							:
	case	SKILL_RECLAIM							:
	case	SKILL_SOW								:
	case	SKILL_HAVEST							:
	case	SKILL_MINING							:

⌨️ 快捷键说明

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