Addition of Saving Santa event.

This commit is contained in:
MobiusDevelopment
2019-11-11 16:38:50 +00:00
parent 2b84f853f7
commit c1762baef0
91 changed files with 8999 additions and 83 deletions

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.WOW,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_HAPPY_HOLIDAYS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_HAPPY_HOLIDAYS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.HAPPY_HOLIDAYS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.HAPPY_HOLIDAYS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings") && isEventPeriod())
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2012-11 01 2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82260" y="148611" z="-3395" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,20 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,24 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->

View File

@@ -224,49 +224,64 @@
</skill>
<skill id="21014" levels="1" name="Scissors">
<!-- Challenge opponent with "Scissors." Can only be used on Thomas D. Turkey. -->
<set name="icon" val="BranchSys.icon.br_xmas_gawi_i00" />
<set name="castRange" val="400" />
<set name="coolTime" val="500" />
<set name="effectPoint" val="-1" />
<set name="effectRange" val="500" />
<set name="hitTime" val="2000" />
<set name="icon" val="BranchSys.icon.br_xmas_gawi_i00" />
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="magicLvl" val="1" />
<set name="operateType" val="A1" />
<set name="targetType" val="ONE" />
<set name="targetType" val="SELF" />
<cond msgId="109">
<target npcId="13183" />
</cond>
<selfEffects>
<effect name="CallSkill">
<param skillId="23019" skillLevel="1" />
</effect>
</selfEffects>
</skill>
<skill id="21015" levels="1" name="Rock">
<!-- Challenge opponent with "Rock." Can only be used on Thomas D. Turkey. -->
<set name="icon" val="BranchSys.icon.br_xmas_bawi_i00" />
<set name="castRange" val="400" />
<set name="coolTime" val="500" />
<set name="effectPoint" val="-1" />
<set name="hitTime" val="2000" />
<set name="icon" val="BranchSys.icon.br_xmas_bawi_i00" />
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="magicLvl" val="1" />
<set name="operateType" val="A1" />
<set name="targetType" val="ONE" />
<set name="targetType" val="SELF" />
<cond msgId="109">
<target npcId="13183" />
</cond>
<selfEffects>
<effect name="CallSkill">
<param skillId="23019" skillLevel="2" />
</effect>
</selfEffects>
</skill>
<skill id="21016" levels="1" name="Paper">
<!-- Challenge opponent with "Paper." Can only be used on Thomas D. Turkey. -->
<set name="icon" val="BranchSys.icon.br_xmas_bo_i00" />
<set name="castRange" val="400" />
<set name="coolTime" val="500" />
<set name="effectPoint" val="-1" />
<set name="hitTime" val="2000" />
<set name="icon" val="BranchSys.icon.br_xmas_bo_i00" />
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="magicLvl" val="1" />
<set name="operateType" val="A1" />
<set name="targetType" val="ONE" />
<set name="targetType" val="SELF" />
<cond msgId="109">
<target npcId="13183" />
</cond>
<selfEffects>
<effect name="CallSkill">
<param skillId="23019" skillLevel="3" />
</effect>
</selfEffects>
</skill>
<skill id="21017" levels="1" name="Holiday Dream Weapon">
<!-- Max CP is increased. The rate of critical attacks is increased. Bestow the ability to regenerate HP by using some of the damage inflicted on the enemy. Excludes damage caused by skills and long-range attacks. -->

View File

@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.conditions;
import java.util.List;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.skills.Skill;
@@ -41,6 +42,7 @@ public class ConditionTargetNpcId extends Condition
@Override
public boolean testImpl(Creature effector, Creature effected, Skill skill, Item item)
{
return (effected != null) && (effected.isNpc() || effected.isDoor()) && _npcIds.contains(effected.getId());
final WorldObject target = (effector == null) || !effector.isPlayer() ? effected : effector.getTarget();
return (target != null) && (target.isNpc() || target.isDoor()) && _npcIds.contains(target.getId());
}
}

View File

