Initial commit

Update char.cpp
This commit is contained in:
Mitachi
2022-06-22 04:23:24 +02:00
commit 681a877061
17 changed files with 266 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# m2-receive-quest-trigger

View File

@ -0,0 +1,7 @@
quest receive_item_test begin
state start begin
when 70001.receive begin
syschat(string.format("(TEST) -> Count Item: %d", pc.count_item(70001)))
end
end
end

View File

@ -0,0 +1,24 @@
quest swap_item begin
state start begin
when 70001.receive begin
local item_to_change = 70001
local count_needed = 10
local reward_vnum = 19
local reward_count = 1
while(pc.count_item(item_to_change) >= count_needed) do
if not pc.enough_inventory(reward_vnum) then
syschat("You don't have enough space to receive the item, free up space.")
syschat("After freeing up space, you will have to receive it again.")
break
end
pc.remove_item(item_to_change, count_needed)
pc.give_item2(reward_vnum, reward_count)
syschat(string.format("Congratulations! You have collected %s x %d! In return you will receive: %s x %d", item.get_name(item_to_change), count_needed, item.get_name(reward_vnum), reward_count ))
end
end
end
end

View File

@ -0,0 +1,3 @@
// Add:
#define ENABLE_QUEST_RECEIVE_ITEM

View File

@ -0,0 +1,15 @@
//1.) Search:
int CHARACTER::GetSkillPowerByLevel(int level, bool bMob) const
{
return CTableBySkill::instance().GetSkillPowerByLevelFromType(GetJob(), GetSkillGroup(), MINMAX(0, level, SKILL_MAX_LEVEL), bMob);
}
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
void CHARACTER::SenderRecvItem(unsigned int pc, LPITEM item)
{
quest::CQuestManager::instance().ReceiveItem(pc, item);
}
#endif

View File

@ -0,0 +1,10 @@
//1.) Search:
public:
int GetSkillPowerByLevel(int level, bool bMob = false) const;
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
void SenderRecvItem(unsigned int pc, LPITEM item);
#endif

View File

@ -0,0 +1,51 @@
//1.) Search:
item2->SetCount(item2->GetCount() + bCount2);
if (bCount == 0)
{
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item2->GetName());
M2_DESTROY_ITEM(item);
if (item2->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
SenderRecvItem(GetPlayerID(), item2);
#endif
//2.) Search:
char szHint[32+1];
snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
LogManager::instance().ItemLog(this, item, "GET", szHint);
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
if (item->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
SenderRecvItem(GetPlayerID(), item);
#endif
//3.) Search:
if (owner == this)
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
else
{
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s 님으로부터 %s"), GetName(), item->GetName());
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 전달: %s 님에게 %s"), owner->GetName(), item->GetName());
}
if (item->GetType() == ITEM_QUEST)
quest::CQuestManager::instance().PickupItem (owner->GetPlayerID(), item);
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
owner->SenderRecvItem(owner->GetPlayerID(), item);
#endif

View File

@ -0,0 +1,12 @@
//1.) Search:
if (iEmptyPos != -1)
{
item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));
LogManager::instance().ItemLog(ch, item, "GM", item->GetName());
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
ch->SenderRecvItem(ch->GetPlayerID(), item);
#endif

View File

@ -0,0 +1,10 @@
//1.) Search:
m_apItems[i] = NULL;
}
// and add before, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
victim->SenderRecvItem(victim->GetPlayerID(), item);
#endif

View File

@ -0,0 +1,9 @@
//1.) Search:
QUEST_ITEM_INFORMER_EVENT,
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
QUEST_ITEM_RECEIVE_EVENT,
#endif

View File

@ -0,0 +1,50 @@
//1.) Search:
m_mapEventName.insert(TEventNameMap::value_type("item_informer", QUEST_ITEM_INFORMER_EVENT));
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
m_mapEventName.insert(TEventNameMap::value_type("receive", QUEST_ITEM_RECEIVE_EVENT));
#endif
//2.) Search:
void CQuestManager::AttrOut(unsigned int pc, LPCHARACTER ch, int attr)
{
...
}
// and add under the whole function, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
bool CQuestManager::ReceiveItem(unsigned int pc, LPITEM item)
{
if (test_server)
sys_log(0, "questmanager::ReceiveItem Start : itemVnum : %d PC : %d", item->GetOriginalVnum(), pc);
PC* pPC;
if ((pPC = GetPC(pc)))
{
if (!CheckQuestLoaded(pPC))
{
LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(pc);
if (ch)
{
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5>ϴ<EFBFBD> <20><><EFBFBD>Դϴ<D4B4>. <20><>ø<EFBFBD> <20><>ٷ<EFBFBD> <20>ֽʽÿ<CABD>."));
}
return false;
}
// call script
SetCurrentItem(item);
return m_mapNPC[item->GetVnum()].OnReceive(*pPC);
}
else
{
sys_err("QUEST RECEIVE_ITEM_EVENT no such pc id : %d", pc);
return false;
}
}
#endif

View File

@ -0,0 +1,9 @@
//1.) Search:
void AttrOut(unsigned int pc, LPCHARACTER ch, int attr);
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
bool ReceiveItem(unsigned int pc, LPITEM item);
#endif

View File

@ -0,0 +1,18 @@
//1.) Search:
bool NPC::OnTakeItem(PC& pc)
{
...
}
// and add before, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
bool NPC::OnReceive(PC& pc)
{
if (m_vnum == 0)
return HandleReceiveAllEvent(pc, QUEST_ITEM_RECEIVE_EVENT);
else
return HandleEvent(pc, QUEST_ITEM_RECEIVE_EVENT);
}
#endif

View File

@ -0,0 +1,9 @@
//1.) Search:
bool OnAttrOut(PC& pc);
// and add after, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
bool OnReceive(PC& pc);
#endif

View File

@ -0,0 +1,18 @@
//1.) Search:
if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
{
LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), PERSONAL_SHOP_BUY, "");
}
DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), -dwPrice);
}
if (item)
sys_log(0, "SHOP: BUY: name %s %s(x %d):%u price %u", ch->GetName(), item->GetName(), item->GetCount(), item->GetID(), dwPrice);
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
ch->SenderRecvItem(ch->GetPlayerID(), item);
#endif

View File

@ -0,0 +1,17 @@
//1.) Search:
if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
{
LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), PERSONAL_SHOP_BUY, "");
}
DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), -dwPrice);
if (item)
sys_log(0, "ShopEx: BUY: name %s %s(x %d):%u price %u", ch->GetName(), item->GetName(), item->GetCount(), item->GetID(), dwPrice);
// and add under, this:
#ifdef ENABLE_QUEST_RECEIVE_ITEM
ch->SenderRecvItem(ch->GetPlayerID(), item);
#endif