2022-03-05 12:44:06 +02:00
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "char.h"
|
|
|
|
|
#include "mob_manager.h"
|
|
|
|
|
#include "affect.h"
|
|
|
|
|
#include "item.h"
|
|
|
|
|
#include "polymorph.h"
|
|
|
|
|
|
|
|
|
|
CPolymorphUtils::CPolymorphUtils()
|
|
|
|
|
{
|
|
|
|
|
m_mapSPDType.insert(std::make_pair(101, 101));
|
|
|
|
|
m_mapSPDType.insert(std::make_pair(1901, 1901));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
POLYMORPH_BONUS_TYPE CPolymorphUtils::GetBonusType(DWORD dwVnum)
|
|
|
|
|
{
|
2022-03-06 00:01:03 +02:00
|
|
|
|
std::unordered_map<DWORD, DWORD>::iterator iter;
|
2022-03-05 12:44:06 +02:00
|
|
|
|
|
|
|
|
|
iter = m_mapSPDType.find(dwVnum);
|
|
|
|
|
|
|
|
|
|
if (iter != m_mapSPDType.end())
|
|
|
|
|
return POLYMORPH_SPD_BONUS;
|
|
|
|
|
|
|
|
|
|
iter = m_mapATKType.find(dwVnum);
|
|
|
|
|
|
|
|
|
|
if (iter != m_mapATKType.end())
|
|
|
|
|
return POLYMORPH_ATK_BONUS;
|
|
|
|
|
|
|
|
|
|
iter = m_mapDEFType.find(dwVnum);
|
|
|
|
|
|
|
|
|
|
if (iter != m_mapDEFType.end())
|
|
|
|
|
return POLYMORPH_DEF_BONUS;
|
|
|
|
|
|
|
|
|
|
return POLYMORPH_NO_BONUS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPolymorphUtils::PolymorphCharacter(LPCHARACTER pChar, LPITEM pItem, const CMob* pMob)
|
|
|
|
|
{
|
|
|
|
|
BYTE bySkillLevel = pChar->GetSkillLevel(POLYMORPH_SKILL_ID);
|
|
|
|
|
DWORD dwDuration = 0;
|
|
|
|
|
DWORD dwBonusPercent = 0;
|
|
|
|
|
int iPolyPercent = 0;
|
|
|
|
|
|
|
|
|
|
switch (pChar->GetSkillMasterType(POLYMORPH_SKILL_ID))
|
|
|
|
|
{
|
|
|
|
|
case SKILL_NORMAL:
|
|
|
|
|
dwDuration = 10;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SKILL_MASTER:
|
|
|
|
|
dwDuration = 15;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SKILL_GRAND_MASTER:
|
|
|
|
|
dwDuration = 20;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SKILL_PERFECT_MASTER:
|
|
|
|
|
dwDuration = 25;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dwDuration *= 60;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> Ȯ<><C8AE> = ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> - <20><> <20><><EFBFBD><EFBFBD> + <20>а<EFBFBD><D0B0><EFBFBD> <20><><EFBFBD><EFBFBD> + 29 + <20>а<EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD>
|
|
|
|
|
iPolyPercent = pChar->GetLevel() - pMob->m_table.bLevel + pItem->GetSocket(2) + (29 + bySkillLevel);
|
|
|
|
|
|
|
|
|
|
if (iPolyPercent <= 0)
|
|
|
|
|
{
|
|
|
|
|
pChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<EFBFBD>а<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-11-27 14:36:04 +02:00
|
|
|
|
if (Random::get(1, 100) > iPolyPercent)
|
2022-03-05 12:44:06 +02:00
|
|
|
|
{
|
|
|
|
|
pChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<EFBFBD>а<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>"));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pChar->AddAffect(AFFECT_POLYMORPH, POINT_POLYMORPH, pMob->m_table.dwVnum, AFF_POLYMORPH, dwDuration, 0, true);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ʽ<EFBFBD> = <20>а<EFBFBD> <20><>ų <20><><EFBFBD><EFBFBD> + <20>а<EFBFBD><D0B0><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
dwBonusPercent = bySkillLevel + pItem->GetSocket(2);
|
|
|
|
|
|
|
|
|
|
switch (GetBonusType(pMob->m_table.dwVnum))
|
|
|
|
|
{
|
|
|
|
|
case POLYMORPH_ATK_BONUS:
|
|
|
|
|
pChar->AddAffect(AFFECT_POLYMORPH, POINT_ATT_BONUS, dwBonusPercent, AFF_POLYMORPH, dwDuration - 1, 0, false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case POLYMORPH_DEF_BONUS:
|
|
|
|
|
pChar->AddAffect(AFFECT_POLYMORPH, POINT_DEF_BONUS, dwBonusPercent, AFF_POLYMORPH, dwDuration - 1, 0, false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case POLYMORPH_SPD_BONUS:
|
|
|
|
|
pChar->AddAffect(AFFECT_POLYMORPH, POINT_MOV_SPEED, dwBonusPercent, AFF_POLYMORPH, dwDuration - 1, 0, false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case POLYMORPH_NO_BONUS:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPolymorphUtils::UpdateBookPracticeGrade(LPCHARACTER pChar, LPITEM pItem)
|
|
|
|
|
{
|
|
|
|
|
if (pChar == NULL || pItem == NULL)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (pItem->GetSocket(1) > 0)
|
|
|
|
|
pItem->SetSocket(1, pItem->GetSocket(1) - 1);
|
|
|
|
|
else
|
|
|
|
|
pChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<EFBFBD>а<EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ú<EFBFBD><C3BA><EFBFBD>ϴ<EFBFBD>. <20>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD> ã<>ư<EFBFBD><C6B0><EFBFBD><EFBFBD><EFBFBD>."));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPolymorphUtils::GiveBook(LPCHARACTER pChar, DWORD dwMobVnum, DWORD dwPracticeCount, BYTE BookLevel, BYTE LevelLimit)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>0 <20><><EFBFBD><EFBFBD>1 <20><><EFBFBD><EFBFBD>2
|
|
|
|
|
// <20>а<EFBFBD><D0B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȣ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>а<EFBFBD><D0B0><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
if (pChar == NULL)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
LPITEM pItem = pChar->AutoGiveItem(POLYMORPH_BOOK_ID, 1);
|
|
|
|
|
|
|
|
|
|
if (pItem == NULL)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (CMobManager::instance().Get(dwMobVnum) == NULL)
|
|
|
|
|
{
|
|
|
|
|
sys_err("Wrong Polymorph vnum passed: CPolymorphUtils::GiveBook(PID(%d), %d %d %d %d)",
|
|
|
|
|
pChar->GetPlayerID(), dwMobVnum, dwPracticeCount, BookLevel, LevelLimit);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pItem->SetSocket(0, dwMobVnum); // <20>а<EFBFBD><D0B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȣ
|
|
|
|
|
pItem->SetSocket(1, dwPracticeCount); // <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD> Ƚ<><C8BD>
|
|
|
|
|
pItem->SetSocket(2, BookLevel); // <20><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPolymorphUtils::BookUpgrade(LPCHARACTER pChar, LPITEM pItem)
|
|
|
|
|
{
|
|
|
|
|
if (pChar == NULL || pItem == NULL)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
pItem->SetSocket(1, pItem->GetSocket(2) * 50);
|
|
|
|
|
pItem->SetSocket(2, pItem->GetSocket(2)+1);
|
|
|
|
|
return true;
|
|
|
|
|
}
|