Public feed #725400

Something

public text v1 · immutable
Raw Edit
·published 2007-10-04 11:41 UTC
rendered paste body
/*
 * 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 2, 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package net.sf.l2j.gameserver.model.actor.instance;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
import net.sf.l2j.gameserver.instancemanager.L2JOneoCustomManager;
import net.sf.l2j.gameserver.instancemanager.SiegeManager;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.L2Spawn;
import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.gameserver.templates.L2NpcTemplate;
import net.sf.l2j.util.Rnd;

/**
 *
 * @Author DaRkRaGe [L2JOneo]
 */
public final class L2JOneoCustomInstance extends L2MonsterInstance
{
    private static final int RAIDBOSS_MAINTENANCE_INTERVAL = 30000; // 30 sec
    private L2JOneoCustomManager.StatusEnum _raidStatus;

	/**
	 * Constructor of L2JOneoCostumInstance (use L2Character and L2NpcInstance constructor).<BR><BR>
	 */
	public L2JOneoCustomInstance(int objectId, L2NpcTemplate template)
	{
		super(objectId, template);
	}

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

    @Override
	protected int getMaintenanceInterval() { return RAIDBOSS_MAINTENANCE_INTERVAL; }

    @Override
	public void doDie(L2Character killer)
        {
		if (killer instanceof L2PlayableInstance && (killer instanceof L2MinionInstance) && (killer instanceof L2PcInstance))
		{
			L2PcInstance player = null;
			{
				player = (L2PcInstance) killer;
			}
			boolean Siege = SiegeManager.getInstance().checkIfInZone(this);
			Castle castle = CastleManager.getInstance().getCastle(this);		
			L2Clan clan = player.getClan();
			if (player.getClan() != null)
				player.sendMessage("You need a clan for this Siege");
			
		else
		
		if (Siege == true && Config.ENABLE_FACTION_KOOFS_NOOBS)
		{
			castle.getCastleId();
			castle.setOwner(clan);
		}
			L2JOneoCustomManager.getInstance().updateStatus(this, true);

			super.doDie(killer);
		}
	}

		
    /**
     * Spawn all minions at a regular interval
     * Also if boss is too far from home location at the time of this check, teleport it home
     *
     */
    @Override
    protected void manageMinions()
    {
        _minionList.spawnMinions();
        _minionMaintainTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable() {
            public void run()
            {
                // teleport raid boss home if it's too far from home location
                L2Spawn bossSpawn = getSpawn();
                if(!isInsideRadius(bossSpawn.getLocx(),bossSpawn.getLocy(),bossSpawn.getLocz(), 5000, true, false))
                {
                    teleToLocation(bossSpawn.getLocx(),bossSpawn.getLocy(),bossSpawn.getLocz(), true);
                    healFull(); // prevents minor exploiting with it
                }
                _minionList.maintainMinions();
            }
        }, 60000, getMaintenanceInterval()+Rnd.get(5000));
    }

    public void setRaidStatus (L2JOneoCustomManager.StatusEnum status)
    {
    	_raidStatus = status;
    }

    public L2JOneoCustomManager.StatusEnum getRaidStatus()
    {
    	return _raidStatus;
    }
     /**
     * Reduce the current HP of the L2Attackable, update its _aggroList and launch the doDie Task if necessary.<BR><BR>
     *
     */
    @Override
	public void reduceCurrentHp(double damage, L2Character attacker, boolean awake)
    {
        super.reduceCurrentHp(damage, attacker, awake);
    }

    public void healFull()
    {
        super.setCurrentHp(super.getMaxHp());
        super.setCurrentMp(super.getMaxMp());
    }

}