L2JLisvus

Would you like to react to this message? Create an account in a few clicks or log in to continue.

    Summon with dead summons

    avatar
    confejulian


    Posts : 254
    Join date : 2016-08-27

    Summon with dead summons Empty Summon with dead summons

    Post  confejulian 15th September 2019, 23:49

    Shared the modify of l2skillsummon to you can use summon skill with death summons bodys, and you can't use with pets. After you use summon skill, dead corpse disapear instantaniusly. This code was maked on rev 582, i don't know if need any corrections to adapt to actual rev.
    Code:
    /*
     * 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 2, 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, write to the Free Software
     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
     * 02111-1307, USA.
     *
     * http://www.gnu.org/copyleft/gpl.html
     */
    package net.sf.l2j.gameserver.skills.l2skills;

    import javolution.util.FastList;
    import net.sf.l2j.gameserver.datatables.NpcTable;
    import net.sf.l2j.gameserver.idfactory.IdFactory;
    import net.sf.l2j.gameserver.instancemanager.SiegeManager;
    import net.sf.l2j.gameserver.model.L2Character;
    import net.sf.l2j.gameserver.model.L2Object;
    import net.sf.l2j.gameserver.model.L2Skill;
    import net.sf.l2j.gameserver.model.L2Summon;
    import net.sf.l2j.gameserver.model.L2World;
    import net.sf.l2j.gameserver.model.actor.instance.L2CubicInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2SiegeSummonInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
    import net.sf.l2j.gameserver.model.base.Experience;
    import net.sf.l2j.gameserver.serverpackets.SystemMessage;
    import net.sf.l2j.gameserver.templates.L2NpcTemplate;
    import net.sf.l2j.gameserver.templates.StatsSet;

    public class L2SkillSummon extends L2Skill
    {
     private final int npcId;
     private final float expPenalty;
     private final boolean isCubic;

     public L2SkillSummon(StatsSet set)
     {
     super(set);

     npcId = set.getInteger("npcId", 0); // default for undescribed skills
     expPenalty = set.getFloat("expPenalty", 0.f);
     isCubic = set.getBool("isCubic", false);
     }

     @Override
     public boolean checkCondition(L2Character activeChar, boolean itemOrWeapon)
     {
     if (activeChar instanceof L2PcInstance)
     {
     L2PcInstance player = (L2PcInstance) activeChar;

     if (player.inObserverMode())
     {
     return false;
     }

     if (!isCubic)
     {
     if ((player.getPet() != null) || player.isMounted())
     {
     player.sendMessage("You already have a pet.");
     return false;
     }

     if (player.isAttackingNow() || player.isRooted())
     {
     player.sendPacket(new SystemMessage(SystemMessage.YOU_CANNOT_SUMMON_IN_COMBAT));
     return false;
     }

     FastList<Integer> lista_summons_id = new FastList<>();
     // Los siguientes ID se refieren aquellos ID de summon por ITEM, por ejemplo el Strider.
     lista_summons_id.add(12077); // Wolf
     lista_summons_id.add(12311); // Hatchling of the Wind
     lista_summons_id.add(12312); // Hatchling of the Stars
     lista_summons_id.add(12313); // Hatchling of the Twilight
     lista_summons_id.add(12526); // Wind Strider
     lista_summons_id.add(12527); // Star Strider
     lista_summons_id.add(12528); // Twilight Strider
     lista_summons_id.add(12564); // Sin Eater (Gremlin PET)
     lista_summons_id.add(12780); // Baby Buffalo
     lista_summons_id.add(12781); // Baby Kookaburra
     lista_summons_id.add(12782); // Baby Cougar
     
     // Dejaremos estas 3 condiciones por si acaso
     L2Object target = player.getTarget();
     if (target instanceof L2SummonInstance)
     {
     // Descomentar lineas para DEBUG
     // System.out.println("L2SummonInstace ID: " + ((L2SummonInstance) target).getNpcId());
     // System.out.println("L2SummonInstance usado");
     }
     else if (target instanceof L2Summon) /** Summon por ITEM */
     {
     // System.out.println("L2Summon ID: " + ((L2Summon) target).getNpcId());
     // System.out.println("L2Summon usado");
     int id_summon = ((L2Summon) target).getNpcId();
     if (lista_summons_id.contains(id_summon))
     {
     player.sendMessage("Incorrect target");
     return false;
     }
     }
     else if (target instanceof L2PetInstance)
     {
     // System.out.println("L2PetInstance ID: " + ((L2PetInstance) target).getNpcId());
     // System.out.println("L2PetInstance usado");
     }
     if ((player.getPet() != null) || player.isMounted())
     {
     player.sendMessage("You already have a pet.");
     return false;
     }
     
     }

     // If summon siege golem (13), Summon Wild Hog Cannon (299), check if its ok to summon
     if (((getId() == 13) || (getId() == 299)) && !SiegeManager.getInstance().checkIfOkToSummon(player, false))
     {
     return false;
     }

     }
     return super.checkCondition(activeChar, itemOrWeapon);
     }

     @Override
     public void useSkill(L2Character caster, L2Object[] targets)
     {
     if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
     {
     return;
     }

     L2PcInstance activeChar = (L2PcInstance) caster;

     if (npcId == 0)
     {
     return;
     }

     if (isCubic)
     {
     for (int index = 0; index < targets.length; index++)
     {

     if (!(targets[index] instanceof L2PcInstance))
     {
     continue;
     }

     L2PcInstance target = (L2PcInstance) targets[index];

     int mastery = target.getSkillLevel(L2Skill.SKILL_CUBIC_MASTERY);
     if (mastery < 0)
     {
     mastery = 0;
     }

     if ((mastery == 0) && (target.getCubics().size() > 0) && !target.getCubics().containsKey(npcId))
     {
     // Player can have only 1 cubic - we should replace old cubic with new one
     for (L2CubicInstance c : target.getCubics().values())
     {
     c.stopAction();
     c.cancelDisappear();
     }
     target.getCubics().clear();
     }

     if ((target.getCubics().size() > mastery) || target.getCubics().containsKey(npcId))
     {
     continue;
     }

     if (target == activeChar)
     {
     target.addCubic(npcId, getLevel(), false);
     }
     else
     {
     target.addCubic(npcId, getLevel(), true);
     }
     target.broadcastUserInfo();

     }

     return;
     }

     L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(npcId);

     L2SummonInstance summon;
     if (summonTemplate.type.equalsIgnoreCase("L2SiegeSummon"))
     {
     summon = new L2SiegeSummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
     }
     else
     {
     summon = new L2SummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, this);
     }

     summon.setName(summonTemplate.name);
     summon.setTitle(activeChar.getName());
     summon.setExpPenalty(expPenalty);
     if (summon.getLevel() >= Experience.LEVEL.length)
     {
     summon.getStat().setExp(Experience.LEVEL[Experience.LEVEL.length - 1]);
     _log.warning("Summon (" + summon.getName() + ") NpcID: " + summon.getNpcId() + " has a level above 78. Please rectify.");
     }
     else
     {
     summon.getStat().setExp(Experience.LEVEL[(summon.getLevel() % Experience.LEVEL.length)]);
     }

     summon.setCurrentHp(summon.getMaxHp());
     summon.setCurrentMp(summon.getMaxMp());
     summon.setHeading(activeChar.getHeading());
     summon.setRunning();
     activeChar.setPet(summon);

     L2World.getInstance().storeObject(summon);
     summon.spawnMe(activeChar.getX() + 50, activeChar.getY() + 100, activeChar.getZ());
     
     L2Character target = (L2Character) caster.getTarget();
     if (target != null)
     {
     if (target.isDead() && (getTargetType() == SkillTargetType.TARGET_CORPSE_MOB) && (target instanceof L2NpcInstance))
     {
     /** Si se usa el cuerpo de un MOB **/
     ((L2NpcInstance) target).endDecayTask();
     // System.out.println("Sumoneaste, se debio borrar MOB");
     }
     if (target.isDead() && (getTargetType() == SkillTargetType.TARGET_CORPSE_MOB) && (target instanceof L2SummonInstance))
     {
     /** Si se usa el cuerpo de un SUMMON **/
     ((L2SummonInstance) target).decayMe();
     // System.out.println("Sumoneaste, se debio borrar SUMMON");
     }
     }
     }
    }

    regards

      Current date/time is 19th May 2024, 10:19