L2JMobius

High Five Voiced Commands (7rb, combine talismans, AA, boss status, atod ) - All projects

Invoke · 4 · 5985

Offline Invoke

  • Heir
  • **
    • Posts: 18
Hey guys, its been a long since i shared something, hope you find these simple commands useful, -Invoke.

7rb:
Code: [Select]
package handlers.voicedcommandhandlers;

import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;

/**
 *
 * @author -Invoke
 *
 */

public class SevenRB implements IVoicedCommandHandler
{
private static final String QUEST_NAME = "Q00254_LegendaryTales";
private static final String SERVER_NAME = "7RB Quest";
private static final String[] COMMANDS =
{
"7rb",
};

@Override
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String params)
{
if (command.equalsIgnoreCase("7rb"))
{
QuestState state = activeChar.getQuestState(QUEST_NAME);
NpcHtmlMessage html = new NpcHtmlMessage();
html.setHtml(buildHtml(state));
activeChar.sendPacket(html);
}
return true;
}

private static final String buildHtml(QuestState st)
{
StringBuilder sb = new StringBuilder();
sb.append("<html noscrollbar><head>");
sb.append("<title>" + SERVER_NAME + "</title>");
sb.append("</head>");
sb.append("<body><br>");
sb.append("<br>7 Rb Quest (Legendary Tales) status:<br>");
if (st == null)
{
sb.append("Quest not found. Please visit Glimore in Dragon Valley in order to begin the quest.");
sb.append("<br>");
}
else
{
if (st.isCond(1))
{
for (Bosses boss : Bosses.class.getEnumConstants())
{
sb.append(boss.getName() + ": ");
sb.append(checkMask(st, boss) ? "<font color=\"00FF00\">Killed.</font>" : "<font color=\"FF0000\">Not killed.</font>");
sb.append("<br>");
}
}
else
{
sb.append("Legendary Tales quest is completed.");
sb.append("<br>");
}
}
sb.append("</body></html>");
return sb.toString();
}

private static boolean checkMask(QuestState qs, Bosses boss)
{
int pos = boss.getMask();
return ((qs.getInt("raids") & pos) == pos);
}

public static enum Bosses
{
EMERALD_HORN("Emerald Horn"),
DUST_RIDER("Dust Rider"),
BLEEDING_FLY("Bleeding Fly"),
BLACK_DAGGER("Blackdagger Wing"),
SHADOW_SUMMONER("Shadow Summoner"),
SPIKE_SLASHER("Spike Slasher"),
MUSCLE_BOMBER("Muscle Bomber");

private final String name;
private final int _mask;

private Bosses(String name)
{
this.name = name;
_mask = 1 << ordinal();
}

public int getMask()
{
return _mask;
}

public String getName()
{
return name;
}
}

@Override
public String[] getVoicedCommandList()
{
return COMMANDS;
}
}

Combine Talismans: *ADD THIS IN ItemInstance*
Code: [Select]
/**
* Method used by .combinetalismans.
* @param value
*/
public void setMana(int value)
{
_mana = value;
}
Code: [Select]
package handlers.voicedcommandhandlers;

import java.util.ArrayList;
import java.util.List;

import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.network.serverpackets.ItemList;

/**
 *
 * @author -Invoke
 *
 */

