Перейти к содержанию
Авторизация  
BBMAXI

[manual] Skillseller

Рекомендуемые сообщения

Что может этот НПС? и что это вообще?

1. Продает скилы, все скилы указываются в нужной БД.

2. После рестарта проданные скилы не изчезают.

3. Может продавать вещи (мультиселл)

 

 

Index: java/net/sf/l2j/gameserver/model/L2TraderSkillLearn.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2TraderSkillLearn.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/L2TraderSkillLearn.java (revision 0)

+/*
+* 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 net.sf.l2j.gameserver.model;
+
+/**
+ * This class ...
+ *
+ * @version $Revision: 1.2.4.2 $ $Date: 2005/03/27 15:29:33 $
+ */
+public final class L2TraderSkillLearn
+{
+ // these two build the primary key
+ private final int _id;
+ private final int _level;
+
+ // not needed, just for easier debug
+ private final String _name;
+
+ private final int _spCost;
+ private final int _minLevel;
+ private final int _costid;
+ private final int _costcount;
+
+ public L2TraderSkillLearn(int id, int lvl, int minLvl, String name, int cost, int costid, int costcount)
+ {
+ _id = id;
+ _level = lvl;
+ _minLevel = minLvl;
+ _name = name.intern();
+ _spCost = cost;
+ _costid = costid;
+ _costcount = costcount;
+ }
+
+ /**
+ * @return Returns the id.
+ */
+ public int getId()
+ {
+ return _id;
+ }
+
+ /**
+ * @return Returns the level.
+ */
+ public int getLevel()
+ {
+ return _level;
+ }
+
+ /**
+ * @return Returns the minLevel.
+ */
+ public int getMinLevel()
+ {
+ return _minLevel;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName()
+ {
+ return _name;
+ }
+
+ /**
+ * @return Returns the spCost.
+ */
+ public int getSpCost()
+ {
+ return _spCost;
+ }
+ public int getIdCost()
+ {
+ return _costid;
+ }
+ public int getCostCount()
+ {
+ return _costcount;
+ }
+}
No newline at end of file

Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TraderManagerInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2TraderManagerInstance.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2TraderManagerInstance.java (revision 0)

+/*
+ * 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 net.sf.l2j.gameserver.model.actor.instance;
+
+import java.util.StringTokenizer;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.TradeController;
+import net.sf.l2j.gameserver.datatables.SkillTable;
+import net.sf.l2j.gameserver.datatables.SkillTreeTable;
+import net.sf.l2j.gameserver.model.L2Skill;
+import net.sf.l2j.gameserver.model.L2TraderSkillLearn;
+import net.sf.l2j.gameserver.model.L2Multisell;
+import net.sf.l2j.gameserver.model.L2TradeList;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.serverpackets.AcquireSkillList;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
+import net.sf.l2j.gameserver.network.serverpackets.BuyList;
+import net.sf.l2j.gameserver.network.serverpackets.SellList;
+import net.sf.l2j.gameserver.network.serverpackets.SetupGauge;
+import net.sf.l2j.gameserver.network.serverpackets.ShopPreviewList;
+import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
+import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.gameserver.util.StringUtil;
+
+public class L2TraderManagerInstance extends L2NpcInstance
+{
+
+ /**
+ * @param objectId
+ * @param template
+ */
+ public L2TraderManagerInstance(int objectId, L2NpcTemplate template)
+ {
+ super(objectId, template);
+ }
+
+ @Override
+ public String getHtmlPath(int npcId, int val)
+ {
+ String pom = "";
+
+ if (val == 0)
+ pom = "" + npcId;
+ else
+ pom = npcId + "-" + val;
+
+ return "data/html/skill_trader/" + pom + ".htm";
+ }
+
+
+ protected final void showSellWindow(L2PcInstance player)
+ {
+ if (Config.DEBUG) _log.fine("Showing selllist");
+
+
+ player.sendPacket(new SellList(player));
+
+ if (Config.DEBUG) _log.fine("Showing sell window");
+
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ }
+
+ @Override
+ public void onBypassFeedback(L2PcInstance player, String command)
+ {
+ StringTokenizer st = new StringTokenizer(command, " ");
+ String actualCommand = st.nextToken(); // Get actual command
+
+
+ if (command.startsWith("TraderSkillList"))
+ {
+ player.setSkillLearningClassId(player.getClassId());
+ showTraderSkillList(player);
+ }
+ else if (actualCommand.equalsIgnoreCase("Sell"))
+ {
+ showSellWindow(player);
+ }
+ else if (actualCommand.equalsIgnoreCase("Multisell"))
+ {
+ if (st.countTokens() < 1) return;
+
+ int val = Integer.parseInt(st.nextToken());
+ L2Multisell.getInstance().separateAndSend(val, player, false, getCastle().getTaxRate());
+ }
+ else if (actualCommand.equalsIgnoreCase("Exc_Multisell"))
+ {
+ if (st.countTokens() < 1) return;
+
+ int val = Integer.parseInt(st.nextToken());
+ L2Multisell.getInstance().separateAndSend(val, player, true, getCastle().getTaxRate());
+ }
+ else
+ {
+ super.onBypassFeedback(player, command);
+ }
+ }
+
+ /**
+ * this displays TraderSkillList to the player.
+ * @param player
+ */
+ public void showTraderSkillList(L2PcInstance player)
+ {
+ L2TraderSkillLearn[] skills = SkillTreeTable.getInstance().getAvailableTraderSkills(player);
+ AcquireSkillList asl = new AcquireSkillList(AcquireSkillList.SkillType.Usual);
+ int counts = 0;
+
+ for (L2TraderSkillLearn s: skills)
+ {
+ L2Skill sk = SkillTable.getInstance().getInfo(s.getId(), s.getLevel());
+ if (sk == null)
+ continue;
+
+ counts++;
+
+ asl.addSkill(s.getId(), s.getLevel(), s.getLevel(), s.getSpCost(), 1);
+ }
+
+ if (counts == 0)
+ {
+ NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
+ int minlevel = SkillTreeTable.getInstance().getMinLevelForNewTraderSkill(player);
+
+ if (minlevel > 0)
+ {
+ // No more skills to learn, come back when you level.
+
+ SystemMessage sm = new SystemMessage(SystemMessageId.DO_NOT_HAVE_FURTHER_SKILLS_TO_LEARN);
+ sm.addNumber(minlevel);
+ player.sendPacket(sm);
+ }
+ else
+ {
+ html.setHtml(
+ "<html><head><body>" +
+ "You've learned all skills.<br>" +
+ "</body></html>"
+ );
+ player.sendPacket(html);
+
+ }
+ }
+ else
+ {
+ player.sendPacket(asl);
+ }
+
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ }
+}
No newline at end of file

Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestAquireSkill.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestAquireSkill.java (revision 0)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestAquireSkill.java (revision 0)

