Dye and Potential update.

Contributed by Serenitty.
This commit is contained in:
MobiusDevelopment
2022-08-24 22:39:29 +00:00
parent bbd0f7f911
commit 43e9fd8656
9 changed files with 120 additions and 89 deletions

View File

@@ -1,8 +1,9 @@
DROP TABLE IF EXISTS `character_potens`;
CREATE TABLE IF NOT EXISTS `character_potens` (
`charId` INT UNSIGNED NOT NULL DEFAULT 0,
`slot_position` INT NOT NULL DEFAULT 0,
`poten_id` INT NOT NULL DEFAULT 0,
`enchant_level` INT NOT NULL DEFAULT 0,
`enchant_exp` INT NOT NULL DEFAULT 0,
`poten_id` INT NOT NULL DEFAULT 0,
PRIMARY KEY (`charId`,`poten_id`)
PRIMARY KEY (`charId`,`slot_position`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

View File

@@ -2,20 +2,20 @@
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/hennaPatternPotential.xsd">
<enchantFees>
<fee step="1">
<requiredItem id="57" count="500000" />
<requiredItem id="57" count="500000" /> <!-- Adena -->
<dailyCount>5</dailyCount>
<enchantExp count="0" chance="50" />
<enchantExp count="1" chance="50" />
</fee>
<fee step="2">
<requiredItem id="57" count="2000000" />
<requiredItem id="57" count="2000000" /> <!-- Adena -->
<dailyCount>5</dailyCount>
<enchantExp count="1" chance="90" />
<enchantExp count="2" chance="29" />
<enchantExp count="3" chance="1" />
</fee>
<fee step="3">
<requiredItem id="96623" count="1" />
<requiredItem id="96623" count="1" /> <!-- Dye Powder -->
<dailyCount>10</dailyCount>
<enchantExp count="1" chance="10" />
<enchantExp count="2" chance="75" />
@@ -25,26 +25,26 @@
</fee>
</enchantFees>
<experiencePoints>
<hiddenPower level="1" exp="20" /> <!-- 1 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="2" exp="30" /> <!-- 2 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="3" exp="40" /> <!-- 3 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="4" exp="50" /> <!-- 4 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="5" exp="100" /> <!-- 5 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="6" exp="110" /> <!-- 6 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="7" exp="120" /> <!-- 7 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="8" exp="130" /> <!-- 8 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="9" exp="140" /> <!-- 9 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="10" exp="150" /> <!-- 10 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="11" exp="170" /> <!-- 11 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="12" exp="190" /> <!-- 12 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="13" exp="210" /> <!-- 13 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="14" exp="230" /> <!-- 14 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="15" exp="250" /> <!-- 15 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="16" exp="300" /> <!-- 16 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="17" exp="350" /> <!-- 17 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="18" exp="400" /> <!-- 18 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="19" exp="450" /> <!-- 19 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="20" exp="500" /> <!-- 20 window, how many points do you need to fill a skillbonus. -->
<hiddenPower level="1" exp="20" /> <!-- How many points do you need to fill a skillbonus. -->
<hiddenPower level="2" exp="30" />
<hiddenPower level="3" exp="40" />
<hiddenPower level="4" exp="50" />
<hiddenPower level="5" exp="100" />
<hiddenPower level="6" exp="110" />
<hiddenPower level="7" exp="120" />
<hiddenPower level="8" exp="130" />
<hiddenPower level="9" exp="140" />
<hiddenPower level="10" exp="150" />
<hiddenPower level="11" exp="170" />
<hiddenPower level="12" exp="190" />
<hiddenPower level="13" exp="210" />
<hiddenPower level="14" exp="230" />
<hiddenPower level="15" exp="250" />
<hiddenPower level="16" exp="300" />
<hiddenPower level="17" exp="350" />
<hiddenPower level="18" exp="400" />
<hiddenPower level="19" exp="500" />
<hiddenPower level="20" exp="600" />
</experiencePoints>
<hiddenPotentials>
<poten id="1" slotId="1" maxSkillLevel="20" skillId="83001" /> <!-- P and M. Atk. -->

View File

@@ -7924,7 +7924,7 @@
<magicCriticalRate>5</magicCriticalRate>
<effects>
<effect name="NewHennaSlot">
<amount>4</amount>
<amount>1</amount>
</effect>
</effects>
</skill>

View File

@@ -47,6 +47,7 @@ public class HennaPatternPotentialData implements IXmlReader
private final Map<Integer, DyePotential> _potentials = new HashMap<>();
private int MAX_POTEN_LEVEL = 0;
private int MAX_POTEN_EXP = 0;
protected HennaPatternPotentialData()
{
@@ -145,6 +146,10 @@ public class HennaPatternPotentialData implements IXmlReader
{
MAX_POTEN_LEVEL = level;
}
if (MAX_POTEN_EXP < exp)
{
MAX_POTEN_EXP = exp;
}
}
}
break;
@@ -199,6 +204,11 @@ public class HennaPatternPotentialData implements IXmlReader
return MAX_POTEN_LEVEL;
}
public int getMaxPotenExp()
{
return MAX_POTEN_EXP;
}
public DyePotential getPotential(int potenId)
{
return _potentials.get(potenId);

View File

@@ -443,8 +443,8 @@ public class Player extends Playable
private static final String RESTORE_CHAR_HENNAS = "SELECT slot,symbol_id FROM character_hennas WHERE charId=? AND class_index=?";
private static final String ADD_CHAR_HENNA = "INSERT INTO character_hennas (charId,symbol_id,slot,class_index) VALUES (?,?,?,?)";
private static final String DELETE_CHAR_HENNA = "DELETE FROM character_hennas WHERE charId=? AND slot=? AND class_index=?";
private static final String ADD_CHAR_HENNA_POTENS = "REPLACE INTO character_potens (charId,enchant_level,enchant_exp,poten_id) VALUES (?,?,?,?)";
private static final String RESTORE_CHAR_HENNA_POTENS = "SELECT poten_id,enchant_level,enchant_exp FROM character_potens WHERE charId=?";
private static final String ADD_CHAR_HENNA_POTENS = "REPLACE INTO character_potens (charId,slot_position,poten_id,enchant_level,enchant_exp) VALUES (?,?,?,?,?)";
private static final String RESTORE_CHAR_HENNA_POTENS = "SELECT slot_position,poten_id,enchant_level,enchant_exp FROM character_potens WHERE charId=?";
// Character Shortcut SQL String Definitions:
private static final String DELETE_CHAR_SHORTCUTS = "DELETE FROM character_shortcuts WHERE charId=? AND class_index=?";
@@ -8062,6 +8062,7 @@ public class Player extends Playable
// Calculate henna modifiers of this player.
recalcHennaStats();
applyDyePotenSkills();
}
/**
@@ -8289,15 +8290,12 @@ public class Player extends Playable
{
while (rset.next())
{
final int potenId = rset.getInt("poten_id");
if (potenId > 0)
{
_hennaPoten[pos] = new HennaPoten();
_hennaPoten[pos].setEnchantLevel(rset.getInt("enchant_level"));
_hennaPoten[pos].setEnchantExp(rset.getInt("enchant_exp"));
_hennaPoten[pos].setPotenId(potenId);
pos++;
}
_hennaPoten[pos] = new HennaPoten();
_hennaPoten[pos].setSlotPosition(rset.getInt("slot_position"));
_hennaPoten[pos].setEnchantLevel(rset.getInt("enchant_level"));
_hennaPoten[pos].setEnchantExp(rset.getInt("enchant_exp"));
_hennaPoten[pos].setPotenId(rset.getInt("poten_id"));
pos++;
}
}
}
@@ -8318,15 +8316,16 @@ public class Player extends Playable
{
for (int i = 0; i < 4; i++)
{
if ((_hennaPoten[i] != null) && (_hennaPoten[i].getPotenId() > 0))
if ((_hennaPoten[i] != null) && (_hennaPoten[i].getSlotPosition() > 0))
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA_POTENS))
{
statement.setInt(1, getObjectId());
statement.setInt(2, _hennaPoten[i].getEnchantLevel());
statement.setInt(3, _hennaPoten[i].getEnchantExp());
statement.setInt(4, _hennaPoten[i].getPotenId());
statement.setInt(2, _hennaPoten[i].getSlotPosition());
statement.setInt(3, _hennaPoten[i].getPotenId());
statement.setInt(4, _hennaPoten[i].getEnchantLevel());
statement.setInt(5, _hennaPoten[i].getEnchantExp());
statement.execute();
}
catch (Exception e)
@@ -8422,7 +8421,7 @@ public class Player extends Playable
public int getAvailableHennaSlots()
{
return (int) getStat().getValue(Stat.HENNA_SLOTS_AVAILABLE, 3);
return (int) getStat().getValue(Stat.HENNA_SLOTS_AVAILABLE, 4);
}
public void setDyePotentialDailyStep(int dailyStep)
@@ -8445,26 +8444,6 @@ public class Player extends Playable
return getVariables().getInt(PlayerVariables.DYE_POTENTIAL_DAILY_COUNT, 5);
}
public void setDyePotentialDailyExp(int dailyExp)
{
getVariables().set(PlayerVariables.DYE_POTENTIAL_DAILY_EXP, dailyExp);
}
public int getDyePotentialDailyExp()
{
return getVariables().getInt(PlayerVariables.DYE_POTENTIAL_DAILY_EXP, 0);
}
public void setDyePotentialenchantStep(int enchantlvl)
{
getVariables().set(PlayerVariables.DYE_POTENTIAL_DAILY_LVL, enchantlvl);
}
public int getDyePotentialenchantStep()
{
return getVariables().getInt(PlayerVariables.DYE_POTENTIAL_DAILY_LVL, 0);
}
/**
* @return map of all henna base stats bonus
*/

