Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis
- diff --git aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- index 1792260..a62cd7b 100644
- --- aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- +++ aCis_game/java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
- @@ -41,6 +41,25 @@
- final IntIntHolder sitem = SummonItemData.getInstance().getSummonItem(item.getItemId());
- + final NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(sitem.getId());
- + if (npcTemplate == null)
- + return;
- +
- + if (npcTemplate.getType().equalsIgnoreCase("Agathion"))
- + {
- + if (player.getAgathion() != null)
- + {
- + player.getAgathion().unSummon(player);
- + item.setAgathion(player, false);
- + player.sendMessage("Agathion has been unsummoned");
- + return;
- + }
- + item.setAgathion(player, true);
- + item.checkProtected(player);
- + player.getAI().tryToCast(player, SkillTable.getInstance().getInfo(2046, 1), false, false, item.getObjectId());
- + return;
- + }
- +
- if ((player.getSummon() != null || player.isMounted()) && sitem.getValue() > 0)
- {
- player.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
- @@ -53,10 +72,6 @@
- return;
- }
- - final NpcTemplate npcTemplate = NpcData.getInstance().getTemplate(sitem.getId());
- - if (npcTemplate == null)
- - return;
- -
- switch (sitem.getValue())
- {
- case 0: // static summons (like Christmas tree)
- diff --git aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
- index 30cc469..ebc1666 100644
- --- aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
- +++ aCis_game/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
- @@ -6,10 +6,12 @@
- import net.sf.l2j.gameserver.enums.skills.SkillType;
- import net.sf.l2j.gameserver.geoengine.GeoEngine;
- import net.sf.l2j.gameserver.handler.ISkillHandler;
- +import net.sf.l2j.gameserver.idfactory.IdFactory;
- import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.Creature;
- import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
- import net.sf.l2j.gameserver.model.actor.instance.Pet;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- import net.sf.l2j.gameserver.model.holder.IntIntHolder;
- @@ -41,10 +43,6 @@
- if (item.getOwnerId() != player.getObjectId() || item.getLocation() != ItemLocation.INVENTORY)
- return;
- - // Owner has a pet listed in world.
- - if (World.getInstance().getPet(player.getObjectId()) != null)
- - return;
- -
- // Check summon item validity.
- final IntIntHolder summonItem = SummonItemData.getInstance().getSummonItem(item.getItemId());
- if (summonItem == null)
- @@ -55,6 +53,37 @@
- if (npcTemplate == null)
- return;
- + if (npcTemplate.getType().equalsIgnoreCase("Agathion"))
- + {
- + if (player.getAgathion() != null)
- + player.getAgathion().unSummon(player);
- +
- + Agathion summon;
- + summon = new Agathion(IdFactory.getInstance().getNextId(), npcTemplate, player);
- + player.setAgathion(summon);
- + // summon.setInstanceId(player.getInstanceId());
- +
- + summon.setName(npcTemplate.getName());
- + summon.setTitle(player.getName());
- + summon.getStatus().setMaxHpMp();
- + summon.forceRunStance();
- +
- + final SpawnLocation spawnLoc = activeChar.getPosition().clone();
- + spawnLoc.addStrictOffset(40);
- + spawnLoc.setHeadingTo(activeChar.getPosition());
- + spawnLoc.set(GeoEngine.getInstance().getValidLocation(activeChar, spawnLoc));
- +
- + summon.spawnMe(spawnLoc);
- + summon.setInvul(true);
- + summon.getAI().setFollowStatus(true);
- + item.setAgathionItem(player);
- + return;
- + }
- +
- + // Owner has a pet listed in world.
- + if (World.getInstance().getPet(player.getObjectId()) != null)
- + return;
- +
- // Add the pet instance to world.
- final Pet pet = Pet.restore(item, npcTemplate, player);
- if (pet == null)
- diff --git aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java
- index 023516a..64c28dd 100644
- --- aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java
- +++ aCis_game/java/net/sf/l2j/gameserver/model/actor/Player.java
- @@ -107,6 +107,7 @@
- import net.sf.l2j.gameserver.model.actor.container.player.Request;
- import net.sf.l2j.gameserver.model.actor.container.player.ShortcutList;
- import net.sf.l2j.gameserver.model.actor.container.player.SubClass;
- +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
- import net.sf.l2j.gameserver.model.actor.instance.Door;
- import net.sf.l2j.gameserver.model.actor.instance.FestivalMonster;
- import net.sf.l2j.gameserver.model.actor.instance.Folk;
- @@ -373,6 +374,7 @@
- private final QuestList _questList = new QuestList(this);
- private Summon _summon;
- + private Agathion aga;
- private TamedBeast _tamedBeast;
- private int _partyRoom;
- @@ -6489,6 +6491,9 @@
- else if (_summon != null)
- _summon.unSummon(this);
- + if (getAgathion() != null)
- + aga.unSummon(this);
- +
- // Stop all scheduled tasks.
- stopChargeTask();
- @@ -7407,4 +7412,14 @@
- return gms;
- }
- +
- + public void setAgathion(Agathion aga)
- + {
- + this.aga = aga;
- + }
- +
- + public Agathion getAgathion()
- + {
- + return aga;
- + }
- }
- \ No newline at end of file
- diff --git aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
- index f666547..778fc12 100644
- --- aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
- +++ aCis_game/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
- @@ -273,7 +273,7 @@
- switch (skill.getSkillType())
- {
- case SUMMON:
- - if (!((L2SkillSummon) skill).isCubic() && (_actor.getSummon() != null || _actor.isMounted()))
- + if (!((L2SkillSummon) skill).isAgathion() && !((L2SkillSummon) skill).isCubic() && (_actor.getSummon() != null || _actor.isMounted()))
- {
- _actor.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
- return false;
- diff --git aCis_game/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java aCis_game/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java
- new file mode 100644
- index 0000000..87861da
- --- /dev/null
- +++ aCis_game/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java
- @@ -0,0 +1,192 @@
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import java.util.concurrent.Future;
- +
- +import net.sf.l2j.commons.math.MathUtil;
- +import net.sf.l2j.commons.pool.ThreadPool;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.gameserver.model.actor.Npc;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
- +import net.sf.l2j.gameserver.model.location.Location;
- +import net.sf.l2j.gameserver.model.location.SpawnLocation;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.PetDelete;
- +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
- +import net.sf.l2j.gameserver.skills.L2Skill;
- +
- +/**
- + * @author maxi5
- + *
- + */
- +public class Agathion extends Npc
- +{
- + private Player _owner;
- + private Future<?> _followTask;
- +
- + private ItemInstance item;
- +
- + public Agathion(int objectId, NpcTemplate template, Player owner, L2Skill skill)
- + {
- + super(objectId, template);
- +
- + // Set the magical circle animation.
- + setShowSummonAnimation(true);
- +
- + // Set the Player owner.
- + _owner = owner;
- + }
- +
- + public Agathion(int objectId, NpcTemplate template, Player owner)
- + {
- + super(objectId, template);
- +
- + // Set the magical circle animation.
- + setShowSummonAnimation(true);
- +
- + // Set the Player owner.
- + _owner = owner;
- + }
- +
- + @Override
- + public Player getActingPlayer()
- + {
- + return _owner;
- + }
- +
- + @Override
- + public void onInteract(Player player)
- + {
- + if (player.getTarget() != this)
- + player.setTarget(_owner);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +
- + @Override
- + public void onAction(Player player, boolean isCtrlPressed, boolean isShiftPressed)
- + {
- + // Set the target of the player
- + if (player.getTarget() != this)
- + player.setTarget(_owner);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- +
- + @Override
- + public void onSpawn()
- + {
- + setTitle(_owner.getName());
- + followToOwner();
- + super.onSpawn();
- + }
- +
- + public final Player getOwner()
- + {
- + return _owner;
- + }
- +
- + public void setOwner(Player newOwner)
- + {
- + _owner = newOwner;
- + }
- +
- + @Override
- + public final int getNpcId()
- + {
- + return getTemplate().getNpcId();
- + }
- +
- + public void unSummon(Player owner)
- + {
- + // Abort attack, cast and move.
- + abortAll(true);
- +
- + if (item != null)
- + item.setAgathion(owner, false);
- +
- + owner.sendPacket(new PetDelete(2, getObjectId()));
- + owner.setAgathion(null);
- +
- + if (getOwner().getSummon() != null)
- + owner.getSummon().sendInfo(owner);
- + owner.broadcastUserInfo();
- +
- + if (_followTask != null)
- + _followTask.cancel(true);
- +
- + decayMe();
- + deleteMe();
- +
- + super.deleteMe();
- + }
- +
- + @Override
- + public void onTeleported()
- + {
- + getAI().tryToFollow(getOwner(), false);
- + super.onTeleported();
- + }
- +
- + /**
- + *
- + */
- + public void followToOwner()
- + {
- + if (_followTask == null)
- + _followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 1000, 1000);
- +
- + // TODO Auto-generated method stub
- +
- + Player owner = getOwner();
- + SpawnLocation loc = owner.getPosition();
- + int rnd = Rnd.get(-20, +30);
- + boolean action = Rnd.get(10) < 2;
- +
- + if (!checkIfInRange(2000, this, owner))
- + teleportTo(owner.getPosition(), 30);
- + else if (!checkIfInRange(750, this, owner))
- + instantTeleportTo(owner.getPosition(), 30);
- +
- + if (owner.isMoving())
- + getAI().tryToFollow(owner, false);
- + else
- + {
- + if (checkIfInRange(30, this, owner))
- + {
- + getAI().tryToIdle();
- + if (action)
- + broadcastPacket(new SocialAction(this, 1));
- + }
- + if (!checkIfInRange(75, this, owner) || action)
- + getAI().tryToMoveTo(new Location(loc.getX()+rnd, loc.getY()+rnd, loc.getZ()), null);
- + }
- + }
- +
- + private static class Follow implements Runnable
- + {
- + private final Agathion agathion;
- +
- + protected Follow(Agathion aga)
- + {
- + agathion = aga;
- + }
- +
- + @Override
- + public void run()
- + {
- + agathion.followToOwner();
- + }
- + }
- +
- + public static boolean checkIfInRange(int range, Npc npc, Player player)
- + {
- + return MathUtil.checkIfInRange((int) (range + npc.getCollisionRadius()), npc, player, true);
- + }
- +
- + public void setAgathionItem(ItemInstance item)
- + {
- + this.item = item;
- + // TODO Auto-generated method stub
- + }
- +}
- \ No newline at end of file
- diff --git aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
- index 8429f78..940e74b 100644
- --- aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
- +++ aCis_game/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
- @@ -4,6 +4,7 @@
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.util.List;
- +import java.util.concurrent.Future;
- import java.util.concurrent.ScheduledFuture;
- import java.util.concurrent.locks.ReentrantLock;
- import java.util.logging.Level;
- @@ -104,6 +105,9 @@
- private int _shotsMask = 0;
- + private boolean isAgathion;
- + private Future<?> _protectedTask;
- +
- /**
- * Constructor of the ItemInstance from the objectId and the itemId.
- * @param objectId : int designating the ID of the object in the world
- @@ -487,7 +491,7 @@
- */
- public boolean isDropable()
- {
- - return isAugmented() ? false : _item.isDropable();
- + return isAgathion || isAugmented() ? false : _item.isDropable();
- }
- /**
- @@ -495,7 +499,7 @@
- */
- public boolean isDestroyable()
- {
- - return isQuestItem() ? false : _item.isDestroyable();
- + return isAgathion || isQuestItem() ? false : _item.isDestroyable();
- }
- /**
- @@ -503,7 +507,7 @@
- */
- public boolean isTradable()
- {
- - return isAugmented() ? false : _item.isTradable();
- + return isAgathion || isAugmented() ? false : _item.isTradable();
- }
- /**
- @@ -521,7 +525,7 @@
- public boolean isDepositable(boolean isPrivateWareHouse)
- {
- // equipped, hero and quest items
- - if (isEquipped() || !_item.isDepositable())
- + if (isEquipped() || !_item.isDepositable() || isAgathion)
- return false;
- if (!isPrivateWareHouse)
- @@ -1275,4 +1279,47 @@
- return Integer.compare(item.getObjectId(), getObjectId());
- }
- +
- + public void setAgathion(Player player, boolean isAgathion)
- + {
- + this.isAgathion = isAgathion;
- + }
- +
- + public void checkProtected(Player player)
- + {
- + if (_protectedTask != null)
- + _protectedTask.cancel(true);
- + _protectedTask = ThreadPool.schedule(new Protected(player), 5500);
- + }
- +
- + public boolean isAgathion()
- + {
- + return isAgathion;
- + }
- +
- + public void setAgathionItem(Player player)
- + {
- + player.getAgathion().setAgathionItem(this);
- + }
- +
- + private class Protected implements Runnable
- + {
- + private final Player player;
- +
- + protected Protected(Player player)
- + {
- + this.player = player;
- + }
- +
- + @Override
- + public void run()
- + {
- + if (player.getAgathion() != null)
- + isAgathion = true;
- + else
- + isAgathion = false;
- + if (_protectedTask != null)
- + _protectedTask.cancel(true);
- + }
- + }
- }
- \ No newline at end of file
- diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
- index e963ca2..781a634 100644
- --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
- +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
- @@ -3,6 +3,7 @@
- import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
- import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -57,6 +58,12 @@
- return;
- }
- + if (target instanceof Agathion)
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- target.onAction(player, false, _isShiftAction);
- }
- diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
- index 5bbd7e8..e091a24 100644
- --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
- +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
- @@ -3,6 +3,7 @@
- import net.sf.l2j.gameserver.model.World;
- import net.sf.l2j.gameserver.model.WorldObject;
- import net.sf.l2j.gameserver.model.actor.Player;
- +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- @@ -54,6 +55,12 @@
- return;
- }
- + if (target instanceof Agathion)
- + {
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- // (player.getTarget() == target) -> This happens when you control + click a target without having had it selected beforehand. Behaves as the Action packet and will NOT trigger an attack.
- target.onAction(player, (player.getTarget() == target), _isShiftAction);
- }
- diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
- index b9c239f..b603b41 100644
- --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
- +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
- @@ -58,6 +58,12 @@
- return;
- }
- + if (itemToRemove.isAgathion())
- + {
- + player.sendPacket(SystemMessageId.CANNOT_DISCARD_THIS_ITEM);
- + return;
- + }
- +
- if (itemToRemove.isEquipped() && (!itemToRemove.isStackable() || (itemToRemove.isStackable() && _count >= itemToRemove.getCount())))
- {
- final ItemInstance[] unequipped = player.getInventory().unequipItemInSlotAndRecord(itemToRemove.getLocationSlot());
- diff --git aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
- index 6fc1ab5..1f91749 100644
- --- aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
- +++ aCis_game/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
- @@ -48,7 +48,7 @@
- if (item.isQuestItem())
- return;
- - if (_count > item.getCount())
- + if (_count > item.getCount() || item.isAgathion())
- {
- player.sendPacket(SystemMessageId.CANNOT_DISCARD_THIS_ITEM);
- return;
- diff --git aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
- index cf1d5e5..ff6b318 100644
- --- aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
- +++ aCis_game/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
- @@ -13,6 +13,7 @@
- import net.sf.l2j.gameserver.model.actor.Creature;
- import net.sf.l2j.gameserver.model.actor.Player;
- import net.sf.l2j.gameserver.model.actor.Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.Agathion;
- import net.sf.l2j.gameserver.model.actor.instance.Servitor;
- import net.sf.l2j.gameserver.model.actor.instance.SiegeSummon;
- import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
- @@ -25,6 +26,7 @@
- private final int _npcId;
- private final float _expPenalty;
- private final boolean _isCubic;
- + private final boolean _isAgathion;
- private final int _activationTime;
- private final int _activationChance;
- @@ -47,6 +49,7 @@
- _npcId = set.getInteger("npcId", 0); // default for undescribed skills
- _expPenalty = set.getFloat("expPenalty", 0.f);
- _isCubic = set.getBool("isCubic", false);
- + _isAgathion = set.getBool("isAgathion", false);
- _activationTime = set.getInteger("activationtime", 8);
- _activationChance = set.getInteger("activationchance", 30);
- @@ -84,7 +87,7 @@
- if (player.isInObserverMode())
- return false;
- - if (player.getSummon() != null)
- + if (!_isAgathion && player.getSummon() != null)
- {
- player.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
- return false;
- @@ -130,6 +133,37 @@
- }
- else
- {
- + if (_isAgathion)
- + {
- + NpcTemplate summonTemplate = NpcData.getInstance().getTemplate(_npcId);
- +
- + if (summonTemplate == null)
- + {
- + LOGGER.warn("Couldn't properly spawn with id {} ; the template is missing.", _npcId);
- + return;
- + }
- + if (activeChar.getAgathion() != null)
- + activeChar.getAgathion().unSummon(activeChar);
- + Agathion summon;
- + summon = new Agathion(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
- + activeChar.setAgathion(summon);
- +
- + summon.setName(summonTemplate.getName());
- + summon.setTitle(activeChar.getName());
- + summon.getStatus().setMaxHpMp();
- + summon.forceRunStance();
- +
- + final SpawnLocation spawnLoc = activeChar.getPosition().clone();
- + spawnLoc.addStrictOffset(40);
- + spawnLoc.setHeadingTo(activeChar.getPosition());
- + spawnLoc.set(GeoEngine.getInstance().getValidLocation(activeChar, spawnLoc));
- +
- + summon.spawnMe(spawnLoc);
- + summon.setInvul(true);
- + summon.getAI().setFollowStatus(true);
- + return;
- + }
- +
- if (activeChar.getSummon() != null || activeChar.isMounted())
- return;
- @@ -174,6 +208,11 @@
- return _isCubic;
- }
- + public final boolean isAgathion()
- + {
- + return _isAgathion;
- + }
- +
- public final int getTotalLifeTime()
- {
- return _summonTotalLifeTime;
Advertisement
Comments
-
- Tentei adaptá-lo para l2jmobius mas não tive oportunidade, muitas classes não existem ou estarão com outros nomes e outras localizações mas não consigo importá-las, embora algumas linhas estejam lá mas em classes diferentes, no final Fiquei com muitos erros e não, não consegui resolver nenhum deles hahaha espero que você adapte para l2jmobius e compartilhe
Add Comment
Please, Sign In to add comment
Advertisement