@@ 27
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.L2SkillLearn;
import net.sf.l2j.gameserver.model.L2TransformSkillLearn;
+import net.sf.l2j.gameserver.model.L2TraderSkillLearn;
import net.sf.l2j.gameserver.model.actor.L2Npc;

@@ 35
import net.sf.l2j.gameserver.model.actor.instance.L2TransformManagerInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2TraderManagerInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2VillageMasterInstance;

@@ 152
player.sendPacket(sm);
sm = null;
return;
}
break;
}
+
+ if (trainer instanceof L2TraderManagerInstance) // Trader skills
+ {
+ int costid = 0;
+ int costcount = 0;
+ // Skill Learn bug Fix
+ L2TraderSkillLearn[] skillsc = SkillTreeTable.getInstance().getAvailableTraderSkills(player);
+
+ for (L2TraderSkillLearn s : skillsc)
+ {
+ L2Skill sk = SkillTable.getInstance().getInfo(s.getId(),s.getLevel());
+
+ if (sk == null || sk != skill)
+ continue;
+
+ counts++;
+ costid = s.getIdCost();
+ costcount = s.getCostCount();
+ _requiredSp = s.getSpCost();
+ }
+
+ if (counts == 0)
+ {
+ player.sendMessage("You are trying to learn skill that u can't..");
+ Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to learn skill that he can't!!!", IllegalPlayerAction.PUNISH_KICK);
+ return;
+ }
+
+ if (player.getSp() >= _requiredSp)
+ {
+ if (!player.destroyItemByItemId("Consume", costid, costcount, trainer, false))
+ {
+ // Haven't spellbook
+ player.sendPacket(new SystemMessage(SystemMessageId.ITEM_MISSING_TO_LEARN_SKILL));
+ return;
+ }
+
+ SystemMessage sm = new SystemMessage(SystemMessageId.S2_S1_DISAPPEARED);
+ sm.addItemName(costid);
+ sm.addItemNumber(costcount);
+ sendPacket(sm);
+ sm = null;
+ }
+ else
+ {
+ SystemMessage sm = new SystemMessage(SystemMessageId.NOT_ENOUGH_SP_TO_LEARN_SKILL);
+ player.sendPacket(sm);
+ sm = null;
+ return;
+ }
+ break;
+ }
+
// normal skills
L2SkillLearn[] skills = SkillTreeTable.getInstance().getAvailableSkills(player, player.getSkillLearningClassId());

Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestAquireSkillInfo.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestAquireSkillInfo.java (revision 0)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestAquireSkillInfo.java (revision 0)

