Autor Tema: .Sellbuff (Problema) Rev: 1053 L2jAdmins  (Leído 121 veces)

FanaticoLineage2

  • Newbie
  • *
  • Mensajes: 32
  • Karma: +0/-0
    • Ver Perfil
.Sellbuff (Problema) Rev: 1053 L2jAdmins
« en: Mayo 08, 2018, 01:10:11 am »
Reporte: No  importa si le asignas el costo a tus buff de 10kk o 100 de adena el mensaje que les aparece a los usuarios que van a comprar buff es siempre 0 de adena

My buff cost: 0 de adena each!

también, seria bueno poder seleccionar que buff queres vender, así como también que cada buff tenga un costo diferente! :D

PD1: Si un personaje es blade dancer puede vender danzas sin necesidad de duales.
PD2: Cuando alguien va a comprar buff, este personaje se para, pero seria bueno que se vuelva a sentar así se facilita la recarga de MP
PD3: El modo offline sellbuff, de la sección (OfflinTradeCraft) exactamente esta (OfflineSellBuffEnable) no esta funcionando.

Gracias!
« Última modificación: Mayo 08, 2018, 01:33:09 am por FanaticoLineage2 »

fissban

  • Administrador
  • Full Member
  • *
  • Mensajes: 152
  • Karma: +0/-0
    • Ver Perfil
Re:.Sellbuff (Problema) Rev: 1053 L2jAdmins
« Respuesta #1 en: Mayo 10, 2018, 04:49:30 am »
aun no termino pero si quieres puedes darle una mirada de como va quedando

Código
Index: src/main/engine/mods/OfflineShop.java
===================================================================
--- src/main/engine/mods/OfflineShop.java (revision 1051)
+++ src/main/engine/mods/OfflineShop.java (working copy)
@@ -79,7 +79,7 @@
  else if (ObjectData.get(PlayerHolder.class, player).isSellBuff() && ConfigData.OFFLINE_SELLBUFF_ENABLE)
  {
  title = "SellBuff"; // TODO You could add to save this data as something custom.
- storeItems += ObjectData.get(PlayerHolder.class, player).getSellBuffPrice();
+ // storeItems += ObjectData.get(PlayerHolder.class, player).getSellBuffPrice();
  storeType = "SELL_BUFF";
  saveValue = true;
  }
@@ -87,7 +87,7 @@
  if (saveValue)
  {
  // saved state and items in memory
- setValueDB(player.getObjectId(), "offlineShop", storeType + "#" + ((title == null) || (title.length() == 0) ? "null" : title.replaceAll("#", " ")) + "#" + storeItems);
+ setValueDB(player.getObjectId(), "offlineShop", storeType + "#" + (title == null || title.length() == 0 ? "null" : title.replaceAll("#", " ")) + "#" + storeItems);
  }
  }
  catch (Exception e)
@@ -142,7 +142,7 @@
  }
 
  // Handle removal from olympiad game
- if (OlympiadManager.getInstance().isRegistered(player) || (player.getOlympiadGameId() != -1))
+ if (OlympiadManager.getInstance().isRegistered(player) || player.getOlympiadGameId() != -1)
  {
  OlympiadManager.getInstance().removeDisconnectedCompetitor(player);
  }
Index: src/main/engine/mods/SellBuffs.java
===================================================================
--- src/main/engine/mods/SellBuffs.java (revision 1051)
+++ src/main/engine/mods/SellBuffs.java (working copy)
@@ -33,7 +33,6 @@
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.enums.TeamType;
 import net.sf.l2j.gameserver.model.skills.Skill;
-import net.sf.l2j.gameserver.model.skills.enums.SkillTargetType;
 import net.sf.l2j.gameserver.model.skills.enums.SkillType;
 import net.sf.l2j.gameserver.model.world.L2World;
 import net.sf.l2j.gameserver.model.zone.enums.ZoneType;
