Adapted sellbuffs command for HighFive.

This commit is contained in:
MobiusDev
2018-04-07 00:42:28 +00:00
parent a9c55029f1
commit 49770b1c19
20 changed files with 1337 additions and 44 deletions

View File

@@ -0,0 +1,22 @@
# ---------------------------------------------------------------------------
# Sell Buffs configuration
# ---------------------------------------------------------------------------
# Command: .sellbuff or .sellbuffs
# Enable/Disable selling buffs
SellBuffEnable = False
# Multipler for mana cost of buffs
MpCostMultipler = 1
# Payment for Sell Buff System, can be changed to custom server coin
PaymentID = 57
# Minimal price of every buff
MinimalPrice = 100000
# Maximal price of every buff
MaximalPrice = 100000000
# Maximum count of buffs in sell list
MaxBuffs = 20

View File

@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/SellBuffData.xsd">
<skill id="1232"/> <!-- Blazing Skin -->
<skill id="1003"/> <!-- Pa'agrian Gift -->
<skill id="1005"/> <!-- Blessings of Pa'agrio -->
<skill id="1250"/> <!-- Shield of Pa'agrio -->
<skill id="1008"/> <!-- The Glory of Pa'agrio -->
<skill id="1260"/> <!-- The Tact of Pa'agrio -->
<skill id="1004"/> <!-- The Wisdom of Pa'agrio -->
<skill id="1261"/> <!-- Rage of Pa'agrio -->
<skill id="1249"/> <!-- The Vision of Pa'agrio -->
<skill id="1563"/> <!-- Fury of Pa'agrio -->
<skill id="1282"/> <!-- Pa'agrian Haste -->
<skill id="1536"/> <!-- Combat of Pa'agrio -->
<skill id="1538"/> <!-- Condition of Pa'agrio -->
<skill id="1537"/> <!-- Critical of Pa'agrio -->
<skill id="1364"/> <!-- Eye of Pa'agrio -->
<skill id="1365"/> <!-- Soul of Pa'agrio -->
<skill id="1415"/> <!-- Pa'agrio's Emblem -->
<skill id="1416"/> <!-- Pa'agrio's Fist -->
<skill id="1414"/> <!-- Victory of Pa'agrio -->
<skill id="1006"/> <!-- Chant of Fire -->
<skill id="1009"/> <!-- Chant of Shielding -->
<skill id="1007"/> <!-- Chant of Battle -->
<skill id="1002"/> <!-- Flame Chant -->
<skill id="1252"/> <!-- Chant of Evasion -->
<skill id="1308"/> <!-- Chant of Predator -->
<skill id="1253"/> <!-- Chant of Rage -->
<skill id="1562"/> <!-- Chant of Berserker -->
<skill id="1309"/> <!-- Chant of Eagle -->
<skill id="1251"/> <!-- Chant of Fury -->
<skill id="1391"/> <!-- Earth Chant -->
<skill id="1390"/> <!-- War Chant -->
<skill id="1284"/> <!-- Chant of Revenge -->
<skill id="1535"/> <!-- Chant of Movement -->
<skill id="1310"/> <!-- Chant of Vampire -->
<skill id="1519"/> <!-- Chant of Blood Awakening -->
<skill id="1549"/> <!-- Chant of Elements -->
<skill id="1362"/> <!-- Chant of Spirit -->
<skill id="1363"/> <!-- Chant of Victory -->
<skill id="1413"/> <!-- Magnus' Chant -->
<skill id="1461"/> <!-- Chant of Protection -->
<skill id="1078"/> <!-- Concentration -->
<skill id="1068"/> <!-- Might -->
<skill id="1040"/> <!-- Shield -->
<skill id="1035"/> <!-- Mental Shield -->
<skill id="1043"/> <!-- Holy Weapon -->
<skill id="1243"/> <!-- Bless Shield -->
<skill id="1304"/> <!-- Advanced Block -->
<skill id="1259"/> <!-- Resist Shock -->
<skill id="1397"/> <!-- Clarity -->
<skill id="1504"/> <!-- Improved Movement -->
<skill id="1503"/> <!-- Improved Shield Defense -->
<skill id="1303"/> <!-- Wild Magic -->
<skill id="1393"/> <!-- Resist Dark -->
<skill id="1033"/> <!-- Resist Poison -->
<skill id="1044"/> <!-- Regeneration -->
<skill id="1257"/> <!-- Decrease Weight -->
<skill id="1087"/> <!-- Agility -->
<skill id="1204"/> <!-- Wind Walk -->
<skill id="1073"/> <!-- Kiss of Eva -->
<skill id="1354"/> <!-- Arcane Protection -->
<skill id="1353"/> <!-- Divine Protection -->
<skill id="1460"/> <!-- Mana Gain -->
<skill id="1355"/> <!-- Prophecy of Water -->
<skill id="1501"/> <!-- Improved Condition -->
<skill id="1499"/> <!-- Improved Combat -->
<skill id="1242"/> <!-- Death Whisper -->
<skill id="1045"/> <!-- Bless the Body -->
<skill id="1048"/> <!-- Bless the Soul -->
<skill id="1388"/> <!-- Greater Might -->
<skill id="1389"/> <!-- Greater Shield -->
<skill id="1392"/> <!-- Resist Holy -->
<skill id="1182"/> <!-- Resist Aqua -->
<skill id="1189"/> <!-- Resist Wind -->
<skill id="1548"/> <!-- Resist Earth -->
<skill id="1191"/> <!-- Resist Fire -->
<skill id="1036"/> <!-- Magic Barrier -->
<skill id="1077"/> <!-- Focus -->
<skill id="1086"/> <!-- Haste -->
<skill id="1062"/> <!-- Berserker Spirit -->
<skill id="1085"/> <!-- Acumen -->
<skill id="1240"/> <!-- Guidance -->
<skill id="1032"/> <!-- Invigor -->
<skill id="1352"/> <!-- Elemental Protection -->
<skill id="1542"/> <!-- Counter Critical -->
<skill id="1356"/> <!-- Prophecy of Fire -->
<skill id="828"/> <!-- Case Harden -->
<skill id="830"/> <!-- Embroider -->
<skill id="829"/> <!-- Hard Tanning -->
<skill id="827"/> <!-- Restring -->
<skill id="825"/> <!-- Sharp Edge -->
<skill id="826"/> <!-- Spike -->
<skill id="1238"/> <!-- Freezing Skin -->
<skill id="1059"/> <!-- Empower -->
<skill id="1268"/> <!-- Vampiric Rage -->
<skill id="1502"/> <!-- Improved Critical Attack -->
<skill id="1500"/> <!-- Improved Magic -->
<skill id="1357"/> <!-- Prophecy of Wind -->
<skill id="307"/> <!-- Dance of Aqua Guard -->
<skill id="309"/> <!-- Dance of Earth Guard -->
<skill id="311"/> <!-- Dance of Protection -->
<skill id="276"/> <!-- Dance of Concentration -->
<skill id="273"/> <!-- Dance of the Mystic -->
<skill id="274"/> <!-- Dance of Fire -->
<skill id="275"/> <!-- Dance of Fury -->
<skill id="272"/> <!-- Dance of Inspiration -->
<skill id="277"/> <!-- Dance of Light -->
<skill id="310"/> <!-- Dance of the Vampire -->
<skill id="271"/> <!-- Dance of the Warrior -->
<skill id="365"/> <!-- Dance of Siren -->
<skill id="530"/> <!-- Dance of Alignment -->
<skill id="915"/> <!-- Dance of Berserker -->
<skill id="264"/> <!-- Song of Earth -->
<skill id="306"/> <!-- Song of Flame Guard -->
<skill id="269"/> <!-- Song of Hunter -->
<skill id="270"/> <!-- Song of Invocation -->
<skill id="265"/> <!-- Song of Life -->
<skill id="308"/> <!-- Song of Storm Guard -->
<skill id="305"/> <!-- Song of Vengeance -->
<skill id="304"/> <!-- Song of Vitality -->
<skill id="267"/> <!-- Song of Warding -->
<skill id="266"/> <!-- Song of Water -->
<skill id="268"/> <!-- Song of Wind -->
<skill id="364"/> <!-- Song of Champion -->
<skill id="363"/> <!-- Song of Meditation -->
<skill id="349"/> <!-- Song of Renewal -->
<skill id="529"/> <!-- Song of Elemental -->
<skill id="914"/> <!-- Song of Purification -->
<skill id="764"/> <!-- Song of Wind Storm -->
</list>

