L2JMobius

C6 Special Christmas Tree (5561) and its special buff (2139)

ver · 6 · 5070

Offline ver

  • Knight
  • ***
    • Posts: 70
Hi guys,
 
I wanted to find out how christmass tree casts its buff when player is around. For that I've Summoned Special Christmass Tree aaaaand nothing happend.

Summoning trees works fine, however Special Christmass Tree (npc 13007 from item 5561) seems to be not casting its buff (2139) at all.
I know it too little, too late cuz christmass time is over, however... would be nice if that thing would work

best regards!


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16147

Offline ver

  • Knight
  • ***
    • Posts: 70
No, both trees are Npc type at the moment. Will try XmassTree.
However XmassTree type you've pointed seems to be incorrect.

From description of 5561: "Summons a Christmas tree that will increase HP and MP regeneration. This effect is only produced if the Special Christmas Tree is summoned outside of a village." - so it suppose to cast just "Special Tree Recovery Bonus" (2139)... and nothing else.
While XmassTreeInstance gives Holiday Wind Walk, Holiday Haste, Holiday Empower, Holiday Might and Holiday Shield which seems to be related to some other event? Any idea what should give those buffs?


Offline ver

  • Knight
  • ***
    • Posts: 70
Based on XmassTree instance I've created this:

Code: [Select]
Index: L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/ChirstmasTreeInstance.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/ChirstmasTreeInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/ChirstmasTreeInstance.java
new file mode 100644
--- /dev/null (revision 21fb136d627be4148c7aba1cee452fd59087b50a)
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/ChirstmasTreeInstance.java (revision 21fb136d627be4148c7aba1cee452fd59087b50a)
@@ -0,0 +1,91 @@
+/*
+ * 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 org.l2jmobius.gameserver.model.actor.instance;
+
+import org.l2jmobius.commons.concurrent.ThreadPool;
+import org.l2jmobius.commons.util.Rnd;
+import org.l2jmobius.gameserver.data.SkillTable;
+import org.l2jmobius.gameserver.model.Skill;
+import org.l2jmobius.gameserver.model.WorldObject;
+import org.l2jmobius.gameserver.model.actor.Creature;
+import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
+import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
+
+import java.util.concurrent.ScheduledFuture;
+
+public class ChirstmasTreeInstance extends NpcInstance
+{
+ private final ScheduledFuture<?> _aiTask;
+ // Special Tree Recovery Bonus
+ private int RECOVERY_BONUS = 2139;
+
+ class ChirstmasTreeAI implements Runnable
+ {
+ private final ChirstmasTreeInstance _caster;
+
+ protected ChirstmasTreeAI(ChirstmasTreeInstance caster)
+ {
+ _caster = caster;
+ }
+
+ @Override
+ public void run()
+ {
+ final Skill skill = SkillTable.getInstance().getSkill(RECOVERY_BONUS, 1);
+ for (PlayerInstance player : getKnownList().getKnownPlayers().values())
+ {
+ if (player.getFirstEffect(skill) == null)
+ {
+ setTarget(player);
+ doCast(skill);
+ broadcastPacket(new MagicSkillUse(_caster, player, skill.getId(), skill.getLevel(), skill.getHitTime(), 0));
+ }
+ }
+ }
+ }
+
+ public ChirstmasTreeInstance(int objectId, NpcTemplate template)
+ {
+ super(objectId, template);
+ _aiTask = ThreadPool.scheduleAtFixedRate(new ChirstmasTreeAI(this), 3000, 3000);
+ }
+
+ @Override
+ public void deleteMe()
+ {
+ if (_aiTask != null)
+ {
+ _aiTask.cancel(true);
+ }
+
+ super.deleteMe();
+ }
+
+ @Override
+ public int getDistanceToWatchObject(WorldObject object)
+ {
+ final Skill skill = SkillTable.getInstance().getSkill(RECOVERY_BONUS, 1);
+
+ return skill.getEffectRange();
+ }
+
+ @Override
+ public boolean isAutoAttackable(Creature attacker)
+ {
+ return false;
+ }
+}


Seems to be working:


Ofcourse SQL changing type of tree is also required:
Code: [Select]
UPDATE `npc` SET `type` = 'ChirstmasTree' WHERE (`id` = '13007');


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16147
Works, but better use same instance type and do what is different by checking template id.

Also speck check Christmas.


Offline ver

  • Knight
  • ***
    • Posts: 70
Not really...

Xmass instance (besides odd name) does some holiday buff from the tree (I mean holiday buffs, not that recovery blessing) which is not suppose to be done there. Holiday buffs are suppose to be casted by Santa Trainee located in starting villages in 'Tis The Season event. At least the event description says like that (I've found some copy here: http://l2mordor.eu/legacy/archive/2006/12/tis_the_season_1.html). I see no point of keeping XmassInstance at all...

Maybe thats why we have two Santa Trainees - 31864 and 31863. One in starting villages giving buffs and 2nd around the world (not giving buffs, just event manager). Just not sure which one suppose to be where, but I think it doesnt really matter cuz they both looks the same and (probably) suppose to have same dialogues.
 
Btw the code itself... the tree description says it should not give recovery buff while summoned in peace area.
I tried to achieve it by this:

Code: [Select]
_aiTask = isInsideZone(ZoneId.PEACE) ? null : ThreadPool.scheduleAtFixedRate(new ChirstmasTreeAI(this), 3000, 3000);

but for some reason isInsideZone(ZoneId.PEACE) returns always false if used in that place...

I made it that way - inside the ChirstmasTreeAI.run method:
Code: [Select]
@Override
public void run()
{
if (_caster.isInsideZone(ZoneId.PEACE))
{
return;
}

It works, but... but imho the AI should not be even started. I dont like it ;/

I also found that org.l2jmobius.gameserver.handler.itemhandlers.ChristmasTree is also not used because tree npc is spawned by org.l2jmobius.gameserver.handler.itemhandlers.SummonItems. So itemhandlers.ChristmasTree should be kicked too.

What do you think?