@@ -44,7 +43,7 @@
  */
 public class SellBuffs extends AbstractMod
 {
- private static final int MAX_SKILL_PER_PAGE = 12;
+ private static final int MAX_SKILL_PER_PAGE = 11;
 
  public SellBuffs()
  {
@@ -67,7 +66,7 @@
  return true;
  }
 
- ph.setSellBuff(false, 0);
+ ph.setSellBuff(false);
 
  ph.getInstance().standUp();
  ph.getInstance().setIsImmobilized(false);
@@ -88,17 +87,17 @@
  hb.append("<html><body><center>");
  hb.append(Html.head("SELL BUFF"));
  hb.append("<font color=LEVEL>Welcome </font><font color=00C3FF>", ph.getName(), "</font> system selling buffs.<br1>");
- hb.append("You can only sell buffs if your class<br1>");
+ hb.append("<br1>");
  hb.append("is the type of support.<br1>");
- hb.append("All your buffs will be sold at a single price.<br1>");
- hb.append("To cancel this state should use<br1>");
- hb.append("the command. <font color=LEVEL>CancelSellBuffs</font>");
+ hb.append("You can sell your buffs at the price you want,");
+ hb.append("those to which you do not define a price will not be sold.");
+ hb.append("<br1>");
+ hb.append("To cancel this state should use the command<br1>");
+ hb.append("<font color=LEVEL>CancelSellBuffs</font>");
  hb.append("<br><br>");
- hb.append("<font color=00C3FF>Choose the price of your services</font>");
- hb.append("<br>");
- hb.append("<edit var=price width=200 height=15>");
+ hb.append("<font color=00C3FF>Do you want to continue?</font>");
  hb.append("<br>");
- hb.append("<button value=Next action=\"bypass -h Engine SellBuffs sell $price\" width=80 height=25 back=L2UI_CH3.Btn1_normalOn fore=L2UI_CH3.btn1_normal>");
+ hb.append("<button value=START action=\"bypass -h Engine SellBuffs start\" width=80 height=25 back=L2UI_CH3.Btn1_normalOn fore=L2UI_CH3.btn1_normal>");
  hb.append("</center></body></html>");
  sendHtml(null, hb, ph);
  return true;
@@ -131,19 +130,9 @@
  getBuffList(ph, ph.getTarget(), page);
  break;
  }
- case "sell": // sit to sell buffs
+ case "finish": // sit to sell buffs
  {
- int price = 0;
- try
- {
- price = Integer.parseInt(st.nextToken());
- }
- catch (Exception e)
- {
- //
- }
-
- ph.setSellBuff(true, price);
+ ph.setSellBuff(true);
 
  ph.getInstance().sitDown();
  ph.getInstance().setIsImmobilized(true);
@@ -172,13 +161,19 @@
  return;
  }
 
- // Check if target get skill
- if (sellerBuff.getSkillLevel(id) != lvl)
+ // prevent bypass exploit
+ if (sellerBuff.getSkillLevel(id) == -1 && sellerBuff.getSkillLevel(id) != lvl)
  {
  return;
  }
 
- int price = phSeller.getSellBuffPrice();
+ int price = phSeller.getSellBuffPrice(id);
+
+ // prevent bypass exploit
+ if (price == -1)
+ {
+ return;
+ }
 
  if (!ph.getInstance().getInventory().reduceAdena("sell buff", price, sellerBuff, true))
  {
@@ -205,9 +200,100 @@
  getBuffList(ph, phSeller, page);
  break;
  }
+ case "start":
+ {
+ int page = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 1;
+
+ startHtml(ph, page);
+ break;
+ }
+ case "set":
+ {
+ try
+ {
+ int skillId = Integer.parseInt(st.nextToken());
+ int price = Integer.parseInt(st.nextToken());
+
+ ph.setSellBuffPrice(skillId, price);
+ }
+ catch (Exception e)
+ {
+ UtilMessage.sendCreatureMsg(ph, SayType.TELL, "sellbuff", "Wrong price!!!!!");
+ }
+ startHtml(ph, 1);
+ break;
+ }
  }
  }
 
