Page 1 of 1

Boat heading and movement.

Posted: Tue Mar 15, 2011 12:42 pm
by Sylar88
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:

I made the following function that is supposed to "move" a boat with a given distance and a given change in its angle from a given anchor point ( x, y ). It basically calculates the new point based on the polar coordinate and returns the cartesian coordinates. With zero angle , isnt it supposed to go forward instead of turning ? Im testing it and it seems the ship is always turning randomply.

Code: Select all

public int[] calculatePoint2(int x, int y, int rotate, int distance)    {        int angle = (int) (boat.getHeading()/182.044444 + rotate);        if(angle > 360)            angle = angle -360;        if(angle < 0)            angle = 360 - angle;        int dx = (int) (Math.cos(angle)* distance);        int dy = (int) (Math.sin(angle)* distance);                int[] result = new int[2];        result[0] = x + dx;        result[1] = y + dy;        return result;    }

Re: Boat heading and movement.

Posted: Tue Mar 15, 2011 1:11 pm
by tukune
http://download.oracle.com/javase/1.4.2 ... 8double%29
public static double cos(double a)
Parameters:
a - an angle, in radians.

Re: Boat heading and movement.

Posted: Tue Mar 15, 2011 1:18 pm
by Sylar88
HUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUGE THANKS :) Im so stupid i didnt read the declaration of the function.

Re: Boat heading and movement.

Posted: Tue Mar 15, 2011 7:07 pm
by badboy29
Also boat have missing sounds:

Code: Select all

itemsound.ship_5minitemsound.ship_1min

Code: Select all

GIRAN_SOUND5 = new PlaySound(0, "itemsound.ship_5min", 1, _boat.getObjectId(), GIRAN_DOCK.x, GIRAN_DOCK.y, GIRAN_DOCK.z); GIRAN_SOUND1 = new PlaySound(0, "itemsound.ship_1min", 1, _boat.getObjectId(), GIRAN_DOCK.x, GIRAN_DOCK.y, GIRAN_DOCK.z);

Re: Boat heading and movement.

Posted: Wed Mar 16, 2011 11:40 am
by Sylar88
There are many things missing/wrong in the boats. Atm im in official files server checking the packets in the boat.