Merged with released L2J-Unity files.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.FactionManager;
|
||||
package custom.FactionSystem;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
@@ -28,10 +28,12 @@ import ai.AbstractNpcAI;
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
final class FactionManager extends AbstractNpcAI
|
||||
public final class FactionSystem extends AbstractNpcAI
|
||||
{
|
||||
// NPC
|
||||
// NPCs
|
||||
private static final int MANAGER = Config.FACTION_MANAGER_NPCID;
|
||||
private static final int GOOD_GUARD = Config.FACTION_GOOD_GUARD_NPCID;
|
||||
private static final int EVIL_GUARD = Config.FACTION_EVIL_GUARD_NPCID;
|
||||
// Other
|
||||
private static final String[] TEXTS =
|
||||
{
|
||||
@@ -40,13 +42,13 @@ final class FactionManager extends AbstractNpcAI
|
||||
"The choice is yours!"
|
||||
};
|
||||
|
||||
private FactionManager()
|
||||
private FactionSystem()
|
||||
{
|
||||
super(FactionManager.class.getSimpleName(), "custom");
|
||||
addSpawnId(MANAGER);
|
||||
addStartNpc(MANAGER);
|
||||
addTalkId(MANAGER);
|
||||
addFirstTalkId(MANAGER);
|
||||
addAggroRangeEnterId(EVIL_GUARD, GOOD_GUARD);
|
||||
|
||||
if (Config.FACTION_SYSTEM_ENABLED)
|
||||
{
|
||||
@@ -61,7 +63,7 @@ final class FactionManager extends AbstractNpcAI
|
||||
{
|
||||
case "selectGoodFaction":
|
||||
{
|
||||
if (Config.FACTION_BALANCE_ONLINE_PLAYERS && (L2World.getInstance().getAllGoodPlayersCount() >= (L2World.getInstance().getAllEvilPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT)))
|
||||
if (Config.FACTION_BALANCE_ONLINE_PLAYERS && (L2World.getInstance().getAllGoodPlayers().size() >= (L2World.getInstance().getAllEvilPlayers().size() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT)))
|
||||
{
|
||||
final String htmltext = null;
|
||||
final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId());
|
||||
@@ -88,7 +90,7 @@ final class FactionManager extends AbstractNpcAI
|
||||
}
|
||||
case "selectEvilFaction":
|
||||
{
|
||||
if (Config.FACTION_BALANCE_ONLINE_PLAYERS && (L2World.getInstance().getAllEvilPlayersCount() >= (L2World.getInstance().getAllGoodPlayersCount() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT)))
|
||||
if (Config.FACTION_BALANCE_ONLINE_PLAYERS && (L2World.getInstance().getAllEvilPlayers().size() >= (L2World.getInstance().getAllGoodPlayers().size() + Config.FACTION_BALANCE_PLAYER_EXCEED_LIMIT)))
|
||||
{
|
||||
final String htmltext = null;
|
||||
final NpcHtmlMessage packet = new NpcHtmlMessage(npc.getObjectId());
|
||||
@@ -117,7 +119,7 @@ final class FactionManager extends AbstractNpcAI
|
||||
{
|
||||
if (npc != null)
|
||||
{
|
||||
broadcastNpcSay(npc, ChatType.NPC_GENERAL, TEXTS[getRandom(TEXTS.length)]);
|
||||
npc.broadcastSay(ChatType.NPC_GENERAL, TEXTS[getRandom(TEXTS.length)], 1500);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -141,7 +143,10 @@ final class FactionManager extends AbstractNpcAI
|
||||
@Override
|
||||
public String onSpawn(L2Npc npc)
|
||||
{
|
||||
startQuestTimer("SPEAK", 10000, npc, null, true);
|
||||
if (npc.getId() == MANAGER)
|
||||
{
|
||||
startQuestTimer("SPEAK", 10000, npc, null, true);
|
||||
}
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
@@ -163,8 +168,18 @@ final class FactionManager extends AbstractNpcAI
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAggroRangeEnter(L2Npc npc, L2PcInstance player, boolean isSummon)
|
||||
{
|
||||
if (Config.FACTION_SYSTEM_ENABLED && Config.FACTION_GUARDS_ENABLED && ((player.isGood() && (npc.getId() == EVIL_GUARD)) || (player.isEvil() && (npc.getId() == GOOD_GUARD))))
|
||||
{
|
||||
addAttackDesire(npc, player);
|
||||
}
|
||||
return super.onAggroRangeEnter(npc, player, isSummon);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new FactionManager();
|
||||
new FactionSystem();
|
||||
}
|
||||
}
|
448
trunk/dist/game/data/scripts/custom/SellBuff/SellBuff.java
vendored
Normal file
448
trunk/dist/game/data/scripts/custom/SellBuff/SellBuff.java
vendored
Normal file
@@ -0,0 +1,448 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.SellBuff;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.handler.BypassHandler;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.handler.IVoicedCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.VoicedCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.SellBuffsManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.AbstractScript;
|
||||
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Sell Buffs voice command
|
||||
* @author St3eT
|
||||
*/
|
||||
public class SellBuff implements IVoicedCommandHandler, IBypassHandler
|
||||
{
|
||||
private static final String[] VOICED_COMMANDS =
|
||||
{
|
||||
"sellbuff",
|
||||
"sellbuffs",
|
||||
};
|
||||
|
||||
private static final String[] BYPASS_COMMANDS =
|
||||
{
|
||||
"sellbuffadd",
|
||||
"sellbuffaddskill",
|
||||
"sellbuffedit",
|
||||
"sellbuffchangeprice",
|
||||
"sellbuffremove",
|
||||
"sellbuffbuymenu",
|
||||
"sellbuffbuyskill",
|
||||
"sellbuffstart",
|
||||
"sellbuffstop",
|
||||
};
|
||||
|
||||
private SellBuff()
|
||||
{
|
||||
if (Config.SELLBUFF_ENABLED)
|
||||
{
|
||||
BypassHandler.getInstance().registerHandler(this);
|
||||
VoicedCommandHandler.getInstance().registerHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
String cmd = "";
|
||||
String params = "";
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
cmd = st.nextToken();
|
||||
}
|
||||
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
params += st.nextToken() + (st.hasMoreTokens() ? " " : "");
|
||||
}
|
||||
|
||||
if (cmd.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return useBypass(cmd, activeChar, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case "sellbuff":
|
||||
case "sellbuffs":
|
||||
{
|
||||
SellBuffsManager.getInstance().sendSellMenu(activeChar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, String params)
|
||||
{
|
||||
if (!Config.SELLBUFF_ENABLED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case "sellbuffstart":
|
||||
{
|
||||
if (activeChar.isSellingBuffs() || (params == null) || params.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (activeChar.getSellingBuffs().isEmpty())
|
||||
{
|
||||
activeChar.sendMessage("Your list of buffs is empty, please add some buffs first!");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
String title = "BUFF SELL: ";
|
||||
final StringTokenizer st = new StringTokenizer(params, " ");
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
title += st.nextToken() + " ";
|
||||
}
|
||||
|
||||
if (title.length() > 40)
|
||||
{
|
||||
activeChar.sendMessage("Your title cannot exceed 29 characters in length. Please try again.");
|
||||
return false;
|
||||
}
|
||||
|
||||
SellBuffsManager.getInstance().startSellBuffs(activeChar, title);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffstop":
|
||||
{
|
||||
if (activeChar.isSellingBuffs())
|
||||
{
|
||||
SellBuffsManager.getInstance().stopSellBuffs(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffadd":
|
||||
{
|
||||
if (!activeChar.isSellingBuffs())
|
||||
{
|
||||
int index = 0;
|
||||
if ((params != null) && !params.isEmpty() && Util.isDigit(params))
|
||||
{
|
||||
index = Integer.parseInt(params);
|
||||
}
|
||||
|
||||
SellBuffsManager.getInstance().sendBuffChoiceMenu(activeChar, index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffedit":
|
||||
{
|
||||
if (!activeChar.isSellingBuffs())
|
||||
{
|
||||
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffchangeprice":
|
||||
{
|
||||
if (!activeChar.isSellingBuffs() && (params != null) && !params.isEmpty())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params, " ");
|
||||
|
||||
int skillId = -1;
|
||||
int price = -1;
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
skillId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
try
|
||||
{
|
||||
price = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Too big price! Maximal price is " + Config.SELLBUFF_MAX_PRICE);
|
||||
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
if ((skillId == -1) || (price == -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Skill skillToChange = activeChar.getKnownSkill(skillId);
|
||||
if (skillToChange == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final SellBuffHolder holder = activeChar.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToChange.getId())).findFirst().orElse(null);
|
||||
if ((holder != null))
|
||||
{
|
||||
activeChar.sendMessage("Price of " + activeChar.getKnownSkill(holder.getSkillId()).getName() + " has been changed to " + price + "!");
|
||||
holder.setPrice(price);
|
||||
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffremove":
|
||||
{
|
||||
if (!activeChar.isSellingBuffs() && (params != null) && !params.isEmpty())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params, " ");
|
||||
|
||||
int skillId = -1;
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
skillId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if ((skillId == -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Skill skillToRemove = activeChar.getKnownSkill(skillId);
|
||||
if (skillToRemove == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final SellBuffHolder holder = activeChar.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToRemove.getId())).findFirst().orElse(null);
|
||||
if ((holder != null) && activeChar.getSellingBuffs().remove(holder))
|
||||
{
|
||||
activeChar.sendMessage("Skill " + activeChar.getKnownSkill(holder.getSkillId()).getName() + " has been removed!");
|
||||
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffaddskill":
|
||||
{
|
||||
if (!activeChar.isSellingBuffs() && (params != null) && !params.isEmpty())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params, " ");
|
||||
|
||||
int skillId = -1;
|
||||
long price = -1;
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
skillId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
try
|
||||
{
|
||||
price = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Too big price! Maximal price is " + Config.SELLBUFF_MIN_PRICE);
|
||||
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
if ((skillId == -1) || (price == -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Skill skillToAdd = activeChar.getKnownSkill(skillId);
|
||||
if (skillToAdd == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (price < Config.SELLBUFF_MIN_PRICE)
|
||||
{
|
||||
activeChar.sendMessage("Too small price! Minimal price is " + Config.SELLBUFF_MIN_PRICE);
|
||||
return false;
|
||||
}
|
||||
else if (price > Config.SELLBUFF_MAX_PRICE)
|
||||
{
|
||||
activeChar.sendMessage("Too big price! Maximal price is " + Config.SELLBUFF_MAX_PRICE);
|
||||
return false;
|
||||
}
|
||||
else if (activeChar.getSellingBuffs().size() >= Config.SELLBUFF_MAX_BUFFS)
|
||||
{
|
||||
activeChar.sendMessage("You already reached max count of buffs! Max buffs is: " + Config.SELLBUFF_MAX_BUFFS);
|
||||
return false;
|
||||
}
|
||||
else if (!SellBuffsManager.getInstance().isInSellList(activeChar, skillToAdd))
|
||||
{
|
||||
activeChar.getSellingBuffs().add(new SellBuffHolder(skillToAdd.getId(), price));
|
||||
activeChar.sendMessage(skillToAdd.getName() + " has been added!");
|
||||
SellBuffsManager.getInstance().sendBuffChoiceMenu(activeChar, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffbuymenu":
|
||||
{
|
||||
if ((params != null) && !params.isEmpty())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params, " ");
|
||||
|
||||
int objId = -1;
|
||||
int index = 0;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
objId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
index = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
final L2PcInstance seller = L2World.getInstance().getPlayer(objId);
|
||||
if (seller != null)
|
||||
{
|
||||
if (!seller.isSellingBuffs() || !activeChar.isInsideRadius(seller, L2Npc.INTERACTION_DISTANCE, true, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SellBuffsManager.getInstance().sendBuffMenu(activeChar, seller, index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "sellbuffbuyskill":
|
||||
{
|
||||
if ((params != null) && !params.isEmpty())
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params, " ");
|
||||
int objId = -1;
|
||||
int skillId = -1;
|
||||
int index = 0;
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
objId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
skillId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
index = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if ((skillId == -1) || (objId == -1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance seller = L2World.getInstance().getPlayer(objId);
|
||||
if (seller == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final Skill skillToBuy = seller.getKnownSkill(skillId);
|
||||
if (!seller.isSellingBuffs() || !Util.checkIfInRange(L2Npc.INTERACTION_DISTANCE, activeChar, seller, true) || (skillToBuy == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (seller.getCurrentMp() < (skillToBuy.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER))
|
||||
{
|
||||
activeChar.sendMessage(seller.getName() + " has no enough mana for " + skillToBuy.getName() + "!");
|
||||
SellBuffsManager.getInstance().sendBuffMenu(activeChar, seller, index);
|
||||
return false;
|
||||
}
|
||||
|
||||
final SellBuffHolder holder = seller.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToBuy.getId())).findFirst().orElse(null);
|
||||
if (holder != null)
|
||||
{
|
||||
if (AbstractScript.getQuestItemsCount(activeChar, Config.SELLBUFF_PAYMENT_ID) >= holder.getPrice())
|
||||
{
|
||||
AbstractScript.takeItems(activeChar, Config.SELLBUFF_PAYMENT_ID, holder.getPrice());
|
||||
AbstractScript.giveItems(seller, Config.SELLBUFF_PAYMENT_ID, holder.getPrice());
|
||||
seller.reduceCurrentMp(skillToBuy.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER);
|
||||
skillToBuy.activateSkill(seller, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(Config.SELLBUFF_PAYMENT_ID);
|
||||
if (item != null)
|
||||
{
|
||||
activeChar.sendMessage("Not enough " + item.getName() + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Not enough items!");
|
||||
}
|
||||
}
|
||||
}
|
||||
SellBuffsManager.getInstance().sendBuffMenu(activeChar, seller, index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getVoicedCommandList()
|
||||
{
|
||||
return VOICED_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return BYPASS_COMMANDS;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new SellBuff();
|
||||
}
|
||||
}
|
@@ -1,85 +1,84 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.ShadowWeapons;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
|
||||
/**
|
||||
* Shadow Weapons AI.<br>
|
||||
* Original Jython script by DrLecter.
|
||||
* @author Nyaran, jurchiks
|
||||
*/
|
||||
final class ShadowWeapons extends Quest
|
||||
{
|
||||
// @formatter:off
|
||||
private static final int[] NPCS =
|
||||
{
|
||||
30037, 30066, 30070, 30109, 30115, 30120, 30174, 30175, 30176, 30187,
|
||||
30191, 30195, 30288, 30289, 30290, 30297, 30373, 30462, 30474, 30498,
|
||||
30499, 30500, 30503, 30504, 30505, 30511, 30512, 30513, 30595, 30676,
|
||||
30677, 30681, 30685, 30687, 30689, 30694, 30699, 30704, 30845, 30847,
|
||||
30849, 30854, 30857, 30862, 30865, 30894, 30897, 30900, 30905, 30910,
|
||||
30913, 31269, 31272, 31276, 31285, 31288, 31314, 31317, 31321, 31324,
|
||||
31326, 31328, 31331, 31334, 31336, 31958, 31961, 31965, 31968, 31974,
|
||||
31977, 31996, 32092, 32093, 32094, 32095, 32096, 32097, 32098, 32193,
|
||||
32196, 32199, 32202, 32205, 32206, 32213, 32214, 32221, 32222, 32229,
|
||||
32230, 32233, 32234
|
||||
};
|
||||
// @formatter:on
|
||||
private ShadowWeapons()
|
||||
{
|
||||
super(-1, ShadowWeapons.class.getSimpleName(), "custom");
|
||||
addStartNpc(NPCS);
|
||||
addTalkId(NPCS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext;
|
||||
final boolean has_d = hasQuestItems(player, 8869); // Shadow Item Exchange Coupon (D-Grade)
|
||||
final boolean has_c = hasQuestItems(player, 8870); // Shadow Item Exchange Coupon (C-Grade)
|
||||
|
||||
if (has_d || has_c)
|
||||
{
|
||||
if (!has_d)
|
||||
{
|
||||
htmltext = "exchange_c.html";
|
||||
}
|
||||
else if (!has_c)
|
||||
{
|
||||
htmltext = "exchange_d.html";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "exchange_both.html";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "exchange_no.html";
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
new ShadowWeapons();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.ShadowWeapons;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Shadow Weapons AI.<br>
|
||||
* @author Nyaran, jurchiks
|
||||
*/
|
||||
public final class ShadowWeapons extends AbstractNpcAI
|
||||
{
|
||||
// @formatter:off
|
||||
private static final int[] NPCS =
|
||||
{
|
||||
30037, 30066, 30070, 30109, 30115, 30120, 30174, 30175, 30176, 30187,
|
||||
30191, 30195, 30288, 30289, 30290, 30297, 30373, 30462, 30474, 30498,
|
||||
30499, 30500, 30503, 30504, 30505, 30511, 30512, 30513, 30595, 30676,
|
||||
30677, 30681, 30685, 30687, 30689, 30694, 30699, 30704, 30845, 30847,
|
||||
30849, 30854, 30857, 30862, 30865, 30894, 30897, 30900, 30905, 30910,
|
||||
30913, 31269, 31272, 31276, 31285, 31288, 31314, 31317, 31321, 31324,
|
||||
31326, 31328, 31331, 31334, 31336, 31958, 31961, 31965, 31968, 31974,
|
||||
31977, 31996, 32092, 32093, 32094, 32095, 32096, 32097, 32098, 32193,
|
||||
32196, 32199, 32202, 32205, 32206, 32213, 32214, 32221, 32222, 32229,
|
||||
32230, 32233, 32234
|
||||
};
|
||||
// @formatter:on
|
||||
private ShadowWeapons()
|
||||
{
|
||||
addStartNpc(NPCS);
|
||||
addTalkId(NPCS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext;
|
||||
final boolean has_d = hasQuestItems(player, 8869); // Shadow Item Exchange Coupon (D-Grade)
|
||||
final boolean has_c = hasQuestItems(player, 8870); // Shadow Item Exchange Coupon (C-Grade)
|
||||
|
||||
if (has_d || has_c)
|
||||
{
|
||||
if (!has_d)
|
||||
{
|
||||
htmltext = "exchange_c.html";
|
||||
}
|
||||
else if (!has_c)
|
||||
{
|
||||
htmltext = "exchange_d.html";
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "exchange_both.html";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = "exchange_no.html";
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
new ShadowWeapons();
|
||||
}
|
||||
}
|
||||
|
@@ -1,241 +1,244 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Elpies;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2EventMonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
final class Elpies extends Event
|
||||
{
|
||||
// NPC
|
||||
private static final int ELPY = 900100;
|
||||
// Amount of Elpies to spawn when the event starts
|
||||
private static final int ELPY_AMOUNT = 100;
|
||||
// Event duration in minutes
|
||||
private static final int EVENT_DURATION_MINUTES = 2;
|
||||
// @formatter:off
|
||||
private static final int[][] DROPLIST_CONSUMABLES =
|
||||
{
|
||||
// itemId, chance, min amount, max amount
|
||||
{ 1540, 80, 10, 15 }, // Quick Healing Potion
|
||||
{ 1538, 60, 5, 10 }, // Blessed Scroll of Escape
|
||||
{ 3936, 40, 5, 10 }, // Blessed Scroll of Ressurection
|
||||
{ 6387, 25, 5, 10 }, // Blessed Scroll of Ressurection Pets
|
||||
{ 22025, 15, 5, 10 }, // Powerful Healing Potion
|
||||
{ 6622, 10, 1, 1 }, // Giant's Codex
|
||||
{ 20034, 5, 1, 1 }, // Revita Pop
|
||||
{ 20004, 1, 1, 1 }, // Energy Ginseng
|
||||
{ 20004, 0, 1, 1 } // Energy Ginseng
|
||||
};
|
||||
|
||||
private static final int[][] DROPLIST_CRYSTALS =
|
||||
{
|
||||
{ 1458, 80, 50, 100 }, // Crystal D-Grade
|
||||
{ 1459, 60, 40, 80 }, // Crystal C-Grade
|
||||
{ 1460, 40, 30, 60 }, // Crystal B-Grade
|
||||
{ 1461, 20, 20, 30 }, // Crystal A-Grade
|
||||
{ 1462, 0, 10, 20 } // Crystal S-Grade
|
||||
};
|
||||
// @formatter:on
|
||||
// Non-final variables
|
||||
private static boolean EVENT_ACTIVE = false;
|
||||
private ScheduledFuture<?> _eventTask = null;
|
||||
private final Set<L2Npc> _elpies = ConcurrentHashMap.newKeySet(ELPY_AMOUNT);
|
||||
|
||||
private Elpies()
|
||||
{
|
||||
super(Elpies.class.getSimpleName(), "custom/events");
|
||||
addSpawnId(ELPY);
|
||||
addKillId(ELPY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventBypass(L2PcInstance activeChar, String bypass)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStart(L2PcInstance eventMaker)
|
||||
{
|
||||
if (EVENT_ACTIVE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check Custom Table - we use custom NPC's
|
||||
if (!Config.CUSTOM_NPC_DATA)
|
||||
{
|
||||
_log.info(getName() + ": Event can't be started because custom NPC table is disabled!");
|
||||
eventMaker.sendMessage("Event " + getName() + " can't be started because custom NPC table is disabled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
EVENT_ACTIVE = true;
|
||||
|
||||
final EventLocation[] locations = EventLocation.values();
|
||||
final EventLocation randomLoc = locations[getRandom(locations.length)];
|
||||
|
||||
final long despawnDelay = EVENT_DURATION_MINUTES * 60000;
|
||||
|
||||
for (int i = 0; i < ELPY_AMOUNT; i++)
|
||||
{
|
||||
_elpies.add(addSpawn(ELPY, randomLoc.getRandomX(), randomLoc.getRandomY(), randomLoc.getZ(), 0, true, despawnDelay));
|
||||
}
|
||||
|
||||
Broadcast.toAllOnlinePlayers("*Squeak Squeak*");
|
||||
Broadcast.toAllOnlinePlayers("Elpy invasion in " + randomLoc.getName());
|
||||
Broadcast.toAllOnlinePlayers("Help us exterminate them!");
|
||||
Broadcast.toAllOnlinePlayers("You have " + EVENT_DURATION_MINUTES + " minutes!");
|
||||
|
||||
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Time is up!");
|
||||
eventStop();
|
||||
}, despawnDelay);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStop()
|
||||
{
|
||||
if (!EVENT_ACTIVE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EVENT_ACTIVE = false;
|
||||
|
||||
if (_eventTask != null)
|
||||
{
|
||||
_eventTask.cancel(true);
|
||||
_eventTask = null;
|
||||
}
|
||||
|
||||
for (L2Npc npc : _elpies)
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
_elpies.clear();
|
||||
|
||||
Broadcast.toAllOnlinePlayers("*Squeak Squeak*");
|
||||
Broadcast.toAllOnlinePlayers("Elpy Event finished!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
|
||||
{
|
||||
if (EVENT_ACTIVE)
|
||||
{
|
||||
_elpies.remove(npc);
|
||||
|
||||
dropItem(npc, killer, DROPLIST_CONSUMABLES);
|
||||
dropItem(npc, killer, DROPLIST_CRYSTALS);
|
||||
|
||||
if (_elpies.isEmpty())
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("All elpies have been killed!");
|
||||
eventStop();
|
||||
}
|
||||
}
|
||||
|
||||
return super.onKill(npc, killer, isSummon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(L2Npc npc)
|
||||
{
|
||||
((L2EventMonsterInstance) npc).eventSetDropOnGround(true);
|
||||
((L2EventMonsterInstance) npc).eventSetBlockOffensiveSkills(true);
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
private static enum EventLocation
|
||||
{
|
||||
ADEN("Aden", 146558, 148341, 26622, 28560, -2200),
|
||||
DION("Dion", 18564, 19200, 144377, 145782, -3081),
|
||||
GLUDIN("Gludin", -84040, -81420, 150257, 151175, -3125),
|
||||
HV("Hunters Village", 116094, 117141, 75776, 77072, -2700),
|
||||
OREN("Oren", 82048, 82940, 53240, 54126, -1490);
|
||||
|
||||
private final String _name;
|
||||
private final int _minX;
|
||||
private final int _maxX;
|
||||
private final int _minY;
|
||||
private final int _maxY;
|
||||
private final int _z;
|
||||
|
||||
EventLocation(String name, int minX, int maxX, int minY, int maxY, int z)
|
||||
{
|
||||
_name = name;
|
||||
_minX = minX;
|
||||
_maxX = maxX;
|
||||
_minY = minY;
|
||||
_maxY = maxY;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public int getRandomX()
|
||||
{
|
||||
return getRandom(_minX, _maxX);
|
||||
}
|
||||
|
||||
public int getRandomY()
|
||||
{
|
||||
return getRandom(_minY, _maxY);
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
}
|
||||
|
||||
private static void dropItem(L2Npc mob, L2PcInstance player, int[][] droplist)
|
||||
{
|
||||
final int chance = getRandom(100);
|
||||
|
||||
for (int[] drop : droplist)
|
||||
{
|
||||
if (chance >= drop[1])
|
||||
{
|
||||
mob.dropItem(player, drop[0], getRandom(drop[2], drop[3]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Elpies();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Elpies;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2EventMonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
public final class Elpies extends Event
|
||||
{
|
||||
// NPC
|
||||
private static final int ELPY = 900100;
|
||||
// Amount of Elpies to spawn when the event starts
|
||||
private static final int ELPY_AMOUNT = 100;
|
||||
// Event duration in minutes
|
||||
private static final int EVENT_DURATION_MINUTES = 2;
|
||||
// @formatter:off
|
||||
private static final int[][] DROPLIST_CONSUMABLES =
|
||||
{
|
||||
// itemId, chance, min amount, max amount
|
||||
{ 1540, 80, 10, 15 }, // Quick Healing Potion
|
||||
{ 1538, 60, 5, 10 }, // Blessed Scroll of Escape
|
||||
{ 3936, 40, 5, 10 }, // Blessed Scroll of Ressurection
|
||||
{ 6387, 25, 5, 10 }, // Blessed Scroll of Ressurection Pets
|
||||
{ 22025, 15, 5, 10 }, // Powerful Healing Potion
|
||||
{ 6622, 10, 1, 1 }, // Giant's Codex
|
||||
{ 20034, 5, 1, 1 }, // Revita Pop
|
||||
{ 20004, 1, 1, 1 }, // Energy Ginseng
|
||||
{ 20004, 0, 1, 1 } // Energy Ginseng
|
||||
};
|
||||
|
||||
private static final int[][] DROPLIST_CRYSTALS =
|
||||
{
|
||||
{ 1458, 80, 50, 100 }, // Crystal D-Grade
|
||||
{ 1459, 60, 40, 80 }, // Crystal C-Grade
|
||||
{ 1460, 40, 30, 60 }, // Crystal B-Grade
|
||||
{ 1461, 20, 20, 30 }, // Crystal A-Grade
|
||||
{ 1462, 0, 10, 20 } // Crystal S-Grade
|
||||
};
|
||||
// @formatter:on
|
||||
// Non-final variables
|
||||
private static boolean EVENT_ACTIVE = false;
|
||||
private static int CURRENT_ELPY_COUNT = 0;
|
||||
private ScheduledFuture<?> _eventTask = null;
|
||||
|
||||
private Elpies()
|
||||
{
|
||||
addSpawnId(ELPY);
|
||||
addKillId(ELPY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventBypass(L2PcInstance activeChar, String bypass)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStart(L2PcInstance eventMaker)
|
||||
{
|
||||
if (EVENT_ACTIVE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check Custom Table - we use custom NPC's
|
||||
if (!Config.CUSTOM_NPC_DATA)
|
||||
{
|
||||
_log.info(getName() + ": Event can't be started because custom NPC table is disabled!");
|
||||
eventMaker.sendMessage("Event " + getName() + " can't be started because custom NPC table is disabled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
EVENT_ACTIVE = true;
|
||||
|
||||
final EventLocation[] locations = EventLocation.values();
|
||||
final EventLocation randomLoc = locations[getRandom(locations.length)];
|
||||
|
||||
CURRENT_ELPY_COUNT = 0;
|
||||
final long despawnDelay = EVENT_DURATION_MINUTES * 60000;
|
||||
|
||||
for (int i = 0; i < ELPY_AMOUNT; i++)
|
||||
{
|
||||
addSpawn(ELPY, randomLoc.getRandomX(), randomLoc.getRandomY(), randomLoc.getZ(), 0, true, despawnDelay);
|
||||
CURRENT_ELPY_COUNT++;
|
||||
}
|
||||
|
||||
Broadcast.toAllOnlinePlayers("*Squeak Squeak*");
|
||||
Broadcast.toAllOnlinePlayers("Elpy invasion in " + randomLoc.getName());
|
||||
Broadcast.toAllOnlinePlayers("Help us exterminate them!");
|
||||
Broadcast.toAllOnlinePlayers("You have " + EVENT_DURATION_MINUTES + " minutes!");
|
||||
|
||||
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Time is up!");
|
||||
eventStop();
|
||||
}, despawnDelay);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStop()
|
||||
{
|
||||
if (!EVENT_ACTIVE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
EVENT_ACTIVE = false;
|
||||
|
||||
if (_eventTask != null)
|
||||
{
|
||||
_eventTask.cancel(true);
|
||||
_eventTask = null;
|
||||
}
|
||||
|
||||
for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(ELPY))
|
||||
{
|
||||
final L2Npc npc = spawn.getLastSpawn();
|
||||
if (npc != null)
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
}
|
||||
|
||||
Broadcast.toAllOnlinePlayers("*Squeak Squeak*");
|
||||
Broadcast.toAllOnlinePlayers("Elpy Event finished!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
|
||||
{
|
||||
if (EVENT_ACTIVE)
|
||||
{
|
||||
dropItem(npc, killer, DROPLIST_CONSUMABLES);
|
||||
dropItem(npc, killer, DROPLIST_CRYSTALS);
|
||||
CURRENT_ELPY_COUNT--;
|
||||
|
||||
if (CURRENT_ELPY_COUNT <= 0)
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("All elpies have been killed!");
|
||||
eventStop();
|
||||
}
|
||||
}
|
||||
|
||||
return super.onKill(npc, killer, isSummon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSpawn(L2Npc npc)
|
||||
{
|
||||
((L2EventMonsterInstance) npc).eventSetDropOnGround(true);
|
||||
((L2EventMonsterInstance) npc).eventSetBlockOffensiveSkills(true);
|
||||
return super.onSpawn(npc);
|
||||
}
|
||||
|
||||
private static enum EventLocation
|
||||
{
|
||||
ADEN("Aden", 146558, 148341, 26622, 28560, -2200),
|
||||
DION("Dion", 18564, 19200, 144377, 145782, -3081),
|
||||
GLUDIN("Gludin", -84040, -81420, 150257, 151175, -3125),
|
||||
HV("Hunters Village", 116094, 117141, 75776, 77072, -2700),
|
||||
OREN("Oren", 82048, 82940, 53240, 54126, -1490);
|
||||
|
||||
private final String _name;
|
||||
private final int _minX;
|
||||
private final int _maxX;
|
||||
private final int _minY;
|
||||
private final int _maxY;
|
||||
private final int _z;
|
||||
|
||||
EventLocation(String name, int minX, int maxX, int minY, int maxY, int z)
|
||||
{
|
||||
_name = name;
|
||||
_minX = minX;
|
||||
_maxX = maxX;
|
||||
_minY = minY;
|
||||
_maxY = maxY;
|
||||
_z = z;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public int getRandomX()
|
||||
{
|
||||
return getRandom(_minX, _maxX);
|
||||
}
|
||||
|
||||
public int getRandomY()
|
||||
{
|
||||
return getRandom(_minY, _maxY);
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return _z;
|
||||
}
|
||||
}
|
||||
|
||||
private static final void dropItem(L2Npc mob, L2PcInstance player, int[][] droplist)
|
||||
{
|
||||
final int chance = getRandom(100);
|
||||
|
||||
for (int[] drop : droplist)
|
||||
{
|
||||
if (chance >= drop[1])
|
||||
{
|
||||
mob.dropItem(player, drop[0], getRandom(drop[2], drop[3]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Elpies();
|
||||
}
|
||||
}
|
||||
|
@@ -1,274 +1,275 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Rabbits;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Rabbits event.<br>
|
||||
* Chests are hidden at Fantasy Isle and players must use the Rabbit transformation's skills to find and open them.
|
||||
* @author Gnacik, Zoey76
|
||||
*/
|
||||
final class Rabbits extends Event
|
||||
{
|
||||
// NPCs
|
||||
private static final int NPC_MANAGER = 900101;
|
||||
private static final int CHEST = 900102;
|
||||
// Skills
|
||||
private static final SkillHolder RABBIT_MAGIC_EYE = new SkillHolder(629, 1);
|
||||
private static final SkillHolder RABBIT_TORNADO = new SkillHolder(630, 1);
|
||||
private static final SkillHolder RABBIT_TRANSFORMATION = new SkillHolder(2428, 1);
|
||||
private static final SkillHolder RAID_CURSE = new SkillHolder(4515, 1);
|
||||
// Misc
|
||||
private static final int EVENT_TIME = 10;
|
||||
private static final int TOTAL_CHEST_COUNT = 75;
|
||||
private static final int TRANSFORMATION_ID = 105;
|
||||
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet(TOTAL_CHEST_COUNT + 1);
|
||||
private final List<L2PcInstance> _players = new ArrayList<>();
|
||||
private boolean _isActive = false;
|
||||
|
||||
/**
|
||||
* Drop data:<br>
|
||||
* Higher the chance harder the item.<br>
|
||||
* ItemId, chance in percent, min amount, max amount
|
||||
*/
|
||||
// @formatter:off
|
||||
private static final int[][] DROPLIST =
|
||||
{
|
||||
{ 1540, 80, 10, 15 }, // Quick Healing Potion
|
||||
{ 1538, 60, 5, 10 }, // Blessed Scroll of Escape
|
||||
{ 3936, 40, 5, 10 }, // Blessed Scroll of Ressurection
|
||||
{ 6387, 25, 5, 10 }, // Blessed Scroll of Ressurection Pets
|
||||
{ 22025, 15, 5, 10 }, // Powerful Healing Potion
|
||||
{ 6622, 10, 1, 1 }, // Giant's Codex
|
||||
{ 20034, 5, 1, 1 }, // Revita Pop
|
||||
{ 20004, 1, 1, 1 }, // Energy Ginseng
|
||||
{ 20004, 0, 1, 1 } // Energy Ginseng
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
private Rabbits()
|
||||
{
|
||||
super(Rabbits.class.getSimpleName(), "custom/events");
|
||||
addFirstTalkId(NPC_MANAGER, CHEST);
|
||||
addTalkId(NPC_MANAGER);
|
||||
addStartNpc(NPC_MANAGER);
|
||||
addSkillSeeId(CHEST);
|
||||
addAttackId(CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStart(L2PcInstance eventMaker)
|
||||
{
|
||||
// Don't start event if its active
|
||||
if (_isActive)
|
||||
{
|
||||
eventMaker.sendMessage("Event " + getName() + " is already started!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check starting conditions
|
||||
if (!Config.CUSTOM_NPC_DATA)
|
||||
{
|
||||
_log.info(getName() + ": Event can't be started, because custom NPCs are disabled!");
|
||||
eventMaker.sendMessage("Event " + getName() + " can't be started because custom NPCs are disabled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set Event active
|
||||
_isActive = true;
|
||||
|
||||
// Spawn Manager
|
||||
recordSpawn(_npcs, NPC_MANAGER, -59227, -56939, -2039, 64106, false, 0);
|
||||
// Spawn Chests
|
||||
for (int i = 0; i <= TOTAL_CHEST_COUNT; i++)
|
||||
{
|
||||
recordSpawn(_npcs, CHEST, getRandom(-60653, -58772), getRandom(-55830, -58146), -2030, 0, false, EVENT_TIME * 60000);
|
||||
}
|
||||
|
||||
// Announce event start
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Chests spawned!");
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Go to Fantasy Isle and grab some rewards!");
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: You have " + EVENT_TIME + " minutes!");
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: After that time all chests will disappear...");
|
||||
// Schedule event end
|
||||
startQuestTimer("END_RABBITS_EVENT", EVENT_TIME * 60000, null, eventMaker);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStop()
|
||||
{
|
||||
// Don't stop inactive event
|
||||
if (!_isActive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set inactive
|
||||
_isActive = false;
|
||||
|
||||
// Cancel timer
|
||||
cancelQuestTimers("END_RABBITS_EVENT");
|
||||
|
||||
// Despawn NPCs
|
||||
for (L2Npc npc : _npcs)
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
_npcs.clear();
|
||||
|
||||
for (L2PcInstance player : _players)
|
||||
{
|
||||
if (player.getTransformationId() == TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
}
|
||||
_players.clear();
|
||||
|
||||
// Announce event end
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Event has finished.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
switch (event)
|
||||
{
|
||||
case "900101-1.htm":
|
||||
{
|
||||
htmltext = "900101-1.htm";
|
||||
break;
|
||||
}
|
||||
case "transform":
|
||||
{
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
|
||||
RABBIT_TRANSFORMATION.getSkill().applyEffects(npc, player);
|
||||
_players.add(player);
|
||||
break;
|
||||
}
|
||||
case "END_RABBITS_EVENT":
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Time up!");
|
||||
eventStop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return npc.getId() + ".htm";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
|
||||
{
|
||||
if (skill.getId() == RABBIT_TORNADO.getSkillId())
|
||||
{
|
||||
if (!npc.isInvisible() && Util.contains(targets, npc))
|
||||
{
|
||||
dropItem(npc, caster, DROPLIST);
|
||||
npc.deleteMe();
|
||||
_npcs.remove(npc);
|
||||
|
||||
if (_npcs.isEmpty())
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: No more chests...");
|
||||
eventStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (skill.getId() == RABBIT_MAGIC_EYE.getSkillId())
|
||||
{
|
||||
if (npc.isInvisible() && npc.isInsideRadius(caster, skill.getAffectRange(), false, false))
|
||||
{
|
||||
npc.setInvisible(false);
|
||||
}
|
||||
}
|
||||
return super.onSkillSee(npc, caster, skill, targets, isSummon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
|
||||
{
|
||||
if (_isActive && ((skill == null) || (skill.getId() != RABBIT_TORNADO.getSkillId())))
|
||||
{
|
||||
RAID_CURSE.getSkill().applyEffects(npc, attacker);
|
||||
}
|
||||
return super.onAttack(npc, attacker, damage, isSummon);
|
||||
}
|
||||
|
||||
private static void dropItem(L2Npc npc, L2PcInstance player, int[][] droplist)
|
||||
{
|
||||
final int chance = getRandom(100);
|
||||
for (int[] drop : droplist)
|
||||
{
|
||||
if (chance > drop[1])
|
||||
{
|
||||
npc.dropItem(player, drop[0], getRandom(drop[2], drop[3]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void recordSpawn(Set<L2Npc> npcs, int npcId, int x, int y, int z, int heading, boolean randomOffSet, long despawnDelay)
|
||||
{
|
||||
final L2Npc npc = addSpawn(npcId, x, y, z, heading, randomOffSet, despawnDelay);
|
||||
if (npc.getId() == CHEST)
|
||||
{
|
||||
npc.setIsImmobilized(true);
|
||||
npc.disableCoreAI(true);
|
||||
npc.setInvisible(true);
|
||||
}
|
||||
npcs.add(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventBypass(L2PcInstance activeChar, String bypass)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Rabbits();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Rabbits;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* Rabbits event.<br>
|
||||
* Chests are hidden at Fantasy Isle and players must use the Rabbit transformation's skills to find and open them.
|
||||
* @author Gnacik, Zoey76
|
||||
*/
|
||||
public final class Rabbits extends Event
|
||||
{
|
||||
// NPCs
|
||||
private static final int NPC_MANAGER = 900101;
|
||||
private static final int CHEST = 900102;
|
||||
// Skills
|
||||
private static final SkillHolder RABBIT_MAGIC_EYE = new SkillHolder(629, 1);
|
||||
private static final SkillHolder RABBIT_TORNADO = new SkillHolder(630, 1);
|
||||
private static final SkillHolder RABBIT_TRANSFORMATION = new SkillHolder(2428, 1);
|
||||
private static final SkillHolder RAID_CURSE = new SkillHolder(4515, 1);
|
||||
// Misc
|
||||
private static final int EVENT_TIME = 10;
|
||||
private static final int TOTAL_CHEST_COUNT = 75;
|
||||
private static final int TRANSFORMATION_ID = 105;
|
||||
private final List<L2Npc> _npcs = new CopyOnWriteArrayList<>();
|
||||
private final List<L2PcInstance> _players = new ArrayList<>();
|
||||
private boolean _isActive = false;
|
||||
|
||||
/**
|
||||
* Drop data:<br>
|
||||
* Higher the chance harder the item.<br>
|
||||
* ItemId, chance in percent, min amount, max amount
|
||||
*/
|
||||
// @formatter:off
|
||||
private static final int[][] DROPLIST =
|
||||
{
|
||||
{ 1540, 80, 10, 15 }, // Quick Healing Potion
|
||||
{ 1538, 60, 5, 10 }, // Blessed Scroll of Escape
|
||||
{ 3936, 40, 5, 10 }, // Blessed Scroll of Ressurection
|
||||
{ 6387, 25, 5, 10 }, // Blessed Scroll of Ressurection Pets
|
||||
{ 22025, 15, 5, 10 }, // Powerful Healing Potion
|
||||
{ 6622, 10, 1, 1 }, // Giant's Codex
|
||||
{ 20034, 5, 1, 1 }, // Revita Pop
|
||||
{ 20004, 1, 1, 1 }, // Energy Ginseng
|
||||
{ 20004, 0, 1, 1 } // Energy Ginseng
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
private Rabbits()
|
||||
{
|
||||
addFirstTalkId(NPC_MANAGER, CHEST);
|
||||
addTalkId(NPC_MANAGER);
|
||||
addStartNpc(NPC_MANAGER);
|
||||
addSkillSeeId(CHEST);
|
||||
addAttackId(CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStart(L2PcInstance eventMaker)
|
||||
{
|
||||
// Don't start event if its active
|
||||
if (_isActive)
|
||||
{
|
||||
eventMaker.sendMessage("Event " + getName() + " is already started!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check starting conditions
|
||||
if (!Config.CUSTOM_NPC_DATA)
|
||||
{
|
||||
_log.info(getName() + ": Event can't be started, because custom NPCs are disabled!");
|
||||
eventMaker.sendMessage("Event " + getName() + " can't be started because custom NPCs are disabled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set Event active
|
||||
_isActive = true;
|
||||
|
||||
// Spawn Manager
|
||||
recordSpawn(_npcs, NPC_MANAGER, -59227, -56939, -2039, 64106, false, 0);
|
||||
// Spawn Chests
|
||||
for (int i = 0; i <= TOTAL_CHEST_COUNT; i++)
|
||||
{
|
||||
recordSpawn(_npcs, CHEST, getRandom(-60653, -58772), getRandom(-55830, -58146), -2030, 0, false, EVENT_TIME * 60000);
|
||||
}
|
||||
|
||||
// Announce event start
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Chests spawned!");
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Go to Fantasy Isle and grab some rewards!");
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: You have " + EVENT_TIME + " minuntes!");
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: After that time all chests will disappear...");
|
||||
// Schedule event end
|
||||
startQuestTimer("END_RABBITS_EVENT", EVENT_TIME * 60000, null, eventMaker);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStop()
|
||||
{
|
||||
// Don't stop inactive event
|
||||
if (!_isActive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set inactive
|
||||
_isActive = false;
|
||||
|
||||
// Cancel timer
|
||||
cancelQuestTimers("END_RABBITS_EVENT");
|
||||
|
||||
// Despawn NPCs
|
||||
for (L2Npc npc : _npcs)
|
||||
{
|
||||
if (npc != null)
|
||||
{
|
||||
npc.deleteMe();
|
||||
}
|
||||
}
|
||||
_npcs.clear();
|
||||
|
||||
for (L2PcInstance player : _players)
|
||||
{
|
||||
if ((player != null) && (player.getTransformationId() == TRANSFORMATION_ID))
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
}
|
||||
_players.clear();
|
||||
|
||||
// Announce event end
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Event has finished.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
switch (event)
|
||||
{
|
||||
case "900101-1.htm":
|
||||
{
|
||||
htmltext = "900101-1.htm";
|
||||
break;
|
||||
}
|
||||
case "transform":
|
||||
{
|
||||
if (player.isTransformed())
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
|
||||
RABBIT_TRANSFORMATION.getSkill().applyEffects(npc, player);
|
||||
_players.add(player);
|
||||
break;
|
||||
}
|
||||
case "END_RABBITS_EVENT":
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: Time up!");
|
||||
eventStop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return npc.getId() + ".htm";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onSkillSee(L2Npc npc, L2PcInstance caster, Skill skill, L2Object[] targets, boolean isSummon)
|
||||
{
|
||||
if (skill.getId() == RABBIT_TORNADO.getSkillId())
|
||||
{
|
||||
if (!npc.isInvisible() && CommonUtil.contains(targets, npc))
|
||||
{
|
||||
dropItem(npc, caster, DROPLIST);
|
||||
npc.deleteMe();
|
||||
_npcs.remove(npc);
|
||||
|
||||
if (_npcs.size() <= 1)
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Rabbits Event: No more chests...");
|
||||
eventStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (skill.getId() == RABBIT_MAGIC_EYE.getSkillId())
|
||||
{
|
||||
if (npc.isInvisible() && npc.isInsideRadius(caster, skill.getAffectRange(), false, false))
|
||||
{
|
||||
npc.setInvisible(false);
|
||||
}
|
||||
}
|
||||
return super.onSkillSee(npc, caster, skill, targets, isSummon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill)
|
||||
{
|
||||
if (_isActive && ((skill == null) || (skill.getId() != RABBIT_TORNADO.getSkillId())))
|
||||
{
|
||||
RAID_CURSE.getSkill().applyEffects(npc, attacker);
|
||||
}
|
||||
return super.onAttack(npc, attacker, damage, isSummon);
|
||||
}
|
||||
|
||||
private static void dropItem(L2Npc npc, L2PcInstance player, int[][] droplist)
|
||||
{
|
||||
final int chance = getRandom(100);
|
||||
for (int[] drop : droplist)
|
||||
{
|
||||
if (chance > drop[1])
|
||||
{
|
||||
npc.dropItem(player, drop[0], getRandom(drop[2], drop[3]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void recordSpawn(List<L2Npc> npcs, int npcId, int x, int y, int z, int heading, boolean randomOffSet, long despawnDelay)
|
||||
{
|
||||
final L2Npc npc = addSpawn(npcId, x, y, z, heading, randomOffSet, despawnDelay);
|
||||
if (npc.getId() == CHEST)
|
||||
{
|
||||
npc.setIsImmobilized(true);
|
||||
npc.disableCoreAI(true);
|
||||
npc.setInvisible(true);
|
||||
}
|
||||
npcs.add(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventBypass(L2PcInstance activeChar, String bypass)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Rabbits();
|
||||
}
|
||||
}
|
||||
|
@@ -1,402 +1,411 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Race;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
final class Race extends Event
|
||||
{
|
||||
// Event NPC's list
|
||||
private final Set<L2Npc> _npcs = ConcurrentHashMap.newKeySet();
|
||||
// Npc
|
||||
private L2Npc _npc;
|
||||
// Player list
|
||||
private final Set<L2PcInstance> _players = ConcurrentHashMap.newKeySet();
|
||||
// Event Task
|
||||
ScheduledFuture<?> _eventTask = null;
|
||||
// Event state
|
||||
private static boolean _isactive = false;
|
||||
// Race state
|
||||
private static boolean _isRaceStarted = false;
|
||||
// 5 min for register
|
||||
private static final int _time_register = 5;
|
||||
// 5 min for race
|
||||
private static final int _time_race = 10;
|
||||
// NPC's
|
||||
private static final int _start_npc = 900103;
|
||||
private static final int _stop_npc = 900104;
|
||||
// Skills (Frog by default)
|
||||
private static int _skill = 6201;
|
||||
// We must keep second NPC spawn for radar
|
||||
private static int[] _randspawn = null;
|
||||
// Locations
|
||||
private static final String[] _locations =
|
||||
{
|
||||
"Heretic catacomb enterance",
|
||||
"Dion castle bridge",
|
||||
"Floran village enterance",
|
||||
"Floran fort gate"
|
||||
};
|
||||
|
||||
// @formatter:off
|
||||
private static final int[][] _coords =
|
||||
{
|
||||
// x, y, z, heading
|
||||
{ 39177, 144345, -3650, 0 },
|
||||
{ 22294, 155892, -2950, 0 },
|
||||
{ 16537, 169937, -3500, 0 },
|
||||
{ 7644, 150898, -2890, 0 }
|
||||
};
|
||||
private static final int[][] _rewards =
|
||||
{
|
||||
{ 6622, 2 }, // Giant's Codex
|
||||
{ 9625, 2 }, // Giant's Codex -
|
||||
{ 9626, 2 }, // Giant's Codex -
|
||||
{ 9627, 2 }, // Giant's Codex -
|
||||
{ 9546, 5 }, // Attr stones
|
||||
{ 9547, 5 },
|
||||
{ 9548, 5 },
|
||||
{ 9549, 5 },
|
||||
{ 9550, 5 },
|
||||
{ 9551, 5 },
|
||||
{ 9574, 3 }, // Mid-Grade Life Stone: level 80
|
||||
{ 9575, 2 }, // High-Grade Life Stone: level 80
|
||||
{ 9576, 1 }, // Top-Grade Life Stone: level 80
|
||||
{ 20034,1 } // Revita pop
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
private Race()
|
||||
{
|
||||
super(Race.class.getSimpleName(), "custom/events");
|
||||
addStartNpc(_start_npc);
|
||||
addFirstTalkId(_start_npc);
|
||||
addTalkId(_start_npc);
|
||||
addStartNpc(_stop_npc);
|
||||
addFirstTalkId(_stop_npc);
|
||||
addTalkId(_stop_npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStart(L2PcInstance eventMaker)
|
||||
{
|
||||
// Don't start event if its active
|
||||
if (_isactive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check Custom Table - we use custom NPC's
|
||||
if (!Config.CUSTOM_NPC_DATA)
|
||||
{
|
||||
_log.info(getName() + ": Event can't be started, because custom npc table is disabled!");
|
||||
eventMaker.sendMessage("Event " + getName() + " can't be started because custom NPC table is disabled!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set Event active
|
||||
_isactive = true;
|
||||
// Spawn Manager
|
||||
_npc = recordSpawn(_start_npc, 18429, 145861, -3090, 0, false, 0);
|
||||
|
||||
// Announce event start
|
||||
Broadcast.toAllOnlinePlayers("* Race Event started! *");
|
||||
Broadcast.toAllOnlinePlayers("Visit Event Manager in Dion village and signup, you have " + _time_register + " min before Race Start...");
|
||||
|
||||
// Schedule Event end
|
||||
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> StartRace(), _time_register * 60 * 1000);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void StartRace()
|
||||
{
|
||||
// Abort race if no players signup
|
||||
if (_players.isEmpty())
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Race aborted, nobody signup.");
|
||||
eventStop();
|
||||
return;
|
||||
}
|
||||
// Set state
|
||||
_isRaceStarted = true;
|
||||
// Announce
|
||||
Broadcast.toAllOnlinePlayers("Race started!");
|
||||
// Get random Finish
|
||||
final int location = getRandom(0, _locations.length - 1);
|
||||
_randspawn = _coords[location];
|
||||
// And spawn NPC
|
||||
recordSpawn(_stop_npc, _randspawn[0], _randspawn[1], _randspawn[2], _randspawn[3], false, 0);
|
||||
// Transform players and send message
|
||||
for (L2PcInstance player : _players)
|
||||
{
|
||||
if (player.isOnline())
|
||||
{
|
||||
if (player.isInsideRadius(_npc, 500, false, false))
|
||||
{
|
||||
sendMessage(player, "Race started! Go find Finish NPC as fast as you can... He is located near " + _locations[location]);
|
||||
transformPlayer(player);
|
||||
player.getRadar().addMarker(_randspawn[0], _randspawn[1], _randspawn[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendMessage(player, "I told you stay near me right? Distance was too high, you are excluded from race");
|
||||
_players.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Schedule timeup for Race
|
||||
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> timeUp(), _time_race * 60 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStop()
|
||||
{
|
||||
// Don't stop inactive event
|
||||
if (!_isactive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set inactive
|
||||
_isactive = false;
|
||||
_isRaceStarted = false;
|
||||
|
||||
// Cancel task if any
|
||||
if (_eventTask != null)
|
||||
{
|
||||
_eventTask.cancel(true);
|
||||
_eventTask = null;
|
||||
}
|
||||
// Untransform players
|
||||
// Teleport to event start point
|
||||
for (L2PcInstance player : _players)
|
||||
{
|
||||
if (player.isOnline())
|
||||
{
|
||||
player.untransform();
|
||||
player.teleToLocation(_npc.getX(), _npc.getY(), _npc.getZ(), true);
|
||||
}
|
||||
}
|
||||
_players.clear();
|
||||
// Despawn NPCs
|
||||
for (L2Npc _npc : _npcs)
|
||||
{
|
||||
_npc.deleteMe();
|
||||
}
|
||||
_npcs.clear();
|
||||
// Announce event end
|
||||
Broadcast.toAllOnlinePlayers("* Race Event finished *");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventBypass(L2PcInstance activeChar, String bypass)
|
||||
{
|
||||
if (bypass.startsWith("skill"))
|
||||
{
|
||||
if (_isRaceStarted)
|
||||
{
|
||||
activeChar.sendMessage("Race already started, you cannot change transform skill now");
|
||||
}
|
||||
else
|
||||
{
|
||||
final int _number = Integer.valueOf(bypass.substring(5));
|
||||
final Skill _sk = SkillData.getInstance().getSkill(_number, 1);
|
||||
if (_sk != null)
|
||||
{
|
||||
_skill = _number;
|
||||
activeChar.sendMessage("Transform skill set to:");
|
||||
activeChar.sendMessage(_sk.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Error while changing transform skill");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bypass.startsWith("tele"))
|
||||
{
|
||||
if ((Integer.valueOf(bypass.substring(4)) > 0) && (_randspawn != null))
|
||||
{
|
||||
activeChar.teleToLocation(_randspawn[0], _randspawn[1], _randspawn[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.teleToLocation(18429, 145861, -3090);
|
||||
}
|
||||
}
|
||||
showMenu(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
final String htmltext = event;
|
||||
final QuestState qs = getQuestState(player, false);
|
||||
if (qs == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (event.equalsIgnoreCase("transform"))
|
||||
{
|
||||
transformPlayer(player);
|
||||
return null;
|
||||
}
|
||||
else if (event.equalsIgnoreCase("untransform"))
|
||||
{
|
||||
player.untransform();
|
||||
return null;
|
||||
}
|
||||
else if (event.equalsIgnoreCase("showfinish"))
|
||||
{
|
||||
player.getRadar().addMarker(_randspawn[0], _randspawn[1], _randspawn[2]);
|
||||
return null;
|
||||
}
|
||||
else if (event.equalsIgnoreCase("signup"))
|
||||
{
|
||||
if (_players.contains(player))
|
||||
{
|
||||
return "900103-onlist.htm";
|
||||
}
|
||||
_players.add(player);
|
||||
return "900103-signup.htm";
|
||||
}
|
||||
else if (event.equalsIgnoreCase("quit"))
|
||||
{
|
||||
player.untransform();
|
||||
if (_players.contains(player))
|
||||
{
|
||||
_players.remove(player);
|
||||
}
|
||||
return "900103-quit.htm";
|
||||
}
|
||||
else if (event.equalsIgnoreCase("finish"))
|
||||
{
|
||||
if (player.isAffectedBySkill(_skill))
|
||||
{
|
||||
winRace(player);
|
||||
return "900104-winner.htm";
|
||||
}
|
||||
return "900104-notrans.htm";
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
getQuestState(player, true);
|
||||
|
||||
if (npc.getId() == _start_npc)
|
||||
{
|
||||
if (_isRaceStarted)
|
||||
{
|
||||
return _start_npc + "-started-" + isRacing(player) + ".htm";
|
||||
}
|
||||
return _start_npc + "-" + isRacing(player) + ".htm";
|
||||
}
|
||||
else if ((npc.getId() == _stop_npc) && _isRaceStarted)
|
||||
{
|
||||
return _stop_npc + "-" + isRacing(player) + ".htm";
|
||||
}
|
||||
return npc.getId() + ".htm";
|
||||
}
|
||||
|
||||
private int isRacing(L2PcInstance player)
|
||||
{
|
||||
return _players.contains(player) ? 1 : 0;
|
||||
}
|
||||
|
||||
private L2Npc recordSpawn(int npcId, int x, int y, int z, int heading, boolean randomOffSet, long despawnDelay)
|
||||
{
|
||||
final L2Npc npc = addSpawn(npcId, x, y, z, heading, randomOffSet, despawnDelay);
|
||||
_npcs.add(npc);
|
||||
return npc;
|
||||
}
|
||||
|
||||
private void transformPlayer(L2PcInstance player)
|
||||
{
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
if (player.isSitting())
|
||||
{
|
||||
player.standUp();
|
||||
}
|
||||
|
||||
player.getEffectList().stopSkillEffects(true, AbnormalType.SPEED_UP);
|
||||
player.stopSkillEffects(true, 268);
|
||||
player.stopSkillEffects(true, 298); // Rabbit Spirit Totem
|
||||
SkillData.getInstance().getSkill(_skill, 1).applyEffects(player, player);
|
||||
}
|
||||
|
||||
private void sendMessage(L2PcInstance player, String text)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(_npc.getObjectId(), ChatType.MPCC_ROOM, _npc.getName(), text));
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
final String content = getHtm(activeChar.getHtmlPrefix(), "admin_menu.htm");
|
||||
html.setHtml(content);
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
private void timeUp()
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Time up, nobody wins!");
|
||||
eventStop();
|
||||
}
|
||||
|
||||
private void winRace(L2PcInstance player)
|
||||
{
|
||||
final int[] _reward = _rewards[getRandom(_rewards.length - 1)];
|
||||
player.addItem("eventModRace", _reward[0], _reward[1], _npc, true);
|
||||
Broadcast.toAllOnlinePlayers(player.getName() + " is a winner!");
|
||||
eventStop();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Race();
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Race;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* @author Gnacik
|
||||
*/
|
||||
public final class Race extends Event
|
||||
{
|
||||
// Event NPC's list
|
||||
private List<L2Npc> _npclist;
|
||||
// Npc
|
||||
private L2Npc _npc;
|
||||
// Player list
|
||||
private List<L2PcInstance> _players;
|
||||
// Event Task
|
||||
ScheduledFuture<?> _eventTask = null;
|
||||
// Event state
|
||||
private static boolean _isactive = false;
|
||||
// Race state
|
||||
private static boolean _isRaceStarted = false;
|
||||
// 5 min for register
|
||||
private static final int _time_register = 5;
|
||||
// 5 min for race
|
||||
private static final int _time_race = 10;
|
||||
// NPC's
|
||||
private static final int _start_npc = 900103;
|
||||
private static final int _stop_npc = 900104;
|
||||
// Skills (Frog by default)
|
||||
private static int _skill = 6201;
|
||||
// We must keep second NPC spawn for radar
|
||||
private static int[] _randspawn = null;
|
||||
// Locations
|
||||
private static final String[] _locations =
|
||||
{
|
||||
"Heretic catacomb enterance",
|
||||
"Dion castle bridge",
|
||||
"Floran village enterance",
|
||||
"Floran fort gate"
|
||||
};
|
||||
|
||||
// @formatter:off
|
||||
private static final int[][] _coords =
|
||||
{
|
||||
// x, y, z, heading
|
||||
{ 39177, 144345, -3650, 0 },
|
||||
{ 22294, 155892, -2950, 0 },
|
||||
{ 16537, 169937, -3500, 0 },
|
||||
{ 7644, 150898, -2890, 0 }
|
||||
};
|
||||
private static final int[][] _rewards =
|
||||
{
|
||||
{ 6622, 2 }, // Giant's Codex
|
||||
{ 9625, 2 }, // Giant's Codex -
|
||||
{ 9626, 2 }, // Giant's Codex -
|
||||
{ 9627, 2 }, // Giant's Codex -
|
||||
{ 9546, 5 }, // Attr stones
|
||||
{ 9547, 5 },
|
||||
{ 9548, 5 },
|
||||
{ 9549, 5 },
|
||||
{ 9550, 5 },
|
||||
{ 9551, 5 },
|
||||
{ 9574, 3 }, // Mid-Grade Life Stone: level 80
|
||||
{ 9575, 2 }, // High-Grade Life Stone: level 80
|
||||
{ 9576, 1 }, // Top-Grade Life Stone: level 80
|
||||
{ 20034,1 } // Revita pop
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
private Race()
|
||||
{
|
||||
addStartNpc(_start_npc);
|
||||
addFirstTalkId(_start_npc);
|
||||
addTalkId(_start_npc);
|
||||
addStartNpc(_stop_npc);
|
||||
addFirstTalkId(_stop_npc);
|
||||
addTalkId(_stop_npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStart(L2PcInstance eventMaker)
|
||||
{
|
||||
// Don't start event if its active
|
||||
if (_isactive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Check Custom Table - we use custom NPC's
|
||||
if (!Config.CUSTOM_NPC_DATA)
|
||||
{
|
||||
_log.info(getName() + ": Event can't be started, because custom npc table is disabled!");
|
||||
eventMaker.sendMessage("Event " + getName() + " can't be started because custom NPC table is disabled!");
|
||||
return false;
|
||||
}
|
||||
// Initialize list
|
||||
_npclist = new ArrayList<>();
|
||||
_players = new CopyOnWriteArrayList<>();
|
||||
// Set Event active
|
||||
_isactive = true;
|
||||
// Spawn Manager
|
||||
_npc = recordSpawn(_start_npc, 18429, 145861, -3090, 0, false, 0);
|
||||
|
||||
// Announce event start
|
||||
Broadcast.toAllOnlinePlayers("* Race Event started! *");
|
||||
Broadcast.toAllOnlinePlayers("Visit Event Manager in Dion village and signup, you have " + _time_register + " min before Race Start...");
|
||||
|
||||
// Schedule Event end
|
||||
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> StartRace(), _time_register * 60 * 1000);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
protected void StartRace()
|
||||
{
|
||||
// Abort race if no players signup
|
||||
if (_players.isEmpty())
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Race aborted, nobody signup.");
|
||||
eventStop();
|
||||
return;
|
||||
}
|
||||
// Set state
|
||||
_isRaceStarted = true;
|
||||
// Announce
|
||||
Broadcast.toAllOnlinePlayers("Race started!");
|
||||
// Get random Finish
|
||||
final int location = getRandom(0, _locations.length - 1);
|
||||
_randspawn = _coords[location];
|
||||
// And spawn NPC
|
||||
recordSpawn(_stop_npc, _randspawn[0], _randspawn[1], _randspawn[2], _randspawn[3], false, 0);
|
||||
// Transform players and send message
|
||||
for (L2PcInstance player : _players)
|
||||
{
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
if (player.isInsideRadius(_npc, 500, false, false))
|
||||
{
|
||||
sendMessage(player, "Race started! Go find Finish NPC as fast as you can... He is located near " + _locations[location]);
|
||||
transformPlayer(player);
|
||||
player.getRadar().addMarker(_randspawn[0], _randspawn[1], _randspawn[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendMessage(player, "I told you stay near me right? Distance was too high, you are excluded from race");
|
||||
_players.remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Schedule timeup for Race
|
||||
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> timeUp(), _time_race * 60 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventStop()
|
||||
{
|
||||
// Don't stop inactive event
|
||||
if (!_isactive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set inactive
|
||||
_isactive = false;
|
||||
_isRaceStarted = false;
|
||||
|
||||
// Cancel task if any
|
||||
if (_eventTask != null)
|
||||
{
|
||||
_eventTask.cancel(true);
|
||||
_eventTask = null;
|
||||
}
|
||||
// Untransform players
|
||||
// Teleport to event start point
|
||||
for (L2PcInstance player : _players)
|
||||
{
|
||||
if ((player != null) && player.isOnline())
|
||||
{
|
||||
player.untransform();
|
||||
player.teleToLocation(_npc, true);
|
||||
}
|
||||
}
|
||||
// Despawn NPCs
|
||||
for (L2Npc _npc : _npclist)
|
||||
{
|
||||
if (_npc != null)
|
||||
{
|
||||
_npc.deleteMe();
|
||||
}
|
||||
}
|
||||
_npclist.clear();
|
||||
_players.clear();
|
||||
// Announce event end
|
||||
Broadcast.toAllOnlinePlayers("* Race Event finished *");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eventBypass(L2PcInstance activeChar, String bypass)
|
||||
{
|
||||
if (bypass.startsWith("skill"))
|
||||
{
|
||||
if (_isRaceStarted)
|
||||
{
|
||||
activeChar.sendMessage("Race already started, you cannot change transform skill now");
|
||||
}
|
||||
else
|
||||
{
|
||||
final int _number = Integer.valueOf(bypass.substring(5));
|
||||
final Skill _sk = SkillData.getInstance().getSkill(_number, 1);
|
||||
if (_sk != null)
|
||||
{
|
||||
_skill = _number;
|
||||
activeChar.sendMessage("Transform skill set to:");
|
||||
activeChar.sendMessage(_sk.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Error while changing transform skill");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (bypass.startsWith("tele"))
|
||||
{
|
||||
if ((Integer.valueOf(bypass.substring(4)) > 0) && (_randspawn != null))
|
||||
{
|
||||
activeChar.teleToLocation(_randspawn[0], _randspawn[1], _randspawn[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.teleToLocation(18429, 145861, -3090);
|
||||
}
|
||||
}
|
||||
showMenu(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
final String htmltext = event;
|
||||
final QuestState st = getQuestState(player, false);
|
||||
if (st == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (event.equalsIgnoreCase("transform"))
|
||||
{
|
||||
transformPlayer(player);
|
||||
return null;
|
||||
}
|
||||
else if (event.equalsIgnoreCase("untransform"))
|
||||
{
|
||||
player.untransform();
|
||||
return null;
|
||||
}
|
||||
else if (event.equalsIgnoreCase("showfinish"))
|
||||
{
|
||||
player.getRadar().addMarker(_randspawn[0], _randspawn[1], _randspawn[2]);
|
||||
return null;
|
||||
}
|
||||
else if (event.equalsIgnoreCase("signup"))
|
||||
{
|
||||
if (_players.contains(player))
|
||||
{
|
||||
return "900103-onlist.htm";
|
||||
}
|
||||
_players.add(player);
|
||||
return "900103-signup.htm";
|
||||
}
|
||||
else if (event.equalsIgnoreCase("quit"))
|
||||
{
|
||||
player.untransform();
|
||||
if (_players.contains(player))
|
||||
{
|
||||
_players.remove(player);
|
||||
}
|
||||
return "900103-quit.htm";
|
||||
}
|
||||
else if (event.equalsIgnoreCase("finish"))
|
||||
{
|
||||
if (player.isAffectedBySkill(_skill))
|
||||
{
|
||||
winRace(player);
|
||||
return "900104-winner.htm";
|
||||
}
|
||||
return "900104-notrans.htm";
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
getQuestState(player, true);
|
||||
|
||||
if (npc.getId() == _start_npc)
|
||||
{
|
||||
if (_isRaceStarted)
|
||||
{
|
||||
return _start_npc + "-started-" + isRacing(player) + ".htm";
|
||||
}
|
||||
return _start_npc + "-" + isRacing(player) + ".htm";
|
||||
}
|
||||
else if ((npc.getId() == _stop_npc) && _isRaceStarted)
|
||||
{
|
||||
return _stop_npc + "-" + isRacing(player) + ".htm";
|
||||
}
|
||||
return npc.getId() + ".htm";
|
||||
}
|
||||
|
||||
private int isRacing(L2PcInstance player)
|
||||
{
|
||||
return _players.contains(player) ? 1 : 0;
|
||||
}
|
||||
|
||||
private L2Npc recordSpawn(int npcId, int x, int y, int z, int heading, boolean randomOffSet, long despawnDelay)
|
||||
{
|
||||
final L2Npc npc = addSpawn(npcId, x, y, z, heading, randomOffSet, despawnDelay);
|
||||
if (npc != null)
|
||||
{
|
||||
_npclist.add(npc);
|
||||
}
|
||||
return npc;
|
||||
}
|
||||
|
||||
private void transformPlayer(L2PcInstance player)
|
||||
{
|
||||
if (player.isTransformed())
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
if (player.isSitting())
|
||||
{
|
||||
player.standUp();
|
||||
}
|
||||
|
||||
player.getEffectList().stopSkillEffects(true, AbnormalType.SPEED_UP);
|
||||
player.stopSkillEffects(true, 268);
|
||||
player.stopSkillEffects(true, 298); // Rabbit Spirit Totem
|
||||
SkillData.getInstance().getSkill(_skill, 1).applyEffects(player, player);
|
||||
}
|
||||
|
||||
private void sendMessage(L2PcInstance player, String text)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(_npc.getObjectId(), ChatType.MPCC_ROOM, _npc.getName(), text));
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
final String content = getHtm(activeChar.getHtmlPrefix(), "admin_menu.htm");
|
||||
html.setHtml(content);
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
protected void timeUp()
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers("Time up, nobody wins!");
|
||||
eventStop();
|
||||
}
|
||||
|
||||
private void winRace(L2PcInstance player)
|
||||
{
|
||||
final int[] _reward = _rewards[getRandom(_rewards.length - 1)];
|
||||
player.addItem("eventModRace", _reward[0], _reward[1], _npc, true);
|
||||
Broadcast.toAllOnlinePlayers(player.getName() + " is a winner!");
|
||||
eventStop();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Race();
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Cursed weapon holders are not allowed to participate.
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Maximum of %max% participant(s) per IP address is allowed.
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Chaotic players are not allowed to participate.
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Only players from level %min% to level %max% are allowed to participate.
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
You can not participate while registered for Olympiad.
|
||||
</body>
|
||||
</html>
|
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Registration for TvT Event:<br>
|
||||
<center>
|
||||
%playercount% players in.<br>
|
||||
Participation Fee: %fee%<br>
|
||||
<button action="bypass -h Quest TvTManager join" value="Participate" width="200" height="31" back="L2UI_CT1.OlympiadWnd_DF_Apply_Down" fore="L2UI_CT1.OlympiadWnd_DF_Apply">
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
You need %fee% for participation.
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
You are registered for a TvT Event.
|
||||
</body>
|
||||
</html>
|
@@ -1,13 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
</head><title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Cancel registration for TvT Event:<br>
|
||||
You are already registered for this event. Do you wish to cancel your participation in this Event?<br>
|
||||
<center>
|
||||
Participation fee is not returned!<br>
|
||||
<button action="bypass -h Quest TvTManager remove" msg="1480" value="Cancel" width="200" height="31" back="L2UI_CT1.OlympiadWnd_DF_Back_Down" fore="L2UI_CT1.OlympiadWnd_DF_Back">
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@@ -1,9 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
<font color="LEVEL">Your team won the event!</font><br>
|
||||
Look in your inventory, there should be your reward.
|
||||
</body>
|
||||
</html>
|
@@ -1,12 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
Status:<br>
|
||||
<center>
|
||||
%team1name% with %team1playercount% players and %team1points% points.<br>
|
||||
%team2name% with %team2playercount% players and %team2points% points.
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
The event is full! Only %max% players are allowed per team.
|
||||
</body>
|
||||
</html>
|
@@ -1,222 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.TvT.TvTManager;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IVoicedCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.VoicedCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* TvT Manager AI.
|
||||
* @author Zoey76
|
||||
*/
|
||||
final class TvTManager extends AbstractNpcAI implements IVoicedCommandHandler
|
||||
{
|
||||
private static final int MANAGER_ID = 70010;
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"tvt",
|
||||
"tvtjoin",
|
||||
"tvtleave"
|
||||
};
|
||||
|
||||
public TvTManager()
|
||||
{
|
||||
super(TvTManager.class.getSimpleName(), "custom/events/TvT");
|
||||
addFirstTalkId(MANAGER_ID);
|
||||
addTalkId(MANAGER_ID);
|
||||
addStartNpc(MANAGER_ID);
|
||||
|
||||
if (Config.TVT_ALLOW_VOICED_COMMAND)
|
||||
{
|
||||
VoicedCommandHandler.getInstance().registerHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
if ((player == null) || !TvTEvent.isParticipating())
|
||||
{
|
||||
return super.onAdvEvent(event, npc, player);
|
||||
}
|
||||
|
||||
String htmltext = null;
|
||||
switch (event)
|
||||
{
|
||||
case "join":
|
||||
{
|
||||
final int playerLevel = player.getLevel();
|
||||
final int team1Count = TvTEvent.getTeamsPlayerCounts()[0];
|
||||
final int team2Count = TvTEvent.getTeamsPlayerCounts()[1];
|
||||
if (player.isCursedWeaponEquipped())
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "CursedWeaponEquipped.html");
|
||||
}
|
||||
else if (OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Olympiad.html");
|
||||
}
|
||||
else if (player.getReputation() < 0)
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Karma.html");
|
||||
}
|
||||
else if ((playerLevel < Config.TVT_EVENT_MIN_LVL) || (playerLevel > Config.TVT_EVENT_MAX_LVL))
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Level.html");
|
||||
htmltext = htmltext.replaceAll("%min%", String.valueOf(Config.TVT_EVENT_MIN_LVL));
|
||||
htmltext = htmltext.replaceAll("%max%", String.valueOf(Config.TVT_EVENT_MAX_LVL));
|
||||
}
|
||||
else if ((team1Count == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS) && (team2Count == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS))
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "TeamsFull.html");
|
||||
htmltext = htmltext.replaceAll("%max%", String.valueOf(Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS));
|
||||
}
|
||||
else if ((Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, player, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP))
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "IPRestriction.html");
|
||||
htmltext = htmltext.replaceAll("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP)));
|
||||
}
|
||||
else if (TvTEvent.needParticipationFee() && !TvTEvent.hasParticipationFee(player))
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "ParticipationFee.html");
|
||||
htmltext = htmltext.replaceAll("%fee%", TvTEvent.getParticipationFee());
|
||||
}
|
||||
else if (TvTEvent.addParticipant(player))
|
||||
{
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Registered.html");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "remove":
|
||||
{
|
||||
if (TvTEvent.removeParticipant(player.getObjectId()))
|
||||
{
|
||||
if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
|
||||
{
|
||||
AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, player);
|
||||
}
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Unregistered.html");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("You cannot unregister to this event.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
String htmltext = null;
|
||||
if (TvTEvent.isParticipating())
|
||||
{
|
||||
final boolean isParticipant = TvTEvent.isPlayerParticipant(player.getObjectId());
|
||||
final int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
|
||||
htmltext = getHtm(player.getHtmlPrefix(), !isParticipant ? "Participation.html" : "RemoveParticipation.html");
|
||||
htmltext = htmltext.replaceAll("%objectId%", String.valueOf(npc.getObjectId()));
|
||||
htmltext = htmltext.replaceAll("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
|
||||
htmltext = htmltext.replaceAll("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
|
||||
htmltext = htmltext.replaceAll("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
|
||||
htmltext = htmltext.replaceAll("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
|
||||
htmltext = htmltext.replaceAll("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
|
||||
|
||||
if (!isParticipant)
|
||||
{
|
||||
htmltext = htmltext.replaceAll("%fee%", TvTEvent.getParticipationFee());
|
||||
}
|
||||
}
|
||||
else if (TvTEvent.isStarting() || TvTEvent.isStarted())
|
||||
{
|
||||
htmltext = getTvTStatus(player);
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
|
||||
{
|
||||
String html = null;
|
||||
switch (command)
|
||||
{
|
||||
case "tvt":
|
||||
{
|
||||
if (TvTEvent.isStarting() || TvTEvent.isStarted())
|
||||
{
|
||||
html = getTvTStatus(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
html = "The event has not started.";
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "tvtjoin":
|
||||
{
|
||||
html = onAdvEvent("join", null, activeChar);
|
||||
break;
|
||||
}
|
||||
case "tvtleave":
|
||||
{
|
||||
html = onAdvEvent("remove", null, activeChar);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (html != null)
|
||||
{
|
||||
activeChar.sendPacket(new NpcHtmlMessage(html));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getTvTStatus(L2PcInstance player)
|
||||
{
|
||||
final int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
|
||||
final int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
|
||||
String htmltext = getHtm(player.getHtmlPrefix(), "Status.html");
|
||||
htmltext = htmltext.replaceAll("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
|
||||
htmltext = htmltext.replaceAll("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
|
||||
htmltext = htmltext.replaceAll("%team1points%", String.valueOf(teamsPointsCounts[0]));
|
||||
htmltext = htmltext.replaceAll("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
|
||||
htmltext = htmltext.replaceAll("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
|
||||
htmltext = htmltext.replaceAll("%team2points%", String.valueOf(teamsPointsCounts[1]));
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getVoicedCommandList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new TvTManager();
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>TvT Event</title>
|
||||
</head>
|
||||
<body>
|
||||
You have been unregistered from the TvT Event.
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
Congratulations you are married!
|
||||
</body>
|
||||
</html>
|
@@ -1,7 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
You don't have enough adena for marriage.<br>
|
||||
<font color="LEVEL">You need %fee% Adena.</font>
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
Go away, you are already married!
|
||||
</body>
|
||||
</html>
|
@@ -1,10 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
Your partner %player% asked to marry you.<br>
|
||||
<center>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Wedding accept">Accept Wedding</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Wedding decline">Decline Wedding</Button>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
The request of marriage was declined.
|
||||
</body>
|
||||
</html>
|
@@ -1,16 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
In order to get married you first have to be engaged.<br>
|
||||
To get engaged simply target your desired partner and type in the command ".engage" without the quotes.<br>
|
||||
For this to work, you both need to be on each other's friends list.<br>
|
||||
To do this, you need to type "/friendinvite PlayerName" without the quotes where PlayerName is the name of your partner.<br>
|
||||
Once engaged, you ask me to get married.<br>
|
||||
You both have to be wearing Formal Wear in order for this to work as well as the wedding will cost %fee% Adena.<br>
|
||||
Once married, you can use the command ".gotolove" without the quotes, to teleport to your partner at anytime.<br>
|
||||
If you wish to divorce, simply type the command ".divorce" without the quotes.<br>
|
||||
<center>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Wedding start">Back</Button>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
@@ -1,7 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
You are not wearing formal wear, go get formal wear and come back later.<br>
|
||||
If dont know where get it, then <font color="LEVEL">Trader Alexis</font> in Aden town can help you.
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
You don't have partner, you need to be engaged before you can marry.
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
No partner found, your friend must be online.
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
You requested %player% to marry you.
|
||||
</body>
|
||||
</html>
|
@@ -1,20 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
I understand that you want to get married? Marriage is an expensive ceremony!<br>
|
||||
Are you sure you want to go ahead with it?<br>
|
||||
<center>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h Quest Wedding ask">I want to marry</Button>
|
||||
</center>
|
||||
<br>
|
||||
Instructions:<br>
|
||||
In order to get married you first have to be engaged.<br>
|
||||
To get engaged simply target your desired partner and type in the command ".engage" without the quotes.<br>
|
||||
For this to work, you both need to be on each other's friends list.<br>
|
||||
To do this, you need to type "/friendinvite PlayerName" without the quotes where PlayerName is the name of your partner.<br>
|
||||
Once engaged, you ask me to get married.<br>
|
||||
You both have to be wearing Formal wear in order for this to work as well as the wedding will cost %fee% Adena.<br>
|
||||
Once married, you can use the command ".gotolove" without the quotes, to teleport to your partner at anytime.<br>
|
||||
If you wish to divorce, simply type the command ".divorce" without the quotes.
|
||||
</body>
|
||||
</html>
|
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Andromeda:<br>
|
||||
You asked your partner to marry you, wait till your partner accepted or declined your request.
|
||||
</body>
|
||||
</html>
|
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.events.Wedding;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.instancemanager.CoupleManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Couple;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* Wedding AI.
|
||||
* @author Zoey76
|
||||
*/
|
||||
final class Wedding extends AbstractNpcAI
|
||||
{
|
||||
// NPC
|
||||
private static final int MANAGER_ID = 50007;
|
||||
// Item
|
||||
private static final int FORMAL_WEAR = 6408;
|
||||
|
||||
public Wedding()
|
||||
{
|
||||
super(Wedding.class.getSimpleName(), "custom/events");
|
||||
addFirstTalkId(MANAGER_ID);
|
||||
addTalkId(MANAGER_ID);
|
||||
addStartNpc(MANAGER_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
if (player.getPartnerId() == 0)
|
||||
{
|
||||
return "NoPartner.html";
|
||||
}
|
||||
|
||||
final L2PcInstance partner = L2World.getInstance().getPlayer(player.getPartnerId());
|
||||
if ((partner == null) || !partner.isOnline())
|
||||
{
|
||||
return "NotFound.html";
|
||||
}
|
||||
|
||||
if (player.isMarried())
|
||||
{
|
||||
return "Already.html";
|
||||
}
|
||||
|
||||
if (player.isMarryAccepted())
|
||||
{
|
||||
return "WaitForPartner.html";
|
||||
}
|
||||
|
||||
String htmltext = null;
|
||||
if (player.isMarryRequest())
|
||||
{
|
||||
if (!isWearingFormalWear(player) || !isWearingFormalWear(partner))
|
||||
{
|
||||
htmltext = sendHtml(partner, "NoFormal.html", null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setMarryRequest(false);
|
||||
partner.setMarryRequest(false);
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Ask.html");
|
||||
htmltext = htmltext.replaceAll("%player%", partner.getName());
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case "ask":
|
||||
{
|
||||
if (!isWearingFormalWear(player) || !isWearingFormalWear(partner))
|
||||
{
|
||||
htmltext = sendHtml(partner, "NoFormal.html", null, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setMarryAccepted(true);
|
||||
partner.setMarryRequest(true);
|
||||
|
||||
sendHtml(partner, "Ask.html", "%player%", player.getName());
|
||||
|
||||
htmltext = getHtm(player.getHtmlPrefix(), "Requested.html");
|
||||
htmltext = htmltext.replaceAll("%player%", partner.getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "accept":
|
||||
{
|
||||
if (!isWearingFormalWear(player) || !isWearingFormalWear(partner))
|
||||
{
|
||||
htmltext = sendHtml(partner, "NoFormal.html", null, null);
|
||||
}
|
||||
else if ((player.getAdena() < Config.L2JMOD_WEDDING_PRICE) || (partner.getAdena() < Config.L2JMOD_WEDDING_PRICE))
|
||||
{
|
||||
htmltext = sendHtml(partner, "Adena.html", "%fee%", String.valueOf(Config.L2JMOD_WEDDING_PRICE));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.reduceAdena("Wedding", Config.L2JMOD_WEDDING_PRICE, player.getLastFolkNPC(), true);
|
||||
partner.reduceAdena("Wedding", Config.L2JMOD_WEDDING_PRICE, player.getLastFolkNPC(), true);
|
||||
|
||||
// Accept the wedding request
|
||||
player.setMarryAccepted(true);
|
||||
final Couple couple = CoupleManager.getInstance().getCouple(player.getCoupleId());
|
||||
couple.marry();
|
||||
|
||||
// Messages to the couple
|
||||
player.sendMessage("Congratulations you are married!");
|
||||
player.setMarried(true);
|
||||
player.setMarryRequest(false);
|
||||
partner.sendMessage("Congratulations you are married!");
|
||||
partner.setMarried(true);
|
||||
partner.setMarryRequest(false);
|
||||
|
||||
// Wedding march
|
||||
player.broadcastPacket(new MagicSkillUse(player, player, 2230, 1, 1, 0));
|
||||
partner.broadcastPacket(new MagicSkillUse(partner, partner, 2230, 1, 1, 0));
|
||||
|
||||
// Fireworks
|
||||
final Skill skill = CommonSkill.LARGE_FIREWORK.getSkill();
|
||||
if (skill != null)
|
||||
{
|
||||
player.doCast(skill);
|
||||
partner.doCast(skill);
|
||||
}
|
||||
|
||||
Broadcast.toAllOnlinePlayers("Congratulations to " + player.getName() + " and " + partner.getName() + "! They have been married.");
|
||||
|
||||
htmltext = sendHtml(partner, "Accepted.html", null, null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "decline":
|
||||
{
|
||||
player.setMarryRequest(false);
|
||||
partner.setMarryRequest(false);
|
||||
player.setMarryAccepted(false);
|
||||
partner.setMarryAccepted(false);
|
||||
|
||||
player.sendMessage("You declined your partner's marriage request.");
|
||||
partner.sendMessage("Your partner declined your marriage request.");
|
||||
|
||||
htmltext = sendHtml(partner, "Declined.html", null, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return htmltext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onFirstTalk(L2Npc npc, L2PcInstance player)
|
||||
{
|
||||
return getHtm(player.getHtmlPrefix(), "Start.html").replaceAll("%fee%", String.valueOf(Config.L2JMOD_WEDDING_PRICE));
|
||||
}
|
||||
|
||||
private String sendHtml(L2PcInstance player, String fileName, String regex, String replacement)
|
||||
{
|
||||
String html = getHtm(player.getHtmlPrefix(), fileName);
|
||||
if ((regex != null) && (replacement != null))
|
||||
{
|
||||
html = html.replaceAll(regex, replacement);
|
||||
}
|
||||
player.sendPacket(new NpcHtmlMessage(html));
|
||||
return html;
|
||||
}
|
||||
|
||||
private static boolean isWearingFormalWear(L2PcInstance player)
|
||||
{
|
||||
if (Config.L2JMOD_WEDDING_FORMALWEAR)
|
||||
{
|
||||
final L2ItemInstance formalWear = player.getChestArmorInstance();
|
||||
return (formalWear != null) && (formalWear.getId() == FORMAL_WEAR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new Wedding();
|
||||
}
|
||||
}
|
@@ -1,183 +1,183 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.listeners;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Id;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.NpcLevelRange;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Priority;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Range;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureKill;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.attackable.OnAttackableAttack;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
|
||||
import com.l2jmobius.gameserver.model.events.impl.item.OnItemCreate;
|
||||
import com.l2jmobius.gameserver.model.events.impl.sieges.castle.OnCastleSiegeStart;
|
||||
import com.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* An example usage of Listeners.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ListenerTest extends AbstractNpcAI
|
||||
{
|
||||
private static final int[] ELPIES =
|
||||
{
|
||||
20432,
|
||||
22228
|
||||
};
|
||||
|
||||
private ListenerTest()
|
||||
{
|
||||
super(ListenerTest.class.getSimpleName(), "ai/npc");
|
||||
|
||||
// Method preset listener registration
|
||||
// An set function which is a Consumer it has one parameter and doesn't returns anything!
|
||||
setAttackableAttackId(this::onAttackableAttack, ELPIES);
|
||||
|
||||
// Manual listener registration
|
||||
Containers.Global().addListener(new ConsumerEventListener(Containers.Global(), EventType.ON_PLAYER_DLG_ANSWER, (OnPlayerDlgAnswer event) ->
|
||||
{
|
||||
_log.log(Level.INFO, ListenerTest.class.getSimpleName() + ": " + event.getActiveChar() + " OnPlayerDlgAnswer: Answer: " + event.getAnswer() + " MessageId: " + event.getMessageId());
|
||||
}, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as an L2Attackable (Rabbits 20432 and 22228) is being attacked from L2PcInstance (a player)
|
||||
* @param event
|
||||
*/
|
||||
public void onAttackableAttack(OnAttackableAttack event)
|
||||
{
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": " + event.getClass().getSimpleName() + " invoked attacker: " + event.getAttacker() + " target: " + event.getTarget() + " damage: " + event.getDamage() + " skill: " + event.getSkill());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as L2Attackable (Rabbits 20432 and 22228) are being killed by L2PcInstance (a player)<br>
|
||||
* This listener is registered into individual npcs container.
|
||||
* @param event
|
||||
*/
|
||||
// Annotation listener registration
|
||||
@RegisterEvent(EventType.ON_CREATURE_KILL)
|
||||
@RegisterType(ListenerRegisterType.NPC)
|
||||
@Id(20432)
|
||||
@Id(22228)
|
||||
public void onCreatureKill(OnCreatureKill event)
|
||||
{
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": " + event.getClass().getSimpleName() + " invoked attacker: " + event.getAttacker() + " target: " + event.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as Siege of castle ids 1-9 starts<br>
|
||||
* This listener is registered into individual castle container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_CASTLE_SIEGE_START)
|
||||
@RegisterType(ListenerRegisterType.CASTLE)
|
||||
@Range(from = 1, to = 9)
|
||||
public void onSiegeStart(OnCastleSiegeStart event)
|
||||
{
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": The siege of " + event.getSiege().getCastle().getName() + " (" + event.getSiege().getCastle().getResidenceId() + ") has started!");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as Ancient Adena (5575) item is created on player's inventory (As new item!).<br>
|
||||
* This listener is registered into individual items container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_ITEM_CREATE)
|
||||
@RegisterType(ListenerRegisterType.ITEM)
|
||||
@Id(5575)
|
||||
public void onItemCreate(OnItemCreate event)
|
||||
{
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": Item [" + event.getItem() + "] has been created actor: " + event.getActiveChar() + " process: " + event.getProcess() + " reference: " + event.getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* Prioritized event notification <br>
|
||||
* This method will be invoked as soon as creature from level range between 1 and 10 dies.<br>
|
||||
* This listener is registered into individual npcs container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_CREATURE_KILL)
|
||||
@RegisterType(ListenerRegisterType.NPC)
|
||||
@NpcLevelRange(from = 1, to = 10)
|
||||
@Priority(100)
|
||||
public void OnCreatureKill(OnCreatureKill event)
|
||||
{
|
||||
// 70% chance to drop
|
||||
if (Rnd.get(100) >= 70)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure a player killed this monster.
|
||||
if ((event.getAttacker() != null) && event.getAttacker().isPlayable() && event.getTarget().isAttackable())
|
||||
{
|
||||
((L2Attackable) event.getTarget()).dropItem(event.getAttacker().getActingPlayer(), new ItemHolder(57, Rnd.get(100, 1000)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon a a player logs into the game.<br>
|
||||
* This listener is registered into global players container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void onPlayerLogin(OnPlayerLogin event)
|
||||
{
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": Player: " + event.getActiveChar() + " has logged in!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prioritized event notification - Ensuring that this listener will be the first to receive notification.<br>
|
||||
* Also this method interrupts notification to other listeners and taking over return if somehow it wasn't the first one to set.<br>
|
||||
* This method will be invoked as soon a a creature dies.<br>
|
||||
* This listener is registered into global players container.
|
||||
* @param event
|
||||
* @return termination return preventing the base code execution if needed.
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_CREATURE_KILL)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@Priority(Integer.MAX_VALUE)
|
||||
public TerminateReturn onPlayerDeath(OnCreatureKill event)
|
||||
{
|
||||
if (event.getTarget().isGM())
|
||||
{
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": Player: " + event.getTarget() + " was prevented from dying!");
|
||||
return new TerminateReturn(true, true, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new ListenerTest();
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package custom.listeners;
|
||||
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.events.Containers;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Id;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.NpcLevelRange;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Priority;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Range;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureDeath;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnAttackableAttack;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
|
||||
import com.l2jmobius.gameserver.model.events.impl.item.OnItemCreate;
|
||||
import com.l2jmobius.gameserver.model.events.impl.sieges.OnCastleSiegeStart;
|
||||
import com.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.scripting.annotations.Disabled;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* An example usage of Listeners.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
@Disabled
|
||||
public class ListenerTest extends AbstractNpcAI
|
||||
{
|
||||
private static final int[] ELPIES =
|
||||
{
|
||||
20432,
|
||||
22228
|
||||
};
|
||||
|
||||
private ListenerTest()
|
||||
{
|
||||
|
||||
// Method preset listener registration
|
||||
// An set function which is a Consumer it has one parameter and doesn't returns anything!
|
||||
setAttackableAttackId(this::onAttackableAttack, ELPIES);
|
||||
|
||||
// Manual listener registration
|
||||
Containers.Global().addListener(new ConsumerEventListener(Containers.Global(), EventType.ON_PLAYER_DLG_ANSWER, (OnPlayerDlgAnswer event) ->
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": " + event.getActiveChar() + " OnPlayerDlgAnswer: Answer: " + event.getAnswer() + " MessageId: " + event.getMessageId());
|
||||
}, this));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as an L2Attackable (Rabbits 20432 and 22228) is being attacked from L2PcInstance (a player)
|
||||
* @param event
|
||||
*/
|
||||
private void onAttackableAttack(OnAttackableAttack event)
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": " + event.getClass().getSimpleName() + " invoked attacker: " + event.getAttacker() + " target: " + event.getTarget() + " damage: " + event.getDamage() + " skill: " + event.getSkill());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as L2Attackable (Rabbits 20432 and 22228) are being killed by L2PcInstance (a player)<br>
|
||||
* This listener is registered into individual npcs container.
|
||||
* @param event
|
||||
*/
|
||||
// Annotation listener registration
|
||||
@RegisterEvent(EventType.ON_CREATURE_DEATH)
|
||||
@RegisterType(ListenerRegisterType.NPC)
|
||||
@Id(20432)
|
||||
@Id(22228)
|
||||
private void onCreatureKill(OnCreatureDeath event)
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": " + event.getClass().getSimpleName() + " invoked attacker: " + event.getAttacker() + " target: " + event.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as Siege of castle ids 1-9 starts<br>
|
||||
* This listener is registered into individual castle container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_CASTLE_SIEGE_START)
|
||||
@RegisterType(ListenerRegisterType.CASTLE)
|
||||
@Range(from = 1, to = 9)
|
||||
private void onSiegeStart(OnCastleSiegeStart event)
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": The siege of " + event.getSiege().getCastle().getName() + " (" + event.getSiege().getCastle().getResidenceId() + ") has started!");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon as Ancient Adena (5575) item is created on player's inventory (As new item!).<br>
|
||||
* This listener is registered into individual items container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_ITEM_CREATE)
|
||||
@RegisterType(ListenerRegisterType.ITEM)
|
||||
@Id(5575)
|
||||
private void onItemCreate(OnItemCreate event)
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": Item [" + event.getItem() + "] has been created actor: " + event.getActiveChar() + " process: " + event.getProcess() + " reference: " + event.getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
* Prioritized event notification <br>
|
||||
* This method will be invoked as soon as creature from level range between 1 and 10 dies.<br>
|
||||
* This listener is registered into individual npcs container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_CREATURE_DEATH)
|
||||
@RegisterType(ListenerRegisterType.NPC)
|
||||
@NpcLevelRange(from = 1, to = 10)
|
||||
@Priority(100)
|
||||
private void OnCreatureKill(OnCreatureDeath event)
|
||||
{
|
||||
// 70% chance to drop
|
||||
if (Rnd.get(100) >= 70)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure a player killed this monster.
|
||||
if ((event.getAttacker() != null) && event.getAttacker().isPlayable() && event.getTarget().isAttackable())
|
||||
{
|
||||
final L2Attackable monster = (L2Attackable) event.getTarget();
|
||||
monster.dropItem(event.getAttacker().getActingPlayer(), new ItemHolder(57, Rnd.get(100, 1000)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked as soon a a player logs into the game.<br>
|
||||
* This listener is registered into global players container.
|
||||
* @param event
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_PLAYER_LOGIN)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
private void onPlayerLogin(OnPlayerLogin event)
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": Player: " + event.getActiveChar() + " has logged in!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prioritized event notification - Ensuring that this listener will be the first to receive notification.<br>
|
||||
* Also this method interrupts notification to other listeners and taking over return if somehow it wasn't the first one to set.<br>
|
||||
* This method will be invoked as soon a a creature dies.<br>
|
||||
* This listener is registered into global players container.
|
||||
* @param event
|
||||
* @return termination return preventing the base code execution if needed.
|
||||
*/
|
||||
@RegisterEvent(EventType.ON_CREATURE_DEATH)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@Priority(Integer.MAX_VALUE)
|
||||
private TerminateReturn onPlayerDeath(OnCreatureDeath event)
|
||||
{
|
||||
if (event.getTarget().isGM())
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": Player: " + event.getTarget() + " was prevented from dying!");
|
||||
return new TerminateReturn(true, true, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new ListenerTest();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user