@@ -0,0 +1,779 @@
/*
* 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 events.SavingSanta;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.concurrent.ThreadPool;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.data.xml.impl.SkillData;
import org.l2jmobius.gameserver.datatables.ItemTable;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.enums.QuestSound;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.quest.LongTimeEvent;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import org.l2jmobius.gameserver.network.serverpackets.NpcSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;
/**
* Christmas Event: Saving Santa<br>
* http://legacy.lineage2.com/archive/2008/12/saving_santa_ev.html<br>
* TODO:<br>
* 1) Heading for Santa's Helpers.<br>
* 2) Unhardcode HTMLs.<br>
* @author Zoey76, Mobius
*/
public class SavingSanta extends LongTimeEvent
{
private boolean _isSantaFree = true;
private boolean _isJackPot = false;
private boolean _isWaitingForPlayerSkill = false;
private static final List<Npc> _santaHelpers = new ArrayList<>();
private static final List<Npc> _specialTrees = new ArrayList<>();
private static final Map<String, Long> _rewardedPlayers = new ConcurrentHashMap<>();
private static final Map<String, Long> _blessedPlayers = new ConcurrentHashMap<>();
// Is Saving Santa event used?
private static boolean SAVING_SANTA = true;
// Use Santa's Helpers Auto Buff?
private static boolean SANTAS_HELPER_AUTOBUFF = false;
private static final ItemHolder[] REQUIRED_ITEMS =
{
new ItemHolder(5556, 4),
new ItemHolder(5557, 4),
new ItemHolder(5558, 10),
new ItemHolder(5559, 1)
};
//@formatter:off
private static final int SANTA_TRAINEE_ID = 31863;
private static final int SPECIAL_CHRISTMAS_TREE_ID = 13007;
private static final int HOLIDAY_SANTA_ID = 104;
private static final int HOLIDAY_SLED_ID = 105;
private static final int THOMAS_D_TURKEY_ID = 13183;
private static final long MIN_TIME_BETWEEN_2_REWARDS = 43200000;
private static final long MIN_TIME_BETWEEN_2_BLESSINGS = 14400000;
private static final int BR_XMAS_PRESENT_NORMAL = 20101;
private static final int BR_XMAS_PRESENT_JACKPOT = 20102;
private static final int BR_XMAS_WPN_TICKET_NORMAL = 20107;
private static final int BR_XMAS_WPN_TICKET_JACKPOT = 20108;
private static final int BR_XMAS_REWARD_BUFF = 23017;
private static final int BR_XMAS_GAWIBAWIBO_CAP = 20100;
private static final int X_MAS_TREE1 = 5560;
private static final int X_MAS_TREE2 = 5561;
private static final int SANTAS_HAT_ID = 7836;
private static final int[] WEAPON_REWARDS = {14621, 14622, 14625, 14623, 14624, 14630, 14631, 14628, 14627, 14626, 14674, 14632, 14634, 14633};
private static final Location THOMAS_SPAWN = new Location(117935, -126003, -2585, 54625);
private static final int[] SANTA_MAGE_BUFFS = {7055, 7054, 7051};
private static final int[] SANTA_FIGHTER_BUFFS = {7043, 7057, 7051};
//@formatter:on
private static final NpcStringId[] NPC_STRINGS =
{
NpcStringId.IT_S_HURTING_I_M_IN_PAIN_WHAT_CAN_I_DO_FOR_THE_PAIN,
NpcStringId.NO_WHEN_I_LOSE_THAT_ONE_I_LL_BE_IN_MORE_PAIN,
NpcStringId.HAHAHAH_I_CAPTURED_SANTA_CLAUS_THERE_WILL_BE_NO_GIFTS_THIS_YEAR,
NpcStringId.NOW_WHY_DON_T_YOU_TAKE_UP_THE_CHALLENGE,
NpcStringId.COME_ON_I_LL_TAKE_ALL_OF_YOU_ON,
NpcStringId.HOW_ABOUT_IT_I_THINK_I_WON,
NpcStringId.NOW_THOSE_OF_YOU_WHO_LOST_GO_AWAY,
NpcStringId.WHAT_A_BUNCH_OF_LOSERS,
NpcStringId.I_GUESS_YOU_CAME_TO_RESCUE_SANTA_BUT_YOU_PICKED_THE_WRONG_PERSON,
NpcStringId.AH_OKAY,
NpcStringId.AGH_I_WASN_T_GOING_TO_DO_THAT,
NpcStringId.YOU_RE_CURSED_OH_WHAT,
NpcStringId.STOP_IT_NO_MORE_I_DID_IT_BECAUSE_I_WAS_TOO_LONELY,
NpcStringId.I_HAVE_TO_RELEASE_SANTA_HOW_INFURIATING,
NpcStringId.I_HATE_HAPPY_MERRY_CHRISTMAS,
NpcStringId.OH_I_M_BORED,
NpcStringId.SHALL_I_GO_TO_TAKE_A_LOOK_IF_SANTA_IS_STILL_THERE_HEHE,
NpcStringId.OH_HO_HO_MERRY_CHRISTMAS,
NpcStringId.SANTA_COULD_GIVE_NICE_PRESENTS_ONLY_IF_HE_S_RELEASED_FROM_THE_TURKEY,
NpcStringId.OH_HO_HO_OH_HO_HO_THANK_YOU_LADIES_AND_GENTLEMEN_I_WILL_REPAY_YOU_FOR_SURE,
NpcStringId.MERRY_CHRISTMAS_YOU_RE_DOING_A_GOOD_JOB,
NpcStringId.MERRY_CHRISTMAS_THANK_YOU_FOR_RESCUING_ME_FROM_THAT_WRETCHED_TURKEY,
NpcStringId.S1_I_HAVE_PREPARED_A_GIFT_FOR_YOU,
NpcStringId.I_HAVE_A_GIFT_FOR_S1,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_I_HOPE_YOU_LIKE_THE_GIFT_I_GAVE_YOU,
NpcStringId.TAKE_A_LOOK_AT_THE_INVENTORY_PERHAPS_THERE_MIGHT_BE_A_BIG_PRESENT,
NpcStringId.I_M_TIRED_OF_DEALING_WITH_YOU_I_M_LEAVING,
NpcStringId.WHEN_ARE_YOU_GOING_TO_STOP_I_SLOWLY_STARTED_TO_BE_TIRED_OF_IT,
NpcStringId.MESSAGE_FROM_SANTA_CLAUS_MANY_BLESSINGS_TO_S1_WHO_SAVED_ME
};
public SavingSanta()
{
addStartNpc(SANTA_TRAINEE_ID);
addFirstTalkId(SANTA_TRAINEE_ID);
addTalkId(SANTA_TRAINEE_ID);
addFirstTalkId(THOMAS_D_TURKEY_ID);
addFirstTalkId(HOLIDAY_SANTA_ID);
addFirstTalkId(HOLIDAY_SLED_ID);
addSkillSeeId(THOMAS_D_TURKEY_ID);
addSpellFinishedId(THOMAS_D_TURKEY_ID);
addSpawnId(SPECIAL_CHRISTMAS_TREE_ID);
if (isEventPeriod())
{
startQuestTimer("SpecialTreeHeal", 5000, null, null);
if (SAVING_SANTA)
{
startQuestTimer("ThomasQuest", 1000, null, null);
}
if (SANTAS_HELPER_AUTOBUFF)
{
startQuestTimer("SantaBlessings", 5000, null, null);
}
}
}
@Override
public String onSpawn(Npc npc)
{
_specialTrees.add(npc);
return super.onSpawn(npc);
}
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isSummon)
{
if (_isWaitingForPlayerSkill && (skill.getId() > 21013) && (skill.getId() < 21017))
{
caster.broadcastPacket(new MagicSkillUse(caster, caster, 23019, skill.getId() - 21013, 3000, 1));
SkillData.getInstance().getSkill(23019, skill.getId() - 21013).applyEffects(caster, caster);
}
return null;
}
@Override
public String onSpellFinished(Npc npc, PlayerInstance player, Skill skill)
{
// Turkey's Choice
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (skill.getId() == 6100)
{
_isWaitingForPlayerSkill = false;
for (PlayerInstance pl : World.getInstance().getVisibleObjectsInRange(npc, PlayerInstance.class, 600))
{
// Level 1: Scissors
// Level 2: Rock
// Level 3: Paper
if (!pl.isAffectedBySkill(23019))
{
continue;
}
int result = pl.getEffectList().getBuffInfoBySkillId(23019).getSkill().getLevel() - skill.getLevel();
if (result == 0)
{
// Oh. I'm bored.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[15]));
}
else if ((result == -1) || (result == 2))
{
// Now!! Those of you who lost, go away!
// What a bunch of losers.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[6 + getRandom(2)]));
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23023, 1, 3000, 1));
pl.getEffectList().stopSkillEffects(true, 23022);
}
else if ((result == 1) || (result == -2))
{
int level = (pl.isAffectedBySkill(23022) ? (pl.getEffectList().getBuffInfoBySkillId(23022).getSkill().getLevel() + 1) : 1);
pl.broadcastPacket(new MagicSkillUse(pl, pl, 23022, level, 3000, 1));
SkillData.getInstance().getSkill(23022, level).applyEffects(pl, pl);
if ((level == 1) || (level == 2))
{
// Ah, okay...
// Agh!! I wasn't going to do that!
// You're cursed!! Oh.. What?
// Have you done nothing but rock-paper-scissors??
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[10 + getRandom(4)]));
}
else if (level == 3)
{
SkillData.getInstance().getSkill(23018, 1).applyEffects(pl, pl);
// Stop it, no more... I did it because I was too lonely...
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[13]));
}
else if (level == 4)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_HAVE_DEFEATED_THOMAS_D_TURKEY_AND_RESCUED_SANTA));
// I have to release Santa... How infuriating!!!
// I hate happy Merry Christmas!!!
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[14 + getRandom(2)]));
startQuestTimer("SantaSpawn", 120000, null, null);
final Npc holidaySled = addSpawn(HOLIDAY_SLED_ID, 117935, -126003, -2585, 54625, false, 12000);
// Message from Santa Claus: Many blessings to $s1, who saved me~
final NpcSay santaSaved = new NpcSay(holidaySled.getObjectId(), ChatType.NPC_SHOUT, holidaySled.getId(), NPC_STRINGS[28]);
santaSaved.addStringParameter(pl.getName());
holidaySled.broadcastPacket(santaSaved);
// Oh ho ho.... Merry Christmas!!
holidaySled.broadcastPacket(new NpcSay(holidaySled.getObjectId(), ChatType.NPC_GENERAL, holidaySled.getId(), NPC_STRINGS[17]));
if (getRandom(100) > 90)
{
_isJackPot = true;
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, pl, true);
}
else
{
pl.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, pl, true);
}
ThreadPool.schedule(new SledAnimation(holidaySled), 7000);
npc.decayMe();
_isSantaFree = true;
break;
}
}
}
}
return super.onSpellFinished(npc, player, skill);
}
private static class SledAnimation implements Runnable
{
private final Npc _sled;
public SledAnimation(Npc sled)
{
_sled = sled;
}
@Override
public void run()
{
try
{
_sled.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
_sled.broadcastPacket(new SocialAction(_sled.getObjectId(), 1));
}
catch (Exception e)
{
// Ignore.
}
}
}
@Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{
String htmltext = null;
if (event.equalsIgnoreCase("ThomasQuest"))
{
startQuestTimer("ThomasQuest", 14400000, null, null);
Npc ThomasDTurkey = addSpawn(THOMAS_D_TURKEY_ID, THOMAS_SPAWN.getX(), THOMAS_SPAWN.getY(), THOMAS_SPAWN.getZ(), THOMAS_SPAWN.getHeading(), false, 1800000);
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.THOMAS_D_TURKEY_HAS_APPEARED_PLEASE_SAVE_SANTA));
startQuestTimer("ThomasCast1", 15000, ThomasDTurkey, null);
_isSantaFree = false;
}
else if (event.equalsIgnoreCase("SantaSpawn"))
{
if (_isSantaFree)
{
startQuestTimer("SantaSpawn", 120000, null, null);
// for (PlayerInstance pl : L2World.getInstance().getAllPlayers().values())
for (PlayerInstance pl : World.getInstance().getPlayers())
{
if ((pl != null) && pl.isOnline() && (pl.getLevel() >= 20) && pl.isInCombat() && !pl.isInsideZone(ZoneId.PEACE) && !pl.isFlyingMounted())
{
if (_rewardedPlayers.containsKey(pl.getAccountName()))
{
long elapsedTimeSinceLastRewarded = System.currentTimeMillis() - _rewardedPlayers.get(pl.getAccountName());
if (elapsedTimeSinceLastRewarded < MIN_TIME_BETWEEN_2_REWARDS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_REWARD", 0);
if ((System.currentTimeMillis() - time) < MIN_TIME_BETWEEN_2_REWARDS)
{
_rewardedPlayers.put(pl.getAccountName(), time);
continue;
}
}
int locx = (int) (pl.getX() + (Math.pow(-1, getRandom(1, 2)) * 50));
int locy = (int) (pl.getY() + (Math.pow(-1, getRandom(1, 2)) * 50));
int heading = Util.calculateHeadingFrom(locx, locy, pl.getX(), pl.getY());
Npc santa = addSpawn(HOLIDAY_SANTA_ID, locx, locy, pl.getZ(), heading, false, 30000);
_rewardedPlayers.put(pl.getAccountName(), System.currentTimeMillis());
player.getVariables().set("LAST_SANTA_REWARD", System.currentTimeMillis());
startQuestTimer("SantaRewarding0", 500, santa, pl);
}
}
}
}
else if (event.equalsIgnoreCase("ThomasCast1"))
{
if (!npc.isDecayed())
{
_isWaitingForPlayerSkill = true;
startQuestTimer("ThomasCast2", 4000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6116, 1));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("ThomasCast2"))
{
if (!npc.isDecayed())
{
startQuestTimer("ThomasCast1", 13000, npc, null);
npc.doCast(SkillData.getInstance().getSkill(6100, getRandom(1, 3)));
// It's hurting... I'm in pain... What can I do for the pain...
// No... When I lose that one... I'll be in more pain...
// Hahahah!!! I captured Santa Claus!! There will be no gifts this year!!!
// Now! Why don't you take up the challenge?
// Come on, I'll take all of you on!
// How about it? I think I won?
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[getRandom(6)]));
}
else
{
if (!_isSantaFree)
{
Broadcast.toAllOnlinePlayers(new SystemMessage(SystemMessageId.YOU_DID_NOT_RESCUE_SANTA_AND_THOMAS_D_TURKEY_HAS_DISAPPEARED));
_isWaitingForPlayerSkill = false;
}
}
}
else if (event.equalsIgnoreCase("SantaRewarding0"))
{
startQuestTimer("SantaRewarding1", 9500, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
}
else if (event.equalsIgnoreCase("SantaRewarding1"))
{
startQuestTimer("SantaRewarding2", 5000, npc, player);
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
// Merry Christmas~ Thank you for rescuing me from that wretched Turkey.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[21]));
}
else if (event.equalsIgnoreCase("SantaRewarding2"))
{
startQuestTimer("SantaRewarding3", 5000, npc, player);
// I have a gift for $s1.
final NpcSay iHaveAGift = new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[23]);
iHaveAGift.addStringParameter(player.getName());
npc.broadcastPacket(iHaveAGift);
}
else if (event.equalsIgnoreCase("SantaRewarding3"))
{
npc.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
if (_isJackPot)
{
// Take a look at the inventory. Perhaps there might be a big present~
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[25]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_JACKPOT, 1, player, true);
_isJackPot = false;
}
else
{
// Take a look at the inventory. I hope you like the gift I gave you.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[24]));
player.addItem("SavingSantaPresent", BR_XMAS_PRESENT_NORMAL, 1, player, true);
}
}
else if (event.equalsIgnoreCase("SantaBlessings"))
{
startQuestTimer("SantaBlessings", 15000, null, null);
final long currentTime = System.currentTimeMillis();
for (Npc santaHelper1 : _santaHelpers)
{
for (PlayerInstance plb : World.getInstance().getVisibleObjects(santaHelper1, PlayerInstance.class))
{
if ((plb.getLevel() >= 20) && !plb.isFlyingMounted())
{
if (_blessedPlayers.containsKey(plb.getAccountName()))
{
long elapsedTimeSinceLastBlessed = currentTime - _blessedPlayers.get(plb.getAccountName());
if (elapsedTimeSinceLastBlessed < MIN_TIME_BETWEEN_2_BLESSINGS)
{
continue;
}
}
else
{
final long time = player.getVariables().getLong("LAST_SANTA_BLESSING", 0);
if ((currentTime - time) < MIN_TIME_BETWEEN_2_BLESSINGS)
{
_blessedPlayers.put(plb.getAccountName(), time);
continue;
}
}
for (Npc santaHelper : _santaHelpers)
{
for (PlayerInstance playerx : World.getInstance().getVisibleObjects(santaHelper, PlayerInstance.class))
{
if (playerx.getClassId().isMage())
{
for (int buffId : SANTA_MAGE_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
else
{
for (int buffId : SANTA_FIGHTER_BUFFS)
{
if (!playerx.getEffectList().isAffectedBySkill(buffId))
{
playerx.broadcastPacket(new MagicSkillUse(santaHelper, playerx, buffId, 1, 2000, 1));
SkillData.getInstance().getSkill(buffId, 1).applyEffects(playerx, playerx);
_blessedPlayers.put(playerx.getAccountName(), currentTime);
playerx.getVariables().set("LAST_SANTA_BLESSING", currentTime);
}
}
}
}
}
}
}
}
}
else if (event.equalsIgnoreCase("SpecialTreeHeal"))
{
startQuestTimer("SpecialTreeHeal", 9000, null, null);
for (Npc tree : _specialTrees)
{
for (PlayerInstance playerr : World.getInstance().getVisibleObjects(tree, PlayerInstance.class))
{
int xxMin = tree.getX() - 60;
int yyMin = tree.getY() - 60;
int xxMax = tree.getX() + 60;
int yyMax = tree.getY() + 60;
int playerX = playerr.getX();
int playerY = playerr.getY();
if ((playerX > xxMin) && (playerX < xxMax) && (playerY > yyMin) && (playerY < yyMax))
{
SkillData.getInstance().getSkill(2139, 1).applyEffects(tree, playerr);
}
}
}
}
else if (player != null)
{
// FIXME: Unhardcore html!
if (event.equalsIgnoreCase("Tree"))
{
int itemsOk = 0;
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
for (ItemHolder item : REQUIRED_ITEMS)
{
long pieceCount = player.getInventory().getInventoryItemCount(item.getId(), -1);
if (pieceCount >= item.getCount())
{
itemsOk = itemsOk + 1;
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>" + ItemTable.getInstance().getTemplate(item.getId()).getName() + "</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
}
if (itemsOk == 4)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buyTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk < 4)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyTree"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
for (ItemHolder item : REQUIRED_ITEMS)
{
if (player.getInventory().getInventoryItemCount(item.getId(), -1) < item.getCount())
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
}
for (ItemHolder item : REQUIRED_ITEMS)
{
player.destroyItemByItemId(event, item.getId(), item.getCount(), player, true);
}
player.addItem(event, X_MAS_TREE1, 1, player, true);
}
else if (event.equalsIgnoreCase("SpecialTree") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Special Christmas Tree</font></td><td width=40><img src=\"Icon.etc_x_mas_tree_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the tree\" action=\"bypass -h Quest SavingSanta buySpecialTree\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySpecialTree") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, X_MAS_TREE2, 1, player, true);
}
else if (event.equalsIgnoreCase("SantaHat"))
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1);
int itemsOk = 0;
if (pieceCount >= 10)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Christmas Tree</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buyHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough items.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buyHat"))
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getInventoryItemCount(X_MAS_TREE1, -1) < 10)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
return null;
}
player.destroyItemByItemId(event, X_MAS_TREE1, 10, player, true);
player.addItem(event, SANTAS_HAT_ID, 1, player, true);
}
else if (event.equalsIgnoreCase("SavingSantaHat") && isEventPeriod())
{
htmltext = "<html><title>Christmas Event</title><body><br><br><table width=260><tr><td></td><td width=40></td><td width=40></td></tr><tr><td><font color=LEVEL>Saving Santa's Hat</font></td><td width=40><img src=\"Icon.Accessory_santas_cap_i00\" width=32 height=32></td><td width=40></td></tr></table><br><br><table width=260>";
long pieceCount = player.getInventory().getAdena();
int itemsOk = 0;
if (pieceCount >= 50000)
{
itemsOk = 1;
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=0FF000>OK</font></td></tr>";
}
else
{
htmltext = htmltext + "<tr><td>Adena</td><td width=40>" + pieceCount + "</td><td width=40><font color=8ae2ffb>NO</font></td></tr>";
}
if (itemsOk == 1)
{
htmltext = htmltext + "<tr><td><br></td><td width=40></td><td width=40></td></tr></table><table width=260>";
htmltext = htmltext + "<tr><td><center><button value=\"Get the hat\" action=\"bypass -h Quest SavingSanta buySavingHat\" width=110 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td></tr></table></body></html>";
}
else if (itemsOk == 0)
{
htmltext = htmltext + "</table><br><br>You do not have enough Adena.</center></body></html>";
}
return htmltext;
}
else if (event.equalsIgnoreCase("buySavingHat") && isEventPeriod())
{
playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
if (player.getInventory().getAdena() < 50000)
{
return null;
}
player.reduceAdena(event, 50000, player, true);
player.addItem(event, BR_XMAS_GAWIBAWIBO_CAP, 1, player, true);
}
else if (event.equalsIgnoreCase("HolidayFestival") && isEventPeriod())
{
if (_isSantaFree)
{
npc.broadcastPacket(new MagicSkillUse(npc, player, BR_XMAS_REWARD_BUFF, 1, 2000, 1));
SkillData.getInstance().getSkill(BR_XMAS_REWARD_BUFF, 1).applyEffects(player, player);
}
else
{
return "savingsanta-nobuff.htm";
}
}
else if (event.equalsIgnoreCase("getWeapon") && isEventPeriod())
{
if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) && (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0))
{
return "savingsanta-noweapon.htm";
}
return "savingsanta-weapon.htm";
}
else if (event.startsWith("weapon_") && isEventPeriod())
{
final int itemId = Integer.parseInt(event.split("weapon_")[1]) - 1;
if (player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_JACKPOT, -1) > 0)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_JACKPOT, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(10);
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
}
else if ((player.getInventory().getInventoryItemCount(BR_XMAS_WPN_TICKET_NORMAL, -1) > 0) /* || (player.getLevel() < 20) */)
{
player.destroyItemByItemId(event, BR_XMAS_WPN_TICKET_NORMAL, 1, player, true);
player.addItem(event, WEAPON_REWARDS[itemId], 1, player, true).setEnchantLevel(getRandom(4, 16));
}
}
}
return null;
}
@Override
public String onFirstTalk(Npc npc, PlayerInstance player)
{
switch (npc.getId())
{
case THOMAS_D_TURKEY_ID:
case HOLIDAY_SANTA_ID:
case HOLIDAY_SLED_ID:
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return null;
}
case SANTA_TRAINEE_ID:
{
return SAVING_SANTA ? "savingsanta.htm" : "santa.htm";
}
default:
{
return null;
}
}
}
@Override
public boolean unload()
{
for (Npc santaHelper : _santaHelpers)
{
santaHelper.deleteMe();
}
for (Npc specialTree : _specialTrees)
{
specialTree.deleteMe();
}
return super.unload();
}
@Override
public String onAggroRangeEnter(Npc npc, PlayerInstance player, boolean isSummon)
{
// FIXME: Increase Thomas D. Turkey aggro rage.
if (npc.getId() == THOMAS_D_TURKEY_ID)
{
// I guess you came to rescue Santa. But you picked the wrong person.
npc.broadcastPacket(new NpcSay(npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NPC_STRINGS[8]));
}
return null;
}
public static void main(String[] args)
{
new SavingSanta();
}
}

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<event name="Saving Santa" active="21 12 2019-11 01 2020" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/eventConfig.xsd">
<droplist>
<add item="5556" min="1" max="1" chance="4%" /> <!-- Star Ornament -->
<add item="5557" min="1" max="1" chance="4%" /> <!-- Bead Ornament -->
<add item="5558" min="1" max="1" chance="8%" /> <!-- Fir Tree Branch -->
<add item="5559" min="1" max="1" chance="1%" /> <!-- Flower Pot -->
<add item="5562" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 1st Carol -->
<add item="5563" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 2nd Carol -->
<add item="5564" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 3rd Carol -->
<add item="5565" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 4th Carol -->
<add item="5566" min="1" max="1" chance="2%" /> <!-- Echo Crystal - 5th Carol -->
</droplist>
<spawnlist>
<add npc="31863" x="147698" y="-56025" z="-2775" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="147453" y="26968" z="-2204" heading="49545" /> <!-- Santa Trainee -->
<add npc="31863" x="82218" y="148605" z="-3470" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="82754" y="53573" z="-1496" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="15064" y="143254" z="-2668" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="111067" y="218933" z="-3543" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-12965" y="122914" z="-3117" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="87362" y="-143166" z="-1293" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-81037" y="150092" z="-3044" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="117412" y="76642" z="-2695" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="43983" y="-47758" z="-797" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45907" y="49387" z="-3060" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="12153" y="16753" z="-4584" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-84458" y="244761" z="-3730" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="114750" y="-178692" z="-820" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-45656" y="-113119" z="-240" heading="0" /> <!-- Santa Trainee -->
<add npc="31863" x="-117195" y="46837" z="36" heading="0" /> <!-- Santa Trainee -->
<add npc="13006" x="83254" y="148340" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83278" y="147900" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83241" y="148898" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="83281" y="149343" z="-3405" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84304" y="149133" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="84311" y="148101" z="-3402" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82948" y="147658" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80905" y="147659" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="80908" y="149556" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="82957" y="149554" z="-3469" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147849" y="-55119" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147580" y="-55117" z="-2734" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147581" y="-57244" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147847" y="-57261" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="149085" y="-55826" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146340" y="-55829" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147826" y="-54095" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147584" y="-54070" z="-2735" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="146235" y="25921" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147840" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147055" y="25568" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148694" y="25929" z="-2013" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147733" y="27366" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147197" y="27364" z="-2205" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147266" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147646" y="29065" z="-2269" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147456" y="27664" z="-2204" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="148078" y="-55960" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="147348" y="-55939" z="-2781" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="117056" y="75627" z="-2726" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116473" y="75352" z="-2712" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115785" y="76111" z="-2715" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="115939" y="76544" z="-2719" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116833" y="77400" z="-2697" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="116666" y="76210" z="-2730" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13130" y="122533" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13165" y="122425" z="-2989" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="-13126" y="122806" z="-3117" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="15733" y="142767" z="-2706" heading="0" /> <!-- Christmas Tree -->
<add npc="13006" x="16208" y="142710" z="-270" heading="0" /> <!-- Christmas Tree -->
</spawnlist>
<messages>
<add type="onEnd" text="Saving Santa: Event end!" />
<add type="onEnter" text="Saving Santa: Event ongoing!" />
</messages>
</event>

