Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onMagicHitTimer(L2Character[] targets, L2Skill skill, int coolTime, boolean instant, boolean simultaneously)
- {
- if (skill == null)
- {
- abortCast();
- setAttackingChar(null);
- return;
- }
- if ((targets == null || targets.length == 0) && skill.getTargetType() != SkillTargetType.TARGET_AURA)
- {
- abortCast();
- setAttackingChar(null);
- return;
- }
- if (getFusionSkill() != null)
- {
- if (simultaneously)
- {
- _skillCast2 = null;
- setIsCastingSimultaneouslyNow(false);
- }
- else
- {
- _skillCast = null;
- setIsCastingNow(false);
- }
- if(targets!=null && targets.length>0)
- notifyQuestEventSkillFinished(skill, targets[0]);
- getFusionSkill().onCastAbort();
- return;
- }
- L2Effect mog = getFirstEffect(L2EffectType.SIGNET_GROUND);
- if (mog != null)
- {
- if (simultaneously)
- {
- _skillCast2 = null;
- setIsCastingSimultaneouslyNow(false);
- }
- else
- {
- _skillCast = null;
- setIsCastingNow(false);
- }
- mog.exit();
- if(targets!=null && targets.length>0)
- notifyQuestEventSkillFinished(skill, targets[0]);
- return;
- }
- if(Config.CONSUME_ON_SUCCESS)
- consume(skill);
- try
- {
- for (L2Object element : targets)
- {
- if (element instanceof L2PlayableInstance)
- {
- L2Character target = (L2Character) element;
- if (skill.getSkillType() == L2SkillType.BUFF)
- {
- SystemMessage smsg = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
- smsg.addSkillName(skill);
- target.sendPacket(smsg);
- }
- if (this instanceof L2PcInstance && target instanceof L2Summon)
- ((L2Summon) target).broadcastFullInfo();
- }
- }
- // Consume Items if necessary and Send the Server->Client packet InventoryUpdate with Item modification to all the L2Character
- if (skill.getItemConsume() > 0)
- {
- if (!destroyItemByItemId("Consume", skill.getItemConsumeId(), skill.getItemConsume(), null, false))
- {
- sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);
- abortCast();
- return;
- }
- }
- if (this instanceof L2PcInstance)
- {
- L2PcInstance player = (L2PcInstance) this;
- // Consume Charges if necessary ... L2SkillChargeDmg does the consume by itself.
- if (skill.getNeededCharges() > 0 && !(skill instanceof L2SkillChargeDmg) && skill.getConsumeCharges())
- player.decreaseCharges(skill.getNeededCharges());
- }
- // Launch the magic skill in order to calculate its effects
- callSkill(skill, targets);
- }
- catch (Exception e)
- {
- }
- if (instant || coolTime == 0)
- onMagicFinalizer(skill, (targets==null || targets.length==0)?null:targets[0], simultaneously);
- else
- {
- if (simultaneously)
- _skillCast2 = ThreadPoolManager.getInstance().scheduleEffect(new MagicUseTask(targets, skill, coolTime, 3, simultaneously), coolTime);
- else
- _skillCast = ThreadPoolManager.getInstance().scheduleEffect(new MagicUseTask(targets, skill, coolTime, 3, simultaneously), coolTime);
- }
- }
- /**
- * Runs after skill hitTime+coolTime
- */
- public void onMagicFinalizer(L2Skill skill, L2Object target, boolean simultaneously)
- {
- if (simultaneously)
- {
- _skillCast2 = null;
- setIsCastingSimultaneouslyNow(false);
- return;
- }
- _skillCast = null;
- setIsCastingNow(false);
- _castInterruptTime = 0;
- if (skill.isOffensive() && !skill.isNeutral() && skill.getSkillType() != L2SkillType.UNLOCK && skill.getSkillType() != L2SkillType.DELUXE_KEY_UNLOCK && skill.getSkillType() != L2SkillType.MAKE_KILLABLE)
- getAI().clientStartAutoAttack();
- // Notify the AI of the L2Character with EVT_FINISH_CASTING
- getAI().notifyEvent(CtrlEvent.EVT_FINISH_CASTING);
- notifyQuestEventSkillFinished(skill, target);
- if (getAI().getIntention() != AI_INTENTION_MOVE_TO)
- {
- switch (skill.getSkillType())
- {
- case PDAM:
- case BLOW:
- case CHARGEDAM:
- case SPOIL:
- case SOW:
- case DRAIN_SOUL: // Soul Crystal casting
- if (getTarget() instanceof L2Character && getTarget() != this && target == getTarget())
- getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, getTarget());
- break;
- }
- }
- if(_chanceSkills!=null && target!=null )
- _chanceSkills.onAttack(target);
- if (this instanceof L2PcInstance)
- {
- L2PcInstance currPlayer = (L2PcInstance) this;
- SkillDat queuedSkill = currPlayer.getQueuedSkill();
- currPlayer.setCurrentSkill(null, false, false);
- if (queuedSkill != null)
- {
- currPlayer.setQueuedSkill(null, false, false);
- ThreadPoolManager.getInstance().executeAi(new QueuedMagicUseTask(currPlayer, queuedSkill.getSkill(), queuedSkill.isCtrlPressed(), queuedSkill.isShiftPressed()));
- }
- if(skill.getItemConsume()!=0)
- sendPacket(new InventoryUpdate());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement