Homunculus system rework.

Thanks to Manax.
This commit is contained in:
MobiusDevelopment
2021-06-05 22:06:01 +00:00
parent 41f1d2167d
commit 36c5aeabcd
108 changed files with 5933 additions and 2267 deletions

View File

@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS `character_homunculus` (
`ownerId` INT NOT NULL,
`slot` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`id` TINYINT UNSIGNED NOT NULL,
`level` TINYINT UNSIGNED NOT NULL DEFAULT '1',
`exp` INT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel1` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel2` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel3` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel4` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel5` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`active` TINYINT UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/HomunculusData.xsd">
<homunculus id="1" type="0" basicSkillId="32999" basicSkillLevel="1" skillId1="33004" skillId2="33009" skillId3="33014" skillId4="33019" skillId5="33024" hpLevel1="816" atkLevel1="782" defLevel1="802" expToLevel2="35000" hpLevel2="979" atkLevel2="939" defLevel2="962" expToLevel3="87500" hpLevel3="1174" atkLevel3="1126" defLevel3="1154" expToLevel4="192500" hpLevel4="1410" atkLevel4="1351" defLevel4="1385" expToLevel5="350000" hpLevel5="1691" atkLevel5="1621" defLevel5="1662" expToLevel6="560000" critRate="30" /> <!-- Basic Juju -->
<homunculus id="2" type="1" basicSkillId="32999" basicSkillLevel="2" skillId1="33029" skillId2="33034" skillId3="33039" skillId4="33044" skillId5="33049" hpLevel1="979" atkLevel1="938" defLevel1="962" expToLevel2="40000" hpLevel2="1175" atkLevel2="1126" defLevel2="1154" expToLevel3="100000" hpLevel3="1409" atkLevel3="1350" defLevel3="1385" expToLevel4="220000" hpLevel4="1691" atkLevel4="1621" defLevel4="1662" expToLevel5="400000" hpLevel5="2029" atkLevel5="1945" defLevel5="1994" expToLevel6="640000" critRate="30" /> <!-- Water Juju -->
<homunculus id="3" type="2" basicSkillId="32999" basicSkillLevel="3" skillId1="33054" skillId2="33059" skillId3="33064" skillId4="33069" skillId5="33074" hpLevel1="1174" atkLevel1="1125" defLevel1="1154" expToLevel2="45000" hpLevel2="1410" atkLevel2="1351" defLevel2="1384" expToLevel3="112500" hpLevel3="1690" atkLevel3="1620" defLevel3="1662" expToLevel4="247500" hpLevel4="2029" atkLevel4="1945" defLevel4="1994" expToLevel5="450000" hpLevel5="2434" atkLevel5="2334" defLevel5="2392" expToLevel6="720000" critRate="30" /> <!-- Luminous Juju -->
<homunculus id="4" type="0" basicSkillId="33000" basicSkillLevel="1" skillId1="33005" skillId2="33010" skillId3="33015" skillId4="33020" skillId5="33025" hpLevel1="816" atkLevel1="1188" defLevel1="990" expToLevel2="35000" hpLevel2="979" atkLevel2="1426" defLevel2="1188" expToLevel3="87500" hpLevel3="1174" atkLevel3="1710" defLevel3="1425" expToLevel4="192500" hpLevel4="1410" atkLevel4="2052" defLevel4="1710" expToLevel5="350000" hpLevel5="1691" atkLevel5="2462" defLevel5="2052" expToLevel6="560000" critRate="15" /> <!-- Basic Tana -->
<homunculus id="5" type="1" basicSkillId="33000" basicSkillLevel="2" skillId1="33030" skillId2="33035" skillId3="33040" skillId4="33045" skillId5="33050" hpLevel1="979" atkLevel1="1425" defLevel1="1188" expToLevel2="40000" hpLevel2="1175" atkLevel2="1710" defLevel2="1425" expToLevel3="100000" hpLevel3="1409" atkLevel3="2052" defLevel3="1710" expToLevel4="220000" hpLevel4="1691" atkLevel4="2462" defLevel4="2052" expToLevel5="400000" hpLevel5="2029" atkLevel5="2954" defLevel5="2462" expToLevel6="640000" critRate="15" /> <!-- Water Tana -->
<homunculus id="6" type="2" basicSkillId="33000" basicSkillLevel="3" skillId1="33055" skillId2="33060" skillId3="33065" skillId4="33070" skillId5="33075" hpLevel1="1174" atkLevel1="1710" defLevel1="1425" expToLevel2="45000" hpLevel2="1410" atkLevel2="2052" defLevel2="1710" expToLevel3="112500" hpLevel3="1690" atkLevel3="2462" defLevel3="2052" expToLevel4="247500" hpLevel4="2029" atkLevel4="2954" defLevel4="2462" expToLevel5="450000" hpLevel5="2434" atkLevel5="3544" defLevel5="2954" expToLevel6="720000" critRate="15" /> <!-- Luminous Tana -->
<homunculus id="7" type="0" basicSkillId="33001" basicSkillLevel="1" skillId1="33006" skillId2="33011" skillId3="33016" skillId4="33021" skillId5="33026" hpLevel1="1020" atkLevel1="792" defLevel1="1188" expToLevel2="35000" hpLevel2="1224" atkLevel2="950" defLevel2="1426" expToLevel3="87500" hpLevel3="1468" atkLevel3="1140" defLevel3="1710" expToLevel4="192500" hpLevel4="1762" atkLevel4="1368" defLevel4="2052" expToLevel5="350000" hpLevel5="2114" atkLevel5="1642" defLevel5="2462" expToLevel6="560000" critRate="15" /> <!-- Basic Pallo -->
<homunculus id="8" type="1" basicSkillId="33001" basicSkillLevel="2" skillId1="33031" skillId2="33036" skillId3="33041" skillId4="33046" skillId5="33051" hpLevel1="1224" atkLevel1="950" defLevel1="1425" expToLevel2="40000" hpLevel2="1468" atkLevel2="1140" defLevel2="1710" expToLevel3="100000" hpLevel3="1761" atkLevel3="1368" defLevel3="2052" expToLevel4="220000" hpLevel4="2114" atkLevel4="1641" defLevel4="2462" expToLevel5="400000" hpLevel5="2536" atkLevel5="1969" defLevel5="2954" expToLevel6="640000" critRate="15" /> <!-- Water Pallo -->
<homunculus id="9" type="2" basicSkillId="33001" basicSkillLevel="3" skillId1="33056" skillId2="33061" skillId3="33066" skillId4="33071" skillId5="33076" hpLevel1="1468" atkLevel1="1140" defLevel1="1710" expToLevel2="45000" hpLevel2="1761" atkLevel2="1368" defLevel2="2052" expToLevel3="112500" hpLevel3="2113" atkLevel3="1641" defLevel3="2462" expToLevel4="247500" hpLevel4="2536" atkLevel4="1969" defLevel4="2954" expToLevel5="450000" hpLevel5="3043" atkLevel5="2362" defLevel5="3544" expToLevel6="720000" critRate="15" /> <!-- Luminous Pallo -->
<homunculus id="10" type="0" basicSkillId="33002" basicSkillLevel="1" skillId1="33007" skillId2="33012" skillId3="33017" skillId4="33022" skillId5="33027" hpLevel1="1224" atkLevel1="990" defLevel1="792" expToLevel2="35000" hpLevel2="1469" atkLevel2="1188" defLevel2="950" expToLevel3="87500" hpLevel3="1762" atkLevel3="1425" defLevel3="1140" expToLevel4="192500" hpLevel4="2114" atkLevel4="1710" defLevel4="1368" expToLevel5="350000" hpLevel5="2537" atkLevel5="2052" defLevel5="1642" expToLevel6="560000" critRate="15" /> <!-- Basic Ayri -->
<homunculus id="11" type="1" basicSkillId="33002" basicSkillLevel="2" skillId1="33032" skillId2="33037" skillId3="33042" skillId4="33047" skillId5="33052" hpLevel1="1468" atkLevel1="1188" defLevel1="950" expToLevel2="40000" hpLevel2="1762" atkLevel2="1425" defLevel2="1140" expToLevel3="100000" hpLevel3="2113" atkLevel3="1710" defLevel3="1368" expToLevel4="220000" hpLevel4="2537" atkLevel4="2052" defLevel4="1641" expToLevel5="400000" hpLevel5="3044" atkLevel5="2462" defLevel5="1969" expToLevel6="640000" critRate="15" /> <!-- Water Ayri -->
<homunculus id="12" type="2" basicSkillId="33002" basicSkillLevel="3" skillId1="33057" skillId2="33062" skillId3="33067" skillId4="33072" skillId5="33077" hpLevel1="1761" atkLevel1="1425" defLevel1="1140" expToLevel2="45000" hpLevel2="2114" atkLevel2="1710" defLevel2="1368" expToLevel3="112500" hpLevel3="2535" atkLevel3="2052" defLevel3="1641" expToLevel4="247500" hpLevel4="3044" atkLevel4="2462" defLevel4="1969" expToLevel5="450000" hpLevel5="3652" atkLevel5="2954" defLevel5="2362" expToLevel6="720000" critRate="15" /> <!-- Luminous Ayri -->
<homunculus id="13" type="0" basicSkillId="33003" basicSkillLevel="1" skillId1="33008" skillId2="33013" skillId3="33018" skillId4="33023" skillId5="33028" hpLevel1="816" atkLevel1="1188" defLevel1="990" expToLevel2="35000" hpLevel2="979" atkLevel2="1426" defLevel2="1188" expToLevel3="87500" hpLevel3="1174" atkLevel3="1710" defLevel3="1425" expToLevel4="192500" hpLevel4="1410" atkLevel4="2052" defLevel4="1710" expToLevel5="350000" hpLevel5="1691" atkLevel5="2462" defLevel5="2052" expToLevel6="560000" critRate="15" /> <!-- Basic Churing -->
<homunculus id="14" type="1" basicSkillId="33003" basicSkillLevel="2" skillId1="33033" skillId2="33038" skillId3="33043" skillId4="33048" skillId5="33053" hpLevel1="979" atkLevel1="1425" defLevel1="1188" expToLevel2="40000" hpLevel2="1175" atkLevel2="1710" defLevel2="1425" expToLevel3="100000" hpLevel3="1409" atkLevel3="2052" defLevel3="1710" expToLevel4="220000" hpLevel4="1691" atkLevel4="2462" defLevel4="2052" expToLevel5="400000" hpLevel5="2029" atkLevel5="2954" defLevel5="2462" expToLevel6="640000" critRate="15" /> <!-- Water Churing -->
<homunculus id="15" type="2" basicSkillId="33003" basicSkillLevel="3" skillId1="33058" skillId2="33063" skillId3="33068" skillId4="33073" skillId5="33078" hpLevel1="1174" atkLevel1="1710" defLevel1="1425" expToLevel2="45000" hpLevel2="1410" atkLevel2="2052" defLevel2="1710" expToLevel3="112500" hpLevel3="1690" atkLevel3="2462" defLevel3="2052" expToLevel4="247500" hpLevel4="2029" atkLevel4="2954" defLevel4="2462" expToLevel5="450000" hpLevel5="2434" atkLevel5="3544" defLevel5="2954" expToLevel6="720000" critRate="15" /> <!-- Luminous Churing -->
</list>

View File

@@ -0,0 +1,46 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="homunculus" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:byte" name="id" use="optional"/>
<xs:attribute type="xs:byte" name="type" use="optional"/>
<xs:attribute type="xs:int" name="basicSkillId" use="optional"/>
<xs:attribute type="xs:byte" name="basicSkillLevel" use="optional"/>
<xs:attribute type="xs:int" name="skillId1" use="optional"/>
<xs:attribute type="xs:int" name="skillId2" use="optional"/>
<xs:attribute type="xs:int" name="skillId3" use="optional"/>
<xs:attribute type="xs:int" name="skillId4" use="optional"/>
<xs:attribute type="xs:int" name="skillId5" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel1" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel1" use="optional"/>
<xs:attribute type="xs:short" name="defLevel1" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel2" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel2" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel2" use="optional"/>
<xs:attribute type="xs:short" name="defLevel2" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel3" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel3" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel3" use="optional"/>
<xs:attribute type="xs:short" name="defLevel3" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel4" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel4" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel4" use="optional"/>
<xs:attribute type="xs:short" name="defLevel4" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel5" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel5" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel5" use="optional"/>
<xs:attribute type="xs:short" name="defLevel5" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel6" use="optional"/>
<xs:attribute type="xs:byte" name="critRate" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -77,6 +77,7 @@ import org.l2jmobius.gameserver.data.xml.FenceData;
import org.l2jmobius.gameserver.data.xml.FishingData;
import org.l2jmobius.gameserver.data.xml.HennaData;
import org.l2jmobius.gameserver.data.xml.HitConditionBonusData;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.data.xml.InitialEquipmentData;
import org.l2jmobius.gameserver.data.xml.InitialShortcutData;
import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
@@ -341,6 +342,7 @@ public class GameServer
CastleManager.getInstance().loadInstances();
GrandBossManager.getInstance();
EventDroplist.getInstance();
HomunculusData.getInstance();
printSection("Instance");
InstanceManager.getInstance();

View File

@@ -0,0 +1,79 @@
/*
* 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 org.l2jmobius.gameserver.data.xml;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
/**
* @author Mobius
*/
public class HomunculusData implements IXmlReader
{
private final Map<Integer, HomunculusTemplate> _templates = new HashMap<>();
protected HomunculusData()
{
load();
}
@Override
public void load()
{
_templates.clear();
parseDatapackFile("data/HomunculusData.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _templates.size() + " templates.");
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "homunculus", homunculusNode ->
{
final StatSet set = new StatSet(parseAttributes(homunculusNode));
final int id = set.getInt("id");
_templates.put(id, new HomunculusTemplate(id, set.getInt("type"), set.getInt("basicSkillId"), set.getInt("basicSkillLevel"), set.getInt("skillId1"), set.getInt("skillId2"), set.getInt("skillId3"), set.getInt("skillId4"), set.getInt("skillId5"), set.getInt("hpLevel1"), set.getInt("atkLevel1"), set.getInt("defLevel1"), set.getInt("expToLevel2"), set.getInt("hpLevel2"), set.getInt("atkLevel2"), set.getInt("defLevel2"), set.getInt("expToLevel3"), set.getInt("hpLevel3"), set.getInt("atkLevel3"), set.getInt("defLevel3"), set.getInt("expToLevel4"), set.getInt("hpLevel4"), set.getInt("atkLevel4"), set.getInt("defLevel4"), set.getInt("expToLevel5"), set.getInt("hpLevel5"), set.getInt("atkLevel5"), set.getInt("defLevel5"), set.getInt("expToLevel6"), set.getInt("critRate")));
}));
}
public HomunculusTemplate getTemplate(int id)
{
return _templates.get(id);
}
public int size()
{
return _templates.size();
}
public static HomunculusData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HomunculusData INSTANCE = new HomunculusData();
}
}

View File

@@ -0,0 +1,205 @@
/*
* 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 org.l2jmobius.gameserver.instancemanager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
/**
* @author nexvill
*/
public class HomunculusManager
{
private static final Logger LOGGER = Logger.getLogger(HomunculusManager.class.getName());
private static final String SELECT_QUERY = "SELECT slot, id, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, active FROM character_homunculus WHERE ownerId=?";
private static final String INSERT_QUERY = "INSERT INTO `character_homunculus` (ownerId, slot, id, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, active) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
private static final String DELETE_QUERY = "DELETE FROM character_homunculus WHERE ownerId=? AND slot=? AND id=? AND level=? AND exp=? AND skillLevel1=? AND skillLevel2=? AND skillLevel3=? AND skillLevel4=? AND skillLevel5=? AND active=?";
private static final String UPDATE_QUERY = "UPDATE character_homunculus SET level=?, exp=?, skillLevel1=?, skillLevel2=?, skillLevel3=?, skillLevel4=?, skillLevel5=?, active=? WHERE ownerId=? AND slot=? AND id=?";
private static final String UPDATE_SLOT_QUERY = "UPDATE character_homunculus SET slot=0 WHERE ownerId=? AND slot=1";
public List<Homunculus> select(PlayerInstance owner)
{
final List<Homunculus> list = new ArrayList<>();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(SELECT_QUERY))
{
statement.setInt(1, owner.getObjectId());
final ResultSet rset = statement.executeQuery();
while (rset.next())
{
final int id = rset.getInt("id");
final int slot = rset.getInt("slot");
final int level = rset.getInt("level");
final int exp = rset.getInt("exp");
final int skillLevel1 = rset.getInt("skillLevel1");
final int skillLevel2 = rset.getInt("skillLevel2");
final int skillLevel3 = rset.getInt("skillLevel3");
final int skillLevel4 = rset.getInt("skillLevel4");
final int skillLevel5 = rset.getInt("skillLevel5");
final boolean isActive = rset.getInt("active") > 0;
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(id);
Homunculus homunculus = null;
boolean remove = template == null;
if (!remove)
{
homunculus = new Homunculus(template, slot, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, isActive);
}
if (remove)
{
delete(owner, slot, id, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, isActive);
}
else
{
list.add(homunculus);
}
}
rset.close();
}
catch (Exception e)
{
LOGGER.warning("HomunculusManager.select(Player): " + e);
}
return list;
}
public boolean insert(PlayerInstance owner, Homunculus homunculus)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_QUERY))
{
statement.setInt(1, owner.getObjectId());
statement.setInt(2, homunculus.getSlot());
statement.setInt(3, homunculus.getId());
statement.setInt(4, homunculus.getLevel());
statement.setInt(5, homunculus.getExp());
statement.setInt(6, homunculus.getSkillLevel1());
statement.setInt(7, homunculus.getSkillLevel2());
statement.setInt(8, homunculus.getSkillLevel3());
statement.setInt(9, homunculus.getSkillLevel4());
statement.setInt(10, homunculus.getSkillLevel5());
statement.setInt(11, homunculus.isActive() ? 1 : 0);
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not add homunculus to homunculus list: " + homunculus);
return false;
}
return true;
}
public boolean delete(PlayerInstance owner, Homunculus homunculus)
{
return delete(owner, homunculus.getSlot(), homunculus.getId(), homunculus.getLevel(), homunculus.getExp(), homunculus.getSkillLevel1(), homunculus.getSkillLevel2(), homunculus.getSkillLevel3(), homunculus.getSkillLevel4(), homunculus.getSkillLevel5(), homunculus.isActive());
}
private boolean delete(PlayerInstance owner, int slot, int id, int level, int exp, int skillLevel1, int skillLevel2, int skillLevel3, int skillLevel4, int skillLevel5, boolean active)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_QUERY))
{
statement.setInt(1, owner.getObjectId());
statement.setInt(2, slot);
statement.setInt(3, id);
statement.setInt(4, level);
statement.setInt(5, exp);
statement.setInt(6, skillLevel1);
statement.setInt(7, skillLevel2);
statement.setInt(8, skillLevel3);
statement.setInt(9, skillLevel4);
statement.setInt(10, skillLevel5);
statement.setInt(11, active ? 1 : 0);
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not delete homunculus: " + id + " " + active + " ownerId: " + owner.getObjectId());
return false;
}
if (slot == 0)
{
updateSlot(owner);
}
return true;
}
private boolean updateSlot(PlayerInstance owner)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_SLOT_QUERY))
{
statement.setInt(1, owner.getObjectId());
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not change homunculus slot on owner id: " + owner.getObjectId());
return false;
}
return true;
}
public boolean update(PlayerInstance owner, Homunculus homunculus)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_QUERY))
{
statement.setInt(1, homunculus.getLevel());
statement.setInt(2, homunculus.getExp());
statement.setInt(3, homunculus.getSkillLevel1());
statement.setInt(4, homunculus.getSkillLevel2());
statement.setInt(5, homunculus.getSkillLevel3());
statement.setInt(6, homunculus.getSkillLevel4());
statement.setInt(7, homunculus.getSkillLevel5());
statement.setInt(8, homunculus.isActive() ? 1 : 0);
statement.setInt(9, owner.getObjectId());
statement.setInt(10, homunculus.getSlot());
statement.setInt(11, homunculus.getId());
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not update homunculus list on owner id: " + owner.getObjectId());
return false;
}
return true;
}
private static class SingletonHolder
{
protected static final HomunculusManager INSTANCE = new HomunculusManager();
}
public static HomunculusManager getInstance()
{
return SingletonHolder.INSTANCE;
}
}

View File

@@ -230,6 +230,7 @@ import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.holders.SubClassHolder;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.holders.TrainingHolder;
import org.l2jmobius.gameserver.model.homunculus.HomunculusList;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.interfaces.ILocational;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
@@ -890,10 +891,7 @@ public class PlayerInstance extends Playable
private ScheduledFuture<?> _timedHuntingZoneTask = null;
private int _homunculusHpBonus;
private int _homunculusAtkBonus;
private int _homunculusDefBonus;
private float _homunculusCritBonus;
private final HomunculusList _homunculusList = new HomunculusList(this);
private final List<QuestTimer> _questTimers = new ArrayList<>();
private final List<TimerHolder<?>> _timerHolders = new ArrayList<>();
@@ -6787,7 +6785,7 @@ public class PlayerInstance extends Playable
player.setTrueHero(true);
}
player.calculateHomunculusBonuses();
player.getHomunculusList().restore();
// Recalculate all stats
player.getStat().recalculateStats(false);
@@ -14441,42 +14439,8 @@ public class PlayerInstance extends Playable
return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + zoneId, 0), 0);
}
public int getHomunculusHpBonus()
public HomunculusList getHomunculusList()
{
return _homunculusHpBonus;
}
public int getHomunculusAtkBonus()
{
return _homunculusAtkBonus;
}
public int getHomunculusDefBonus()
{
return _homunculusDefBonus;
}
public float getHomunculusCritBonus()
{
return _homunculusCritBonus;
}
public void calculateHomunculusBonuses()
{
if (getVariables().getInt(PlayerVariables.HOMUNCULUS_ID, 0) > 0)
{
final int quality = getVariables().getInt(PlayerVariables.HOMUNCULUS_QUALITY, 0);
_homunculusHpBonus = 800 + (quality * 100);
_homunculusAtkBonus = 100 + (quality * 25);
_homunculusDefBonus = 80 + (quality * 10);
_homunculusCritBonus = 0.1f * (quality + 1);
}
else
{
_homunculusHpBonus = 0;
_homunculusAtkBonus = 0;
_homunculusDefBonus = 0;
_homunculusCritBonus = 0;
}
return _homunculusList;
}
}

View File

@@ -0,0 +1,254 @@
/*
* 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 org.l2jmobius.gameserver.model.homunculus;
/**
* @author nexvill
*/
public class Homunculus implements Comparable<Homunculus>
{
private final HomunculusTemplate _template;
private int _slot;
private int _level;
private int _exp;
private int _skillLevel1;
private int _skillLevel2;
private int _skillLevel3;
private int _skillLevel4;
private int _skillLevel5;
private boolean _isActive;
public Homunculus(HomunculusTemplate template, int slot, int level, int exp, int skillLevel1, int skillLevel2, int skillLevel3, int skillLevel4, int skillLevel5, boolean isActive)
{
_template = template;
_slot = slot;
_level = level;
_exp = exp;
_skillLevel1 = skillLevel1;
_skillLevel2 = skillLevel2;
_skillLevel3 = skillLevel3;
_skillLevel4 = skillLevel4;
_skillLevel5 = skillLevel5;
_isActive = isActive;
}
public HomunculusTemplate getTemplate()
{
return _template;
}
public int getId()
{
return _template.getId();
}
public int getType()
{
return _template.getType();
}
public void setSlot(int slot)
{
_slot = slot;
}
public int getSlot()
{
return _slot;
}
public void setLevel(int level)
{
_level = level;
}
public int getLevel()
{
return _level;
}
public void setExp(int exp)
{
_exp = exp;
}
public int getExp()
{
return _exp;
}
public void setSkillLevel1(int level)
{
_skillLevel1 = level;
}
public int getSkillLevel1()
{
return _skillLevel1;
}
public void setSkillLevel2(int level)
{
_skillLevel2 = level;
}
public int getSkillLevel2()
{
return _skillLevel2;
}
public void setSkillLevel3(int level)
{
_skillLevel3 = level;
}
public int getSkillLevel3()
{
return _skillLevel3;
}
public void setSkillLevel4(int level)
{
_skillLevel4 = level;
}
public int getSkillLevel4()
{
return _skillLevel4;
}
public void setSkillLevel5(int level)
{
_skillLevel5 = level;
}
public int getSkillLevel5()
{
return _skillLevel5;
}
public int getHp()
{
switch (_level)
{
case 1:
{
return _template.getHpLevel1();
}
case 2:
{
return _template.getHpLevel2();
}
case 3:
{
return _template.getHpLevel3();
}
case 4:
{
return _template.getHpLevel4();
}
case 5:
{
return _template.getHpLevel5();
}
}
return _template.getHpLevel1();
}
public int getAtk()
{
switch (_level)
{
case 1:
{
return _template.getAtkLevel1();
}
case 2:
{
return _template.getAtkLevel2();
}
case 3:
{
return _template.getAtkLevel3();
}
case 4:
{
return _template.getAtkLevel4();
}
case 5:
{
return _template.getAtkLevel5();
}
}
return _template.getAtkLevel1();
}
public int getDef()
{
switch (_level)
{
case 1:
{
return _template.getDefLevel1();
}
case 2:
{
return _template.getDefLevel2();
}
case 3:
{
return _template.getDefLevel3();
}
case 4:
{
return _template.getDefLevel4();
}
case 5:
{
return _template.getDefLevel5();
}
}
return _template.getDefLevel1();
}
public int getCritRate()
{
return _template.getCritRate();
}
public void setActive(boolean active)
{
_isActive = active;
}
public boolean isActive()
{
return _isActive;
}
@Override
public String toString()
{
return "Homunculus[id=" + _template.getId() + ", isActive=" + _isActive + "]";
}
@Override
public int compareTo(Homunculus o)
{
return getId() - o.getId();
}
}

View File

@@ -0,0 +1,411 @@
/*
* 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 org.l2jmobius.gameserver.model.homunculus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.HomunculusManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* @author nexvill
*/
public class HomunculusList
{
private static final Logger LOGGER = Logger.getLogger(HomunculusList.class.getName());
public static final int MAX_SIZE = 2;
private List<Homunculus> _homunculusList = Collections.emptyList();
private int _hp;
private int _atk;
private int _def;
private int _critRate;
private final PlayerInstance _owner;
private final Map<Integer, SkillHolder> _skills = new HashMap<>();
public HomunculusList(PlayerInstance owner)
{
_owner = owner;
}
public void restore()
{
_homunculusList = new ArrayList<>();
final List<Homunculus> homunculuses = HomunculusManager.getInstance().select(_owner);
for (Homunculus homunculus : homunculuses)
{
_homunculusList.add(homunculus);
}
Collections.sort(_homunculusList);
if (_homunculusList.size() > MAX_SIZE)
{
LOGGER.warning(this + ": Contains more than two homunculus's!");
for (int i = MAX_SIZE; i < _homunculusList.size(); i++)
{
_homunculusList.remove(i);
}
}
refreshStats(false);
}
public Homunculus get(int slot)
{
for (Homunculus homunculus : _homunculusList)
{
if (homunculus.getSlot() == slot)
{
return homunculus;
}
}
return null;
}
public int size()
{
return _homunculusList.size();
}
public int getFreeSize()
{
return Math.max(0, MAX_SIZE - size());
}
public boolean isFull()
{
return getFreeSize() == 0;
}
public boolean add(Homunculus homunculus)
{
if (isFull())
{
return false;
}
if (HomunculusManager.getInstance().insert(_owner, homunculus))
{
_homunculusList.add(homunculus);
Collections.sort(_homunculusList);
if (refreshStats(true))
{
_owner.sendSkillList();
}
return true;
}
return false;
}
public boolean update(Homunculus homunculus)
{
return HomunculusManager.getInstance().update(_owner, homunculus);
}
public boolean remove(Homunculus homunculus)
{
if (!remove0(homunculus))
{
return false;
}
if (refreshStats(true))
{
_owner.sendSkillList();
}
return true;
}
private boolean remove0(Homunculus homunculus)
{
if (!_homunculusList.remove(homunculus))
{
return false;
}
Collections.sort(_homunculusList);
return HomunculusManager.getInstance().delete(_owner, homunculus);
}
public boolean refreshStats(boolean send)
{
_hp = 0;
_atk = 0;
_def = 0;
_critRate = 0;
boolean updateSkillList = false;
for (int skillId : _skills.keySet())
{
if (_owner.removeSkill(skillId, false) != null)
{
updateSkillList = true;
}
}
_skills.clear();
for (Homunculus homunculus : _homunculusList)
{
if (!homunculus.isActive())
{
continue;
}
switch (homunculus.getLevel())
{
case 1:
{
_hp = homunculus.getTemplate().getHpLevel1();
_atk = homunculus.getTemplate().getAtkLevel1();
_def = homunculus.getTemplate().getDefLevel1();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 2:
{
_hp = homunculus.getTemplate().getHpLevel2();
_atk = homunculus.getTemplate().getAtkLevel2();
_def = homunculus.getTemplate().getDefLevel2();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 3:
{
_hp = homunculus.getTemplate().getHpLevel3();
_atk = homunculus.getTemplate().getAtkLevel3();
_def = homunculus.getTemplate().getDefLevel3();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel3() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId3(), homunculus.getSkillLevel3());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 4:
{
_hp = homunculus.getTemplate().getHpLevel4();
_atk = homunculus.getTemplate().getAtkLevel4();
_def = homunculus.getTemplate().getDefLevel4();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel3() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId3(), homunculus.getSkillLevel3());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel4() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId4(), homunculus.getSkillLevel4());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 5:
{
_hp = homunculus.getTemplate().getHpLevel5();
_atk = homunculus.getTemplate().getAtkLevel5();
_def = homunculus.getTemplate().getDefLevel5();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel3() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId3(), homunculus.getSkillLevel3());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel4() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId4(), homunculus.getSkillLevel4());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel5() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId5(), homunculus.getSkillLevel5());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
}
_critRate = homunculus.getTemplate().getCritRate();
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getBasicSkillId(), homunculus.getTemplate().getBasicSkillLevel());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
for (SkillHolder skillEntry : _skills.values())
{
_owner.addSkill(skillEntry.getSkill(), false);
}
if (!_skills.isEmpty())
{
updateSkillList = true;
}
if (send)
{
_owner.broadcastUserInfo();
}
return updateSkillList;
}
public int getHp()
{
return _hp;
}
public int getAtk()
{
return _atk;
}
public int getDef()
{
return _def;
}
public int getCritRate()
{
return _critRate;
}
@Override
public String toString()
{
return "HomunculusList[owner=" + _owner.getName() + "]";
}
}

View File

@@ -0,0 +1,238 @@
/*
* 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 org.l2jmobius.gameserver.model.homunculus;
/**
* @author nexvill
**/
public class HomunculusTemplate
{
private final int _id;
private final int _type;
private final int _basicSkillId;
private final int _basicSkillLevel;
private final int _skillId1;
private final int _skillId2;
private final int _skillId3;
private final int _skillId4;
private final int _skillId5;
private final int _hpLevel1;
private final int _atkLevel1;
private final int _defLevel1;
private final int _expToLevel2;
private final int _hpLevel2;
private final int _atkLevel2;
private final int _defLevel2;
private final int _expToLevel3;
private final int _hpLevel3;
private final int _atkLevel3;
private final int _defLevel3;
private final int _expToLevel4;
private final int _hpLevel4;
private final int _atkLevel4;
private final int _defLevel4;
private final int _expToLevel5;
private final int _hpLevel5;
private final int _atkLevel5;
private final int _defLevel5;
private final int _expToLevel6;
private final int _critRate;
public HomunculusTemplate(int id, int type, int basicSkillId, int basicSkillLevel, int skillId1, int skillId2, int skillId3, int skillId4, int skillId5, int hpLevel1, int atkLevel1, int defLevel1, int expToLevel2, int hpLevel2, int atkLevel2, int defLevel2, int expToLevel3, int hpLevel3, int atkLevel3, int defLevel3, int expToLevel4, int hpLevel4, int atkLevel4, int defLevel4, int expToLevel5, int hpLevel5, int atkLevel5, int defLevel5, int expToLevel6, int critRate)
{
_id = id;
_type = type;
_basicSkillId = basicSkillId;
_basicSkillLevel = basicSkillLevel;
_skillId1 = skillId1;
_skillId2 = skillId2;
_skillId3 = skillId3;
_skillId4 = skillId4;
_skillId5 = skillId5;
_hpLevel1 = hpLevel1;
_atkLevel1 = atkLevel1;
_defLevel1 = defLevel1;
_expToLevel2 = expToLevel2;
_hpLevel2 = hpLevel2;
_atkLevel2 = atkLevel2;
_defLevel2 = defLevel2;
_expToLevel3 = expToLevel3;
_hpLevel3 = hpLevel3;
_atkLevel3 = atkLevel3;
_defLevel3 = defLevel3;
_expToLevel4 = expToLevel4;
_hpLevel4 = hpLevel4;
_atkLevel4 = atkLevel4;
_defLevel4 = defLevel4;
_expToLevel5 = expToLevel5;
_hpLevel5 = hpLevel5;
_atkLevel5 = atkLevel5;
_defLevel5 = defLevel5;
_expToLevel6 = expToLevel6;
_critRate = critRate;
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public int getBasicSkillId()
{
return _basicSkillId;
}
public int getBasicSkillLevel()
{
return _basicSkillLevel;
}
public int getSkillId1()
{
return _skillId1;
}
public int getSkillId2()
{
return _skillId2;
}
public int getSkillId3()
{
return _skillId3;
}
public int getSkillId4()
{
return _skillId4;
}
public int getSkillId5()
{
return _skillId5;
}
public int getHpLevel1()
{
return _hpLevel1;
}
public int getHpLevel2()
{
return _hpLevel2;
}
public int getHpLevel3()
{
return _hpLevel3;
}
public int getHpLevel4()
{
return _hpLevel4;
}
public int getHpLevel5()
{
return _hpLevel5;
}
public int getAtkLevel1()
{
return _atkLevel1;
}
public int getAtkLevel2()
{
return _atkLevel2;
}
public int getAtkLevel3()
{
return _atkLevel3;
}
public int getAtkLevel4()
{
return _atkLevel4;
}
public int getAtkLevel5()
{
return _atkLevel5;
}
public int getDefLevel1()
{
return _defLevel1;
}
public int getDefLevel2()
{
return _defLevel2;
}
public int getDefLevel3()
{
return _defLevel3;
}
public int getDefLevel4()
{
return _defLevel4;
}
public int getDefLevel5()
{
return _defLevel5;
}
public int getExpToLevel2()
{
return _expToLevel2;
}
public int getExpToLevel3()
{
return _expToLevel3;
}
public int getExpToLevel4()
{
return _expToLevel4;
}
public int getExpToLevel5()
{
return _expToLevel5;
}
public int getExpToLevel6()
{
return _expToLevel6;
}
public int getCritRate()
{
return _critRate;
}
}

View File

@@ -41,8 +41,6 @@ public class MAttackFinalizer implements IStatFunction
{
// Enchanted chest bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_CHEST, Item.SLOT_FULL_ARMOR);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusAtkBonus();
}
if (Config.CHAMPION_ENABLE && creature.isChampion())

View File

@@ -40,9 +40,6 @@ public class MCritRateFinalizer implements IStatFunction
{
// Enchanted legs bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_LEGS);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusCritBonus();
}
final double witBonus = creature.getWIT() > 0 ? BaseStat.WIT.calcBonus(creature) : 1.;

View File

@@ -76,9 +76,6 @@ public class MDefenseFinalizer implements IStatFunction
}
baseValue *= BaseStat.CHA.calcBonus(creature);
// Bonus from Homunculus.
baseValue += player.getHomunculusDefBonus();
}
else if (creature.isPet() && (creature.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK) != 0))
{

View File

@@ -52,8 +52,6 @@ public class MaxHpFinalizer implements IStatFunction
{
baseValue = player.getTemplate().getBaseHpMax(player.getLevel());
}
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusHpBonus();
}
final double chaBonus = creature.isPlayer() ? BaseStat.CHA.calcBonus(creature) : 1.;

View File

@@ -41,8 +41,6 @@ public class PAttackFinalizer implements IStatFunction
{
// Enchanted chest bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_CHEST, Item.SLOT_FULL_ARMOR);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusAtkBonus();
}
if (Config.CHAMPION_ENABLE && creature.isChampion())

View File

@@ -40,9 +40,6 @@ public class PCriticalRateFinalizer implements IStatFunction
{
// Enchanted legs bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_LEGS);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusCritBonus();
}
final double dexBonus = creature.getDEX() > 0 ? BaseStat.DEX.calcBonus(creature) : 1.;
return validateValue(creature, Stat.defaultValue(creature, stat, baseValue * dexBonus * 10), 0, creature.isPlayer() ? Config.MAX_PCRIT_RATE : Double.MAX_VALUE);

View File

@@ -79,9 +79,6 @@ public class PDefenseFinalizer implements IStatFunction
}
}
baseValue *= BaseStat.CHA.calcBonus(creature);
// Bonus from Homunculus.
baseValue += player.getHomunculusDefBonus();
}
}
if (creature.isRaid())

View File

@@ -65,13 +65,17 @@ public class PlayerVariables extends AbstractVariables
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
public static final String HOMUNCULUS_STATUS = "HOMUNCULUS_STATUS";
public static final String HOMUNCULUS_TIME = "HOMUNCULUS_TIME";
public static final String HOMUNCULUS_HP = "HOMUNCULUS_HP";
public static final String HOMUNCULUS_SP = "HOMUNCULUS_SP";
public static final String HOMUNCULUS_VP = "HOMUNCULUS_VP";
public static final String HOMUNCULUS_ID = "HOMUNCULUS";
public static final String HOMUNCULUS_QUALITY = "HOMUNCULUS_QUALITY";
public static final String HOMUNCULUS_HP_POINTS = "HOMUNCULUS_HP_POINTS";
public static final String HOMUNCULUS_SP_POINTS = "HOMUNCULUS_SP_POINTS";
public static final String HOMUNCULUS_VP_POINTS = "HOMUNCULUS_VP_POINTS";
public static final String HOMUNCULUS_CREATION_TIME = "HOMUNCULUS_CREATION_TIME";
public static final String HOMUNCULUS_UPGRADE_POINTS = "HOMUNCULUS_UPGRADE_POINTS";
public static final String HOMUNCULUS_KILLED_MOBS = "HOMUNCULUS_KILLED_MOBS";
public static final String HOMUNCULUS_USED_KILL_CONVERT = "HOMUNCULUS_USED_KILL_CONVERT";
public static final String HOMUNCULUS_USED_RESET_KILLS = "HOMUNCULUS_USED_RESET_KILLS";
public static final String HOMUNCULUS_USED_VP_POINTS = "HOMUNCULUS_USED_VP_POINTS";
public static final String HOMUNCULUS_USED_VP_CONVERT = "HOMUNCULUS_USED_VP_CONVERT";
public static final String HOMUNCULUS_USED_RESET_VP = "HOMUNCULUS_USED_RESET_VP";
private final int _objectId;

View File

@@ -75,17 +75,17 @@ import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExt
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusCreateStart;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusDeleteData;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEnchantExperience;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEnchantPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEnchantSkill;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvolve;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusInitPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusInsert;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusSummon;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExRequestHomonculusList;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExRequestHomunculusActivate;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExActivateHomunculus;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExDeleteHomunculusData;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExEnchantHomunculusSkill;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusCreateStart;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusEnchantExp;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusGetEnchantPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusInitPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusInsert;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusSummon;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExShowHomunculusInfo;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
@@ -565,17 +565,17 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_AUTH_RECONNECT(0x1A4, null, ConnectionState.IN_GAME),
EX_PET_EQUIP_ITEM(0x1A5, null, ConnectionState.IN_GAME),
EX_PET_UNEQUIP_ITEM(0x1A6, null, ConnectionState.IN_GAME),
EX_SHOW_HOMUNCULUS_INFO(0x1A7, ExRequestHomonculusList::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_CREATE_START(0x1A8, ExHomunculusCreateStart::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INSERT(0x1A9, ExHomunculusInsert::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_SUMMON(0x1AA, ExHomunculusSummon::new, ConnectionState.IN_GAME),
EX_DELETE_HOMUNCULUS_DATA(0x1AB, ExHomunculusDeleteData::new, ConnectionState.IN_GAME),
EX_REQUEST_ACTIVATE_HOMUNCULUS(0x1AC, ExRequestHomunculusActivate::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_GET_ENCHANT_POINT(0x1AD, ExHomunculusEnchantPoint::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INIT_POINT(0x1AE, ExHomunculusInitPoint::new, ConnectionState.IN_GAME),
EX_SHOW_HOMUNCULUS_INFO(0x1A7, RequestExShowHomunculusInfo::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_CREATE_START(0x1A8, RequestExHomunculusCreateStart::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INSERT(0x1A9, RequestExHomunculusInsert::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_SUMMON(0x1AA, RequestExHomunculusSummon::new, ConnectionState.IN_GAME),
EX_DELETE_HOMUNCULUS_DATA(0x1AB, RequestExDeleteHomunculusData::new, ConnectionState.IN_GAME),
EX_REQUEST_ACTIVATE_HOMUNCULUS(0x1AC, RequestExActivateHomunculus::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_GET_ENCHANT_POINT(0x1AD, RequestExHomunculusGetEnchantPoint::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INIT_POINT(0x1AE, RequestExHomunculusInitPoint::new, ConnectionState.IN_GAME),
EX_EVOLVE_PET(0x1AF, ExHomunculusEvolve::new, ConnectionState.IN_GAME),
EX_ENCHANT_HOMUNCULUS_SKILL(0x1B0, ExHomunculusEnchantSkill::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_ENCHANT_EXP(0x1B1, ExHomunculusEnchantExperience::new, ConnectionState.IN_GAME),
EX_ENCHANT_HOMUNCULUS_SKILL(0x1B0, RequestExEnchantHomunculusSkill::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_ENCHANT_EXP(0x1B1, RequestExHomunculusEnchantExp::new, ConnectionState.IN_GAME),
EX_TELEPORT_FAVORITES_LIST(0x1B2, ExRequestTeleportFavoriteList::new, ConnectionState.IN_GAME),
EX_TELEPORT_FAVORITES_UI_TOGGLE(0x1B3, ExRequestTeleportFavoritesUIToggle::new, ConnectionState.IN_GAME),
EX_TELEPORT_FAVORITES_ADD_DEL(0x1B4, ExRequestTeleportFavoritesAddDel::new, ConnectionState.IN_GAME),

View File

@@ -882,7 +882,7 @@ public enum OutgoingPackets
EX_SHARED_POSITION_TELEPORT_UI(0xFE, 0x253),
EX_CHAR_INFO(0xFE, 0x254),
EX_AUTH_RECONNECT(0xFE, 0x255),
EX_SHOW_BIRTH_INFO(0xFE, 0x256),
EX_SHOW_HOMUNCULUS_BIRTH_INFO(0xFE, 0x256),
EX_HOMUNCULUS_CREATE_START_RESULT(0xFE, 0x257),
EX_HOMUNCULUS_INSERT_RESULT(0xFE, 0x258),
EX_HOMUNCULUS_SUMMON_RESULT(0xFE, 0x259),

View File

@@ -110,9 +110,9 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillList;
import org.l2jmobius.gameserver.network.serverpackets.attendance.ExVipAttendanceItemList;
import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.util.BuilderUtil;
/**
@@ -327,9 +327,9 @@ public class EnterWorld implements IClientIncomingPacket
}
// Enable Homunculus system.
player.sendPacket(new ExHomonculusBirthInfo(player));
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExHomunculusPointInfo(player));
player.sendPacket(new ExHomunculusReady(player));
player.sendPacket(new ExHomunculusReady(true));
// Send time.
player.sendPacket(new ExEnterWorld());

View File

@@ -1,47 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
/**
* @author Mobius
*/
public class ExHomunculusEnchantPoint implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new ExHomunculusPointInfo(player));
}
}

View File

@@ -1,47 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
/**
* @author Mobius
*/
public class ExHomunculusEnchantSkill implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExHomonculusList(player));
}
}

View File

@@ -20,7 +20,7 @@ import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
@@ -42,6 +42,6 @@ public class ExHomunculusEvolve implements IClientIncomingPacket
return;
}
client.sendPacket(new ExHomonculusList(player));
client.sendPacket(new ExShowHomunculusList(player));
}
}

View File

@@ -1,149 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusInsertHpSpVp;
/**
* @author Mobius
*/
public class ExHomunculusInsert implements IClientIncomingPacket
{
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final int time = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_TIME, 0);
if (((Chronos.currentTimeMillis() / 1000) - time) < 86400)
{
player.sendMessage("Waiting time has not passed.");
return;
}
switch (_type)
{
case 0: // hp
{
if (player.getCurrentHp() >= 10000)
{
player.setCurrentHp(player.getCurrentHp() - 10000);
final int hp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP, 0);
if (hp < 99)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP, hp + 1);
}
else
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP, 100);
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status == 1)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 2);
}
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
}
else
{
return;
}
break;
}
case 1: // sp
{
if (player.getSp() >= 5000000000L)
{
player.setSp(player.getSp() - 5000000000L);
final int sp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP, 0);
if (sp < 9)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP, sp + 1);
}
else
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP, 10);
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status == 1)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 2);
}
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
}
else
{
return;
}
break;
}
case 2: // vp
{
if (player.getVitalityPoints() >= 35000)
{
player.setVitalityPoints(player.getVitalityPoints() - 35000, true);
final int vp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP, 0);
if (vp < 4)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP, vp + 1);
}
else
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP, 5);
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status == 1)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 2);
}
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
}
else
{
return;
}
break;
}
}
player.sendPacket(new ExHomunculusInsertHpSpVp(player));
player.sendPacket(new ExHomonculusBirthInfo(player));
}
}

View File

@@ -1,78 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusSummonResult;
/**
* @author Mobius
*/
public class ExHomunculusSummon implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final int homunculus = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_ID, 0);
if (homunculus == 0)
{
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
final int hp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP, 0);
final int sp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP, 0);
final int vp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP, 0);
if ((status == 2) && ((hp == 100) || (sp == 10) || (vp == 5)))
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_ID, 1);
int quality = 2;
if (Rnd.get(100) < 50)
{
quality = 0;
}
else if (Rnd.get(100) < 30)
{
quality = 1;
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_QUALITY, quality);
player.calculateHomunculusBonuses();
player.getStat().recalculateStats(true);
}
}
client.sendPacket(new ExHomonculusSummonResult(player));
client.sendPacket(new ExHomonculusList(player));
}
}

View File

@@ -1,48 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
/**
* @author Mobius
*/
public class ExRequestHomonculusList implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD(); // ?
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExHomonculusList(player));
}
}

View File

@@ -1,49 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusActivateResult;
/**
* @author Mobius
*/
public class ExRequestHomunculusActivate implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD();
packet.readC(); // enabled?
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExHomonculusActivateResult(player));
}
}

View File

@@ -0,0 +1,94 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExActivateHomunculusResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class RequestExActivateHomunculus implements IClientIncomingPacket
{
private int _slot;
private boolean _activate;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD();
_activate = packet.readC() == 1 ? true : false; // enabled?
return true;
}
@Override
public void run(GameClient client)
{
PlayerInstance activeChar = client.getPlayer();
if (activeChar == null)
{
return;
}
final Homunculus homunculus = activeChar.getHomunculusList().get(_slot);
boolean anotherActive = false;
int size = activeChar.getHomunculusList().size();
if (size > 1)
{
if (_slot == 0)
{
if (activeChar.getHomunculusList().get(1).isActive())
{
anotherActive = true;
}
}
else
{
if (activeChar.getHomunculusList().get(0).isActive())
{
anotherActive = true;
}
}
}
if (anotherActive)
{
return;
}
if (!homunculus.isActive() && _activate)
{
homunculus.setActive(true);
activeChar.getHomunculusList().update(homunculus);
activeChar.getHomunculusList().refreshStats(true);
activeChar.sendPacket(new ExShowHomunculusList(activeChar));
activeChar.sendPacket(new ExActivateHomunculusResult(true));
}
else if (homunculus.isActive() && !_activate)
{
homunculus.setActive(false);
activeChar.getHomunculusList().update(homunculus);
activeChar.getHomunculusList().refreshStats(true);
activeChar.sendPacket(new ExShowHomunculusList(activeChar));
activeChar.sendPacket(new ExActivateHomunculusResult(false));
}
}
}

View File

@@ -18,18 +18,23 @@ package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExDeleteHomunculusDataResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class ExHomunculusEnchantExperience implements IClientIncomingPacket
public class RequestExDeleteHomunculusData implements IClientIncomingPacket
{
private int _slot;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD(); // Position?
return true;
}
@@ -42,6 +47,11 @@ public class ExHomunculusEnchantExperience implements IClientIncomingPacket
return;
}
client.sendPacket(new ExHomonculusList(player));
final Homunculus homunculus = player.getHomunculusList().get(_slot);
if (player.getHomunculusList().remove(homunculus))
{
player.sendPacket(new ExDeleteHomunculusDataResult());
player.sendPacket(new ExShowHomunculusList(player));
}
}
}

View File

@@ -21,18 +21,27 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExEnchantHomunculusSkillResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusHPSPVP;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class ExHomunculusDeleteData implements IClientIncomingPacket
public class RequestExEnchantHomunculusSkill implements IClientIncomingPacket
{
private static final int SP_COST = 1000000000;
private int _slot;
private int _skillNumber;
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD(); // Position?
packet.readD();
_slot = packet.readD();
_skillNumber = packet.readD();
return true;
}
@@ -45,18 +54,22 @@ public class ExHomunculusDeleteData implements IClientIncomingPacket
return;
}
player.getVariables().remove(PlayerVariables.HOMUNCULUS_STATUS);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_TIME);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_HP);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_SP);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_VP);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_ID);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_QUALITY);
if (player.getSp() < SP_COST)
{
return;
}
player.calculateHomunculusBonuses();
player.getStat().recalculateStats(true);
int points = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0);
if (points < 1)
{
player.sendMessage("Not enough upgrade points.");
return;
}
client.sendPacket(new ExHomonculusList(player));
client.sendPacket(new ExHomonculusBirthInfo(player));
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, points - 1);
player.sendPacket(new ExEnchantHomunculusSkillResult(player, _slot, _skillNumber));
player.sendPacket(new ExHomunculusHPSPVP(player));
player.sendPacket(new ExShowHomunculusList(player));
player.sendPacket(new ExHomunculusPointInfo(player));
}
}

View File

@@ -23,15 +23,16 @@ import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusCreateStartResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusCreateStartResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
/**
* @author Mobius
*/
public class ExHomunculusCreateStart implements IClientIncomingPacket
public class RequestExHomunculusCreateStart implements IClientIncomingPacket
{
private static final int COST = 1000000;
private static final long CREATION_TIME = 86400000L;
@Override
public boolean read(GameClient client, PacketReader packet)
@@ -48,22 +49,15 @@ public class ExHomunculusCreateStart implements IClientIncomingPacket
return;
}
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status > 0)
{
return;
}
if (player.getAdena() < COST)
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA_2);
return;
}
player.reduceAdena("Homunculus creation", COST, player, true);
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 1);
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
player.getVariables().set(PlayerVariables.HOMUNCULUS_CREATION_TIME, Chronos.currentTimeMillis() + CREATION_TIME);
client.sendPacket(new ExHomonculusBirthInfo(player));
client.sendPacket(new ExHomonculusCreateStartResult(player));
client.sendPacket(new ExShowHomunculusBirthInfo(player));
client.sendPacket(new ExHomunculusCreateStartResult(player));
}
}

View File

@@ -0,0 +1,124 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusEnchantEXPResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class RequestExHomunculusEnchantExp implements IClientIncomingPacket
{
private static final int EXP_PER_POINT = 750;
private int _slot;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) == 0)
{
player.sendPacket(new ExHomunculusEnchantEXPResult(false, false));
}
else
{
int points = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) - 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, points);
final Homunculus homunculus = player.getHomunculusList().get(_slot);
homunculus.setExp(homunculus.getExp() + EXP_PER_POINT);
player.sendPacket(new ExHomunculusPointInfo(player));
switch (homunculus.getLevel())
{
case 1:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel2())
{
homunculus.setLevel(2);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
case 2:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel3())
{
homunculus.setLevel(3);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
case 3:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel4())
{
homunculus.setLevel(4);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
case 4:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel5())
{
homunculus.setLevel(5);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
}
player.getHomunculusList().update(homunculus);
player.getHomunculusList().refreshStats(true);
player.sendPacket(new ExShowHomunculusList(player));
}
}
}

View File

@@ -0,0 +1,110 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusGetEnchantPointResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusHPSPVP;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
/**
* @author Mobius
*/
public class RequestExHomunculusGetEnchantPoint implements IClientIncomingPacket
{
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (_type == 0) // mobs
{
int killedMobs = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_KILLED_MOBS, 0);
if (killedMobs < 500)
{
return;
}
int usedKillConverts = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0);
if (usedKillConverts >= 5)
{
return;
}
int upgradePoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) + 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, upgradePoints);
player.getVariables().set(PlayerVariables.HOMUNCULUS_KILLED_MOBS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, usedKillConverts + 1);
}
else if (_type == 1) // vitality
{
int usedVpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0);
if (usedVpPoints < 2)
{
return;
}
int usedVpConverts = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0);
if (usedVpConverts >= 5)
{
return;
}
int upgradePoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) + 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, upgradePoints);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, usedVpConverts + 1);
}
else if (_type == 2) // vitality consume
{
int usedVpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0);
if (usedVpPoints >= 2)
{
return;
}
if (player.getVitalityPoints() >= (PlayerStat.MAX_VITALITY_POINTS / 4))
{
player.setVitalityPoints(player.getVitalityPoints() - (PlayerStat.MAX_VITALITY_POINTS / 4), false);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, usedVpPoints + 1);
}
}
if (_type == 2)
{
player.sendPacket(new ExHomunculusHPSPVP(player));
}
player.sendPacket(new ExHomunculusPointInfo(player));
player.sendPacket(new ExHomunculusGetEnchantPointResult(_type));
}
}

View File

@@ -0,0 +1,86 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusInitPointResult;
/**
* @author Mobius
*/
public class RequestExHomunculusInitPoint implements IClientIncomingPacket
{
private static final int POWERFUL_FISH = 47552;
private static final int FISH_COUNT = 5;
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (_type == 0)
{
final int usedResetKills = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, 0);
final int usedKillConvert = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0);
if (((player.getInventory().getItemByItemId(POWERFUL_FISH) != null) && (player.getInventory().getItemByItemId(POWERFUL_FISH).getCount() < FISH_COUNT)) //
|| ((usedResetKills <= 3) && (usedKillConvert == 0)))
{
player.sendPacket(new ExHomunculusInitPointResult(false, _type));
}
else if ((usedResetKills <= 3) && (usedKillConvert == 5))
{
player.destroyItemByItemId("Homunculus Points", POWERFUL_FISH, FISH_COUNT, player, true);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, usedResetKills + 1);
player.sendPacket(new ExHomunculusInitPointResult(true, _type));
}
}
else
{
final int usedResetVp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_RESET_VP, 0);
final int usedVpConvert = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0);
if (((player.getInventory().getItemByItemId(POWERFUL_FISH) != null) && (player.getInventory().getItemByItemId(POWERFUL_FISH).getCount() < FISH_COUNT)) //
|| ((usedResetVp <= 3) && (usedVpConvert == 0)))
{
player.sendPacket(new ExHomunculusInitPointResult(false, _type));
}
else if ((usedResetVp <= 3) && (usedVpConvert == 5))
{
player.destroyItemByItemId("Homunculus Points", POWERFUL_FISH, FISH_COUNT, player, true);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_VP, usedResetVp + 1);
player.sendPacket(new ExHomunculusInitPointResult(true, _type));
}
}
}
}

View File

@@ -0,0 +1,109 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusHPSPVP;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusInsertResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
/**
* @author Mobius
*/
public class RequestExHomunculusInsert implements IClientIncomingPacket
{
private static final short HP_COST = 10000;
private static final long SP_COST = 5000000000L;
private static final int VP_COST = PlayerStat.MAX_VITALITY_POINTS / 4;
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
int hpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
int spPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
int vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
switch (_type)
{
case 0:
{
if ((player.getCurrentHp() > HP_COST) && (hpPoints < 100))
{
int newHp = (int) (player.getCurrentHp()) - HP_COST;
player.setCurrentHp(newHp, true);
hpPoints += 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP_POINTS, hpPoints);
}
else
{
return;
}
break;
}
case 1:
{
if ((player.getSp() >= SP_COST) && (spPoints < 10))
{
player.addExpAndSp(0, -SP_COST);
spPoints += 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP_POINTS, spPoints);
}
else
{
return;
}
break;
}
case 2:
{
if ((player.getVitalityPoints() >= VP_COST) && (vpPoints < 5))
{
int newVitality = player.getVitalityPoints() - VP_COST;
player.setVitalityPoints(newVitality, true);
vpPoints += 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP_POINTS, vpPoints);
}
else
{
return;
}
break;
}
}
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExHomunculusHPSPVP(player));
player.sendPacket(new ExHomunculusInsertResult(_type));
}
}

View File

@@ -0,0 +1,157 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusSummonResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class RequestExHomunculusSummon implements IClientIncomingPacket
{
private static int _hpPoints;
private static int _spPoints;
private static int _vpPoints;
private static int _homunculusCreateTime;
@Override
public boolean read(GameClient client, PacketReader packet)
{
// packet.readC();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
_hpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
_spPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
_vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
_homunculusCreateTime = (int) (player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0) / 1000);
if (_homunculusCreateTime > 0)
{
if (((System.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
{
int homunculusId = 0;
final int chance = Rnd.get(100);
if (chance >= 60) // Basic Homunculus
{
int chance2 = Rnd.get(100);
if (chance2 >= 80)
{
homunculusId = 1;
}
else if (chance2 >= 60)
{
homunculusId = 4;
}
else if (chance2 >= 40)
{
homunculusId = 7;
}
else if (chance2 >= 20)
{
homunculusId = 10;
}
else
{
homunculusId = 13;
}
}
else if (chance >= 10) // Water Homunculus
{
int chance2 = Rnd.get(100);
if (chance2 >= 80)
{
homunculusId = 2;
}
else if (chance2 >= 60)
{
homunculusId = 5;
}
else if (chance2 >= 40)
{
homunculusId = 8;
}
else if (chance2 >= 20)
{
homunculusId = 11;
}
else
{
homunculusId = 14;
}
}
else // Luminous Homunculus
{
int chance2 = Rnd.get(100);
if (chance2 >= 80)
{
homunculusId = 3;
}
else if (chance2 >= 60)
{
homunculusId = 6;
}
else if (chance2 >= 40)
{
homunculusId = 9;
}
else if (chance2 >= 20)
{
homunculusId = 12;
}
else
{
homunculusId = 15;
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
final Homunculus homunculus = new Homunculus(template, player.getHomunculusList().size(), 1, 0, 0, 0, 0, 0, 0, false);
if (player.getHomunculusList().add(homunculus))
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExShowHomunculusList(player));
player.sendPacket(new ExHomunculusSummonResult());
}
}
}
}
}

View File

@@ -21,15 +21,20 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class ExHomunculusInitPoint implements IClientIncomingPacket
public class RequestExShowHomunculusInfo implements IClientIncomingPacket
{
private int _type; // 0 - create tab, 1 - manage tab, 2 - get upgrade points menu
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@@ -42,6 +47,23 @@ public class ExHomunculusInitPoint implements IClientIncomingPacket
return;
}
player.sendPacket(new ExHomunculusPointInfo(player));
switch (_type)
{
case 0:
{
player.sendPacket(new ExShowHomunculusBirthInfo(player));
break;
}
case 1:
{
player.sendPacket(new ExShowHomunculusList(player));
break;
}
case 2:
{
player.sendPacket(new ExHomunculusPointInfo(player));
break;
}
}
}
}

View File

@@ -17,21 +17,19 @@
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusActivateResult implements IClientOutgoingPacket
public class ExActivateHomunculusResult implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
private final boolean _activate;
public ExHomonculusActivateResult(PlayerInstance player)
public ExActivateHomunculusResult(boolean activate)
{
_player = player;
_activate = activate;
}
@Override
@@ -39,15 +37,17 @@ public class ExHomonculusActivateResult implements IClientOutgoingPacket
{
OutgoingPackets.EX_ACTIVATE_HOMUNCULUS_RESULT.writeId(packet);
// struct _C_EX_REQUEST_ACTIVATE_HOMUNCULUS
// {
// var int nIdx;
// var byte bActivate;
// };
packet.writeD(0x01);
packet.writeC(0x01);
packet.writeD(1); // success
if (_activate)
{
packet.writeC(1); // activate
packet.writeD(13246); // The relations are being established.
}
else
{
packet.writeC(0); // activate
packet.writeD(13247); // The relations are broken.
}
return true;
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExDeleteHomunculusDataResult implements IClientOutgoingPacket
{
public ExDeleteHomunculusDataResult()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ACTIVATE_HOMUNCULUS_RESULT.writeId(packet);
packet.writeD(1); // 1 - success
packet.writeD(13252); // The homunculus is destroyed.
return true;
}
}

View File

@@ -0,0 +1,103 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExEnchantHomunculusSkillResult implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final int _slot;
private final int _skillNumber;
public ExEnchantHomunculusSkillResult(PlayerInstance player, int slot, int skillNumber)
{
_player = player;
_slot = slot;
_skillNumber = skillNumber;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ENCHANT_HOMUNCULUS_SKILL_RESULT.writeId(packet);
final int playerNumber = Rnd.get(1, 6);
final int homunculusNumber = Rnd.get(1, 6);
final int systemNumber = Rnd.get(1, 6);
final Homunculus homunculus = _player.getHomunculusList().get(_slot);
int boundLevel = 1;
if ((playerNumber == homunculusNumber) && (playerNumber == systemNumber))
{
boundLevel = 3;
}
else if ((playerNumber == homunculusNumber) || (playerNumber == systemNumber) || (homunculusNumber == systemNumber))
{
boundLevel = 2;
}
switch (_skillNumber)
{
case 1:
{
homunculus.setSkillLevel1(boundLevel);
break;
}
case 2:
{
homunculus.setSkillLevel2(boundLevel);
break;
}
case 3:
{
homunculus.setSkillLevel3(boundLevel);
break;
}
case 4:
{
homunculus.setSkillLevel4(boundLevel);
break;
}
case 5:
{
homunculus.setSkillLevel5(boundLevel);
break;
}
}
_player.getHomunculusList().update(homunculus);
_player.getHomunculusList().refreshStats(true);
packet.writeD(boundLevel); // skill bound level result
packet.writeD(homunculus.getId()); // homunculus id? random value on JP
packet.writeD(_slot); // slot
packet.writeD(_skillNumber); // skill number
packet.writeD(playerNumber); // player number
packet.writeD(homunculusNumber); // homunculus number
packet.writeD(systemNumber); // system number
return true;
}
}

View File

@@ -1,58 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusBirthInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExHomonculusBirthInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_BIRTH_INFO.writeId(packet);
final int status = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
final int hp = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP, 0);
final int sp = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP, 0);
final int vp = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP, 0);
final int time = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_TIME, 0);
final long currentTime = Chronos.currentTimeMillis();
packet.writeD(status); // 0 = time idle, 1 = time updating, 2 = summon enabled
packet.writeD(hp); // hp 100
packet.writeD(sp); // sp 10
packet.writeD(vp); // vitality 5
packet.writeQ((currentTime / 1000) + (86400 - Math.min(86400, (currentTime / 1000) - time)));
return true;
}
}

View File

@@ -1,82 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusList implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExHomonculusList(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_HOMUNCULUS_LIST.writeId(packet);
final int homunculus = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_ID, 0);
if (homunculus > 0)
{
final int quality = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_QUALITY, 0);
packet.writeD(0x01); // Size.
packet.writeD(0x00); // nIdx
packet.writeD(homunculus); // nID
packet.writeD(quality); // eType
packet.writeC(0x01); // bActivate
packet.writeD(0x00); // m_nSkillID 0
packet.writeD(0x00); // m_nSkillID 1
packet.writeD(0x00); // m_nSkillID 2
packet.writeD(0x00); // m_nSkillID 3
packet.writeD(0x00); // m_nSkillID 4
packet.writeD(0x00); // m_nSkillID 5
packet.writeD(0x00); // m_nSkillLevel 0
packet.writeD(0x00); // m_nSkillLevel 1
packet.writeD(0x00); // m_nSkillLevel 2
packet.writeD(0x00); // m_nSkillLevel 3
packet.writeD(0x00); // m_nSkillLevel 4
packet.writeD(0x00); // m_nSkillLevel 5
packet.writeD(0x01); // m_nLevel
packet.writeD(0x00); // m_nExp
packet.writeD(_player.getHomunculusHpBonus()); // m_nHP
packet.writeD(_player.getHomunculusAtkBonus()); // m_nAttack
packet.writeD(_player.getHomunculusDefBonus()); // m_nDefence
packet.writeD((int) (_player.getHomunculusCritBonus() * 100)); // m_nCritical
}
else
{
packet.writeD(0); // Size.
}
return true;
}
}

View File

@@ -24,24 +24,20 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusCreateStartResult implements IClientOutgoingPacket
public class ExHomunculusCreateStartResult implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
public ExHomonculusCreateStartResult(PlayerInstance player)
public ExHomunculusCreateStartResult(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_CREATE_START_RESULT.writeId(packet);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(1); // 1 - success
packet.writeD(13254); // You've sealed a homunculus' heart. In order to create it, your blood, spirit and tears are required.
return true;
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExHomunculusEnchantEXPResult implements IClientOutgoingPacket
{
private final boolean _success;
private final boolean _newLevel;
public ExHomunculusEnchantEXPResult(boolean success, boolean newLevel)
{
_success = success;
_newLevel = newLevel;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_ENCHANT_EXP_RESULT.writeId(packet);
if (!_success)
{
packet.writeD(0);
packet.writeD(13248); // Not enough upgrade points.
}
else if (!_newLevel)
{
packet.writeD(1); // success
packet.writeD(0); // SystemMessageId
}
else
{
packet.writeD(1);
packet.writeD(13239); // The homunculus' level is increased!
}
return true;
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExHomunculusGetEnchantPointResult implements IClientOutgoingPacket
{
private final int _enchantType;
public ExHomunculusGetEnchantPointResult(int enchantType)
{
_enchantType = enchantType;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_GET_ENCHANT_POINT_RESULT.writeId(packet);
if (_enchantType != 2)
{
packet.writeD(1); // success
packet.writeD(_enchantType);
packet.writeD(13238); // You've obtained upgrade points.
}
else
{
packet.writeD(1);
packet.writeD(_enchantType);
packet.writeD(13272); // VP added.
}
return true;
}
}

View File

@@ -24,13 +24,17 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomunculusInsertHpSpVp implements IClientOutgoingPacket
public class ExHomunculusHPSPVP implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final int _hp;
private final long _sp;
private final int _vp;
public ExHomunculusInsertHpSpVp(PlayerInstance player)
public ExHomunculusHPSPVP(PlayerInstance player)
{
_player = player;
_hp = (int) player.getCurrentHp();
_sp = player.getSp();
_vp = player.getVitalityPoints();
}
@Override
@@ -38,9 +42,9 @@ public class ExHomunculusInsertHpSpVp implements IClientOutgoingPacket
{
OutgoingPackets.EX_HOMUNCULUS_HPSPVP.writeId(packet);
packet.writeD((int) _player.getCurrentHp());
packet.writeQ(_player.getSp());
packet.writeD(_player.getVitalityPoints());
packet.writeD(_hp);
packet.writeQ(_sp);
packet.writeD(_vp);
return true;
}

View File

@@ -0,0 +1,55 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExHomunculusInitPointResult implements IClientOutgoingPacket
{
private final boolean _success;
private final int _type;
public ExHomunculusInitPointResult(boolean success, int type)
{
_success = success;
_type = type;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_INIT_POINT_RESULT.writeId(packet);
if (_success)
{
packet.writeD(1); // success
packet.writeD(_type); // init type
packet.writeD(13244); // The received upgrade points are reset.
}
else
{
packet.writeD(0);
packet.writeD(_type);
packet.writeD(13243); // Not enough items for resetting.
}
return true;
}
}

View File

@@ -17,22 +17,18 @@
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusInsertResult implements IClientOutgoingPacket
public class ExHomunculusInsertResult implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
private final int _type;
public ExHomonculusInsertResult(PlayerInstance player, int type)
public ExHomunculusInsertResult(int type)
{
_player = player;
_type = type;
}
@@ -41,8 +37,19 @@ public class ExHomonculusInsertResult implements IClientOutgoingPacket
{
OutgoingPackets.EX_HOMUNCULUS_INSERT_RESULT.writeId(packet);
packet.writeD(0x01);
packet.writeD(_type);
packet.writeD(1); // 1 - success
if (_type == 0)
{
packet.writeD(13230); // The homunculus takes your blood (HP).
}
else if (_type == 1)
{
packet.writeD(13231); // The homunculus takes your spirit (SP).
}
else
{
packet.writeD(13232); // The homunculus takes your tears (VP).
}
return true;
}

View File

@@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
@@ -26,7 +27,6 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
*/
public class ExHomunculusPointInfo implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
public ExHomunculusPointInfo(PlayerInstance player)
@@ -38,15 +38,13 @@ public class ExHomunculusPointInfo implements IClientOutgoingPacket
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_POINT_INFO.writeId(packet);
packet.writeD(0); // enchant points
packet.writeD(0); // hunted monster points
packet.writeD(0); // points obtained
packet.writeD(0); // reset time
packet.writeD(0); // vitality points?
packet.writeD(0); // vitality points obtained?
packet.writeD(0); // vitality points reset time?
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0)); // points
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_KILLED_MOBS, 0)); // killed mobs
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0)); // consumed basic kill points
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, 0)); // consumed reset kill points?
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0)); // vp points
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0)); // consumed basic vp points
packet.writeD(_player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_RESET_VP, 0)); // consumed reset vp points
return true;
}
}

View File

@@ -17,7 +17,6 @@
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
@@ -26,19 +25,18 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
*/
public class ExHomunculusReady implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
private final boolean _enabled;
public ExHomunculusReady(PlayerInstance player)
public ExHomunculusReady(boolean enabled)
{
_player = player;
_enabled = enabled;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_READY.writeId(packet);
packet.writeC(0x01); // 1 = enabled, 0 = disabled
packet.writeC(_enabled ? 1 : 0);
return true;
}
}

View File

@@ -17,28 +17,22 @@
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
public class ExHomonculusSummonResult implements IClientOutgoingPacket
public class ExHomunculusSummonResult implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
public ExHomonculusSummonResult(PlayerInstance player)
public ExHomunculusSummonResult()
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_HOMUNCULUS_LIST.writeId(packet);
OutgoingPackets.EX_HOMUNCULUS_SUMMON_RESULT.writeId(packet);
packet.writeD(1);
packet.writeD(2);
packet.writeD(1); // Homunculus client id?
packet.writeD(1); // 1 - success
packet.writeD(13213); // A new homunculus is created
return true;
}

View File

@@ -0,0 +1,69 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExShowHomunculusBirthInfo implements IClientOutgoingPacket
{
private final int _hpPoints;
private final int _spPoints;
private final int _vpPoints;
private final int _homunculusCreateTime;
public ExShowHomunculusBirthInfo(PlayerInstance player)
{
_hpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
_spPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
_vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
_homunculusCreateTime = (int) (player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0) / 1000);
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_HOMUNCULUS_BIRTH_INFO.writeId(packet);
int creationStage = 0;
if (_homunculusCreateTime > 0)
{
if (((System.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
{
creationStage = 2;
}
else
{
creationStage = 1;
}
}
packet.writeD(creationStage); // in creation process (0: can create, 1: in process, 2: can awake
packet.writeD(_hpPoints); // hp points
packet.writeD(_spPoints); // sp points
packet.writeD(_vpPoints); // vp points
packet.writeD(_homunculusCreateTime); // finish time
packet.writeD(0); // JP = 0. ?
return true;
}
}

View File

@@ -0,0 +1,81 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExShowHomunculusList implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExShowHomunculusList(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_HOMUNCULUS_LIST.writeId(packet);
if (_player.getHomunculusList().size() > 0)
{
packet.writeD(_player.getHomunculusList().size()); // homunculus count
for (int i = 0; i < _player.getHomunculusList().size(); i++)
{
packet.writeD(i); // slot
final Homunculus homunculus = _player.getHomunculusList().get(i);
packet.writeD(homunculus.getId()); // homunculus id
packet.writeD(homunculus.getType());
packet.writeC(homunculus.isActive() ? 1 : 0);
packet.writeD(homunculus.getTemplate().getBasicSkillId());
packet.writeD(homunculus.getSkillLevel1() > 0 ? homunculus.getTemplate().getSkillId1() : 0);
packet.writeD(homunculus.getSkillLevel2() > 0 ? homunculus.getTemplate().getSkillId2() : 0);
packet.writeD(homunculus.getSkillLevel3() > 0 ? homunculus.getTemplate().getSkillId3() : 0);
packet.writeD(homunculus.getSkillLevel4() > 0 ? homunculus.getTemplate().getSkillId4() : 0);
packet.writeD(homunculus.getSkillLevel5() > 0 ? homunculus.getTemplate().getSkillId5() : 0);
packet.writeD(homunculus.getTemplate().getBasicSkillLevel());
packet.writeD(homunculus.getSkillLevel1());
packet.writeD(homunculus.getSkillLevel2());
packet.writeD(homunculus.getSkillLevel3());
packet.writeD(homunculus.getSkillLevel4());
packet.writeD(homunculus.getSkillLevel5());
packet.writeD(homunculus.getLevel());
packet.writeD(homunculus.getExp());
packet.writeD(homunculus.getHp());
packet.writeD(homunculus.getAtk());
packet.writeD(homunculus.getDef());
packet.writeD(homunculus.getCritRate());
}
}
else
{
packet.writeD(0);
}
return true;
}
}

View File

@@ -0,0 +1,13 @@
CREATE TABLE IF NOT EXISTS `character_homunculus` (
`ownerId` INT NOT NULL,
`slot` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`id` TINYINT UNSIGNED NOT NULL,
`level` TINYINT UNSIGNED NOT NULL DEFAULT '1',
`exp` INT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel1` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel2` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel3` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel4` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`skillLevel5` TINYINT UNSIGNED NOT NULL DEFAULT '0',
`active` TINYINT UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/HomunculusData.xsd">
<homunculus id="1" type="0" basicSkillId="32999" basicSkillLevel="1" skillId1="33004" skillId2="33009" skillId3="33014" skillId4="33019" skillId5="33024" hpLevel1="816" atkLevel1="782" defLevel1="802" expToLevel2="35000" hpLevel2="979" atkLevel2="939" defLevel2="962" expToLevel3="87500" hpLevel3="1174" atkLevel3="1126" defLevel3="1154" expToLevel4="192500" hpLevel4="1410" atkLevel4="1351" defLevel4="1385" expToLevel5="350000" hpLevel5="1691" atkLevel5="1621" defLevel5="1662" expToLevel6="560000" critRate="30" /> <!-- Basic Juju -->
<homunculus id="2" type="1" basicSkillId="32999" basicSkillLevel="2" skillId1="33029" skillId2="33034" skillId3="33039" skillId4="33044" skillId5="33049" hpLevel1="979" atkLevel1="938" defLevel1="962" expToLevel2="40000" hpLevel2="1175" atkLevel2="1126" defLevel2="1154" expToLevel3="100000" hpLevel3="1409" atkLevel3="1350" defLevel3="1385" expToLevel4="220000" hpLevel4="1691" atkLevel4="1621" defLevel4="1662" expToLevel5="400000" hpLevel5="2029" atkLevel5="1945" defLevel5="1994" expToLevel6="640000" critRate="30" /> <!-- Water Juju -->
<homunculus id="3" type="2" basicSkillId="32999" basicSkillLevel="3" skillId1="33054" skillId2="33059" skillId3="33064" skillId4="33069" skillId5="33074" hpLevel1="1174" atkLevel1="1125" defLevel1="1154" expToLevel2="45000" hpLevel2="1410" atkLevel2="1351" defLevel2="1384" expToLevel3="112500" hpLevel3="1690" atkLevel3="1620" defLevel3="1662" expToLevel4="247500" hpLevel4="2029" atkLevel4="1945" defLevel4="1994" expToLevel5="450000" hpLevel5="2434" atkLevel5="2334" defLevel5="2392" expToLevel6="720000" critRate="30" /> <!-- Luminous Juju -->
<homunculus id="4" type="0" basicSkillId="33000" basicSkillLevel="1" skillId1="33005" skillId2="33010" skillId3="33015" skillId4="33020" skillId5="33025" hpLevel1="816" atkLevel1="1188" defLevel1="990" expToLevel2="35000" hpLevel2="979" atkLevel2="1426" defLevel2="1188" expToLevel3="87500" hpLevel3="1174" atkLevel3="1710" defLevel3="1425" expToLevel4="192500" hpLevel4="1410" atkLevel4="2052" defLevel4="1710" expToLevel5="350000" hpLevel5="1691" atkLevel5="2462" defLevel5="2052" expToLevel6="560000" critRate="15" /> <!-- Basic Tana -->
<homunculus id="5" type="1" basicSkillId="33000" basicSkillLevel="2" skillId1="33030" skillId2="33035" skillId3="33040" skillId4="33045" skillId5="33050" hpLevel1="979" atkLevel1="1425" defLevel1="1188" expToLevel2="40000" hpLevel2="1175" atkLevel2="1710" defLevel2="1425" expToLevel3="100000" hpLevel3="1409" atkLevel3="2052" defLevel3="1710" expToLevel4="220000" hpLevel4="1691" atkLevel4="2462" defLevel4="2052" expToLevel5="400000" hpLevel5="2029" atkLevel5="2954" defLevel5="2462" expToLevel6="640000" critRate="15" /> <!-- Water Tana -->
<homunculus id="6" type="2" basicSkillId="33000" basicSkillLevel="3" skillId1="33055" skillId2="33060" skillId3="33065" skillId4="33070" skillId5="33075" hpLevel1="1174" atkLevel1="1710" defLevel1="1425" expToLevel2="45000" hpLevel2="1410" atkLevel2="2052" defLevel2="1710" expToLevel3="112500" hpLevel3="1690" atkLevel3="2462" defLevel3="2052" expToLevel4="247500" hpLevel4="2029" atkLevel4="2954" defLevel4="2462" expToLevel5="450000" hpLevel5="2434" atkLevel5="3544" defLevel5="2954" expToLevel6="720000" critRate="15" /> <!-- Luminous Tana -->
<homunculus id="7" type="0" basicSkillId="33001" basicSkillLevel="1" skillId1="33006" skillId2="33011" skillId3="33016" skillId4="33021" skillId5="33026" hpLevel1="1020" atkLevel1="792" defLevel1="1188" expToLevel2="35000" hpLevel2="1224" atkLevel2="950" defLevel2="1426" expToLevel3="87500" hpLevel3="1468" atkLevel3="1140" defLevel3="1710" expToLevel4="192500" hpLevel4="1762" atkLevel4="1368" defLevel4="2052" expToLevel5="350000" hpLevel5="2114" atkLevel5="1642" defLevel5="2462" expToLevel6="560000" critRate="15" /> <!-- Basic Pallo -->
<homunculus id="8" type="1" basicSkillId="33001" basicSkillLevel="2" skillId1="33031" skillId2="33036" skillId3="33041" skillId4="33046" skillId5="33051" hpLevel1="1224" atkLevel1="950" defLevel1="1425" expToLevel2="40000" hpLevel2="1468" atkLevel2="1140" defLevel2="1710" expToLevel3="100000" hpLevel3="1761" atkLevel3="1368" defLevel3="2052" expToLevel4="220000" hpLevel4="2114" atkLevel4="1641" defLevel4="2462" expToLevel5="400000" hpLevel5="2536" atkLevel5="1969" defLevel5="2954" expToLevel6="640000" critRate="15" /> <!-- Water Pallo -->
<homunculus id="9" type="2" basicSkillId="33001" basicSkillLevel="3" skillId1="33056" skillId2="33061" skillId3="33066" skillId4="33071" skillId5="33076" hpLevel1="1468" atkLevel1="1140" defLevel1="1710" expToLevel2="45000" hpLevel2="1761" atkLevel2="1368" defLevel2="2052" expToLevel3="112500" hpLevel3="2113" atkLevel3="1641" defLevel3="2462" expToLevel4="247500" hpLevel4="2536" atkLevel4="1969" defLevel4="2954" expToLevel5="450000" hpLevel5="3043" atkLevel5="2362" defLevel5="3544" expToLevel6="720000" critRate="15" /> <!-- Luminous Pallo -->
<homunculus id="10" type="0" basicSkillId="33002" basicSkillLevel="1" skillId1="33007" skillId2="33012" skillId3="33017" skillId4="33022" skillId5="33027" hpLevel1="1224" atkLevel1="990" defLevel1="792" expToLevel2="35000" hpLevel2="1469" atkLevel2="1188" defLevel2="950" expToLevel3="87500" hpLevel3="1762" atkLevel3="1425" defLevel3="1140" expToLevel4="192500" hpLevel4="2114" atkLevel4="1710" defLevel4="1368" expToLevel5="350000" hpLevel5="2537" atkLevel5="2052" defLevel5="1642" expToLevel6="560000" critRate="15" /> <!-- Basic Ayri -->
<homunculus id="11" type="1" basicSkillId="33002" basicSkillLevel="2" skillId1="33032" skillId2="33037" skillId3="33042" skillId4="33047" skillId5="33052" hpLevel1="1468" atkLevel1="1188" defLevel1="950" expToLevel2="40000" hpLevel2="1762" atkLevel2="1425" defLevel2="1140" expToLevel3="100000" hpLevel3="2113" atkLevel3="1710" defLevel3="1368" expToLevel4="220000" hpLevel4="2537" atkLevel4="2052" defLevel4="1641" expToLevel5="400000" hpLevel5="3044" atkLevel5="2462" defLevel5="1969" expToLevel6="640000" critRate="15" /> <!-- Water Ayri -->
<homunculus id="12" type="2" basicSkillId="33002" basicSkillLevel="3" skillId1="33057" skillId2="33062" skillId3="33067" skillId4="33072" skillId5="33077" hpLevel1="1761" atkLevel1="1425" defLevel1="1140" expToLevel2="45000" hpLevel2="2114" atkLevel2="1710" defLevel2="1368" expToLevel3="112500" hpLevel3="2535" atkLevel3="2052" defLevel3="1641" expToLevel4="247500" hpLevel4="3044" atkLevel4="2462" defLevel4="1969" expToLevel5="450000" hpLevel5="3652" atkLevel5="2954" defLevel5="2362" expToLevel6="720000" critRate="15" /> <!-- Luminous Ayri -->
<homunculus id="13" type="0" basicSkillId="33003" basicSkillLevel="1" skillId1="33008" skillId2="33013" skillId3="33018" skillId4="33023" skillId5="33028" hpLevel1="816" atkLevel1="1188" defLevel1="990" expToLevel2="35000" hpLevel2="979" atkLevel2="1426" defLevel2="1188" expToLevel3="87500" hpLevel3="1174" atkLevel3="1710" defLevel3="1425" expToLevel4="192500" hpLevel4="1410" atkLevel4="2052" defLevel4="1710" expToLevel5="350000" hpLevel5="1691" atkLevel5="2462" defLevel5="2052" expToLevel6="560000" critRate="15" /> <!-- Basic Churing -->
<homunculus id="14" type="1" basicSkillId="33003" basicSkillLevel="2" skillId1="33033" skillId2="33038" skillId3="33043" skillId4="33048" skillId5="33053" hpLevel1="979" atkLevel1="1425" defLevel1="1188" expToLevel2="40000" hpLevel2="1175" atkLevel2="1710" defLevel2="1425" expToLevel3="100000" hpLevel3="1409" atkLevel3="2052" defLevel3="1710" expToLevel4="220000" hpLevel4="1691" atkLevel4="2462" defLevel4="2052" expToLevel5="400000" hpLevel5="2029" atkLevel5="2954" defLevel5="2462" expToLevel6="640000" critRate="15" /> <!-- Water Churing -->
<homunculus id="15" type="2" basicSkillId="33003" basicSkillLevel="3" skillId1="33058" skillId2="33063" skillId3="33068" skillId4="33073" skillId5="33078" hpLevel1="1174" atkLevel1="1710" defLevel1="1425" expToLevel2="45000" hpLevel2="1410" atkLevel2="2052" defLevel2="1710" expToLevel3="112500" hpLevel3="1690" atkLevel3="2462" defLevel3="2052" expToLevel4="247500" hpLevel4="2029" atkLevel4="2954" defLevel4="2462" expToLevel5="450000" hpLevel5="2434" atkLevel5="3544" defLevel5="2954" expToLevel6="720000" critRate="15" /> <!-- Luminous Churing -->
</list>

View File

@@ -0,0 +1,46 @@
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="homunculus" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:byte" name="id" use="optional"/>
<xs:attribute type="xs:byte" name="type" use="optional"/>
<xs:attribute type="xs:int" name="basicSkillId" use="optional"/>
<xs:attribute type="xs:byte" name="basicSkillLevel" use="optional"/>
<xs:attribute type="xs:int" name="skillId1" use="optional"/>
<xs:attribute type="xs:int" name="skillId2" use="optional"/>
<xs:attribute type="xs:int" name="skillId3" use="optional"/>
<xs:attribute type="xs:int" name="skillId4" use="optional"/>
<xs:attribute type="xs:int" name="skillId5" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel1" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel1" use="optional"/>
<xs:attribute type="xs:short" name="defLevel1" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel2" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel2" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel2" use="optional"/>
<xs:attribute type="xs:short" name="defLevel2" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel3" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel3" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel3" use="optional"/>
<xs:attribute type="xs:short" name="defLevel3" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel4" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel4" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel4" use="optional"/>
<xs:attribute type="xs:short" name="defLevel4" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel5" use="optional"/>
<xs:attribute type="xs:short" name="hpLevel5" use="optional"/>
<xs:attribute type="xs:short" name="atkLevel5" use="optional"/>
<xs:attribute type="xs:short" name="defLevel5" use="optional"/>
<xs:attribute type="xs:int" name="expToLevel6" use="optional"/>
<xs:attribute type="xs:byte" name="critRate" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -78,6 +78,7 @@ import org.l2jmobius.gameserver.data.xml.FenceData;
import org.l2jmobius.gameserver.data.xml.FishingData;
import org.l2jmobius.gameserver.data.xml.HennaData;
import org.l2jmobius.gameserver.data.xml.HitConditionBonusData;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.data.xml.InitialEquipmentData;
import org.l2jmobius.gameserver.data.xml.InitialShortcutData;
import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
@@ -343,6 +344,7 @@ public class GameServer
CastleManager.getInstance().loadInstances();
GrandBossManager.getInstance();
EventDroplist.getInstance();
HomunculusData.getInstance();
printSection("Instance");
InstanceManager.getInstance();

View File

@@ -0,0 +1,79 @@
/*
* 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 org.l2jmobius.gameserver.data.xml;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
/**
* @author Mobius
*/
public class HomunculusData implements IXmlReader
{
private final Map<Integer, HomunculusTemplate> _templates = new HashMap<>();
protected HomunculusData()
{
load();
}
@Override
public void load()
{
_templates.clear();
parseDatapackFile("data/HomunculusData.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _templates.size() + " templates.");
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "homunculus", homunculusNode ->
{
final StatSet set = new StatSet(parseAttributes(homunculusNode));
final int id = set.getInt("id");
_templates.put(id, new HomunculusTemplate(id, set.getInt("type"), set.getInt("basicSkillId"), set.getInt("basicSkillLevel"), set.getInt("skillId1"), set.getInt("skillId2"), set.getInt("skillId3"), set.getInt("skillId4"), set.getInt("skillId5"), set.getInt("hpLevel1"), set.getInt("atkLevel1"), set.getInt("defLevel1"), set.getInt("expToLevel2"), set.getInt("hpLevel2"), set.getInt("atkLevel2"), set.getInt("defLevel2"), set.getInt("expToLevel3"), set.getInt("hpLevel3"), set.getInt("atkLevel3"), set.getInt("defLevel3"), set.getInt("expToLevel4"), set.getInt("hpLevel4"), set.getInt("atkLevel4"), set.getInt("defLevel4"), set.getInt("expToLevel5"), set.getInt("hpLevel5"), set.getInt("atkLevel5"), set.getInt("defLevel5"), set.getInt("expToLevel6"), set.getInt("critRate")));
}));
}
public HomunculusTemplate getTemplate(int id)
{
return _templates.get(id);
}
public int size()
{
return _templates.size();
}
public static HomunculusData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final HomunculusData INSTANCE = new HomunculusData();
}
}

View File

@@ -0,0 +1,205 @@
/*
* 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 org.l2jmobius.gameserver.instancemanager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
/**
* @author nexvill
*/
public class HomunculusManager
{
private static final Logger LOGGER = Logger.getLogger(HomunculusManager.class.getName());
private static final String SELECT_QUERY = "SELECT slot, id, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, active FROM character_homunculus WHERE ownerId=?";
private static final String INSERT_QUERY = "INSERT INTO `character_homunculus` (ownerId, slot, id, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, active) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
private static final String DELETE_QUERY = "DELETE FROM character_homunculus WHERE ownerId=? AND slot=? AND id=? AND level=? AND exp=? AND skillLevel1=? AND skillLevel2=? AND skillLevel3=? AND skillLevel4=? AND skillLevel5=? AND active=?";
private static final String UPDATE_QUERY = "UPDATE character_homunculus SET level=?, exp=?, skillLevel1=?, skillLevel2=?, skillLevel3=?, skillLevel4=?, skillLevel5=?, active=? WHERE ownerId=? AND slot=? AND id=?";
private static final String UPDATE_SLOT_QUERY = "UPDATE character_homunculus SET slot=0 WHERE ownerId=? AND slot=1";
public List<Homunculus> select(PlayerInstance owner)
{
final List<Homunculus> list = new ArrayList<>();
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(SELECT_QUERY))
{
statement.setInt(1, owner.getObjectId());
final ResultSet rset = statement.executeQuery();
while (rset.next())
{
final int id = rset.getInt("id");
final int slot = rset.getInt("slot");
final int level = rset.getInt("level");
final int exp = rset.getInt("exp");
final int skillLevel1 = rset.getInt("skillLevel1");
final int skillLevel2 = rset.getInt("skillLevel2");
final int skillLevel3 = rset.getInt("skillLevel3");
final int skillLevel4 = rset.getInt("skillLevel4");
final int skillLevel5 = rset.getInt("skillLevel5");
final boolean isActive = rset.getInt("active") > 0;
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(id);
Homunculus homunculus = null;
boolean remove = template == null;
if (!remove)
{
homunculus = new Homunculus(template, slot, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, isActive);
}
if (remove)
{
delete(owner, slot, id, level, exp, skillLevel1, skillLevel2, skillLevel3, skillLevel4, skillLevel5, isActive);
}
else
{
list.add(homunculus);
}
}
rset.close();
}
catch (Exception e)
{
LOGGER.warning("HomunculusManager.select(Player): " + e);
}
return list;
}
public boolean insert(PlayerInstance owner, Homunculus homunculus)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(INSERT_QUERY))
{
statement.setInt(1, owner.getObjectId());
statement.setInt(2, homunculus.getSlot());
statement.setInt(3, homunculus.getId());
statement.setInt(4, homunculus.getLevel());
statement.setInt(5, homunculus.getExp());
statement.setInt(6, homunculus.getSkillLevel1());
statement.setInt(7, homunculus.getSkillLevel2());
statement.setInt(8, homunculus.getSkillLevel3());
statement.setInt(9, homunculus.getSkillLevel4());
statement.setInt(10, homunculus.getSkillLevel5());
statement.setInt(11, homunculus.isActive() ? 1 : 0);
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not add homunculus to homunculus list: " + homunculus);
return false;
}
return true;
}
public boolean delete(PlayerInstance owner, Homunculus homunculus)
{
return delete(owner, homunculus.getSlot(), homunculus.getId(), homunculus.getLevel(), homunculus.getExp(), homunculus.getSkillLevel1(), homunculus.getSkillLevel2(), homunculus.getSkillLevel3(), homunculus.getSkillLevel4(), homunculus.getSkillLevel5(), homunculus.isActive());
}
private boolean delete(PlayerInstance owner, int slot, int id, int level, int exp, int skillLevel1, int skillLevel2, int skillLevel3, int skillLevel4, int skillLevel5, boolean active)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(DELETE_QUERY))
{
statement.setInt(1, owner.getObjectId());
statement.setInt(2, slot);
statement.setInt(3, id);
statement.setInt(4, level);
statement.setInt(5, exp);
statement.setInt(6, skillLevel1);
statement.setInt(7, skillLevel2);
statement.setInt(8, skillLevel3);
statement.setInt(9, skillLevel4);
statement.setInt(10, skillLevel5);
statement.setInt(11, active ? 1 : 0);
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not delete homunculus: " + id + " " + active + " ownerId: " + owner.getObjectId());
return false;
}
if (slot == 0)
{
updateSlot(owner);
}
return true;
}
private boolean updateSlot(PlayerInstance owner)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_SLOT_QUERY))
{
statement.setInt(1, owner.getObjectId());
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not change homunculus slot on owner id: " + owner.getObjectId());
return false;
}
return true;
}
public boolean update(PlayerInstance owner, Homunculus homunculus)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_QUERY))
{
statement.setInt(1, homunculus.getLevel());
statement.setInt(2, homunculus.getExp());
statement.setInt(3, homunculus.getSkillLevel1());
statement.setInt(4, homunculus.getSkillLevel2());
statement.setInt(5, homunculus.getSkillLevel3());
statement.setInt(6, homunculus.getSkillLevel4());
statement.setInt(7, homunculus.getSkillLevel5());
statement.setInt(8, homunculus.isActive() ? 1 : 0);
statement.setInt(9, owner.getObjectId());
statement.setInt(10, homunculus.getSlot());
statement.setInt(11, homunculus.getId());
statement.execute();
}
catch (Exception e)
{
LOGGER.warning(owner.getHomunculusList() + " could not update homunculus list on owner id: " + owner.getObjectId());
return false;
}
return true;
}
private static class SingletonHolder
{
protected static final HomunculusManager INSTANCE = new HomunculusManager();
}
public static HomunculusManager getInstance()
{
return SingletonHolder.INSTANCE;
}
}

View File

@@ -234,6 +234,7 @@ import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.holders.SubClassHolder;
import org.l2jmobius.gameserver.model.holders.TimedHuntingZoneHolder;
import org.l2jmobius.gameserver.model.holders.TrainingHolder;
import org.l2jmobius.gameserver.model.homunculus.HomunculusList;
import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.interfaces.ILocational;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
@@ -904,10 +905,7 @@ public class PlayerInstance extends Playable
private ScheduledFuture<?> _timedHuntingZoneTask = null;
private int _homunculusHpBonus;
private int _homunculusAtkBonus;
private int _homunculusDefBonus;
private float _homunculusCritBonus;
private final HomunculusList _homunculusList = new HomunculusList(this);
private final List<PlayerCollectionData> _collections = new ArrayList<>();
private final List<Integer> _collectionFavorites = new ArrayList<>();
@@ -6805,7 +6803,7 @@ public class PlayerInstance extends Playable
player.setTrueHero(true);
}
player.calculateHomunculusBonuses();
player.getHomunculusList().restore();
// Recalculate all stats
player.getStat().recalculateStats(false);
@@ -14479,6 +14477,11 @@ public class PlayerInstance extends Playable
return Math.max(getVariables().getLong(PlayerVariables.HUNTING_ZONE_ENTRY + zoneId, 0), 0);
}
public HomunculusList getHomunculusList()
{
return _homunculusList;
}
public List<PlayerCollectionData> getCollections()
{
return _collections;
@@ -14637,43 +14640,4 @@ public class PlayerInstance extends Playable
LOGGER.log(Level.SEVERE, "Could not restore collection favorite list data for playerId: " + getObjectId(), e);
}
}
public int getHomunculusHpBonus()
{
return _homunculusHpBonus;
}
public int getHomunculusAtkBonus()
{
return _homunculusAtkBonus;
}
public int getHomunculusDefBonus()
{
return _homunculusDefBonus;
}
public float getHomunculusCritBonus()
{
return _homunculusCritBonus;
}
public void calculateHomunculusBonuses()
{
if (getVariables().getInt(PlayerVariables.HOMUNCULUS_ID, 0) > 0)
{
final int quality = getVariables().getInt(PlayerVariables.HOMUNCULUS_QUALITY, 0);
_homunculusHpBonus = 800 + (quality * 100);
_homunculusAtkBonus = 100 + (quality * 25);
_homunculusDefBonus = 80 + (quality * 10);
_homunculusCritBonus = 0.1f * (quality + 1);
}
else
{
_homunculusHpBonus = 0;
_homunculusAtkBonus = 0;
_homunculusDefBonus = 0;
_homunculusCritBonus = 0;
}
}
}

View File

@@ -0,0 +1,254 @@
/*
* 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 org.l2jmobius.gameserver.model.homunculus;
/**
* @author nexvill
*/
public class Homunculus implements Comparable<Homunculus>
{
private final HomunculusTemplate _template;
private int _slot;
private int _level;
private int _exp;
private int _skillLevel1;
private int _skillLevel2;
private int _skillLevel3;
private int _skillLevel4;
private int _skillLevel5;
private boolean _isActive;
public Homunculus(HomunculusTemplate template, int slot, int level, int exp, int skillLevel1, int skillLevel2, int skillLevel3, int skillLevel4, int skillLevel5, boolean isActive)
{
_template = template;
_slot = slot;
_level = level;
_exp = exp;
_skillLevel1 = skillLevel1;
_skillLevel2 = skillLevel2;
_skillLevel3 = skillLevel3;
_skillLevel4 = skillLevel4;
_skillLevel5 = skillLevel5;
_isActive = isActive;
}
public HomunculusTemplate getTemplate()
{
return _template;
}
public int getId()
{
return _template.getId();
}
public int getType()
{
return _template.getType();
}
public void setSlot(int slot)
{
_slot = slot;
}
public int getSlot()
{
return _slot;
}
public void setLevel(int level)
{
_level = level;
}
public int getLevel()
{
return _level;
}
public void setExp(int exp)
{
_exp = exp;
}
public int getExp()
{
return _exp;
}
public void setSkillLevel1(int level)
{
_skillLevel1 = level;
}
public int getSkillLevel1()
{
return _skillLevel1;
}
public void setSkillLevel2(int level)
{
_skillLevel2 = level;
}
public int getSkillLevel2()
{
return _skillLevel2;
}
public void setSkillLevel3(int level)
{
_skillLevel3 = level;
}
public int getSkillLevel3()
{
return _skillLevel3;
}
public void setSkillLevel4(int level)
{
_skillLevel4 = level;
}
public int getSkillLevel4()
{
return _skillLevel4;
}
public void setSkillLevel5(int level)
{
_skillLevel5 = level;
}
public int getSkillLevel5()
{
return _skillLevel5;
}
public int getHp()
{
switch (_level)
{
case 1:
{
return _template.getHpLevel1();
}
case 2:
{
return _template.getHpLevel2();
}
case 3:
{
return _template.getHpLevel3();
}
case 4:
{
return _template.getHpLevel4();
}
case 5:
{
return _template.getHpLevel5();
}
}
return _template.getHpLevel1();
}
public int getAtk()
{
switch (_level)
{
case 1:
{
return _template.getAtkLevel1();
}
case 2:
{
return _template.getAtkLevel2();
}
case 3:
{
return _template.getAtkLevel3();
}
case 4:
{
return _template.getAtkLevel4();
}
case 5:
{
return _template.getAtkLevel5();
}
}
return _template.getAtkLevel1();
}
public int getDef()
{
switch (_level)
{
case 1:
{
return _template.getDefLevel1();
}
case 2:
{
return _template.getDefLevel2();
}
case 3:
{
return _template.getDefLevel3();
}
case 4:
{
return _template.getDefLevel4();
}
case 5:
{
return _template.getDefLevel5();
}
}
return _template.getDefLevel1();
}
public int getCritRate()
{
return _template.getCritRate();
}
public void setActive(boolean active)
{
_isActive = active;
}
public boolean isActive()
{
return _isActive;
}
@Override
public String toString()
{
return "Homunculus[id=" + _template.getId() + ", isActive=" + _isActive + "]";
}
@Override
public int compareTo(Homunculus o)
{
return getId() - o.getId();
}
}

View File

@@ -0,0 +1,411 @@
/*
* 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 org.l2jmobius.gameserver.model.homunculus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.l2jmobius.gameserver.instancemanager.HomunculusManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
/**
* @author nexvill
*/
public class HomunculusList
{
private static final Logger LOGGER = Logger.getLogger(HomunculusList.class.getName());
public static final int MAX_SIZE = 2;
private List<Homunculus> _homunculusList = Collections.emptyList();
private int _hp;
private int _atk;
private int _def;
private int _critRate;
private final PlayerInstance _owner;
private final Map<Integer, SkillHolder> _skills = new HashMap<>();
public HomunculusList(PlayerInstance owner)
{
_owner = owner;
}
public void restore()
{
_homunculusList = new ArrayList<>();
final List<Homunculus> homunculuses = HomunculusManager.getInstance().select(_owner);
for (Homunculus homunculus : homunculuses)
{
_homunculusList.add(homunculus);
}
Collections.sort(_homunculusList);
if (_homunculusList.size() > MAX_SIZE)
{
LOGGER.warning(this + ": Contains more than two homunculus's!");
for (int i = MAX_SIZE; i < _homunculusList.size(); i++)
{
_homunculusList.remove(i);
}
}
refreshStats(false);
}
public Homunculus get(int slot)
{
for (Homunculus homunculus : _homunculusList)
{
if (homunculus.getSlot() == slot)
{
return homunculus;
}
}
return null;
}
public int size()
{
return _homunculusList.size();
}
public int getFreeSize()
{
return Math.max(0, MAX_SIZE - size());
}
public boolean isFull()
{
return getFreeSize() == 0;
}
public boolean add(Homunculus homunculus)
{
if (isFull())
{
return false;
}
if (HomunculusManager.getInstance().insert(_owner, homunculus))
{
_homunculusList.add(homunculus);
Collections.sort(_homunculusList);
if (refreshStats(true))
{
_owner.sendSkillList();
}
return true;
}
return false;
}
public boolean update(Homunculus homunculus)
{
return HomunculusManager.getInstance().update(_owner, homunculus);
}
public boolean remove(Homunculus homunculus)
{
if (!remove0(homunculus))
{
return false;
}
if (refreshStats(true))
{
_owner.sendSkillList();
}
return true;
}
private boolean remove0(Homunculus homunculus)
{
if (!_homunculusList.remove(homunculus))
{
return false;
}
Collections.sort(_homunculusList);
return HomunculusManager.getInstance().delete(_owner, homunculus);
}
public boolean refreshStats(boolean send)
{
_hp = 0;
_atk = 0;
_def = 0;
_critRate = 0;
boolean updateSkillList = false;
for (int skillId : _skills.keySet())
{
if (_owner.removeSkill(skillId, false) != null)
{
updateSkillList = true;
}
}
_skills.clear();
for (Homunculus homunculus : _homunculusList)
{
if (!homunculus.isActive())
{
continue;
}
switch (homunculus.getLevel())
{
case 1:
{
_hp = homunculus.getTemplate().getHpLevel1();
_atk = homunculus.getTemplate().getAtkLevel1();
_def = homunculus.getTemplate().getDefLevel1();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 2:
{
_hp = homunculus.getTemplate().getHpLevel2();
_atk = homunculus.getTemplate().getAtkLevel2();
_def = homunculus.getTemplate().getDefLevel2();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 3:
{
_hp = homunculus.getTemplate().getHpLevel3();
_atk = homunculus.getTemplate().getAtkLevel3();
_def = homunculus.getTemplate().getDefLevel3();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel3() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId3(), homunculus.getSkillLevel3());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 4:
{
_hp = homunculus.getTemplate().getHpLevel4();
_atk = homunculus.getTemplate().getAtkLevel4();
_def = homunculus.getTemplate().getDefLevel4();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel3() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId3(), homunculus.getSkillLevel3());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel4() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId4(), homunculus.getSkillLevel4());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
case 5:
{
_hp = homunculus.getTemplate().getHpLevel5();
_atk = homunculus.getTemplate().getAtkLevel5();
_def = homunculus.getTemplate().getDefLevel5();
if (homunculus.getSkillLevel1() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId1(), homunculus.getSkillLevel1());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel2() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId2(), homunculus.getSkillLevel2());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel3() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId3(), homunculus.getSkillLevel3());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel4() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId4(), homunculus.getSkillLevel4());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
if (homunculus.getSkillLevel5() > 0)
{
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getSkillId5(), homunculus.getSkillLevel5());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
break;
}
}
_critRate = homunculus.getTemplate().getCritRate();
final SkillHolder skillEntry = new SkillHolder(homunculus.getTemplate().getBasicSkillId(), homunculus.getTemplate().getBasicSkillLevel());
final SkillHolder tempSkillEntry = _skills.get(skillEntry.getSkillId());
if ((tempSkillEntry == null) || (tempSkillEntry.getSkillLevel() < skillEntry.getSkillLevel()))
{
_skills.put(skillEntry.getSkillId(), skillEntry);
}
}
for (SkillHolder skillEntry : _skills.values())
{
_owner.addSkill(skillEntry.getSkill(), false);
}
if (!_skills.isEmpty())
{
updateSkillList = true;
}
if (send)
{
_owner.broadcastUserInfo();
}
return updateSkillList;
}
public int getHp()
{
return _hp;
}
public int getAtk()
{
return _atk;
}
public int getDef()
{
return _def;
}
public int getCritRate()
{
return _critRate;
}
@Override
public String toString()
{
return "HomunculusList[owner=" + _owner.getName() + "]";
}
}

View File

@@ -0,0 +1,238 @@
/*
* 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 org.l2jmobius.gameserver.model.homunculus;
/**
* @author nexvill
**/
public class HomunculusTemplate
{
private final int _id;
private final int _type;
private final int _basicSkillId;
private final int _basicSkillLevel;
private final int _skillId1;
private final int _skillId2;
private final int _skillId3;
private final int _skillId4;
private final int _skillId5;
private final int _hpLevel1;
private final int _atkLevel1;
private final int _defLevel1;
private final int _expToLevel2;
private final int _hpLevel2;
private final int _atkLevel2;
private final int _defLevel2;
private final int _expToLevel3;
private final int _hpLevel3;
private final int _atkLevel3;
private final int _defLevel3;
private final int _expToLevel4;
private final int _hpLevel4;
private final int _atkLevel4;
private final int _defLevel4;
private final int _expToLevel5;
private final int _hpLevel5;
private final int _atkLevel5;
private final int _defLevel5;
private final int _expToLevel6;
private final int _critRate;
public HomunculusTemplate(int id, int type, int basicSkillId, int basicSkillLevel, int skillId1, int skillId2, int skillId3, int skillId4, int skillId5, int hpLevel1, int atkLevel1, int defLevel1, int expToLevel2, int hpLevel2, int atkLevel2, int defLevel2, int expToLevel3, int hpLevel3, int atkLevel3, int defLevel3, int expToLevel4, int hpLevel4, int atkLevel4, int defLevel4, int expToLevel5, int hpLevel5, int atkLevel5, int defLevel5, int expToLevel6, int critRate)
{
_id = id;
_type = type;
_basicSkillId = basicSkillId;
_basicSkillLevel = basicSkillLevel;
_skillId1 = skillId1;
_skillId2 = skillId2;
_skillId3 = skillId3;
_skillId4 = skillId4;
_skillId5 = skillId5;
_hpLevel1 = hpLevel1;
_atkLevel1 = atkLevel1;
_defLevel1 = defLevel1;
_expToLevel2 = expToLevel2;
_hpLevel2 = hpLevel2;
_atkLevel2 = atkLevel2;
_defLevel2 = defLevel2;
_expToLevel3 = expToLevel3;
_hpLevel3 = hpLevel3;
_atkLevel3 = atkLevel3;
_defLevel3 = defLevel3;
_expToLevel4 = expToLevel4;
_hpLevel4 = hpLevel4;
_atkLevel4 = atkLevel4;
_defLevel4 = defLevel4;
_expToLevel5 = expToLevel5;
_hpLevel5 = hpLevel5;
_atkLevel5 = atkLevel5;
_defLevel5 = defLevel5;
_expToLevel6 = expToLevel6;
_critRate = critRate;
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public int getBasicSkillId()
{
return _basicSkillId;
}
public int getBasicSkillLevel()
{
return _basicSkillLevel;
}
public int getSkillId1()
{
return _skillId1;
}
public int getSkillId2()
{
return _skillId2;
}
public int getSkillId3()
{
return _skillId3;
}
public int getSkillId4()
{
return _skillId4;
}
public int getSkillId5()
{
return _skillId5;
}
public int getHpLevel1()
{
return _hpLevel1;
}
public int getHpLevel2()
{
return _hpLevel2;
}
public int getHpLevel3()
{
return _hpLevel3;
}
public int getHpLevel4()
{
return _hpLevel4;
}
public int getHpLevel5()
{
return _hpLevel5;
}
public int getAtkLevel1()
{
return _atkLevel1;
}
public int getAtkLevel2()
{
return _atkLevel2;
}
public int getAtkLevel3()
{
return _atkLevel3;
}
public int getAtkLevel4()
{
return _atkLevel4;
}
public int getAtkLevel5()
{
return _atkLevel5;
}
public int getDefLevel1()
{
return _defLevel1;
}
public int getDefLevel2()
{
return _defLevel2;
}
public int getDefLevel3()
{
return _defLevel3;
}
public int getDefLevel4()
{
return _defLevel4;
}
public int getDefLevel5()
{
return _defLevel5;
}
public int getExpToLevel2()
{
return _expToLevel2;
}
public int getExpToLevel3()
{
return _expToLevel3;
}
public int getExpToLevel4()
{
return _expToLevel4;
}
public int getExpToLevel5()
{
return _expToLevel5;
}
public int getExpToLevel6()
{
return _expToLevel6;
}
public int getCritRate()
{
return _critRate;
}
}

View File

@@ -41,8 +41,6 @@ public class MAttackFinalizer implements IStatFunction
{
// Enchanted chest bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_CHEST, Item.SLOT_FULL_ARMOR);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusAtkBonus();
}
if (Config.CHAMPION_ENABLE && creature.isChampion())

View File

@@ -40,9 +40,6 @@ public class MCritRateFinalizer implements IStatFunction
{
// Enchanted legs bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_LEGS);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusCritBonus();
}
final double witBonus = creature.getWIT() > 0 ? BaseStat.WIT.calcBonus(creature) : 1.;

View File

@@ -76,9 +76,6 @@ public class MDefenseFinalizer implements IStatFunction
}
baseValue *= BaseStat.CHA.calcBonus(creature);
// Bonus from Homunculus.
baseValue += player.getHomunculusDefBonus();
}
else if (creature.isPet() && (creature.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK) != 0))
{

View File

@@ -52,8 +52,6 @@ public class MaxHpFinalizer implements IStatFunction
{
baseValue = player.getTemplate().getBaseHpMax(player.getLevel());
}
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusHpBonus();
}
final double chaBonus = creature.isPlayer() ? BaseStat.CHA.calcBonus(creature) : 1.;

View File

@@ -41,8 +41,6 @@ public class PAttackFinalizer implements IStatFunction
{
// Enchanted chest bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_CHEST, Item.SLOT_FULL_ARMOR);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusAtkBonus();
}
if (Config.CHAMPION_ENABLE && creature.isChampion())

View File

@@ -40,9 +40,6 @@ public class PCriticalRateFinalizer implements IStatFunction
{
// Enchanted legs bonus
baseValue += calcEnchantBodyPart(creature, Item.SLOT_LEGS);
// Bonus from Homunculus.
baseValue += creature.getActingPlayer().getHomunculusCritBonus();
}
final double dexBonus = creature.getDEX() > 0 ? BaseStat.DEX.calcBonus(creature) : 1.;
return validateValue(creature, Stat.defaultValue(creature, stat, baseValue * dexBonus * 10), 0, creature.isPlayer() ? Config.MAX_PCRIT_RATE : Double.MAX_VALUE);

View File

@@ -79,9 +79,6 @@ public class PDefenseFinalizer implements IStatFunction
}
}
baseValue *= BaseStat.CHA.calcBonus(creature);
// Bonus from Homunculus.
baseValue += player.getHomunculusDefBonus();
}
}
if (creature.isRaid())

View File

@@ -65,13 +65,17 @@ public class PlayerVariables extends AbstractVariables
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
public static final String HOMUNCULUS_STATUS = "HOMUNCULUS_STATUS";
public static final String HOMUNCULUS_TIME = "HOMUNCULUS_TIME";
public static final String HOMUNCULUS_HP = "HOMUNCULUS_HP";
public static final String HOMUNCULUS_SP = "HOMUNCULUS_SP";
public static final String HOMUNCULUS_VP = "HOMUNCULUS_VP";
public static final String HOMUNCULUS_ID = "HOMUNCULUS";
public static final String HOMUNCULUS_QUALITY = "HOMUNCULUS_QUALITY";
public static final String HOMUNCULUS_HP_POINTS = "HOMUNCULUS_HP_POINTS";
public static final String HOMUNCULUS_SP_POINTS = "HOMUNCULUS_SP_POINTS";
public static final String HOMUNCULUS_VP_POINTS = "HOMUNCULUS_VP_POINTS";
public static final String HOMUNCULUS_CREATION_TIME = "HOMUNCULUS_CREATION_TIME";
public static final String HOMUNCULUS_UPGRADE_POINTS = "HOMUNCULUS_UPGRADE_POINTS";
public static final String HOMUNCULUS_KILLED_MOBS = "HOMUNCULUS_KILLED_MOBS";
public static final String HOMUNCULUS_USED_KILL_CONVERT = "HOMUNCULUS_USED_KILL_CONVERT";
public static final String HOMUNCULUS_USED_RESET_KILLS = "HOMUNCULUS_USED_RESET_KILLS";
public static final String HOMUNCULUS_USED_VP_POINTS = "HOMUNCULUS_USED_VP_POINTS";
public static final String HOMUNCULUS_USED_VP_CONVERT = "HOMUNCULUS_USED_VP_CONVERT";
public static final String HOMUNCULUS_USED_RESET_VP = "HOMUNCULUS_USED_RESET_VP";
private final int _objectId;

View File

@@ -82,17 +82,17 @@ import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExt
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusCreateStart;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusDeleteData;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEnchantExperience;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEnchantPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEnchantSkill;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvolve;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusInitPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusInsert;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusSummon;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExRequestHomonculusList;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExRequestHomunculusActivate;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExActivateHomunculus;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExDeleteHomunculusData;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExEnchantHomunculusSkill;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusCreateStart;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusEnchantExp;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusGetEnchantPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusInitPoint;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusInsert;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExHomunculusSummon;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.RequestExShowHomunculusInfo;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
import org.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
@@ -572,17 +572,17 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_AUTH_RECONNECT(0x1A4, null, ConnectionState.IN_GAME),
EX_PET_EQUIP_ITEM(0x1A5, null, ConnectionState.IN_GAME),
EX_PET_UNEQUIP_ITEM(0x1A6, null, ConnectionState.IN_GAME),
EX_SHOW_HOMUNCULUS_INFO(0x1A7, ExRequestHomonculusList::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_CREATE_START(0x1A8, ExHomunculusCreateStart::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INSERT(0x1A9, ExHomunculusInsert::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_SUMMON(0x1AA, ExHomunculusSummon::new, ConnectionState.IN_GAME),
EX_DELETE_HOMUNCULUS_DATA(0x1AB, ExHomunculusDeleteData::new, ConnectionState.IN_GAME),
EX_REQUEST_ACTIVATE_HOMUNCULUS(0x1AC, ExRequestHomunculusActivate::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_GET_ENCHANT_POINT(0x1AD, ExHomunculusEnchantPoint::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INIT_POINT(0x1AE, ExHomunculusInitPoint::new, ConnectionState.IN_GAME),
EX_SHOW_HOMUNCULUS_INFO(0x1A7, RequestExShowHomunculusInfo::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_CREATE_START(0x1A8, RequestExHomunculusCreateStart::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INSERT(0x1A9, RequestExHomunculusInsert::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_SUMMON(0x1AA, RequestExHomunculusSummon::new, ConnectionState.IN_GAME),
EX_DELETE_HOMUNCULUS_DATA(0x1AB, RequestExDeleteHomunculusData::new, ConnectionState.IN_GAME),
EX_REQUEST_ACTIVATE_HOMUNCULUS(0x1AC, RequestExActivateHomunculus::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_GET_ENCHANT_POINT(0x1AD, RequestExHomunculusGetEnchantPoint::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_INIT_POINT(0x1AE, RequestExHomunculusInitPoint::new, ConnectionState.IN_GAME),
EX_EVOLVE_PET(0x1AF, ExHomunculusEvolve::new, ConnectionState.IN_GAME),
EX_ENCHANT_HOMUNCULUS_SKILL(0x1B0, ExHomunculusEnchantSkill::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_ENCHANT_EXP(0x1B1, ExHomunculusEnchantExperience::new, ConnectionState.IN_GAME),
EX_ENCHANT_HOMUNCULUS_SKILL(0x1B0, RequestExEnchantHomunculusSkill::new, ConnectionState.IN_GAME),
EX_HOMUNCULUS_ENCHANT_EXP(0x1B1, RequestExHomunculusEnchantExp::new, ConnectionState.IN_GAME),
EX_TELEPORT_FAVORITES_LIST(0x1B2, ExRequestTeleportFavoriteList::new, ConnectionState.IN_GAME),
EX_TELEPORT_FAVORITES_UI_TOGGLE(0x1B3, ExRequestTeleportFavoritesUIToggle::new, ConnectionState.IN_GAME),
EX_TELEPORT_FAVORITES_ADD_DEL(0x1B4, ExRequestTeleportFavoritesAddDel::new, ConnectionState.IN_GAME),

View File

@@ -882,7 +882,7 @@ public enum OutgoingPackets
EX_SHARED_POSITION_TELEPORT_UI(0xFE, 0x253),
EX_CHAR_INFO(0xFE, 0x254),
EX_AUTH_RECONNECT(0xFE, 0x255),
EX_SHOW_BIRTH_INFO(0xFE, 0x256),
EX_SHOW_HOMUNCULUS_BIRTH_INFO(0xFE, 0x256),
EX_HOMUNCULUS_CREATE_START_RESULT(0xFE, 0x257),
EX_HOMUNCULUS_INSERT_RESULT(0xFE, 0x258),
EX_HOMUNCULUS_SUMMON_RESULT(0xFE, 0x259),

View File

@@ -112,9 +112,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillLi
import org.l2jmobius.gameserver.network.serverpackets.attendance.ExVipAttendanceItemList;
import org.l2jmobius.gameserver.network.serverpackets.collection.ExCollectionInfo;
import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusReady;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.util.BuilderUtil;
/**
@@ -329,9 +329,9 @@ public class EnterWorld implements IClientIncomingPacket
}
// Enable Homunculus system.
player.sendPacket(new ExHomonculusBirthInfo(player));
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExHomunculusPointInfo(player));
player.sendPacket(new ExHomunculusReady(player));
player.sendPacket(new ExHomunculusReady(true));
// Send time.
player.sendPacket(new ExEnterWorld());

View File

@@ -1,47 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
/**
* @author Mobius
*/
public class ExHomunculusEnchantPoint implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
player.sendPacket(new ExHomunculusPointInfo(player));
}
}

View File

@@ -1,47 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
/**
* @author Mobius
*/
public class ExHomunculusEnchantSkill implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExHomonculusList(player));
}
}

View File

@@ -20,7 +20,7 @@ import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
@@ -42,6 +42,6 @@ public class ExHomunculusEvolve implements IClientIncomingPacket
return;
}
client.sendPacket(new ExHomonculusList(player));
client.sendPacket(new ExShowHomunculusList(player));
}
}

View File

@@ -1,149 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusInsertHpSpVp;
/**
* @author Mobius
*/
public class ExHomunculusInsert implements IClientIncomingPacket
{
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final int time = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_TIME, 0);
if (((Chronos.currentTimeMillis() / 1000) - time) < 86400)
{
player.sendMessage("Waiting time has not passed.");
return;
}
switch (_type)
{
case 0: // hp
{
if (player.getCurrentHp() >= 10000)
{
player.setCurrentHp(player.getCurrentHp() - 10000);
final int hp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP, 0);
if (hp < 99)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP, hp + 1);
}
else
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP, 100);
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status == 1)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 2);
}
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
}
else
{
return;
}
break;
}
case 1: // sp
{
if (player.getSp() >= 5000000000L)
{
player.setSp(player.getSp() - 5000000000L);
final int sp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP, 0);
if (sp < 9)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP, sp + 1);
}
else
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP, 10);
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status == 1)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 2);
}
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
}
else
{
return;
}
break;
}
case 2: // vp
{
if (player.getVitalityPoints() >= 35000)
{
player.setVitalityPoints(player.getVitalityPoints() - 35000, true);
final int vp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP, 0);
if (vp < 4)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP, vp + 1);
}
else
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP, 5);
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status == 1)
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 2);
}
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
}
else
{
return;
}
break;
}
}
player.sendPacket(new ExHomunculusInsertHpSpVp(player));
player.sendPacket(new ExHomonculusBirthInfo(player));
}
}

View File

@@ -1,78 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusSummonResult;
/**
* @author Mobius
*/
public class ExHomunculusSummon implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final int homunculus = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_ID, 0);
if (homunculus == 0)
{
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
final int hp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP, 0);
final int sp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP, 0);
final int vp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP, 0);
if ((status == 2) && ((hp == 100) || (sp == 10) || (vp == 5)))
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_ID, 1);
int quality = 2;
if (Rnd.get(100) < 50)
{
quality = 0;
}
else if (Rnd.get(100) < 30)
{
quality = 1;
}
player.getVariables().set(PlayerVariables.HOMUNCULUS_QUALITY, quality);
player.calculateHomunculusBonuses();
player.getStat().recalculateStats(true);
}
}
client.sendPacket(new ExHomonculusSummonResult(player));
client.sendPacket(new ExHomonculusList(player));
}
}

View File

@@ -1,48 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
/**
* @author Mobius
*/
public class ExRequestHomonculusList implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD(); // ?
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExHomonculusList(player));
}
}

View File

@@ -1,49 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusActivateResult;
/**
* @author Mobius
*/
public class ExRequestHomunculusActivate implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD();
packet.readC(); // enabled?
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExHomonculusActivateResult(player));
}
}

View File

@@ -0,0 +1,94 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExActivateHomunculusResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class RequestExActivateHomunculus implements IClientIncomingPacket
{
private int _slot;
private boolean _activate;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD();
_activate = packet.readC() == 1 ? true : false; // enabled?
return true;
}
@Override
public void run(GameClient client)
{
PlayerInstance activeChar = client.getPlayer();
if (activeChar == null)
{
return;
}
final Homunculus homunculus = activeChar.getHomunculusList().get(_slot);
boolean anotherActive = false;
int size = activeChar.getHomunculusList().size();
if (size > 1)
{
if (_slot == 0)
{
if (activeChar.getHomunculusList().get(1).isActive())
{
anotherActive = true;
}
}
else
{
if (activeChar.getHomunculusList().get(0).isActive())
{
anotherActive = true;
}
}
}
if (anotherActive)
{
return;
}
if (!homunculus.isActive() && _activate)
{
homunculus.setActive(true);
activeChar.getHomunculusList().update(homunculus);
activeChar.getHomunculusList().refreshStats(true);
activeChar.sendPacket(new ExShowHomunculusList(activeChar));
activeChar.sendPacket(new ExActivateHomunculusResult(true));
}
else if (homunculus.isActive() && !_activate)
{
homunculus.setActive(false);
activeChar.getHomunculusList().update(homunculus);
activeChar.getHomunculusList().refreshStats(true);
activeChar.sendPacket(new ExShowHomunculusList(activeChar));
activeChar.sendPacket(new ExActivateHomunculusResult(false));
}
}
}

View File

@@ -18,18 +18,23 @@ package org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExDeleteHomunculusDataResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class ExHomunculusEnchantExperience implements IClientIncomingPacket
public class RequestExDeleteHomunculusData implements IClientIncomingPacket
{
private int _slot;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD(); // Position?
return true;
}
@@ -42,6 +47,11 @@ public class ExHomunculusEnchantExperience implements IClientIncomingPacket
return;
}
client.sendPacket(new ExHomonculusList(player));
final Homunculus homunculus = player.getHomunculusList().get(_slot);
if (player.getHomunculusList().remove(homunculus))
{
player.sendPacket(new ExDeleteHomunculusDataResult());
player.sendPacket(new ExShowHomunculusList(player));
}
}
}

View File

@@ -21,18 +21,27 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusList;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExEnchantHomunculusSkillResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusHPSPVP;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class ExHomunculusDeleteData implements IClientIncomingPacket
public class RequestExEnchantHomunculusSkill implements IClientIncomingPacket
{
private static final int SP_COST = 1000000000;
private int _slot;
private int _skillNumber;
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readD(); // Position?
packet.readD();
_slot = packet.readD();
_skillNumber = packet.readD();
return true;
}
@@ -45,18 +54,22 @@ public class ExHomunculusDeleteData implements IClientIncomingPacket
return;
}
player.getVariables().remove(PlayerVariables.HOMUNCULUS_STATUS);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_TIME);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_HP);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_SP);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_VP);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_ID);
player.getVariables().remove(PlayerVariables.HOMUNCULUS_QUALITY);
if (player.getSp() < SP_COST)
{
return;
}
player.calculateHomunculusBonuses();
player.getStat().recalculateStats(true);
int points = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0);
if (points < 1)
{
player.sendMessage("Not enough upgrade points.");
return;
}
client.sendPacket(new ExHomonculusList(player));
client.sendPacket(new ExHomonculusBirthInfo(player));
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, points - 1);
player.sendPacket(new ExEnchantHomunculusSkillResult(player, _slot, _skillNumber));
player.sendPacket(new ExHomunculusHPSPVP(player));
player.sendPacket(new ExShowHomunculusList(player));
player.sendPacket(new ExHomunculusPointInfo(player));
}
}

View File

@@ -23,15 +23,16 @@ import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomonculusCreateStartResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusCreateStartResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
/**
* @author Mobius
*/
public class ExHomunculusCreateStart implements IClientIncomingPacket
public class RequestExHomunculusCreateStart implements IClientIncomingPacket
{
private static final int COST = 1000000;
private static final long CREATION_TIME = 86400000L;
@Override
public boolean read(GameClient client, PacketReader packet)
@@ -48,22 +49,15 @@ public class ExHomunculusCreateStart implements IClientIncomingPacket
return;
}
final int status = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
if (status > 0)
{
return;
}
if (player.getAdena() < COST)
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA_2);
return;
}
player.reduceAdena("Homunculus creation", COST, player, true);
player.getVariables().set(PlayerVariables.HOMUNCULUS_STATUS, 1);
player.getVariables().set(PlayerVariables.HOMUNCULUS_TIME, Chronos.currentTimeMillis() / 1000);
player.getVariables().set(PlayerVariables.HOMUNCULUS_CREATION_TIME, Chronos.currentTimeMillis() + CREATION_TIME);
client.sendPacket(new ExHomonculusBirthInfo(player));
client.sendPacket(new ExHomonculusCreateStartResult(player));
client.sendPacket(new ExShowHomunculusBirthInfo(player));
client.sendPacket(new ExHomunculusCreateStartResult(player));
}
}

View File

@@ -0,0 +1,124 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusEnchantEXPResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class RequestExHomunculusEnchantExp implements IClientIncomingPacket
{
private static final int EXP_PER_POINT = 750;
private int _slot;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_slot = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) == 0)
{
player.sendPacket(new ExHomunculusEnchantEXPResult(false, false));
}
else
{
int points = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) - 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, points);
final Homunculus homunculus = player.getHomunculusList().get(_slot);
homunculus.setExp(homunculus.getExp() + EXP_PER_POINT);
player.sendPacket(new ExHomunculusPointInfo(player));
switch (homunculus.getLevel())
{
case 1:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel2())
{
homunculus.setLevel(2);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
case 2:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel3())
{
homunculus.setLevel(3);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
case 3:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel4())
{
homunculus.setLevel(4);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
case 4:
{
if (homunculus.getExp() >= homunculus.getTemplate().getExpToLevel5())
{
homunculus.setLevel(5);
player.sendPacket(new ExHomunculusEnchantEXPResult(true, true));
}
else
{
player.sendPacket(new ExHomunculusEnchantEXPResult(true, false));
}
break;
}
}
player.getHomunculusList().update(homunculus);
player.getHomunculusList().refreshStats(true);
player.sendPacket(new ExShowHomunculusList(player));
}
}
}

View File

@@ -0,0 +1,110 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusGetEnchantPointResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusHPSPVP;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
/**
* @author Mobius
*/
public class RequestExHomunculusGetEnchantPoint implements IClientIncomingPacket
{
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (_type == 0) // mobs
{
int killedMobs = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_KILLED_MOBS, 0);
if (killedMobs < 500)
{
return;
}
int usedKillConverts = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0);
if (usedKillConverts >= 5)
{
return;
}
int upgradePoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) + 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, upgradePoints);
player.getVariables().set(PlayerVariables.HOMUNCULUS_KILLED_MOBS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, usedKillConverts + 1);
}
else if (_type == 1) // vitality
{
int usedVpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0);
if (usedVpPoints < 2)
{
return;
}
int usedVpConverts = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0);
if (usedVpConverts >= 5)
{
return;
}
int upgradePoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, 0) + 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_UPGRADE_POINTS, upgradePoints);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, usedVpConverts + 1);
}
else if (_type == 2) // vitality consume
{
int usedVpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, 0);
if (usedVpPoints >= 2)
{
return;
}
if (player.getVitalityPoints() >= (PlayerStat.MAX_VITALITY_POINTS / 4))
{
player.setVitalityPoints(player.getVitalityPoints() - (PlayerStat.MAX_VITALITY_POINTS / 4), false);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_POINTS, usedVpPoints + 1);
}
}
if (_type == 2)
{
player.sendPacket(new ExHomunculusHPSPVP(player));
}
player.sendPacket(new ExHomunculusPointInfo(player));
player.sendPacket(new ExHomunculusGetEnchantPointResult(_type));
}
}

View File

@@ -0,0 +1,86 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusInitPointResult;
/**
* @author Mobius
*/
public class RequestExHomunculusInitPoint implements IClientIncomingPacket
{
private static final int POWERFUL_FISH = 47552;
private static final int FISH_COUNT = 5;
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (_type == 0)
{
final int usedResetKills = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, 0);
final int usedKillConvert = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0);
if (((player.getInventory().getItemByItemId(POWERFUL_FISH) != null) && (player.getInventory().getItemByItemId(POWERFUL_FISH).getCount() < FISH_COUNT)) //
|| ((usedResetKills <= 3) && (usedKillConvert == 0)))
{
player.sendPacket(new ExHomunculusInitPointResult(false, _type));
}
else if ((usedResetKills <= 3) && (usedKillConvert == 5))
{
player.destroyItemByItemId("Homunculus Points", POWERFUL_FISH, FISH_COUNT, player, true);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_KILL_CONVERT, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_KILLS, usedResetKills + 1);
player.sendPacket(new ExHomunculusInitPointResult(true, _type));
}
}
else
{
final int usedResetVp = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_RESET_VP, 0);
final int usedVpConvert = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0);
if (((player.getInventory().getItemByItemId(POWERFUL_FISH) != null) && (player.getInventory().getItemByItemId(POWERFUL_FISH).getCount() < FISH_COUNT)) //
|| ((usedResetVp <= 3) && (usedVpConvert == 0)))
{
player.sendPacket(new ExHomunculusInitPointResult(false, _type));
}
else if ((usedResetVp <= 3) && (usedVpConvert == 5))
{
player.destroyItemByItemId("Homunculus Points", POWERFUL_FISH, FISH_COUNT, player, true);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_VP_CONVERT, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_USED_RESET_VP, usedResetVp + 1);
player.sendPacket(new ExHomunculusInitPointResult(true, _type));
}
}
}
}

View File

@@ -0,0 +1,109 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusHPSPVP;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusInsertResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
/**
* @author Mobius
*/
public class RequestExHomunculusInsert implements IClientIncomingPacket
{
private static final short HP_COST = 10000;
private static final long SP_COST = 5000000000L;
private static final int VP_COST = PlayerStat.MAX_VITALITY_POINTS / 4;
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
int hpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
int spPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
int vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
switch (_type)
{
case 0:
{
if ((player.getCurrentHp() > HP_COST) && (hpPoints < 100))
{
int newHp = (int) (player.getCurrentHp()) - HP_COST;
player.setCurrentHp(newHp, true);
hpPoints += 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP_POINTS, hpPoints);
}
else
{
return;
}
break;
}
case 1:
{
if ((player.getSp() >= SP_COST) && (spPoints < 10))
{
player.addExpAndSp(0, -SP_COST);
spPoints += 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP_POINTS, spPoints);
}
else
{
return;
}
break;
}
case 2:
{
if ((player.getVitalityPoints() >= VP_COST) && (vpPoints < 5))
{
int newVitality = player.getVitalityPoints() - VP_COST;
player.setVitalityPoints(newVitality, true);
vpPoints += 1;
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP_POINTS, vpPoints);
}
else
{
return;
}
break;
}
}
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExHomunculusHPSPVP(player));
player.sendPacket(new ExHomunculusInsertResult(_type));
}
}

View File

@@ -0,0 +1,157 @@
/*
* 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 org.l2jmobius.gameserver.network.clientpackets.homunculus;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.HomunculusData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.model.homunculus.HomunculusTemplate;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusSummonResult;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class RequestExHomunculusSummon implements IClientIncomingPacket
{
private static int _hpPoints;
private static int _spPoints;
private static int _vpPoints;
private static int _homunculusCreateTime;
@Override
public boolean read(GameClient client, PacketReader packet)
{
// packet.readC();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
_hpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
_spPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
_vpPoints = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
_homunculusCreateTime = (int) (player.getVariables().getLong(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0) / 1000);
if (_homunculusCreateTime > 0)
{
if (((System.currentTimeMillis() / 1000) >= _homunculusCreateTime) && (_hpPoints == 100) && (_spPoints == 10) && (_vpPoints == 5))
{
int homunculusId = 0;
final int chance = Rnd.get(100);
if (chance >= 60) // Basic Homunculus
{
int chance2 = Rnd.get(100);
if (chance2 >= 80)
{
homunculusId = 1;
}
else if (chance2 >= 60)
{
homunculusId = 4;
}
else if (chance2 >= 40)
{
homunculusId = 7;
}
else if (chance2 >= 20)
{
homunculusId = 10;
}
else
{
homunculusId = 13;
}
}
else if (chance >= 10) // Water Homunculus
{
int chance2 = Rnd.get(100);
if (chance2 >= 80)
{
homunculusId = 2;
}
else if (chance2 >= 60)
{
homunculusId = 5;
}
else if (chance2 >= 40)
{
homunculusId = 8;
}
else if (chance2 >= 20)
{
homunculusId = 11;
}
else
{
homunculusId = 14;
}
}
else // Luminous Homunculus
{
int chance2 = Rnd.get(100);
if (chance2 >= 80)
{
homunculusId = 3;
}
else if (chance2 >= 60)
{
homunculusId = 6;
}
else if (chance2 >= 40)
{
homunculusId = 9;
}
else if (chance2 >= 20)
{
homunculusId = 12;
}
else
{
homunculusId = 15;
}
}
final HomunculusTemplate template = HomunculusData.getInstance().getTemplate(homunculusId);
final Homunculus homunculus = new Homunculus(template, player.getHomunculusList().size(), 1, 0, 0, 0, 0, 0, 0, false);
if (player.getHomunculusList().add(homunculus))
{
player.getVariables().set(PlayerVariables.HOMUNCULUS_CREATION_TIME, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_HP_POINTS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_SP_POINTS, 0);
player.getVariables().set(PlayerVariables.HOMUNCULUS_VP_POINTS, 0);
player.sendPacket(new ExShowHomunculusBirthInfo(player));
player.sendPacket(new ExShowHomunculusList(player));
player.sendPacket(new ExHomunculusSummonResult());
}
}
}
}
}

View File

@@ -21,15 +21,20 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusBirthInfo;
import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExShowHomunculusList;
/**
* @author Mobius
*/
public class ExHomunculusInitPoint implements IClientIncomingPacket
public class RequestExShowHomunculusInfo implements IClientIncomingPacket
{
private int _type; // 0 - create tab, 1 - manage tab, 2 - get upgrade points menu
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = packet.readD();
return true;
}
@@ -42,6 +47,23 @@ public class ExHomunculusInitPoint implements IClientIncomingPacket
return;
}
player.sendPacket(new ExHomunculusPointInfo(player));
switch (_type)
{
case 0:
{
player.sendPacket(new ExShowHomunculusBirthInfo(player));
break;
}
case 1:
{
player.sendPacket(new ExShowHomunculusList(player));
break;
}
case 2:
{
player.sendPacket(new ExHomunculusPointInfo(player));
break;
}
}
}
}

View File

@@ -17,21 +17,19 @@
package org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusActivateResult implements IClientOutgoingPacket
public class ExActivateHomunculusResult implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
private final boolean _activate;
public ExHomonculusActivateResult(PlayerInstance player)
public ExActivateHomunculusResult(boolean activate)
{
_player = player;
_activate = activate;
}
@Override
@@ -39,15 +37,17 @@ public class ExHomonculusActivateResult implements IClientOutgoingPacket
{
OutgoingPackets.EX_ACTIVATE_HOMUNCULUS_RESULT.writeId(packet);
// struct _C_EX_REQUEST_ACTIVATE_HOMUNCULUS
// {
// var int nIdx;
// var byte bActivate;
// };
packet.writeD(0x01);
packet.writeC(0x01);
packet.writeD(1); // success
if (_activate)
{
packet.writeC(1); // activate
packet.writeD(13246); // The relations are being established.
}
else
{
packet.writeC(0); // activate
packet.writeD(13247); // The relations are broken.
}
return true;
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExDeleteHomunculusDataResult implements IClientOutgoingPacket
{
public ExDeleteHomunculusDataResult()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ACTIVATE_HOMUNCULUS_RESULT.writeId(packet);
packet.writeD(1); // 1 - success
packet.writeD(13252); // The homunculus is destroyed.
return true;
}
}

View File

@@ -0,0 +1,103 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.homunculus.Homunculus;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExEnchantHomunculusSkillResult implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final int _slot;
private final int _skillNumber;
public ExEnchantHomunculusSkillResult(PlayerInstance player, int slot, int skillNumber)
{
_player = player;
_slot = slot;
_skillNumber = skillNumber;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_ENCHANT_HOMUNCULUS_SKILL_RESULT.writeId(packet);
final int playerNumber = Rnd.get(1, 6);
final int homunculusNumber = Rnd.get(1, 6);
final int systemNumber = Rnd.get(1, 6);
final Homunculus homunculus = _player.getHomunculusList().get(_slot);
int boundLevel = 1;
if ((playerNumber == homunculusNumber) && (playerNumber == systemNumber))
{
boundLevel = 3;
}
else if ((playerNumber == homunculusNumber) || (playerNumber == systemNumber) || (homunculusNumber == systemNumber))
{
boundLevel = 2;
}
switch (_skillNumber)
{
case 1:
{
homunculus.setSkillLevel1(boundLevel);
break;
}
case 2:
{
homunculus.setSkillLevel2(boundLevel);
break;
}
case 3:
{
homunculus.setSkillLevel3(boundLevel);
break;
}
case 4:
{
homunculus.setSkillLevel4(boundLevel);
break;
}
case 5:
{
homunculus.setSkillLevel5(boundLevel);
break;
}
}
_player.getHomunculusList().update(homunculus);
_player.getHomunculusList().refreshStats(true);
packet.writeD(boundLevel); // skill bound level result
packet.writeD(homunculus.getId()); // homunculus id? random value on JP
packet.writeD(_slot); // slot
packet.writeD(_skillNumber); // skill number
packet.writeD(playerNumber); // player number
packet.writeD(homunculusNumber); // homunculus number
packet.writeD(systemNumber); // system number
return true;
}
}

View File

@@ -1,58 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusBirthInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExHomonculusBirthInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_BIRTH_INFO.writeId(packet);
final int status = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_STATUS, 0);
final int hp = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_HP, 0);
final int sp = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_SP, 0);
final int vp = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_VP, 0);
final int time = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_TIME, 0);
final long currentTime = Chronos.currentTimeMillis();
packet.writeD(status); // 0 = time idle, 1 = time updating, 2 = summon enabled
packet.writeD(hp); // hp 100
packet.writeD(sp); // sp 10
packet.writeD(vp); // vitality 5
packet.writeQ((currentTime / 1000) + (86400 - Math.min(86400, (currentTime / 1000) - time)));
return true;
}
}

View File

@@ -1,82 +0,0 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusList implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExHomonculusList(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_HOMUNCULUS_LIST.writeId(packet);
final int homunculus = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_ID, 0);
if (homunculus > 0)
{
final int quality = _player.getVariables().getInt(PlayerVariables.HOMUNCULUS_QUALITY, 0);
packet.writeD(0x01); // Size.
packet.writeD(0x00); // nIdx
packet.writeD(homunculus); // nID
packet.writeD(quality); // eType
packet.writeC(0x01); // bActivate
packet.writeD(0x00); // m_nSkillID 0
packet.writeD(0x00); // m_nSkillID 1
packet.writeD(0x00); // m_nSkillID 2
packet.writeD(0x00); // m_nSkillID 3
packet.writeD(0x00); // m_nSkillID 4
packet.writeD(0x00); // m_nSkillID 5
packet.writeD(0x00); // m_nSkillLevel 0
packet.writeD(0x00); // m_nSkillLevel 1
packet.writeD(0x00); // m_nSkillLevel 2
packet.writeD(0x00); // m_nSkillLevel 3
packet.writeD(0x00); // m_nSkillLevel 4
packet.writeD(0x00); // m_nSkillLevel 5
packet.writeD(0x01); // m_nLevel
packet.writeD(0x00); // m_nExp
packet.writeD(_player.getHomunculusHpBonus()); // m_nHP
packet.writeD(_player.getHomunculusAtkBonus()); // m_nAttack
packet.writeD(_player.getHomunculusDefBonus()); // m_nDefence
packet.writeD((int) (_player.getHomunculusCritBonus() * 100)); // m_nCritical
}
else
{
packet.writeD(0); // Size.
}
return true;
}
}

View File

@@ -24,24 +24,18 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExHomonculusCreateStartResult implements IClientOutgoingPacket
public class ExHomunculusCreateStartResult implements IClientOutgoingPacket
{
@SuppressWarnings("unused")
private final PlayerInstance _player;
public ExHomonculusCreateStartResult(PlayerInstance player)
public ExHomunculusCreateStartResult(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_CREATE_START_RESULT.writeId(packet);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(1); // 1 - success
packet.writeD(13254); // You've sealed a homunculus' heart. In order to create it, your blood, spirit and tears are required.
return true;
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExHomunculusEnchantEXPResult implements IClientOutgoingPacket
{
private final boolean _success;
private final boolean _newLevel;
public ExHomunculusEnchantEXPResult(boolean success, boolean newLevel)
{
_success = success;
_newLevel = newLevel;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_ENCHANT_EXP_RESULT.writeId(packet);
if (!_success)
{
packet.writeD(0);
packet.writeD(13248); // Not enough upgrade points.
}
else if (!_newLevel)
{
packet.writeD(1); // success
packet.writeD(0); // SystemMessageId
}
else
{
packet.writeD(1);
packet.writeD(13239); // The homunculus' level is increased!
}
return true;
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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 org.l2jmobius.gameserver.network.serverpackets.homunculus;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author nexvill
*/
public class ExHomunculusGetEnchantPointResult implements IClientOutgoingPacket
{
private final int _enchantType;
public ExHomunculusGetEnchantPointResult(int enchantType)
{
_enchantType = enchantType;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_HOMUNCULUS_GET_ENCHANT_POINT_RESULT.writeId(packet);
if (_enchantType != 2)
{
packet.writeD(1); // success
packet.writeD(_enchantType);
packet.writeD(13238); // You've obtained upgrade points.
}
else
{
packet.writeD(1);
packet.writeD(_enchantType);
packet.writeD(13272); // VP added.
}
return true;
}
}

Some files were not shown because too many files have changed in this diff Show More