mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-28 22:15:54 -04:00
55 lines
2.0 KiB
Plaintext
55 lines
2.0 KiB
Plaintext
include library.quests;
|
|
include library.utils;
|
|
|
|
trigger OnGrantedSchematic(int schematicCrc, boolean fromSkill)
|
|
{
|
|
// was a quest item received?
|
|
|
|
// There may be multiple retrieve_item tasks active simultaneously,
|
|
// either because they were granted at the same time, or because
|
|
// the player has accepted multiple quests. Which task, if any
|
|
// might be interested in this item?
|
|
String[] activeTasks = quests.getActiveQuestsWithScript("quest.task.retrieve_schematic", self);
|
|
int i;
|
|
for(i = 0; i < activeTasks.length; ++i)
|
|
{
|
|
LOG("newquests", "checking " + activeTasks[i]);
|
|
// is the active task complete?
|
|
boolean taskComplete = false;
|
|
|
|
if(hasObjVar(self, "quest." + activeTasks[i] + ".target_object_template"))
|
|
{
|
|
// the object type was overridden in script
|
|
String targetObjectTemplate = getStringObjVar(self, "quest." + activeTasks[i] + ".target_object_template");
|
|
LOG("newquests", "the TARGET column is overidden by target_object_template(" + targetObjectTemplate + ")");
|
|
if (schematicCrc == getStringCrc(targetObjectTemplate))
|
|
{
|
|
LOG("newquests", "this schematic(" + schematicCrc + ") is this retrieve_schematic task");
|
|
taskComplete = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// if there was no override, use the datatable entry
|
|
String targetObjectTemplate = quests.getDataEntry(activeTasks[i], "TARGET");
|
|
int targetObjectCrc = getStringCrc(targetObjectTemplate);
|
|
LOG("newquests", "the data table for " + activeTasks[i] + " specifies the schematic " + targetObjectCrc + "(" + targetObjectTemplate + ") to complete this task. The player has received " + schematicCrc);
|
|
if (schematicCrc == targetObjectCrc)
|
|
{
|
|
LOG("newquests", "this schematic(" + schematicCrc + ") is this retrieve_schematic task");
|
|
taskComplete = true;
|
|
}
|
|
}
|
|
|
|
// if the task is complete, stop iterating through the active tasks
|
|
// and complete this task
|
|
if (taskComplete)
|
|
{
|
|
LOG("newquests", "This retrieve_schematic quest completing the task");
|
|
quests.complete(activeTasks[i], self, true);
|
|
break;
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|