Treasure Hunter how does it work on DSP?

Thief
altnob
Posts: 10
Joined: Mon Jul 22, 2013 6:58 pm

Treasure Hunter how does it work on DSP?

Post by altnob » Fri Aug 30, 2013 5:17 pm

I'm curiouis to know how TH works on DSP can someone fill me in?

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: Treasure Hunter how does it work on DSP?

Post by atom0s » Fri Aug 30, 2013 6:10 pm

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)

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Treasure Hunter how does it work on DSP?

Post by kjLotus » Fri Aug 30, 2013 6:13 pm

it also does not increase with chance on hit

altnob
Posts: 10
Joined: Mon Jul 22, 2013 6:58 pm

Re: Treasure Hunter how does it work on DSP?

Post by altnob » Fri Aug 30, 2013 7:58 pm

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?

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Treasure Hunter how does it work on DSP?

Post by kjLotus » Fri Aug 30, 2013 10:11 pm

think it only does that if the mob has had TH applied to it (as in atom0s' post), too lazy to check

altnob
Posts: 10
Joined: Mon Jul 22, 2013 6:58 pm

Re: Treasure Hunter how does it work on DSP?

Post by altnob » Sat Aug 31, 2013 12:19 am

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.

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Treasure Hunter how does it work on DSP?

Post by kjLotus » Sat Aug 31, 2013 12:32 am

checked da codez
fourth line you posted

uint8 highestTH = PMob->m_THLvl;

this is zero if a thf never hit

altnob
Posts: 10
Joined: Mon Jul 22, 2013 6:58 pm

Re: Treasure Hunter how does it work on DSP?

Post by altnob » Sat Aug 31, 2013 12:57 am

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

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Treasure Hunter how does it work on DSP?

Post by kjLotus » Sat Aug 31, 2013 1:17 am

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

altnob
Posts: 10
Joined: Mon Jul 22, 2013 6:58 pm

Re: Treasure Hunter how does it work on DSP?

Post by altnob » Sat Aug 31, 2013 10:27 am

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.

Post Reply