+ private void startHtml(PlayerHolder ph, int page)
+ {
+ HtmlBuilder hb = new HtmlBuilder();
+ hb.append(Html.START);
+ hb.append(Html.head("SELL BUFF"));
+ hb.append("<br>");
+ hb.append("<center>");
+ hb.append("<table border=0 cellspacing=0 cellpadding=0>");
+
+ int searchPage = MAX_SKILL_PER_PAGE * (page - 1);
+ int skillCount = 0;
+
+ int count = 0;
+ for (Skill sk : ((L2Character) ph.getInstance()).getSkills().values())
+ {
+ if (!checkSkil(sk))
+ {
+ continue;
+ }
+
+ count++;
+
+ // min
+ if (skillCount < searchPage)
+ {
+ skillCount++;
+ continue;
+ }
+ // max
+ if (skillCount >= searchPage + MAX_SKILL_PER_PAGE)
+ {
+ continue;
+ }
+ int price = ph.getSellBuffPrice(sk.getId());
+
+ hb.append("<tr>");
+ hb.append("<td width=64 align=center><font color=LEVEL>price: ", Html.formatAdena(price), "</font></td>");
+ hb.append("<td width=32 align=center><img src=\"", SkillInfoData.getSkillIcon(sk.getId()), "\" width=32 height=25></td>");
+ hb.append("<td width=50 align=center><edit var=price" + sk.getId() + " width=50 height=25></td>");
+ hb.append("<td width=80 align=center><button value=Set action=\"bypass -h Engine SellBuffs set " + sk.getId() + " $price" + sk.getId() + "\" width=80 height=25 back=L2UI_CH3.Btn1_normalOn fore=L2UI_CH3.btn1_normal></td>");
+ hb.append("</tr>");
+ }
+ hb.append("</table>");
+ hb.append("<br><button value=Set action=\"bypass -h Engine SellBuffs finish\" width=80 height=25 back=L2UI_CH3.Btn1_normalOn fore=L2UI_CH3.btn1_normal>");
+
+ hb.append("<img src=L2UI.SquareGray width=264 height=1>");
+ hb.append("<table bgcolor=000000>");
+ hb.append("<tr>");
+
+ int currentPage = 1;
+
+ for (int i = 0; i < count; i++)
+ {
+ if (i % MAX_SKILL_PER_PAGE == 0)
+ {
+ hb.append("<td width=18 align=center><a action=\"bypass -h Engine SellBuffs start " + currentPage + "\">" + currentPage + "</a></td>");
+ currentPage++;
+ }
+ }
+
+ hb.append("</tr>");
+ hb.append("</table>");
+ hb.append("<img src=L2UI.SquareGray width=264 height=1>");
+ hb.append("</center>");
+ hb.append(Html.END);
+ sendHtml(null, hb, ph);
+ }
+
  @Override
  public boolean onInteract(PlayerHolder ph, CharacterHolder sellerBuff)
  {
@@ -235,7 +321,7 @@
  hb.append("<center>");
  hb.append("<br><br>");
  hb.append("Hello <font color=00C3FF>", ph.getName(), "</font>");
- hb.append("<br><center>My Buff Cost: <font color=\"LEVEL\">", ph.getSellBuffPrice(), "</font> adena each!</center>");
+ hb.append("<br>");
  hb.append("<br>");
  hb.append("<center><button value=\"View my Buffs\" action=\"bypass -h Engine SellBuffs view\" width=80 height=25 back=L2UI_CH3.Btn1_normalOn fore=L2UI_CH3.btn1_normal>");
  hb.append("</center>");
@@ -260,7 +346,7 @@
  hb.append("<br><br>");
  hb.append("<center>");
  hb.append("<font color=LEVEL>Hello </font><font color=00C3FF>", ph.getName(), "</font><font color=LEVEL> want my Buff!</font>");
- hb.append("<br>My Buff Cost: <font color=00C3FF>", ph.getSellBuffPrice(), "</font><font color=LEVEL> adena each!</font><br>");
+ hb.append("<br>");
 
  int searchPage = MAX_SKILL_PER_PAGE * (page - 1);
  int skillCount = 0;
@@ -268,7 +354,7 @@
  int count = 0;
  for (Skill sk : ((L2Character) sellerBuff.getInstance()).getSkills().values())
  {
- if (sk.isPassive() || sk.getTargetType() == SkillTargetType.TARGET_SELF || sk.isOffensive() || sk.getSkillType() != SkillType.BUFF)
+ if (!checkSkil(sk))
  {
  continue;
  }
@@ -287,10 +373,17 @@
  continue;
  }
 
+ int price = ((PlayerHolder) sellerBuff).getSellBuffPrice(sk.getId());
+
+ if (price == -1)
+ {
+ continue;
+ }
+
  hb.append("<table>");
  hb.append("<tr>");
  hb.append("<td width=32 align=center><img src=\"", SkillInfoData.getSkillIcon(sk.getId()), "\" width=32 height=16></td>");
- hb.append("<td width=180 align=center><a action=\"bypass -h Engine SellBuffs buy ", sk.getId(), " ", sk.getLevel(), " ", ((PlayerHolder) sellerBuff).getName(), " ", page, "\">", sk.getName(), "</td>");
+ hb.append("<td width=180 align=center><a action=\"bypass -h Engine SellBuffs buy ", sk.getId(), " ", sk.getLevel(), " ", ((PlayerHolder) sellerBuff).getName(), " ", page, "\">", sk.getName(), " (", price, ")</td>");
  hb.append("<td width=32 align=center><img src=\"", SkillInfoData.getSkillIcon(sk.getId()), "\" width=32 height=16></td>");
  hb.append("</tr>");
  hb.append("</table>");
@@ -322,4 +415,24 @@
 
  sendHtml(null, hb, ph);
  }
