mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-08-27 17:57:22 -04:00
Merge remote-tracking branch 'origin/master' into Fixes
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import sys
|
||||
import main.NGECore
|
||||
import services.AdminService
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
if target:
|
||||
actor.sendSystemMessage(' \\#FE2EF7 [GM] \\#FFFFFF Command Completed Successfully: Account name for target is ' + core.adminService.getAccountNameFromDB(target.getClient().getAccountId()) + '.', 0)
|
||||
|
||||
|
||||
else:
|
||||
actor.sendSystemMessage(' \\#FE2EF7 [GM] \\#FFFFFF getStationName: Invalid Syntax. Syntax is: /getStationName <Character First Name>', 0)
|
||||
return
|
||||
@@ -78,7 +78,8 @@ public class ObjControllerMessage extends SWGMessage {
|
||||
public static final int RESOURCE_WEIGHTS = 0x0207;
|
||||
public static final int MISSION_ACCEPT_RESPONSE = 0x00FA;
|
||||
public static final int MISSION_ABORT_RESPONSE = 0x0142;
|
||||
public static final int QUEST_TASK_TIMER_MESSAGE = 0x0441;
|
||||
public static final int QUEST_TASK_COUNTER = 0x0441;
|
||||
public static final int QUEST_TASK_TIMER = 0x0444;
|
||||
public static final int FORCE_ACTIVATE_QUEST = 0x04BE;
|
||||
|
||||
public ObjControllerMessage() {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package protocol.swg.objectControllerObjects;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
|
||||
public class QuestTaskCounterMessage extends ObjControllerObject {
|
||||
|
||||
private long objectId;
|
||||
private String questName;
|
||||
private String stf;
|
||||
|
||||
public QuestTaskCounterMessage(long objectId, String questName, String stf) {
|
||||
this.objectId = objectId;
|
||||
this.questName = questName;
|
||||
this.stf = stf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(IoBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IoBuffer serialize() {
|
||||
|
||||
byte[] questNameBytes = getAsciiString(questName);
|
||||
byte[] stfBytes = getUnicodeString(stf);
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(38 + questNameBytes.length + stfBytes.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(ObjControllerMessage.QUEST_TASK_COUNTER);
|
||||
buffer.putLong(objectId);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.put(questNameBytes);
|
||||
buffer.putInt(1); // ??
|
||||
buffer.put(stfBytes);
|
||||
buffer.putInt(0); // ??
|
||||
buffer.putInt(1); // ??
|
||||
|
||||
return buffer.flip();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +1,66 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package protocol.swg.objectControllerObjects;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class QuestTaskTimerMessage extends ObjControllerObject {
|
||||
|
||||
private long objectId;
|
||||
private String questName;
|
||||
|
||||
public QuestTaskTimerMessage(long objectId, String questName) {
|
||||
this.objectId = objectId;
|
||||
this.questName = questName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(IoBuffer data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IoBuffer serialize() {
|
||||
|
||||
IoBuffer buffer = IoBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.setAutoExpand(true);
|
||||
buffer.putInt(ObjControllerMessage.QUEST_TASK_TIMER_MESSAGE);
|
||||
buffer.putLong(objectId);
|
||||
buffer.putInt(0);
|
||||
buffer.put(getAsciiString("quest/ep3_trando_hssissk_zssik_10"));
|
||||
buffer.putInt(1);
|
||||
buffer.put(getUnicodeString("quest/groundquests:destroy_counter"));
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(1);
|
||||
|
||||
int size = buffer.position();
|
||||
buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size);
|
||||
|
||||
return buffer.flip();
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package protocol.swg.objectControllerObjects;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
|
||||
public class QuestTaskTimerMessage extends ObjControllerObject {
|
||||
|
||||
private long objectId;
|
||||
private int count;
|
||||
private int taskId;
|
||||
private String questName;
|
||||
private String stf;
|
||||
|
||||
public QuestTaskTimerMessage(long objectId, String questName, String stf, int count) {
|
||||
this.objectId = objectId;
|
||||
this.count = count;
|
||||
this.questName = questName;
|
||||
this.stf = stf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(IoBuffer data) { }
|
||||
|
||||
@Override
|
||||
public IoBuffer serialize() {
|
||||
byte[] nameBytes = getAsciiString(questName);
|
||||
byte[] stfBytes = getUnicodeString(stf);
|
||||
IoBuffer buffer = IoBuffer.allocate(24 + nameBytes.length + stfBytes.length).order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putInt(ObjControllerMessage.QUEST_TASK_TIMER);
|
||||
buffer.putLong(objectId);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.put(nameBytes);
|
||||
buffer.putInt(taskId);
|
||||
buffer.put(stfBytes);
|
||||
buffer.putInt(count);
|
||||
|
||||
return buffer.flip();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ public class SWGList<E> implements List<E>, Serializable {
|
||||
private byte viewType;
|
||||
private short updateType;
|
||||
private boolean addByte;
|
||||
private boolean questMethod;
|
||||
protected transient Object objectMutex = new Object();
|
||||
private transient SWGObject object;
|
||||
|
||||
@@ -67,14 +66,6 @@ public class SWGList<E> implements List<E>, Serializable {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public SWGList(SWGObject object, int viewType, int updateType, boolean addByte, boolean questMethod) {
|
||||
this.viewType = (byte) viewType;
|
||||
this.updateType = (short) updateType;
|
||||
this.addByte = addByte;
|
||||
this.object = object;
|
||||
this.questMethod = questMethod;
|
||||
}
|
||||
|
||||
public void init(SWGObject object) {
|
||||
objectMutex = new Object();
|
||||
updateCounter = 0;
|
||||
@@ -94,19 +85,7 @@ public class SWGList<E> implements List<E>, Serializable {
|
||||
public boolean add(E e) {
|
||||
synchronized(objectMutex) {
|
||||
if (valid(e) && list.add(e)) {
|
||||
if (!questMethod) queue(item(1, list.lastIndexOf(e), Baseline.toBytes(e), true, true));
|
||||
else {
|
||||
List<byte[]> buffer = new ArrayList<byte[]>();
|
||||
|
||||
int index = 0;
|
||||
for (E element : list) {
|
||||
buffer.add(item(1, index, Baseline.toBytes(element), true, true));
|
||||
index++;
|
||||
}
|
||||
queue(buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
queue(item(1, list.lastIndexOf(e), Baseline.toBytes(e), true, true));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -462,17 +441,7 @@ public class SWGList<E> implements List<E>, Serializable {
|
||||
}
|
||||
|
||||
private byte[] item(int type, int index, byte[] data, boolean useIndex, boolean useData) {
|
||||
if (questMethod) {
|
||||
int size = data.length;
|
||||
|
||||
IoBuffer buffer = Delta.createBuffer(size);
|
||||
buffer.put(data);
|
||||
buffer.flip();
|
||||
updateCounter++;
|
||||
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
|
||||
int size = 1 + ((useIndex) ? 2 : 0) + ((useData) ? data.length : 0);
|
||||
|
||||
IoBuffer buffer = Delta.createBuffer(size);
|
||||
|
||||
@@ -47,6 +47,7 @@ import resources.objects.waypoint.WaypointObject;
|
||||
import resources.quest.Quest;
|
||||
import services.quest.QuestItem;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.common.StringUtilities;
|
||||
import engine.resources.objects.Baseline;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -161,7 +162,7 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
baseline.put("currentFSQuestList", new SWGList<Byte>(this, 8, 4, false));
|
||||
baseline.put("completedFSQuestList", new SWGList<Byte>(this, 8, 5, false));
|
||||
baseline.put("activeQuest", 0);
|
||||
baseline.put("questJournal", new SWGList<Quest>(this, 8, 7, false, true));
|
||||
baseline.put("questJournal", new SWGMap<Integer, Quest>(this, 8, 7, true));
|
||||
baseline.put("professionWheelPosition", "");
|
||||
return baseline;
|
||||
}
|
||||
@@ -591,8 +592,8 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public SWGList<Quest> getQuestJournal() {
|
||||
return (SWGList<Quest>) getBaseline(8).get("questJournal");
|
||||
public SWGMap<Integer, Quest> getQuestJournal() {
|
||||
return (SWGMap<Integer, Quest>) getBaseline(8).get("questJournal");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -600,11 +601,6 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
return (TreeMap<String, QuestItem>) otherVariables.get("questRetrieveItemTemplates");
|
||||
}
|
||||
|
||||
public boolean hasRetrieveItemTemplate(String template) {
|
||||
TreeMap<String, QuestItem> templates = getQuestRetrieveItemTemplates();
|
||||
return templates.containsKey(template);
|
||||
}
|
||||
|
||||
public int getActiveQuest() {
|
||||
return (int) getBaseline(8).get("activeQuest");
|
||||
}
|
||||
@@ -1044,10 +1040,19 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
getContainer().notifyObservers(getBaseline(viewType).createDelta(updateType, buffer.array()), true);
|
||||
}
|
||||
|
||||
break;
|
||||
case 8:
|
||||
switch (updateType) {
|
||||
case 7:
|
||||
IoBuffer newBuffer = getBaseline(viewType).createDelta(updateType, buffer.array());
|
||||
getContainer().getClient().getSession().write(newBuffer.array());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (getContainer() != null && getContainer().getClient() != null) {
|
||||
getContainer().getClient().getSession().write(getBaseline(viewType).createDelta(updateType, buffer.array()));
|
||||
StringUtilities.printBytes(getBaseline(viewType).createDelta(updateType, buffer.array()).array());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,17 +154,16 @@ public class WaypointObject extends IntangibleObject implements IDelta, Serializ
|
||||
}
|
||||
|
||||
public synchronized byte[] getBytes() {
|
||||
IoBuffer buffer = Baseline.createBuffer(38 + StringUtilities.getUnicodeString(getName()).length);
|
||||
buffer.putInt(getCellNumber());
|
||||
buffer.put(Baseline.toBytes(getBaseline(3).get("position")));
|
||||
buffer.putLong(getTargetId());
|
||||
buffer.putInt(getPlanetCrc());
|
||||
buffer.put(StringUtilities.getUnicodeString(getName()));
|
||||
buffer.putLong(getObjectID());
|
||||
buffer.put(getColor());
|
||||
buffer.put(Baseline.getBoolean(isActive()));
|
||||
return buffer.flip().array();
|
||||
|
||||
IoBuffer buffer = Baseline.createBuffer(38 + StringUtilities.getUnicodeString(getName()).length);
|
||||
buffer.putInt(getCellNumber());
|
||||
buffer.put(Baseline.toBytes(getBaseline(3).get("position")));
|
||||
buffer.putLong(getTargetId());
|
||||
buffer.putInt(getPlanetCrc());
|
||||
buffer.put(StringUtilities.getUnicodeString(getName()));
|
||||
buffer.putLong(getObjectID());
|
||||
buffer.put(getColor());
|
||||
buffer.put(Baseline.getBoolean(isActive()));
|
||||
return buffer.flip().array();
|
||||
}
|
||||
|
||||
@Deprecated public int getCellId() { return getCellNumber(); }
|
||||
|
||||
@@ -130,11 +130,11 @@ public class Quest extends Delta implements Serializable {
|
||||
byte[] activeStepBytes = activeStepBitmask.toByteArray();
|
||||
byte[] completedStepBytes = completedStepBitmask.toByteArray();
|
||||
|
||||
IoBuffer buffer = createBuffer(23);
|
||||
IoBuffer buffer = createBuffer(18);
|
||||
|
||||
buffer.put((byte) 0);
|
||||
//buffer.put((byte) 0);
|
||||
|
||||
buffer.putInt(getCrc());
|
||||
//buffer.putInt(getCrc());
|
||||
|
||||
buffer.putLong(ownerId); // quest giver id?
|
||||
|
||||
|
||||
@@ -55,6 +55,22 @@ public class AdminService implements INetworkDispatch {
|
||||
return accessLevel;
|
||||
}
|
||||
|
||||
public String getAccountNameFromDB(long id) {
|
||||
String accountName = null;
|
||||
PreparedStatement preparedStatement;
|
||||
|
||||
try {
|
||||
preparedStatement = NGECore.getInstance().getDatabase1().preparedStatement("SELECT * FROM accounts WHERE id=" + id + "");
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
if(resultSet.next())
|
||||
accountName = resultSet.getString("user");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> arg0, Map<Integer, INetworkRemoteEvent> arg1) {
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ public class PlayerService implements INetworkDispatch {
|
||||
});
|
||||
|
||||
swgOpcodes.put(Opcodes.CmdSceneReady, (session, data) -> {
|
||||
|
||||
session.setAttribute("CmdSceneReady", true);
|
||||
});
|
||||
|
||||
/*swgOpcodes.put(Opcodes.ExpertiseRequestMessage, new INetworkRemoteEvent() {
|
||||
|
||||
@@ -690,7 +690,8 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) {
|
||||
|
||||
if (command.getGodLevel() > 0 || command.getCommandName().equals("setgodmode")) {
|
||||
if (command.getGodLevel() > 0 || command.getCommandName().equals("setgodmode") || command.getCommandName().equals("server") || command.getCommandName().equals("teleport")
|
||||
|| command.getCommandName().equals("teleportto") || command.getCommandName().equals("teleporttarget") ) {
|
||||
String accessLevel = core.adminService.getAccessLevelFromDB(actor.getClient().getAccountId());
|
||||
String filePath = "accesslevels/" + accessLevel + ".txt";
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import protocol.swg.CommPlayerMessage;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.PlayClientEffectObjectTransformMessage;
|
||||
import protocol.swg.objectControllerObjects.NpcConversationMessage;
|
||||
import protocol.swg.objectControllerObjects.QuestTaskTimerMessage;
|
||||
import protocol.swg.objectControllerObjects.QuestTaskCounterMessage;
|
||||
import resources.common.OutOfBand;
|
||||
import resources.common.SpawnPoint;
|
||||
import resources.datatables.FactionStatus;
|
||||
|
||||
@@ -33,12 +33,14 @@ import protocol.swg.CommPlayerMessage;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.PlayMusicMessage;
|
||||
import protocol.swg.objectControllerObjects.ForceActivateQuest;
|
||||
import protocol.swg.objectControllerObjects.QuestTaskCounterMessage;
|
||||
import protocol.swg.objectControllerObjects.QuestTaskTimerMessage;
|
||||
import protocol.swg.objectControllerObjects.ShowLootBox;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
import resources.common.OutOfBand;
|
||||
import resources.common.ProsePackage;
|
||||
import resources.datatables.DisplayType;
|
||||
import resources.objects.SWGList;
|
||||
import resources.objects.SWGMap;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
@@ -84,17 +86,12 @@ public class QuestService implements INetworkDispatch {
|
||||
catch (Exception e) {e.printStackTrace();}
|
||||
}
|
||||
|
||||
SWGList<Quest> questJournal = ghost.getQuestJournal();
|
||||
SWGMap<Integer, Quest> questJournal = ghost.getQuestJournal();
|
||||
|
||||
if (questJournal.size() == 0)
|
||||
return false;
|
||||
|
||||
for (Quest quest : questJournal) {
|
||||
if (quest.getName().equals(questName))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return questJournal.containsKey(CRC.StringtoCRC("quest/" + questName));
|
||||
}
|
||||
|
||||
public boolean isQuestCompleted(CreatureObject creo, String questName) {
|
||||
@@ -105,17 +102,15 @@ public class QuestService implements INetworkDispatch {
|
||||
catch (Exception e) {e.printStackTrace();}
|
||||
}
|
||||
|
||||
SWGList<Quest> questJournal = ghost.getQuestJournal();
|
||||
SWGMap<Integer, Quest> questJournal = ghost.getQuestJournal();
|
||||
|
||||
if (questJournal.size() == 0)
|
||||
return false;
|
||||
|
||||
for (Quest quest : questJournal) {
|
||||
if (quest.getName().equals(questName))
|
||||
return quest.isCompleted();
|
||||
}
|
||||
|
||||
return false;
|
||||
if (!questJournal.containsKey(CRC.StringtoCRC("quest/" + questName)))
|
||||
return false;
|
||||
else
|
||||
return questJournal.get(CRC.StringtoCRC("quest/") + questName).isCompleted();
|
||||
}
|
||||
|
||||
public void sendQuestWindow(CreatureObject reciever, String questName) {
|
||||
@@ -128,13 +123,15 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
public void activateNextTask(CreatureObject quester, String questName) {
|
||||
|
||||
for (Quest quest : quester.getPlayerObject().getQuestJournal()) {
|
||||
if (quest.getName().equals(questName) && !quest.isCompleted())
|
||||
activateNextTask(quester, quest);
|
||||
if (quester.getPlayerObject().getQuestJournal().containsKey(CRC.StringtoCRC("quest/" + questName)) && !quester.getPlayerObject().getQuestJournal().get(CRC.StringtoCRC("quest/" + questName)).isCompleted()) {
|
||||
activateNextTask(quester, quester.getPlayerObject().getQuestJournal().get(CRC.StringtoCRC("quest/" + questName)));
|
||||
}
|
||||
}
|
||||
|
||||
public void activateNextTask(CreatureObject quester, Quest quest) {
|
||||
if (quester == null || quester.getClient() == null || quester.getClient().getSession() == null)
|
||||
return;
|
||||
|
||||
QuestData qData = getQuestData(quest.getName());
|
||||
|
||||
if (qData == null)
|
||||
@@ -167,33 +164,42 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
// quest.task.ground.retrieve_item
|
||||
case "retrieve_item":
|
||||
String template = task.getServerTemplate();
|
||||
player.getQuestRetrieveItemTemplates().put(template, new QuestItem(quest.getName(), activeStep));
|
||||
player.getQuestRetrieveItemTemplates().put(task.getServerTemplate(), new QuestItem(quest.getName(), activeStep));
|
||||
|
||||
// TODO: add item count
|
||||
ObjControllerMessage itemCount = new ObjControllerMessage(11, new QuestTaskCounterMessage(quester.getObjectID(), quest.getCrcName(), "@quest/groundquests:retrieve_item_counter"));
|
||||
quester.getClient().getSession().write(itemCount.serialize());
|
||||
break;
|
||||
|
||||
case "timer":
|
||||
ObjControllerMessage timer = new ObjControllerMessage(11, new QuestTaskTimerMessage(quester.getObjectID(), quest.getCrcName(), "@quest/groundquests:timer_timertext", 20));
|
||||
quester.getClient().getSession().write(timer.serialize());
|
||||
System.out.println("Sent timer.");
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println("Don't know what to do for quest task: " + type);
|
||||
//System.out.println("Don't know what to do for quest task: " + type);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//if (task.getGrantQuestOnComplete() != null && !task.getGrantQuestOnComplete().equals(""))
|
||||
//activateQuest(quester, task.getGrantQuestOnComplete());
|
||||
|
||||
if (activeStep + 1 >= qData.getTasks().size()) {
|
||||
QuestList listItem = questRewardMap.get(quest.getName());
|
||||
|
||||
if (listItem.isCompleteWhenTasksComplete())
|
||||
completeQuest(player, quest); // Should this be the Force Complete Quest packet sent instead?
|
||||
|
||||
completeQuest(player, quest); // Force complete packet sent if the quest isn't auto completed (window shows up, typical for exclusive reward items)
|
||||
/*else
|
||||
sendQuestCompleteWindow(quester, quest.getName());*/
|
||||
|
||||
if (task.getGrantQuestOnComplete() != null && !task.getGrantQuestOnComplete().equals(""))
|
||||
activateQuest(quester, task.getGrantQuestOnComplete());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (task.getGrantQuestOnComplete() != null && !task.getGrantQuestOnComplete().equals(""))
|
||||
activateQuest(quester, task.getGrantQuestOnComplete());
|
||||
|
||||
quest.incrementQuestStep(); // After handling the quest type, we can now increment the step
|
||||
|
||||
if (!task.isVisible()) {
|
||||
@@ -205,7 +211,6 @@ public class QuestService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public void activateQuest(CreatureObject quester, String questString) {
|
||||
System.out.println("Activating quest: " + questString);
|
||||
Quest quest = new Quest(questString, quester.getObjectID());
|
||||
|
||||
PlayerObject player = quester.getPlayerObject();
|
||||
@@ -213,9 +218,9 @@ public class QuestService implements INetworkDispatch {
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
QuestList info = questRewardMap.get(questString);
|
||||
QuestList info = questRewardMap.get(quest.getName());
|
||||
if (info == null) {
|
||||
info = getQuestListDatatable(questString);
|
||||
info = getQuestListDatatable(quest.getName());
|
||||
}
|
||||
|
||||
ProsePackage prose = new ProsePackage("@quest/ground/system_message:quest_received");
|
||||
@@ -225,7 +230,7 @@ public class QuestService implements INetworkDispatch {
|
||||
PlayMusicMessage music = new PlayMusicMessage("sound/ui_npe2_quest_received.snd", quester.getObjectID(), 0, true);
|
||||
quester.getClient().getSession().write(music.serialize());
|
||||
|
||||
player.getQuestJournal().add(quest);
|
||||
player.getQuestJournal().put(quest.getCrc(), quest);
|
||||
player.setActiveQuest(quest.getCrc());
|
||||
|
||||
activateNextTask(quester, quest);
|
||||
@@ -249,8 +254,13 @@ public class QuestService implements INetworkDispatch {
|
||||
if (inventory == null)
|
||||
return;
|
||||
|
||||
boolean rewardSound = false;
|
||||
|
||||
PlayMusicMessage completeSound = new PlayMusicMessage("sound/ui_npe2_quest_completed.snd", creo.getObjectID(), 0, true);
|
||||
creo.getClient().getSession().write(completeSound.serialize());
|
||||
|
||||
// TODO: Give other awards - exclusive loots, faction points
|
||||
// Recieving quest awards (faction, item, exp, credits) - http://youtu.be/-L7Rz1WpmGM?t=14m50s
|
||||
// Receiving quest awards (faction, item, exp, credits) - http://youtu.be/-L7Rz1WpmGM?t=14m50s
|
||||
|
||||
// Give quest items
|
||||
|
||||
@@ -260,6 +270,7 @@ public class QuestService implements INetworkDispatch {
|
||||
recievedItems.add(rewardLoot.getObjectID());
|
||||
}
|
||||
|
||||
// TODO: Other item awards -- put above this comment
|
||||
if (recievedItems.size() != 0) {
|
||||
|
||||
for (long item : recievedItems) {
|
||||
@@ -268,26 +279,34 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
ObjControllerMessage objMessage = new ObjControllerMessage(11, new ShowLootBox(creo.getObjectID(), recievedItems));
|
||||
creo.getClient().getSession().write(objMessage.serialize());
|
||||
|
||||
if (!rewardSound) {
|
||||
PlayMusicMessage itemSound = new PlayMusicMessage("sound/ui_npe2_quest_reward.snd", creo.getObjectID(), 0, true);
|
||||
creo.getClient().getSession().write(itemSound.serialize());
|
||||
rewardSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Give credits
|
||||
if (info.getRewardBankCredits() != 0) {
|
||||
creo.addBankCredits(info.getRewardBankCredits());
|
||||
creo.sendSystemMessage(OutOfBand.ProsePackage("@base_player:prose_transfer_success", "DI", info.getRewardBankCredits()), DisplayType.Broadcast);
|
||||
|
||||
if (!rewardSound) {
|
||||
PlayMusicMessage credSound = new PlayMusicMessage("sound/ui_npe2_quest_credits.snd", creo.getObjectID(), 0, true);
|
||||
creo.getClient().getSession().write(credSound.serialize());
|
||||
rewardSound = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Give experience - TODO: Give specific type of experience.
|
||||
if (info.getRewardExperienceAmount() == 0 && info.getTier() != -1 && !(info.getTier() > 6)) {
|
||||
if (info.getRewardExperienceAmount() != 0 && info.getTier() != -1 && !(info.getTier() > 6)) {
|
||||
int experienceAward = 0;
|
||||
try {
|
||||
DatatableVisitor experienceVisitor = ClientFileManager.loadFile("clientdata/datatables/quest/quest_experience", DatatableVisitor.class);
|
||||
DatatableVisitor experienceVisitor = ClientFileManager.loadFile("datatables/quest/quest_experience", DatatableVisitor.class);
|
||||
|
||||
for (int r = 0; r < experienceVisitor.getRowCount(); r++) {
|
||||
if ((int) experienceVisitor.getObject(r, 0) == creo.getLevel()) {
|
||||
|
||||
if (info.getTier() > 6 || info.getTier() == -1)
|
||||
return;
|
||||
|
||||
experienceAward = (int) experienceVisitor.getObject(r, info.getTier());
|
||||
}
|
||||
}
|
||||
@@ -297,7 +316,7 @@ public class QuestService implements INetworkDispatch {
|
||||
} else {
|
||||
core.playerService.giveExperience(creo, info.getRewardExperienceAmount());
|
||||
}
|
||||
|
||||
|
||||
// Update quest & client
|
||||
quest.setRecievedAward(true);
|
||||
creo.getClient().getSession().write(player.getBaseline(8).createDelta(7));
|
||||
@@ -321,7 +340,7 @@ public class QuestService implements INetworkDispatch {
|
||||
if (player.getQuestRetrieveItemTemplates().size() == 0)
|
||||
return radialName;
|
||||
|
||||
if (!player.hasRetrieveItemTemplate(template))
|
||||
if (!player.getQuestRetrieveItemTemplates().containsKey(template))
|
||||
return radialName;
|
||||
|
||||
QuestItem item = player.getQuestRetrieveItemTemplates().get(template);
|
||||
@@ -338,18 +357,14 @@ public class QuestService implements INetworkDispatch {
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (!player.hasRetrieveItemTemplate(target.getTemplate())) {
|
||||
System.out.println("Player doesn't have the template: " + target.getTemplate());
|
||||
if (!player.getQuestRetrieveItemTemplates().containsKey(target.getTemplate()))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QuestItem item = player.getQuestRetrieveItemTemplates().get(target.getTemplate());
|
||||
activateNextTask(quester, item.getQuestName());
|
||||
|
||||
|
||||
player.getQuestRetrieveItemTemplates().remove(target.getTemplate(), item);
|
||||
|
||||
if (player.hasRetrieveItemTemplate(target.getTemplate()))
|
||||
System.out.println("STILL HAS TEMPLATE!!");
|
||||
}
|
||||
|
||||
public QuestData getQuestData(String questName) {
|
||||
@@ -370,7 +385,6 @@ public class QuestService implements INetworkDispatch {
|
||||
if (questRewardMap.containsKey(questName))
|
||||
return questRewardMap.get(questName);
|
||||
else {
|
||||
System.out.println("Doesn't have it. Getting it from the list...");
|
||||
QuestList list = getQuestListDatatable(questName); // parsing puts it in quest map
|
||||
questRewardMap.put(questName, list);
|
||||
return list;
|
||||
|
||||
Reference in New Issue
Block a user