Package l2p.gameserver.model.instances

Source Code of l2p.gameserver.model.instances.L2FestivalMonsterInstance

package l2p.gameserver.model.instances;

import l2p.gameserver.ai.CtrlEvent;
import l2p.gameserver.model.L2Character;
import l2p.gameserver.model.L2Party;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.L2World;
import l2p.gameserver.model.entity.SevenSignsFestival.SevenSignsFestival;
import l2p.gameserver.model.items.L2ItemInstance;
import l2p.gameserver.serverpackets.SystemMessage;
import l2p.gameserver.tables.ItemTable;
import l2p.gameserver.templates.L2NpcTemplate;
import l2p.util.GArray;
import l2p.util.Rnd;

public class L2FestivalMonsterInstance extends L2MonsterInstance
{
  protected int _bonusMultiplier = 1;

  /**
   * Constructor<?> of L2FestivalMonsterInstance (use L2Character and L2NpcInstance constructor).<BR><BR>
   * <p/>
   * <B><U> Actions</U> :</B><BR><BR>
   * <li>Call the L2Character constructor to set the _template of the L2FestivalMonsterInstance (copy skills from template to object and link _calculators to NPC_STD_CALCULATOR) </li>
   * <li>Set the name of the L2MonsterInstance</li>
   * <li>Create a RandomAnimation Task that will be launched after the calculated delay if the server allow it </li><BR><BR>
   *
   * @param objectId      Identifier of the object to initialized
   * @param L2NpcTemplate Template to apply to the NPC
   */
  public L2FestivalMonsterInstance(int objectId, L2NpcTemplate template)
  {
    super(objectId, template);
  }

  public void setOfferingBonus(int bonusMultiplier)
  {
    _bonusMultiplier = bonusMultiplier;
  }

  @Override
  public void onSpawn()
  {
    super.onSpawn();
  }

  @Override
  public void spawnMe()
  {
    super.spawnMe();
    GArray<L2Player> pl = L2World.getAroundPlayers(this);
    if(pl.isEmpty())
    {
      return;
    }
    GArray<L2Player> alive = new GArray<L2Player>(9);
    for(L2Player p : pl)
    {
      if(!p.isDead())
      {
        alive.add(p);
      }
    }
    if(alive.isEmpty())
    {
      return;
    }
    L2Player target = alive.get(Rnd.get(alive.size()));
    getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, target, 1);
  }

  /**
   * Actions:
   * <li>Check if the killing object is a player, and then find the party they belong to.</li>
   * <li>Add a blood offering item to the leader of the party.</li>
   * <li>Update the party leader's inventory to show the new item addition.</li>
   */
  @Override
  public void doItemDrop(L2Character topDamager)
  {
    super.doItemDrop(topDamager);
    if(!topDamager.isPlayable())
    {
      return;
    }
    L2Player topDamagerPlayer = topDamager.getPlayer();
    L2Party associatedParty = topDamagerPlayer.getParty();
    if(associatedParty == null)
    {
      return;
    }
    L2Player partyLeader = associatedParty.getPartyLeader();
    if(partyLeader == null)
    {
      return;
    }
    L2ItemInstance bloodOfferings = ItemTable.getInstance().createItem(SevenSignsFestival.FESTIVAL_BLOOD_OFFERING);
    int mult = 1;
    if(getChampion() == 1)
    {
      mult = 12;
    }
    else if(getChampion() == 2)
    {
      mult = 75;
    }
    bloodOfferings.setCount(_bonusMultiplier * mult);
    partyLeader.getInventory().addItem(bloodOfferings);
    partyLeader.sendPacket(SystemMessage.obtainItems(SevenSignsFestival.FESTIVAL_BLOOD_OFFERING, _bonusMultiplier * mult, 0));
  }

  @Override
  public boolean isAggressive()
  {
    return true;
  }

  @Override
  public int getAggroRange()
  {
    return 1000;
  }

  @Override
  public boolean hasRandomAnimation()
  {
    return false;
  }
}
TOP

Related Classes of l2p.gameserver.model.instances.L2FestivalMonsterInstance

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.