02-20-2010, 02:17 PM
Goodday Написал:О ёпт там с 14** ревы пару минут переписать под эту
PHP код:<?php
package services.PVPCommunityBoard;
import l2p.Config;
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.olympiad.Olympiad;
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.skills.effects.EffectTemplate;
import l2p.gameserver.tables.SkillTable;
import l2p.util.Files;
import l2p.util.Util;
public class CBBuffer extends Functions implements ScriptFile
{
public L2NpcInstance npc;
/** Количество бафов в группах */
private static int CAST_TIME = 0;
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
{1461, 3, 5}, // Chant of protect
{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
// Songs
{264, 1, 4}, // Song of Earth
{265, 1, 4}, // Song of Life
{266, 1, 4}, // Song of Water
{267, 1, 4}, // Song of Warding
{268, 1, 4}, // Song of Wind
{269, 1, 4}, // Song of Hunter
{270, 1, 4}, // Song of Invocation
{304, 1, 4}, // Song of Vitality
{306, 1, 4}, // Song of Flame Guard
{308, 1, 4}, // Song of Storm Guard
{349, 1, 4}, // Song of Renewal
{363, 1, 4}, // Song of Meditation
{364, 1, 4}, // Song of Champion
// Dances
{271, 1, 3}, // Dance of Warrior
{272, 1, 3}, // Dance of Inspiration
{273, 1, 3}, // Dance of Mystic
{274, 1, 3}, // Dance of Fire
{275, 1, 3}, // Dance of Fury
{276, 1, 3}, // Dance of Concentration
{277, 1, 3}, // Dance of Light
{307, 1, 3}, // Dance of Aqua Guard
{309, 1, 3}, // Dance of Earth Guard
{310, 1, 3}, // Dance of Vampire
{311, 1, 3}, // Dance of Protection
{365, 1, 3}, // Dance of Siren
// Группа для магов 2
{ 7059, 1, 2 }, // Wild Magic
{ 4356, 3, 2 }, // Empower
{ 4355, 3, 2 }, // Acumen
{ 4352, 1, 2 }, // Berserker Spirit
{ 4346, 4, 2 }, // Mental Shield
{ 4344, 3, 2 }, // Shield
{ 4351, 6, 2 }, // Concentration
{ 4342, 2, 2 }, // Wind Walk
{ 4347, 6, 2 }, // Bless the Body
{ 4348, 6, 2 }, // Bless the Soul
{ 4350, 4, 2 }, // Resist Shock
{ 4350, 4, 2 }, // Resist Shock
{ 4347, 6, 2 }, // Bless the Body
{ 4348, 6, 2 }, // Bless the Soul
{ 4349, 2, 2 }, // Magic Barrier
{ 1391, 3, 2 }, // Earth Chant
{ 1252, 3, 2 }, // Chant of Evasion
{ 1284, 3, 2 }, // Chant of Revenge
{ 1362, 1, 2 }, // Chant of Spirit
{ 1413, 1, 2 }, // Chant of Victory
{ 1323, 1, 2 }, // Noblesse of Blessing
{ 273, 1, 2 }, // Dance of Mystic
{ 276, 1, 2 }, // Dance of Concentration
{ 365, 1, 2 }, // Dance of Siren
{ 264, 1, 2 }, // Song of Earth
{ 266, 1, 2 }, // Song of Water
{ 267, 1, 2 }, // Song of Warding
{ 268, 1, 2 }, // Song of Wind
{ 304, 1, 2 }, // Song of Vitality
{ 306, 1, 2 }, // Song of Flame Guard
{ 308, 1, 2 }, // Song of Storm Guard
{ 349, 1, 2 }, // Song of Renewal
{ 363, 1, 2 }, // Song of Meditation
{ 4554, 4, 2 }, // Hot Springs Malaria 4 lvl
// Группа для воинов 1
{ 4345, 3, 1 }, // Might
{ 4344, 3, 1 }, // Shield
{ 4349, 2, 1 }, // Magic Barrier
{ 4342, 2, 1 }, // Wind Walk
{ 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
{ 4352, 1, 1 }, // Berserker Spirit
{ 4350, 4, 1 }, // Resist Shock
{ 4347, 6, 1 }, // Bless the Body
{ 4348, 6, 1 }, // Bless the Soul
{ 1391, 3, 1 }, // Earth Chant
{ 1252, 3, 1 }, // Chant of Evasion
{ 1284, 3, 1 }, // Chant of Revenge
{ 1362, 1, 1 }, // Chant of Spirit
{ 1363, 1, 1 }, // Chant of Victory
{ 1323, 1, 1 }, // Noblesse of Blessing
{ 271, 1, 1 }, // Dance of Warrior
{ 274, 1, 1 }, // Dance of Fire
{ 275, 1, 1 }, // Dance of Fury
{ 264, 1, 1 }, // Song of Earth
{ 267, 1, 1 }, // Song of Warding
{ 268, 1, 1 }, // Song of Wind
{ 269, 1, 1 }, // Song of Hunter
{ 304, 1, 1 }, // Song of Vitality
{ 306, 1, 1 }, // Song of Flame Guard
{ 308, 1, 1 }, // Song of Storm Guard
{ 349, 1, 1 }, // Song of Renewal
{ 364, 1, 1 } // Song of Champion
};
public void onLoad()
{
if(Config.SERVICES_BUFFER_ENABLED)
System.out.println("Loaded Service: CBBuffer [state: ON]");
else
System.out.println("Loaded Service: CBBuffer [state: OFF]");
for(final 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(final String[] args)
{
//final L2Player player = (L2Player) self;
final L2Player player = (L2Player)getSelf();
final 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;
final int id_groups = Integer.valueOf(args[0]);
final int select_id = Integer.valueOf(args[1]);
L2Skill skill;
for(final 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), CAST_TIME);
time += 0;
}
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), CAST_TIME);
time += 0;
}
}
}
/**
* Бафает один бафф, снимает плату за бафф, отображает диалог с кнопкой возврата к списку бафов
*
* @param args
* массив строк: элемент 0 - id скида, элемент 1 - уровень скила
*/
public void doBuff(final String[] args)
{
//final L2Player player = (L2Player) self;
final L2Player player = (L2Player)getSelf();
final 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
{
final int skill_id = Integer.valueOf(args[0]);
final int skill_lvl = Integer.valueOf(args[1]);
final int select_id = Integer.valueOf(args[2]);
final L2Skill skill = SkillTable.getInstance().getInfo(skill_id, skill_lvl);
if(select_id == 0)
ThreadPoolManager.getInstance().scheduleGeneral(new BeginBuff(player, skill, player), CAST_TIME);
if(select_id == 1)
{
if(pet == null)
return;
ThreadPoolManager.getInstance().scheduleGeneral(new BeginPetBuff(player, skill, pet), CAST_TIME);
}
player.reduceAdena(Config.SERVICES_BUFFER_PRICE);
}
catch(final Exception e)
{
player.sendMessage("Invalid skill!");
}
}
/**
* Проверяет возможность бафа персонажа.<BR>
* В случае невозможности бафа показывает игроку html с ошибкой и возвращает false.
*
* @param player
* персонаж
* @return true, если можно бафать персонажа
*/
public boolean checkCondition(final L2Player player)
{
if( !Config.SERVICES_BUFFER_ENABLED || player == null)
return false;
if(player.getOlympiadGameId() != -1 || Olympiad.isRegisteredInComp(player))
{
show("Buff sell are closed for Oly time.", player);
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)
{
//final Residence castle = TownManager.getInstance().getClosestTown(self).getCastle();
//final Siege siege = castle.getSiege();
final Residence castle = TownManager.getInstance().getClosestTown(getSelf()).getCastle();
final Siege siege = castle.getSiege();
if(siege != null && siege.isInProgress())
{
show(Files.read("data/scripts/services/NPCBuffer/no-siege.htm", player), player);
return false;
}
}
return true;
}
/* Выбор меню */
public void SelectMenu(final String[] args)
{
final int select_menu = Integer.valueOf(args[0]);
//final L2Player player = (L2Player) self;
final 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 class BeginBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Player _target;
public BeginBuff(final L2Character buffer, final L2Skill skill, final L2Player target)
{
_buffer = buffer;
_skill = skill;
_target = target;
}
public void run()
{
if(_target.isInOlympiadMode() || _target.isAttackingNow() || _target.isCastingNow() || _target.isInCombat())
return;
//_buffer.broadcastPacket(new MagicSkillUse(_buffer, _target, _skill.getDisplayId(), _skill.getLevel(), _skill.getHitTime(), 0));
ThreadPoolManager.getInstance().scheduleGeneral(new EndBuff(_buffer, _skill, _target), CAST_TIME);
}
}
public class EndBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Player _target;
public EndBuff(final L2Character buffer, final L2Skill skill, final 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(final L2Character buffer, final L2Skill skill, final 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), CAST_TIME);
}
}
public class EndPetBuff implements Runnable
{
L2Character _buffer;
L2Skill _skill;
L2Summon _target;
public EndPetBuff(final L2Character buffer, final L2Skill skill, final 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()));
}
}
}
PHP код:
<?php
package services.PVPCommunityBoard;
import javolution.util.FastMap;
import l2p.Config;
import l2p.extensions.scripts.Functions;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.cache.Msg;
import l2p.gameserver.idfactory.IdFactory;
import l2p.gameserver.instancemanager.InstancedZoneManager;
import l2p.gameserver.instancemanager.TownManager;
import l2p.gameserver.instancemanager.ZoneManager;
import l2p.gameserver.model.entity.residence.TeleportLocation;
import l2p.gameserver.model.L2Effect;
import l2p.gameserver.model.L2Object;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.L2Spawn;
import l2p.gameserver.model.L2Zone;
import l2p.gameserver.model.Reflection;
import l2p.gameserver.model.L2Zone.ZoneType;
import l2p.gameserver.model.entity.SevenSigns;
import l2p.gameserver.model.entity.residence.Castle;
import l2p.gameserver.model.entity.olympiad.Olympiad;
import l2p.gameserver.model.entity.residence.Residence;
import l2p.gameserver.model.entity.siege.Siege;
import l2p.gameserver.model.instances.L2DoorInstance;
import l2p.gameserver.model.items.L2ItemInstance;
import l2p.gameserver.model.instances.L2ReflectionBossInstance;
import l2p.gameserver.serverpackets.SystemMessage;
import l2p.gameserver.tables.NpcTable;
import l2p.gameserver.tables.ReflectionTable;
import l2p.util.Location;
public class CBUtil extends Functions implements ScriptFile
{
public void onLoad()
{
System.out.println("CB Utilites Loaded [state: OK]");
}
public void onReload()
{}
public void onShutdown()
{}
/**
* Перемещает за плату в аденах
*
* @param x
* @param y
* @param z
* @param price
*/
public void Gatekeeper(final String[] param)
{
final L2Player player = (L2Player) getSelf();
if(player == null)
{
return;
}
final int price = Integer.parseInt(param[3]);
if(player.isActionsDisabled() || player.isSitting())
{
return;
}
if(price > 0 && player.getAdena() < price)
{
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
if(player.getMountType() == 2)
{
player.sendMessage("Телепортация верхом на виверне невозможна.");
return;
}
/*
* Затычка, npc Mozella не ТПшит чаров уровень которых превышает заданный в конфиге
* Off Like >= 56 lvl, данные по ограничению lvl'a устанавливаются в altsettings.properties.
*/
if(player.getLastNpc() != null)
{
final int mozella_cruma = 30483; // NPC Mozella id 30483
if(player.getLastNpc().getNpcId() == mozella_cruma && player.getLevel() >= Config.CRUMA_GATEKEEPER_LVL)
{
show("data/html/teleporter/30483-no.htm", player);
return;
}
}
final int x = Integer.parseInt(param[0]);
final int y = Integer.parseInt(param[1]);
final int z = Integer.parseInt(param[2]);
if(player.getOlympiadGameId() != -1 || Olympiad.isRegisteredInComp(player))
{
player.sendMessage("Дождитесь окончания боя на олимпиаде!");
return;
}
if(player.isAttackingNow() || player.isCastingNow() || player.isInCombat())
{
player.sendMessage("В бою телепортация запрещена!");
return;
}
final Castle castle = TownManager.getInstance().getClosestTown(x, y).getCastle();
if(castle != null && castle.getSiege().isInProgress())
{
// Определяем, в город ли телепортируется чар
boolean teleToTown = false;
int townId = 0;
for(final L2Zone town : ZoneManager.getInstance().getZoneByType(ZoneType.Town))
{
if(town.checkIfInZone(x, y))
{
teleToTown = true;
townId = town.getIndex();
break;
}
}
if(teleToTown && townId == castle.getTown())
{
player.sendPacket(new SystemMessage(SystemMessage.YOU_CANNOT_TELEPORT_TO_A_VILLAGE_THAT_IS_IN_A_SIEGE));
return;
}
}
//final Location pos = GeoEngine.findPointToStay(x, y, z, 50, 100);
if(price > 0)
{
player.reduceAdena(price);
}
player.teleToLocation(x, y, z);
}
}