mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-07-14 00:02:07 -04:00
Changed go to location tasks to not need a script
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
def setup(core):
|
||||
core.questService.addCollisionEvent('find_majolnir', 'task2', 3526, 5, -4619, 10, 'tatooine')
|
||||
return
|
||||
|
||||
def task2(core, activator, collidable):
|
||||
print ('called.')
|
||||
if activator.getPlayerObject() is None:
|
||||
return
|
||||
|
||||
player = activator.getPlayerObject()
|
||||
|
||||
if player.getQuest('find_majolnir') is None:
|
||||
print ('not in quest journal')
|
||||
return
|
||||
|
||||
quest = player.getQuest('find_majolnir')
|
||||
|
||||
if quest.isCompleted() or quest.getActiveStep() != 2:
|
||||
return
|
||||
|
||||
core.questService.completeActiveTask(activator, quest)
|
||||
return
|
||||
@@ -0,0 +1,22 @@
|
||||
from engine.resources.common import CRC
|
||||
|
||||
def run(core, activator, collidable):
|
||||
|
||||
if activator.getPlayerObject() is None:
|
||||
return
|
||||
|
||||
player = activator.getPlayerObject()
|
||||
|
||||
if player.getActiveQuestName() != collidable.getAttachedQuest():
|
||||
return
|
||||
|
||||
quest = player.getQuest(player.getActiveQuest())
|
||||
|
||||
if quest.isCompleted():
|
||||
return
|
||||
|
||||
if quest.getActiveTask() != collidable.getTask():
|
||||
return
|
||||
|
||||
core.questService.completeActiveTask(activator, quest)
|
||||
return
|
||||
@@ -575,8 +575,6 @@ public class NGECore {
|
||||
playerCityService.loadCityRankCaps();
|
||||
playerCityService.loadCities();
|
||||
|
||||
questService.loadEvents();
|
||||
|
||||
retroService.run();
|
||||
|
||||
browserService = new BrowserService(this);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* 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 resources.common.collidables;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
|
||||
public class QuestCollidable extends CollidableCircle {
|
||||
|
||||
private String attachedQuest;
|
||||
private int task;
|
||||
|
||||
public QuestCollidable(Point3D center, float radius, Planet planet, String attachedQuest, int task) {
|
||||
super(center, radius, planet);
|
||||
this.attachedQuest = attachedQuest;
|
||||
this.task = task;
|
||||
}
|
||||
|
||||
public String getAttachedQuest() { return this.attachedQuest; }
|
||||
public int getTask() { return this.task; }
|
||||
}
|
||||
@@ -98,6 +98,7 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
baseline.put("holoEmoteUses", 0);
|
||||
baseline.put("activeMissions", new ArrayList<Long>()); // TODO: Look at MissionCriticalObject in CREO4, could use that instead of this
|
||||
baseline.put("questRetrieveItemTemplates", new TreeMap<String, QuestItem>());
|
||||
baseline.put("activeQuestName", "");
|
||||
return baseline;
|
||||
}
|
||||
|
||||
@@ -606,14 +607,23 @@ public class PlayerObject extends IntangibleObject implements Serializable {
|
||||
return (int) getBaseline(8).get("activeQuest");
|
||||
}
|
||||
|
||||
public void setActiveQuest(int questCRC) {
|
||||
getBaseline(8).set("activeQuest", questCRC);
|
||||
public String getActiveQuestName() {
|
||||
return (String) otherVariables.get("activeQuestName");
|
||||
}
|
||||
|
||||
public void setActiveQuest(String questName) {
|
||||
otherVariables.set("activeQuestName", questName);
|
||||
getBaseline(8).set("activeQuest", CRC.StringtoCRC("quest/" + questName));
|
||||
}
|
||||
|
||||
public Quest getQuest(String questName) {
|
||||
return getQuestJournal().get(CRC.StringtoCRC("quest/" + questName));
|
||||
}
|
||||
|
||||
public Quest getQuest(int questCrc) {
|
||||
return getQuestJournal().get(questCrc);
|
||||
}
|
||||
|
||||
public String getProfessionWheelPosition() {
|
||||
return (String) getBaseline(8).get("professionWheelPosition");
|
||||
}
|
||||
|
||||
@@ -75,11 +75,11 @@ public class Quest extends Delta implements Serializable {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
public int getActiveStep() {
|
||||
public int getActiveTask() {
|
||||
return activeStep;
|
||||
}
|
||||
|
||||
public void setActiveStep(int activeStep) {
|
||||
public void setActiveTask(int activeStep) {
|
||||
this.activeStep = activeStep;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class Quest extends Delta implements Serializable {
|
||||
|
||||
buffer.flip();
|
||||
|
||||
StringUtilities.printBytes(buffer.array());
|
||||
//StringUtilities.printBytes(buffer.array());
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ import resources.common.ObjControllerOpcodes;
|
||||
import resources.common.OutOfBand;
|
||||
import resources.common.ProsePackage;
|
||||
import resources.common.collidables.CollidableCircle;
|
||||
import resources.common.collidables.QuestCollidable;
|
||||
import resources.datatables.DisplayType;
|
||||
import resources.objects.SWGMap;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
@@ -156,7 +157,7 @@ public class QuestService implements INetworkDispatch {
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
int activeStep = quest.getActiveStep();
|
||||
int activeStep = quest.getActiveTask();
|
||||
|
||||
QuestTask task = qData.getTasks().get(activeStep);
|
||||
|
||||
@@ -172,7 +173,6 @@ public class QuestService implements INetworkDispatch {
|
||||
player.getWaypoints().put(wpGoTo.getObjectID(), wpGoTo);
|
||||
|
||||
quest.setWaypointId(wpGoTo.getObjectID());
|
||||
|
||||
break;
|
||||
|
||||
// quest.task.ground.comm_player
|
||||
@@ -199,6 +199,7 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
// quest.task.ground.timer
|
||||
case "timer":
|
||||
//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()));
|
||||
|
||||
ScheduledFuture<?> taskTimer = Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(() -> {
|
||||
@@ -245,7 +246,7 @@ public class QuestService implements INetworkDispatch {
|
||||
|
||||
QuestData qData = getQuestData(quest.getName());
|
||||
|
||||
int activeStep = quest.getActiveStep();
|
||||
int activeStep = quest.getActiveTask();
|
||||
|
||||
QuestTask task = qData.getTasks().get(activeStep);
|
||||
|
||||
@@ -301,7 +302,7 @@ public class QuestService implements INetworkDispatch {
|
||||
quester.getClient().getSession().write(music.serialize());
|
||||
|
||||
player.getQuestJournal().put(quest.getCrc(), quest);
|
||||
player.setActiveQuest(quest.getCrc());
|
||||
player.setActiveQuest(quest.getName());
|
||||
|
||||
activateNextTask(quester, quest);
|
||||
}
|
||||
@@ -476,12 +477,6 @@ public class QuestService implements INetworkDispatch {
|
||||
}
|
||||
}
|
||||
|
||||
public void addCollisionEvent(String questName, String method, float x, float y, float z, float radius, String planet) {
|
||||
CollidableCircle collision = new CollidableCircle(new Point3D(x,y,z), radius, core.terrainService.getPlanetByName(planet));
|
||||
collision.setCallback(core.scriptService.getMethod("scripts/quests/events/", questName, method));
|
||||
core.simulationService.addCollidable(collision, x, z);
|
||||
}
|
||||
|
||||
public boolean adminActivateQuest(CreatureObject creo, String questName) {
|
||||
|
||||
PlayerObject ghost = creo.getPlayerObject();
|
||||
@@ -565,7 +560,14 @@ public class QuestService implements INetworkDispatch {
|
||||
if (visitor.getObjectByColumnNameAndIndex("RETRIEVE_MENU_TEXT", r) != null) task.setRetrieveMenuText((String) visitor.getObjectByColumnNameAndIndex("RETRIEVE_MENU_TEXT", r));
|
||||
if (visitor.getObjectByColumnNameAndIndex("MIN_TIME", r) != null) task.setMinTime((int) visitor.getObjectByColumnNameAndIndex("MIN_TIME", r));
|
||||
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("", r))
|
||||
|
||||
if (task.getType().equals("quest.task.ground.go_to_location")) {
|
||||
QuestCollidable collision = new QuestCollidable(new Point3D(task.getLocationX(), task.getLocationY(), task.getLocationZ()), task.getRadius(), core.terrainService.getPlanetByName(task.getPlanet()), quest, r);
|
||||
collision.setCallback(core.scriptService.getMethod("scripts/quests/events/", "go_to_location", "run"));
|
||||
core.simulationService.addCollidable(collision, task.getLocationX(), task.getLocationZ());
|
||||
}
|
||||
|
||||
data.getTasks().add(task);
|
||||
}
|
||||
@@ -612,19 +614,6 @@ public class QuestService implements INetworkDispatch {
|
||||
return qList;
|
||||
}
|
||||
|
||||
public void loadEvents() {
|
||||
FileVisitor<Path> fv = new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
|
||||
{
|
||||
core.scriptService.callScript("scripts/quests/events/", file.getFileName().toString().replace(".py", ""), "setup", core);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
try { Files.walkFileTree(Paths.get("scripts/quests/events/"), fv); }
|
||||
catch (IOException e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
// useful for custom quest scripts, and for the some of the datatables that are all screwed up
|
||||
/*private QuestData parseXmlQuestData(Quest quest) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user