Merged with released L2J-Unity files.
This commit is contained in:
@@ -1,123 +1,122 @@
|
||||
/*
|
||||
* 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 handlers.effecthandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.model.L2PetData;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.conditions.Condition;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.effects.L2EffectType;
|
||||
import com.l2jmobius.gameserver.model.holders.PetItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetItemList;
|
||||
|
||||
/**
|
||||
* Summon Pet effect implementation.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class SummonPet extends AbstractEffect
|
||||
{
|
||||
public SummonPet(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
|
||||
{
|
||||
super(attachCond, applyCond, set, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2EffectType getEffectType()
|
||||
{
|
||||
return L2EffectType.SUMMON_PET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstant()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(BuffInfo info)
|
||||
{
|
||||
if ((info.getEffector() == null) || (info.getEffected() == null) || !info.getEffector().isPlayer() || !info.getEffected().isPlayer() || info.getEffected().isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = info.getEffector().getActingPlayer();
|
||||
|
||||
if (player.hasPet() || player.isMounted())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ALREADY_HAVE_A_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
final PetItemHolder holder = player.removeScript(PetItemHolder.class);
|
||||
if (holder == null)
|
||||
{
|
||||
_log.log(Level.WARNING, "Summoning pet without attaching PetItemHandler!", new Throwable());
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = holder.getItem();
|
||||
if (player.getInventory().getItemByObjectId(item.getObjectId()) != item)
|
||||
{
|
||||
_log.log(Level.WARNING, "Player: " + player + " is trying to summon pet from item that he doesn't owns.");
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PetData petData = PetDataTable.getInstance().getPetDataByItemId(item.getId());
|
||||
if ((petData == null) || (petData.getNpcId() == -1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(petData.getNpcId());
|
||||
final L2PetInstance pet = L2PetInstance.spawnPet(npcTemplate, player, item);
|
||||
|
||||
pet.setShowSummonAnimation(true);
|
||||
if (!pet.isRespawned())
|
||||
{
|
||||
pet.setCurrentHp(pet.getMaxHp());
|
||||
pet.setCurrentMp(pet.getMaxMp());
|
||||
pet.getStat().setExp(pet.getExpForThisLevel());
|
||||
pet.setCurrentFed(pet.getMaxFed());
|
||||
}
|
||||
|
||||
pet.setRunning();
|
||||
|
||||
if (!pet.isRespawned())
|
||||
{
|
||||
pet.storeMe();
|
||||
}
|
||||
|
||||
item.setEnchantLevel(pet.getLevel());
|
||||
player.setPet(pet);
|
||||
pet.spawnMe(player.getX() + 50, player.getY() + 100, player.getZ());
|
||||
pet.startFeed();
|
||||
pet.setFollowStatus(true);
|
||||
pet.getOwner().sendPacket(new PetItemList(pet.getInventory().getItems()));
|
||||
pet.broadcastStatusUpdate();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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 handlers.effecthandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PetDataTable;
|
||||
import com.l2jmobius.gameserver.model.L2PetData;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.effects.L2EffectType;
|
||||
import com.l2jmobius.gameserver.model.holders.PetItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetItemList;
|
||||
|
||||
/**
|
||||
* Summon Pet effect implementation.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class SummonPet extends AbstractEffect
|
||||
{
|
||||
public SummonPet(StatsSet params)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public L2EffectType getEffectType()
|
||||
{
|
||||
return L2EffectType.SUMMON_PET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInstant()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
|
||||
{
|
||||
if (!effector.isPlayer() || !effected.isPlayer() || effected.isAlikeDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = effector.getActingPlayer();
|
||||
|
||||
if (player.hasPet() || player.isMounted())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_ALREADY_HAVE_A_PET);
|
||||
return;
|
||||
}
|
||||
|
||||
final PetItemHolder holder = player.removeScript(PetItemHolder.class);
|
||||
if (holder == null)
|
||||
{
|
||||
_log.log(Level.WARNING, "Summoning pet without attaching PetItemHandler!", new Throwable());
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance collar = holder.getItem();
|
||||
if (player.getInventory().getItemByObjectId(collar.getObjectId()) != collar)
|
||||
{
|
||||
_log.warning("Player: " + player + " is trying to summon pet from item that he doesn't owns.");
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PetData petData = PetDataTable.getInstance().getPetDataByItemId(collar.getId());
|
||||
if ((petData == null) || (petData.getNpcId() == -1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(petData.getNpcId());
|
||||
final L2PetInstance pet = L2PetInstance.spawnPet(npcTemplate, player, collar);
|
||||
|
||||
pet.setShowSummonAnimation(true);
|
||||
if (!pet.isRespawned())
|
||||
{
|
||||
pet.setCurrentHp(pet.getMaxHp());
|
||||
pet.setCurrentMp(pet.getMaxMp());
|
||||
pet.getStat().setExp(pet.getExpForThisLevel());
|
||||
pet.setCurrentFed(pet.getMaxFed());
|
||||
}
|
||||
|
||||
pet.setRunning();
|
||||
|
||||
if (!pet.isRespawned())
|
||||
{
|
||||
pet.storeMe();
|
||||
}
|
||||
|
||||
collar.setEnchantLevel(pet.getLevel());
|
||||
player.setPet(pet);
|
||||
pet.spawnMe(player.getX() + 50, player.getY() + 100, player.getZ());
|
||||
pet.startFeed();
|
||||
pet.setFollowStatus(true);
|
||||
pet.getOwner().sendPacket(new PetItemList(pet.getInventory().getItems()));
|
||||
pet.broadcastStatusUpdate();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user