Ребята, помогите сделать так, что бы NPC buffer бафал наборы бафов моментально или же быстрее стандарта (ибо по стандарту он бафает ровно так же, как и живой сапорт оч. медленно, особенно денсы и сонги)
Сборка l2phoenix:
package services.NPCBuffer;
import l2p.Config;
import l2p.extensions.multilang.CustomMessage;
import l2p.extensions.scripts.Functions;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.ThreadPoolManager;
import l2p.gameserver.cache.Msg;
import l2p.gameserver.instancemanager.TownManager;
import l2p.gameserver.model.L2Character;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.L2Skill;
import l2p.gameserver.model.L2Summon;
import l2p.gameserver.model.entity.residence.Residence;
import l2p.gameserver.model.entity.siege.Siege;
import l2p.gameserver.model.instances.L2NpcInstance;
import l2p.gameserver.serverpackets.MagicSkillLaunched;
import l2p.gameserver.serverpackets.MagicSkillUse;
import l2p.gameserver.tables.SkillTable;
import l2p.util.Files;
import l2p.util.Util;
public class Buffer extends Functions implements ScriptFile
{
/** Количество бафов в группах */
private static int grpCount1, grpCount2, grpCount3, grpCount4, grpCount5;
// Количество бафов в 1 и второй группах должно быть одинаковое
private static int buffs[][] = { // id, lvl, group
// Chants
{ 1251, 2, 5 }, // Chant of Fury
{ 1252, 3, 5 }, // Chant of Evasion
{ 1253, 3, 5 }, // Chant of Rage
{ 1284, 3, 5 }, // Chant of Revenge
{ 1308, 3, 5 }, // Chant of Predator
{ 1309, 3, 5 }, // Chant of Eagle
{ 1310, 4, 5 }, // Chant of Vampire
{ 1362, 1, 5 }, // Chant of Spirit
{ 1363, 1, 5 }, // Chant of Victory
{ 1390, 3, 5 }, // War Chant
{ 1391, 3, 5 }, // Earth Chant
// Combo Magic full
{ 1500, 1, 4 }, // Improved magic
{ 1503, 1, 4 }, // Improved shield defense
{ 1303, 2, 4 }, // Wild Magic
{ 1353, 1, 4 }, // Divine Protection
{ 4350, 4, 4 }, // Resist shok
{ 1504, 1, 4 }, // Improved movement
{ 1397, 3, 4 }, // Clarity
{ 4352, 2, 4 }, // Berserker spirit
{ 4346, 4, 4 }, // Mental shield
{ 4355, 3, 4 }, // Acumen
{ 1501, 1, 4 }, // Improved condition
{ 1352, 1, 4 }, // Elemental Protection
{ 4351, 6, 4 }, // Concentration
{ 1362, 1, 4 }, // Chant of spirit
{ 1461, 1, 4 }, // Chant of protection
{ 1284, 3, 4 }, // Chant of revenge
{ 1413, 1, 4 }, // Magnus chant
{ 264, 1, 4 }, // Song of earth
{ 267, 1, 4 }, // Song of Warding
{ 268, 1, 4 }, // Song of wind
{ 304, 1, 4 }, // Song of vitality
{ 363, 1, 4 }, // Song of meditation
{ 764, 1, 4 }, // Song of wind storm
{ 349, 1, 4 }, // Song of renewal
{ 305, 1, 4 }, // Song of vengeance
{ 273, 1, 4 }, // Dance of mystic
{ 276, 1, 4 }, // Dance of Concentration
{ 365, 1, 4 }, // Dance of siren
{ 915, 1, 4 }, // dance of Berserker
// Combo Fighter full
{ 1397, 3, 3 }, // Clarity
{ 4350, 4, 3 }, // Resist shok
{ 1500, 1, 3 }, // Improved magic
{ 1503, 1, 3 }, // Improved shield defense
{ 4346, 4, 3 }, // Mental shield
{ 4352, 2, 3 }, // Berserker spirit
{ 1352, 1, 3 }, // Elemental Protection
{ 764, 1, 3 }, // Song of wind storm
{ 349, 1, 3 }, // Song of renewal
{ 268, 1, 3 }, // Song of wind
{ 304, 1, 3 }, // Song of vitality
{ 269, 1, 3 }, // Song of hunter
{ 267, 1, 3 }, // Song of Warding
{ 264, 1, 3 }, // Song of Earth
{ 310, 1, 3 }, // Dance of the vampire
{ 271, 1, 3 }, // Dance of the warrior
{ 274, 1, 3 }, // Dance of the fire
{ 275, 1, 3 }, // Dance of the fury
{ 915, 1, 3 }, // dance of Berserker
{ 1461, 1, 3 }, // Chant of protection
{ 1519, 1, 3 }, // Chant of blood awakening
{ 1363, 1, 3 }, // Chant of victory
{ 1518, 1, 3 }, // Chant of critical attack
{ 1284, 3, 3 }, // Chant of revenge
{ 1517, 1, 3 }, // Chant of combat
{ 1535, 1, 3 }, // Chatn of movement
{ 1390, 3, 3 }, // War chant
{ 1310, 3, 3 }, // Chant of vampire
// Группа для магов 2
{ 1303, 2, 2 }, // Wild Magic
{ 4356, 3, 2 }, // Empower
{ 4355, 3, 2 }, // Acumen
{ 4352, 1, 2 }, // Berserker Spirit
{ 4346, 4, 2 }, // Mental Shield
{ 4351, 6, 2 }, // Concentration
{ 4342, 2, 2 }, // Wind Walk
{ 4347, 6, 2 }, // Bless the Body
{ 4348, 6, 2 }, // Bless the Soul
{ 4344, 3, 2 }, // Shield
{ 1397, 3, 2 }, // Clarity
{ 4350, 4, 2 }, // Resist Shock
// Группа для воинов 1
{ 1388, 3, 1 }, // Greater Might
{ 4345, 3, 1 }, // Might
{ 4344, 3, 1 }, // Shield
{ 4349, 2, 1 }, // Magic Barrier
{ 4342, 2, 1 }, // Wind Walk
{ 4347, 6, 1 }, // Bless the Body
{ 4357, 2, 1 }, // Haste
{ 4359, 3, 1 }, // Focus
{ 4358, 3, 1 }, // Guidance
{ 4360, 3, 1 }, // Death Whisper
{ 4354, 4, 1 }, // Vampiric Rage
{ 4346, 4, 1 } // Mental Shield
};
public void onLoad()
{
if(Config.SERVICES_BUFFER_ENABLED)
System.out.println("Loaded Service: NPCBuffer [state: activated]");
else
System.out.println("Loaded Service: NPCBuffer [state: deactivated]");
for(int buff[] : buffs)
switch(buff[2])
{
case 1:
grpCount1++;
break;
case 2:
grpCount2++;
break;
case 3:
grpCount3++;
break;
case 4:
grpCount4++;
break;
case 5:
grpCount5++;
break;
}
}
public void onReload()
{}
public void onShutdown()
{}
/**
* Бафает группу баффов, снимает плату за бафф, отображает диалог с кнопкой возврата к списку бафов
* @param args массив строк, где элемент 0 - id группы бафов
*/
public void doBuffGroup(String[] args)
{
L2Player player = (L2Player) getSelf();
L2Summon pet = player.getPet();
if(!checkCondition(player))
return;
if(player.getAdena() < Config.SERVICES_BUFFER_PRICE * (Integer.valueOf(args[1]) + 2))
{
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
player.reduceAdena(Config.SERVICES_BUFFER_PRICE * (Integer.valueOf(args[1]) + 2));
int time = 0;
int id_groups = Integer.valueOf(args[0]);
int select_id = Integer.valueOf(args[1]);
L2Skill skill;
for(int buff[] : buffs)
if(buff[2] == id_groups)
{
if(select_id == 0)
{
skill = SkillTable.getInstance().getInfo(buff[0], buff[1]);
time += skill.getHitTime();
ThreadPoolManager.getInstance().scheduleGeneral(new BeginBuff(player, skill, player), time);
time += 200;
}
if(select_id == 1)
{
if(pet == null)
return;
skill = SkillTable.getInstance().getInfo(buff[0], buff[1]);
time += skill.getHitTime();
ThreadPoolManager.getInstance().scheduleGeneral(new BeginPetBuff(player, skill, pet), time);
time += 200;
}
}
}
/**
* Бафает один бафф, снимает плату за бафф, отображает диалог с кнопкой возврата к списку бафов
* @param args массив строк: элемент 0 - id скида, элемент 1 - уровень скила
*/
public void doBuff(String[] args)
{
L2Player player = (L2Player) getSelf();
L2Summon pet = player.getPet();
if(!checkCondition(player))
return;
if(player.getAdena() < Config.SERVICES_BUFFER_PRICE)
{
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
try
{
int skill_id = Integer.valueOf(args[0]);
int skill_lvl = Integer.valueOf(args[1]);
int select_id = Integer.valueOf(args[2]);
L2Skill skill = SkillTable.getInstance().getInfo(skill_id, skill_lvl);
if(select_id == 0)
ThreadPoolManager.getInstance().scheduleGeneral(new BeginBuff(player, skill, player), skill.getHitTime());
if(select_id == 1)
{
if(pet == null)
return;
ThreadPoolManager.getInstance().scheduleGeneral(new BeginPetBuff(player, skill, pet), skill.getHitTime());
}
player.reduceAdena(Config.SERVICES_BUFFER_PRICE);
}
catch(Exception e)
{
player.sendMessage("Invalid skill!");
}
show(Files.read("data/scripts/services/NPCBuffer/buffs-ru.htm", player), player);
}
/**
* Проверяет возможность бафа персонажа.<BR>
* В случае невозможности бафа показывает игроку html с ошибкой и возвращает false.
* @param player персонаж
* @return true, если можно бафать персонажа
*/
public boolean checkCondition(L2Player player)
{
if(!Config.SERVICES_BUFFER_ENABLED || player == null)
return false;
String html;
// Проверяем по уровню
if(player.getLevel() > Config.SERVICES_BUFFER_MAX_LVL || player.getLevel() < Config.SERVICES_BUFFER_MIN_LVL)
{
html = Files.read("data/scripts/services/NPCBuffer/no-lvl.htm", player);
html = html.replace("%min_lvl%", Integer.toString(Config.SERVICES_BUFFER_MIN_LVL));
html = html.replace("%max_lvl%", Integer.toString(Config.SERVICES_BUFFER_MAX_LVL));
show(html, player);
return false;
}
//Можно ли юзать бафера во время осады?
if(!Config.SERVICES_BUFFER_SIEGE)
{
Residence castle = TownManager.getInstance().getClosestTown(getSelf()).getCastle();
Siege siege = castle.getSiege();
if(siege != null)
{
show(Files.read("data/scripts/services/NPCBuffer/no-siege.htm", player), player);
return false;
}
}
return true;
}
/* Выбор меню */
public void SelectMenu(String[] args)
{
int select_menu = Integer.valueOf(args[0]);
L2Player player = (L2Player) getSelf();
String html = null;
if(select_menu == 0)
html = Files.read("data/scripts/services/NPCBuffer/buffschar.htm", player);
if(select_menu == 1)
{
if(Config.SERVICES_BUFFER_PET_ENABLED != true)
return;
if(player.getPet() == null)
return;
html = Files.read("data/scripts/services/NPCBuffer/buffspet.htm", player);
}
assert html != null;
html = html.replace("%grp_price1%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount1 + 2)));
html = html.replace("%grp_price2%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount2 + 2)));
html = html.replace("%grp_price3%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount3 + 2)));
html = html.replace("%grp_price4%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount4 + 2)));
html = html.replace("%grp_price5%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount5 + 2)));
html = html.replace("%buffs_in_grp1%", Integer.toString(grpCount1));
html = html.replace("%buffs_in_grp2%", Integer.toString(grpCount2));
html = html.replace("%buffs_in_grp3%", Integer.toString(grpCount3));
html = html.replace("%buffs_in_grp4%", Integer.toString(grpCount4));
html = html.replace("%buffs_in_grp5%", Integer.toString(grpCount5));
html = html.replace("%price%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE));
show(html, player);
}
/* Показывает страницу с выбором кого бафать. */
public void SelectBuffs()
{
L2Player player = (L2Player) getSelf();
if(!checkCondition(player))
return;
show(Files.read("data/scripts/services/NPCBuffer/buffs.htm", player), player);
}
/**
* Генерит ссылку, которая в дальнейшем аппендится эвент менеждерам
* @return html код ссылки
*/
public String OutDia()
{
if(!Config.SERVICES_BUFFER_ENABLED)
return "";
String append = "<br><a action=\"bypass -h scripts_services.NPCBuffer.Buffer:SelectBuffs\">";
append += new CustomMessage("scripts.services.NPCBuffer.Buffer.selectBuffs", getSelf());
append += "</a>";
return append;
}
// Далее идут аппенды диалогов эвент гейткиперам
public String DialogAppend_12741(Integer val)
{
if(val != 0)
return "";
return OutDia();
}
public class BeginBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Player _target;
public BeginBuff(L2Character buffer, L2Skill skill, L2Player target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
if(_target.isInOlympiadMode())
return;
_buffer.broadcastPacket(new MagicSkillUse(_buffer, _target, _skill.getDisplayId(), _skill.getLevel(), _skill.getHitTime(), 0));
ThreadPoolManager.getInstance().scheduleGeneral(new EndBuff(_buffer, _skill, _target), _skill.getHitTime());
}
}
public class EndBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Player _target;
public EndBuff(L2Character buffer, L2Skill skill, L2Player target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
_skill.getEffects(_buffer, _target, false, false);
_buffer.broadcastPacket(new MagicSkillLaunched(_buffer.getObjectId(), _skill.getId(), _skill.getLevel(), _target, _skill.isOffensive()));
}
}
public class BeginPetBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Summon _target;
public BeginPetBuff(L2Character buffer, L2Skill skill, L2Summon target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
_buffer.broadcastPacket(new MagicSkillUse(_buffer, _target, _skill.getDisplayId(), _skill.getLevel(), _skill.getHitTime(), 0));
ThreadPoolManager.getInstance().scheduleGeneral(new EndPetBuff(_buffer, _skill, _target), _skill.getHitTime());
}
}
public class EndPetBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Summon _target;
public EndPetBuff(L2Character buffer, L2Skill skill, L2Summon target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
_skill.getEffects(_buffer, _target, false, false);
_buffer.broadcastPacket(new MagicSkillLaunched(_buffer.getObjectId(), _skill.getId(), _skill.getLevel(), _target, _skill.isOffensive()));
}
}
}
Добавлено через 1 минуту
что надо изменить-добавить, что бы увеличить скорость накладывания бафа ?
пробовал это:
time += 200(1) , не помогает
Сборка l2phoenix:
package services.NPCBuffer;
import l2p.Config;
import l2p.extensions.multilang.CustomMessage;
import l2p.extensions.scripts.Functions;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.ThreadPoolManager;
import l2p.gameserver.cache.Msg;
import l2p.gameserver.instancemanager.TownManager;
import l2p.gameserver.model.L2Character;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.L2Skill;
import l2p.gameserver.model.L2Summon;
import l2p.gameserver.model.entity.residence.Residence;
import l2p.gameserver.model.entity.siege.Siege;
import l2p.gameserver.model.instances.L2NpcInstance;
import l2p.gameserver.serverpackets.MagicSkillLaunched;
import l2p.gameserver.serverpackets.MagicSkillUse;
import l2p.gameserver.tables.SkillTable;
import l2p.util.Files;
import l2p.util.Util;
public class Buffer extends Functions implements ScriptFile
{
/** Количество бафов в группах */
private static int grpCount1, grpCount2, grpCount3, grpCount4, grpCount5;
// Количество бафов в 1 и второй группах должно быть одинаковое
private static int buffs[][] = { // id, lvl, group
// Chants
{ 1251, 2, 5 }, // Chant of Fury
{ 1252, 3, 5 }, // Chant of Evasion
{ 1253, 3, 5 }, // Chant of Rage
{ 1284, 3, 5 }, // Chant of Revenge
{ 1308, 3, 5 }, // Chant of Predator
{ 1309, 3, 5 }, // Chant of Eagle
{ 1310, 4, 5 }, // Chant of Vampire
{ 1362, 1, 5 }, // Chant of Spirit
{ 1363, 1, 5 }, // Chant of Victory
{ 1390, 3, 5 }, // War Chant
{ 1391, 3, 5 }, // Earth Chant
// Combo Magic full
{ 1500, 1, 4 }, // Improved magic
{ 1503, 1, 4 }, // Improved shield defense
{ 1303, 2, 4 }, // Wild Magic
{ 1353, 1, 4 }, // Divine Protection
{ 4350, 4, 4 }, // Resist shok
{ 1504, 1, 4 }, // Improved movement
{ 1397, 3, 4 }, // Clarity
{ 4352, 2, 4 }, // Berserker spirit
{ 4346, 4, 4 }, // Mental shield
{ 4355, 3, 4 }, // Acumen
{ 1501, 1, 4 }, // Improved condition
{ 1352, 1, 4 }, // Elemental Protection
{ 4351, 6, 4 }, // Concentration
{ 1362, 1, 4 }, // Chant of spirit
{ 1461, 1, 4 }, // Chant of protection
{ 1284, 3, 4 }, // Chant of revenge
{ 1413, 1, 4 }, // Magnus chant
{ 264, 1, 4 }, // Song of earth
{ 267, 1, 4 }, // Song of Warding
{ 268, 1, 4 }, // Song of wind
{ 304, 1, 4 }, // Song of vitality
{ 363, 1, 4 }, // Song of meditation
{ 764, 1, 4 }, // Song of wind storm
{ 349, 1, 4 }, // Song of renewal
{ 305, 1, 4 }, // Song of vengeance
{ 273, 1, 4 }, // Dance of mystic
{ 276, 1, 4 }, // Dance of Concentration
{ 365, 1, 4 }, // Dance of siren
{ 915, 1, 4 }, // dance of Berserker
// Combo Fighter full
{ 1397, 3, 3 }, // Clarity
{ 4350, 4, 3 }, // Resist shok
{ 1500, 1, 3 }, // Improved magic
{ 1503, 1, 3 }, // Improved shield defense
{ 4346, 4, 3 }, // Mental shield
{ 4352, 2, 3 }, // Berserker spirit
{ 1352, 1, 3 }, // Elemental Protection
{ 764, 1, 3 }, // Song of wind storm
{ 349, 1, 3 }, // Song of renewal
{ 268, 1, 3 }, // Song of wind
{ 304, 1, 3 }, // Song of vitality
{ 269, 1, 3 }, // Song of hunter
{ 267, 1, 3 }, // Song of Warding
{ 264, 1, 3 }, // Song of Earth
{ 310, 1, 3 }, // Dance of the vampire
{ 271, 1, 3 }, // Dance of the warrior
{ 274, 1, 3 }, // Dance of the fire
{ 275, 1, 3 }, // Dance of the fury
{ 915, 1, 3 }, // dance of Berserker
{ 1461, 1, 3 }, // Chant of protection
{ 1519, 1, 3 }, // Chant of blood awakening
{ 1363, 1, 3 }, // Chant of victory
{ 1518, 1, 3 }, // Chant of critical attack
{ 1284, 3, 3 }, // Chant of revenge
{ 1517, 1, 3 }, // Chant of combat
{ 1535, 1, 3 }, // Chatn of movement
{ 1390, 3, 3 }, // War chant
{ 1310, 3, 3 }, // Chant of vampire
// Группа для магов 2
{ 1303, 2, 2 }, // Wild Magic
{ 4356, 3, 2 }, // Empower
{ 4355, 3, 2 }, // Acumen
{ 4352, 1, 2 }, // Berserker Spirit
{ 4346, 4, 2 }, // Mental Shield
{ 4351, 6, 2 }, // Concentration
{ 4342, 2, 2 }, // Wind Walk
{ 4347, 6, 2 }, // Bless the Body
{ 4348, 6, 2 }, // Bless the Soul
{ 4344, 3, 2 }, // Shield
{ 1397, 3, 2 }, // Clarity
{ 4350, 4, 2 }, // Resist Shock
// Группа для воинов 1
{ 1388, 3, 1 }, // Greater Might
{ 4345, 3, 1 }, // Might
{ 4344, 3, 1 }, // Shield
{ 4349, 2, 1 }, // Magic Barrier
{ 4342, 2, 1 }, // Wind Walk
{ 4347, 6, 1 }, // Bless the Body
{ 4357, 2, 1 }, // Haste
{ 4359, 3, 1 }, // Focus
{ 4358, 3, 1 }, // Guidance
{ 4360, 3, 1 }, // Death Whisper
{ 4354, 4, 1 }, // Vampiric Rage
{ 4346, 4, 1 } // Mental Shield
};
public void onLoad()
{
if(Config.SERVICES_BUFFER_ENABLED)
System.out.println("Loaded Service: NPCBuffer [state: activated]");
else
System.out.println("Loaded Service: NPCBuffer [state: deactivated]");
for(int buff[] : buffs)
switch(buff[2])
{
case 1:
grpCount1++;
break;
case 2:
grpCount2++;
break;
case 3:
grpCount3++;
break;
case 4:
grpCount4++;
break;
case 5:
grpCount5++;
break;
}
}
public void onReload()
{}
public void onShutdown()
{}
/**
* Бафает группу баффов, снимает плату за бафф, отображает диалог с кнопкой возврата к списку бафов
* @param args массив строк, где элемент 0 - id группы бафов
*/
public void doBuffGroup(String[] args)
{
L2Player player = (L2Player) getSelf();
L2Summon pet = player.getPet();
if(!checkCondition(player))
return;
if(player.getAdena() < Config.SERVICES_BUFFER_PRICE * (Integer.valueOf(args[1]) + 2))
{
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
player.reduceAdena(Config.SERVICES_BUFFER_PRICE * (Integer.valueOf(args[1]) + 2));
int time = 0;
int id_groups = Integer.valueOf(args[0]);
int select_id = Integer.valueOf(args[1]);
L2Skill skill;
for(int buff[] : buffs)
if(buff[2] == id_groups)
{
if(select_id == 0)
{
skill = SkillTable.getInstance().getInfo(buff[0], buff[1]);
time += skill.getHitTime();
ThreadPoolManager.getInstance().scheduleGeneral(new BeginBuff(player, skill, player), time);
time += 200;
}
if(select_id == 1)
{
if(pet == null)
return;
skill = SkillTable.getInstance().getInfo(buff[0], buff[1]);
time += skill.getHitTime();
ThreadPoolManager.getInstance().scheduleGeneral(new BeginPetBuff(player, skill, pet), time);
time += 200;
}
}
}
/**
* Бафает один бафф, снимает плату за бафф, отображает диалог с кнопкой возврата к списку бафов
* @param args массив строк: элемент 0 - id скида, элемент 1 - уровень скила
*/
public void doBuff(String[] args)
{
L2Player player = (L2Player) getSelf();
L2Summon pet = player.getPet();
if(!checkCondition(player))
return;
if(player.getAdena() < Config.SERVICES_BUFFER_PRICE)
{
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
try
{
int skill_id = Integer.valueOf(args[0]);
int skill_lvl = Integer.valueOf(args[1]);
int select_id = Integer.valueOf(args[2]);
L2Skill skill = SkillTable.getInstance().getInfo(skill_id, skill_lvl);
if(select_id == 0)
ThreadPoolManager.getInstance().scheduleGeneral(new BeginBuff(player, skill, player), skill.getHitTime());
if(select_id == 1)
{
if(pet == null)
return;
ThreadPoolManager.getInstance().scheduleGeneral(new BeginPetBuff(player, skill, pet), skill.getHitTime());
}
player.reduceAdena(Config.SERVICES_BUFFER_PRICE);
}
catch(Exception e)
{
player.sendMessage("Invalid skill!");
}
show(Files.read("data/scripts/services/NPCBuffer/buffs-ru.htm", player), player);
}
/**
* Проверяет возможность бафа персонажа.<BR>
* В случае невозможности бафа показывает игроку html с ошибкой и возвращает false.
* @param player персонаж
* @return true, если можно бафать персонажа
*/
public boolean checkCondition(L2Player player)
{
if(!Config.SERVICES_BUFFER_ENABLED || player == null)
return false;
String html;
// Проверяем по уровню
if(player.getLevel() > Config.SERVICES_BUFFER_MAX_LVL || player.getLevel() < Config.SERVICES_BUFFER_MIN_LVL)
{
html = Files.read("data/scripts/services/NPCBuffer/no-lvl.htm", player);
html = html.replace("%min_lvl%", Integer.toString(Config.SERVICES_BUFFER_MIN_LVL));
html = html.replace("%max_lvl%", Integer.toString(Config.SERVICES_BUFFER_MAX_LVL));
show(html, player);
return false;
}
//Можно ли юзать бафера во время осады?
if(!Config.SERVICES_BUFFER_SIEGE)
{
Residence castle = TownManager.getInstance().getClosestTown(getSelf()).getCastle();
Siege siege = castle.getSiege();
if(siege != null)
{
show(Files.read("data/scripts/services/NPCBuffer/no-siege.htm", player), player);
return false;
}
}
return true;
}
/* Выбор меню */
public void SelectMenu(String[] args)
{
int select_menu = Integer.valueOf(args[0]);
L2Player player = (L2Player) getSelf();
String html = null;
if(select_menu == 0)
html = Files.read("data/scripts/services/NPCBuffer/buffschar.htm", player);
if(select_menu == 1)
{
if(Config.SERVICES_BUFFER_PET_ENABLED != true)
return;
if(player.getPet() == null)
return;
html = Files.read("data/scripts/services/NPCBuffer/buffspet.htm", player);
}
assert html != null;
html = html.replace("%grp_price1%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount1 + 2)));
html = html.replace("%grp_price2%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount2 + 2)));
html = html.replace("%grp_price3%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount3 + 2)));
html = html.replace("%grp_price4%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount4 + 2)));
html = html.replace("%grp_price5%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE * (grpCount5 + 2)));
html = html.replace("%buffs_in_grp1%", Integer.toString(grpCount1));
html = html.replace("%buffs_in_grp2%", Integer.toString(grpCount2));
html = html.replace("%buffs_in_grp3%", Integer.toString(grpCount3));
html = html.replace("%buffs_in_grp4%", Integer.toString(grpCount4));
html = html.replace("%buffs_in_grp5%", Integer.toString(grpCount5));
html = html.replace("%price%", Util.formatAdena(Config.SERVICES_BUFFER_PRICE));
show(html, player);
}
/* Показывает страницу с выбором кого бафать. */
public void SelectBuffs()
{
L2Player player = (L2Player) getSelf();
if(!checkCondition(player))
return;
show(Files.read("data/scripts/services/NPCBuffer/buffs.htm", player), player);
}
/**
* Генерит ссылку, которая в дальнейшем аппендится эвент менеждерам
* @return html код ссылки
*/
public String OutDia()
{
if(!Config.SERVICES_BUFFER_ENABLED)
return "";
String append = "<br><a action=\"bypass -h scripts_services.NPCBuffer.Buffer:SelectBuffs\">";
append += new CustomMessage("scripts.services.NPCBuffer.Buffer.selectBuffs", getSelf());
append += "</a>";
return append;
}
// Далее идут аппенды диалогов эвент гейткиперам
public String DialogAppend_12741(Integer val)
{
if(val != 0)
return "";
return OutDia();
}
public class BeginBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Player _target;
public BeginBuff(L2Character buffer, L2Skill skill, L2Player target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
if(_target.isInOlympiadMode())
return;
_buffer.broadcastPacket(new MagicSkillUse(_buffer, _target, _skill.getDisplayId(), _skill.getLevel(), _skill.getHitTime(), 0));
ThreadPoolManager.getInstance().scheduleGeneral(new EndBuff(_buffer, _skill, _target), _skill.getHitTime());
}
}
public class EndBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Player _target;
public EndBuff(L2Character buffer, L2Skill skill, L2Player target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
_skill.getEffects(_buffer, _target, false, false);
_buffer.broadcastPacket(new MagicSkillLaunched(_buffer.getObjectId(), _skill.getId(), _skill.getLevel(), _target, _skill.isOffensive()));
}
}
public class BeginPetBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Summon _target;
public BeginPetBuff(L2Character buffer, L2Skill skill, L2Summon target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
_buffer.broadcastPacket(new MagicSkillUse(_buffer, _target, _skill.getDisplayId(), _skill.getLevel(), _skill.getHitTime(), 0));
ThreadPoolManager.getInstance().scheduleGeneral(new EndPetBuff(_buffer, _skill, _target), _skill.getHitTime());
}
}
public class EndPetBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Summon _target;
public EndPetBuff(L2Character buffer, L2Skill skill, L2Summon target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
_skill.getEffects(_buffer, _target, false, false);
_buffer.broadcastPacket(new MagicSkillLaunched(_buffer.getObjectId(), _skill.getId(), _skill.getLevel(), _target, _skill.isOffensive()));
}
}
}
Добавлено через 1 минуту
что надо изменить-добавить, что бы увеличить скорость накладывания бафа ?
пробовал это:
time += 200(1) , не помогает