2024-12-21 10:04:04 +08:00
|
|
|
|
|
|
|
|
|
|
#include "Stdafx.h"
|
|
|
|
|
|
#include "NpcReputationProcessor.h"
|
|
|
|
|
|
#include "DNUserSession.h"
|
|
|
|
|
|
#include "DNGameDataManager.h"
|
|
|
|
|
|
#include "ReputationSystemRepository.h"
|
|
|
|
|
|
#include "DNMissionSystem.h"
|
|
|
|
|
|
#include "DNMailSender.h"
|
|
|
|
|
|
#include "TimeSet.h"
|
|
|
|
|
|
#include "DNGuildSystem.h"
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(PRE_ADD_TOTAL_LEVEL_SKILL)
|
|
|
|
|
|
#if defined(_GAMESERVER)
|
|
|
|
|
|
#include "DnBlow.h"
|
|
|
|
|
|
#endif // _GAMESERVER
|
|
|
|
|
|
#endif // PRE_ADD_TOTAL_LEVEL_SKILL
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(PRE_ADD_WORLD_EVENT)
|
|
|
|
|
|
#include "DNEvent.h"
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if defined( PRE_ADD_NPC_REPUTATION_SYSTEM )
|
|
|
|
|
|
|
|
|
|
|
|
// Transaction/Commit <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> Auto Ŭ<><C5AC><EFBFBD><EFBFBD>
|
|
|
|
|
|
class CAutoTC
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CAutoTC( CDNUserSession* pSession, int iNpcID )
|
|
|
|
|
|
:m_pSession(pSession),m_iNpcID(iNpcID),m_pRepository(pSession->GetReputationSystem())
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pRepository->Transaction();
|
|
|
|
|
|
}
|
|
|
|
|
|
~CAutoTC()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pRepository->Commit();
|
|
|
|
|
|
m_pSession->GetEventSystem()->OnEvent( EventSystem::OnNpcReputaionChange, 3,
|
|
|
|
|
|
EventSystem::NpcID, m_iNpcID,
|
|
|
|
|
|
EventSystem::NpcReputaionFavor, m_pRepository->GetNpcReputation( m_iNpcID, IReputationSystem::NpcFavor ),
|
|
|
|
|
|
EventSystem::NpcReputaionMalice, m_pRepository->GetNpcReputation( m_iNpcID, IReputationSystem::NpcMalice ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
CDNUserSession* m_pSession;
|
|
|
|
|
|
CReputationSystemRepository* m_pRepository;
|
|
|
|
|
|
int m_iNpcID;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
bool CNpcReputationProcessor::_bIsCheckMission( CDNUserSession* pSession, const int iNpcID )
|
|
|
|
|
|
{
|
|
|
|
|
|
TReputeTableData* pReputeTable = g_pDataManager->GetReputeTableData( iNpcID );
|
|
|
|
|
|
if( NULL == pReputeTable )
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool bIsClearMission = pSession->GetMissionSystem()->bIsAchieveMission( pReputeTable->iMissionID );
|
|
|
|
|
|
if( false == bIsClearMission )
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined( _WORK )
|
|
|
|
|
|
WCHAR wszBuf[MAX_PATH];
|
|
|
|
|
|
wsprintf( wszBuf, L"NpcID:%d, MissionID:%d <20>̼<EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD> <20>ȵǼ<C8B5> ȣ<><C8A3><EFBFBD><EFBFBD> <20>ۿ<EFBFBD><DBBF><EFBFBD><EFBFBD><EFBFBD>", iNpcID, pReputeTable->iMissionID );
|
|
|
|
|
|
pSession->SendDebugChat( wszBuf );
|
|
|
|
|
|
#endif // #if defined( _WORK )
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
bool CNpcReputationProcessor::_bIsCheckQuest( CDNUserSession* pSession, const int iNpcID )
|
|
|
|
|
|
{
|
|
|
|
|
|
TReputeTableData* pReputeTable = g_pDataManager->GetReputeTableData( iNpcID );
|
|
|
|
|
|
if( pReputeTable == NULL )
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
bool bIsClearQuest = false;
|
|
|
|
|
|
const std::vector<int>& questIds = pReputeTable->iQuestIDs;
|
|
|
|
|
|
std::vector<int>::const_iterator iter = questIds.begin();
|
|
|
|
|
|
for (; iter != questIds.end(); ++iter)
|
|
|
|
|
|
{
|
|
|
|
|
|
const int& curQuestId = (*iter);
|
|
|
|
|
|
if (pSession->GetQuest()->IsClearQuest(curQuestId))
|
|
|
|
|
|
{
|
|
|
|
|
|
bIsClearQuest = true;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (bIsClearQuest == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined( _WORK )
|
|
|
|
|
|
WCHAR wszBuf[MAX_PATH];
|
|
|
|
|
|
wsprintf( wszBuf, L"NpcID:%d <20><><EFBFBD><EFBFBD>Ʈ Ŭ<><C5AC><EFBFBD><EFBFBD> <20>ȵǼ<C8B5> ȣ<><C8A3><EFBFBD><EFBFBD> <20>ۿ<EFBFBD><DBBF><EFBFBD><EFBFBD><EFBFBD>", iNpcID );
|
|
|
|
|
|
pSession->SendDebugChat( wszBuf );
|
|
|
|
|
|
#endif // #if defined( _WORK )
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif // #if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
|
|
|
|
|
|
BYTE CNpcReputationProcessor::_ConvertUnionToPointType(int nType)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (nType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case NpcReputation::UnionType::Commercial: return DBDNWorldDef::EtcPointCode::Union_Commercial;
|
|
|
|
|
|
case NpcReputation::UnionType::Liberty: return DBDNWorldDef::EtcPointCode::Union_Liberty;
|
|
|
|
|
|
case NpcReputation::UnionType::Royal: return DBDNWorldDef::EtcPointCode::Union_Royal;
|
|
|
|
|
|
}
|
|
|
|
|
|
return DBDNWorldDef::EtcPointCode::None;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CNpcReputationProcessor::_AddUnionReputePoint( CDNUserSession* pSession, int iUnionID, int nUnionPoint )
|
|
|
|
|
|
{
|
|
|
|
|
|
if (nUnionPoint <= 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
BYTE cPointType = _ConvertUnionToPointType(iUnionID);
|
|
|
|
|
|
if( pSession->GetGuildUID().IsSet() )
|
|
|
|
|
|
{
|
|
|
|
|
|
CDNGuildBase* pGuild = g_pGuildManager->At( pSession->GetGuildUID() );
|
|
|
|
|
|
if(pGuild)
|
|
|
|
|
|
{
|
|
|
|
|
|
TGuildRewardItem* GuildRewardItem = pGuild->GetGuildRewardItem();
|
|
|
|
|
|
if( GuildRewardItem[GUILDREWARDEFFECT_TYPE_EXTRAUNIONPOINT].nItemID > 0 &&
|
|
|
|
|
|
GuildRewardItem[GUILDREWARDEFFECT_TYPE_EXTRAUNIONPOINT].nEffectValue > 0 )
|
|
|
|
|
|
{
|
|
|
|
|
|
nUnionPoint += (int)(nUnionPoint * GuildRewardItem[GUILDREWARDEFFECT_TYPE_EXTRAUNIONPOINT].nEffectValue * 0.01);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#if defined(PRE_ADD_WORLD_EVENT)
|
|
|
|
|
|
const TEventListInfo* pEventInfo = g_pEvent->GetEventByType(pSession->GetWorldSetID(), WorldEvent::EVENT4/*4. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈȹ<C6AE>淮 <20><><EFBFBD><EFBFBD>*/, pSession->GetClassID());
|
|
|
|
|
|
if (pEventInfo && pEventInfo->nAtt1 > 0 )
|
|
|
|
|
|
nUnionPoint += (int)(nUnionPoint * (pEventInfo->nAtt1/100.0f));
|
|
|
|
|
|
#else //#if defined(PRE_ADD_WORLD_EVENT)
|
|
|
|
|
|
#if defined(PRE_ADD_WEEKLYEVENT)
|
|
|
|
|
|
int nThreadID = 0;
|
|
|
|
|
|
float fEventValue = g_pDataManager->GetWeeklyEventValuef(WeeklyEvent::Player, pSession->GetClassID(), WeeklyEvent::Event_9, nThreadID);
|
|
|
|
|
|
if (fEventValue != 0.f)
|
|
|
|
|
|
nUnionPoint += (int)(nUnionPoint * fEventValue);
|
|
|
|
|
|
#endif // #if defined(PRE_ADD_WEEKLYEVENT)
|
|
|
|
|
|
#endif //#if defined(PRE_ADD_WORLD_EVENT)
|
|
|
|
|
|
|
|
|
|
|
|
pSession->AddEtcPoint(cPointType, nUnionPoint);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CNpcReputationProcessor::Process( CDNUserSession* pSession, const int iNpcID, const IReputationSystem::eType Type, REPUTATION_TYPE value )
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
if( _bIsCheckMission( pSession, iNpcID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
#else
|
|
|
|
|
|
if( _bIsCheckQuest( pSession, iNpcID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
#endif // #if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
|
|
|
|
|
|
CAutoTC TC( pSession, iNpcID );
|
|
|
|
|
|
pSession->GetReputationSystem()->AddNpcReputation( iNpcID, Type, value );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CNpcReputationProcessor::PresentProcess( CDNUserSession* pSession, const int iNpcID, const int iPresentID, const int iPresentCount )
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><> <20>˻<EFBFBD>
|
|
|
|
|
|
if (iPresentCount <= 0 || iPresentCount > NPCPRESENTMAX)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
#if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
if( _bIsCheckMission( pSession, iNpcID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
#else
|
|
|
|
|
|
if( _bIsCheckQuest( pSession, iNpcID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
#endif // #if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
|
|
|
|
|
|
CAutoTC TC( pSession, iNpcID );
|
|
|
|
|
|
|
|
|
|
|
|
TReputeTableData* pReputationTable = g_pDataManager->GetReputeTableData( iNpcID );
|
|
|
|
|
|
if( pReputationTable == NULL )
|
|
|
|
|
|
return;
|
|
|
|
|
|
TPresentTableData* pPresentTable = g_pDataManager->GetPresentTableData( iPresentID );
|
|
|
|
|
|
if( pPresentTable == NULL )
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˻<EFBFBD>
|
|
|
|
|
|
if( pReputationTable->CheckPresentID( iPresentID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
switch( pPresentTable->Type )
|
|
|
|
|
|
{
|
|
|
|
|
|
case TPresentTableData::Normal:
|
|
|
|
|
|
{
|
|
|
|
|
|
// ItemID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inven<65><6E> <20><><EFBFBD><EFBFBD> (db <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)
|
|
|
|
|
|
if( pSession->GetItem()->DeleteInventoryByItemID( pPresentTable->iTypeID, iPresentCount, DBDNWorldDef::UseItem::Present, iNpcID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case TPresentTableData::Cash:
|
|
|
|
|
|
{
|
|
|
|
|
|
// ItemID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inven<65><6E> <20><><EFBFBD><EFBFBD> (db <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)
|
|
|
|
|
|
if( pSession->GetItem()->DeleteCashInventoryByItemID( pPresentTable->iTypeID, iPresentCount, DBDNWorldDef::UseItem::Present, iNpcID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case TPresentTableData::Coin:
|
|
|
|
|
|
{
|
|
|
|
|
|
if( pSession->CheckEnoughCoin( pPresentTable->iTypeID ) == false )
|
|
|
|
|
|
return;
|
|
|
|
|
|
pSession->DelCoin( pPresentTable->iTypeID, DBDNWorldDef::CoinChangeCode::Present, iNpcID );
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
|
|
|
{
|
|
|
|
|
|
_ASSERT(0);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool bPlusItem = false;
|
|
|
|
|
|
|
|
|
|
|
|
#if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
// Npc<70><63> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>.
|
|
|
|
|
|
int nPlusItemID = pReputationTable->iPlusItemID;
|
|
|
|
|
|
if( 0 != nPlusItemID )
|
|
|
|
|
|
{
|
|
|
|
|
|
const REPUTATION_TYPE nCurrentRepute = pSession->GetReputationSystem()->GetNpcReputation( iNpcID, IReputationSystem::NpcFavor );
|
|
|
|
|
|
|
|
|
|
|
|
if( nPlusItemID == pReputationTable->iNpcPresentID1 && nCurrentRepute >= pReputationTable->iNpcPresentRepute1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
bPlusItem = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if( nPlusItemID == pReputationTable->iNpcPresentID2 && nCurrentRepute >= pReputationTable->iNpcPresentRepute2 )
|
|
|
|
|
|
{
|
|
|
|
|
|
bPlusItem = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
#endif // #if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
|
|
|
|
|
|
// #48214 ȣ<><C8A3><EFBFBD><EFBFBD> <20>ݷ<EFBFBD><DDB7><EFBFBD> <20><>ȭ <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><DEB9><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ؼ<EFBFBD> <20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ϱ<EFBFBD><CFB1><EFBFBD> <20>Ѵ<EFBFBD>.
|
|
|
|
|
|
// <20>κ<EFBFBD><CEBA>丮<EFBFBD><E4B8AE> Ư<><C6AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>ִ<EFBFBD><D6B4><EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>.
|
|
|
|
|
|
CDNUserItem* pUserItem = pSession->GetItem();
|
|
|
|
|
|
if (pUserItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
int nItemID = pReputationTable->iPlusItemID;
|
|
|
|
|
|
if (pUserItem->GetInventoryItemCount(nItemID) > 0)
|
|
|
|
|
|
bPlusItem = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(PRE_ADD_TOTAL_LEVEL_SKILL)
|
|
|
|
|
|
#if defined(_GAMESERVER)
|
|
|
|
|
|
float incValue = 0.0f;
|
|
|
|
|
|
DnActorHandle hActor = pSession->GetActorHandle();
|
|
|
|
|
|
if (hActor && hActor->IsAppliedThisStateBlow(STATE_BLOW::BLOW_260))
|
|
|
|
|
|
{
|
|
|
|
|
|
DNVector(DnBlowHandle) vlBlows;
|
|
|
|
|
|
hActor->GatherAppliedStateBlowByBlowIndex(STATE_BLOW::BLOW_260, vlBlows);
|
|
|
|
|
|
{
|
|
|
|
|
|
int nCount = (int)vlBlows.size();
|
|
|
|
|
|
for (int i = 0; i < nCount; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
DnBlowHandle hBlow = vlBlows[i];
|
|
|
|
|
|
if (hBlow && hBlow->IsEnd() == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
incValue += hBlow->GetFloatValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif // _GAMESERVER
|
|
|
|
|
|
#endif // PRE_ADD_TOTAL_LEVEL_SKILL
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ʽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
|
|
|
|
|
float fPlusProbRate = 0;
|
|
|
|
|
|
if (bPlusItem)
|
|
|
|
|
|
fPlusProbRate = (float)pReputationTable->iPlusProb/100.0f;
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ʽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
int iAddFavorBonus = (int)(pPresentTable->iAddFavorPoint * fPlusProbRate);
|
|
|
|
|
|
int iTakeMaliceBonus = (int)(pPresentTable->iTakeMalicePoint * fPlusProbRate);
|
|
|
|
|
|
int iFavorGroupBonus = (int)(pPresentTable->iFavorGroupPoint * fPlusProbRate);
|
|
|
|
|
|
int iMaliceGroupBonus = (int)(pPresentTable->iMaliceGroupPoint * fPlusProbRate);
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(PRE_ADD_TOTAL_LEVEL_SKILL)
|
|
|
|
|
|
#if defined(_GAMESERVER)
|
|
|
|
|
|
iAddFavorBonus += (int)(pPresentTable->iAddFavorPoint * incValue);
|
|
|
|
|
|
#elif defined( _VILLAGESERVER )
|
|
|
|
|
|
float fTotalLevel = pSession->GetTotalLevelSkillEffect(TotalLevelSkill::Common::RepuTationIncrease);
|
|
|
|
|
|
iAddFavorBonus += (int)(pPresentTable->iAddFavorPoint * fTotalLevel);
|
|
|
|
|
|
#endif // _GAMESERVER
|
|
|
|
|
|
#endif // PRE_ADD_TOTAL_LEVEL_SKILL
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> NPC ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
pSession->GetReputationSystem()->AddNpcReputation( iNpcID, IReputationSystem::NpcFavor, (pPresentTable->iAddFavorPoint+iAddFavorBonus)*iPresentCount );
|
|
|
|
|
|
pSession->GetReputationSystem()->AddNpcReputation( iNpcID, IReputationSystem::NpcMalice, ((pPresentTable->iTakeMalicePoint+iTakeMaliceBonus)*-1)*iPresentCount );
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> NPC <20><> ģ<><C4A3> NPC ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
for( UINT i=0 ; i<pReputationTable->vFavorNpcID.size() ; ++i )
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
if( _bIsCheckMission( pSession, pReputationTable->vFavorNpcID[i] ) == false )
|
|
|
|
|
|
continue;
|
|
|
|
|
|
#else
|
|
|
|
|
|
if( _bIsCheckQuest( pSession, pReputationTable->vFavorNpcID[i] ) == false )
|
|
|
|
|
|
continue;
|
|
|
|
|
|
#endif // #if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
|
|
|
|
|
|
pSession->GetReputationSystem()->AddNpcReputation( pReputationTable->vFavorNpcID[i], IReputationSystem::NpcFavor, (pPresentTable->iFavorGroupPoint+iFavorGroupBonus)*iPresentCount );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> NPC <20><> <20>Ⱦ<EFBFBD><C8BE>ϴ<EFBFBD> NPC ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
for( UINT i=0 ; i<pReputationTable->vMaliceNpcID.size() ; ++i )
|
|
|
|
|
|
{
|
|
|
|
|
|
#if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
if( _bIsCheckMission( pSession, pReputationTable->vMaliceNpcID[i] ) == false )
|
|
|
|
|
|
continue;
|
|
|
|
|
|
#else
|
|
|
|
|
|
if( _bIsCheckQuest( pSession, pReputationTable->vMaliceNpcID[i] ) == false )
|
|
|
|
|
|
continue;
|
|
|
|
|
|
#endif // #if defined ( PRE_ADD_REPUTATION_EXPOSURE )
|
|
|
|
|
|
|
|
|
|
|
|
pSession->GetReputationSystem()->AddNpcReputation( pReputationTable->vMaliceNpcID[i], IReputationSystem::NpcMalice, (pPresentTable->iMaliceGroupPoint+iMaliceGroupBonus)*iPresentCount );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int iMailID = 0;
|
|
|
|
|
|
for (int i=0; i<iPresentCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
iMailID = 0;
|
|
|
|
|
|
#if defined( _VILLAGESERVER )
|
|
|
|
|
|
int iRand = (_rand()%NpcReputation::Common::MaxMailRandValue)+1;
|
|
|
|
|
|
#else
|
|
|
|
|
|
int iRand = (_rand(reinterpret_cast<CMultiRoom*>(pSession->GetGameRoom()))%NpcReputation::Common::MaxMailRandValue)+1;
|
|
|
|
|
|
#endif // #if defined( _VILLAGESERVER )
|
|
|
|
|
|
for( int i=0 ;i<NpcReputation::Common::MaxMailCount ; ++i )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( pReputationTable->iMailID[i] <= 0 || pReputationTable->iMailRand[i] <= 0 )
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
if( iRand <= pReputationTable->iMailRand[i] )
|
|
|
|
|
|
{
|
|
|
|
|
|
iMailID = pReputationTable->iMailID[i];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( iMailID > 0 )
|
|
|
|
|
|
CDNMailSender::Process( pSession, iMailID );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
int nUnionPoint = pReputationTable->GetUnionPointByPresent( iPresentID );
|
|
|
|
|
|
_AddUnionReputePoint( pSession, pReputationTable->iUnionID, nUnionPoint*iPresentCount );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void CNpcReputationProcessor::CheckAndCalcStoreBenefit( CDNUserSession* pUserSession, int iNpcID, TStoreBenefitData::eType Type, /*IN OUT*/ int& iNeedCoin )
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD>ϵǾ<CFB5><C7BE>ְ<EFBFBD>,
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִٸ<D6B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|
|
|
|
|
vector<TStoreBenefitData*> vlBenefitDatas;
|
|
|
|
|
|
g_pDataManager->GetStoreBenefitData( iNpcID, vlBenefitDatas );
|
|
|
|
|
|
for( int i = 0; i < (int)vlBenefitDatas.size(); ++i )
|
|
|
|
|
|
{
|
|
|
|
|
|
const TStoreBenefitData* pBenefitData = vlBenefitDatas.at( i );
|
|
|
|
|
|
if( Type == pBenefitData->Type )
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><> npc <20><><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> percent <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD> <20><><EFBFBD>ذ<EFBFBD> <20>̻<EFBFBD><CCBB><EFBFBD> <20>Ǵ<EFBFBD><C7B4><EFBFBD> Ȯ<><C8AE>.
|
|
|
|
|
|
CReputationSystemRepository* pRepository = pUserSession->GetReputationSystem();
|
|
|
|
|
|
if( pRepository->IsExistNpcReputation( iNpcID ) )
|
|
|
|
|
|
{
|
|
|
|
|
|
int iNowFavorPercent = pRepository->GetNpcReputationPercent( iNpcID, IReputationSystem::NpcFavor );
|
|
|
|
|
|
int iBenefitIndex = -1;
|
|
|
|
|
|
for( int k = 0; k < STORE_BENEFIT_MAX; ++k )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( 0 != pBenefitData->aiFavorThreshold[ k ] )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( pBenefitData->aiFavorThreshold[ k ] <= iNowFavorPercent )
|
|
|
|
|
|
iBenefitIndex = k;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20>ش<EFBFBD> npc <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>.
|
|
|
|
|
|
if( -1 < iBenefitIndex )
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ժ<EFBFBD>, <20><>ȭ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ó<><C3B3>.
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD>ΰ<EFBFBD> <20><> <20><> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7>ֵ<EFBFBD><D6B5><EFBFBD> ó<><C3B3>.
|
|
|
|
|
|
if( TStoreBenefitData::SellingPriceUp == Type )
|
|
|
|
|
|
{
|
|
|
|
|
|
iNeedCoin += int( (float)iNeedCoin * (float(pBenefitData->aiAdjustPercent[ iBenefitIndex ]) / 100.0f) );
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
iNeedCoin -= int( (float)iNeedCoin * (float(pBenefitData->aiAdjustPercent[ iBenefitIndex ]) / 100.0f) );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // #if defined( PRE_ADD_NPC_REPUTATION_SYSTEM )
|
|
|
|
|
|
|
|
|
|
|
|
void CNpcReputationProcessor::CheckAndCalcUnionBenefit( CDNUserSession* pUserSession, TStoreBenefitData::eType Type, /*IN OUT*/ int& iNeedPoint )
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD>ݾ<EFBFBD><DDBE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD> <20><>ȭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ȵ<EFBFBD>.
|
|
|
|
|
|
if( Type == TStoreBenefitData::EnchantFeeDiscount )
|
|
|
|
|
|
{
|
|
|
|
|
|
if( pUserSession->bIsRemoteEnchant() == true )
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CTimeSet timeSet;
|
|
|
|
|
|
__time64_t tLocalTime = timeSet.GetTimeT64_LC();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<NpcReputation::UnionType::Etc; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
TUnionMembership* pMembership = pUserSession->GetItem()->GetUnionMembership(i);
|
|
|
|
|
|
if (!pMembership) continue;
|
|
|
|
|
|
if (pMembership->nItemID == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
// <20>Ⱓ üũ
|
|
|
|
|
|
if (pMembership->tExpireDate == 0 ||
|
|
|
|
|
|
pMembership->tExpireDate < tLocalTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
pMembership->nItemID = 0;
|
|
|
|
|
|
pMembership->tExpireDate = 0;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>.
|
|
|
|
|
|
TUnionReputeBenefitData* pBenefitData = g_pDataManager->GetUnionReputeBenefitByItemID(pMembership->nItemID);
|
|
|
|
|
|
if (!pBenefitData) continue;
|
|
|
|
|
|
|
|
|
|
|
|
for (int j=0; j<NpcReputation::Common::MaxBenefitCount; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pBenefitData->nBenefitType[j] == -1) continue;
|
|
|
|
|
|
if (Type != pBenefitData->nBenefitType[j]) continue;
|
|
|
|
|
|
if (pBenefitData->nBenefitNum[j] <= 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
switch (Type)
|
|
|
|
|
|
{
|
|
|
|
|
|
case TStoreBenefitData::SellingPriceUp:
|
|
|
|
|
|
case TStoreBenefitData::FishProficiencyUp:
|
|
|
|
|
|
case TStoreBenefitData::CookProficiencyUp:
|
|
|
|
|
|
case TStoreBenefitData::CultivateProficiencyUp:
|
|
|
|
|
|
{
|
|
|
|
|
|
iNeedPoint += int( (float)iNeedPoint * (float(pBenefitData->nBenefitNum[j]) / 100.0f) );
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default: // Discount
|
|
|
|
|
|
{
|
|
|
|
|
|
iNeedPoint -= int( (float)iNeedPoint * (float(pBenefitData->nBenefitNum[j]) / 100.0f) );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CNpcReputationProcessor::UseUnionReputePoint( CDNUserSession* pSession, int nType, int nUsePoint )
|
|
|
|
|
|
{
|
|
|
|
|
|
const_cast<TUnionReputePointInfo*>(pSession->GetUnionReputePointInfoPtr())->DelUnionReputePoint(nType, nUsePoint);
|
|
|
|
|
|
|
|
|
|
|
|
BYTE cPointType = _ConvertUnionToPointType(nType);
|
|
|
|
|
|
pSession->UseEtcPoint(cPointType, nUsePoint);
|
|
|
|
|
|
}
|