View File

@@ -16,6 +16,8 @@
*/
package org.l2jmobius.gameserver.model.item.henna;
import org.l2jmobius.gameserver.data.xml.HennaPatternPotentialData;
/**
* @author Serenitty
*/
@@ -25,6 +27,7 @@ public class HennaPoten
private int _potenId;
private int _enchantLevel = 1;
private int _enchantExp;
private int _slotPosition;
public HennaPoten()
{
@@ -45,6 +48,16 @@ public class HennaPoten
_potenId = val;
}
public int getSlotPosition()
{
return _slotPosition;
}
public void setSlotPosition(int val)
{
_slotPosition = val;
}
public int getPotenId()
{
return _potenId;
@@ -67,12 +80,17 @@ public class HennaPoten
public int getEnchantExp()
{
if (_enchantExp > HennaPatternPotentialData.getInstance().getMaxPotenExp())
{
_enchantExp = HennaPatternPotentialData.getInstance().getMaxPotenExp();
return _enchantExp;
}
return _enchantExp;
}
public boolean isPotentialAvailable()
{
return (_henna != null) && (_henna.getPatternLevel() > 0);
return (_henna != null) && (_enchantLevel > 1);
}
public int getActiveStep()
@@ -81,6 +99,12 @@ public class HennaPoten
{
return 0;
}
return Math.min(_enchantLevel, _henna.getPatternLevel());
if (_enchantExp == HennaPatternPotentialData.getInstance().getMaxPotenExp())
{
return Math.min(_enchantLevel, _henna.getPatternLevel());
}
return Math.min(_enchantLevel - 1, _henna.getPatternLevel());
}
}

