mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
284 lines
6.6 KiB
Plaintext
284 lines
6.6 KiB
Plaintext
include library.locations;
|
|
include library.quests;
|
|
include library.utils;
|
|
|
|
void completeTask(obj_id self, String questName, boolean succeeded) {
|
|
|
|
if(hasObjVar(self, "quest." + questName)) {
|
|
|
|
obj_id waypoint = getObjIdObjVar(self, "quest." + questName + ".waypoint");
|
|
|
|
if(isIdValid(waypoint)) {
|
|
|
|
destroyWaypointInDatapad(waypoint, self);
|
|
}
|
|
}
|
|
|
|
if(hasTheaterAssigned(self))
|
|
unassignTheaterFromPlayer(self);
|
|
|
|
quests.complete(questName, self, succeeded);
|
|
}
|
|
|
|
void setupTheater(obj_id self, int questRow) {
|
|
|
|
if(quests.isMyQuest(questRow, "quest.task.find_theater")) {
|
|
|
|
string questName = quests.getDataEntry(questRow, "NAME");
|
|
string script = null;
|
|
int theaterLocationType = TLT_getGoodLocation;
|
|
|
|
if(questName == null || questName.equals("") || !quests.isActive(questName, self))
|
|
return;
|
|
|
|
string parameterString = quests.getDataEntry(questRow, "PARAMETER");
|
|
|
|
if(parameterString != null && !parameterString.equals("")) {
|
|
|
|
string[] params = split(parameterString, ':');
|
|
|
|
for(int i = 0; i < params.length; i++) {
|
|
|
|
if ( "flat" == params[i] )
|
|
{
|
|
theaterLocationType = TLT_flatten;
|
|
}
|
|
else if ( "atloc" == params[i] )
|
|
{
|
|
theaterLocationType = TLT_none;
|
|
}
|
|
else if(!Character.isDigit(params[i].charAt(0))) {
|
|
|
|
script = params[i];
|
|
|
|
LOG("newquests", "FIND THEATER: script parsed: " + script);
|
|
}
|
|
}
|
|
}
|
|
|
|
string target = null;
|
|
|
|
if(hasObjVar(self, "quest." + questName + ".target")) {
|
|
|
|
target = getStringObjVar(self, "quest." + questName + ".target");
|
|
|
|
} else {
|
|
|
|
target = quests.getDataEntry(questRow, "TARGET");
|
|
}
|
|
|
|
if(target == null || target.equals(""))
|
|
return;
|
|
|
|
boolean havePlanet = false;
|
|
string[] tokens = split(target, ':');
|
|
|
|
string datatable = null;
|
|
|
|
if(tokens.length > 1)
|
|
havePlanet = true;
|
|
else
|
|
datatable = tokens[0];
|
|
|
|
if(havePlanet) {
|
|
|
|
if(tokens[0].indexOf(".iff") < 0)
|
|
datatable = tokens[1];
|
|
else
|
|
datatable = tokens[0];
|
|
}
|
|
|
|
location theaterLoc = new location();
|
|
boolean hasLocInfo = false;
|
|
|
|
int theaterTest = dataTableGetInt(datatable, 0, 0);
|
|
|
|
if(theaterTest > 0) {
|
|
|
|
if(theaterTest == ##"THEATER") {
|
|
|
|
float x = dataTableGetFloat(datatable, 0, "x");
|
|
float y = dataTableGetFloat(datatable, 0, "y");
|
|
float z = dataTableGetFloat(datatable, 0, "z");
|
|
string scene = dataTableGetString(datatable, 0, "scene");
|
|
|
|
if(scene == null || scene.equals(""))
|
|
scene = getCurrentSceneName();
|
|
|
|
theaterLoc = new location(x, y, z, scene);
|
|
|
|
hasLocInfo = true;
|
|
}
|
|
}
|
|
|
|
boolean created = false;
|
|
int attempts = 0;
|
|
|
|
if(hasLocInfo) {
|
|
|
|
created = assignTheaterToPlayer(self, datatable, theaterLocationType);
|
|
|
|
} else {
|
|
|
|
theaterLoc = quests.getTheaterLocationTarget(self, questRow);
|
|
|
|
if(theaterLoc != null) {
|
|
|
|
unassignTheaterFromPlayer(self);
|
|
created = assignTheaterToPlayer(self, datatable, theaterLoc, script, theaterLocationType);
|
|
|
|
}
|
|
}
|
|
|
|
if(created) {
|
|
|
|
if(isGod(self))
|
|
sendSystemMessageTestingOnly(self, "Theater Location: " + theaterLoc.toString());
|
|
|
|
// Add the theater location for the quest complete
|
|
addLocationTarget(questName, theaterLoc, 32.0f);
|
|
// Add a "fake" location for someplace nearby.
|
|
setupWaypoint(self, questRow, theaterLoc);
|
|
|
|
} else {
|
|
|
|
if(hasObjVar(self, "quest." + questName + ".generate")) {
|
|
|
|
if(hasObjVar(self, "quest." + questName + ".waypoint"))
|
|
return;
|
|
|
|
location loc = getLocationObjVar(self, "quest." + questName + ".generate");
|
|
|
|
obj_id wp = createWaypointInDatapad(self, loc);
|
|
|
|
string summary = quests.getDataEntry(questName, "JOURNAL_ENTRY_SUMMARY");
|
|
|
|
if(summary != null && summary.length() > 0)
|
|
setWaypointName(wp, summary);
|
|
else
|
|
setWaypointName(wp, "missing task summary for " + questName);
|
|
|
|
setWaypointColor(wp, "yellow");
|
|
setWaypointActive(wp, true);
|
|
setObjVar(self, "quest." + questName + ".waypoint", wp);
|
|
|
|
} else {
|
|
|
|
quests.complete(questName, self, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void setupWaypoint(obj_id self, int questRow, location loc) {
|
|
|
|
if(loc != null) {
|
|
|
|
string questName = quests.getDataEntry(questRow, "NAME");
|
|
|
|
if(hasObjVar(self, "quest." + questName + ".waypoint")) {
|
|
|
|
obj_id waypoint = getObjIdObjVar(self, "quest." + questName + ".waypoint");
|
|
|
|
if(isIdValid(waypoint))
|
|
destroyWaypointInDatapad(waypoint, self);
|
|
|
|
removeObjVar(self, "quest." + questName + ".waypoint");
|
|
}
|
|
|
|
if(questName != null && questName.length() > 0) {
|
|
|
|
int x_rand = rand(100, 250);
|
|
int z_rand = rand(100, 250);
|
|
|
|
int x_mod = rand(0, 1);
|
|
int z_mod = rand(0, 1);
|
|
|
|
if(x_mod == 0)
|
|
x_rand *= -1;
|
|
|
|
if(z_mod == 0)
|
|
z_rand *= -1;
|
|
|
|
loc.x += (float)x_rand;
|
|
loc.z += (float)z_rand;
|
|
|
|
obj_id wp = createWaypointInDatapad(self, loc);
|
|
|
|
string summary = quests.getDataEntry(questName, "JOURNAL_ENTRY_SUMMARY");
|
|
|
|
if(summary != null && summary.length() > 0) {
|
|
|
|
setWaypointName(wp, summary);
|
|
|
|
} else {
|
|
|
|
setWaypointName(wp, "missing task summary for " + questName);
|
|
}
|
|
|
|
setWaypointColor(wp, "yellow");
|
|
setWaypointActive(wp, true);
|
|
addLocationTarget(questName + "_waypoint", loc, 32.0f);
|
|
setObjVar(self, "quest." + questName + ".waypoint", wp);
|
|
}
|
|
}
|
|
}
|
|
|
|
trigger OnLogin() {
|
|
|
|
int rows = dataTableGetNumRows("datatables/player/quests.iff");
|
|
int iter = 0;
|
|
for(iter = 0; iter < rows; ++iter) {
|
|
|
|
string questName = quests.getDataEntry(iter, "NAME");
|
|
|
|
if(quests.isMyQuest(iter, "quest.task.find_theater")) {
|
|
|
|
if(quests.isActive(questName, self)) {
|
|
|
|
if(hasObjVar(self, "quest." + questName + ".generate")) {
|
|
|
|
removeObjVar(self, "quest." + questName + ".generate");
|
|
setupTheater(self, iter);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnQuestActivated(int questRow) {
|
|
|
|
if(quests.isMyQuest(questRow, "quest.task.find_theater")) {
|
|
|
|
setupTheater(self, questRow);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnArrivedAtLocation(string locationName) {
|
|
|
|
if(quests.isActive(locationName, self)) {
|
|
|
|
CustomerServiceLog("fs_quests", "DEBUG -- %TU arrived at location '" + locationName + "'. Preparing to mark find theater task as successfully completed.", self);
|
|
|
|
if(hasObjVar(self, "quest." + locationName + ".selected_location")) {
|
|
|
|
location expectedLoc = getLocationObjVar(self, "quest." + locationName + ".selected_location");
|
|
CustomerServiceLog("fs_quests", "DEBUG -- %TU should be close to: " + expectedLoc.toString(), self);
|
|
}
|
|
|
|
location currentLoc = getLocation(self);
|
|
CustomerServiceLog("fs_quests", "DEBUG -- %TU am currently at: " + currentLoc.toString(), self);
|
|
|
|
if(hasTheaterAssigned(self))
|
|
CustomerServiceLog("fs_quests", "DEBUG -- %TU still has a theater assigned when task is successful. This should not be.", self);
|
|
|
|
completeTask(self, locationName, true);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|