📄 pkmanager.cpp
字号:
if( nDestroyRatio > 100 ) nDestroyRatio = 100;
int nDestoryItemNum = random( nMinDestroyItemNum, nMaxDestroyItemNum );
int nSeed = rand()%100;
if( nDestoryItemNum != 0 )
{
if( nSeed < nDestroyRatio )
{
CWearSlot* pWear = (CWearSlot*)pPlayer->GetSlot( eItemTable_Weared );
if( pWear->GetItemCount() )
{
//---厘馒酒捞袍 格废累己
cConstLinkedList<const ITEMBASE*> ListWearItem;
for( int i = TP_WEAR_START ; i < TP_WEAR_END ; ++i )
{
//背券秒家客 畴痢秒家殿阑 刚历 矫挪饶俊!
if( !pWear->IsEmpty( i ) )
if( !pWear->IsLock( i ) )
{
ListWearItem.AddTail( pWear->GetItemInfoAbs(i) );
}
}
//---厘馒酒捞袍 罚待 急琶
while( ListWearItem.GetCount() )
{
int nIndex = rand()%ListWearItem.GetCount();
ITEMBASE ItemInfo = *ListWearItem.GetAt( nIndex );
ListWearItem.DeleteAt( nIndex );
//CItemSlot* pDSlot = pDiePlayer->GetSlot( pItemInfo->Position );
// if( EI_TRUE != pDSlot->DeleteItemAbs( pDiePlayer, m_LootingItemArray[nArrayNum].dwData, &ItemBase ) )
// return FALSE;
MSG_ITEM_DESTROY msg;
msg.Category = MP_PK;
msg.Protocol = MP_PK_DESTROY_ITEM;
msg.wAbsPosition = ItemInfo.Position;
WORD wType = bWantedPlayer && nSeed < 3 ? eLog_ItemDestroyByWanted : eLog_ItemDestroyByBadFame;
if( wType == eLog_ItemDestroyByWanted )
msg.cbReason = 1; //泅惑裹捞骨肺 颇鲍
else
msg.cbReason = 0; //臭篮 厩疙栏肺 颇鲍
if( EI_TRUE == ITEMMGR->DiscardItem( pPlayer, ItemInfo.Position, ItemInfo.wIconIdx,
ItemInfo.Durability ) )
{
pPlayer->SendMsg( &msg, sizeof(msg) );
// Log
LogItemMoney(pPlayer->GetID(), pPlayer->GetObjectName(), 0, "",
wType, pPlayer->GetMoney(), 0, 0,
ItemInfo.wIconIdx, ItemInfo.dwDBIdx, ItemInfo.Position, 0,
ItemInfo.Durability, pPlayer->GetPlayerExpPoint());
}
if( --nDestoryItemNum <= 0 ) break;
}
ListWearItem.DeleteAll();
}
}
}
//公傍颇鲍 (柳过档 器窃登绢 乐绰扒啊?)
if( g_pServerSystem->GetNation() == eNATION_CHINA )
{
if( dwBadFame < 60 ) return;
}
nSeed = rand()%100;
if( nSeed < nDestroyRatio )
{
MUGONG_TOTALINFO TotalInfo;
pPlayer->GetMugongTotalInfo( &TotalInfo );
cConstLinkedList<const MUGONGBASE*> ListMugong;
for( int i = 0 ; i < SLOT_MUGONGTOTAL_NUM ; ++i )
{
if( TotalInfo.mugong
[i].dwDBIdx != 0 )
{
ListMugong.AddTail( &TotalInfo.mugong[i] );
}
}
if( ListMugong.GetCount() != 0 )
{
int nIndex = rand()%ListMugong.GetCount();
const MUGONGBASE* pMugong = ListMugong.GetAt(nIndex);
WORD logType = bWantedPlayer && nSeed < 3 ? eLog_MugongLevelDownByWanted : eLog_MugongLevelDownByBadFame;
if( pMugong )
pPlayer->MugongLevelDown(pMugong->wIconIdx, logType);
ListMugong.DeleteAll();
}
}
/*
//漂扁颇鲍 (扁夯漂扁牢瘤 备喊)
nSeed = rand()%100;
if( nSeed < nDestroyRatio )
{
MUGONG_TOTALINFO TotalInfo;
pPlayer->GetMugongTotalInfo( &TotalInfo );
cConstLinkedList<const MUGONGBASE*> ListMugong;
for( int i = 0 ; i < SLOT_MUGONGTOTAL_NUM ; ++i )
{
if( TotalInfo.mugong[i].dwDBIdx != 0 )
{
ListMugong.AddTail( &TotalInfo.mugong[i] );
}
}
if( ListMugong.GetCount() != 0 )
{
int nIndex = rand()%ListMugong.GetCount();
const MUGONGBASE* pMugong = ListMugong.GetAt(nIndex);
if( pMugong )
if( MUGONGMNGR->RemMugong( pPlayer, pMugong->wIconIdx, pMugong->Position ) )
{
MSG_MUGONG_REM_ACK ToMsg;
ToMsg.Category = MP_PK;
ToMsg.Protocol = MP_PK_DESTROY_MUGONG;
ToMsg.dwObjectID = pPlayer->GetID();
ToMsg.wMugongIdx = pMugong->wIconIdx;
ToMsg.TargetPos = pMugong->Position;
pPlayer->SendMsg(&ToMsg, sizeof(ToMsg));
}
ListMugong.DeleteAll();
}
}
*/
}
void CPKManager::PKModeExitPanelty( CPlayer* pPlayer ) //碍力 辆丰 趣篮 磷菌阑矫
{
DWORD dwBadFame = pPlayer->GetBadFame();
if( dwBadFame < 50 )
{
return;
}
EXPTYPE dwExp = 0;
MONEYTYPE dwMoney = 0;
EXPTYPE pointForLevel = GAMERESRCMNGR->GetMaxExpPoint( pPlayer->GetLevel() );
if( dwBadFame < 2000 )
{
dwExp = pointForLevel / 100;
dwMoney = pPlayer->GetMoney() * 2 / 100;
}
else if( dwBadFame < 5000 )
{
dwExp = pointForLevel * 2 / 100;
dwMoney = pPlayer->GetMoney() * 4 / 100;
}
else if( dwBadFame < 20000 )
{
dwExp = pointForLevel * 3 / 100;
dwMoney = pPlayer->GetMoney() * 6 / 100;
}
else if( dwBadFame < 50000 )
{
dwExp = pointForLevel * 10 / 100;
dwMoney = pPlayer->GetMoney() * 13 / 100;
}
else if( dwBadFame < 200000 )
{
dwExp = pointForLevel * 17 / 100;
dwMoney = pPlayer->GetMoney() * 21 / 100;
}
else if( dwBadFame < 500000 )
{
dwExp = pointForLevel * 24 / 100;
dwMoney = pPlayer->GetMoney() * 29 / 100;
}
else if( dwBadFame < 2000000 )
{
dwExp = pointForLevel * 31 / 100;
dwMoney = pPlayer->GetMoney() * 36 / 100;
}
else if( dwBadFame < 5000000 )
{
dwExp = pointForLevel * 38 / 100;
dwMoney = pPlayer->GetMoney() * 44 / 100;
}
else if( dwBadFame < 20000000 )
{
dwExp = pointForLevel * 45 / 100;
dwMoney = pPlayer->GetMoney() * 52 / 100;
}
else if( dwBadFame < 100000000 )
{
dwExp = pointForLevel * 52 / 100;
dwMoney = pPlayer->GetMoney() * 59 / 100;
}
else if( dwBadFame < 200000000 )
{
dwExp = pointForLevel * 59 / 100;
dwMoney = pPlayer->GetMoney() * 67 / 100;
}
else if( dwBadFame < 400000000 )
{
dwExp = pointForLevel * 66 / 100;
dwMoney = pPlayer->GetMoney() * 74 / 100;
}
else if( dwBadFame < 800000000 )
{
dwExp = pointForLevel * 73 / 100;
dwMoney = pPlayer->GetMoney() * 82 / 100;
}
else //10撅鳖瘤
{
dwExp = pointForLevel * 80 / 100;
dwMoney = pPlayer->GetMoney() * 90 / 100;
}
if( dwMoney )
{
pPlayer->SetMoney( dwMoney, MONEY_SUBTRACTION, MF_LOST, eItemTable_Inventory, eMoneyLog_LosePKModeExitPanelty, 0 );
}
if( dwExp && pPlayer->GetLevel() >= 5 ) //5饭骇 捞惑老锭父 厩疙摹 菩澄萍啊 乐促.
{
// if( pPlayer->GetPlayerExpPoint() < dwExp )
// dwExp = pPlayer->GetPlayerExpPoint();
// if( dwExp )
pPlayer->ReduceExpPoint( dwExp , eExpLog_LosebyBadFame );
}
}
void CPKManager::NetworkMsgParse( BYTE Protocol, void* pMsg )
{
switch( Protocol )
{
case MP_PK_PKON_SYN:
{
MSGBASE* pmsg = (MSGBASE*)pMsg;
CPlayer* pPlayer = (CPlayer*)g_pUserTable->FindUser(pmsg->dwObjectID);
if( !pPlayer ) break;
if( !IsPKAllow() ) //烙矫
{
MSG_BYTE msg; //error code?
msg.Category = MP_PK;
msg.Protocol = MP_PK_PKON_NACK;
msg.bData = ePKCODE_NOTALLAW;
pPlayer->SendMsg( &msg, sizeof(msg) );
break;
}
int rt;
if( ( rt = pPlayer->PKModeOn() ) == ePKCODE_OK )
{
MSG_DWORD msg;
msg.Category = MP_PK;
msg.Protocol = MP_PK_PKON_ACK;
msg.dwData = pmsg->dwObjectID;
msg.dwObjectID = pPlayer->GetID();
PACKEDDATA_OBJ->QuickSend( pPlayer, &msg, sizeof(msg) );
}
else
{
MSG_BYTE msg;
msg.Category = MP_PK;
msg.Protocol = MP_PK_PKON_NACK;
msg.bData = rt;
pPlayer->SendMsg( &msg, sizeof(msg) );
}
}
break;
case MP_PK_PKOFF_SYN:
{
MSGBASE* pmsg = (MSGBASE*)pMsg;
CPlayer* pPlayer = (CPlayer*)g_pUserTable->FindUser(pmsg->dwObjectID);
if( !pPlayer ) break;
if( pPlayer->PKModeOff() )
{
MSG_DWORD msg;
msg.Category = MP_PK;
msg.Protocol = MP_PK_PKOFF_ACK;
msg.dwData = pmsg->dwObjectID;
msg.dwObjectID = pPlayer->GetID();
PACKEDDATA_OBJ->QuickSend( pPlayer, &msg, sizeof(msg) );
}
else
{
MSGBASE msg;
msg.Category = MP_PK;
msg.Protocol = MP_PK_PKOFF_NACK;
pPlayer->SendMsg( &msg, sizeof(msg) );
}
}
break;
case MP_PK_LOOTING_SELECT_SYN:
{
MSG_DWORD2* pmsg = (MSG_DWORD2*)pMsg;
CLootingRoom* pRoom = LOOTINGMGR->GetLootingRoom( pmsg->dwData1 );
if( pRoom )
{
LOOTINGMGR->Loot( pmsg->dwData1, pmsg->dwData2 );
}
else
{
CPlayer* pPlayer = (CPlayer*)g_pUserTable->FindUser(pmsg->dwObjectID);
if( pPlayer )
{
MSG_DWORD2 msg;
msg.Category = MP_PK;
msg.Protocol = MP_PK_LOOTING_ERROR;
msg.dwData1 = pmsg->dwData1;
msg.dwData2 = eLOOTINGERROR_NO_LOOTINGROOM;
pPlayer->SendMsg( &msg, sizeof(msg) );
}
}
}
break;
case MP_PK_LOOTING_ENDLOOTING:
{
MSG_DWORD* pmsg = (MSG_DWORD*)pMsg;
LOOTINGMGR->CloseLootingRoom( pmsg->dwData, FALSE );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -