L2JMobius
Public Development => Shares/Contributions => Topic started by: lovepako on April 11, 2025, 06:12:01 AM
-
All that's missing is the HTML, whoever has more time can create it :)
/**
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack 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 quests.Q00689_SkillSeller;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
import org.l2jmobius.gameserver.model.quest.Quest;
import org.l2jmobius.gameserver.model.quest.QuestState;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
/**
* @author fissban
*/
public class Q00689_SkillSeller extends Quest
{
// Npc
private static final int NPC = 50061;
// Cantidad maxima q un user puede aprender de skills.
private static final int MAX_SKILLS_ADD = 3;
// Precio por aprender cada skills....
private static final int ITEMD_ID = 57; // Adena
private static final int ITEM_COUNT = 10; // Cantidad
// Skills a regalar (SkillId - SkillLvl)
private static final List<SkillHolder> SKILLS = new ArrayList<>();
{
SKILLS.add(new SkillHolder(365, 1));// Acumen
SKILLS.add(new SkillHolder(364, 1));// Mental Shield
SKILLS.add(new SkillHolder(349, 1));// Magic Barrier
SKILLS.add(new SkillHolder(305, 1));// Empower
SKILLS.add(new SkillHolder(1355, 1));// Focus
SKILLS.add(new SkillHolder(1356, 1));// Concentration
SKILLS.add(new SkillHolder(1357, 1));// Concentration
SKILLS.add(new SkillHolder(1413, 1));// Haste
SKILLS.add(new SkillHolder(1363, 1));// Agility
SKILLS.add(new SkillHolder(1388, 3));// Wind Walk
SKILLS.add(new SkillHolder(1389, 3));// Guidance
SKILLS.add(new SkillHolder(1416, 1));// Death Whisper
SKILLS.add(new SkillHolder(4699, 13));// Shield
SKILLS.add(new SkillHolder(4700, 13));// Blessed Body
SKILLS.add(new SkillHolder(4703, 13));// Blessed Soul
}
public Q00689_SkillSeller()
{
super(689);
addStartNpc(NPC);
addFirstTalkId(NPC);
addTalkId(NPC);
}
@override
public String onFirstTalk(Npc npc, Player activeChar)
{
return GenerateHtmlIndex(activeChar);
}
@override
public String onEvent(String event, Npc npc, Player player)
{
if (event.equals("verSkills"))
{
return GenerateHtmlRegalos(player);
}
if (event.startsWith("regalarSkills"))
{
QuestState qs = player.getQuestState(getName());
// Verifique a capacidade das habilidades que o personagem aprendeu
System.out.println("a" + qs.getInt("skills"));
if (qs.getInt("skills") >= MAX_SKILLS_ADD)
{
return "maxSkills.htm";
}
StringTokenizer st = new StringTokenizer(event, " ");
st.nextToken(); // regalarSkills
try
{
if (getQuestItemsCount(player, ITEMD_ID) >= ITEM_COUNT)
{
takeItems(player, ITEMD_ID, ITEM_COUNT);
player.broadcastPacket(new SocialAction(player.getObjectId(), 3));
qs.set("skills", qs.get("skills") + 1); // incrementamos la cant de skills q ah aprendido el char
System.out.println("b" + qs.get("skills"));
player.sendSkillList();
player.addSkill(SKILLS.get(Integer.parseInt(st.nextToken())).getSkill(), true);
player.broadcastUserInfo();
}
else
{
return "noitem.htm";
}
}
catch (Exception e)
{
LOGGER.warning("WTF...tenemos un player q intenta aprender un skill fuera de la lista?");
LOGGER.warning("contactar con fissban por asesoria :P");
}
}
return null;
}
/**
* Generamos el html inicial
* @param player
* @return
*/
private static String GenerateHtmlIndex(Player player)
{
return "verskill.htm";
}
/**
* Generamos los html para cada lista de Skills a regalar
* @param player
* @return
*/
private static String GenerateHtmlRegalos(Player player)
{
StringBuilder sb = new StringBuilder();
sb.append("<html><body><title>Lineage II Freedom - Private Server</title>");
sb.append("<center>");
sb.append("<br>");
sb.append("Bem Vindos <font color=\"LEVEL\">" + player.getName() + "</font>");
sb.append("<br>");
int cont = 0;
for (SkillHolder skill : SKILLS)
{
if (skill.getSkill() == null)
{
LOGGER.warning("skill null -->> " + cont);
LOGGER.warning("contactar por este nullPoint");
cont++;
continue;
}
sb.append("<table bgcolor=\"ae9987\" width=260 height=36>");
sb.append("<tr>");
sb.append("<td width=32 height=32><img src=\"Icon.skill" + getSkillIcon(skill.getSkillId()) + "\" width=32 height=32></td>");
sb.append("<td align=center width=196 height=32><button value=\"" + skill.getSkill().getName() + "\" action=\"bypass -h Quest Q689_SkillSeller regalarSkills " + cont + "\" width=120 height=30 back=L2UI_CH3.bigbutton2_down fore=L2UI_CH3.bigbutton2></td>");
sb.append("<td width=32 height=32><img src=\"Icon.skill" + getSkillIcon(skill.getSkillId()) + "\" width=32 height=32></td>");
sb.append("</tr>");
sb.append("</table>");
cont++;
}
sb.append("</center>");
sb.append("</body></html>");
return sb.toString();
}
/**
* Generamos el ID de la imagen de un skill a partir de su ID
* @param id
* @return
*/
private static String getSkillIcon(int id)
{
String formato;
if (id == 4)
{
formato = "0004";
}
else if ((id > 9) && (id < 100))
{
formato = "00" + id;
}
else if ((id > 99) && (id < 1000))
{
formato = "0" + id;
}
else if (id == 1517)
{
formato = "1536";
}
else if (id == 1518)
{
formato = "1537";
}
else if (id == 1547)
{
formato = "0065";
}
else if (id == 2076)
{
formato = "0195";
}
else if ((id > 4550) && (id < 4555))
{
formato = "5739";
}
else if ((id > 4698) && (id < 4701))
{
formato = "1331";
}
else if ((id > 4701) && (id < 4704))
{
formato = "1332";
}
else if (id == 6049)
{
formato = "0094";
}
else
{
formato = String.valueOf(id);
}
return formato;
}
public static void main(String[] args)
{
new Q00689_SkillSeller();
}
}