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

📄 npc_addexp.cpp

📁 奇迹世界 部分源代码奇迹世界 部分源代码奇迹世界 部分源代码
💻 CPP
字号:
#include "stdafx.h"
#include "NPC.h"
#include "Field.h"
#include "CharacterFormula.h"
#include "Party.h"
#include "PartyManager.h"
#include "Map.h"
#include "Player.h"
#include "GameRoom.h"
#include "PublicMath.h"


class AddExpOperator
{
public:
	DWORD			m_dwMemberNum;			// 颇萍盔 荐
	LEVELTYPE		m_partyTotalLV;			// 颇萍盔 饭骇 醚钦
	NPC*			m_pTarget;				// 鸥百
	BYTE			m_byRoomBonusType;		// 冯 焊呈胶 鸥涝(酒捞袍, 版氰摹 快急)
	BYTE			m_byRadius;				// 版氰摹 蜡瓤 馆瘤抚(0老 版快 葛滴俊霸)

	VOID operator () ( Player *pMember )
	{
		if( m_byRadius )
		{
			WzVector vAttackerPos, vTargetPos;	
			pMember->GetPos( &vAttackerPos );	m_pTarget->GetPos( &vTargetPos );
			if( Math_VectorLength( vAttackerPos, vTargetPos ) > m_byRadius )	return;
		}

		if( pMember->IsDead() )		return;

		DWORD ResultExp = GetKillExpOfParty( m_byRoomBonusType, m_dwMemberNum, m_partyTotalLV, pMember->GetLevel(), 
			m_pTarget->GetDisplayLevel(), m_pTarget->GetGrade(), (DAMAGETYPE)m_pTarget->GetMaxHP(), m_pTarget->GetMaxHP() );

		// PC规 蜡历捞搁 版氰摹 10%甫 歹 霖促.
		if( pMember->GetReservedValue() )
			ResultExp = (DWORD)(ResultExp * 1.1f);

		// 乔肺档 矫胶袍(敲饭捞啊 12矫埃捞 逞栏搁 版氰摹 绝澜)
		if( pMember->IsOverPlayingTime() )
			ResultExp = 0;

		pMember->AddExp( ResultExp, m_pTarget->GetObjectKey() );
	}
};

typedef std::map<WORD, WORD>		PARTYKEY_MAP;
typedef PARTYKEY_MAP::iterator		PARTYKEY_MAP_ITER;
typedef std::pair<WORD, WORD>		PARTYKEY_MAP_PAIR;

class GetPartyKeysOperator
{
	PARTYKEY_MAP	&m_mapPartyKey;
	Field*			m_pField;

public:
	GetPartyKeysOperator( PARTYKEY_MAP &mapPartyKey, Field* pField ) : m_mapPartyKey(mapPartyKey), m_pField(pField) {}
	~GetPartyKeysOperator() {}

	VOID operator () ( BATTLE_RECORD *pRecord )
	{
		Character *pAttacker = m_pField->FindCharacter( pRecord->GetObjectKey() );
		if( !pAttacker )	return;

		WORD wPartyKey = pAttacker->GetPartyState().GetPartyKey();

		// pAttacker啊 家券眉牢 版快 弊 林牢阑 茫酒辑 颇萍虐甫 悸泼秦具茄促.
		if( (pAttacker->GetObjectType() & SUMMON_OBJECT) == SUMMON_OBJECT )
		{
			Character *pSummoner = m_pField->FindCharacter( pAttacker->GetSummonerKey() );
			if( pSummoner )
			{
				wPartyKey = pSummoner->GetPartyState().GetPartyKey();
			}
		}

		m_mapPartyKey.insert( PARTYKEY_MAP_PAIR(wPartyKey, 0) );
	}
};

VOID NPC::DistributeExp()
{
	if( m_pBattleRecord->IsEmpty() )	return;
	if( !GetField() )					return;

	BYTE byZoneType = GetField()->GetMap()->GetMapInfo()->GetMapInfo()->byMKind;

	// 阿阿狼 傍拜磊甸俊 措秦 吝汗登瘤 臼绰 颇萍虐甫 掘绢辰促.
	PARTYKEY_MAP mapPartyKey;
	GetPartyKeysOperator partykeyOPR( mapPartyKey, GetField() );
	m_pBattleRecord->ForEachRecord( partykeyOPR );

	// 阿 颇萍俊 措秦 版氰摹甫 盒硅茄促.
	PARTYKEY_MAP_ITER it;
	for( it = mapPartyKey.begin(); it != mapPartyKey.end(); ++it )
	{
		Party *pParty = PartyManager::Instance()->FindParty( it->first );
		if( !pParty )	continue;

		AddExpOperator ExpOpr;
		ExpOpr.m_dwMemberNum = pParty->GetMemberNum();
		ExpOpr.m_partyTotalLV = pParty->GetTotalLevel();
		ExpOpr.m_pTarget = this;

		// 固记甘狼 版快
		if( byZoneType == eZONETYPE_MISSION )
		{
			ExpOpr.m_byRoomBonusType = eHUNTING_BONUS_TYPE_ITEM;
			ExpOpr.m_byRadius = 0;
		}
		// 清泼甘狼 版快
		else if( byZoneType == eZONETYPE_HUNTING )
		{
			GameRoom * pGameRoom = (GameRoom *)GetField()->GetMap()->GetGameZone();
			ExpOpr.m_byRoomBonusType = pGameRoom->GetAdditionalInfo()->m_Bonus;
			ExpOpr.m_byRadius = 20;
		}
		pParty->ForEachMember( ExpOpr );
	}
}



















⌨️ 快捷键说明

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