Files
dsrc/sku.0/sys.server/compiled/game/script/quest/task/find_location.script
T

78 lines
2.3 KiB
Plaintext

include library.locations;
include library.quests;
include library.utils;
trigger OnLogin()
{
// if the location was supposed to be randomly generated,
// but the target planet was specified as something other
// than the planet the quest was granted on, the
// location generation must be deferred until the
// player travels to the destination. Iterate through
// the quests, get generate
int rows = dataTableGetNumRows("datatables/player/quests.iff");
int iter = 0;
for(iter = 0; iter < rows; ++iter)
{
if(isQuestActive(self, iter))
{
// determine if the quest iterator is referring to
// a find_location task
if(quests.isMyQuest(iter, "quest.task.find_location"))
{
// this active quest is a find_location task,
// see if the target location needs to be generated
String questName = quests.getDataEntry(iter, "NAME");
if(hasObjVar(self, "quest." + questName + ".generate"))
{
// remove the object variable, it may be re-added
// if getLocationTarget() fails because THIS
// is not the right planet
removeObjVar(self, "quest." + questName + ".generate");
location loc = quests.getLocationTarget(self, iter);
}
}
}
}
return SCRIPT_CONTINUE;
}
trigger OnQuestActivated(int questRow)
{
LOG("newquests", "find_location - OnQuestActivated(" + questRow + ")");
// is the activating quest a find_location task?
if(quests.isMyQuest(questRow, "quest.task.find_location"))
{
LOG("newquests", "OnQuestActivated for find_location");
// attempt to generate the target location. This may
// defer until the player arrives on the target planet
// if the location is randomly generated
quests.getLocationTarget(self, questRow);
}
return SCRIPT_CONTINUE;
}
trigger OnArrivedAtLocation(string locationName)
{
// the location target name (locationName)
// is the name of the task, look up the task
// in the quests data table
int questId = quests.getQuestId(locationName);
if(questId > -1)
{
// the task was found, is it a find_location task?
if(quests.isMyQuest(questId, "quest.task.find_location"))
{
// is the task currently active?
if(quests.isActive(locationName, self))
{
LOG("newquests", "find_location arrived at " + locationName);
quests.complete(locationName, self, true);
}
}
}
return SCRIPT_CONTINUE;
}