if (Config.DEBUG)
_log.fine("player has a pet already. ignore summon skill");
return;
}
L2SummonInstance summon;
L2NpcTemplate summonTemplate = NpcTable.getInstance().getTemplate(_npcId);
if (summonTemplate == null)
{
_log.warning("Summon attempt for nonexisting NPC ID:"+_npcId+", skill ID:"+this.getId());
return; // npcID doesn't exist
}
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() >= ExperienceData.getInstance().getMaxLevel())
{
summon.getStat().setExp(ExperienceData.getInstance().getExpForLevel(ExperienceData.getInstance().getMaxPetLevel() - 1));
_log.warning("Summon ("+summon.getName()+") NpcID: "+summon.getNpcId()+" has a level above 75. Please rectify.");
}
else
{
summon.getStat().setExp(ExperienceData.getInstance().getExpForLevel(summon.getLevel() % ExperienceData.getInstance().getMaxPetLevel()));
}
summon.setCurrentHp(summon.getMaxHp());
summon.setCurrentMp(summon.getMaxMp());
summon.setHeading(activeChar.getHeading());
summon.setRunning();
activeChar.setPet(summon);
L2World.getInstance().storeObject(summon);
//Check to see if we should do the decay right after the cast
if(getTargetType() == SkillTargetType.TARGET_CORPSE_MOB)
{
L2Character target = (L2Character) targets[0];
if(target.isDead() && target instanceof L2NpcInstance)
{
summon.spawnMe(target.getX(), target.getY(), target.getZ() + 5);
((L2NpcInstance) target).endDecayTask();
}
}
else
{
summon.spawnMe(activeChar.getX() + Rnd.get(40)-20, activeChar.getY() + Rnd.get(40)-20, activeChar.getZ());
}
summon.setFollowStatus(true);
summon.setShowSummonAnimation(false); // addVisibleObject created the info packets with summon animation
// if someone comes into range now, the animation shouldnt show any more
activeChar.sendPacket(new PetInfo(summon));
}