mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-08-02 03:15:52 -04:00
Merge branch 'feature/quests-tasks-and-cmds'
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
# commandString = 0 quest/quest_name
|
||||
|
||||
player = actor.getPlayerObject()
|
||||
|
||||
if player is None:
|
||||
return
|
||||
|
||||
questName = commandString.split("quest/")[1]
|
||||
|
||||
quest = player.getQuest(questName)
|
||||
|
||||
if quest is None:
|
||||
return
|
||||
|
||||
if quest.isCompleted():
|
||||
return
|
||||
|
||||
player.removeQuest(questName)
|
||||
return
|
||||
@@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
print ('acceptQuest: ' + commandString)
|
||||
return
|
||||
@@ -82,6 +82,7 @@ public class ObjControllerMessage extends SWGMessage {
|
||||
public static final int QUEST_TASK_TIMER = 0x0444;
|
||||
public static final int FORCE_ACTIVATE_QUEST = 0x04BE;
|
||||
public static final int SHOW_QUEST_COMPLETION_WINDOW = 0x04B8;
|
||||
public static final int SHOW_QUEST_ACCEPT_WINDOW = 0x04B7;
|
||||
|
||||
public ObjControllerMessage() {
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*******************************************************************************
|
||||
* 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 org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import engine.resources.objects.Baseline;
|
||||
|
||||
public class ShowQuestAcceptWindow extends ObjControllerObject {
|
||||
|
||||
private long objectId;
|
||||
private int questCrc;
|
||||
|
||||
public ShowQuestAcceptWindow(long objectId, int questCrc) {
|
||||
this.objectId = objectId;
|
||||
this.questCrc = questCrc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(IoBuffer data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IoBuffer serialize() {
|
||||
IoBuffer buffer = Baseline.createBuffer(20);
|
||||
|
||||
buffer.putInt(ObjControllerMessage.SHOW_QUEST_COMPLETION_WINDOW);
|
||||
buffer.putLong(objectId);
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putInt(questCrc);
|
||||
|
||||
return buffer.flip();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -623,6 +623,10 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
return getQuestJournal().get(questCrc);
|
||||
}
|
||||
|
||||
public void removeQuest(String questName) {
|
||||
getQuestJournal().remove(CRC.StringtoCRC("quest/" + questName));
|
||||
}
|
||||
|
||||
public String getProfessionWheelPosition() {
|
||||
return (String) getBaseline(8).get("professionWheelPosition");
|
||||
}
|
||||
@@ -1048,20 +1052,11 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
|
||||
|
||||
switch (viewType) {
|
||||
case 3:
|
||||
case 6:
|
||||
if (getContainer() != null) {
|
||||
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) {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class AdminService implements INetworkDispatch {
|
||||
PreparedStatement preparedStatement;
|
||||
|
||||
try {
|
||||
preparedStatement = core.getDatabase1().preparedStatement("SELECT accessLevel FROM accounts WHERE id=" + id);
|
||||
preparedStatement = core.getDatabase1().preparedStatement("SELECT \"accessLevel\" FROM accounts WHERE id=" + id);
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
if(resultSet.next())
|
||||
accessLevel = resultSet.getString("accessLevel");
|
||||
|
||||
@@ -422,7 +422,8 @@ public class CharacterService implements INetworkDispatch {
|
||||
if (isDuplicate) { return true; }
|
||||
|
||||
//FIXME: this is a bit lazy... but it's only temporary :p
|
||||
PreparedStatement psc = databaseConnection.preparedStatement("SELECT COUNT(*) FROM pg_tables WHERE \"tablename\"=?");
|
||||
// FIXME: org.postgresql.util.PSQLException: ERROR: relation "temp_reserved_char_names" does not exist
|
||||
/*PreparedStatement psc = databaseConnection.preparedStatement("SELECT COUNT(*) FROM pg_tables WHERE \"tablename\"=?");
|
||||
psc.setString(1, "temp_reserved_char_names");
|
||||
ResultSet resultSetC = psc.executeQuery();
|
||||
boolean tableExists = resultSetC.next();
|
||||
@@ -434,9 +435,9 @@ public class CharacterService implements INetworkDispatch {
|
||||
ps2.setString(2, firstName.toLowerCase());
|
||||
ResultSet resultSet2 = ps2.executeQuery();
|
||||
boolean isReserved = resultSet2.next();
|
||||
resultSet2.getStatement().close();
|
||||
resultSet2.getStatement().close();*/
|
||||
|
||||
return isReserved;
|
||||
return isDuplicate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -128,12 +128,12 @@ public class ConnectionService implements INetworkDispatch {
|
||||
|
||||
try {
|
||||
|
||||
preparedStatement = databaseConnection.preparedStatement("SELECT accountId FROM sessions WHERE key=?");
|
||||
preparedStatement = databaseConnection.preparedStatement("SELECT \"accountId\" FROM sessions WHERE key=?");
|
||||
preparedStatement.setBytes(1, clientIdMsg.getSessionKey());
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
long accountId = resultSet.getLong("accountID");
|
||||
long accountId = resultSet.getLong("accountId");
|
||||
|
||||
client.setAccountId(accountId);
|
||||
client.setSessionKey(clientIdMsg.getSessionKey());
|
||||
|
||||
@@ -49,6 +49,7 @@ import protocol.swg.objectControllerObjects.ForceActivateQuest;
|
||||
import protocol.swg.objectControllerObjects.QuestTaskCounterMessage;
|
||||
import protocol.swg.objectControllerObjects.QuestTaskTimerMessage;
|
||||
import protocol.swg.objectControllerObjects.ShowLootBox;
|
||||
import protocol.swg.objectControllerObjects.ShowQuestAcceptWindow;
|
||||
import protocol.swg.objectControllerObjects.ShowQuestCompletionWindow;
|
||||
import resources.common.Console;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
@@ -62,6 +63,8 @@ import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
import resources.quest.Quest;
|
||||
import services.sui.SUIService.MessageBoxType;
|
||||
import services.sui.SUIWindow;
|
||||
import main.NGECore;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
@@ -177,10 +180,8 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
// quest.task.ground.comm_player
|
||||
case "comm_player":
|
||||
|
||||
CommPlayerMessage message = new CommPlayerMessage(quester.getObjectID(), OutOfBand.ProsePackage(task.getCommMessageText()), task.getNpcAppearanceTemplate());
|
||||
quester.getClient().getSession().write(message.serialize());
|
||||
|
||||
break;
|
||||
|
||||
// quest.task.ground.retrieve_item
|
||||
@@ -199,6 +200,7 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
// quest.task.ground.timer
|
||||
case "timer":
|
||||
// TODO: Fix timer not showing
|
||||
//System.out.println("Max time: " + task.getMaxTime() + " Min time: " + task.getMinTime());
|
||||
AtomicInteger time = new AtomicInteger(new Random(task.getMaxTime()).nextInt((task.getMaxTime() - task.getMinTime()) + task.getMinTime()));
|
||||
|
||||
@@ -223,12 +225,19 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
// quest.task.ground.show_message_box
|
||||
case "show_message_box":
|
||||
SUIWindow msgBox = core.suiService.createMessageBox(MessageBoxType.MESSAGE_BOX_OK, task.getMsgBoxTitle(), task.getMsgBoxPrompt(), quester, null, 0);
|
||||
|
||||
if (task.getMsgBoxSound() != null && !task.getMsgBoxSound().equals("")) {
|
||||
PlayMusicMessage music = new PlayMusicMessage(task.getMsgBoxSound(), quester.getObjectID(), 0, false);
|
||||
quester.getClient().getSession().write(music.serialize());
|
||||
}
|
||||
|
||||
core.suiService.openSUIWindow(msgBox);
|
||||
break;
|
||||
|
||||
default:
|
||||
//System.out.println("Don't know what to do for quest task: " + type);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (!task.isVisible()) {
|
||||
@@ -255,8 +264,8 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
QuestTask task = qData.getTasks().get(activeStep);
|
||||
|
||||
//if (quest.getWaypointId() != 0)
|
||||
//core.objectService.destroyObject(quest.getWaypointId());
|
||||
if (quest.getWaypointId() != 0)
|
||||
core.objectService.destroyObject(quest.getWaypointId());
|
||||
|
||||
if (quest.getTimer() != null)
|
||||
quest.getTimer().cancel(true);
|
||||
@@ -400,8 +409,9 @@ public class QuestService implements INetworkDispatch {
|
||||
creo.getClient().getSession().write(player.getBaseline(8).createDelta(7));
|
||||
}
|
||||
|
||||
public void sendQuestAcceptWindow(CreatureObject reciever, String questName) {
|
||||
|
||||
public void sendQuestAcceptWindow(CreatureObject reciever, int questCrc) {
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x0B, new ShowQuestAcceptWindow(reciever.getObjectID(), questCrc));
|
||||
reciever.getClient().getSession().write(objController.serialize());
|
||||
}
|
||||
|
||||
public void sendQuestCompleteWindow(CreatureObject reciever, int questCrc) {
|
||||
@@ -590,6 +600,16 @@ public class QuestService implements INetworkDispatch {
|
||||
if (visitor.getObjectByColumnNameAndIndex("MAX_TIME", r) != null) task.setMaxTime((int) visitor.getObjectByColumnNameAndIndex("MAX_TIME", r));
|
||||
if (visitor.getObjectByColumnNameAndIndex("RADIUS", r) != null && visitor.getObjectByColumnNameAndIndex("RADIUS", r) != "") task.setRadius(Float.parseFloat((String) visitor.getObjectByColumnNameAndIndex("RADIUS", r)));
|
||||
if (visitor.getObjectByColumnNameAndIndex("SIGNAL_NAME", r) != null) task.setSignalName((String) visitor.getObjectByColumnNameAndIndex("SIGNAL_NAME", r));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_TITLE", r) != null) task.setMsgBoxTitle((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_TITLE", r));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_TEXT", r) != null) task.setMsgBoxPrompt((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_TEXT", r));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SOUND", r) != null) task.setMsgBoxSound((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SOUND", r));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SIZE_WIDTH", r) != null) task.setMsgBoxWidth(Integer.parseInt((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SIZE_WIDTH", r)));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SIZE_HEIGHT", r) != null) task.setMsgBoxHeight(Integer.parseInt((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SIZE_HEIGHT", r)));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SIZE_WIDTH", r) != null) task.setMsgBoxWidth(Integer.parseInt((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_SIZE_WIDTH", r)));
|
||||
|
||||
// if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_LOCATION_X", r) != null) task.setMsgBoxWidth((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_LOCATION_X", r));
|
||||
// if (visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_LOCATION_Y", r) != null) task.setMsgBoxWidth((String) visitor.getObjectByColumnNameAndIndex("MESSAGE_BOX_LOCATION_Y", r));
|
||||
|
||||
//if (visitor.getObjectByColumnNameAndIndex("", r))
|
||||
|
||||
if (task.getType().equals("quest.task.ground.go_to_location")) {
|
||||
|
||||
@@ -52,6 +52,9 @@ public class QuestTask {
|
||||
private String itemName;
|
||||
private String tasksOnFail;
|
||||
private String retrieveMenuText;
|
||||
private String msgBoxPrompt;
|
||||
private String msgBoxTitle;
|
||||
private String msgBoxSound;
|
||||
|
||||
private boolean visible;
|
||||
private boolean grantQuestOnCompleteShowSystemMessage;
|
||||
@@ -67,6 +70,9 @@ public class QuestTask {
|
||||
private int dropPercent;
|
||||
private int minTime;
|
||||
private int maxTime;
|
||||
private int msgBoxWidth;
|
||||
private int msgBoxHeight;
|
||||
private int msgBoxLength;
|
||||
|
||||
private long waitMarkerBuilding;
|
||||
|
||||
@@ -478,4 +484,52 @@ public class QuestTask {
|
||||
public void setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public String getMsgBoxPrompt() {
|
||||
return msgBoxPrompt;
|
||||
}
|
||||
|
||||
public void setMsgBoxPrompt(String msgBoxPrompt) {
|
||||
this.msgBoxPrompt = msgBoxPrompt;
|
||||
}
|
||||
|
||||
public String getMsgBoxTitle() {
|
||||
return msgBoxTitle;
|
||||
}
|
||||
|
||||
public void setMsgBoxTitle(String msgBoxTitle) {
|
||||
this.msgBoxTitle = msgBoxTitle;
|
||||
}
|
||||
|
||||
public String getMsgBoxSound() {
|
||||
return msgBoxSound;
|
||||
}
|
||||
|
||||
public void setMsgBoxSound(String msgBoxSound) {
|
||||
this.msgBoxSound = msgBoxSound;
|
||||
}
|
||||
|
||||
public int getMsgBoxWidth() {
|
||||
return msgBoxWidth;
|
||||
}
|
||||
|
||||
public void setMsgBoxWidth(int msgBoxWidth) {
|
||||
this.msgBoxWidth = msgBoxWidth;
|
||||
}
|
||||
|
||||
public int getMsgBoxHeight() {
|
||||
return msgBoxHeight;
|
||||
}
|
||||
|
||||
public void setMsgBoxHeight(int msgBoxHeight) {
|
||||
this.msgBoxHeight = msgBoxHeight;
|
||||
}
|
||||
|
||||
public int getMsgBoxLength() {
|
||||
return msgBoxLength;
|
||||
}
|
||||
|
||||
public void setMsgBoxLength(int msgBoxLength) {
|
||||
this.msgBoxLength = msgBoxLength;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user