View File

@@ -90,8 +90,6 @@ public class PlayerVariables extends AbstractVariables
public static final String HENNA4_DURATION = "HENNA4_DURATION";
public static final String DYE_POTENTIAL_DAILY_STEP = "DYE_POTENTIAL_DAILY_STEP";
public static final String DYE_POTENTIAL_DAILY_COUNT = "DYE_POTENTIAL_DAILY_COUNT";
public static final String DYE_POTENTIAL_DAILY_EXP = "DYE_POTENTIAL_DAILY_EXP";
public static final String DYE_POTENTIAL_DAILY_LVL = "DYE_POTENTIAL_DAILY_LVL";
public static final String MISSION_LEVEL_PROGRESS = "MISSION_LEVEL_PROGRESS_";
private final int _objectId;

View File

@@ -34,11 +34,13 @@ import org.l2jmobius.gameserver.network.serverpackets.newhenna.NewHennaPotenEnch
public class RequestNewHennaPotenEnchant implements IClientIncomingPacket
{
private int _slotId;
private int _costItemId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slotId = packet.readC();
_costItemId = packet.readD();
return true;
}
@@ -51,23 +53,42 @@ public class RequestNewHennaPotenEnchant implements IClientIncomingPacket
return;
}
int dailyStep = player.getDyePotentialDailyStep();
final DyePotentialFee currentFee = HennaPatternPotentialData.getInstance().getFee(dailyStep);
int dailyCount = player.getDyePotentialDailyCount();
if ((_slotId < 1) || (_slotId > 4))
{
return;
}
int dailyStep = player.getDyePotentialDailyStep();
final DyePotentialFee currentFee = HennaPatternPotentialData.getInstance().getFee(dailyStep);
int dailyCount = player.getDyePotentialDailyCount();
final HennaPoten hennaPattern = player.getHennaPoten(_slotId);
int enchantExp = hennaPattern.getEnchantExp();
final int fullExpNeeded = HennaPatternPotentialData.getInstance().getExpForLevel(hennaPattern.getEnchantLevel());
if ((enchantExp >= fullExpNeeded) && (hennaPattern.getEnchantLevel() == 20))
{
player.sendPacket(new NewHennaPotenEnchant(_slotId, hennaPattern.getEnchantLevel(), hennaPattern.getEnchantExp(), dailyStep, dailyCount, hennaPattern.getActiveStep(), true));
return;
}
if ((currentFee == null) || (dailyCount <= 0))
{
return;
}
if (!player.destroyItemByItemId(getClass().getSimpleName(), currentFee.getItem().getId(), currentFee.getItem().getCount(), player, true))
int costItemID = 0;
if (_costItemId == 97147) // Dye Powder
{
costItemID = _costItemId;
}
else
{
costItemID = currentFee.getItem().getId();
}
if (!player.destroyItemByItemId(getClass().getSimpleName(), costItemID, currentFee.getItem().getCount(), player, true))
{
return;
}
dailyCount -= 1;
if ((dailyCount <= 0) && (dailyStep != HennaPatternPotentialData.getInstance().getMaxPotenEnchantStep()))
{
@@ -84,6 +105,7 @@ public class RequestNewHennaPotenEnchant implements IClientIncomingPacket
{
player.setDyePotentialDailyCount(dailyCount);
}
double totalChance = 0;
double random = Rnd.nextDouble() * 100;
for (Entry<Integer, Double> entry : currentFee.getEnchantExp().entrySet())
@@ -91,21 +113,22 @@ public class RequestNewHennaPotenEnchant implements IClientIncomingPacket
totalChance += entry.getValue();
if (random <= totalChance)
{
final HennaPoten poten = player.getHennaPoten(_slotId);
final int increase = entry.getKey();
int newEnchantExp = poten.getEnchantExp() + increase;
final int tatooExpNeeded = HennaPatternPotentialData.getInstance().getExpForLevel(poten.getEnchantLevel());
if (newEnchantExp >= tatooExpNeeded)
int newEnchantExp = hennaPattern.getEnchantExp() + increase;
final int PatternExpNeeded = HennaPatternPotentialData.getInstance().getExpForLevel(hennaPattern.getEnchantLevel());
if ((newEnchantExp >= PatternExpNeeded) && (hennaPattern.getEnchantLevel() < 20))
{
newEnchantExp -= tatooExpNeeded;
if (poten.getEnchantLevel() < HennaPatternPotentialData.getInstance().getMaxPotenLevel())
newEnchantExp -= PatternExpNeeded;
if (hennaPattern.getEnchantLevel() < HennaPatternPotentialData.getInstance().getMaxPotenLevel())
{
poten.setEnchantLevel(poten.getEnchantLevel() + 1);
hennaPattern.setEnchantLevel(hennaPattern.getEnchantLevel() + 1);
player.applyDyePotenSkills();
}
}
poten.setEnchantExp(newEnchantExp);
player.sendPacket(new NewHennaPotenEnchant(_slotId, poten.getEnchantLevel(), poten.getEnchantExp(), dailyStep, dailyCount, poten.getActiveStep(), true));
hennaPattern.setEnchantExp(newEnchantExp);
hennaPattern.setSlotPosition(_slotId);
player.sendPacket(new NewHennaPotenEnchant(_slotId, hennaPattern.getEnchantLevel(), hennaPattern.getEnchantExp(), dailyStep, dailyCount, hennaPattern.getActiveStep(), true));
return;
}
}