View File

@@ -0,0 +1,9 @@
<html>
<body>
<center>
<br>
%list%
<br>
</center>
</body>
</html>

View File

@@ -0,0 +1,10 @@
<html>
<body>
<center>
<br>
%list%
<br>
<button action="bypass -h voice .sellbuff" value="Back" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Back_Down" fore="L2UI_CT1.OlympiadWnd_DF_Back">
</center>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<html>
<body>
<center>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td width=256 height=185 background="L2UI_CT1.OlympiadWnd_DF_GrandTexture"></td></tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=292 height=50>
<tr><td height=10></td></tr>
<tr>
<td><button action="bypass -h sellbuffadd" value="Add Buffs" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Apply_Down" fore="L2UI_CT1.OlympiadWnd_DF_Apply"></td>
<td><button action="bypass -h sellbuffedit" value="Edit Buffs" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Apply_Down" fore="L2UI_CT1.OlympiadWnd_DF_Apply"></td>
</tr>
</table>
<br><br>
<table border=0 cellpadding=0 cellspacing=0 width=292 height=50>
<tr>
<td align=center>Title:</td>
</tr>
<tr>
<td align=center><edit var="title" width=120></td>
</tr>
</table>
<button action="bypass -h sellbuffstart $title" value="Start Selling" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Watch_Down" fore="L2UI_CT1.OlympiadWnd_DF_Watch"></td>
</center>
</html>

