{
if(!Config.EVENT_BOUNTY_HUNTERS_ENABLED)
{
return;
}
L2NpcTemplate target;
double mod = 1.;
if(id == 0)
{
GArray<L2NpcTemplate> monsters = NpcTable.getAllOfLevel(player.getLevel());
if(monsters == null || monsters.isEmpty())
{
show(new CustomMessage("scripts.events.bountyhunters.NoTargets", player), player);
return;
}
GArray<L2NpcTemplate> targets = new GArray<L2NpcTemplate>();
for(L2NpcTemplate npc : monsters)
{
if(checkTarget(npc))
{
targets.add(npc);
}
}
if(targets.isEmpty())
{
show(new CustomMessage("scripts.events.bountyhunters.NoTargets", player), player);
return;
}
target = targets.get(Rnd.get(targets.size()));
}
else
{
target = NpcTable.getTemplate(id);
if(target == null || !checkTarget(target))
{
show(new CustomMessage("scripts.events.bountyhunters.WrongTarget", player), player);
return;
}
if(player.getLevel() - target.level > 5)
{
show(new CustomMessage("scripts.events.bountyhunters.TooEasy", player), player);
return;
}
mod = 0.5 * (10 + target.level - player.getLevel()) / 10.;
}
int mobcount = target.level + Rnd.get(25, 50);
player.setVar("bhMonstersId", String.valueOf(target.getNpcId()));
player.setVar("bhMonstersNeeded", String.valueOf(mobcount));
player.setVar("bhMonstersKilled", "0");
int fails = player.getVar("bhfails") == null ? 0 : Integer.parseInt(player.getVar("bhfails")) * 5;
int success = player.getVar("bhsuccess") == null ? 0 : Integer.parseInt(player.getVar("bhsuccess")) * 5;
double reputation = Math.min(Math.max((100 + success - fails) / 100., .25), 2.) * mod;