public class CombineTalismans implements IVoicedCommandHandler
{
private static final String[] _voicedCommands =
{

"combine", "combinetalismans", "combinetalisman"
};

@Override
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String params)
{

if (command.startsWith("combine") || command.startsWith("combinetalismans")
|| command.startsWith("combinetalisman"))
{

List<int[]> _sameIds = new ArrayList<>();

for (ItemInstance item : activeChar.getInventory().getItems()) {
// Getting talisman
if ((item.getMana() > 0) && item.getName().contains("Talisman")) {
addTalisman(_sameIds, item.getId());
}
}
int newCount = 0;
for (int[] idCount : _sameIds) {
// Item Count > 1
if (idCount[1] > 1) {
int lifeTime = 0;
List<ItemInstance> existingTalismans = activeChar.getInventory().getItemsByItemId(idCount[0]);
for (ItemInstance existingTalisman : existingTalismans) {
// Take remaining mana of this talisman.
lifeTime += existingTalisman.getMana();
// Destroy all talismans from this ID.
activeChar.getInventory().destroyItem("Combine Talismans", existingTalisman, activeChar, null);
}

ItemInstance newTalisman = activeChar.addItem("Combine talismans", idCount[0], 1, null, false);
// Add the total mana to the new talisman.
newTalisman.setMana(lifeTime);
// store in DB
newTalisman.updateDatabase();

newCount++;
}
}

if (newCount > 0)
{
activeChar.sendMessage("You have combined " + newCount + " talismans.");
activeChar.sendPacket(new ItemList(activeChar, false));
}
else
{
activeChar.sendMessage("You don't have Talismans to combine.");
return true;
}
}
return false;
}

private static void addTalisman(List<int[]> sameIds, int itemId)
{
for (int[] sameId : sameIds)
{
if (sameId[0] == itemId) {
sameId[1] = sameId[1] + 1;
return;
}
}
sameIds.add(new int[] { itemId, 1 });
}

@Override
public String[] getVoicedCommandList()
{
return _voicedCommands;
}
}

Make Ancient Adena:
Code: [Select]
package handlers.voicedcommandhandlers;

import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;

/**
 *
 * @author -Invoke
 *
 */
public class MakeAncientAdena implements IVoicedCommandHandler
{
private static final int ANCIENT_ADENA = 5575;
private static final int BLUE_SEAL_STONE = 6360;
private static final int GREEN_SEAL_STONE = 6361;
private static final int RED_SEAL_STONE = 6362;
private static final String[] commands =
{
"aa",
"makeaa",
};

@Override
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String params)
{
if (command.equalsIgnoreCase("aa") || command.equalsIgnoreCase("makeaa"))
{
ItemInstance redStones = activeChar.getInventory().getItemByItemId(RED_SEAL_STONE);
ItemInstance greenStones = activeChar.getInventory().getItemByItemId(GREEN_SEAL_STONE);
ItemInstance blueStones = activeChar.getInventory().getItemByItemId(BLUE_SEAL_STONE);
int count = 0;
int aa = 0;
if ((redStones != null) && activeChar.destroyItem("MakeAA", redStones, null, true))
{
count += redStones.getCount();
aa += redStones.getCount() * 10;
}
if ((greenStones != null) && activeChar.destroyItem("MakeAA", greenStones, null, true))
{
count += greenStones.getCount();
aa += greenStones.getCount() * 5;
}
if ((blueStones != null) && activeChar.destroyItem("MakeAA", blueStones, null, true))
{
count += blueStones.getCount();
aa += blueStones.getCount() * 3;
}
if (count == 0)
{
activeChar.sendMessage("You do not have any seal stones to exchange.");
return false;
}
activeChar.addItem("MakeAA", ANCIENT_ADENA, aa, activeChar, true);
activeChar.sendMessage("You have successfully exchanged " + count + " seal stones!");
}
return true;
}

@Override
public String[] getVoicedCommandList()
{
return commands;
}
}

Grand Boss Status:
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.voicedcommandhandlers;

import java.sql.Date;
import java.text.SimpleDateFormat;

import org.l2jmobius.gameserver.data.xml.impl.NpcData;
import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
import org.l2jmobius.gameserver.model.StatsSet;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;

/**
 *
 * @author -Invoke
 *
 */
public class GrandBossStatus implements IVoicedCommandHandler
{

private static final String[] VOICED_COMMANDS =
{
"grandboss"
};

@Override
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String target)
{
if (command.startsWith("grandboss"))
{
return BossStatus(activeChar);
}
return true;
}

