Merge pull request #17 from ProjectSWGCore/experimental

Experimental
This commit is contained in:
Zing
2014-08-16 22:17:58 -07:00
18 changed files with 294 additions and 213 deletions
Binary file not shown.
+6 -3
View File
@@ -12,9 +12,12 @@ def run(core, actor, target, commandString):
#if actor.getSkills('Foraging')==0:
#actor.sendSystemMessage('@skl_use:sys_forage_noskill'),0)
#if actor.isForaging()==1:
#actor.sendSystemMessage('@skl_use:sys_forage_already',0)
#return
if actor.getAttachment("LastForageTime"):
if actor.getAttachment("LastForageTime")>int(round(time.time() * 1000))-5000:
actor.sendSystemMessage('@skl_use:sys_forage_already',0)
return
actor.setAttachment("LastForageTime",int(round(time.time() * 1000)))
if actor.getCombatFlag()!=0:
actor.sendSystemMessage('@skl_use:sys_forage_combatfail',0)
+8 -8
View File
@@ -13,13 +13,13 @@ def addTemplate(core):
mobileTemplate.setCreatureName('forage_goon')
mobileTemplate.setLevel(1)
mobileTemplate.setDifficulty(Difficulty.ELITE)
mobileTemplate.setMinSpawnDistance(4)
mobileTemplate.setMaxSpawnDistance(8)
mobileTemplate.setDeathblow(False)
mobileTemplate.setDeathblow(True)
mobileTemplate.setScale(1)
mobileTemplate.setAssistRange(12)
mobileTemplate.setStalker(False)
mobileTemplate.setSocialGroup("tusken raider")
mobileTemplate.setOptionsBitmask(Options.AGGRESSIVE | Options.ATTACKABLE)
templates = Vector()
@@ -33,16 +33,16 @@ def addTemplate(core):
mobileTemplate.setTemplates(templates)
weaponTemplates = Vector()
weapontemplate = WeaponTemplate('object/weapon/ranged/carbine/shared_carbine_dh17.iff', WeaponType.CARBINE, 0.6, 15, 'kinetic')
weaponTemplates.add(weapontemplate)
weapontemplate = WeaponTemplate('object/weapon/ranged/pistol/shared_pistol_dl44.iff', WeaponType.PISTOL, 0.4, 15, 'kinetic')
weaponTemplates.add(weapontemplate)
weapontemplate = WeaponTemplate('object/weapon/ranged/rifle/shared_rifle_dlt20a.iff', WeaponType.RIFLE, 0.8, 24, 'kinetic')
#weapontemplate = WeaponTemplate('object/weapon/ranged/carbine/shared_carbine_dh17.iff', WeaponType.CARBINE, 0.6, 15, 'kinetic')
#weaponTemplates.add(weapontemplate)
#weapontemplate = WeaponTemplate('object/weapon/ranged/pistol/shared_pistol_dl44.iff', WeaponType.PISTOL, 0.4, 15, 'kinetic')
#weaponTemplates.add(weapontemplate)
weapontemplate = WeaponTemplate('object/weapon/ranged/rifle/shared_rifle_dlt20a.iff', WeaponType.RIFLE, 1.0, 24, 'kinetic')
weaponTemplates.add(weapontemplate)
mobileTemplate.setWeaponTemplateVector(weaponTemplates)
attacks = Vector()
mobileTemplate.setDefaultAttack('rangedShot')
mobileTemplate.setDefaultAttack('rangedShotrifle')
mobileTemplate.setAttacks(attacks)
core.spawnService.addMobileTemplate('forage_goon', mobileTemplate)
+2 -1
View File
@@ -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();
}
}
+8 -8
View File
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Random;
import java.util.Vector;
import engine.resources.common.Stf;
import engine.resources.objects.SWGObject;
import engine.resources.scene.Point3D;
import main.NGECore;
@@ -250,7 +251,7 @@ public class Forager {
adversaryRoll=999;
// adversaryRoll=999; // To test TMs
if (adversaryRoll<14) { // 14 100 // To test TMs
int adversaryTypeRoll = new Random().nextInt(100);
if (adversaryTypeRoll<50){
@@ -417,18 +418,17 @@ public class Forager {
}
goon.addObserver(forager);
// goon.addObserver(forager);
goon.setCustomName(name);
goon.setLevel(forager.getLevel());
goon.setOptions(Options.AGGRESSIVE, true);
goon.setOptions(Options.ATTACKABLE, true);
// goon.setOptions(Options.AGGRESSIVE, true);
// goon.setOptions(Options.ATTACKABLE, true);
AIActor actor = (AIActor) goon.getAttachment("AI");
actor.addDefender(forager);
forager.sendSystemMessage("@foraging/forage_enemy:" + barkString, DisplayType.Broadcast);
//OutOfBand oob = OutOfBand.ProsePackage("@foraging/forage_enemy:" + barkString));
OutOfBand oob = OutOfBand.ProsePackage("@jawa_trader:cant_understand");
forager.sendSystemMessage("@jawa_trader:cant_understand", DisplayType.Broadcast);
NGECore.getInstance().chatService.spatialChat(goon, forager, "", (short)0x0, (short)0x0, 1, oob);
OutOfBand oob = OutOfBand.ProsePackage("@foraging/forage_enemy:" + barkString);
Stf stf = new Stf("@foraging/forage_enemy:" + barkString);
NGECore.getInstance().chatService.spatialChat(goon, forager, stf.getStfValue(), (short)0x0, (short)0x0, 1, oob);
}
public void handleGuardSpawn(CreatureObject owner, TangibleObject map){
+2 -33
View File
@@ -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);
+13 -8
View File
@@ -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(); }
+3 -3
View File
@@ -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?
+2
View File
@@ -363,6 +363,8 @@ public class CharacterService implements INetworkDispatch {
createStarterClothing(object, sharedRaceTemplate, clientCreateCharacter.getStarterProfession());
//core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", core, object);
session.setAttribute("CmdSceneReady", false);
System.out.println("Saving character with name: " + object.getCustomName());
core.getSWGObjectODB().put(object.getObjectID(), object);
+1 -1
View File
@@ -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() {
+10 -7
View File
@@ -80,8 +80,9 @@ public class CommandService implements INetworkDispatch {
if (actor == null)
return false;
if (actor.getClient() == null)
return false;
// if (actor.getClient() == null)
// return false;
// Please consider that AI is calling callCommand too. Thank you.
if (command == null)
return false;
@@ -95,6 +96,7 @@ public class CommandService implements INetworkDispatch {
if (actor.hasCooldown(command.getCooldownGroup()) || actor.hasCooldown(command.getCommandName()))
return false;
// Causes this service method to return with false after equipping a rifle, not allowing to unequip it anymore
// because the client seems to consider rifles invalidweapons for an unkown reason
@@ -115,7 +117,7 @@ public class CommandService implements INetworkDispatch {
return false;
}
}
switch (command.getTargetType()) {
case 0: // Target Not Used For This Command
break;
@@ -251,7 +253,7 @@ public class CommandService implements INetworkDispatch {
default:
break;
}
switch (command.getTarget()) {
case 0: // Ally Only
if (target == null) {
@@ -318,7 +320,7 @@ public class CommandService implements INetworkDispatch {
e.printStackTrace();
}
}
if(command instanceof CombatCommand) {
try {
processCommand(actor, target, (BaseSWGCommand) command.clone(), actionCounter, commandArgs);
@@ -688,10 +690,11 @@ 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";
System.out.println(command.getCommandName() + " was just used by an admin with accessLevel: " + accessLevel + ".");
if(FileUtilities.doesFileExist(filePath)) {
Scanner scanner;
try {
+1 -1
View File
@@ -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;
+31 -14
View File
@@ -1040,48 +1040,63 @@ public class ObjectService implements INetworkDispatch {
long objectId = selectCharacter.getCharacterId();
Client client = core.getClient(session);
if(client == null) {
System.out.println("NULL Client");
System.err.println("NULL Client");
return;
}
CreatureObject creature = null;
if(getObject(objectId) == null) {
creature = getCreatureFromDB(objectId);
if(creature == null) {
System.out.println("Cant get creature from db");
System.err.println("Cant get creature from db");
} else {
if (creature.getCustomName() == null || creature.getCustomName().isEmpty()) {
System.err.println("Name: " + creature.getCustomName());
System.out.println("Player with ObjID of " + creature.getObjectID() + " tried logging in but has a null/empty name!");
System.err.println("Player with ObjID of " + creature.getObjectID() + " tried logging in but has a null/empty name!");
return;
} else {
System.out.println("SelectCharacter: not in object list");
System.err.println("SelectCharacter: not in object list");
}
}
} else {
if (!(getObject(objectId) instanceof CreatureObject))
if (!(getObject(objectId) instanceof CreatureObject)) {
System.out.println("Character is not an instance of CreatureObject!");
return;
}
creature = (CreatureObject) getObject(objectId);
if (creature.getCustomName() == null || creature.getCustomName().isEmpty()) {
System.err.println("Creature's custom name was null/empty! Name: " + creature.getCustomName());
}
if(creature.getAttachment("disconnectTask") != null && creature.getClient() != null && !creature.getClient().getSession().isClosing())
return;
if(creature.getAttachment("disconnectTask") != null)
((ScheduledFuture<?>)creature.getAttachment("disconnectTask")).cancel(true);
if (creature.getClient() != null) {
if (!creature.getClient().getSession().isClosing()) {
System.err.println("Character is already disconnecting...");
return;
}
creature.setClient(null);
}
}
if(creature.getAttachment("disconnectTask") != null) {
((ScheduledFuture<?>) creature.getAttachment("disconnectTask")).cancel(true);
}
PlayerObject ghost = (PlayerObject) creature.getSlottedObject("ghost");
if(ghost == null)
if (ghost == null) {
System.err.println("The Character's Ghost is null!");
return;
}
System.out.println("Character '" + creature.getCustomName() + "' now zoning...");
ghost.clearFlagBitmask(PlayerFlags.LD);
final CreatureObject finalCreature = creature;
creature.viewChildren(creature, true, false, new Traverser() {
public void process(SWGObject object) {
finalCreature.makeUnaware(object);
}
});
creature.getAwareObjects().removeAll(creature.getAwareObjects());
creature.setAttachment("disconnectTask", null);
@@ -1090,6 +1105,8 @@ public class ObjectService implements INetworkDispatch {
creature.setPlanet(planet);
client.setParent(creature);
session.setAttribute("CmdSceneReady", false);
objectList.put(creature.getObjectID(), creature);
creature.viewChildren(creature, true, true, (object) -> {
+61 -47
View File
@@ -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;
+2 -2
View File
@@ -329,8 +329,8 @@ public class TravelService implements INetworkDispatch {
Planet planet = core.terrainService.getPlanetByName(tp.getPlanetName());
Point3D spawnLocation = SpawnPoint.getRandomPosition(tp.getLocation(), 5, 20, actor.getPlanetId());
core.simulationService.transferToPlanet(actor, planet, spawnLocation, new Quaternion(0, 0, 0, 0), null);
float positionY = core.terrainService.getHeight(actor.getPlanetId(), spawnLocation.x, spawnLocation.z);
core.simulationService.transferToPlanet(actor, planet, new Point3D(spawnLocation.x, positionY, spawnLocation.z), new Quaternion(0, 0, 0, 0), null);
}