@@ 26
import net.sf.l2j.gameserver.model.L2TransformSkillLearn;
+import net.sf.l2j.gameserver.model.L2TraderSkillLearn;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;

@@ 31
import net.sf.l2j.gameserver.model.actor.instance.L2TransformManagerInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2TraderManagerInstance;
import net.sf.l2j.gameserver.network.serverpackets.AcquireSkillInfo;

@@ 82
}

if (_skillType == 0)
{
+
+ if (trainer instanceof L2TraderManagerInstance)
+ {
+
+ int costid = 0;
+ int costcount = 0;
+ int spCost = 0;
+ L2TraderSkillLearn[] skillst = SkillTreeTable.getInstance().getAvailableTraderSkills(activeChar);
+
+ for (L2TraderSkillLearn s : skillst)
+ {
+ if (s.getId() == _id && s.getLevel() == _level)
+ {
+ canteach = true;
+ costid = s.getIdCost();
+ costcount = s.getCostCount();
+ spCost = s.getSpCost();
+ break;
+ }
+ }
+
+ if (!canteach)
+ return; // cheater
+
+ int requiredSp = 10;
+ AcquireSkillInfo asi = new AcquireSkillInfo(skill.getId(), skill.getLevel(), spCost,0);
+ asi.addRequirement(4, costid, costcount, 0);
+
+ sendPacket(asi);
+ return;
+ }
+
if (trainer instanceof L2TransformManagerInstance)
{
int itemId = 0;
L2TransformSkillLearn[] skillst = SkillTreeTable.getInstance().getAvailableTransformSkills(activeChar);

for (L2TransformSkillLearn s : skillst)
{
if (s.getId() == _id && s.getLevel() == _level)

Index: java/net/sf/l2j/gameserver/datatables/SkillTreeTable.java
===================================================================
--- java/net/sf/l2j/gameserver/datatables/SkillTreeTable.java (revision 0)
+++ java/net/sf/l2j/gameserver/datatables/SkillTreeTable.java (revision 0)

@@ 32
import net.sf.l2j.gameserver.model.L2SkillLearn;
import net.sf.l2j.gameserver.model.L2TransformSkillLearn;
+import net.sf.l2j.gameserver.model.L2TraderSkillLearn;
import net.sf.l2j.gameserver.model.L2EnchantSkillLearn.EnchantSkillDetail;

@@ 62
private List<L2TransformSkillLearn> _TransformSkillTrees; // Transform Skills (Test)
+private List<L2TraderSkillLearn> _TraderSkillTrees; // Transform Skills (Test)
private FastList<L2SkillLearn> _specialSkillTrees;

@@ 143
int count6 = 0;
int count7 = 0;
+ int count8 = 0;
Connection con = null;

@@ 406
}
catch (Exception e)
{
_log.severe("Error while creating special skill table: " + e);
}
}
catch (Exception e)
{
_log.log(Level.SEVERE, "Error while skill tables ", e);
}
+ //Skill tree for Trader skill
+ try
+ {
+ _TraderSkillTrees = new FastList<L2TraderSkillLearn>();
+
+ PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost FROM trader_skill_trees ORDER BY skill_id, level");
+ ResultSet skilltree7 = statement.executeQuery();
+
+ int prevSkillId = -1;
+
+
+ while (skilltree7.next())
+ {
+ int id = skilltree7.getInt("skill_id");
+ int lvl = skilltree7.getInt("level");
+ String name = skilltree7.getString("name");
+ int minLvl = skilltree7.getInt("min_level");
+ int cost = skilltree7.getInt("sp");
+ int costId = skilltree7.getInt("costid");
+ int costCount = skilltree7.getInt("cost");
+
+ if (prevSkillId != id)
+ prevSkillId = id;
+
+ L2TraderSkillLearn skill = new L2TraderSkillLearn(id, lvl, minLvl, name, cost, costId, costCount);
+
+
+ _TraderSkillTrees.add(skill);
+ }
+
+ skilltree7.close();
+ statement.close();
+
+ count8 = _TraderSkillTrees.size();
+ }
+ catch (Exception e)
+ {
+ _log.severe("Error while creating tarder skill table: " + e);
+ }
finally
{
try
{
con.close();
}
catch (Exception e)
{
}

@@ 724
}

return result.toArray(new L2PledgeSkillLearn[result.size()]);
}

+ public L2TraderSkillLearn[] getAvailableTraderSkills(L2PcInstance cha)
+ {
+ List<L2TraderSkillLearn> result = new FastList<L2TraderSkillLearn>();
+ List<L2TraderSkillLearn> skills = new FastList<L2TraderSkillLearn>();
+
+ skills.addAll(_TraderSkillTrees);
+
+ if (skills == null)
+ {
+ // the skilltree for this class is undefined, so we give an empty list
+ _log.warning("Skilltree for fishing is not defined !");
+ return new L2TraderSkillLearn[0];
+ }
+
+ L2Skill[] oldSkills = cha.getAllSkills();
+
+ for (L2TraderSkillLearn temp : skills)
+ {
+ if (temp.getMinLevel() <= cha.getLevel())
+ {
+ boolean knownSkill = false;
+
+ for (int j = 0; j < oldSkills.length && !knownSkill; j++)
+ {
+ if (oldSkills[j].getId() == temp.getId())
+ {
+ knownSkill = true;
+
+ if (oldSkills[j].getLevel() == temp.getLevel() - 1)
+ {
+ // this is the next level of a skill that we know
+ result.add(temp);
+ }
+ }
+ }
+
+ if (!knownSkill && temp.getLevel() == 1)
+ {
+ // this is a new skill
+ result.add(temp);
+ }
+ }
+ }
+
+ return result.toArray(new L2TraderSkillLearn[result.size()]);
+ }
+
/**
* Returns all allowed skills for a given class.
* @param classId

@@ 856
}

return minLevel;
}

+ public int getMinLevelForNewTraderSkill(L2PcInstance cha)
+ {
+ int minLevel = 0;
+ List<L2TraderSkillLearn> skills = new FastList<L2TraderSkillLearn>();
+
+ skills.addAll(_TraderSkillTrees);
+
+ if (skills == null)
+ {
+ // the skilltree for this class is undefined, so we give an empty list
+ _log.warning("SkillTree for Trader Skills is not defined !");
+ return minLevel;
+ }
+
+ for (L2TraderSkillLearn s : skills)
+ {
+ if (s.getMinLevel() > cha.getLevel())
+ if (minLevel == 0 || s.getMinLevel() < minLevel)
+ minLevel = s.getMinLevel();
+ }
+
+ return minLevel;
+ }
+
public int getSkillCost(L2PcInstance player, L2Skill skill)
{

 

Авторство этой статьи принадлежит sterser.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...