mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-07-15 00:07:39 -04:00
Start of FactionStanding, Custom Object Scripts
This commit is contained in:
@@ -132,7 +132,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation) {
|
||||
public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation, String customServerTemplate) {
|
||||
SWGObject object = null;
|
||||
CrcStringTableVisitor crcTable;
|
||||
try {
|
||||
@@ -199,16 +199,49 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
object.setPlanetId(planet.getID());
|
||||
|
||||
object.setAttachment("serverTemplate", ((customServerTemplate != null) ? customServerTemplate : object.getTemplate()));
|
||||
|
||||
loadServerTemplate(object);
|
||||
|
||||
objectList.put(objectID, object);
|
||||
|
||||
|
||||
// Set Default Tangible Options
|
||||
/*
|
||||
if (Template.startsWith("object/creature/") || Template.startsWith("object/mobile/")) {
|
||||
((CreatureObject) object).setOptionsBitmask(Options.MOBILE);
|
||||
|
||||
if (Template.startsWith("object/mobile/beast_master/")) {
|
||||
((CreatureObject) object).setOptionsBitmask(Options.NONE);
|
||||
} else if (Template.startsWith("object/mobile/vendor/")) {
|
||||
((CreatureObject) object).setOptionsBitmask(Options.INVULNERABLE | Options.USABLE);
|
||||
} else if (Template.startsWith("object/mobile/vehicle/")) {
|
||||
((CreatureObject) object).addOption(Options.INVULNERABLE | Options.MOUNT);
|
||||
} else if (Template.startsWith("object/mobile/hologram/")) {
|
||||
((CreatureObject) object).addOption(Options.INVULNERABLE);
|
||||
} else if (Template.startsWith("object/creature/npc/theme_park/")) {
|
||||
((CreatureObject) object).addOption(Options.INVULNERABLE);
|
||||
} else if (Template.startsWith("object/creature/general/")) {
|
||||
((CreatureObject) object).setOptionsBitmask(Options.INVULNERABLE | Options.CONVERSABLE);
|
||||
} else if (Template.startsWith("object/creature/droid/")) {
|
||||
((CreatureObject) object).addOption(Options.INVULNERABLE);
|
||||
}
|
||||
} else if (object instanceof TangibleObject) {
|
||||
((TangibleObject) object).setOptionsBitmask(Options.INVULNERABLE);
|
||||
|
||||
if (Template.startsWith("object/tangible/vendor/")) {
|
||||
((CreatureObject) object).addOption(Options.USABLE);
|
||||
} else if (Template.startsWith("object/creature/droid/")) {
|
||||
((CreatureObject) object).addOption(Options.INVULNERABLE);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public void loadServerTemplate(SWGObject object) {
|
||||
|
||||
String template = object.getTemplate();
|
||||
String template = ((object.getAttachment("serverTemplate") == null) ? object.getTemplate() : ((String) object.getAttachment("serverTemplate")));
|
||||
String serverTemplate = template.replace(".iff", "");
|
||||
// check if template is empty(4 default lines) to reduce RAM usage(saves about 500 MB of RAM)
|
||||
try {
|
||||
@@ -239,6 +272,10 @@ public class ObjectService implements INetworkDispatch {
|
||||
return createObject(Template, 0, planet, new Point3D(x, y, z), new Quaternion(1, 0, 0, 0));
|
||||
}
|
||||
|
||||
public SWGObject createObject(String Template, long objectID, Planet planet, Point3D position, Quaternion orientation) {
|
||||
return createObject(Template, objectID, planet, position, orientation, null);
|
||||
}
|
||||
|
||||
public void addObjectToScene(SWGObject object) {
|
||||
|
||||
core.simulationService.add(object, object.getPosition().x, object.getPosition().z);
|
||||
@@ -296,6 +333,18 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
if (object instanceof CreatureObject) {
|
||||
if (core.factionService.getFactionMap().containsKey(((CreatureObject) object).getFaction())) {
|
||||
if (FileUtilities.doesFileExist(filePath)) {
|
||||
PyObject method = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "destroy");
|
||||
|
||||
if (method != null && method.isCallable()) {
|
||||
method.__call__(Py.java2py(core), Py.java2py(((TangibleObject) object).getKiller()), Py.java2py(object));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (object == null) {
|
||||
return;
|
||||
}
|
||||
@@ -505,6 +554,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
objControllerOpcodes.put(ObjControllerOpcodes.USE_OBJECT, new INetworkRemoteEvent() {
|
||||
|
||||
@Override
|
||||
@@ -529,6 +579,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user