+
+ private boolean checkSkil(Skill sk)
+ {
+ if (sk.isPassive() || sk.isOffensive() || sk.getSkillType() != SkillType.BUFF)
+ {
+ return false;
+ }
+
+ switch (sk.getTargetType())
+ {
+ case TARGET_SELF:
+ case TARGET_PET:
+ case TARGET_CORPSE:
+ case TARGET_CORPSE_PLAYER:
+ case TARGET_CORPSE_PET:
+ return false;
+ }
+
+ return true;
+ }
 }
Index: src/main/holders/objects/PlayerHolder.java
===================================================================
--- src/main/holders/objects/PlayerHolder.java (revision 1051)
+++ src/main/holders/objects/PlayerHolder.java (working copy)
@@ -132,7 +132,8 @@
  // XXX sell buff ------------------------------------------------------------------------------------------------------
 
  private boolean isSellBuff = false;
- private int sellBuffPrice;
+
+ private Map<Integer, Integer> sellBuffs = new HashMap<>();
 
  /**
  * If a character is in sellBuff mode or not
@@ -143,24 +144,28 @@
  return isSellBuff;
  }
 
+ public Integer getSellBuffPrice(int skillId)
+ {
+ if (sellBuffs.containsKey(skillId))
+ {
+ return sellBuffs.get(skillId);
+ }
+ return -1;
+ }
+
+ public void setSellBuffPrice(int skillId, int price)
+ {
+ sellBuffs.put(skillId, price);
+ }
+
  /**
  * The status of a character is defined if it is in sellBuff mode or not.
  * @param isSellBuff
  * @param sellBuffPrice
  */
- public void setSellBuff(boolean isSellBuff, int sellBuffPrice)
+ public void setSellBuff(boolean isSellBuff)
  {
  this.isSellBuff = isSellBuff;
- this.sellBuffPrice = sellBuffPrice;
- }
-
- /**
- * Sale price of sellBuffs.
- * @return
- */
- public int getSellBuffPrice()
- {
- return sellBuffPrice;
  }
 
  // XXX AIO -----------------------------------------------------------------------------------------------------------