Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ItemHandler.java
- agregar esto
- + registerItemHandler(new MagicGem());
- MagicGem.java
- package l2jorion.game.handler.item;
- import l2jorion.Config;
- import l2jorion.game.handler.IItemHandler;
- import l2jorion.game.managers.GrandBossManager;
- import l2jorion.game.model.L2World;
- import l2jorion.game.model.actor.instance.L2ItemInstance;
- import l2jorion.game.model.actor.instance.L2PcInstance;
- import l2jorion.game.model.actor.instance.L2PlayableInstance;
- import l2jorion.game.model.zone.ZoneId;
- import l2jorion.game.taskmanager.AttackStanceTaskManager;
- public class MagicGem implements IItemHandler
- {
- private static final int[] ITEM_IDS =
- {
- Config.ITEM_SPAWNID
- };
- @Override
- public void useItem(L2PlayableInstance playable, L2ItemInstance magicGem)
- {
- if (!(playable instanceof L2PcInstance))
- {
- return;
- }
- L2PcInstance player = (L2PcInstance) playable;
- if (player.isMoving())
- {
- player.sendMessage("You cannot use a Magic Gem right now.");
- return;
- }
- if (player.inObserverMode())
- {
- player.sendMessage("You cannot use a Magic Gem right now.");
- return;
- }
- if (player.isCastingNow())
- {
- player.sendMessage("You cannot use a Magic Gem right now.");
- return;
- }
- if ((player.isMounted()))
- {
- player.sendMessage("You cannot use a Magic Gem right now.");
- return;
- }
- if (player.isAttackingNow())
- {
- player.sendMessage("You cannot use a Magic Gem right now.");
- return;
- }
- if (player.isSpawnHelperEnabled())
- {
- player.unspawnServitors();
- player.setspawnhelper(false);
- // player.setInstanceId(0);
- }
- if (!GrandBossManager.getInstance().checkIfInZone(null, player) && !player.isInsideZone(ZoneId.ZONE_PVP) && (!player.isInsideZone(ZoneId.ZONE_NOSUMMONFRIEND) && !player.isInsideZone(ZoneId.ZONE_SIEGE)) && !player.isInOlympiadMode()
- && !AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && player.getPvpFlag() == 0 && !player.isSpawnHelperEnabled())
- {
- player.spawnServitors();
- player.getAppearance().setInvisible();
- player.decayMe();
- L2World.getInstance().addPlayerToWorld(player);
- player.broadcastUserInfo();
- player.spawnMe();
- player.setspawnhelper(true);
- player.sendMessage("You use a Magic Gem.");
- }
- else
- {
- player.sendMessage("You cannot use a Magic Gem right now.");
- }
- }
- @Override
- public int[] getItemIds()
- {
- return ITEM_IDS;
- }
- }
- Config.java
- public static int ITEM_SPAWNID;
- public static int NPC1_SPAWN_MAGIC_GEM;
- public static int NPC2_SPAWN_MAGIC_GEM;
- public static int NPC3_SPAWN_MAGIC_GEM;
- public static int NPC4_SPAWN_MAGIC_GEM;
- ITEM_SPAWNID = Integer.parseInt(L2jOrionSettings.getProperty("ItemIdSpawn", "5072"));
- NPC1_SPAWN_MAGIC_GEM = Integer.parseInt(L2jOrionSettings.getProperty("NpcIdSpawn1", "31228"));
- NPC2_SPAWN_MAGIC_GEM = Integer.parseInt(L2jOrionSettings.getProperty("NpcIdSpawn2", "7077"));
- NPC3_SPAWN_MAGIC_GEM = Integer.parseInt(L2jOrionSettings.getProperty("NpcIdSpawn3", "4"));
- NPC4_SPAWN_MAGIC_GEM = Integer.parseInt(L2jOrionSettings.getProperty("NpcIdSpawn4", "7"));
- Config/main/L2jOrion.ini
- ItemIdSpawn = 5072
- NpcIdSpawn1 = 31228
- NpcIdSpawn2 = 7077
- NpcIdSpawn3 = 4
- NpcIdSpawn4 = 7
- L2PcInstance.java
- private boolean _spawnhelper = false;
- public boolean isSpawnHelperEnabled()
- {
- return _spawnhelper;
- }
- public void setspawnhelper(boolean val)
- {
- _spawnhelper = val;
- }
- // Magic Gem
- private L2Spawn[] _npcServitors = new L2Spawn[4];
- private L2Spawn getNpcServitor(int id)
- {
- if (_npcServitors[id] != null)
- {
- return _npcServitors[id];
- }
- L2Spawn spawn = null;
- try
- {
- L2NpcTemplate tmpl;
- switch (id)
- {
- case 0:
- tmpl = NpcTable.getInstance().getTemplate(Config.NPC1_SPAWN_MAGIC_GEM);
- break;
- case 1:
- tmpl = NpcTable.getInstance().getTemplate(Config.NPC2_SPAWN_MAGIC_GEM);
- break;
- case 2:
- tmpl = NpcTable.getInstance().getTemplate(Config.NPC3_SPAWN_MAGIC_GEM);
- break;
- default:
- tmpl = NpcTable.getInstance().getTemplate(Config.NPC4_SPAWN_MAGIC_GEM);
- }
- spawn = new L2Spawn(tmpl);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- _npcServitors[id] = spawn;
- return _npcServitors[id];
- }
- // public Instance _instance = null;
- public void spawnServitors()
- {
- // /** The _player. */
- // final L2PcInstance _player;
- // _player = L2PcInstance.this;
- // InstanceManager.getInstance().createInstance(getObjectId());
- L2Spawn servitor;
- float angle = Rnd.get(1000);
- int sCount = 4;
- for (int i = 0; i < sCount; i++)
- {
- servitor = getNpcServitor(i);
- if (servitor != null)
- {
- // servitor.setInstanceId(getObjectId());
- // _player.setInstanceId(getObjectId());
- servitor.setLocx(Math.round(getX() + (float) Math.cos(angle / 1000 * 2 * Math.PI) * 30));
- servitor.setLocy(Math.round(getY() + (float) Math.sin(angle / 1000 * 2 * Math.PI) * 65));
- servitor.setLocz(getZ());
- int heading = (int) Math.round(Math.atan2(getY() - servitor.getLocy(), getX() - servitor.getLocx()) / Math.PI * 32768);
- if (heading < 0)
- {
- heading = 65535 + heading;
- }
- servitor.setHeading(heading);
- // if (InstanceManager.getInstance().getInstance(getObjectId()) != null)
- // {
- servitor.doSpawn();
- servitor.getNpc().setTitle(_player.getName());
- // }
- }
- angle += 1000 / sCount;
- }
- }
- public void unspawnServitors()
- {
- L2Spawn servitor;
- int sCount = 4;
- for (int i = 0; i < sCount; i++)
- {
- servitor = getNpcServitor(i);
- if (servitor != null)
- {
- servitor.getLastSpawn().deleteMe();
- }
- }
- }
- l2jorion.game.ai.AbstractAI
- public void moveTo(int x, int y, int z)
- {
- if (!_actor.isMovementDisabled())
- {
- _clientMoving = true;
- _clientMovingToPawnOffset = 0;
- _actor.moveToLocation(x, y, z, 0);
- _actor.broadcastPacket(new CharMoveToLocation(_actor));
- }
- else
- {
- clientActionFailed();
- }
- + if (_actor instanceof L2PcInstance)
- + {
- + if (((L2PcInstance) _actor).isSpawnHelperEnabled() && _actor.isMoving())
- + {
- + ((L2PcInstance) _actor).unspawnServitors();
- + ((L2PcInstance) _actor).setspawnhelper(false);
- // _actor.setInstanceId(0);
- + ((L2PcInstance) _actor).getAppearance().setVisible();
- + ((L2PcInstance) _actor).broadcastUserInfo();
- + }
- + }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement