Page 1 of 2

Treasure Hunter how does it work on DSP?

Posted: Fri Aug 30, 2013 5:17 pm
by altnob
I'm curiouis to know how TH works on DSP can someone fill me in?

Re: Treasure Hunter how does it work on DSP?

Posted: Fri Aug 30, 2013 6:10 pm
by atom0s
When a monster dies and a pool of items is found (DropList) the highest treasure hunter in the party is used as a number of tries an item can drop:

ai_mob_dummy.cpp:

Code: Select all

                DropList_t* DropList = itemutils::GetDropList(m_PMob->m_DropID);

			    if (DropList != NULL && DropList->size())
			    {
					uint8 highestTH = charutils::GetHighestTreasureHunter(PChar, m_PMob);

                    for(uint8 i = 0; i < DropList->size(); ++i)
				    {
						//highestTH is the number of 'extra chances' at an item. If the item is obtained, then break out.
						uint8 tries = 0;
						while(tries < 1+highestTH)
						{
							if(rand()%100 < DropList->at(i).DropRate)
							{
								PChar->PTreasurePool->AddItem(DropList->at(i).ItemID, m_PMob);
								break;
							}
							tries++;
						}
				    }

			    }
The number of tries relates to the highest Treasure Hunter in the party. For example if you have two THF's, one with TH2 and one with TH3, the TH3 is considered the highest and 4 chances are given for the item to drop. (Treasure Hunter level + 1 = number of tries)

Re: Treasure Hunter how does it work on DSP?

Posted: Fri Aug 30, 2013 6:13 pm
by kjLotus
it also does not increase with chance on hit

Re: Treasure Hunter how does it work on DSP?

Posted: Fri Aug 30, 2013 7:58 pm
by altnob
Does the thief have to make action or does it just check if it's in zone and in party/alliance?
uint8 GetHighestTreasureHunter(CCharEntity* PChar, CMobEntity* PMob)
{
bool thf_in_party = true;
uint8 highestTH = PMob->m_THLvl;
if (map_config.thf_in_party_for_drops == 1) {
if(PChar->PParty != NULL) { // There's a party
if(PChar->PParty->m_PAlliance == NULL) { // but no alliance
thf_in_party = false;
for(uint8 i = 0; i < PChar->PParty->members.size(); i++) {
CCharEntity* thPChar = (CCharEntity*)PChar->PParty->members;
// THFs must be within 100 yalms in order for TH to work
if (distance(thPChar->loc.p, PMob->loc.p) < 100 && (charutils::hasTrait(thPChar, TRAIT_TREASURE_HUNTER))) {
thf_in_party = true;
break; // no point continuing to search
}
}
}
else{ // alliance
thf_in_party = false;
for(uint8 a = 0; a < PChar->PParty->m_PAlliance->partyList.size(); ++a) {
for(uint8 i = 0; i < PChar->PParty->m_PAlliance->partyList[a]->members.size(); i++) {
CCharEntity* thPChar = (CCharEntity*)PChar->PParty->m_PAlliance->partyList[a]->members;
if (distance(thPChar->loc.p, PMob->loc.p) < 100 && (charutils::hasTrait(thPChar, TRAIT_TREASURE_HUNTER))) {
thf_in_party = true;
break; // no point continuing to search
}
}
}
}
}
}

if (!thf_in_party) {
highestTH = 0;
}

return highestTH;
}


Judging by this, thf doesn't have to make action just needs to be within 100yalms of kill. Right?

Re: Treasure Hunter how does it work on DSP?

Posted: Fri Aug 30, 2013 10:11 pm
by kjLotus
think it only does that if the mob has had TH applied to it (as in atom0s' post), too lazy to check

Re: Treasure Hunter how does it work on DSP?

Posted: Sat Aug 31, 2013 12:19 am
by altnob
kjLotus wrote:think it only does that if the mob has had TH applied to it (as in atom0s' post), too lazy to check
judging by the source code it only checks if there's a thief within 100 yalms of the mob when it dies. so theoritcally a thief does not have to make action on the mob it just needs to be within exp range.

Re: Treasure Hunter how does it work on DSP?

Posted: Sat Aug 31, 2013 12:32 am
by kjLotus
checked da codez
fourth line you posted

uint8 highestTH = PMob->m_THLvl;

this is zero if a thf never hit

Re: Treasure Hunter how does it work on DSP?

Posted: Sat Aug 31, 2013 12:57 am
by altnob
kjLotus wrote:checked da codez
fourth line you posted

uint8 highestTH = PMob->m_THLvl;

this is zero if a thf never hit

can you further elaborate on this? what i mean is can you post the source code and show me what means what as to what you're referring to? to me it just looks like it checks for <100yalms

Re: Treasure Hunter how does it work on DSP?

Posted: Sat Aug 31, 2013 1:17 am
by kjLotus
thf does auto attack

ai_char_normal.cpp#2624

Code: Select all

	if (charutils::hasTrait(m_PChar, TRAIT_TREASURE_HUNTER))
	{
		if (Monster->m_THLvl == 0)
			{
				Monster->m_THLvl = m_PChar->getMod(MOD_TREASURE_HUNTER);
				Monster->m_THPCID = m_PChar->id;
			}
			else if ((Monster->m_THPCID != m_PChar->id) && (Monster->m_THLvl < m_PChar->getMod(MOD_TREASURE_HUNTER))) Monster->m_THLvl = m_PChar->getMod(MOD_TREASURE_HUNTER)+1;
			else if ((Monster->m_THPCID == m_PChar->id) && (Monster->m_THLvl < m_PChar->getMod(MOD_TREASURE_HUNTER))) Monster->m_THLvl = m_PChar->getMod(MOD_TREASURE_HUNTER);
			if (Monster->m_THLvl > 12) Monster->m_THLvl = 12;
	}

if someone with TH never attacked, highestTH is just 0

Re: Treasure Hunter how does it work on DSP?

Posted: Sat Aug 31, 2013 10:27 am
by altnob
kjLotus wrote:thf does auto attack

ai_char_normal.cpp#2624

Code: Select all

	if (charutils::hasTrait(m_PChar, TRAIT_TREASURE_HUNTER))
	{
		if (Monster->m_THLvl == 0)
			{
				Monster->m_THLvl = m_PChar->getMod(MOD_TREASURE_HUNTER);
				Monster->m_THPCID = m_PChar->id;
			}
			else if ((Monster->m_THPCID != m_PChar->id) && (Monster->m_THLvl < m_PChar->getMod(MOD_TREASURE_HUNTER))) Monster->m_THLvl = m_PChar->getMod(MOD_TREASURE_HUNTER)+1;
			else if ((Monster->m_THPCID == m_PChar->id) && (Monster->m_THLvl < m_PChar->getMod(MOD_TREASURE_HUNTER))) Monster->m_THLvl = m_PChar->getMod(MOD_TREASURE_HUNTER);
			if (Monster->m_THLvl > 12) Monster->m_THLvl = 12;
	}

if someone with TH never attacked, highestTH is just 0

This is probably why I'm no good at coding. I just don't see how that's an auto attack. To me it just checks to see if char has trait. I'll take your word for it.