|
@@ -14,852 +14,72 @@
|
|
*/
|
|
*/
|
|
package com.l2jserver.gameserver.model.actor.instance;
|
|
package com.l2jserver.gameserver.model.actor.instance;
|
|
|
|
|
|
-import java.io.BufferedReader;
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
|
-import java.io.FileReader;
|
|
|
|
-import java.io.LineNumberReader;
|
|
|
|
-import java.util.Collection;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.StringTokenizer;
|
|
|
|
-import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
-import com.l2jserver.Config;
|
|
|
|
-import com.l2jserver.gameserver.GameTimeController;
|
|
|
|
-import com.l2jserver.gameserver.ThreadPoolManager;
|
|
|
|
-import com.l2jserver.gameserver.ai.L2CharacterAI;
|
|
|
|
-import com.l2jserver.gameserver.model.L2ItemInstance;
|
|
|
|
-import com.l2jserver.gameserver.model.actor.L2Character;
|
|
|
|
-import com.l2jserver.gameserver.model.actor.knownlist.VehicleKnownList;
|
|
|
|
-import com.l2jserver.gameserver.model.actor.stat.VehicleStat;
|
|
|
|
-import com.l2jserver.gameserver.network.clientpackets.Say2;
|
|
|
|
-import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
|
|
|
|
-import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
|
|
|
-import com.l2jserver.gameserver.network.serverpackets.PlaySound;
|
|
|
|
-import com.l2jserver.gameserver.network.serverpackets.VehicleCheckLocation;
|
|
|
|
|
|
+import com.l2jserver.gameserver.ai.L2BoatAI;
|
|
|
|
+import com.l2jserver.gameserver.model.L2CharPosition;
|
|
|
|
+import com.l2jserver.gameserver.model.Location;
|
|
|
|
+import com.l2jserver.gameserver.model.actor.L2Vehicle;
|
|
import com.l2jserver.gameserver.network.serverpackets.VehicleDeparture;
|
|
import com.l2jserver.gameserver.network.serverpackets.VehicleDeparture;
|
|
import com.l2jserver.gameserver.network.serverpackets.VehicleInfo;
|
|
import com.l2jserver.gameserver.network.serverpackets.VehicleInfo;
|
|
import com.l2jserver.gameserver.network.serverpackets.VehicleStarted;
|
|
import com.l2jserver.gameserver.network.serverpackets.VehicleStarted;
|
|
import com.l2jserver.gameserver.templates.chars.L2CharTemplate;
|
|
import com.l2jserver.gameserver.templates.chars.L2CharTemplate;
|
|
-import com.l2jserver.gameserver.templates.item.L2Weapon;
|
|
|
|
-import com.l2jserver.gameserver.util.Util;
|
|
|
|
-
|
|
|
|
-import javolution.util.FastList;
|
|
|
|
-import javolution.util.FastMap;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @author Maktakien
|
|
|
|
|
|
+ * @author Maktakien, reworked by DS
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
-public class L2BoatInstance extends L2Character
|
|
|
|
|
|
+public class L2BoatInstance extends L2Vehicle
|
|
{
|
|
{
|
|
protected static final Logger _logBoat = Logger.getLogger(L2BoatInstance.class.getName());
|
|
protected static final Logger _logBoat = Logger.getLogger(L2BoatInstance.class.getName());
|
|
- protected final FastList<L2PcInstance> _passengers = new FastList<L2PcInstance>();
|
|
|
|
-
|
|
|
|
- private class L2BoatTrajet
|
|
|
|
- {
|
|
|
|
- private Map<Integer, L2BoatPoint> _path;
|
|
|
|
-
|
|
|
|
- public int idWaypoint1;
|
|
|
|
-
|
|
|
|
- public int idWTicket1;
|
|
|
|
-
|
|
|
|
- public int ntx1;
|
|
|
|
-
|
|
|
|
- public int nty1;
|
|
|
|
-
|
|
|
|
- public int ntz1;
|
|
|
|
-
|
|
|
|
- public int max;
|
|
|
|
-
|
|
|
|
- public String boatName;
|
|
|
|
-
|
|
|
|
- public String npc1;
|
|
|
|
-
|
|
|
|
- public String sysmess10_1;
|
|
|
|
-
|
|
|
|
- public String sysmess5_1;
|
|
|
|
-
|
|
|
|
- public String sysmess1_1;
|
|
|
|
-
|
|
|
|
- public String sysmessb_1;
|
|
|
|
-
|
|
|
|
- public String sysmess0_1;
|
|
|
|
-
|
|
|
|
- protected class L2BoatPoint
|
|
|
|
- {
|
|
|
|
- public int speed1;
|
|
|
|
-
|
|
|
|
- public int speed2;
|
|
|
|
-
|
|
|
|
- public int x;
|
|
|
|
-
|
|
|
|
- public int y;
|
|
|
|
-
|
|
|
|
- public int z;
|
|
|
|
-
|
|
|
|
- public int time;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param idWaypoint1
|
|
|
|
- * @param idWTicket1
|
|
|
|
- * @param ntx1
|
|
|
|
- * @param nty1
|
|
|
|
- * @param ntz1
|
|
|
|
- * @param idnpc1
|
|
|
|
- * @param sysmess10_1
|
|
|
|
- * @param sysmess5_1
|
|
|
|
- * @param sysmess1_1
|
|
|
|
- * @param sysmessb_1
|
|
|
|
- */
|
|
|
|
- public L2BoatTrajet(int pIdWaypoint1, int pIdWTicket1, int pNtx1, int pNty1, int pNtz1, String pNpc1, String pSysmess10_1,
|
|
|
|
- String pSysmess5_1, String pSysmess1_1, String pSysmess0_1, String pSysmessb_1, String pBoatname)
|
|
|
|
- {
|
|
|
|
- idWaypoint1 = pIdWaypoint1;
|
|
|
|
- idWTicket1 = pIdWTicket1;
|
|
|
|
- ntx1 = pNtx1;
|
|
|
|
- nty1 = pNty1;
|
|
|
|
- ntz1 = pNtz1;
|
|
|
|
- npc1 = pNpc1;
|
|
|
|
- sysmess10_1 = pSysmess10_1;
|
|
|
|
- sysmess5_1 = pSysmess5_1;
|
|
|
|
- sysmess1_1 = pSysmess1_1;
|
|
|
|
- sysmessb_1 = pSysmessb_1;
|
|
|
|
- sysmess0_1 = pSysmess0_1;
|
|
|
|
- boatName = pBoatname;
|
|
|
|
- loadBoatPath();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param line
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public void parseLine(String line)
|
|
|
|
- {
|
|
|
|
- // L2BoatPath bp = new L2BoatPath();
|
|
|
|
- _path = new FastMap<Integer, L2BoatPoint>();
|
|
|
|
- StringTokenizer st = new StringTokenizer(line, ";");
|
|
|
|
- Integer.parseInt(st.nextToken());
|
|
|
|
- max = Integer.parseInt(st.nextToken());
|
|
|
|
- for (int i = 0; i < max; i++)
|
|
|
|
- {
|
|
|
|
- L2BoatPoint bp = new L2BoatPoint();
|
|
|
|
- bp.speed1 = Integer.parseInt(st.nextToken());
|
|
|
|
- bp.speed2 = Integer.parseInt(st.nextToken());
|
|
|
|
- bp.x = Integer.parseInt(st.nextToken());
|
|
|
|
- bp.y = Integer.parseInt(st.nextToken());
|
|
|
|
- bp.z = Integer.parseInt(st.nextToken());
|
|
|
|
- bp.time = Integer.parseInt(st.nextToken());
|
|
|
|
- _path.put(i, bp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
- private void loadBoatPath()
|
|
|
|
- {
|
|
|
|
- LineNumberReader lnr = null;
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- File doorData = new File(Config.DATAPACK_ROOT, "data/boatpath.csv");
|
|
|
|
- lnr = new LineNumberReader(new BufferedReader(new FileReader(doorData)));
|
|
|
|
-
|
|
|
|
- String line = null;
|
|
|
|
- while ((line = lnr.readLine()) != null)
|
|
|
|
- {
|
|
|
|
- if (line.trim().length() == 0 || !line.startsWith(idWaypoint1 + ";"))
|
|
|
|
- continue;
|
|
|
|
- parseLine(line);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- _logBoat.warning("No path for boat " + boatName + " !!!");
|
|
|
|
- }
|
|
|
|
- catch (FileNotFoundException e)
|
|
|
|
- {
|
|
|
|
- _logBoat.warning("boatpath.csv is missing in data folder");
|
|
|
|
- }
|
|
|
|
- catch (Exception e)
|
|
|
|
- {
|
|
|
|
- _logBoat.log(Level.WARNING, "Error while creating boat table " + e.getMessage(), e);
|
|
|
|
- }
|
|
|
|
- finally
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- lnr.close();
|
|
|
|
- }
|
|
|
|
- catch (Exception e1)
|
|
|
|
- { /* ignore problems */
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param state
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public int state(int state, L2BoatInstance _boat)
|
|
|
|
- {
|
|
|
|
- if (state < max)
|
|
|
|
- {
|
|
|
|
- L2BoatPoint bp = _path.get(state);
|
|
|
|
- double dx = (_boat.getX() - bp.x);
|
|
|
|
- double dy = (_boat.getY() - bp.y);
|
|
|
|
- double distance = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
- double cos;
|
|
|
|
- double sin;
|
|
|
|
- sin = dy / distance;
|
|
|
|
- cos = dx / distance;
|
|
|
|
-
|
|
|
|
- _boat.getPosition().setHeading(Util.calculateHeadingFrom(cos, sin));
|
|
|
|
-
|
|
|
|
- getStat().setMoveSpeed(bp.speed1);
|
|
|
|
- getStat().setRotationSpeed(bp.speed2);
|
|
|
|
- _boat.moveToLocation(bp.x, bp.y, bp.z, (float) bp.speed1);
|
|
|
|
- if (bp.time == 0)
|
|
|
|
- bp.time = 1;
|
|
|
|
|
|
|
|
-// _boat.broadcastPacket(new VehicleInfo(_boat));
|
|
|
|
- _boat.broadcastPacket(new VehicleDeparture(_boat));
|
|
|
|
- return bp.time;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private String _name;
|
|
|
|
-
|
|
|
|
- protected L2BoatTrajet _t1;
|
|
|
|
-
|
|
|
|
- protected L2BoatTrajet _t2;
|
|
|
|
-
|
|
|
|
- protected int _cycle = 0;
|
|
|
|
-
|
|
|
|
- public L2BoatInstance(int objectId, L2CharTemplate template, String name)
|
|
|
|
|
|
+ public L2BoatInstance(int objectId, L2CharTemplate template)
|
|
{
|
|
{
|
|
super(objectId, template);
|
|
super(objectId, template);
|
|
setInstanceType(InstanceType.L2BoatInstance);
|
|
setInstanceType(InstanceType.L2BoatInstance);
|
|
- setAI(new L2CharacterAI(new AIAccessor()));
|
|
|
|
- /*
|
|
|
|
- * super.setStat(new DoorStat(new L2DoorInstance[] {this}));
|
|
|
|
- * super.setStatus(new DoorStatus(new L2DoorInstance[] {this}));
|
|
|
|
- */
|
|
|
|
- _name = name;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void initKnownList()
|
|
|
|
- {
|
|
|
|
- setKnownList(new VehicleKnownList(this));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public VehicleStat getStat()
|
|
|
|
- {
|
|
|
|
- return (VehicleStat)super.getStat();
|
|
|
|
|
|
+ setAI(new L2BoatAI(new AIAccessor()));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void initCharStat()
|
|
|
|
|
|
+ public boolean isBoat()
|
|
{
|
|
{
|
|
- setStat(new VehicleStat(this));
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * @param x
|
|
|
|
- * @param y
|
|
|
|
- * @param z
|
|
|
|
- */
|
|
|
|
- public void moveToLocation(int x, int y, int z, float speed)
|
|
|
|
- {
|
|
|
|
- final int curX = getX();
|
|
|
|
- final int curY = getY();
|
|
|
|
-
|
|
|
|
- // Calculate distance (dx,dy) between current position and destination
|
|
|
|
- final int dx = (x - curX);
|
|
|
|
- final int dy = (y - curY);
|
|
|
|
- double distance = Math.sqrt(dx * dx + dy * dy);
|
|
|
|
-
|
|
|
|
- if (Config.DEBUG)
|
|
|
|
- _logBoat.fine("distance to target:" + distance);
|
|
|
|
-
|
|
|
|
- // Define movement angles needed
|
|
|
|
- // ^
|
|
|
|
- // | X (x,y)
|
|
|
|
- // | /
|
|
|
|
- // | /distance
|
|
|
|
- // | /
|
|
|
|
- // |/ angle
|
|
|
|
- // X ---------->
|
|
|
|
- // (curx,cury)
|
|
|
|
-
|
|
|
|
- double cos;
|
|
|
|
- double sin;
|
|
|
|
- sin = dy / distance;
|
|
|
|
- cos = dx / distance;
|
|
|
|
- // Create and Init a MoveData object
|
|
|
|
- MoveData m = new MoveData();
|
|
|
|
-
|
|
|
|
- // Caclulate the Nb of ticks between the current position and the
|
|
|
|
- // destination
|
|
|
|
- int ticksToMove = (int) (GameTimeController.TICKS_PER_SECOND * distance / speed);
|
|
|
|
-
|
|
|
|
- // Calculate and set the heading of the L2Character
|
|
|
|
- int heading = (int) (Math.atan2(-sin, -cos) * 10430.378350470452724949566316381);
|
|
|
|
- heading += 32768;
|
|
|
|
- getPosition().setHeading(heading);
|
|
|
|
-
|
|
|
|
- if (Config.DEBUG)
|
|
|
|
- _logBoat.fine("dist:" + distance + "speed:" + speed + " ttt:" + ticksToMove + " heading:" + heading);
|
|
|
|
-
|
|
|
|
- m._xDestination = x;
|
|
|
|
- m._yDestination = y;
|
|
|
|
- m._zDestination = z; // this is what was requested from client
|
|
|
|
- m._heading = 0; // initial value for coordinate sync
|
|
|
|
- m.onGeodataPathIndex = -1; // Initialize not on geodata path
|
|
|
|
- m.disregardingGeodata = true;
|
|
|
|
- m._moveStartTime = GameTimeController.getGameTicks();
|
|
|
|
-
|
|
|
|
- if (Config.DEBUG)
|
|
|
|
- _logBoat.fine("time to target:" + ticksToMove);
|
|
|
|
-
|
|
|
|
- // Set the L2Character _move object to MoveData object
|
|
|
|
- _move = m;
|
|
|
|
-
|
|
|
|
- // Add the L2Character to movingObjects of the GameTimeController
|
|
|
|
- // The GameTimeController manage objects movement
|
|
|
|
- GameTimeController.getInstance().registerMovingObject(this);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- class BoatCaptain implements Runnable
|
|
|
|
- {
|
|
|
|
- private int _state;
|
|
|
|
-
|
|
|
|
- private L2BoatInstance _boat;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param i
|
|
|
|
- * @param instance
|
|
|
|
- */
|
|
|
|
- public BoatCaptain(int i, L2BoatInstance instance)
|
|
|
|
- {
|
|
|
|
- _state = i;
|
|
|
|
- _boat = instance;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void run()
|
|
|
|
- {
|
|
|
|
- if (_boat.getId() == 5) // Rune <-> Primeval Isle
|
|
|
|
- {
|
|
|
|
- switch (_state)
|
|
|
|
- {
|
|
|
|
- case 1:
|
|
|
|
- _boat.say(-1);
|
|
|
|
- _boat.begin();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- BoatCaptain bc;
|
|
|
|
- switch (_state)
|
|
|
|
- {
|
|
|
|
- case 1:
|
|
|
|
- _boat.say(5);
|
|
|
|
- bc = new BoatCaptain(2, _boat);
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 240000);
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- _boat.say(1);
|
|
|
|
- bc = new BoatCaptain(3, _boat);
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 40000);
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- _boat.say(0);
|
|
|
|
- bc = new BoatCaptain(4, _boat);
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 20000);
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- _boat.say(-1);
|
|
|
|
- _boat.begin();
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- class Boatrun implements Runnable
|
|
|
|
- {
|
|
|
|
- private int _state;
|
|
|
|
-
|
|
|
|
- private L2BoatInstance _boat;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param i
|
|
|
|
- * @param instance
|
|
|
|
- */
|
|
|
|
- public Boatrun(int i, L2BoatInstance instance)
|
|
|
|
- {
|
|
|
|
- _state = i;
|
|
|
|
- _boat = instance;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void run()
|
|
|
|
- {
|
|
|
|
- _boat.needOnVehicleCheckLocation = false;
|
|
|
|
- if (_boat._cycle == 1)
|
|
|
|
- {
|
|
|
|
- int time = _boat._t1.state(_state, _boat);
|
|
|
|
- if (time > 0)
|
|
|
|
- {
|
|
|
|
- _state++;
|
|
|
|
- Boatrun bc = new Boatrun(_state, _boat);
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, time);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else if (time == 0)
|
|
|
|
- {
|
|
|
|
- _boat._cycle = 2;
|
|
|
|
- _boat.say(10);
|
|
|
|
- BoatCaptain bc = new BoatCaptain(1, _boat);
|
|
|
|
- if (getId() == 5)
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 180000);
|
|
|
|
- else
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 300000);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- _boat.needOnVehicleCheckLocation = true;
|
|
|
|
- _state++;
|
|
|
|
- _boat._runstate = _state;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else if (_boat._cycle == 2)
|
|
|
|
- {
|
|
|
|
- int time = _boat._t2.state(_state, _boat);
|
|
|
|
- if (time > 0)
|
|
|
|
- {
|
|
|
|
- _state++;
|
|
|
|
- Boatrun bc = new Boatrun(_state, _boat);
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, time);
|
|
|
|
- }
|
|
|
|
- else if (time == 0)
|
|
|
|
- {
|
|
|
|
- _boat._cycle = 1;
|
|
|
|
- _boat.say(10);
|
|
|
|
- BoatCaptain bc = new BoatCaptain(1, _boat);
|
|
|
|
- if (getId() == 5)
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 180000);
|
|
|
|
- else
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 300000);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- _boat.needOnVehicleCheckLocation = true;
|
|
|
|
- _state++;
|
|
|
|
- _boat._runstate = _state;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public int _runstate = 0;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
- public void evtArrived()
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- if (_runstate != 0)
|
|
|
|
- {
|
|
|
|
- // _runstate++;
|
|
|
|
- Boatrun bc = new Boatrun(_runstate, this);
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 10);
|
|
|
|
- _runstate = 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public int getId()
|
|
|
|
- {
|
|
|
|
- return _id;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void beginCycle()
|
|
|
|
- {
|
|
|
|
- say(10);
|
|
|
|
- BoatCaptain bc = new BoatCaptain(1, this);
|
|
|
|
- if (getId() == 5)
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 180000);
|
|
|
|
- else
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(bc, 300000);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param destination
|
|
|
|
- * @param destination2
|
|
|
|
- * @param destination3
|
|
|
|
- */
|
|
|
|
- private int lastx = -1;
|
|
|
|
-
|
|
|
|
- private int lasty = -1;
|
|
|
|
-
|
|
|
|
- protected boolean needOnVehicleCheckLocation = false;
|
|
|
|
-
|
|
|
|
- private int _id;
|
|
|
|
-
|
|
|
|
- public void updatePeopleInTheBoat(int x, int y, int z)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- if (!_passengers.isEmpty())
|
|
|
|
- {
|
|
|
|
- boolean check = false;
|
|
|
|
- if ((lastx == -1) || (lasty == -1))
|
|
|
|
- {
|
|
|
|
- check = true;
|
|
|
|
- lastx = x;
|
|
|
|
- lasty = y;
|
|
|
|
- }
|
|
|
|
- else if ((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) > 2250000) // 1500
|
|
|
|
- // *
|
|
|
|
- // 1500
|
|
|
|
- // =
|
|
|
|
- // 2250000
|
|
|
|
- {
|
|
|
|
- check = true;
|
|
|
|
- lastx = x;
|
|
|
|
- lasty = y;
|
|
|
|
- }
|
|
|
|
- VehicleCheckLocation vcl = null;
|
|
|
|
- if (needOnVehicleCheckLocation == true)
|
|
|
|
- vcl = new VehicleCheckLocation(this, x, y, z);
|
|
|
|
-
|
|
|
|
- for (L2PcInstance player : _passengers)
|
|
|
|
- {
|
|
|
|
- if (player != null && player.isInBoat())
|
|
|
|
- {
|
|
|
|
- if (player.getBoat() == this)
|
|
|
|
- {
|
|
|
|
- player.getPosition().setXYZ(x, y, z);
|
|
|
|
- player.revalidateZone(false);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (check == true && vcl != null)
|
|
|
|
- player.sendPacket(vcl);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param i
|
|
|
|
- */
|
|
|
|
- public void begin()
|
|
|
|
- {
|
|
|
|
- _passengers.clear();
|
|
|
|
- final Collection<L2PcInstance> knownPlayers = getKnownList().getKnownPlayersInRadius(1000);
|
|
|
|
- if (knownPlayers != null && !knownPlayers.isEmpty())
|
|
|
|
- {
|
|
|
|
- //synchronized (getKnownList().getKnownPlayers())
|
|
|
|
- {
|
|
|
|
- for (L2PcInstance player : knownPlayers)
|
|
|
|
- {
|
|
|
|
- if (player.isInBoat() && player.getBoat() == this)
|
|
|
|
- addPassenger(player);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ThreadPoolManager.getInstance().scheduleGeneral(new Boatrun(0, this), 0);
|
|
|
|
- broadcastPacket(new VehicleStarted(this, 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void addPassenger(L2PcInstance player)
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean moveToNextRoutePoint()
|
|
{
|
|
{
|
|
- final int itemId;
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- itemId = _t1.idWTicket1;
|
|
|
|
- else
|
|
|
|
- itemId = _t2.idWTicket1;
|
|
|
|
|
|
+ final boolean result = super.moveToNextRoutePoint();
|
|
|
|
+ if (result)
|
|
|
|
+ broadcastPacket(new VehicleDeparture(this));
|
|
|
|
|
|
- if (itemId != 0)
|
|
|
|
- {
|
|
|
|
- final L2ItemInstance it = player.getInventory().getItemByItemId(itemId);
|
|
|
|
- if ((it != null) && (it.getCount() >= 1))
|
|
|
|
- {
|
|
|
|
- player.getInventory().destroyItem("Boat", it, 1, player, this);
|
|
|
|
- InventoryUpdate iu = new InventoryUpdate();
|
|
|
|
- iu.addModifiedItem(it);
|
|
|
|
- player.sendPacket(iu);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- oustPlayer(player);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- _passengers.add(player);
|
|
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public void oustPlayer(L2PcInstance player)
|
|
public void oustPlayer(L2PcInstance player)
|
|
{
|
|
{
|
|
- final int x, y, z;
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- {
|
|
|
|
- x = _t1.ntx1;
|
|
|
|
- y = _t1.nty1;
|
|
|
|
- z = _t1.ntz1;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- x = _t2.ntx1;
|
|
|
|
- y = _t2.nty1;
|
|
|
|
- z = _t2.ntz1;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- removePassenger(player);
|
|
|
|
|
|
+ super.oustPlayer(player);
|
|
|
|
|
|
|
|
+ final Location loc = getOustLoc();
|
|
if (player.isOnline() > 0)
|
|
if (player.isOnline() > 0)
|
|
- player.teleToLocation(x, y, z);
|
|
|
|
|
|
+ player.teleToLocation(loc.getX(), loc.getY(), loc.getZ());
|
|
else
|
|
else
|
|
- player.setXYZInvisible(x, y, z); // disconnects handling
|
|
|
|
|
|
+ player.setXYZInvisible(loc.getX(), loc.getY(), loc.getZ()); // disconnects handling
|
|
}
|
|
}
|
|
|
|
|
|
- public void removePassenger(L2PcInstance player)
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- _passengers.remove(player);
|
|
|
|
- }
|
|
|
|
- catch (Exception e)
|
|
|
|
- {}
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param i
|
|
|
|
- */
|
|
|
|
- public void say(int i)
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void stopMove(L2CharPosition pos, boolean updateKnownObjects)
|
|
{
|
|
{
|
|
- final Collection<L2PcInstance> knownPlayers = getKnownList().getKnownPlayers().values();
|
|
|
|
- if (knownPlayers == null || knownPlayers.isEmpty())
|
|
|
|
- return;
|
|
|
|
|
|
+ super.stopMove(pos, updateKnownObjects);
|
|
|
|
|
|
- CreatureSay sm;
|
|
|
|
- CreatureSay sm2 = null;
|
|
|
|
- PlaySound ps;
|
|
|
|
- switch (i)
|
|
|
|
- {
|
|
|
|
- case 10:
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t1.npc1, _t1.sysmess10_1);
|
|
|
|
- if (getId() == 5)
|
|
|
|
- sm2 = new CreatureSay(0, Say2.SHOUT, _t1.npc1, _t1.sysmess5_1);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t2.npc1, _t2.sysmess10_1);
|
|
|
|
- if (getId() == 5)
|
|
|
|
- sm2 = new CreatureSay(0, Say2.SHOUT, _t2.npc1, _t2.sysmess5_1);
|
|
|
|
- }
|
|
|
|
- ps = new PlaySound(0, "itemsound.ship_arrival_departure", 1, getObjectId(), getX(), getY(), getZ());
|
|
|
|
- VehicleStarted vs = new VehicleStarted(this, 0);
|
|
|
|
- VehicleInfo vi = new VehicleInfo(this);
|
|
|
|
- for (L2PcInstance player : knownPlayers)
|
|
|
|
- {
|
|
|
|
- player.sendPacket(sm);
|
|
|
|
- player.sendPacket(ps);
|
|
|
|
- player.sendPacket(vs);
|
|
|
|
- player.sendPacket(vi);
|
|
|
|
- if (sm2 != null)
|
|
|
|
- player.sendPacket(sm2);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 5:
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t1.npc1, _t1.sysmess5_1);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t2.npc1, _t2.sysmess5_1);
|
|
|
|
- }
|
|
|
|
- ps = new PlaySound(0, "itemsound.ship_5min", 1, getObjectId(), getX(), getY(), getZ());
|
|
|
|
- for (L2PcInstance player : knownPlayers)
|
|
|
|
- {
|
|
|
|
- player.sendPacket(sm);
|
|
|
|
- player.sendPacket(ps);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 1:
|
|
|
|
-
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t1.npc1, _t1.sysmess1_1);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t2.npc1, _t2.sysmess1_1);
|
|
|
|
- }
|
|
|
|
- ps = new PlaySound(0, "itemsound.ship_1min", 1, getObjectId(), getX(), getY(), getZ());
|
|
|
|
- for (L2PcInstance player : knownPlayers)
|
|
|
|
- {
|
|
|
|
- player.sendPacket(sm);
|
|
|
|
- player.sendPacket(ps);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 0:
|
|
|
|
-
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t1.npc1, _t1.sysmess0_1);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t2.npc1, _t2.sysmess0_1);
|
|
|
|
- }
|
|
|
|
- for (L2PcInstance player : knownPlayers)
|
|
|
|
- {
|
|
|
|
- player.sendPacket(sm);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case -1:
|
|
|
|
- if (_cycle == 1)
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t1.npc1, _t1.sysmessb_1);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- sm = new CreatureSay(0, Say2.SHOUT, _t2.npc1, _t2.sysmessb_1);
|
|
|
|
- }
|
|
|
|
- ps = new PlaySound(0, "itemsound.ship_arrival_departure", 1, getObjectId(), getX(), getY(), getZ());
|
|
|
|
- for (L2PcInstance player : knownPlayers)
|
|
|
|
- {
|
|
|
|
- player.sendPacket(sm);
|
|
|
|
- player.sendPacket(ps);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
- public void spawn()
|
|
|
|
- {
|
|
|
|
- _cycle = 1;
|
|
|
|
- beginCycle();
|
|
|
|
|
|
+ broadcastPacket(new VehicleStarted(this, 0));
|
|
broadcastPacket(new VehicleInfo(this));
|
|
broadcastPacket(new VehicleInfo(this));
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param idWaypoint1
|
|
|
|
- * @param idWTicket1
|
|
|
|
- * @param ntx1
|
|
|
|
- * @param nty1
|
|
|
|
- * @param ntz1
|
|
|
|
- * @param idnpc1
|
|
|
|
- * @param sysmess10_1
|
|
|
|
- * @param sysmess5_1
|
|
|
|
- * @param sysmess1_1
|
|
|
|
- * @param sysmessb_1
|
|
|
|
- */
|
|
|
|
- public void setTrajet1(int idWaypoint1, int idWTicket1, int ntx1, int nty1, int ntz1, String idnpc1, String sysmess10_1,
|
|
|
|
- String sysmess5_1, String sysmess1_1, String sysmess0_1, String sysmessb_1)
|
|
|
|
- {
|
|
|
|
- _t1 = new L2BoatTrajet(idWaypoint1, idWTicket1, ntx1, nty1, ntz1, idnpc1, sysmess10_1, sysmess5_1, sysmess1_1, sysmess0_1, sysmessb_1, _name);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void setTrajet2(int idWaypoint1, int idWTicket1, int ntx1, int nty1, int ntz1, String idnpc1, String sysmess10_1,
|
|
|
|
- String sysmess5_1, String sysmess1_1, String sysmess0_1, String sysmessb_1)
|
|
|
|
- {
|
|
|
|
- _t2 = new L2BoatTrajet(idWaypoint1, idWTicket1, ntx1, nty1, ntz1, idnpc1, sysmess10_1, sysmess5_1, sysmess1_1, sysmess0_1, sysmessb_1, _name);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void updateAbnormalEffect()
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public L2ItemInstance getActiveWeaponInstance()
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public L2Weapon getActiveWeaponItem()
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public L2ItemInstance getSecondaryWeaponInstance()
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public L2Weapon getSecondaryWeaponItem()
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public int getLevel()
|
|
|
|
- {
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public boolean isAutoAttackable(L2Character attacker)
|
|
|
|
- {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * Allow setup of the boat AI only once
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void setAI(L2CharacterAI newAI)
|
|
|
|
- {
|
|
|
|
- if (_ai == null)
|
|
|
|
- _ai = newAI;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * boat AI can't be detached
|
|
|
|
- */
|
|
|
|
- public class AIAccessor extends L2Character.AIAccessor
|
|
|
|
- {
|
|
|
|
- @Override
|
|
|
|
- public void detachAI()
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @param id
|
|
|
|
- */
|
|
|
|
- public void setId(int id)
|
|
|
|
- {
|
|
|
|
- _id = id;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void sendInfo(L2PcInstance activeChar)
|
|
public void sendInfo(L2PcInstance activeChar)
|
|
{
|
|
{
|
|
activeChar.sendPacket(new VehicleInfo(this));
|
|
activeChar.sendPacket(new VehicleInfo(this));
|
|
- if (isMoving())
|
|
|
|
- sendPacket(new VehicleDeparture(this));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|