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

📄 handler_cg_summon.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
字号:
#include "StdAfx.h"
#include "Handler_CG_SUMMON.h"
#include "Player.h"
#include "SummonManager.h"
#include "SummonedNPCs.h"
#include "PublicMath.h"
#include "float.h"
#include "SkillInfoParser.h"
#include "SkillFactory.h"
#include "Summoned.h"
#include "Skill.h"

Handler_CG_SUMMON::Handler_CG_SUMMON()
{
}

Handler_CG_SUMMON::~Handler_CG_SUMMON()
{
}

VOID Handler_CG_SUMMON::OnCG_SUMMON_COMMAND_SYN( ServerSession * pServerSession, MSG_BASE* pMsg, WORD wSize )
{
	MSG_CG_SUMMON_COMMAND_SYN* pRecv = (MSG_CG_SUMMON_COMMAND_SYN*)pMsg;
	MSG_CG_SUMMON_COMMAND_NAK NakMsg;
	NakMsg.m_byCommand = pRecv->m_byCommand;
	eSUMMON_COMMAND eCommand = (eSUMMON_COMMAND)pRecv->m_byCommand;

	Player * pPlayer = PlayerManager::Instance()->FindPlayer( pRecv->m_dwKey );
	if (!pPlayer) return;

	// 粮犁窍绰 疙飞牢瘤 眉农
	if( eCommand >= eSUMMON_COMMAND_MAX )
	{
		NakMsg.m_byErrorCode = RC::RC_SUMMON_INVALID_COMMAND;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	RC::eSUMMON_RESULT rcResult = SummonManager::Instance()->SetCommandState( pPlayer->GetSummonerKey(), eCommand, 0, pRecv->m_dwTargetKey );

	if( rcResult != RC::RC_SUMMON_SUCCESS )
	{
		NakMsg.m_byErrorCode = rcResult;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	MSG_CG_SUMMON_COMMAND_ACK AckMsg;
	AckMsg.m_byCommand = pRecv->m_byCommand;
	pPlayer->SendPacket( &AckMsg, sizeof(AckMsg) );
}

VOID Handler_CG_SUMMON::OnCG_SUMMON_SKILL_ACTION_SYN( ServerSession * pServerSession, MSG_BASE* pMsg, WORD wSize )
{
	MSG_CG_SUMMON_SKILL_ACTION_SYN* pRecvMsg = (MSG_CG_SUMMON_SKILL_ACTION_SYN*)pMsg;
	MSG_CG_SKILL_ACTION_NAK NakMsg;

	Player * pPlayer = PlayerManager::Instance()->FindPlayer( pRecvMsg->m_dwKey );
	if (!pPlayer) return;

	Field *pField = pPlayer->GetField();
	if( !pField ) return;

	// 泅犁 谅钎啊 蜡瓤茄瘤 眉农
	if( !_finite(pRecvMsg->m_wvCurPos.x) || !_finite(pRecvMsg->m_wvCurPos.y) || !_finite(pRecvMsg->m_wvCurPos.z) )
	{
		SUNLOG( eCRITICAL_LOG,  "[OnCG_SUMMON_SKILL_ACTION_SYN] CurPos is Invalid! x[%f] y[%f] z[%f]", pRecvMsg->m_wvCurPos.x, pRecvMsg->m_wvCurPos.y, pRecvMsg->m_wvCurPos.z );
		NakMsg.m_byErrorCode = RC::RC_SKILL_POSITION_INVALID;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	// 格利瘤 谅钎啊 蜡瓤茄瘤 眉农
	if( !_finite(pRecvMsg->m_wvDestPos.x) || !_finite(pRecvMsg->m_wvDestPos.y) || !_finite(pRecvMsg->m_wvDestPos.z) )
	{
		SUNLOG( eCRITICAL_LOG,  "[OnCG_SUMMON_SKILL_ACTION_SYN] DestPos is Invalid! x[%f] y[%f] z[%f]", pRecvMsg->m_wvDestPos.x, pRecvMsg->m_wvDestPos.y, pRecvMsg->m_wvDestPos.z );
		NakMsg.m_byErrorCode = RC::RC_SKILL_POSITION_INVALID;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	// 家券眉啊 粮犁窍绰瘤 眉农
	Summoned *pSummoned = NULL;
	SummonedNPCs *pSummonNPCs = SummonManager::Instance()->FindSummonNPCs( pPlayer->GetSummonerKey() );
	if( pSummonNPCs )	pSummoned = (Summoned*)pSummonNPCs->GetSummoned( pRecvMsg->m_dwSummonedObjKey );
	if( !pSummoned )
	{
		NakMsg.m_byErrorCode = RC::RC_SKILL_SUMMONED_NOTEXIST;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	// 努扼客 辑滚埃俊 家券眉 困摹 焊沥
	WzVector wvResultCurPos, wvResultDestPos;
	pSummoned->ModifyPosition( pRecvMsg->m_wvCurPos, pRecvMsg->m_wvDestPos, wvResultCurPos, wvResultDestPos, pRecvMsg->m_SkillCode );

	// 家券磊(敲饭捞绢)啊 捞 胶懦阑 嚼垫窍绊 乐绰瘤 眉农
	RC::eSKILL_RESULT rcResult = pPlayer->CanUseSkill( pRecvMsg->m_SkillCode );
	if( rcResult != RC::RC_SKILL_SUCCESS )
	{
		NakMsg.m_byErrorCode = rcResult;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	// 家券眉啊 捞 胶懦阑 荤侩且 荐 乐绰瘤 眉农
	rcResult = pSummoned->CanUseSkill( pRecvMsg->m_SkillCode, FALSE );
	if( rcResult != RC::RC_SKILL_SUCCESS )
	{
		NakMsg.m_byErrorCode = rcResult;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	AI_MSG_USE_SKILL AISkillMsg;
	AISkillMsg.dwSkillCode = pRecvMsg->m_SkillCode;
	AISkillMsg.dwTargetKey = pRecvMsg->m_dwMainTargetKey;
	AISkillMsg.vTargetPos = pRecvMsg->m_wvMainTargetPos;

	// MainTarget 谅钎甫 汲沥茄促.
	if( !CheckMainTarget( pSummoned, AISkillMsg.dwSkillCode, AISkillMsg.dwTargetKey, AISkillMsg.vTargetPos ) )
	{
		NakMsg.m_byErrorCode = RC::RC_SKILL_TARGET_NOTEXIST;
		pPlayer->SendPacket( &NakMsg, sizeof(NakMsg) );
		return;
	}

	// 家券眉啊 胶懦阑 荤侩窍档废 AI 皋技瘤甫 朝赴促.
	pSummoned->SendAIMessage( &AISkillMsg, sizeof(AISkillMsg) );

	// 家券眉啊 胶懦荤侩 葛靛啊 登档废 汲沥茄促.
	pSummonNPCs->SetCommandState( eSUMMON_COMMAND_SKILL_ATTACK, pRecvMsg->m_dwSummonedObjKey, 0 );
}

BOOL Handler_CG_SUMMON::CheckMainTarget( Summoned *pSummoned, SLOTCODE SkillCode, DWORD &dwMainTragetKey, WzVector &vMainTragetPos )
{
	Field *pField = pSummoned->GetField();
	if( !pField )	return FALSE;
	SkillScriptInfo *pBaseSkillInfo = (SkillScriptInfo *)SkillInfoParser::Instance()->GetSkillInfo( SkillCode );

	// 皋牢鸥百 谅钎甫 汲沥茄促.
	if( pBaseSkillInfo->m_byTarget == SKILL_TARGET_ME )
	{
		dwMainTragetKey = pSummoned->GetObjectKey();
		pSummoned->GetPos( &vMainTragetPos );
	}
	else if( pBaseSkillInfo->m_byTarget == SKILL_TARGET_AREA )
	{
	}
	else if( pBaseSkillInfo->m_byAttRangeform != SRF_PIERCE )		// 包烹胶懦牢 版快 m_wvMainTargetPos阑 弊措肺 敬促.
	{
		Character *pMainTarget = pField->FindCharacter( dwMainTragetKey );
		if( !pMainTarget )		return FALSE;
		pMainTarget->GetPos( &vMainTragetPos );
	}
	return TRUE;
}


























⌨️ 快捷键说明

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