L2JMobius

C6 [NPC] - Aio Seller

Pirsys · 2 · 2621

Offline Pirsys

  • Knight
  • ***
    • Posts: 67
Code: [Select]
package custom.AioSeller;

import org.l2jmobius.Config;
import org.l2jmobius.gameserver.enums.ChatType;
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;

/**
 * @author TiTaM
 */
public class AioSeller extends Quest
{
// ------------------------------------------------
// Id do Npc
private static final int[] NPC =
{
50009
};
// ------------------------------------------------
// Id da moeda e quantidade para a primeira opçao.
private static final int MOEDA1 = 57;
private static final int COUNT1 = 30000000;
// Dias pra a primeira opçao.
private static final int DIAS1 = 30;
// ------------------------------------------------
// Id da moeda e quantidade para a segunda opçao.
private static final int MOEDA2 = 57;
private static final int COUNT2 = 60000000;
// Dias pra a segunda opçao.
private static final int DIAS2 = 60;
// ------------------------------------------------
// Id da moeda e quantidade para a terceira opçao.
private static final int MOEDA3 = 57;
private static final int COUNT3 = 100000000;
// Dias pra a terceira opçao.
private static final int DIAS3 = 90;
// ------------------------------------------------

public AioSeller(int questid, String name, String descr)
{
super(questid, name);

for (int NPC_ID : NPC)
{
addStartNpc(NPC_ID);
addFirstTalkId(NPC_ID);
addTalkId(NPC_ID);
}
}

@Override
public String onAdvEvent(String event, NpcInstance npc, PlayerInstance player)
{
QuestState st = player.getQuestState(getName());
String htmltext = "";
int npcId = npc.getNpcId();

if (event.equalsIgnoreCase("1.htm"))
{
return "1.htm";
}
if (event.equalsIgnoreCase("2.htm"))
{
return "2.htm";
}
if (event.equalsIgnoreCase("3.htm"))
{
return "3.htm";
}
if (event.equalsIgnoreCase("4.htm"))
{
return "4.htm";
}
if (event.equalsIgnoreCase("5.htm"))
{
return "5.htm";
}
if (event.equalsIgnoreCase("6.htm"))
{
return "6.htm";
}
if (event.equalsIgnoreCase("7.htm"))
{
return "7.htm";
}
if (event.equalsIgnoreCase("8.htm"))
{
return "8.htm";
}
if (event.equalsIgnoreCase("9.htm"))
{
return "9.htm";
}
if (event.equalsIgnoreCase("10.htm"))
{
return "10.htm";
}

if (event.equalsIgnoreCase("aio_option_1"))
{
if (npcId == NPC[0])
{
if (player.getLevel() > 1)

{
htmltext = "aiolevel.htm";

if (player.isAio())
{
htmltext = "already_isaio.htm";
}

}
else
{
if (st.getQuestItemsCount(MOEDA1) >= COUNT1)
{
st.takeItems(MOEDA1, COUNT1);
player.setAio(true);
player.getAppearance().setNameColor(Config.AIO_NCOLOR);
player.getAppearance().setTitleColor(Config.AIO_TCOLOR);
int daysleft = player.getAioEndTime() <= 0 ? 0 : (int) ((player.getAioEndTime() - System.currentTimeMillis()) / 86400000);
player.setEndTime("aio", daysleft + DIAS1);
player.getInventory().addItem("", 9388, 1, player, null);
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
player.sendPacket(new CreatureSay(0, ChatType.WHISPER, "Aio System", "Dear player, you have AIO status now with special abilities , congratulations."));
player.getStat().addExp(player.getStat().getExpForLevel(81));
player.rewardAioSkills();
player.sendSkillList();
player.broadcastUserInfo();
htmltext = "win_aio.htm";
}
else
{
htmltext = "no_item.htm";
}
}
}
}
if (event.equalsIgnoreCase("aio_option_2"))
{
if (npcId == NPC[0])
{
if (player.getLevel() > 1)
{
htmltext = "aiolevel.htm";

if (player.isAio())
{
htmltext = "already_isaio.htm";
}

}

else
{
if (st.getQuestItemsCount(MOEDA2) >= COUNT2)
{
st.takeItems(MOEDA2, COUNT2);
player.setAio(true);
player.getAppearance().setNameColor(Config.AIO_NCOLOR);
player.getAppearance().setTitleColor(Config.AIO_TCOLOR);
int daysleft = player.getAioEndTime() <= 0 ? 0 : (int) ((player.getAioEndTime() - System.currentTimeMillis()) / 86400000);
player.setEndTime("aio", daysleft + DIAS2);
player.getInventory().addItem("", 9388, 1, player, null);
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
player.sendPacket(new CreatureSay(0, ChatType.WHISPER, "Aio System", "Dear player, you have AIO status now with special abilities , congratulations."));
player.getStat().addExp(player.getStat().getExpForLevel(81));
player.rewardAioSkills();
player.sendSkillList();
player.broadcastUserInfo();
htmltext = "win_aio.htm";
}
else
{
htmltext = "no_item.htm";
}
}
}
}
if (event.equalsIgnoreCase("aio_option_3"))
{
if (npcId == NPC[0])
{
if (player.getLevel() > 1)
{
htmltext = "aiolevel.htm";

if (player.isAio())
{
htmltext = "already_isaio.htm";
}

}
else
{
if (st.getQuestItemsCount(MOEDA3) >= COUNT3)
{
st.takeItems(MOEDA3, COUNT3);
player.setAio(true);
player.getAppearance().setNameColor(Config.AIO_NCOLOR);
player.getAppearance().setTitleColor(Config.AIO_TCOLOR);
int daysleft = player.getAioEndTime() <= 0 ? 0 : (int) ((player.getAioEndTime() - System.currentTimeMillis()) / 86400000);
player.setEndTime("aio", daysleft + DIAS3);
player.getInventory().addItem("", 9388, 1, player, null);
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
player.sendPacket(new CreatureSay(0, ChatType.WHISPER, "Aio System", "Dear player, you have AIO status now with special abilities , congratulations."));
player.getStat().addExp(player.getStat().getExpForLevel(81));
player.rewardAioSkills();
player.sendSkillList();
player.broadcastUserInfo();
htmltext = "win_aio.htm";
}
else
{
htmltext = "no_item.htm";
}
}
}
}
if (event.equalsIgnoreCase("remove_aio"))
{
if (npcId == NPC[0])
{
if (player.isAio())
{
player.setAio(false);
player.setAioEndTime(0);
player.lostAioSkills();
player.getInventory().destroyItemByItemId("", 9388, 1, player, null);
player.getAppearance().setNameColor(0xFFFFFF);
player.getAppearance().setTitleColor(0xFFFF77);
player.broadcastUserInfo();
player.sendSkillList();
player.broadcastUserInfo();

htmltext = "remove_aio.htm";
}
else
{
htmltext = "none.htm";
}
}
return htmltext;
}
st.exitQuest(true);
return htmltext;
}

@Override
public String onFirstTalk(NpcInstance npc, PlayerInstance player)
{
QuestState st = player.getQuestState(getName());
if (st == null)
{
st = newQuestState(player);
}
String htmltext = "";
int npcId = npc.getNpcId();
if (npcId == NPC[0])
{
htmltext = "1.htm";
}
return htmltext;
}

public static void main(String[] args)
{
new AioSeller(-1, "AioSeller", "custom");
}
}



HTM = Create and edit you.


Offline Pirsys

  • Knight
  • ***
    • Posts: 67
the npc checks that the character is level 1, to avoid skill errors..