case AGATHION:
activeChar.setAgathion(getNpcId());
// If have lifeTime this is a servitor agathion...
if (_lifeTime > 0)
{
Skill agatSkill = getFirstAddedSkill();
NpcTemplate agatTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
AgathionInstance agat = new AgathionInstance(IdFactory.getInstance().getNextId(), agatTemplate, activeChar, _lifeTime, agatSkill, activeChar.getLoc());
agat.setReflection(activeChar.getReflection());
agat.spawnMe(activeChar.getLoc());
agat.setFollowTarget(activeChar);
agat.setIsInvul(true);
agat.setRunning();
ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(agat), _lifeTime);
}
break;
case TRAP:
Skill trapSkill = getFirstAddedSkill();
if (activeChar.getTrapsCount() >= 5)
{
activeChar.destroyFirstTrap();
}
TrapInstance trap = new TrapInstance(IdFactory.getInstance().getNextId(), NpcHolder.getInstance().getTemplate(getNpcId()), activeChar, trapSkill);
activeChar.addTrap(trap);
trap.spawnMe();
break;
case SERVITOR:
case MULTI_SERVITOR:
case SIEGE_SUMMON:
Location loc = null;
if (_targetType == SkillTargetType.TARGET_CORPSE)
{
for (Creature target : targets)
{
if ((target != null) && target.isDead())
{
activeChar.getAI().setAttackTarget(null);
loc = target.getLoc();
if (target.isNpc())
{
((NpcInstance) target).endDecayTask();
}
else if (target.isServitor())
{
((SummonInstance) target).endDecayTask();
}
else
{
return;
}
}
}
}
if (activeChar.isMounted() || !activeChar.getSummonList().canSummon(_summonType, _summonPoint))
{
return;
}
NpcTemplate summonTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
SummonInstance summon = new SummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, _lifeTime, _summonPoint, this);
activeChar.getSummonList().addSummon(summon);
summon.setExpPenalty(_expPenalty);
summon.setExp(Experience.LEVEL[Math.min(summon.getLevel(), Experience.LEVEL.length - 1)]);
summon.setHeading(activeChar.getHeading());
summon.setReflection(activeChar.getReflection());
summon.spawnMe(loc == null ? Location.findAroundPosition(activeChar, 50, 70) : loc);
summon.setRunning();
summon.setFollowMode(true);
if (summon.getSkillLevel(4140) > 0)
{
summon.altUseSkill(SkillTable.getInstance().getInfo(4140, summon.getSkillLevel(4140)), activeChar);
}
if (summon.getName().equalsIgnoreCase("Shadow"))
{
summon.addStatFunc(new FuncAdd(Stats.ABSORB_DAMAGE_PERCENT, 0x40, this, 15));
}
if (activeChar.isInOlympiadMode())
{
summon.getEffectList().stopAllEffects();
}
summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp(), false);
if (_summonType == SummonType.SIEGE_SUMMON)
{
SiegeEvent<?, ?> siegeEvent = activeChar.getEvent(SiegeEvent.class);
siegeEvent.addSiegeSummon(summon);
}
break;
case MERCHANT:
if ((activeChar.getSummonList().size() > 0) || activeChar.isMounted())
{
return;
}
NpcTemplate merchantTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
MerchantInstance merchant = new MerchantInstance(IdFactory.getInstance().getNextId(), merchantTemplate);
merchant.setCurrentHp(merchant.getMaxHp(), false);
merchant.setCurrentMp(merchant.getMaxMp());
merchant.setHeading(activeChar.getHeading());
merchant.setReflection(activeChar.getReflection());
merchant.spawnMe(activeChar.getLoc());
ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(merchant), _lifeTime);
break;
case TREE:
if (activeChar.isMounted() || !activeChar.getSummonList().canSummon(_summonType, _summonPoint))
{
return;
}
NpcTemplate treeTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
Location SummonLoc;
if (activeChar.getGroundSkillLoc() != null)
{
SummonLoc = activeChar.getGroundSkillLoc();
}
else
{
SummonLoc = activeChar.getLoc();
}
Skill summonSkill = getFirstAddedSkill();
TreeInstance tree = new TreeInstance(IdFactory.getInstance().getNextId(), treeTemplate, activeChar, _lifeTime, summonSkill, SummonLoc);
activeChar.getSummonList().addSummon(tree);
tree.setCurrentHp(tree.getMaxHp(), false);
tree.setCurrentMp(tree.getMaxMp());
tree.setHeading(activeChar.getHeading());
tree.setReflection(activeChar.getReflection());
tree.setFollowMode(false);
tree.spawnMe(SummonLoc);
ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(tree), _lifeTime);
break;
case SYMBOL:
if (activeChar.isMounted())
{
return;
}
NpcTemplate symbolTemplate = NpcHolder.getInstance().getTemplate(getNpcId());
Location symbolLoc;
if (activeChar.getGroundSkillLoc() != null)
{
symbolLoc = activeChar.getGroundSkillLoc();
}
else
{
symbolLoc = activeChar.getLoc();
}
Skill symbolSkill = getFirstAddedSkill();
SymbolInstance symbol = new SymbolInstance(IdFactory.getInstance().getNextId(), symbolTemplate, activeChar, symbolSkill);
symbol.setReflection(activeChar.getReflection());
symbol.setShowName(false);
symbol.spawnMe(symbolLoc);
ThreadPoolManager.getInstance().schedule(new GameObjectTasks.DeleteTask(symbol), _lifeTime);