rafaeru
Active Member
I try to do loot for most damage player. I found this but i dont know how damageMap work. Any hints ?
I work on TFS 0.3.6
I work on TFS 0.3.6
C++:
DeathList Creature::getKillers()
{
DeathList list;
Creature* lhc = NULL;
if(!(lhc = g_game.getCreatureByID(lastHitCreature)))
list.push_back(DeathEntry(getCombatName(lastDamageSource), 0));
else
list.push_back(DeathEntry(lhc, 0));
int32_t requiredTime = g_config.getNumber(ConfigManager::DEATHLIST_REQUIRED_TIME);
int64_t now = OTSYS_TIME();
CountBlock_t cb;
for(CountMap::const_iterator it = damageMap.begin(); it != damageMap.end(); ++it)
{
cb = it->second;
if((now - cb.ticks) > requiredTime)
continue;
Creature* mdc = g_game.getCreatureByID(it->first);
if(!mdc || mdc == lhc || (lhc && (mdc->getMaster() == lhc || lhc->getMaster() == mdc)))
continue;
bool deny = false;
for(DeathList::iterator fit = list.begin(); fit != list.end(); ++fit)
{
if(fit->isNameKill())
continue;
Creature* tmp = fit->getKillerCreature();
if(!(mdc->getName() == tmp->getName() && mdc->getMaster() == tmp->getMaster()) &&
(!mdc->getMaster() || (mdc->getMaster() != tmp && mdc->getMaster() != tmp->getMaster()))
&& (mdc->getSummonCount() <= 0 || tmp->getMaster() != mdc))
continue;
deny = true;
break;
}
if(!deny)
list.push_back(DeathEntry(mdc, cb.total));
}
if(list.size() > 1)
std::sort(list.begin() + 1, list.end(), DeathLessThan());
return list;
}
[code]