Quest Collection Modifcation
#1

Hello just wanted to share some code i wrote last year.



Normal quest collect.

-Allows you to collect only 1 item of whatever is in the production list for the monster

Modified Code:

- allows you to collect up to 5 items of whatever is in the production list for the monster 

-item count between 1-10 randomly each collect

Files you'll need to modify

-Config_Localize_USA.h

doFuncQuest.cpp


 

in Config_Localize_usa.h

at the end add this :

 

#define QUEST_COLLECT_MOD_10162021

 

in DoFuncQuest.cpp replace the function do_QuestCollect

 

void do_QuestCollect(CPC* ch, CNetMsg::SP& msg)
{
int nNPCIndex;
int nItemIndex = -1;
int nItemAmount = 1;
RefMsg(msg) >> nNPCIndex;


if (gserver->m_pulse - ch->m_nLastCollectRequest < PULSE_PRODUCE_DELAY - PULSE_HACK_ATTACK_THRESHOLD)
return ;

CNPC* pNPC = (CNPC*)ch->m_pArea->FindCharInCell(ch, nNPCIndex, MSG_CHAR_NPC);
if (!pNPC)
return ;


if (GetDistance(ch, pNPC) >= pNPC->m_proto->m_attackArea + 0.5)
return ;

#ifdef QUEST_COLLECT_MOD_10162021
bool isBoxCollectNpc = false;

if (pNPC->m_idNum == 1702 || pNPC->m_idNum == 1703 || pNPC->m_idNum == 1711)
isBoxCollectNpc = true;
#endif


if (ch->m_nCollectRequestNPCIndex != nNPCIndex)
ch->m_nCollectRequestCount = 0;

if( pNPC->m_proto->m_family > 0 )
FindFamilyInNear( ch, pNPC );

ch->m_nLastCollectRequest = gserver->m_pulse;
ch->m_nCollectRequestNPCIndex = nNPCIndex;
ch->m_nCollectRequestCount++;

if (ch->m_nCollectRequestCount >= 4)
{

ch->m_nLastCollectRequest = 0;

int nMaxRandom = MAX_NPC_PRODUCT - 1;
int itemIndexProduct[MAX_PRODUCTS_FROM_NPC];
while (nMaxRandom >= 0 )
{
int nProb = GetRandom(0, nMaxRandom);
if (pNPC->m_proto->m_product[nProb] <= 0)
nMaxRandom--;
else
{
nItemIndex = pNPC->m_proto->m_product[nProb];
break ;
}
}

CItem* pItem = NULL;

if (nItemIndex > 0)
{

#ifdef QUEST_COLLECT_MOD_10162021
if (isBoxCollectNpc)
{
for (int i = 0; i < MAX_PRODUCTS_FROM_NPC; i++)
{
itemIndexProduct[i] = pNPC->m_proto->m_product[i];
nItemAmount = GetRandom(1, 10);
pItem = gserver->m_itemProtoList.CreateItem(itemIndexProduct[i], -1, 0, 0, nItemAmount);

if(itemIndexProduct[i] == 0)
continue;

if (pItem)
{
if (pItem->m_itemProto->getItemIndex() != itemIndexProduct[i])
{
GAMELOG << init("Hack Character", ch) << "Invalid Item" << end;
return;
}
if (ch->m_inventory.addItem(pItem) == false)
{
GAMELOG << init("Create Item Fail", ch) << end;
delete pItem;
pItem = NULL;
nItemIndex = 0;
GAMELOG << init("QUEST COLLECT FAIL", ch)
<< "FULL INVEN"
<< end;
}
}
}

}

#endif
if (!isBoxCollectNpc)
pItem = gserver->m_itemProtoList.CreateItem(nItemIndex, -1, 0, 0, nItemAmount);

if (pItem && !isBoxCollectNpc)
{

if (ch->m_inventory.addItem(pItem) == false)
{
delete pItem;
pItem = NULL;
nItemIndex = 0;
GAMELOG << init("QUEST COLLECT FAIL" , ch)
<< "FULL INVEN"
<< end;
}
}
else
{
nItemIndex = 0;
}
}
else
{
nItemIndex = 0;
}
{

CNetMsg::SP rmsg(new CNetMsg);
QuestCollectMsg(rmsg, nNPCIndex, ch->m_index, nItemIndex);
pNPC->m_pArea->SendToCell(rmsg, pNPC, true);
}

DelAttackList(pNPC);
ch->m_pArea->CharFromCell(pNPC, true);
ch->m_pArea->DelNPC(pNPC);
pNPC = NULL;
}
else
{

CNetMsg::SP rmsg(new CNetMsg);
QuestCollectMsg(rmsg, nNPCIndex, ch->m_index, nItemIndex);
pNPC->m_pArea->SendToCell(rmsg, pNPC, true);
}
}

In the code you'll notice :

 

bool isBoxCollectNpc = false;
//replace where it says m_idNum == with your npc id
//replace here
if (pNPC->m_idNum == 1702 || pNPC->m_idNum == 1703 || pNPC->m_idNum == 1711)
isBoxCollectNpc = true;

you'll also notice item amount is random between 1,10 you can modify this to be different for each npc if you want or set your own custom range .

 

//modify the following value to get more or less items when collecting.
nItemAmount = GetRandom(1, 10);

Instead of only collecting 1 item from a monster you can do 5 items.

you'll have to set the flag of the npc to the following. add the  Quest Collect flag



Youll see the Product 0-5 filled out you can add up to 5 items for the drop .

replace the id's with the item you want them to drop




Once you collect from one of the NPCs it will look like the following as example.

 



If you think this code is useful, give it a thumbs up.

#2

Do you have animations for collecting resources from such NPCs in other clients?

When my character collects resources, the other player sees my character's idle animation, instead of the collection animation, and I do not know how to fix it.

#3

first of all, your preprocessors are pointless since if you disabled the preprocessor the code would no longer work since you put a variable definition here 

2

that variable is undefined when you use the 

QUEST_COLLECT_MOD_10162021

preprocessor which is a issue when you get here 

#4

first of all, your preprocessors are pointless since if you disabled the preprocessor the code would no longer work since you put a variable definition here 

2

that variable is undefined when you use the 

QUEST_COLLECT_MOD_10162021

preprocessor which is a issue when you get here 2

 

also this is totally ignoring the fact that if you use this you're creating a dupe here. so niiiiice on that i hope people use this lmao

 

the only checks before creating and giving the items 



is the npc id set 

are they sending rapid request

is the npc summoned currently

is the player within attack range of the npc



then to trigger his code you just need to set the npc id to one of those 3  hardcoded values 

1702 1703 1711

another issue is that he uses get random 1-10 on a array which is probably a maximum of 5 which should crash when randomly it gets a value higher than 5 also 

im preeety sure if you just copy this code to your shit its also opening up the possibility for a dupe since he just makes the item and gives it u could just logout before the function is complete and boom free shit. but may not even need to do that (packet editing ) if you instead use a quest tool like his to edit those values. as long as the server side has those npc's spawned it and ur standing near it, it should work.

looking at this code its sketch but i only looked a short time at it , its possible im wrong but im preeeeeeeeety sure this is bad shit.

#5

Feel free to test, it and write an improvement if you can  i didn't say i was good with c++ im just currently learning . But instead of bashing others posts maybe you should just write something constructive. 

#6

actually im wrong its fine rechecked it but fuck you anyways. 

#7

but yeah those preprocessors achieve nothing try to compile that without them lmao 



Forum Jump:


Users browsing this thread: 1 Guest(s)