View File

@@ -0,0 +1,21 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Special Christmas Tree" action="bypass -h Quest SavingSanta SpecialTree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
</table>
<br>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want the Holiday Festival buff?</center></td></tr>
</table>
<br>
I can give Holiday Festival buff only when Santa is freed! Go defeat the evil Thomas D. Turkey to save Santa!
</body></html>

View File

@@ -0,0 +1,12 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
First get a Santa Claus Weapon Exchange Ticket!
</body></html>

View File

@@ -0,0 +1,43 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
<table width=260>
<tr><td><center>So, you want an Event Weapon?</center></td></tr>
</table>
<br>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td>Choose a weapon type:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Sword" action="bypass -h Quest SavingSanta weapon_1" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Sword" action="bypass -h Quest SavingSanta weapon_2" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_4" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_5" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="1h Blunt" action="bypass -h Quest SavingSanta weapon_6" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="2h Blunt" action="bypass -h Quest SavingSanta weapon_7" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for mages</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dagger" action="bypass -h Quest SavingSanta weapon_3" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Bow" action="bypass -h Quest SavingSanta weapon_9" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Fist" action="bypass -h Quest SavingSanta weapon_8" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Dual" action="bypass -h Quest SavingSanta weapon_11" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Pole" action="bypass -h Quest SavingSanta weapon_10" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for fighters</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Ancient Sword" action="bypass -h Quest SavingSanta weapon_13" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Rapier" action="bypass -h Quest SavingSanta weapon_12" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="CrossBow" action="bypass -h Quest SavingSanta weapon_14" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>for Kamaels</td></tr>
</table>
</body></html>

