/*
* 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 ai;
import lineage2.commons.util.Rnd;
import lineage2.gameserver.ai.Guard;
import lineage2.gameserver.model.Creature;
import lineage2.gameserver.model.instances.NpcInstance;
import lineage2.gameserver.utils.Location;
/**
* @author Mobius
* @version $Revision: 1.0 $
*/
public class AirshipGuard2 extends Guard
{
/**
* Field points.
*/
static final Location[] points =
{
new Location(-148162, 255173, -180),
new Location(-148242, 254842, -184),
new Location(-148395, 254647, -184),
new Location(-148607, 254347, -184),
new Location(-148781, 254206, -184),
new Location(-149090, 254012, -180),
new Location(-148309, 255135, -181),
new Location(-148357, 254894, -183),
new Location(-148461, 254688, -183),
new Location(-148643, 254495, -183),
new Location(-148828, 254275, -183),
new Location(-149093, 254183, -180)
};
/**
* Field current_point.
*/
private int current_point = -1;
/**
* Field wait_timeout.
*/
private long wait_timeout = 0;
/**
* Field wait.
*/
private boolean wait = false;
/**
* Constructor for AirshipGuard2.
* @param actor NpcInstance
*/
public AirshipGuard2(NpcInstance actor)
{
super(actor);
}
/**
* Method isGlobalAI.
* @return boolean
*/
@Override
public boolean isGlobalAI()
{
return true;
}
/**
* Method thinkActive.
* @return boolean
*/
@Override
protected boolean thinkActive()
{
final NpcInstance actor = getActor();
if (actor.isDead())
{
return true;
}
if (_def_think)
{
doTask();
return true;
}
if ((System.currentTimeMillis() > wait_timeout) && ((current_point > -1) || Rnd.chance(5)))
{
if (!wait && ((current_point == 0) || (current_point == 8)))
{
wait_timeout = System.currentTimeMillis() + Rnd.get(0, 30000);
wait = true;
return true;
}
wait_timeout = 0;
wait = false;
current_point++;
if (current_point >= points.length)
{
current_point = 0;
}
addTaskMove(Location.findPointToStay(actor, points[current_point], 0, 100), true);
doTask();
return true;
}
return false;
}
/**
* Method onEvtAttacked.
* @param attacker Creature
* @param damage int
*/
@Override
protected void onEvtAttacked(Creature attacker, int damage)
{
// empty method
}
/**
* Method onEvtAggression.
* @param target Creature
* @param aggro int
*/
@Override
protected void onEvtAggression(Creature target, int aggro)
{
// empty method
}
}