package handlers.skill;
import org.apache.log4j.Logger;
import ru.catssoftware.gameserver.handler.ICustomSkillHandler;
import ru.catssoftware.gameserver.handler.SkillHandler;
import ru.catssoftware.gameserver.model.L2Character;
import ru.catssoftware.gameserver.model.L2Skill;
import ru.catssoftware.gameserver.network.SystemMessageId;
import java.util.ArrayList;
import java.util.List;
public class SkillsCosts implements ICustomSkillHandler {
private static final Logger _log = Logger.getLogger(SkillsCosts.class);
private static final int[] skills_ids = {31557, 31606}; // айди скилов
private static final int[][] items_ids = {{4037, 1}, {57, 100}}; // предметы
public static List<ItemsList> items_list = new ArrayList<>();
public static void main(String[] args) {
SkillHandler.getInstance().registerCustomSkill(new SkillsCosts());
for (int[] items : items_ids) {
items_list.add(new ItemsList(items[0], items[1]));
}
_log.info("SkillHandlers: Loaded: SkillsCosts handlers");
_log.info("SkillHandlers: Loaded: " + items_list.size());
}
@Override
public void useSkill(L2Character activeChar, L2Skill skill, L2Character... targets) {
SkillHandler.getInstance().handleCustomSkill(skill, activeChar, targets);
for (ItemsList required_item : items_list) {
if (required_item == null)
continue;
if (required_item.count > 0) {
if (!activeChar.destroyItemByItemId("SkillLearn", required_item.id, required_item.count, null, true)) {
activeChar.sendPacket(SystemMessageId.FAILED_CHANGE_TARGET);
return;
}
}
}
}
@Override
public int[] getSkills() {
return skills_ids;
}
public static class ItemsList {
public int id;
public int count;
public ItemsList(int id, int count) {
this.id = id;
this.count = count;
}
}
}