View File

@@ -0,0 +1,25 @@
<html><title>Santa's Helper</title><body>
<center>
<table width=260>
<tr><td><center><img src="Icon.etc_X_mas_tree_i00" width=32 height=32></center></td><td><center>Christmas Event</center></td><td><center><img src="Icon.Accessory_santas_cap_i00" width=32 height=32></center></td></tr>
</table>
<br><br>
So, what do you want to trade?<br1>
<table width=260>
<tr><td></td><td></td></tr>
<tr><td><button value="Christmas Tree" action="bypass -h Quest SavingSanta Tree" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>4 Bead Ornaments</td></tr>
<tr><td></td><td>4 Star Ornaments</td></tr>
<tr><td></td><td>10 Fir Tree Branches</td></tr>
<tr><td></td><td>1 Flower pot</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Santa's Hat" action="bypass -h Quest SavingSanta SantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>10 Christmas Trees</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Saving Santa's Hat" action="bypass -h Quest SavingSanta SavingSantaHat" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>50000 Adena</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Holiday Festival" action="bypass -h Quest SavingSanta HolidayFestival" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Free Santa</td></tr>
<tr><td></td><td></td></tr>
<tr><td><button value="Get weapon" action="bypass -h Quest SavingSanta getWeapon" width=136 height=20 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df"></td><td>Weapon Exchange Ticket</td></tr>
</table>
<br>
The items can be obtained by hunting monsters throughout Aden and Elmore. Good luck and come back to see me when you have the required items!
</body></html>