View File

@@ -0,0 +1,14 @@
<html>
<body>
<center>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td width=256 height=185 background="L2UI_CT1.OlympiadWnd_DF_GrandTexture"></td></tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=292 height=50>
<tr>
<td align=center><button action="bypass -h sellbuffstop" value="Stop Selling" width=200 height=31 back="L2UI_CT1.OlympiadWnd_DF_Watch_Down" fore="L2UI_CT1.OlympiadWnd_DF_Watch"></td>
</tr>
</table>
</center>
</body>
</html>

View File

@@ -0,0 +1,448 @@
/*
* 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 custom.SellBuff;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.BypassHandler;
import com.l2jmobius.gameserver.handler.IBypassHandler;
import com.l2jmobius.gameserver.handler.IVoicedCommandHandler;
import com.l2jmobius.gameserver.handler.VoicedCommandHandler;
import com.l2jmobius.gameserver.instancemanager.SellBuffsManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.AbstractScript;
import com.l2jmobius.gameserver.model.holders.SellBuffHolder;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.util.Util;
/**
* Sell Buffs voice command
* @author St3eT
*/
public class SellBuff implements IVoicedCommandHandler, IBypassHandler
{
private static final String[] VOICED_COMMANDS =
{
"sellbuff",
"sellbuffs",
};
private static final String[] BYPASS_COMMANDS =
{
"sellbuffadd",
"sellbuffaddskill",
"sellbuffedit",
"sellbuffchangeprice",
"sellbuffremove",
"sellbuffbuymenu",
"sellbuffbuyskill",
"sellbuffstart",
"sellbuffstop",
};
private SellBuff()
{
if (Config.SELLBUFF_ENABLED)
{
BypassHandler.getInstance().registerHandler(this);
VoicedCommandHandler.getInstance().registerHandler(this);
}
}
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
String cmd = "";
String params = "";
final StringTokenizer st = new StringTokenizer(command, " ");
if (st.hasMoreTokens())
{
cmd = st.nextToken();
}
while (st.hasMoreTokens())
{
params += st.nextToken() + (st.hasMoreTokens() ? " " : "");
}
if (cmd.isEmpty())
{
return false;
}
return useBypass(cmd, activeChar, params);
}
@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
{
switch (command)
{
case "sellbuff":
case "sellbuffs":
{
SellBuffsManager.getInstance().sendSellMenu(activeChar);
break;
}
}
return true;
}
public boolean useBypass(String command, L2PcInstance activeChar, String params)
{
if (!Config.SELLBUFF_ENABLED)
{
return false;
}
switch (command)
{
case "sellbuffstart":
{
if (activeChar.isSellingBuffs() || (params == null) || params.isEmpty())
{
return false;
}
else if (activeChar.getSellingBuffs().isEmpty())
{
activeChar.sendMessage("Your list of buffs is empty, please add some buffs first!");
return false;
}
else
{
String title = "BUFF SELL: ";
final StringTokenizer st = new StringTokenizer(params, " ");
while (st.hasMoreTokens())
{
title += st.nextToken() + " ";
}
if (title.length() > 40)
{
activeChar.sendMessage("Your title cannot exceed 29 characters in length. Please try again.");
return false;
}
SellBuffsManager.getInstance().startSellBuffs(activeChar, title);
}
break;
}
case "sellbuffstop":
{
if (activeChar.isSellingBuffs())
{
SellBuffsManager.getInstance().stopSellBuffs(activeChar);
}
break;
}
case "sellbuffadd":
{
if (!activeChar.isSellingBuffs())
{
int index = 0;
if ((params != null) && !params.isEmpty() && Util.isDigit(params))
{
index = Integer.parseInt(params);
}
SellBuffsManager.getInstance().sendBuffChoiceMenu(activeChar, index);
}
break;
}
case "sellbuffedit":
{
if (!activeChar.isSellingBuffs())
{
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
}
break;
}
case "sellbuffchangeprice":
{
if (!activeChar.isSellingBuffs() && (params != null) && !params.isEmpty())
{
final StringTokenizer st = new StringTokenizer(params, " ");
int skillId = -1;
int price = -1;
if (st.hasMoreTokens())
{
skillId = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
try
{
price = Integer.parseInt(st.nextToken());
}
catch (NumberFormatException e)
{
activeChar.sendMessage("Too big price! Maximal price is " + Config.SELLBUFF_MAX_PRICE);
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
}
}
if ((skillId == -1) || (price == -1))
{
return false;
}
final Skill skillToChange = activeChar.getKnownSkill(skillId);
if (skillToChange == null)
{
return false;
}
final SellBuffHolder holder = activeChar.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToChange.getId())).findFirst().orElse(null);
if ((holder != null))
{
activeChar.sendMessage("Price of " + activeChar.getKnownSkill(holder.getSkillId()).getName() + " has been changed to " + price + "!");
holder.setPrice(price);
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
}
}
break;
}
case "sellbuffremove":
{
if (!activeChar.isSellingBuffs() && (params != null) && !params.isEmpty())
{
final StringTokenizer st = new StringTokenizer(params, " ");
int skillId = -1;
if (st.hasMoreTokens())
{
skillId = Integer.parseInt(st.nextToken());
}
if ((skillId == -1))
{
return false;
}
final Skill skillToRemove = activeChar.getKnownSkill(skillId);
if (skillToRemove == null)
{
return false;
}
final SellBuffHolder holder = activeChar.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToRemove.getId())).findFirst().orElse(null);
if ((holder != null) && activeChar.getSellingBuffs().remove(holder))
{
activeChar.sendMessage("Skill " + activeChar.getKnownSkill(holder.getSkillId()).getName() + " has been removed!");
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
}
}
break;
}
case "sellbuffaddskill":
{
if (!activeChar.isSellingBuffs() && (params != null) && !params.isEmpty())
{
final StringTokenizer st = new StringTokenizer(params, " ");
int skillId = -1;
long price = -1;
if (st.hasMoreTokens())
{
skillId = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
try
{
price = Integer.parseInt(st.nextToken());
}
catch (NumberFormatException e)
{
activeChar.sendMessage("Too big price! Maximal price is " + Config.SELLBUFF_MIN_PRICE);
SellBuffsManager.getInstance().sendBuffEditMenu(activeChar);
}
}
if ((skillId == -1) || (price == -1))
{
return false;
}
final Skill skillToAdd = activeChar.getKnownSkill(skillId);
if (skillToAdd == null)
{
return false;
}
else if (price < Config.SELLBUFF_MIN_PRICE)
{
activeChar.sendMessage("Too small price! Minimal price is " + Config.SELLBUFF_MIN_PRICE);
return false;
}
else if (price > Config.SELLBUFF_MAX_PRICE)
{
activeChar.sendMessage("Too big price! Maximal price is " + Config.SELLBUFF_MAX_PRICE);
return false;
}
else if (activeChar.getSellingBuffs().size() >= Config.SELLBUFF_MAX_BUFFS)
{
activeChar.sendMessage("You already reached max count of buffs! Max buffs is: " + Config.SELLBUFF_MAX_BUFFS);
return false;
}
else if (!SellBuffsManager.getInstance().isInSellList(activeChar, skillToAdd))
{
activeChar.getSellingBuffs().add(new SellBuffHolder(skillToAdd.getId(), price));
activeChar.sendMessage(skillToAdd.getName() + " has been added!");
SellBuffsManager.getInstance().sendBuffChoiceMenu(activeChar, 0);
}
}
break;
}
case "sellbuffbuymenu":
{
if ((params != null) && !params.isEmpty())
{
final StringTokenizer st = new StringTokenizer(params, " ");
int objId = -1;
int index = 0;
if (st.hasMoreTokens())
{
objId = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
index = Integer.parseInt(st.nextToken());
}
final L2PcInstance seller = L2World.getInstance().getPlayer(objId);
if (seller != null)
{
if (!seller.isSellingBuffs() || !activeChar.isInsideRadius(seller, L2Npc.INTERACTION_DISTANCE, true, true))
{
return false;
}
SellBuffsManager.getInstance().sendBuffMenu(activeChar, seller, index);
}
}
break;
}
case "sellbuffbuyskill":
{
if ((params != null) && !params.isEmpty())
{
final StringTokenizer st = new StringTokenizer(params, " ");
int objId = -1;
int skillId = -1;
int index = 0;
if (st.hasMoreTokens())
{
objId = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
skillId = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
index = Integer.parseInt(st.nextToken());
}
if ((skillId == -1) || (objId == -1))
{
return false;
}
final L2PcInstance seller = L2World.getInstance().getPlayer(objId);
if (seller == null)
{
return false;
}
final Skill skillToBuy = seller.getKnownSkill(skillId);
if (!seller.isSellingBuffs() || !Util.checkIfInRange(L2Npc.INTERACTION_DISTANCE, activeChar, seller, true) || (skillToBuy == null))
{
return false;
}
if (seller.getCurrentMp() < (skillToBuy.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER))
{
activeChar.sendMessage(seller.getName() + " has no enough mana for " + skillToBuy.getName() + "!");
SellBuffsManager.getInstance().sendBuffMenu(activeChar, seller, index);
return false;
}
final SellBuffHolder holder = seller.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToBuy.getId())).findFirst().orElse(null);
if (holder != null)
{
if (AbstractScript.getQuestItemsCount(activeChar, Config.SELLBUFF_PAYMENT_ID) >= holder.getPrice())
{
AbstractScript.takeItems(activeChar, Config.SELLBUFF_PAYMENT_ID, holder.getPrice());
AbstractScript.giveItems(seller, Config.SELLBUFF_PAYMENT_ID, holder.getPrice());
seller.reduceCurrentMp(skillToBuy.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER);
skillToBuy.activateSkill(seller, activeChar);
}
else
{
final L2Item item = ItemTable.getInstance().getTemplate(Config.SELLBUFF_PAYMENT_ID);
if (item != null)
{
activeChar.sendMessage("Not enough " + item.getName() + "!");
}
else
{
activeChar.sendMessage("Not enough items!");
}
}
}
SellBuffsManager.getInstance().sendBuffMenu(activeChar, seller, index);
}
break;
}
}
return true;
}
@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
@Override
public String[] getBypassList()
{
return BYPASS_COMMANDS;
}
public static void main(String[] args)
{
new SellBuff();
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="skill" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:integer" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>