Свернуть ↑
package com.l2jfrozen.gameserver.model.actor.instance;
import com.l2jfrozen.gameserver.datatables.AcmeCharScheme sTable;
import com.l2jfrozen.gameserver.datatables.SkillTable;
import com.l2jfrozen.gameserver.model.L2Character;
import com.l2jfrozen.gameserver.model.L2Effect;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.gameserver.model.L2Summon;
import com.l2jfrozen.gameserver.model.entity.event.CTF;
import com.l2jfrozen.gameserver.model.entity.event.DM;
import com.l2jfrozen.gameserver.model.entity.event.TvT;
import com.l2jfrozen.gameserver.model.entity.olympiad.Oly mpiad;
import com.l2jfrozen.gameserver.network.serverpackets.Act ionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.Npc HtmlMessage;
import com.l2jfrozen.gameserver.powerpak.PowerPakConfig;
import com.l2jfrozen.gameserver.taskmanager.AttackStanceT askManager;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import javolution.util.FastList;
import javolution.util.FastMap;
import java.util.StringTokenizer;
public class AcmeBufferInstance extends L2FolkInstance {
public int[] TableId;
public int[] TableDialog;
public AcmeBufferInstance(int objectId, L2NpcTemplate template) {
super(objectId, template);
TableId = new int[]{
1068, 1388, 1086, 1077, 1242, 1240, 1085, 1059, 1303, 1062, 1043,
1040, 1389, 1036, 1035, 1243, 1304, 1078, 1087,
1045, 1048, 1204, 1073, 1397, 1044, 1268, 1257,
1182, 1189, 1191, 1033, 1259, 1392, 1393, 1353, 1352, 1354,
271, 272, 273, 274, 275, 276, 277, 307, 309, 310, 311,
264, 265, 266, 267, 268, 269, 270, 304, 305, 306, 308,
1355, 1356, 1357, 1363, 4699, 4554, 365, 363, 364, 349, 4702
};
TableDialog = new int[]{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
};
}
private boolean checkAllowed(L2PcInstance activeChar)
{
String msg = null;
if(activeChar.isSitting())
msg = "Can't use buffer when sitting";
else if(activeChar.isCastingNow() || activeChar.isCastingPotionNow())
msg = "Can't use buffer when casting";
else if(activeChar.isAlikeDead())
msg = "Can't use buffer while dead";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("ALL" ))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("CURS ED") && activeChar.isCursedWeaponEquiped())
msg = "Can't use Buffer with Cursed Weapon";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("ATTA CK") && AttackStanceTaskManager.getInstance().getAttackSta nceTask(activeChar))
msg = "Buffer is not available during the battle";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("DUNG EON") && activeChar.isIn7sDungeon())
msg = "Buffer is not available in the catacombs and necropolis";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("RB") && activeChar.isInsideZone(L2Character.ZONE_NOSUMMONF RIEND))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("PVP" ) && activeChar.isInsideZone(L2Character.ZONE_PVP))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("PEAC E") && activeChar.isInsideZone(L2Character.ZONE_PEACE))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("SIEG E") && activeChar.isInsideZone(L2Character.ZONE_SIEGE))
msg = "Buffer is not available in this area";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("OLYM PIAD") && (activeChar.isInOlympiadMode() ||
activeChar.isInsideZone(L2Character.ZONE_OLY) || Olympiad.getInstance().isRegistered(activeChar) ||
Olympiad.getInstance().isRegisteredInComp(activeCh ar)))
msg = "Buffer is not available in Olympiad";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("EVEN T") &&
(activeChar.isInFunEvent()))
msg = "Buffer is not available in this event";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("TVT" ) &&
activeChar._inEventTvT && TvT.is_started() )
msg = "Buffer is not available in TVT";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("CTF" ) &&
activeChar._inEventCTF && CTF.is_started() )
msg = "Buffer is not available in CTF";
else if(PowerPakConfig.BUFFER_EXCLUDE_ON.contains("DM") &&
activeChar._inEventDM && DM.is_started() )
msg = "Buffer is not available in DM";
if(msg!=null)
activeChar.sendMessage(msg);
return msg==null;
}
@Override
public String getHtmlPath(int npcId, int val) {
String pom;
if (val == 0) {
pom = "" + npcId;
} else {
pom = npcId + "-" + val;
}
return "data/html/Acme/mods/Buffer/" + pom + ".htm";
}
@Override
public void onBypassFeedback(L2PcInstance player, String command) {
StringTokenizer st = new StringTokenizer(command, " ");
String actualCommand = st.nextToken(); // Get actual command
if(player == null)
return;
if(!checkAllowed(player))
return;
if (actualCommand.startsWith("Chat")) {
String filename = "data/html/Acme/mods/Buffer/100004.htm";
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
if (cmdChoice > 0) {
filename = "data/html/Acme/mods/Buffer/100004-" + cmdChoice + ".htm";
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename);
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else if (actualCommand.startsWith("Cancel")) {
player.stopAllEffects();
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetCancel")) {
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopAllEffects();
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004-08.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("Regenerate")) {
player.setCurrentHpMp(player.getMaxHp(), (player.getMaxMp()));
player.setCurrentCp(player.getMaxCp());
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetRegenerate")) {
L2Summon pet = player.getPet();
pet.setCurrentHpMp(pet.getMaxHp(), (pet.getMaxMp()));
pet.setCurrentCp(pet.getMaxCp());
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile("data/html/Acme/mods/Buffer/100004-08.htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("Buff")) {
String filename = "data/html/Acme/mods/Buffer/100004", v;
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
int id = TableId[cmdChoice];
int dialog = TableDialog[cmdChoice];
int level = SkillTable.getInstance().getMaxLevel(id, 0);
if (id == 4554) {
level = 4;
}
if (dialog == 0) {
v = "";
} else {
v = "-" + Integer.toString(dialog);
}
player.stopSkillEffects(id);
SkillTable.getInstance().getInfo(id, level).getEffects(player, player);
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename + v + ".htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} /*else if (actualCommand.startsWith("PetBuff")) {
String filename = "data/html/Acme/mods/Buffer/100004", v;
int cmdChoice = Integer.parseInt(command.substring(5, 7).trim());
int id = TableId[cmdChoice];
int dialog = TableDialog[cmdChoice];
int level = SkillTable.getInstance().getMaxLevel(id, 0);
if (dialog == 0) {
v = "";
} else {
v = "-" + Integer.toString(dialog);
}
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopSkillEffects(id);
SkillTable.getInstance().getInfo(id, level).getEffects(pet, pet);
} else {
player.sendMessage("У вас нет суммона или питомца");
}
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(filename + v + ".htm");
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
}*/ else if (actualCommand.startsWith("save")) {
int cmdChoice = Integer.parseInt(command.substring(5, 6).trim());
int flag = 0;
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (cmdChoice > 3) {
html.setFile("data/html/Acme/mods/Buffer/100004-11.htm");
flag = 1;
} else {
html.setFile("data/html/Acme/mods/Buffer/100004.htm");
}
CreateScheme(player, Integer.toString(cmdChoice), flag);
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else if (actualCommand.startsWith("give")) {
int cmdChoice = Integer.parseInt(command.substring(5, 6).trim());
if ((cmdChoice < 1) && (cmdChoice > 6)) {
return;
}
String key = "data/html/Acme/mods/Buffer/100004", sKey = Integer.toString(cmdChoice);
int flag = 0;
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (cmdChoice > 3) {
flag = 1;
key = "data/html/Acme/mods/Buffer/100004-8";
}
if (AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey) != null) {
if (flag == 0) {
for (L2Skill sk : AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey)) {
player.stopSkillEffects(sk.getId());
sk.getEffects(this, player);
}
} else {
for (L2Skill sk : AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), sKey)) {
L2Summon pet = player.getPet();
if (pet != null) {
pet.stopSkillEffects(sk.getId());
sk.getEffects(this, pet);
}
}
}
html.setFile(key + ".htm");
} else {
player.sendMessage("Профиль " + sKey + " не найден");
return;
}
sendHtmlMessage(player, html);
player.sendPacket(new ActionFailed());
} else {
super.onBypassFeedback(player, command);
}
}
private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html) {
if(player == null)
return;
if(!checkAllowed(player))
return;
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
player.sendPacket(html);
}
private void CreateScheme(L2PcInstance player, String name, int flag) {
if(player == null)
return;
if(!checkAllowed(player))
return;
if (AcmeCharSchemesTable.getInstance().getAllSchemes( player.getObjectId()) != null
&& AcmeCharSchemesTable.getInstance().getAllSchemes(p layer.getObjectId()).containsKey(name)) {
AcmeCharSchemesTable.getInstance().getAllSchemes(p layer.getObjectId()).remove(name);
}
if (AcmeCharSchemesTable.getInstance().getAllSchemes( player.getObjectId()) == null) {
AcmeCharSchemesTable.getInstance().getSchemesTable ().put(player.getObjectId(),
new FastMap<String, FastList<L2Skill>>(6));
}
AcmeCharSchemesTable.getInstance().setScheme(playe r.getObjectId(), name.trim(),
new FastList<L2Skill>(69));
L2Effect[] s;
if (flag == 0) {
s = player.getAllEffects();
} else {
L2Summon pet = player.getPet();
s = pet.getAllEffects();
}
int Id;
Boolean Ok = false;
int i = 0;
while (i < s.length) {
L2Effect value = s[i];
Id = value.getSkill().getId();
int k = 0;
while (k < TableId.length) {
if (Id == TableId[k]) {
Ok = true;
break;
}
k++;
}
if (Ok) {
AcmeCharSchemesTable.getInstance().getScheme(
player.getObjectId(), name).add(
SkillTable.getInstance().getInfo(Id, value.getSkill().getLevel()));
}
Ok = false;
i++;
}
player.sendMessage("Профиль " + name + " успешно сохранён");
}
}