useStaticObject(core,actor) usable in obj scripts

This commit is contained in:
Treeku
2013-11-10 09:59:09 +00:00
parent 7addf47a99
commit 4a2de02212
2 changed files with 21 additions and 0 deletions
+20
View File
@@ -461,6 +461,26 @@ public class ObjectService implements INetworkDispatch {
});
objControllerOpcodes.put(ObjControllerOpcodes.USE_STATIC_OBJECT, new INetworkRemoteEvent() {
@Override
public void handlePacket(IoSession session, IoBuffer buffer) throws Exception {
CreatureObject creature = (CreatureObject) getObject(buffer.getLong());
if (creature == null || creature.getClient() == null) return;
buffer.skip(4);
SWGObject object = getObject(buffer.getLong());
if (object == null) return;
String filePath = "scripts/" + object.getTemplate().split(".")[0] + ".py";
if (!FileUtilities.doesFileExist(filePath)) {
PyObject method = core.scriptService.getMethod(filePath.substring(0, filePath.lastIndexOf("/")), filePath.substring(filePath.lastIndexOf("/") + 1).split(".")[0], "useStaticObject");
if (method != null && method.isCallable()) {
method.__call__(Py.java2py(core), Py.java2py(creature));
}
}
}
});
}
public void shutdown() {