Перейти к содержанию
Авторизация  
xINVIZIBLx

Модификация L2Teleporterinstance.java

Рекомендуемые сообщения

Сделал что бы, тп точки задавались непосредственно в самом htm.

Делал на aCis.

Импорты урезаны.

 

 

<html><body>&$556;<br><br>
<a action="bypass -h npc_%objectId%_goto 147450 28081 -2294 0 0" msg="811;Village Square">Village Square</a><br1>
<a action="bypass -h npc_%objectId%_goto 151950 25094 -2172 0 0" msg="811;East Gate Entrance">East Gate Entrance</a><br1>
<a action="bypass -h npc_%objectId%_goto 142593 26344 -2425 0 0" msg="811;West Gate Entrance">West Gate Entrance</a><br1>
<a action="bypass -h npc_%objectId%_goto 147503 32299 -2501 0 0" msg="811;South Gate Entrance">South Gate Entrance</a><br1>
<a action="bypass -h npc_%objectId%_goto 147465 20737 -2130 0 0" msg="811;North Gate Entrance">North Gate Entrance</a><br1>
</body></html>

Что соотвутствует после goto x, y, z, price, fornoble

package l2j.gameserver.model.actor.instance;

 

 

 

import java.util.Calendar;

 

import java.util.StringTokenizer;

 

 

 

import l2j.Config;

 

import l2j.gameserver.cache.HtmCache;

 

import l2j.gameserver.instancemanager.CastleManager;

 

import l2j.gameserver.instancemanager.SiegeManager;

 

import l2j.gameserver.instancemanager.TownManager;

 

import l2j.gameserver.model.actor.L2Character;

 

import l2j.gameserver.network.SystemMessageId;

 

import l2j.gameserver.network.serverpackets.ActionFailed;

 

import l2j.gameserver.network.serverpackets.NpcHtmlMessage;

 

import l2j.gameserver.templates.chars.L2NpcTemplate;

 

 

 

/**

 

* @author NightMarez, xINVIZIBLx

 

*/

 

public final class L2TeleporterInstance extends L2NpcInstance

 