View File

@@ -30,19 +30,16 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
public class NewHennaList implements IClientOutgoingPacket
{
private final HennaPoten[] _hennaId;
private final int _activeslots;
private final int _dailyStep;
private final int _dailyCount;
@SuppressWarnings("unused")
private final int _enchantExp;
private final int _availableSlots;
public NewHennaList(Player player)
{
_dailyStep = player.getDyePotentialDailyStep();
_dailyCount = player.getDyePotentialDailyCount();
_hennaId = player.getHennaPotenList();
_activeslots = player.getAvailableHennaSlots();
_enchantExp = player.getDyePotentialDailyExp();
_availableSlots = player.getAvailableHennaSlots();
}
@Override
@@ -56,13 +53,12 @@ public class NewHennaList implements IClientOutgoingPacket
{
final HennaPoten hennaPoten = _hennaId[i - 1];
final Henna henna = _hennaId[i - 1].getHenna();
int isactiveStep = hennaPoten.getActiveStep();
packet.writeD(henna != null ? henna.getDyeId() : 0x00);
packet.writeD(isactiveStep == 0 ? 0 : hennaPoten.getPotenId());
packet.writeC(_activeslots);
packet.writeD(henna != null ? henna.getDyeId() : 0);
packet.writeD(hennaPoten.getPotenId());
packet.writeC(i == _availableSlots ? 0 : 1);
packet.writeH(hennaPoten.getEnchantLevel());
packet.writeD(hennaPoten.getEnchantExp());
packet.writeH(isactiveStep);
packet.writeH(hennaPoten.getActiveStep());
}
return true;
}