Package com.l2jfrozen.gameserver.skills.effects

Source Code of com.l2jfrozen.gameserver.skills.effects.EffectTargetMe

/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package com.l2jfrozen.gameserver.skills.effects;

import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.model.L2Effect;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.skills.Env;



/**
*
* @author Kiannzell
*
*/

public class EffectTargetMe extends L2Effect
{
  public EffectTargetMe(Env env, EffectTemplate template)
  {
    super(env, template);
  }
 
  @Override
  public EffectType getEffectType()
  {
    return EffectType.TARGET_ME;
  }
 
  @Override
  public void onStart()
  {
    // work only on players, cause mobs got their own aggro system (AGGDAMAGE, AGGREMOVE, etc)
    if (getEffected() instanceof L2PcInstance)
    {
      // add an INTENTION_ATTACK, but only if victim got attacker as target
      if ((getEffected().getAI() == null || getEffected().getAI().getNextIntention() == null) && getEffected().getTarget() == getEffector())
        getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, getEffector());
     
      // target the agressor
      getEffected().setTarget(getEffector());
      getEffected().sendPacket(new MyTargetSelected(getEffector().getObjectId(), 0));
    }

  }
 
  @Override
  public void onExit()
  {
  }
 
  @Override
  public boolean onActionTime()
  {
    return false;
  }
}
TOP

Related Classes of com.l2jfrozen.gameserver.skills.effects.EffectTargetMe

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.