{

 

private static final int COND_ALL_FALSE = 0;

 

private static final int COND_BUSY_BECAUSE_OF_SIEGE = 1;

 

private static final int COND_OWNER = 2;

 

private static final int COND_REGULAR = 3;

 

 

 

public L2TeleporterInstance(int objectId, L2NpcTemplate template)

 

{

 

super(objectId, template);

 

}

 

 

 

@Override

 

public void onBypassFeedback(L2PcInstance player, String command)

 

{

 

player.sendPacket(ActionFailed.STATIC_PACKET);

 

 

 

int condition = validateCondition(player);

 

 

 

if (command.startsWith("goto"))

 

{

 

String spike = command.split(" ")[0]; // FIX ME.

 

int loc_x = Integer.parseInt(command.split(" ")[1]);

 

int loc_y = Integer.parseInt(command.split(" ")[2]);

 

int loc_z = Integer.parseInt(command.split(" ")[3]);

 

int price = Integer.parseInt(command.split(" ")[4]);

 

int fornoble = Integer.parseInt(command.split(" ")[5]);

 

 

 

if (condition == COND_REGULAR || condition == COND_OWNER)

 

{

 

doTeleport(player, loc_x, loc_y, loc_z, price, fornoble);

 

return;

 

}

 

}

 

else if (command.startsWith("Chat"))

 

{

 

Calendar cal = Calendar.getInstance();

 

int val = 0;

 

try

 

{

 

val = Integer.parseInt(command.substring(5));

 

}

 

catch (IndexOutOfBoundsException ioobe)

 

{

 

}

 

catch (NumberFormatException nfe)

 

{

 

}

 

 

 

if (val == 1 && cal.get(Calendar.HOUR_OF_DAY) >= 20 && cal.get(Calendar.HOUR_OF_DAY) <= 23 && (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7))

 

{

 

showHalfPriceHtml(player);

 

return;

 

}

 

showChatWindow(player, val);

 

}

 

else

 

super.onBypassFeedback(player, command);

 

}

 

 

 

@Override

 

public String getHtmlPath(int npcId, int val, L2PcInstance player)

 

{

 

String pom = "";

 

if (val == 0)

 

pom = "" + npcId;

 

else

 

pom = npcId + "-" + val;

 

 

 

return (player.isRus() ? "data/html-ru/teleporter/" + pom + ".htm" : "data/html-en/teleporter/" + pom + ".htm");

 

}

 

 

 

private void showHalfPriceHtml(L2PcInstance player)

 

{

 

if (player == null)

 

return;

 

 

 

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

 

 

 

String filename = (player.isRus() ? "data/html-ru/teleporter/half/" + getNpcId() + ".htm" : "data/html-en/teleporter/half/" + getNpcId() + ".htm");

 

if (!HtmCache.getInstance().isLoadable(filename))

 

filename = (player.isRus() ? "data/html-ru/teleporter/" + getNpcId() + "-1.htm" : "data/html-en/teleporter/" + getNpcId() + "-1.htm");

 

 

 

html.setFile(filename);

 

html.replace("%objectId%", String.valueOf(getObjectId()));

 

html.replace("%npcname%", getName());

 

player.sendPacket(html);

 

}

 

 

 

@Override

 

public void showChatWindow(L2PcInstance player)

 

{

 

String filename = (player.isRus() ? "data/html-ru/teleporter/castletp-no.htm" : "data/html-en/teleporter/castletp-no.htm");

 

 

 

int condition = validateCondition(player);

 

if (condition == COND_REGULAR)

 

{

 

super.showChatWindow(player);

 

return;

 

}

 

else if (condition > COND_ALL_FALSE)

 

{

 

if (condition == COND_BUSY_BECAUSE_OF_SIEGE)

 

filename = (player.isRus() ? "data/html-ru/teleporter/castletp-busy.htm" : "data/html-en/teleporter/castletp-busy.htm"); // Busy because of siege

 

else if (condition == COND_OWNER) // Clan owns castle

 

filename = getHtmlPath(getNpcId(), 0, player); // Owner message window

 

}

 

 

 

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

 

html.setFile(filename);

 

html.replace("%objectId%", String.valueOf(getObjectId()));

 

html.replace("%npcname%", getName());

 

player.sendPacket(html);

 

}

 

 

 

private void doTeleport(L2PcInstance player, int loc_x, int loc_y, int loc_z, int price, int fornoble)

 

{

 

// you cannot teleport to village that is in siege

 

if (SiegeManager.getInstance().getSiege(loc_x, loc_y, loc_z) != null)

 

{

 

player.sendPacket(SystemMessageId.NO_PORT_THAT_IS_IN_SIGE);

 

return;

 

}

 

else if (TownManager.townHasCastleInSiege(loc_x, loc_y) && isInsideZone(L2Character.ZONE_TOWN))

 

{

 

player.sendPacket(SystemMessageId.NO_PORT_THAT_IS_IN_SIGE);

 

return;

 

}

 

else if (!Config.KARMA_PLAYER_CAN_USE_GK && player.getKarma() > 0) // karma

 

{

 

player.sendMessage("[sRV]: Go away, you're not welcome here.");

 

return;

 

}

 

else if ((fornoble == 1) && !player.isNoble())

 

{

 

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

 

html.setFile(player.isRus() ? "data/html-ru/teleporter/nobletp-no.htm" : "data/html-en/teleporter/nobletp-no.htm");

 

html.replace("%objectId%", String.valueOf(getObjectId()));

 

html.replace("%npcname%", getName());

 

player.sendPacket(html);

 

return;

 

}

 

else if (player.isAlikeDead())

 

return;

 

 

 

Calendar cal = Calendar.getInstance();

 

 

 

if (!(fornoble == 1))

 

{

 

if (cal.get(Calendar.HOUR_OF_DAY) >= 20 && cal.get(Calendar.HOUR_OF_DAY) <= 23 && (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7))

 

price /= 2;

 

}

 

 

 

if (Config.ALT_GAME_FREE_TELEPORT || player.destroyItemByItemId("Teleport " + ((fornoble == 1) ? " nobless" : ""), 57, price, this, true))

 

{

 

if (Config.DEBUG)

 

_log.fine("Teleporting player " + player.getName() + " to new location: " + loc_x + ":" + loc_y + ":" + loc_z);

 

 

 

player.teleToLocation(loc_x, loc_y, loc_z, true);

 

}

 

 

 

player.sendPacket(ActionFailed.STATIC_PACKET);

 

}

 

 

 

private int validateCondition(L2PcInstance player)

 

{

 

if (CastleManager.getInstance().getCastleIndex(this) < 0) // teleporter isn't on castle ground

 

return COND_REGULAR; // Regular access

 

else if (getCastle().getSiege().getIsInProgress()) // teleporter is on castle ground and siege is in progress

 

return COND_BUSY_BECAUSE_OF_SIEGE; // Busy because of siege

 

else if (player.getClan() != null) // teleporter is on castle ground and player is in a clan

 

{

 

if (getCastle().getOwnerId() == player.getClanId()) // Clan owns castle

 

return COND_OWNER; // Owner

 

}

 

 

 

return COND_ALL_FALSE;

 

}

 

}

 

  • Upvote 6

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

А да,такая штука полезна.Я даже с начало не понял чуток

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Теперь задается goto x, y, z, item_id, count, fornoble

Пример: <a action="bypass -h npc_%objectId%_goto x y z item_id count fornoble" msg="811;Village Square">Village Square</a><br1>

package l2j.gameserver.model.actor.instance;

 

import java.util.Calendar;

import java.util.StringTokenizer;

 

import l2j.Config;

import l2j.gameserver.cache.HtmCache;

import l2j.gameserver.instancemanager.CastleManager;

import l2j.gameserver.instancemanager.SiegeManager;

import l2j.gameserver.instancemanager.TownManager;

import l2j.gameserver.model.actor.L2Character;

import l2j.gameserver.network.SystemMessageId;

import l2j.gameserver.network.serverpackets.ActionFailed;

import l2j.gameserver.network.serverpackets.NpcHtmlMessage;

import l2j.gameserver.templates.chars.L2NpcTemplate;

 

/**

* @author NightMarez, xINVIZIBLx

*/

public final class L2TeleporterInstance extends L2NpcInstance

{

private static final int COND_ALL_FALSE = 0;

private static final int COND_BUSY_BECAUSE_OF_SIEGE = 1;

private static final int COND_OWNER = 2;

private static final int COND_REGULAR = 3;

 

public L2TeleporterInstance(int objectId, L2NpcTemplate template)

{

super(objectId, template);

}

 

@Override

public void onBypassFeedback(L2PcInstance player, String command)

{

player.sendPacket(ActionFailed.STATIC_PACKET);

 

int condition = validateCondition(player);

 

if (command.startsWith("goto"))

{

String spike = command.split(" ")[0]; // FIX ME.

int loc_x = Integer.parseInt(command.split(" ")[1]);

int loc_y = Integer.parseInt(command.split(" ")[2]);

int loc_z = Integer.parseInt(command.split(" ")[3]);

int item_id = Integer.parseInt(command.split(" ")[4]);

int count = Integer.parseInt(command.split(" ")[5]);

int fornoble = Integer.parseInt(command.split(" ")[6]);

 

if (condition == COND_REGULAR || condition == COND_OWNER)

{

doTeleport(player, loc_x, loc_y, loc_z, item_id, count, fornoble);

return;

}

}

else if (command.startsWith("Chat"))

{

Calendar cal = Calendar.getInstance();

int val = 0;

try

{

val = Integer.parseInt(command.substring(5));

}

catch (IndexOutOfBoundsException ioobe)

{

}

catch (NumberFormatException nfe)

{

}

 

if (val == 1 && cal.get(Calendar.HOUR_OF_DAY) >= 20 && cal.get(Calendar.HOUR_OF_DAY) <= 23 && (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7))

{

showHalfPriceHtml(player);

return;

}

showChatWindow(player, val);

}

else

super.onBypassFeedback(player, command);

}

 

@Override

public String getHtmlPath(int npcId, int val, L2PcInstance player)

{

String pom = "";

if (val == 0)

pom = "" + npcId;

else

pom = npcId + "-" + val;

 

return (player.isRus() ? "data/html-ru/teleporter/" + pom + ".htm" : "data/html-en/teleporter/" + pom + ".htm");

}

 

private void showHalfPriceHtml(L2PcInstance player)

{

if (player == null)

return;

 

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

 

String filename = (player.isRus() ? "data/html-ru/teleporter/half/" + getNpcId() + ".htm" : "data/html-en/teleporter/half/" + getNpcId() + ".htm");

if (!HtmCache.getInstance().isLoadable(filename))

filename = (player.isRus() ? "data/html-ru/teleporter/" + getNpcId() + "-1.htm" : "data/html-en/teleporter/" + getNpcId() + "-1.htm");

 

html.setFile(filename);

html.replace("%objectId%", String.valueOf(getObjectId()));

html.replace("%npcname%", getName());

player.sendPacket(html);

}

 

@Override

public void showChatWindow(L2PcInstance player)

{

String filename = (player.isRus() ? "data/html-ru/teleporter/castletp-no.htm" : "data/html-en/teleporter/castletp-no.htm");

 

int condition = validateCondition(player);

if (condition == COND_REGULAR)

{

super.showChatWindow(player);

return;

}

else if (condition > COND_ALL_FALSE)

{

if (condition == COND_BUSY_BECAUSE_OF_SIEGE)

filename = (player.isRus() ? "data/html-ru/teleporter/castletp-busy.htm" : "data/html-en/teleporter/castletp-busy.htm"); // Busy because of siege

else if (condition == COND_OWNER) // Clan owns castle

filename = getHtmlPath(getNpcId(), 0, player); // Owner message window

}

 

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

html.setFile(filename);

html.replace("%objectId%", String.valueOf(getObjectId()));

html.replace("%npcname%", getName());

player.sendPacket(html);

}

 

private void doTeleport(L2PcInstance player, int loc_x, int loc_y, int loc_z, int item_id, int count, int fornoble)

{

// you cannot teleport to village that is in siege

if (SiegeManager.getInstance().getSiege(loc_x, loc_y, loc_z) != null)

{

player.sendPacket(SystemMessageId.NO_PORT_THAT_IS_IN_SIGE);

return;

}

else if (TownManager.townHasCastleInSiege(loc_x, loc_y) && isInsideZone(L2Character.ZONE_TOWN))

{

player.sendPacket(SystemMessageId.NO_PORT_THAT_IS_IN_SIGE);

return;

}

else if (!Config.KARMA_PLAYER_CAN_USE_GK && player.getKarma() > 0) // karma

{

player.sendMessage("[sRV]: Go away, you're not welcome here.");

return;

}

else if ((fornoble == 1) && !player.isNoble())

{

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

html.setFile(player.isRus() ? "data/html-ru/teleporter/nobletp-no.htm" : "data/html-en/teleporter/nobletp-no.htm");

html.replace("%objectId%", String.valueOf(getObjectId()));

html.replace("%npcname%", getName());

player.sendPacket(html);

return;

}

else if (player.isAlikeDead())

return;

 

Calendar cal = Calendar.getInstance();

 

if (!(fornoble == 1))

{

if (cal.get(Calendar.HOUR_OF_DAY) >= 20 && cal.get(Calendar.HOUR_OF_DAY) <= 23 && (cal.get(Calendar.DAY_OF_WEEK) == 1 || cal.get(Calendar.DAY_OF_WEEK) == 7))

price /= 2;

}

 

if (Config.ALT_GAME_FREE_TELEPORT || player.destroyItemByItemId("Teleport " + ((fornoble == 1) ? " nobless" : ""), item_id, count, this, true))

{

if (Config.DEBUG)

_log.fine("Teleporting player " + player.getName() + " to new location: " + loc_x + ":" + loc_y + ":" + loc_z);

 

player.teleToLocation(loc_x, loc_y, loc_z, true);

}

 

player.sendPacket(ActionFailed.STATIC_PACKET);

}

 

private int validateCondition(L2PcInstance player)

{

if (CastleManager.getInstance().getCastleIndex(this) < 0) // teleporter isn't on castle ground

return COND_REGULAR; // Regular access

else if (getCastle().getSiege().getIsInProgress()) // teleporter is on castle ground and siege is in progress

return COND_BUSY_BECAUSE_OF_SIEGE; // Busy because of siege

else if (player.getClan() != null) // teleporter is on castle ground and player is in a clan

{

if (getCastle().getOwnerId() == player.getClanId()) // Clan owns castle

return COND_OWNER; // Owner

}

 

return COND_ALL_FALSE;

}

}

 

Изменено пользователем xINVIZIBLx
  • Upvote 1

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...