View File

@@ -224,49 +224,64 @@
</skill>
<skill id="21014" levels="1" name="Scissors">
<!-- Attacks with scissors. Usable only on the crooked turkey. -->
<set name="icon" val="BranchSys.icon.br_xmas_gawi_i00" />
<set name="castRange" val="400" />
<set name="coolTime" val="500" />
<set name="effectPoint" val="-1" />
<set name="effectRange" val="500" />
<set name="hitTime" val="2000" />
<set name="icon" val="BranchSys.icon.br_xmas_gawi_i00" />
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="magicLvl" val="1" />
<set name="operateType" val="A1" />
<set name="targetType" val="ONE" />
<set name="targetType" val="SELF" />
<cond msgId="109">
<target npcId="13183" />
</cond>
<selfEffects>
<effect name="CallSkill">
<param skillId="23019" skillLevel="1" />
</effect>
</selfEffects>
</skill>
<skill id="21015" levels="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
<set name="icon" val="BranchSys.icon.br_xmas_bawi_i00" />
<set name="castRange" val="400" />
<set name="coolTime" val="500" />
<set name="effectPoint" val="-1" />
<set name="hitTime" val="2000" />
<set name="icon" val="BranchSys.icon.br_xmas_bawi_i00" />
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="magicLvl" val="1" />
<set name="operateType" val="A1" />
<set name="targetType" val="ONE" />
<set name="targetType" val="SELF" />
<cond msgId="109">
<target npcId="13183" />
</cond>
<selfEffects>
<effect name="CallSkill">
<param skillId="23019" skillLevel="2" />
</effect>
</selfEffects>
</skill>
<skill id="21016" levels="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
<set name="icon" val="BranchSys.icon.br_xmas_bo_i00" />
<set name="castRange" val="400" />
<set name="coolTime" val="500" />
<set name="effectPoint" val="-1" />
<set name="hitTime" val="2000" />
<set name="icon" val="BranchSys.icon.br_xmas_bo_i00" />
<set name="isMagic" val="2" /> <!-- Static Skill -->
<set name="magicLvl" val="1" />
<set name="operateType" val="A1" />
<set name="targetType" val="ONE" />
<set name="targetType" val="SELF" />
<cond msgId="109">
<target npcId="13183" />
</cond>
<selfEffects>
<effect name="CallSkill">
<param skillId="23019" skillLevel="3" />
</effect>
</selfEffects>
</skill>
<skill id="21017" levels="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases critical rate. Bestows the ability to regenerate HP by using some of the damage inflicted on the enemy. Excludes damage caused by skills and long-range attack. -->

