L2JMobius

Interlude Mystery Potion

dramaa · 3 · 1218

Online dramaa

  • Baron
  • *****
    • Posts: 268
    • L2Equinox
not a crazy big share, i just saw that mystery potion (increases head size) was not working, and i came with easy solution, made handler for it, not a big change, it's won't come in conflict to any codes or stuff, so if your mystery potions not working as well there it is.

dist/game/data/scripts/handlers/itemhandlers/HeadSizeHandler.java (new class)
Code: [Select]
/*
 * 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 handlers.itemhandlers;

import org.l2jmobius.commons.threads.ThreadPool;
import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.AbnormalVisualEffect;

public class HeadSizeHandler implements IItemHandler
{
private static final int DURATION_MS = 120000; // 2 minutes

[member=79]override[/member]
public boolean useItem(Playable playable, Item item, boolean forceUse)
{
if (!(playable instanceof Player))
{
return false;
}

final Player player = (Player) playable;

player.startAbnormalVisualEffect(true, AbnormalVisualEffect.BIG_HEAD);

ThreadPool.schedule(() -> player.stopAbnormalVisualEffect(true, AbnormalVisualEffect.BIG_HEAD), DURATION_MS);

if (!player.destroyItem("Consume", item.getObjectId(), 1, null, false))
{
player.sendMessage("Failed to destroy item " + item.getId() + ".");
}

return true;
}

}
dist/game/data/scripts/handlers/MasterHandler.java
Add those:
Code: [Select]
import handlers.itemhandlers.HeadSizeHandler;
HeadSizeHandler.class,
skill Mystery Potion
Code: [Select]
<item id="5234" type="EtcItem" name="Mystery Potion">
<!-- Legend says that if you drink this potion your head will grow larger! Believe it if you will! -->
<set name="icon" val="icon.etc_lesser_potion_clear_i00" />
<set name="default_action" val="SKILL_REDUCE" />
<set name="etcitem_type" val="POTION" />
<set name="immediate_effect" val="true" />
<set name="material" val="LIQUID" />
<set name="weight" val="50" />
<set name="price" val="10000" />
<set name="reuse_delay" val="500" />
<set name="is_stackable" val="true" />
<set name="is_oly_restricted" val="true" />
<set name="handler" val="HeadSizeHandler" />
</item

i made it for me, i might did not get it right, how it was actually working, so before use it, do some research.


Online Mobius

  • Distinguished King
  • *****
    • Posts: 19715
As with other potions, the correct way to do it, is call the skill that does that.


Online dramaa

  • Baron
  • *****
    • Posts: 268
    • L2Equinox
As with other potions, the correct way to do it, is call the skill that does that.
Mystery potion has this skill but head was not getting big, i was getting effect as icon like buffs, but head was staying same