public boolean BossStatus(PlayerInstance activeChar)
{
int[] BOSSES =
{
// QA
29001,
// CORE
29006,
// ORFEN
29014,
// ANTHARAS
29068,
// BAIUM
29020,
// VALAKAS
29028
};
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
activeChar.sendMessage("- GRANDBOSS TABLE -");
for (int boss : BOSSES)
{
// if doesnt work remove toString - invoke
String name = NpcData.getInstance().getTemplate(boss).getName().toString();
StatsSet stats = GrandBossManager.getInstance().getStatsSet(boss);
if (stats == null)
{
activeChar.sendMessage("Status for GrandBoss " + boss + " is not found.");
continue;
}
if (boss == 29019)
{
long dmax = 0;
for (int i = 29066; i <= 29068; i++)
{
StatsSet s = GrandBossManager.getInstance().getStatsSet(i);
if (s == null)
{
continue;
}
long d = s.getLong("respawn_time");
if (d >= dmax)
{
dmax = d;
stats = s;
}
}
}
long delay = stats.getLong("respawn_time");
long currentTime = System.currentTimeMillis();
if (delay <= currentTime)
{
activeChar.sendMessage(" " + name + "  Is Alive");
}
else
{
activeChar.sendMessage("(" + name + ")  Is Dead ( " + sdf.format(new Date(delay)) + " )");
}
}
return true;
}

@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}

Open Ancient Tomes of Demon:
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.voicedcommandhandlers;

import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;

/**
 *
 * @author -Invoke
 *
 */
public class ATOD implements IVoicedCommandHandler
{

private static final String[] VOICED_COMMANDS =
{
"openatod"
};

@Override
public boolean useVoicedCommand(String command, PlayerInstance activeChar, String params)
{
if (command.equalsIgnoreCase("openatod")) {
if (params == null) {
activeChar.sendMessage("Usage: .openatod [number]");
} else {
int num = 0;
try {
num = Integer.parseInt(params);
} catch (NumberFormatException nfe) {
activeChar.sendMessage("You must enter a number. Usage: .openatod [number]");
return false;
}

if (num == 0) {
return false;
} else if (activeChar.getInventory().getInventoryItemCount(9599, 0) >= num) {
int a = 0, b = 0, c = 0, rnd;
for (int i = 0; i < num; i++) {
rnd = Rnd.get(100);
if ((rnd <= 100) && (rnd > 44)) {
a++;
} else if ((rnd <= 44) && (rnd > 14)) {
b++;
} else if (rnd <= 14) {
c++;
}
}
if (activeChar.destroyItemByItemId("ATOD", 9599, a + b + c, null, true)) {
if (a > 0) {
activeChar.addItem("ATOD", 9600, a, null, true);
}
if (b > 0) {
activeChar.addItem("ATOD", 9601, b, null, true);
}
if (c > 0) {
activeChar.addItem("ATOD", 9602, c, null, true);
}
} else {
activeChar.sendMessage("You do not have enough tomes.");
return true;
}
} else {
activeChar.sendMessage("You do not have enough tomes.");
return true;
}
}
}
return false;
}

@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}


Offline sztormy

  • Vassal
  • *
    • Posts: 6
org.l2jmobius.gameserver.model.actor.instance.PlayerInstance doesnt exist in the latest build


Online Puppyrawr

  • Viscount
  • *****
    • Posts: 379
  • L2AquaSage
    • L2AquaSage
org.l2jmobius.gameserver.model.actor.instance.PlayerInstance doesnt exist in the latest build

yup its not hard to find out how to fix it! also Invoke post it 2-3 years ago!


Offline Reanimation

  • Knight
  • ***
    • Posts: 62
Have you already tried to adapt it? It's really easy, org.l2jmobius.gameserver.model.actor.instance.PlayerInstance is currently: org.l2jmobius.gameserver.model.actor.player