View File

@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.model.conditions;
import java.util.List;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.skills.Skill;
@@ -41,6 +42,7 @@ public class ConditionTargetNpcId extends Condition
@Override
public boolean testImpl(Creature effector, Creature effected, Skill skill, Item item)
{
return (effected != null) && (effected.isNpc() || effected.isDoor()) && _npcIds.contains(effected.getId());
final WorldObject target = (effector == null) || !effector.isPlayer() ? effected : effector.getTarget();
return (target != null) && (target.isNpc() || target.isDoor()) && _npcIds.contains(target.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -39,6 +39,7 @@ public class OpTargetNpcSkillCondition implements ISkillCondition
@Override
public boolean canUse(Creature caster, Skill skill, WorldObject target)
{
return (target != null) && target.isNpc() && _npcId.contains(target.getId());
final WorldObject actualTarget = (caster == null) || !caster.isPlayer() ? target : caster.getTarget();
return (actualTarget != null) && (actualTarget.isNpc() || actualTarget.isDoor()) && _npcId.contains(actualTarget.getId());
}
}

View File

@@ -305,15 +305,21 @@
<magicCriticalRate>5</magicCriticalRate>
<hitCancelTime>1</hitCancelTime>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>1</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21015" toLevel="1" name="Rock">
<!-- Challenge him with the rock. Usable only on the crooked turkey. -->
@@ -329,15 +335,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>2</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21016" toLevel="1" name="Paper">
<!-- Challenge him with the paper. Usable only on the crooked turkey. -->
@@ -353,15 +365,21 @@
<hitCancelTime>1</hitCancelTime>
<effectRange>500</effectRange>
<staticReuse>true</staticReuse>
<targetType>ENEMY</targetType>
<targetType>SELF</targetType>
<affectScope>SINGLE</affectScope>
<conditions>
<condition name="OpTargetNpc">
<npcIds>
<item>100</item>
<item>13183</item>
</npcIds>
</condition>
</conditions>
<selfEffects>
<effect name="CallSkill">
<skillId>23019</skillId>
<skillLevel>3</skillLevel>
</effect>
</selfEffects>
</skill>
<skill id="21017" toLevel="1" name="Holiday Dream Weapon">
<!-- Increases Max CP. Increases Critical Rate. Increases the ability to restore some damage inflicted on the enemy as HP with a certain probability. Excludes damage by skill or ranged attacks. -->