mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-08-27 17:57:22 -04:00
Added Waypoints
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
playerObject = actor.getSlottedObject('ghost')
|
||||
waypointTarget = core.objectService.getObject(target.getObjectID())
|
||||
wp = playerObject.getWaypointFromList(target)
|
||||
if wp.isActive() == True:
|
||||
wp.setActive(False)
|
||||
playerObject.waypointUpdate(wp)
|
||||
return
|
||||
else:
|
||||
wp.setActive(True)
|
||||
playerObject.waypointUpdate(wp)
|
||||
return
|
||||
@@ -0,0 +1,12 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
playerObject = actor.getSlottedObject('ghost')
|
||||
wp = playerObject.getWaypointFromList(target)
|
||||
if wp is not None:
|
||||
wp.setName(commandString)
|
||||
playerObject.waypointUpdate(wp)
|
||||
return
|
||||
@@ -0,0 +1,84 @@
|
||||
from resources.objects.waypoint import WaypointObject
|
||||
from engine.resources.scene import Point3D
|
||||
from engine.resources.common import CRC
|
||||
import sys
|
||||
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
validPlanets = ["tatooine", "naboo", "corellia", "rori", "talus", "yavin4", "endor", "lok", "dantooine", "dathomir", "kachirho", "etyyy", "khowir", "mustafar"]
|
||||
validColors = ["blue", "green", "orange", "purple", "white", "yellow"]
|
||||
crc = CRC
|
||||
commandArgs = commandString.split(" ")
|
||||
actorPlayer = actor.getSlottedObject("ghost")
|
||||
|
||||
#/wp PLANET X Z Y COLOR NAME
|
||||
if commandArgs[0] in validPlanets and commandArgs[4] in validColors:
|
||||
try:
|
||||
float(commandArgs[1])
|
||||
float(commandArgs[2])
|
||||
float(commandArgs[3])
|
||||
except ValueError:
|
||||
return
|
||||
planet = core.terrainService.getPlanetByName(commandArgs[0])
|
||||
waypoint = core.objectService.createObject('object/waypoint/shared_waypoint.iff', planet, float(commandArgs[1]), float(commandArgs[2]), float(commandArgs[3]))
|
||||
waypoint.setActive(True)
|
||||
waypoint.setColor(colorCheck(core, actor, target, commandString, commandArgs[4]))
|
||||
name = commandString.split(" ", 5)
|
||||
waypoint.setName(name[5])
|
||||
waypoint.setPlanetCRC(crc.StringtoCRC(planet.getName()))
|
||||
actorPlayer.getWaypoints().add(waypoint)
|
||||
actorPlayer.waypointAdd(waypoint)
|
||||
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
|
||||
return
|
||||
|
||||
#/wp X Z Y NAME
|
||||
if isFloat(commandArgs[0]) and isFloat(commandArgs[1]) and isFloat(commandArgs[2]):
|
||||
waypoint = core.objectService.createObject('object/waypoint/shared_waypoint.iff', actor.getPlanet(), actor.getPosition().x, actor.getPosition().z, actor.getPosition().y)
|
||||
waypoint.setActive(True)
|
||||
waypoint.setColor(WaypointObject.BLUE)
|
||||
name = commandString.split(" ", 3)
|
||||
waypoint.setName(name[3])
|
||||
waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName()))
|
||||
actorPlayer.getWaypoints().add(waypoint)
|
||||
actorPlayer.waypointAdd(waypoint)
|
||||
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
|
||||
return
|
||||
|
||||
#/wp NAME
|
||||
else:
|
||||
waypoint = core.objectService.createObject('object/waypoint/shared_waypoint.iff', actor.getPlanet(), actor.getPosition().x, actor.getPosition().z, actor.getPosition().y)
|
||||
waypoint.setActive(True)
|
||||
waypoint.setColor(WaypointObject.BLUE)
|
||||
waypoint.setName(commandString)
|
||||
waypoint.setPlanetCRC(crc.StringtoCRC(actor.getPlanet().getName()))
|
||||
actorPlayer.getWaypoints().add(waypoint)
|
||||
actorPlayer.waypointAdd(waypoint)
|
||||
actor.sendSystemMessage('A waypoint has been created in your datapad at your location.', 0)
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
def colorCheck(core, actor, target, commandString, validcolors):
|
||||
if validcolors == "blue":
|
||||
return WaypointObject.BLUE
|
||||
if validcolors == "green":
|
||||
return WaypointObject.GREEN
|
||||
if validcolors == "orange":
|
||||
return WaypointObject.ORANGE
|
||||
if validcolors == "purple":
|
||||
return WaypointObject.PURPLE
|
||||
if validcolors == "white":
|
||||
return WaypointObject.WHITE
|
||||
if validcolors == "yellow":
|
||||
return WaypointObject.YELLOW
|
||||
return
|
||||
|
||||
def isFloat(string):
|
||||
try:
|
||||
stringFloat = float(string)
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
else:
|
||||
return True
|
||||
return
|
||||
@@ -375,6 +375,112 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder {
|
||||
|
||||
}
|
||||
|
||||
public IoBuffer buildWaypointAddDelta(WaypointObject waypoint) {
|
||||
PlayerObject player = (PlayerObject) object;
|
||||
IoBuffer buffer = bufferPool.allocate(200 + player.getWaypoints().size(), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(1);
|
||||
|
||||
buffer.put((byte) 0); // updateType (SubType)
|
||||
|
||||
buffer.putLong(waypoint.getObjectID());
|
||||
buffer.putInt(waypoint.getCellId());
|
||||
|
||||
buffer.putFloat(waypoint.getPosition().x);
|
||||
buffer.putFloat(waypoint.getPosition().y);
|
||||
buffer.putFloat(waypoint.getPosition().z);
|
||||
|
||||
buffer.putLong(0); // networklocationId
|
||||
buffer.putInt(waypoint.getPlanetCRC());
|
||||
|
||||
buffer.put(getUnicodeString(waypoint.getName()));
|
||||
buffer.putLong(waypoint.getObjectID());
|
||||
|
||||
buffer.put((byte) waypoint.getColor());
|
||||
|
||||
if (waypoint.isActive()) { buffer.put((byte) 1); }
|
||||
else { buffer.put((byte) 0); }
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 8, (short) player.getWaypointListUpdateCounter(), (short) 1, buffer, size + 4);
|
||||
//System.out.println("WaypointAdd: " + buffer.getHexDump());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildWaypointRemoveDelta(WaypointObject waypoint) {
|
||||
IoBuffer buffer = bufferPool.allocate(200, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
PlayerObject player = (PlayerObject) object;
|
||||
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(1);
|
||||
|
||||
buffer.put((byte) 1); // updateType (SubType)
|
||||
|
||||
buffer.putLong(waypoint.getObjectID());
|
||||
buffer.putInt(waypoint.getCellId());
|
||||
|
||||
buffer.putFloat(waypoint.getPosition().x);
|
||||
buffer.putFloat(waypoint.getPosition().y);
|
||||
buffer.putFloat(waypoint.getPosition().z);
|
||||
|
||||
buffer.putLong(0); // networklocationId
|
||||
buffer.putInt(waypoint.getPlanetCRC());
|
||||
|
||||
buffer.put(getUnicodeString(waypoint.getName()));
|
||||
buffer.putLong(waypoint.getObjectID());
|
||||
|
||||
buffer.put((byte) waypoint.getColor());
|
||||
|
||||
if (waypoint.isActive()) { buffer.put((byte) 1); }
|
||||
else { buffer.put((byte) 0); }
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 8, (short) player.getWaypointListUpdateCounter(), (short) 1, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public IoBuffer buildWaypointUpdateDelta(WaypointObject waypoint) {
|
||||
IoBuffer buffer = bufferPool.allocate(200, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
PlayerObject player = (PlayerObject) object;
|
||||
|
||||
buffer.putInt(1);
|
||||
buffer.putInt(1);
|
||||
|
||||
buffer.put((byte) 2); // updateType (SubType)
|
||||
|
||||
buffer.putLong(waypoint.getObjectID());
|
||||
buffer.putInt(waypoint.getCellId());
|
||||
|
||||
buffer.putFloat(waypoint.getPosition().x);
|
||||
buffer.putFloat(waypoint.getPosition().y);
|
||||
buffer.putFloat(waypoint.getPosition().z);
|
||||
|
||||
buffer.putLong(0); // networklocationId << cluster system I guess?
|
||||
buffer.putInt(waypoint.getPlanetCRC());
|
||||
|
||||
buffer.put(getUnicodeString(waypoint.getName()));
|
||||
buffer.putLong(waypoint.getObjectID());
|
||||
|
||||
buffer.put((byte) waypoint.getColor());
|
||||
|
||||
if (waypoint.isActive()) { buffer.put((byte) 1); }
|
||||
else { buffer.put((byte) 0); } // isActive. Activates automatically when created.
|
||||
|
||||
int size = buffer.position();
|
||||
buffer.flip();
|
||||
|
||||
buffer = createDelta("PLAY", (byte) 8, (short) player.getWaypointListUpdateCounter(), (short) 1, buffer, size + 4);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public int getProfData(String profession) {
|
||||
|
||||
switch (profession) {
|
||||
|
||||
@@ -202,6 +202,46 @@ public class PlayerObject extends SWGObject {
|
||||
return waypoints;
|
||||
}
|
||||
|
||||
public int getWaypointListUpdateCounter() {
|
||||
synchronized(objectMutex) {
|
||||
return waypointListUpdateCounter;
|
||||
}
|
||||
}
|
||||
|
||||
public void setWaypointListUpdateCounter(int count) {
|
||||
synchronized(objectMutex){
|
||||
this.waypointListUpdateCounter = count;
|
||||
}
|
||||
}
|
||||
|
||||
public void waypointUpdate(WaypointObject waypoint) {
|
||||
synchronized(objectMutex) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildWaypointUpdateDelta(waypoint));
|
||||
}
|
||||
}
|
||||
|
||||
public void waypointRemove(WaypointObject waypoint) {
|
||||
synchronized(objectMutex) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildWaypointRemoveDelta(waypoint));
|
||||
}
|
||||
}
|
||||
|
||||
public void waypointAdd(WaypointObject waypoint) {
|
||||
synchronized(objectMutex) {
|
||||
getContainer().getClient().getSession().write(messageBuilder.buildWaypointAddDelta(waypoint));
|
||||
}
|
||||
}
|
||||
|
||||
public WaypointObject getWaypointFromList(WaypointObject waypoint) {
|
||||
synchronized(objectMutex) {
|
||||
for(WaypointObject wp : waypoints) {
|
||||
if(wp.getObjectID() == waypoint.getObjectID())
|
||||
return wp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getCurrentForcePower() {
|
||||
synchronized(objectMutex) {
|
||||
return currentForcePower;
|
||||
|
||||
@@ -126,6 +126,9 @@ public class SimulationService implements INetworkDispatch {
|
||||
core.commandService.registerCommand("tip");
|
||||
core.commandService.registerCommand("faction");
|
||||
core.commandService.registerCommand("setspeed");
|
||||
core.commandService.registerCommand("waypoint");
|
||||
core.commandService.registerCommand("setwaypointactivestatus");
|
||||
core.commandService.registerCommand("setwaypointname");
|
||||
}
|
||||
|
||||
public void add(SWGObject object, int x, int y) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import resources.common.*;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
@@ -47,7 +48,6 @@ import protocol.swg.HeartBeatMessage;
|
||||
import protocol.swg.ParametersMessage;
|
||||
import protocol.swg.SelectCharacter;
|
||||
import protocol.swg.UnkByteFlag;
|
||||
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.CrcStringTableVisitor;
|
||||
import engine.clientdata.visitors.WorldSnapshotVisitor;
|
||||
@@ -62,9 +62,7 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
@@ -72,6 +70,7 @@ import resources.objects.guild.GuildObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.staticobject.StaticObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -157,6 +156,8 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
object = new GuildObject(core, objectID, planet, position, orientation, Template);
|
||||
|
||||
} else if(Template.startsWith("object/waypoint")) {
|
||||
object = new WaypointObject(objectID, planet, position);
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user