/** * @param skillTemplate * @param effector * @param skillLvl * @param firstTarget */ public Skill( SkillTemplate skillTemplate, Creature effector, int skillLvl, Creature firstTarget, ItemTemplate itemTemplate) { this.effectedList = new ArrayList<Creature>(); this.conditionChangeListener = new StartMovingListener(); this.firstTarget = firstTarget; this.skillLevel = skillLvl; this.skillStackLvl = skillTemplate.getLvl(); this.skillTemplate = skillTemplate; this.effector = effector; this.duration = skillTemplate.getDuration(); this.itemTemplate = itemTemplate; if (itemTemplate != null) skillMethod = SkillMethod.ITEM; else if (skillTemplate.isPassive()) skillMethod = SkillMethod.PASSIVE; else if (skillTemplate.isProvoked()) skillMethod = SkillMethod.PROVOKED; else if (skillTemplate.isCharge()) skillMethod = SkillMethod.CHARGE; }
/** Start casting of skill */ protected void startCast() { int targetObjId = firstTarget != null ? firstTarget.getObjectId() : 0; if (skillMethod == SkillMethod.CAST || skillMethod == SkillMethod.CHARGE) { switch (targetType) { case 0: // PlayerObjectId as Target PacketSendUtility.broadcastPacketAndReceive( effector, new SM_CASTSPELL( effector.getObjectId(), skillTemplate.getSkillId(), skillLevel, targetType, targetObjId, this.duration, skillTemplate.isCharge())); if (effector instanceof Npc && firstTarget instanceof Player) { NpcAI2 ai = (NpcAI2) effector.getAi2(); if (ai.poll(AIQuestion.CAN_SHOUT)) ShoutEventHandler.onCast(ai, firstTarget); } break; case 3: // Target not in sight? PacketSendUtility.broadcastPacketAndReceive( effector, new SM_CASTSPELL( effector.getObjectId(), skillTemplate.getSkillId(), skillLevel, targetType, 0, this.duration, skillTemplate.isCharge())); break; case 1: // XYZ as Target PacketSendUtility.broadcastPacketAndReceive( effector, new SM_CASTSPELL( effector.getObjectId(), skillTemplate.getSkillId(), skillLevel, targetType, x, y, z, this.duration)); break; } } else if (skillMethod == SkillMethod.ITEM && duration > 0) { PacketSendUtility.broadcastPacketAndReceive( effector, new SM_ITEM_USAGE_ANIMATION( effector.getObjectId(), firstTarget.getObjectId(), (this.itemObjectId == 0 ? 0 : this.itemObjectId), itemTemplate.getTemplateId(), this.duration, 0, 0)); } }