mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-16 07:13:29 -04:00
who isn't sick of converting the freaking scripts? this negates the need
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class craft extends script.base_script
|
||||
{
|
||||
public craft()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "OnQUestActivated(" + quests.getDataEntry(questRow, "NAME"));
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
String craftedObjectTemplateName = null;
|
||||
String objvarname = "quest." + questName + ".target";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
craftedObjectTemplateName = getStringObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
craftedObjectTemplateName = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
int craftedObjectCount = 1;
|
||||
objvarname = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
craftedObjectCount = getIntObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
String countString = quests.getDataEntry(questRow, "PARAMETER");
|
||||
craftedObjectCount = utils.stringToInt(countString);
|
||||
if (craftedObjectCount < 1)
|
||||
{
|
||||
craftedObjectCount = 1;
|
||||
}
|
||||
}
|
||||
if (craftedObjectTemplateName != null && craftedObjectTemplateName.length() > 0)
|
||||
{
|
||||
int objectTemplateCrc = getObjectTemplateCrc(craftedObjectTemplateName);
|
||||
objvarname = "quest." + questName + ".count";
|
||||
setObjVar(self, objvarname, craftedObjectCount);
|
||||
objvarname = "quest." + questName + ".current_count";
|
||||
int currentCount = 0;
|
||||
setObjVar(self, objvarname, currentCount);
|
||||
objvarname = "quest." + questName + ".objectTemplateCrc";
|
||||
setObjVar(self, objvarname, objectTemplateCrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnQuestActivated() - could not determine object to craft");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnCraftedPrototype(obj_id self, obj_id prototypeObject, draft_schematic manufacturingSchematic) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "OnCraftedPrototype(" + prototypeObject + ", " + manufacturingSchematic + ")");
|
||||
LOG("newquests", "OnCraftedPrototype() player has crafted a " + getTemplateName(prototypeObject));
|
||||
String[] activeTasks = quests.getActiveQuestsWithScript("quest.task.craft", self);
|
||||
if (activeTasks != null && activeTasks.length > 0)
|
||||
{
|
||||
int iter = 0;
|
||||
int prototypeObjectTemplateCrc = getObjectTemplateCrc(getTemplateName(prototypeObject));
|
||||
for (iter = 0; iter < activeTasks.length; ++iter)
|
||||
{
|
||||
String objvarname = "quest." + activeTasks[iter] + ".objectTemplateCrc";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
int objectTemplateCrc = getIntObjVar(self, objvarname);
|
||||
if (objectTemplateCrc == prototypeObjectTemplateCrc)
|
||||
{
|
||||
int count = 1;
|
||||
objvarname = "quest." + activeTasks[iter] + ".count";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
count = getIntObjVar(self, objvarname);
|
||||
if (count < 1)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
int currentCount = 0;
|
||||
objvarname = "quest." + activeTasks[iter] + ".current_count";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
currentCount = getIntObjVar(self, objvarname);
|
||||
}
|
||||
currentCount++;
|
||||
setObjVar(self, objvarname, currentCount);
|
||||
if (currentCount >= count)
|
||||
{
|
||||
quests.complete(activeTasks[iter], self, true);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "cract - OnCraftedPrototype - the quest requires " + count + " objects to be crafted. The player has crafted " + currentCount + " objects");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnCraftedPrototype - the crafted object template crc (" + prototypeObjectTemplateCrc + " does not match the required crafted object template crc " + objectTemplateCrc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnCraftedPrototype - could not determine what object needs to be crafted, " + objvarname + " was not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnCraftedPrototype - no active tasks for quest.task.craft");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
// set an object variable indicating what kind of
|
||||
// schematic must be used when crafting the item
|
||||
// to track the quest when OnCraftedPrototype
|
||||
// is invoked
|
||||
LOG("newquests", "OnQUestActivated(" + quests.getDataEntry(questRow, "NAME"));
|
||||
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
String craftedObjectTemplateName = null;
|
||||
String objvarname = "quest." + questName + ".target";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
craftedObjectTemplateName = getStringObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
craftedObjectTemplateName = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
|
||||
int craftedObjectCount = 1;
|
||||
objvarname = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
craftedObjectCount = getIntObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
String countString = quests.getDataEntry(questRow, "PARAMETER");
|
||||
craftedObjectCount = utils.stringToInt(countString);
|
||||
if(craftedObjectCount < 1)
|
||||
craftedObjectCount = 1;
|
||||
}
|
||||
|
||||
if(craftedObjectTemplateName != null && craftedObjectTemplateName.length() > 0)
|
||||
{
|
||||
int objectTemplateCrc = getObjectTemplateCrc(craftedObjectTemplateName);
|
||||
objvarname = "quest." + questName + ".count";
|
||||
setObjVar(self, objvarname, craftedObjectCount);
|
||||
|
||||
objvarname = "quest." + questName + ".current_count";
|
||||
int currentCount = 0;
|
||||
setObjVar(self, objvarname, currentCount);
|
||||
|
||||
objvarname = "quest." + questName + ".objectTemplateCrc";
|
||||
setObjVar(self, objvarname, objectTemplateCrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnQuestActivated() - could not determine object to craft");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnCraftedPrototype(obj_id prototypeObject, draft_schematic manufacturingSchematic)
|
||||
{
|
||||
LOG("newquests", "OnCraftedPrototype(" + prototypeObject + ", " + manufacturingSchematic + ")");
|
||||
LOG("newquests", "OnCraftedPrototype() player has crafted a " + getTemplateName(prototypeObject));
|
||||
|
||||
|
||||
String[] activeTasks = quests.getActiveQuestsWithScript("quest.task.craft", self);
|
||||
if(activeTasks != null && activeTasks.length > 0)
|
||||
{
|
||||
int iter = 0;
|
||||
int prototypeObjectTemplateCrc = getObjectTemplateCrc(getTemplateName(prototypeObject));
|
||||
for(iter = 0; iter < activeTasks.length; ++iter)
|
||||
{
|
||||
String objvarname = "quest." + activeTasks[iter] + ".objectTemplateCrc";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
int objectTemplateCrc = getIntObjVar(self, objvarname);
|
||||
if(objectTemplateCrc == prototypeObjectTemplateCrc)
|
||||
{
|
||||
// see if count has been met
|
||||
int count = 1;
|
||||
objvarname = "quest." + activeTasks[iter] + ".count";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
count = getIntObjVar(self, objvarname);
|
||||
if(count < 1)
|
||||
{
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
int currentCount = 0;
|
||||
objvarname = "quest." + activeTasks[iter] + ".current_count";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
currentCount = getIntObjVar(self, objvarname);
|
||||
}
|
||||
|
||||
currentCount++;
|
||||
setObjVar(self, objvarname, currentCount);
|
||||
|
||||
if(currentCount >= count)
|
||||
{
|
||||
quests.complete(activeTasks[iter], self, true);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "cract - OnCraftedPrototype - the quest requires " + count + " objects to be crafted. The player has crafted " + currentCount + " objects");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnCraftedPrototype - the crafted object template crc (" + prototypeObjectTemplateCrc + " does not match the required crafted object template crc " + objectTemplateCrc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnCraftedPrototype - could not determine what object needs to be crafted, " + objvarname + " was not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "craft - OnCraftedPrototype - no active tasks for quest.task.craft");
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class destroy extends script.base_script
|
||||
{
|
||||
public destroy()
|
||||
{
|
||||
}
|
||||
public int OnIncapacitateTarget(obj_id self, obj_id target) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "destroy - OnIncapacitateTarget()");
|
||||
int questId = quests.getQuestIdForTarget(self, target);
|
||||
if (questId > -1)
|
||||
{
|
||||
LOG("newquests", "destroy - Destroyed target is for a player's current active task");
|
||||
String questName = quests.getDataEntry(questId, "NAME");
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
|
||||
trigger OnIncapacitateTarget(obj_id target)
|
||||
{
|
||||
// the player has killed a creature or NPC
|
||||
// determine if the creature is related to an
|
||||
// active quest owned by the player
|
||||
LOG("newquests", "destroy - OnIncapacitateTarget()");
|
||||
int questId = quests.getQuestIdForTarget(self, target);
|
||||
if(questId > -1)
|
||||
{
|
||||
// it is in fact for this player, complete the
|
||||
// target destroy quest
|
||||
LOG("newquests", "destroy - Destroyed target is for a player's current active task");
|
||||
String questName = quests.getDataEntry(questId, "NAME");
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
import script.library.prose;
|
||||
import script.library.xp;
|
||||
|
||||
public class destroy_multi extends script.base_script
|
||||
{
|
||||
public destroy_multi()
|
||||
{
|
||||
}
|
||||
public int receiveCreditForKill(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String targetType = params.getString("creatureName");
|
||||
location creatureLoc = params.getLocation("location");
|
||||
if (getDistance(getLocation(self), creatureLoc) > xp.MAX_DISTANCE)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (targetType != null && targetType.length() > 0)
|
||||
{
|
||||
String objvarName = "quest.destroy_multi." + targetType;
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
if (questNames != null && questNames.length > 0)
|
||||
{
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
String questName = questNames[iter];
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
int killsRemaining = getIntObjVar(self, objvarName);
|
||||
killsRemaining--;
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: kills remaining = " + killsRemaining);
|
||||
if (killsRemaining < 1)
|
||||
{
|
||||
String[] newQuestNames = new String[questNames.length - 1];
|
||||
int ni = 0;
|
||||
int index = 0;
|
||||
for (ni = 0; ni < questNames.length; ++ni)
|
||||
{
|
||||
if (ni != iter)
|
||||
{
|
||||
newQuestNames[index] = questNames[ni];
|
||||
++index;
|
||||
}
|
||||
}
|
||||
if (newQuestNames.length < 1)
|
||||
{
|
||||
objvarName = "quest.destroy_multi." + targetType;
|
||||
removeObjVar(self, objvarName);
|
||||
}
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
setObjVar(self, objvarName, killsRemaining);
|
||||
string_id message = new string_id("quest/quests", "kill_credit");
|
||||
String summary = quests.getDataEntry(questName, "JOURNAL_ENTRY_SUMMARY");
|
||||
prose_package pp = prose.getPackage(message, self, self, summary, killsRemaining);
|
||||
sendSystemMessageProse(self, pp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: questNames objvar \"" + objvarName + "\" string array is empty");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not retrieve objvar " + objvarName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not determine target type name from target creature");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.destroy_multi"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
LOG("newquests", "OnQuestActivated(" + questName + ")");
|
||||
String target = null;
|
||||
String objvarName = "quest." + questName + ".target";
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
target = getStringObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
int killCount = 0;
|
||||
if (target != null && target.length() > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, target);
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
killCount = getIntObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
String countName = quests.getDataEntry(questRow, "PARAMETER");
|
||||
if (countName != null && countName.length() > 0)
|
||||
{
|
||||
killCount = utils.stringToInt(countName);
|
||||
}
|
||||
}
|
||||
if (killCount > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, killCount);
|
||||
objvarName = "quest.destroy_multi." + target;
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
String[] newQuestNames = null;
|
||||
if (questNames == null)
|
||||
{
|
||||
newQuestNames = new String[1];
|
||||
newQuestNames[0] = questName;
|
||||
}
|
||||
else
|
||||
{
|
||||
newQuestNames = new String[questNames.length + 1];
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
newQuestNames[iter] = questNames[iter];
|
||||
}
|
||||
newQuestNames[questNames.length] = questName;
|
||||
}
|
||||
if (newQuestNames != null && newQuestNames.length > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, newQuestNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: Could not set questnames string array objvar");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine kill count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine target creature type");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
include library.prose;
|
||||
include library.xp;
|
||||
|
||||
messageHandler receiveCreditForKill()
|
||||
{
|
||||
string targetType = params.getString( "creatureName" );
|
||||
location creatureLoc = params.getLocation("location");
|
||||
if ( getDistance( getLocation(self), creatureLoc ) > xp.MAX_DISTANCE )
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if(targetType != null && targetType.length() > 0)
|
||||
{
|
||||
String objvarName = "quest.destroy_multi." + targetType;
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
if(questNames != null && questNames.length > 0)
|
||||
{
|
||||
int iter = 0;
|
||||
for(iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
String questName = questNames[iter];
|
||||
if(quests.isActive(questName, self))
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
int killsRemaining = getIntObjVar(self, objvarName);
|
||||
killsRemaining--;
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: kills remaining = " + killsRemaining);
|
||||
if(killsRemaining < 1)
|
||||
{
|
||||
// remove the target from the questNames
|
||||
String[] newQuestNames = new String[questNames.length - 1];
|
||||
int ni = 0;
|
||||
int index = 0;
|
||||
for(ni = 0; ni < questNames.length; ++ ni)
|
||||
{
|
||||
if(ni != iter)
|
||||
{
|
||||
newQuestNames[index] = questNames[ni];
|
||||
++index;
|
||||
}
|
||||
}
|
||||
if(newQuestNames.length < 1)
|
||||
{
|
||||
objvarName = "quest.destroy_multi." + targetType;
|
||||
removeObjVar(self, objvarName);
|
||||
// if questNames is empty, remove the objvar
|
||||
|
||||
}
|
||||
|
||||
// complete the quest
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
setObjVar(self, objvarName, killsRemaining);
|
||||
//Send System Message to players notifying them they got credit using journal
|
||||
//summary name to specify for what quest.
|
||||
string_id message = new string_id ("quest/quests", "kill_credit");
|
||||
String summary = quests.getDataEntry(questName, "JOURNAL_ENTRY_SUMMARY");
|
||||
prose_package pp = prose.getPackage(message,self,self,summary,killsRemaining);
|
||||
sendSystemMessageProse(self, pp);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: questNames objvar \"" + objvarName + "\" string array is empty");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not retrieve objvar " + objvarName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not determine target type name from target creature");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
if(quests.isMyQuest(questRow, "quest.task.destroy_multi"))
|
||||
{
|
||||
// get target creature type
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
LOG("newquests", "OnQuestActivated(" + questName + ")");
|
||||
String target = null;
|
||||
String objvarName = "quest." + questName + ".target";
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
target = getStringObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
|
||||
int killCount = 0;
|
||||
|
||||
if(target != null && target.length() > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, target);
|
||||
// retrieve the count
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
killCount = getIntObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
String countName = quests.getDataEntry(questRow, "PARAMETER");
|
||||
if(countName != null && countName.length() > 0)
|
||||
{
|
||||
killCount = utils.stringToInt(countName);
|
||||
}
|
||||
}
|
||||
|
||||
if(killCount > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, killCount);
|
||||
objvarName = "quest.destroy_multi." + target;
|
||||
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
String[] newQuestNames = null;
|
||||
if(questNames == null)
|
||||
{
|
||||
newQuestNames = new String[1];
|
||||
newQuestNames[0] = questName;
|
||||
}
|
||||
else
|
||||
{
|
||||
newQuestNames = new String[questNames.length + 1];
|
||||
|
||||
int iter = 0;
|
||||
for(iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
newQuestNames[iter] = questNames[iter];
|
||||
}
|
||||
|
||||
newQuestNames[questNames.length] = questName;
|
||||
}
|
||||
|
||||
if(newQuestNames != null && newQuestNames.length > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, newQuestNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: Could not set questnames string array objvar");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine kill count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine target creature type");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.create;
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class encounter extends script.base_script
|
||||
{
|
||||
public encounter()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "encounter - OnQuestActivated(+ " + questRow + ")");
|
||||
if (quests.isMyQuest(questRow, "quest.task.encounter"))
|
||||
{
|
||||
boolean success = quests.doEncounterSpawn(self, questRow);
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
quests.complete(questName, self, success);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
include library.create;
|
||||
include library.locations;
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
LOG("newquests", "encounter - OnQuestActivated(+ " + questRow + ")");
|
||||
|
||||
// determine if the trigger is related to this particular script
|
||||
// more than one task script may be attached to the player
|
||||
if(quests.isMyQuest(questRow, "quest.task.encounter"))
|
||||
{
|
||||
boolean success = quests.doEncounterSpawn(self, questRow);
|
||||
|
||||
// get the name of the qust from the quests data table
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
|
||||
// complete the task. It is normal for log output to indicate
|
||||
// that the encounter failed to activate, because this call
|
||||
// will deactivate it while in the process of activating it.
|
||||
quests.complete(questName, self, success);
|
||||
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.create;
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class encounter_multi extends script.base_script
|
||||
{
|
||||
public encounter_multi()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.encounter_multi"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
String objvarName = "quest." + questName + ".target";
|
||||
String target = null;
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
target = getStringObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
if (target != null && target.length() > 0)
|
||||
{
|
||||
int rowCount = dataTableGetNumRows(target);
|
||||
if (rowCount > 0)
|
||||
{
|
||||
int spawnCount = 0;
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < rowCount; ++iter)
|
||||
{
|
||||
int count = dataTableGetInt(target, iter, "COUNT");
|
||||
if (count > 0)
|
||||
{
|
||||
spawnCount += count;
|
||||
}
|
||||
}
|
||||
if (spawnCount > 0)
|
||||
{
|
||||
objvarName = "quest." + questName + ".spawnCount";
|
||||
setObjVar(self, objvarName, spawnCount);
|
||||
objvarName = "quest." + questName + "spawned";
|
||||
int spawned = 0;
|
||||
setObjVar(self, objvarName, spawned);
|
||||
dictionary spawnEventParameters = new dictionary();
|
||||
spawnEventParameters.put("questName", questName);
|
||||
spawnEventParameters.put("datatable", target);
|
||||
int currentRow = 0;
|
||||
spawnEventParameters.put("currentRow", currentRow);
|
||||
int currentSpawn = 0;
|
||||
spawnEventParameters.put("currentSpawn", currentSpawn);
|
||||
spawnEventParameters.put("spawner", self);
|
||||
float yaw = getYaw(self);
|
||||
location spawnLocation = utils.getLocationInArc(self, yaw - 30, yaw + 30, 48.0f);
|
||||
location l = locations.getGoodLocationAroundLocation(spawnLocation, 8, 8, 48, 48, false, true);
|
||||
if (l != null)
|
||||
{
|
||||
spawnEventParameters.put("location", l);
|
||||
messageTo(self, "encounterMultiSpawnEvent", spawnEventParameters, 1.0f, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivate() - failed to find suitable location for " + target + " for encounter spawn, failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivate() - no spawns defined in data table " + target + ", failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivate() - failed to retrieve data table information from " + target + " for encounter spawn, failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivated() - could not determine datatable to spawn encounter, failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
Vector spawnedCreatures = utils.getResizeableObjIdArrayScriptVar(self, "encounter_multi_creatures");
|
||||
if (spawnedCreatures != null)
|
||||
{
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < spawnedCreatures.size(); ++iter)
|
||||
{
|
||||
messageTo(((obj_id)spawnedCreatures.get(iter)), "cleanup", null, 0.0f, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int encounterMultiSpawnEvent(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params != null)
|
||||
{
|
||||
obj_id spawner = params.getObjId("spawner");
|
||||
String questName = params.getString("questName");
|
||||
LOG("newquests", "encounterMultiSpawnEvent(spawner=" + params.getObjId("spawner") + ", questName=" + questName + ", currentRow=" + params.getInt("currentRow") + ", currentSpawn=" + params.getInt("currentSpawn") + ")");
|
||||
if (spawner == self && questName != null && questName.length() > 0 && quests.isMyQuest(quests.getQuestId(questName), "quest.task.encounter_multi") && quests.isActive(questName, self))
|
||||
{
|
||||
String datatable = params.getString("datatable");
|
||||
if (datatable != null && datatable.length() > 0)
|
||||
{
|
||||
int currentRow = -1;
|
||||
currentRow = params.getInt("currentRow");
|
||||
if (currentRow >= 0 && currentRow <= dataTableGetNumRows(datatable))
|
||||
{
|
||||
int currentSpawn = -1;
|
||||
currentSpawn = params.getInt("currentSpawn");
|
||||
if (currentSpawn >= 0)
|
||||
{
|
||||
int totalSpawns = dataTableGetInt(datatable, currentRow, "COUNT");
|
||||
if (currentSpawn < totalSpawns)
|
||||
{
|
||||
String spawnEntry = dataTableGetString(datatable, currentRow, "SPAWN");
|
||||
if (spawnEntry != null && spawnEntry.length() > 0)
|
||||
{
|
||||
location l = params.getLocation("location");
|
||||
l.x = l.x + rand(-2, 2);
|
||||
l.z = l.z + rand(-2, 2);
|
||||
obj_id creature = create.createCreature(spawnEntry, l, true);
|
||||
if (isIdValid(creature))
|
||||
{
|
||||
Vector spawnedCreatures = utils.getResizeableObjIdArrayScriptVar(self, "encounter_multi_creatures");
|
||||
if (spawnedCreatures == null)
|
||||
{
|
||||
spawnedCreatures = new Vector();
|
||||
}
|
||||
spawnedCreatures.add(creature);
|
||||
utils.setScriptVar(self, "encounter_multi_creatures", spawnedCreatures);
|
||||
attachScript(creature, "quest.utility.encounter_death_multi_notification");
|
||||
String scriptName = dataTableGetString(datatable, currentRow, "SCRIPT");
|
||||
if (scriptName != null && scriptName.length() > 0)
|
||||
{
|
||||
attachScript(creature, scriptName);
|
||||
}
|
||||
setObjVar(creature, "quest.owner", self);
|
||||
setObjVar(creature, "quest.name", questName);
|
||||
|
||||
{
|
||||
startCombat(creature, self);
|
||||
}
|
||||
currentSpawn++;
|
||||
if (currentSpawn >= totalSpawns)
|
||||
{
|
||||
++currentRow;
|
||||
currentSpawn = 0;
|
||||
}
|
||||
if (currentRow < dataTableGetNumRows(datatable))
|
||||
{
|
||||
dictionary eventParameters = new dictionary();
|
||||
eventParameters.put("questName", questName);
|
||||
eventParameters.put("datatable", datatable);
|
||||
eventParameters.put("currentRow", currentRow);
|
||||
eventParameters.put("currentSpawn", currentSpawn);
|
||||
eventParameters.put("spawner", spawner);
|
||||
eventParameters.put("location", l);
|
||||
messageTo(self, "encounterMultiSpawnEvent", eventParameters, 1.0f, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - encounterMultiSpawnEvent - currentRow(" + currentRow + ") >= numRows(" + dataTableGetNumRows(datatable) + ") stopping message pump");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multu - encounterMultiSpawnEvent - failed to spawn creature " + spawnEntry + " in data table " + datatable + " failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "failed to retrieve spawn entry for task " + questName + " failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "if(currentSpawn(" + currentSpawn + ") < totalSpawns(" + totalSpawns + ")) for row(" + currentRow + ") failed to get row spawn, this shouldn't happen. Look at the script and insure everything is working properly");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "can't determine current spawn entry. failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "can't determine current row(" + currentRow + ") . failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "can't get data table name for quest " + questName + ", failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - encounterMultiSpawnEvent - spawn event isn't for me");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - encounterMultiSpawnEvent() - received null parameters");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void failTasks(obj_id self) throws InterruptedException
|
||||
{
|
||||
String[] activeTasks = quests.getActiveQuestsWithScript("quest.task.encounter_multi", self);
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < activeTasks.length; ++iter)
|
||||
{
|
||||
quests.complete(activeTasks[iter], self, false);
|
||||
}
|
||||
}
|
||||
public int OnDeath(obj_id self, obj_id killer, obj_id corpseId) throws InterruptedException
|
||||
{
|
||||
failTasks(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnIncapacitated(obj_id self, obj_id killer) throws InterruptedException
|
||||
{
|
||||
failTasks(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int destroyNotification(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params != null)
|
||||
{
|
||||
String questName = params.getString("questName");
|
||||
quests.complete(questName, self, false);
|
||||
LOG("newquests", "encounter_multi - destroyNotification - received a destroy notification, meaning the player did not receive a death notification, the task will now fail");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int deathNotification(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
String questName = params.getString("questName");
|
||||
String objvarName = "quest." + questName + ".killCount";
|
||||
int killCount = 1;
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
killCount = getIntObjVar(self, objvarName);
|
||||
killCount++;
|
||||
}
|
||||
objvarName = "quest." + questName + ".spawnCount";
|
||||
int spawnCount = 0;
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
spawnCount = getIntObjVar(self, objvarName);
|
||||
}
|
||||
LOG("newquests", "encounter_multi - deathNotification() - killCount=" + killCount + " spawnCount=" + spawnCount);
|
||||
if (killCount >= spawnCount)
|
||||
{
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
objvarName = "quest." + questName + ".killCount";
|
||||
setObjVar(self, objvarName, killCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - deathNotification() - received a message with null parameters");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,320 +0,0 @@
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.create;
|
||||
include library.locations;
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
if(quests.isMyQuest(questRow, "quest.task.encounter_multi"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
String objvarName = "quest." + questName + ".target";
|
||||
|
||||
String target = null;
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
target = getStringObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
|
||||
if(target != null && target.length() > 0)
|
||||
{
|
||||
// get some info from the data table
|
||||
int rowCount = dataTableGetNumRows(target);
|
||||
if(rowCount > 0)
|
||||
{
|
||||
int spawnCount = 0;
|
||||
int iter = 0 ;
|
||||
for(iter = 0; iter < rowCount; ++ iter)
|
||||
{
|
||||
int count = dataTableGetInt(target, iter, "COUNT");
|
||||
if(count > 0)
|
||||
{
|
||||
spawnCount += count;
|
||||
}
|
||||
}
|
||||
|
||||
if(spawnCount > 0)
|
||||
{
|
||||
objvarName = "quest." + questName + ".spawnCount";
|
||||
setObjVar(self, objvarName, spawnCount);
|
||||
|
||||
objvarName = "quest." + questName + "spawned";
|
||||
int spawned = 0;
|
||||
setObjVar(self, objvarName, spawned);
|
||||
|
||||
// start spawn events
|
||||
dictionary spawnEventParameters = new dictionary();
|
||||
spawnEventParameters.put("questName", questName);
|
||||
spawnEventParameters.put("datatable", target);
|
||||
|
||||
int currentRow = 0;
|
||||
spawnEventParameters.put("currentRow", currentRow);
|
||||
|
||||
int currentSpawn = 0;
|
||||
spawnEventParameters.put("currentSpawn", currentSpawn);
|
||||
spawnEventParameters.put("spawner", self);
|
||||
float yaw = getYaw(self);
|
||||
location spawnLocation = utils.getLocationInArc(self, yaw-30, yaw+30, 48.0f);
|
||||
location l = locations.getGoodLocationAroundLocation(spawnLocation, 8, 8, 48, 48, false, true);
|
||||
if(l != null)
|
||||
{
|
||||
spawnEventParameters.put("location", l);
|
||||
messageTo(self, "encounterMultiSpawnEvent", spawnEventParameters, 1.0f, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivate() - failed to find suitable location for " + target + " for encounter spawn, failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivate() - no spawns defined in data table " + target + ", failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivate() - failed to retrieve data table information from " + target + " for encounter spawn, failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - OnQuestActivated() - could not determine datatable to spawn encounter, failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
resizeable obj_id[] spawnedCreatures = utils.getResizeableObjIdArrayScriptVar(self, "encounter_multi_creatures");
|
||||
if(spawnedCreatures != null)
|
||||
{
|
||||
int iter = 0;
|
||||
for(iter = 0; iter < spawnedCreatures.length; ++iter)
|
||||
{
|
||||
messageTo(spawnedCreatures[iter], "cleanup", null, 0.0f, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler encounterMultiSpawnEvent()
|
||||
{
|
||||
if(params != null)
|
||||
{
|
||||
obj_id spawner = params.getObjId("spawner");
|
||||
String questName = params.getString("questName");
|
||||
LOG("newquests", "encounterMultiSpawnEvent(spawner=" + params.getObjId("spawner") + ", questName=" + questName + ", currentRow=" + params.getInt("currentRow") + ", currentSpawn=" + params.getInt("currentSpawn") + ")");
|
||||
if(spawner == self && questName != null && questName.length() > 0 && quests.isMyQuest(quests.getQuestId(questName), "quest.task.encounter_multi") && quests.isActive(questName, self))
|
||||
{
|
||||
String datatable = params.getString("datatable");
|
||||
if(datatable != null && datatable.length() > 0)
|
||||
{
|
||||
int currentRow = -1;
|
||||
currentRow = params.getInt("currentRow");
|
||||
|
||||
if(currentRow >= 0 && currentRow <= dataTableGetNumRows(datatable))
|
||||
{
|
||||
int currentSpawn = -1;
|
||||
currentSpawn = params.getInt("currentSpawn");
|
||||
if(currentSpawn >= 0)
|
||||
{
|
||||
// lookup the spawn count in the datatable
|
||||
int totalSpawns = dataTableGetInt(datatable, currentRow, "COUNT");
|
||||
if(currentSpawn < totalSpawns)
|
||||
{
|
||||
// spawn next in the row
|
||||
String spawnEntry = dataTableGetString(datatable, currentRow, "SPAWN");
|
||||
if(spawnEntry != null && spawnEntry.length() > 0)
|
||||
{
|
||||
location l = params.getLocation("location");
|
||||
l.x = l.x + rand(-2, 2);
|
||||
l.z = l.z + rand(-2, 2);
|
||||
obj_id creature = create.createCreature(spawnEntry, l, true);
|
||||
if(isIdValid(creature))
|
||||
{
|
||||
resizeable obj_id[] spawnedCreatures = utils.getResizeableObjIdArrayScriptVar(self, "encounter_multi_creatures");
|
||||
if(spawnedCreatures == null)
|
||||
{
|
||||
spawnedCreatures = new Vector();
|
||||
}
|
||||
spawnedCreatures.add(creature);
|
||||
utils.setScriptVar(self, "encounter_multi_creatures", spawnedCreatures);
|
||||
|
||||
// attach a helper script that tells the player
|
||||
// about a creature being destroyed
|
||||
attachScript(creature, "quest.utility.encounter_death_multi_notification");
|
||||
String scriptName = dataTableGetString(datatable, currentRow, "SCRIPT");
|
||||
if(scriptName != null && scriptName.length() > 0)
|
||||
{
|
||||
attachScript(creature, scriptName);
|
||||
}
|
||||
setObjVar(creature, "quest.owner", self);
|
||||
setObjVar(creature, "quest.name", questName);
|
||||
|
||||
// if(ai_lib.isAggro(creature))
|
||||
{
|
||||
startCombat(creature, self);
|
||||
}
|
||||
|
||||
// increment currentSpawn
|
||||
currentSpawn++;
|
||||
if(currentSpawn >= totalSpawns)
|
||||
{
|
||||
++currentRow;
|
||||
currentSpawn = 0;
|
||||
}
|
||||
|
||||
if(currentRow < dataTableGetNumRows(datatable))
|
||||
{
|
||||
// continue message pump
|
||||
dictionary eventParameters = new dictionary();
|
||||
eventParameters.put("questName", questName);
|
||||
eventParameters.put("datatable", datatable);
|
||||
eventParameters.put("currentRow", currentRow);
|
||||
eventParameters.put("currentSpawn", currentSpawn);
|
||||
eventParameters.put("spawner", spawner);
|
||||
eventParameters.put("location", l);
|
||||
messageTo(self, "encounterMultiSpawnEvent", eventParameters, 1.0f, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - encounterMultiSpawnEvent - currentRow(" + currentRow + ") >= numRows(" + dataTableGetNumRows(datatable) + ") stopping message pump");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed to spawn creature, fail task
|
||||
LOG("newquests", "encounter_multu - encounterMultiSpawnEvent - failed to spawn creature " + spawnEntry + " in data table " + datatable + " failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// can't get spawn data, fail task
|
||||
LOG("newquests", "failed to retrieve spawn entry for task " + questName + " failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed to move to next row?
|
||||
// this shouldn't happen
|
||||
LOG("newquests", "if(currentSpawn(" + currentSpawn + ") < totalSpawns(" + totalSpawns + ")) for row(" + currentRow + ") failed to get row spawn, this shouldn't happen. Look at the script and insure everything is working properly");
|
||||
quests.complete(questName, self, false);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "can't determine current spawn entry. failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "can't determine current row(" + currentRow + ") . failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "can't get data table name for quest " + questName + ", failing task");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - encounterMultiSpawnEvent - spawn event isn't for me");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - encounterMultiSpawnEvent() - received null parameters");
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void failTasks(obj_id self)
|
||||
{
|
||||
String[] activeTasks = quests.getActiveQuestsWithScript("quest.task.encounter_multi", self);
|
||||
int iter = 0;
|
||||
for(iter = 0; iter < activeTasks.length; ++iter)
|
||||
{
|
||||
quests.complete(activeTasks[iter], self, false);
|
||||
}
|
||||
}
|
||||
|
||||
trigger OnDeath(obj_id killer, obj_id corpseId)
|
||||
{
|
||||
failTasks(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnIncapacitated(obj_id killer)
|
||||
{
|
||||
failTasks(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler destroyNotification()
|
||||
{
|
||||
if(params != null)
|
||||
{
|
||||
String questName = params.getString("questName");
|
||||
quests.complete(questName, self, false);
|
||||
LOG("newquests", "encounter_multi - destroyNotification - received a destroy notification, meaning the player did not receive a death notification, the task will now fail");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler deathNotification()
|
||||
{
|
||||
if(params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
String questName = params.getString("questName");
|
||||
String objvarName = "quest." + questName + ".killCount";
|
||||
int killCount = 1;
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
killCount = getIntObjVar(self, objvarName);
|
||||
killCount++;
|
||||
}
|
||||
objvarName = "quest." + questName + ".spawnCount";
|
||||
int spawnCount = 0;
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
spawnCount = getIntObjVar(self, objvarName);
|
||||
}
|
||||
|
||||
LOG("newquests", "encounter_multi - deathNotification() - killCount=" + killCount + " spawnCount=" + spawnCount);
|
||||
if(killCount >= spawnCount)
|
||||
{
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
objvarName = "quest." + questName + ".killCount";
|
||||
setObjVar(self, objvarName, killCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "encounter_multi - deathNotification() - received a message with null parameters");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.library.quests;
|
||||
|
||||
public class escort extends script.base_script
|
||||
{
|
||||
public escort()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.escort"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
LOG("newquests", "escort - OnQuestActivated() - initializing escort task " + questName);
|
||||
String objvarname = "quest." + questName + ".target";
|
||||
obj_id target = null;
|
||||
float radius = 32.0f;
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
target = getObjIdObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
String targetName = quests.getDataEntry(questRow, "TARGET");
|
||||
target = quests.getTargetForQuest(self, targetName);
|
||||
}
|
||||
if (target != null)
|
||||
{
|
||||
String locationName = null;
|
||||
location npcDestination = null;
|
||||
objvarname = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
npcDestination = getLocationObjVar(self, objvarname);
|
||||
addLocationTarget(questName, npcDestination, radius);
|
||||
locationName = questName;
|
||||
}
|
||||
else
|
||||
{
|
||||
String parameter = quests.getDataEntry(questRow, "PARAMETER");
|
||||
if (parameter != null && parameter.length() > 0)
|
||||
{
|
||||
quests.activate(parameter, self, quests.getQuestGiver(questRow, self));
|
||||
locationName = parameter;
|
||||
objvarname = "quest." + parameter + ".selected_location";
|
||||
npcDestination = getLocationObjVar(self, objvarname);
|
||||
radius = 64.0f;
|
||||
objvarname = "quest." + parameter + ".parameter";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
radius = getFloatObjVar(self, objvarname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - OnQuestActivated() - could not determine escort target location!");
|
||||
}
|
||||
}
|
||||
if (locationName != null && locationName.length() > 0)
|
||||
{
|
||||
objvarname = questName + ".task_questname";
|
||||
setObjVar(self, objvarname, questName);
|
||||
}
|
||||
if (npcDestination != null)
|
||||
{
|
||||
objvarname = "quest." + questName + ".npc_destination";
|
||||
setObjVar(self, objvarname, npcDestination);
|
||||
addLocationTarget(questName, npcDestination, radius);
|
||||
}
|
||||
objvarname = "quest." + questName + ".escort_target";
|
||||
setObjVar(self, objvarname, target);
|
||||
setMaster(target, self);
|
||||
ai_lib.aiFollow(target, self, 1.0f, 8.0f);
|
||||
attachScript(target, "quest.utility.destroy_notification");
|
||||
attachScript(target, "quest.utility.escort_npc");
|
||||
dictionary params = new dictionary();
|
||||
params.put("target", self);
|
||||
params.put("parameter", questName);
|
||||
messageTo(target, "addNotification", params, 0.0f, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public obj_id getEscortTarget(obj_id self, String questName) throws InterruptedException
|
||||
{
|
||||
obj_id result = null;
|
||||
String objvarname = "quest." + questName + ".escort_target";
|
||||
LOG("newquests", "escort - getEscortTarget(" + self + ", " + questName + ")");
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
result = getObjIdObjVar(self, objvarname);
|
||||
LOG("newquests", "escort - getEscortTarget - " + objvarname + "=" + result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public boolean isEscortNearby(obj_id self, String questName) throws InterruptedException
|
||||
{
|
||||
boolean result = false;
|
||||
obj_id escortTarget = getEscortTarget(self, questName);
|
||||
if (isIdValid(escortTarget))
|
||||
{
|
||||
location escortLocation = getLocation(escortTarget);
|
||||
location myLocation = getLocation(self);
|
||||
float distance = myLocation.distance(escortLocation);
|
||||
LOG("newquests", "escort - isEscortNearby - distance between player and target is " + distance);
|
||||
if (distance > 0.0f && distance < 128.0f)
|
||||
{
|
||||
result = true;
|
||||
LOG("newquests", "escort - isEscortNearby - the escort target is in range");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - isEscortNearby - the escort target is not in range");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - isEscortNearby - escortTarget(" + escortTarget + ") is invalid");
|
||||
}
|
||||
LOG("newquests", "escort - isEscortNearby - returning " + result);
|
||||
return result;
|
||||
}
|
||||
public int OnArrivedAtLocation(obj_id self, String locationName) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "escort - OnArrivedAtLocation(" + locationName + ")");
|
||||
String objvarname = locationName + ".task_questname";
|
||||
if (hasObjVar(self, objvarname))
|
||||
{
|
||||
String questName = getStringObjVar(self, objvarname);
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
LOG("newquests", "escort - OnArrivedAtLocation - arrived at a location specific to this task");
|
||||
obj_id target = getEscortTarget(self, questName);
|
||||
ai_lib.aiStopFollowing(target);
|
||||
setMaster(target, null);
|
||||
messageTo(target, "handleTaskDestroyOnArrival", null, 60.0f, false);
|
||||
messageTo(target, "handleTaskArrived", null, 1.0f, false);
|
||||
objvarname = "quest." + questName + ".npc_destination";
|
||||
location l = getLocationObjVar(self, objvarname);
|
||||
if (l != null)
|
||||
{
|
||||
ai_lib.aiPathTo(target, l);
|
||||
}
|
||||
quests.complete(locationName, self, isEscortNearby(self, questName));
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int destroyNotification(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification()");
|
||||
if (params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
LOG("newquests", "escort - destroyNotification() - source=" + source);
|
||||
if (source != null && isIdValid(source))
|
||||
{
|
||||
String parameter = params.getString("parameter");
|
||||
LOG("newquests", "escort - destroyNotification() - parameter=" + parameter);
|
||||
if (parameter != null && parameter.length() > 0)
|
||||
{
|
||||
if (quests.isMyQuest(quests.getQuestId(parameter), "quest.task.escort"))
|
||||
{
|
||||
if (quests.isActive(parameter, self))
|
||||
{
|
||||
quests.complete(parameter, self, false);
|
||||
LOG("newquests", "escort - destroyNotification() - failing task");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification() - quest no longer active");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification() - notification isn't for me");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification() - parameter unavailable");
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
include library.ai_lib;
|
||||
include library.quests;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
if(quests.isMyQuest(questRow, "quest.task.escort"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
LOG("newquests", "escort - OnQuestActivated() - initializing escort task " + questName);
|
||||
|
||||
// determine the object id of the target to be escorted
|
||||
String objvarname = "quest." + questName + ".target";
|
||||
obj_id target = null;
|
||||
float radius = 32.0f;
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
// target id is overridden by script
|
||||
target = getObjIdObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
// target id is the result of an encounter as identified in quests.tab
|
||||
String targetName = quests.getDataEntry(questRow, "TARGET");
|
||||
target = quests.getTargetForQuest(self, targetName);
|
||||
}
|
||||
|
||||
if(target != null)
|
||||
{
|
||||
// determine location name that will be passed to OnArrivedAtLocation
|
||||
String locationName = null;
|
||||
location npcDestination = null;
|
||||
|
||||
// where does the target need to be escorted to?
|
||||
objvarname = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
// parameter is overridden by script as a location
|
||||
// object variable
|
||||
npcDestination = getLocationObjVar(self, objvarname);
|
||||
addLocationTarget(questName, npcDestination, radius);
|
||||
locationName = questName;
|
||||
}
|
||||
else
|
||||
{
|
||||
String parameter = quests.getDataEntry(questRow, "PARAMETER");
|
||||
if(parameter != null && parameter.length() > 0)
|
||||
{
|
||||
// activate the target task
|
||||
quests.activate(parameter, self, quests.getQuestGiver(questRow, self));
|
||||
|
||||
// save the quest name to catch OnArrivedAtLocation
|
||||
// to complete the escort task
|
||||
locationName = parameter;
|
||||
objvarname = "quest." + parameter + ".selected_location";
|
||||
npcDestination = getLocationObjVar(self, objvarname);
|
||||
|
||||
radius = 64.0f;
|
||||
objvarname = "quest." + parameter + ".parameter";
|
||||
if(hasObjVar(self, objvarname))
|
||||
radius = getFloatObjVar(self, objvarname);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - OnQuestActivated() - could not determine escort target location!");
|
||||
}
|
||||
}
|
||||
|
||||
if(locationName != null && locationName.length() > 0)
|
||||
{
|
||||
objvarname = questName + ".task_questname";
|
||||
setObjVar(self, objvarname, questName);
|
||||
}
|
||||
|
||||
if(npcDestination != null)
|
||||
{
|
||||
objvarname = "quest." + questName + ".npc_destination";
|
||||
setObjVar(self, objvarname, npcDestination);
|
||||
addLocationTarget(questName, npcDestination, radius);
|
||||
}
|
||||
|
||||
objvarname = "quest." + questName + ".escort_target";
|
||||
setObjVar(self, objvarname, target);
|
||||
|
||||
setMaster(target, self);
|
||||
ai_lib.aiFollow(target, self, 1.0f, 8.0f);
|
||||
attachScript(target, "quest.utility.destroy_notification");
|
||||
attachScript(target, "quest.utility.escort_npc");
|
||||
dictionary params = new dictionary();
|
||||
params.put("target", self);
|
||||
params.put("parameter", questName);
|
||||
messageTo(target, "addNotification", params, 0.0f, false);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id getEscortTarget(obj_id self, String questName)
|
||||
{
|
||||
obj_id result = null;
|
||||
String objvarname = "quest." + questName + ".escort_target";
|
||||
LOG("newquests", "escort - getEscortTarget(" + self + ", " + questName + ")");
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
result = getObjIdObjVar(self, objvarname);
|
||||
LOG("newquests", "escort - getEscortTarget - " + objvarname + "=" + result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
boolean isEscortNearby(obj_id self, String questName)
|
||||
{
|
||||
boolean result = false;
|
||||
obj_id escortTarget = getEscortTarget(self, questName);
|
||||
|
||||
if(isIdValid(escortTarget))
|
||||
{
|
||||
location escortLocation = getLocation(escortTarget);
|
||||
location myLocation = getLocation(self);
|
||||
float distance = myLocation.distance(escortLocation);
|
||||
LOG("newquests", "escort - isEscortNearby - distance between player and target is " + distance);
|
||||
if(distance > 0.0f && distance < 128.0f)
|
||||
{
|
||||
result = true;
|
||||
LOG("newquests", "escort - isEscortNearby - the escort target is in range");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - isEscortNearby - the escort target is not in range");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - isEscortNearby - escortTarget(" + escortTarget + ") is invalid");
|
||||
}
|
||||
|
||||
LOG("newquests", "escort - isEscortNearby - returning " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
trigger OnArrivedAtLocation(string locationName)
|
||||
{
|
||||
LOG("newquests", "escort - OnArrivedAtLocation(" + locationName + ")");
|
||||
|
||||
String objvarname = locationName + ".task_questname";
|
||||
if(hasObjVar(self, objvarname))
|
||||
{
|
||||
// arrived at custom target location specified by
|
||||
// quest.<locationName>.parameter
|
||||
|
||||
// map it to an escort quest
|
||||
String questName = getStringObjVar(self, objvarname);
|
||||
if(questName != null && questName.length() > 0)
|
||||
{
|
||||
LOG("newquests", "escort - OnArrivedAtLocation - arrived at a location specific to this task");
|
||||
|
||||
obj_id target = getEscortTarget(self, questName);
|
||||
ai_lib.aiStopFollowing(target);
|
||||
setMaster(target, null);
|
||||
|
||||
// if the npc is to be destroyed a short while after arriving at this location,
|
||||
// attach a script that includes a handler for the following message
|
||||
messageTo(target, "handleTaskDestroyOnArrival", null, 60.0f, false);
|
||||
messageTo(target, "handleTaskArrived", null, 1.0f, false);
|
||||
|
||||
objvarname = "quest." + questName + ".npc_destination";
|
||||
location l = getLocationObjVar(self, objvarname);
|
||||
if(l != null)
|
||||
{
|
||||
ai_lib.aiPathTo(target, l);
|
||||
}
|
||||
// complete the task
|
||||
quests.complete(locationName, self, isEscortNearby(self, questName));
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler destroyNotification()
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification()");
|
||||
if(params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
LOG("newquests", "escort - destroyNotification() - source=" + source);
|
||||
if(source != null && isIdValid(source))
|
||||
{
|
||||
String parameter = params.getString("parameter");
|
||||
LOG("newquests", "escort - destroyNotification() - parameter=" + parameter);
|
||||
if(parameter != null && parameter.length() > 0)
|
||||
{
|
||||
if(quests.isMyQuest(quests.getQuestId(parameter), "quest.task.escort"))
|
||||
{
|
||||
if(quests.isActive(parameter, self))
|
||||
{
|
||||
quests.complete(parameter, self, false);
|
||||
LOG("newquests", "escort - destroyNotification() - failing task");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification() - quest no longer active");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification() - notification isn't for me");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "escort - destroyNotification() - parameter unavailable");
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class find_location extends script.base_script
|
||||
{
|
||||
public find_location()
|
||||
{
|
||||
}
|
||||
public int OnLogin(obj_id self) throws InterruptedException
|
||||
{
|
||||
int rows = dataTableGetNumRows("datatables/player/quests.iff");
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < rows; ++iter)
|
||||
{
|
||||
if (isQuestActive(self, iter))
|
||||
{
|
||||
if (quests.isMyQuest(iter, "quest.task.find_location"))
|
||||
{
|
||||
String questName = quests.getDataEntry(iter, "NAME");
|
||||
if (hasObjVar(self, "quest." + questName + ".generate"))
|
||||
{
|
||||
removeObjVar(self, "quest." + questName + ".generate");
|
||||
location loc = quests.getLocationTarget(self, iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "find_location - OnQuestActivated(" + questRow + ")");
|
||||
if (quests.isMyQuest(questRow, "quest.task.find_location"))
|
||||
{
|
||||
LOG("newquests", "OnQuestActivated for find_location");
|
||||
quests.getLocationTarget(self, questRow);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnArrivedAtLocation(obj_id self, String locationName) throws InterruptedException
|
||||
{
|
||||
int questId = quests.getQuestId(locationName);
|
||||
if (questId > -1)
|
||||
{
|
||||
if (quests.isMyQuest(questId, "quest.task.find_location"))
|
||||
{
|
||||
if (quests.isActive(locationName, self))
|
||||
{
|
||||
LOG("newquests", "find_location arrived at " + locationName);
|
||||
quests.complete(locationName, self, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class find_theater extends script.base_script
|
||||
{
|
||||
public find_theater()
|
||||
{
|
||||
}
|
||||
public void completeTask(obj_id self, String questName, boolean succeeded) throws InterruptedException
|
||||
{
|
||||
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);
|
||||
}
|
||||
public void setupTheater(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
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 == (1606908893))
|
||||
{
|
||||
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());
|
||||
}
|
||||
addLocationTarget(questName, theaterLoc, 32.0f);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setupWaypoint(obj_id self, int questRow, location loc) throws InterruptedException
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
public int OnLogin(obj_id self) throws InterruptedException
|
||||
{
|
||||
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;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.find_theater"))
|
||||
{
|
||||
setupTheater(self, questRow);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnArrivedAtLocation(obj_id self, String locationName) throws InterruptedException
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package script.quest.task.fs_quest_cs;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.fs_counterstrike;
|
||||
|
||||
public class ensure_capture extends script.base_script
|
||||
{
|
||||
public ensure_capture()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
sendSystemMessage(self, new string_id("fs_quest_village", "fs_cs_ensure_detail"));
|
||||
if (!hasObjVar(self, fs_counterstrike.OBJVAR_MY_CAMP_ID))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id camp = getObjIdObjVar(self, fs_counterstrike.OBJVAR_MY_CAMP_ID);
|
||||
fs_counterstrike.createCommander(camp);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
include library.fs_counterstrike;
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
sendSystemMessage(self, new string_id("fs_quest_village", "fs_cs_ensure_detail"));
|
||||
|
||||
if(!hasObjVar(self, fs_counterstrike.OBJVAR_MY_CAMP_ID))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id camp = getObjIdObjVar(self, fs_counterstrike.OBJVAR_MY_CAMP_ID);
|
||||
fs_counterstrike.createCommander(camp);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package script.quest.task.fs_quest_cs;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
import script.library.fs_counterstrike;
|
||||
import script.library.xp;
|
||||
|
||||
public class fs_cs_kill5_guards extends script.base_script
|
||||
{
|
||||
public fs_cs_kill5_guards()
|
||||
{
|
||||
}
|
||||
public int receiveCreditForKill(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "fs_cs_kill5_guards: receiveCreditForKill()");
|
||||
if (params != null)
|
||||
{
|
||||
location creatureLoc = params.getLocation("location");
|
||||
if (getDistance(getLocation(self), creatureLoc) > xp.MAX_DISTANCE)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id target = params.getObjId("target");
|
||||
if (isIdValid(target))
|
||||
{
|
||||
final String targetType = params.getString("creatureName");
|
||||
if (targetType != null && targetType.length() > 0)
|
||||
{
|
||||
String objvarName = "quest.destroy_multi." + targetType;
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
if (!hasObjVar(self, "fs_cs.currentCamp"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id myCamp = getObjIdObjVar(self, "fs_cs.currentCamp");
|
||||
if (!isIdValid(myCamp) || !exists(myCamp))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id spawner = params.getObjId("spawnedBy");
|
||||
if (!isIdValid(spawner))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!hasObjVar(spawner, "quest_spawner.parent"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id spawnersCamp = getObjIdObjVar(spawner, "quest_spawner.parent");
|
||||
if (!isIdValid(spawnersCamp) || !exists(spawnersCamp))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (myCamp != spawnersCamp)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
if (questNames != null && questNames.length > 0)
|
||||
{
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
String questName = questNames[iter];
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
int killsRemaining = getIntObjVar(self, objvarName);
|
||||
killsRemaining--;
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: kills remaining = " + killsRemaining);
|
||||
if (killsRemaining < 1)
|
||||
{
|
||||
String[] newQuestNames = new String[questNames.length - 1];
|
||||
int ni = 0;
|
||||
int index = 0;
|
||||
for (ni = 0; ni < questNames.length; ++ni)
|
||||
{
|
||||
if (ni != iter)
|
||||
{
|
||||
newQuestNames[index] = questNames[ni];
|
||||
++index;
|
||||
}
|
||||
}
|
||||
if (newQuestNames.length < 1)
|
||||
{
|
||||
objvarName = "quest.destroy_multi." + targetType;
|
||||
removeObjVar(self, objvarName);
|
||||
}
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
setObjVar(self, objvarName, killsRemaining);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: questNames objvar \"" + objvarName + "\" string array is empty");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not retrieve objvar " + objvarName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not determine target type name from target creature");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: invalid target specified in messageTo parameters");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.destroy_multi"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
LOG("newquests", "OnQuestActivated(" + questName + ")");
|
||||
String target = null;
|
||||
String objvarName = "quest." + questName + ".target";
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
target = getStringObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
int killCount = 0;
|
||||
if (target != null && target.length() > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, target);
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, objvarName))
|
||||
{
|
||||
killCount = getIntObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
String countName = quests.getDataEntry(questRow, "PARAMETER");
|
||||
if (countName != null && countName.length() > 0)
|
||||
{
|
||||
killCount = utils.stringToInt(countName);
|
||||
}
|
||||
}
|
||||
if (killCount > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, killCount);
|
||||
objvarName = "quest.destroy_multi." + target;
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
String[] newQuestNames = null;
|
||||
if (questNames == null)
|
||||
{
|
||||
newQuestNames = new String[1];
|
||||
newQuestNames[0] = questName;
|
||||
}
|
||||
else
|
||||
{
|
||||
newQuestNames = new String[questNames.length + 1];
|
||||
int iter = 0;
|
||||
for (iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
newQuestNames[iter] = questNames[iter];
|
||||
}
|
||||
newQuestNames[questNames.length] = questName;
|
||||
}
|
||||
if (newQuestNames != null && newQuestNames.length > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, newQuestNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: Could not set questnames string array objvar");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine kill count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine target creature type");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-217
@@ -1,217 +0,0 @@
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
include library.fs_counterstrike;
|
||||
include library.xp;
|
||||
|
||||
messageHandler receiveCreditForKill()
|
||||
{
|
||||
LOG("newquests", "fs_cs_kill5_guards: receiveCreditForKill()");
|
||||
if(params != null)
|
||||
{
|
||||
location creatureLoc = params.getLocation("location");
|
||||
if ( getDistance( getLocation(self), creatureLoc ) > xp.MAX_DISTANCE )
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
obj_id target = params.getObjId("target");
|
||||
if(isIdValid(target))
|
||||
{
|
||||
const String targetType = params.getString( "creatureName" );
|
||||
if(targetType != null && targetType.length() > 0)
|
||||
{
|
||||
String objvarName = "quest.destroy_multi." + targetType;
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
// check to make sure this is a kill from a camp that we powered down
|
||||
// get the camp id off of ourselves
|
||||
if(!hasObjVar(self, "fs_cs.currentCamp"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id myCamp = getObjIdObjVar(self, "fs_cs.currentCamp");
|
||||
if(!isIdValid(myCamp) || !exists(myCamp))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id spawner = params.getObjId("spawnedBy" );
|
||||
if(!isIdValid(spawner))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// get the spawner's creator
|
||||
if(!hasObjVar(spawner, "quest_spawner.parent"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id spawnersCamp = getObjIdObjVar(spawner, "quest_spawner.parent");
|
||||
if(!isIdValid(spawnersCamp) || !exists(spawnersCamp))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// check to make sure that the spawner's camp is the same as the players current camp
|
||||
if(myCamp != spawnersCamp)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
if(questNames != null && questNames.length > 0)
|
||||
{
|
||||
int iter = 0;
|
||||
for(iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
String questName = questNames[iter];
|
||||
if(quests.isActive(questName, self))
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
int killsRemaining = getIntObjVar(self, objvarName);
|
||||
killsRemaining--;
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: kills remaining = " + killsRemaining);
|
||||
if(killsRemaining < 1)
|
||||
{
|
||||
// remove the target from the questNames
|
||||
String[] newQuestNames = new String[questNames.length - 1];
|
||||
int ni = 0;
|
||||
int index = 0;
|
||||
for(ni = 0; ni < questNames.length; ++ ni)
|
||||
{
|
||||
if(ni != iter)
|
||||
{
|
||||
newQuestNames[index] = questNames[ni];
|
||||
++index;
|
||||
}
|
||||
}
|
||||
if(newQuestNames.length < 1)
|
||||
{
|
||||
objvarName = "quest.destroy_multi." + targetType;
|
||||
removeObjVar(self, objvarName);
|
||||
// if questNames is empty, remove the objvar
|
||||
|
||||
}
|
||||
|
||||
// complete the quest
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
setObjVar(self, objvarName, killsRemaining);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: questNames objvar \"" + objvarName + "\" string array is empty");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not retrieve objvar " + objvarName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: could not determine target type name from target creature");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: onReceiveCreditForKill: invalid target specified in messageTo parameters");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
if(quests.isMyQuest(questRow, "quest.task.destroy_multi"))
|
||||
{
|
||||
// get target creature type
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
LOG("newquests", "OnQuestActivated(" + questName + ")");
|
||||
String target = null;
|
||||
String objvarName = "quest." + questName + ".target";
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
target = getStringObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
|
||||
int killCount = 0;
|
||||
|
||||
if(target != null && target.length() > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, target);
|
||||
// retrieve the count
|
||||
objvarName = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, objvarName))
|
||||
{
|
||||
killCount = getIntObjVar(self, objvarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
String countName = quests.getDataEntry(questRow, "PARAMETER");
|
||||
if(countName != null && countName.length() > 0)
|
||||
{
|
||||
killCount = utils.stringToInt(countName);
|
||||
}
|
||||
}
|
||||
|
||||
if(killCount > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, killCount);
|
||||
objvarName = "quest.destroy_multi." + target;
|
||||
|
||||
String[] questNames = getStringArrayObjVar(self, objvarName);
|
||||
String[] newQuestNames = null;
|
||||
if(questNames == null)
|
||||
{
|
||||
newQuestNames = new String[1];
|
||||
newQuestNames[0] = questName;
|
||||
}
|
||||
else
|
||||
{
|
||||
newQuestNames = new String[questNames.length + 1];
|
||||
|
||||
int iter = 0;
|
||||
for(iter = 0; iter < questNames.length; ++iter)
|
||||
{
|
||||
newQuestNames[iter] = questNames[iter];
|
||||
}
|
||||
|
||||
newQuestNames[questNames.length] = questName;
|
||||
}
|
||||
|
||||
if(newQuestNames != null && newQuestNames.length > 0)
|
||||
{
|
||||
setObjVar(self, objvarName, newQuestNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: Could not set questnames string array objvar");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine kill count");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "destroy_multi: OnQuestActivated: could not determine target creature type");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package script.quest.task.fs_quest_cs;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.jedi;
|
||||
import script.library.utils;
|
||||
import script.library.trace;
|
||||
import script.library.quests;
|
||||
import script.library.fs_counterstrike;
|
||||
|
||||
public class quest_done extends script.base_script
|
||||
{
|
||||
public quest_done()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (!quests.isMyQuest(questRow, "quest.task.fs_quest_cs.quest_done"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!hasObjVar(self, "fs_cs.myCapturedCommander"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id commander = getObjIdObjVar(self, "fs_cs.myCapturedCommander");
|
||||
if (!isIdValid(commander) || !exists(commander))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!hasObjVar(commander, "fs_cs.primaryEscort"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id primary = getObjIdObjVar(commander, "fs_cs.primaryEscort");
|
||||
if (!isIdValid(primary) || !exists(primary))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
boolean teamComplete = false;
|
||||
obj_id shieldKiller = null;
|
||||
if (hasObjVar(commander, fs_counterstrike.OBJVAR_CAMP_SHIELD_KILLER))
|
||||
{
|
||||
shieldKiller = getObjIdObjVar(commander, fs_counterstrike.OBJVAR_CAMP_SHIELD_KILLER);
|
||||
if (shieldKiller != primary)
|
||||
{
|
||||
teamComplete = true;
|
||||
}
|
||||
}
|
||||
destroyObject(commander);
|
||||
dictionary d = new dictionary();
|
||||
d.put("teamComplete", teamComplete);
|
||||
messageTo(primary, "msgQuestComplete", d, 0.0f, true);
|
||||
if (shieldKiller != primary)
|
||||
{
|
||||
messageTo(shieldKiller, "msgQuestComplete", d, 0.0f, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (quests.isActive("fs_cs_quest_done", self))
|
||||
{
|
||||
quests.complete("fs_cs_quest_done", self, true);
|
||||
}
|
||||
detachScript(self, "quest.task.fs_quest_cs.quest_done");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// runs when the primary escort returns the camp commander to the village.
|
||||
include library.jedi;
|
||||
include library.utils;
|
||||
include library.trace;
|
||||
include library.quests;
|
||||
include library.fs_counterstrike;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
if(! quests.isMyQuest(questRow, "quest.task.fs_quest_cs.quest_done"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if(!hasObjVar(self, "fs_cs.myCapturedCommander"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id commander = getObjIdObjVar(self, "fs_cs.myCapturedCommander");
|
||||
if(!isIdValid(commander) || !exists(commander))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!hasObjVar(commander, "fs_cs.primaryEscort"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id primary = getObjIdObjVar(commander, "fs_cs.primaryEscort");
|
||||
if(!isIdValid(primary) || !exists(primary))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
boolean teamComplete = false;
|
||||
obj_id shieldKiller = null;
|
||||
if(hasObjVar(commander, fs_counterstrike.OBJVAR_CAMP_SHIELD_KILLER))
|
||||
{
|
||||
shieldKiller = getObjIdObjVar(commander, fs_counterstrike.OBJVAR_CAMP_SHIELD_KILLER);
|
||||
if(shieldKiller != primary)
|
||||
{
|
||||
teamComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
destroyObject(commander);
|
||||
|
||||
dictionary d = new dictionary();
|
||||
d.put("teamComplete", teamComplete);
|
||||
|
||||
messageTo(primary, "msgQuestComplete", d, 0.0f, true);
|
||||
if(shieldKiller != primary)
|
||||
{
|
||||
messageTo(shieldKiller, "msgQuestComplete", d, 0.0f, true);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
if(quests.isActive("fs_cs_quest_done", self))
|
||||
{
|
||||
quests.complete("fs_cs_quest_done", self, true);
|
||||
}
|
||||
|
||||
detachScript(self, "quest.task.fs_quest_cs.quest_done");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package script.quest.task.fs_quest_cs;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.quests;
|
||||
import script.library.fs_counterstrike;
|
||||
|
||||
public class quest_failed_escort extends script.base_script
|
||||
{
|
||||
public quest_failed_escort()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (!quests.isMyQuest(questRow, "quest.task.fs_quest_cs.quest_failed_escort"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (quests.isActive("fs_cs_escort_commander_pri", self))
|
||||
{
|
||||
if (hasObjVar(self, "fs_cs.myCapturedCommander"))
|
||||
{
|
||||
obj_id commander = getObjIdObjVar(self, "fs_cs.myCapturedCommander");
|
||||
if (isIdValid(commander) && exists(commander))
|
||||
{
|
||||
messageTo(commander, "msgPrimaryEscortAbandoned", null, 0.0f, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
fs_counterstrike.resetPlayerToStart(self, null);
|
||||
sendSystemMessage(self, new string_id("fs_quest_village", "arrived_without_commander"));
|
||||
detachScript(self, "quest.task.fs_quest_cs.quest_failed_escort");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
detachScript(self, "quest.task.fs_quest_cs.quest_failed_escort");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
// task escort failure
|
||||
include library.quests;
|
||||
include library.fs_counterstrike;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
if(! quests.isMyQuest(questRow, "quest.task.fs_quest_cs.quest_failed_escort"))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if(quests.isActive("fs_cs_escort_commander_pri", self))
|
||||
{
|
||||
if(hasObjVar(self, "fs_cs.myCapturedCommander"))
|
||||
{
|
||||
obj_id commander = getObjIdObjVar(self, "fs_cs.myCapturedCommander");
|
||||
if(isIdValid(commander) && exists(commander))
|
||||
{
|
||||
messageTo(commander, "msgPrimaryEscortAbandoned", null, 0.0f, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs_counterstrike.resetPlayerToStart(self, null);
|
||||
sendSystemMessage(self, new string_id("fs_quest_village", "arrived_without_commander"));
|
||||
detachScript(self, "quest.task.fs_quest_cs.quest_failed_escort");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
detachScript(self, "quest.task.fs_quest_cs.quest_failed_escort");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package script.quest.task.fs_quest_sad;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.fs_dyn_village;
|
||||
import script.library.create;
|
||||
import script.library.geiger;
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.theater;
|
||||
import script.library.utils;
|
||||
import script.library.fs_quests_sad;
|
||||
|
||||
public class basic_task extends script.base_script
|
||||
{
|
||||
public basic_task()
|
||||
{
|
||||
}
|
||||
public static final String FS_QUEST_SAD_QUANTITY_KILLABLE = "fs_quest_sad.quantity_killable";
|
||||
public static final String FS_QUEST_SAD_THEATER_LOCATION = "fs_quest_sad.theater_location";
|
||||
public static final location FS_VILLAGE_LOCATION = new location(5238.26f, 78.5f, -4189.03f);
|
||||
public void completeTask(obj_id self, String questName, boolean succeeded) throws InterruptedException
|
||||
{
|
||||
int killable = getIntObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
killable = 0;
|
||||
setObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE, killable);
|
||||
geiger.clearGeiger(self);
|
||||
if (hasObjVar(self, "quest." + questName))
|
||||
{
|
||||
obj_id waypoint = getObjIdObjVar(self, "quest." + questName + ".waypoint");
|
||||
if (isIdValid(waypoint))
|
||||
{
|
||||
destroyWaypointInDatapad(waypoint, self);
|
||||
}
|
||||
}
|
||||
if (hasTheaterAssigned(self))
|
||||
{
|
||||
unassignTheaterFromPlayer(self);
|
||||
}
|
||||
if (utils.hasObjVar(self, fs_quests_sad.SAD_OBJVAR_MASTER_THEATER))
|
||||
{
|
||||
obj_id theater = utils.getObjIdObjVar(self, fs_quests_sad.SAD_OBJVAR_MASTER_THEATER);
|
||||
messageTo(theater, "destroySelf", null, 90.0f, false);
|
||||
}
|
||||
fs_quests_sad.recordTaskSuccess(self);
|
||||
LOG("newquests", "fs_quest_sad.basic_task - completing");
|
||||
quests.complete(questName, self, succeeded);
|
||||
}
|
||||
public void setupTheater(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.fs_quest_sad.basic_task"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
if (questName == null || questName.equals("") || !quests.isActive(questName, self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
String target = null;
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
if (target == null || target.equals(""))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - no target");
|
||||
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('/') <= 0) || (tokens[0].indexOf('\\') <= 0))
|
||||
{
|
||||
datatable = tokens[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
datatable = tokens[1];
|
||||
}
|
||||
}
|
||||
location theaterLoc = null;
|
||||
boolean hasLocInfo = false;
|
||||
boolean created = false;
|
||||
String parameterString = quests.getDataEntry(questRow, "PARAMETER");
|
||||
float radius = 0.0f;
|
||||
if (parameterString != null && !parameterString.equals(""))
|
||||
{
|
||||
radius = utils.stringToFloat(parameterString);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "row has no PARAMETER field");
|
||||
radius = 1.0f;
|
||||
}
|
||||
int attempts = 0;
|
||||
float positiveRadius = (radius > 0.0f ? radius : -radius);
|
||||
float extension = 0.0f;
|
||||
while (theaterLoc == null && attempts < 150)
|
||||
{
|
||||
extension += 50.0f;
|
||||
++attempts;
|
||||
theaterLoc = locations.getRandomGoodLocation(getLocation(self), positiveRadius - 200.0f, positiveRadius + 200.0f + extension, 32.0f);
|
||||
}
|
||||
if (theaterLoc != null)
|
||||
{
|
||||
LOG("newquests", "basic_task assigning theater to player");
|
||||
unassignTheaterFromPlayer(self);
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.fs_quests_sad.theater_controller", TLT_none);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "getTheaterLocationTarget failed to return a location, marking the player as a big winner");
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
if (created)
|
||||
{
|
||||
if (radius >= 0.0f)
|
||||
{
|
||||
setupWaypoint(self, questRow, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
setupGeiger(self, questRow, theaterLoc);
|
||||
}
|
||||
utils.setScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
setupTheater(self, questRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setupGeiger(obj_id self, int questRow, location loc) throws InterruptedException
|
||||
{
|
||||
sendSystemMessage(self, "Target Moved -- Radiation Sensor Updated", null);
|
||||
if (loc != null)
|
||||
{
|
||||
geiger.setGeiger(self, loc);
|
||||
}
|
||||
}
|
||||
public void setupWaypoint(obj_id self, int questRow, location loc) throws InterruptedException
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
String waypointObjVar = "quest." + questName + ".waypoint";
|
||||
sendSystemMessage(self, "Waypoint Updated", null);
|
||||
if (hasObjVar(self, waypointObjVar))
|
||||
{
|
||||
obj_id point = getObjIdObjVar(self, waypointObjVar);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar(self, waypointObjVar);
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
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, waypointObjVar, wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
public int theaterFailed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "inside theaterFailed");
|
||||
if (params == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String name = params.getString("name");
|
||||
String paramDatatable = params.getString("datatable");
|
||||
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.fs_quest_sad.basic_task"))
|
||||
{
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
String target = null;
|
||||
target = quests.getDataEntry(iter, "TARGET");
|
||||
if (target == null || target.equals(""))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - no target");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String[] tokens = split(target, ':');
|
||||
String datatable = null;
|
||||
datatable = tokens[0];
|
||||
LOG("newquests", "fs_quest_sad.basic_task - quest is active");
|
||||
LOG("newquests", "fs_quest_sad.basic_task, datatable, paramDatatable = '" + datatable + "' , '" + paramDatatable + "'");
|
||||
unassignTheaterFromPlayer(self);
|
||||
location theaterLoc = null;
|
||||
boolean needUpdate = true;
|
||||
if (utils.hasScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION))
|
||||
{
|
||||
theaterLoc = utils.getLocationScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION);
|
||||
needUpdate = false;
|
||||
utils.removeScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION);
|
||||
}
|
||||
if (theaterLoc == null)
|
||||
{
|
||||
float distanceToVillage = (getLocation(self)).distance(FS_VILLAGE_LOCATION);
|
||||
int attempts = 0;
|
||||
float searchDelta = 0;
|
||||
while ((theaterLoc == null) && (attempts < 32))
|
||||
{
|
||||
LOG("newquests", "theater is null, generating random good location");
|
||||
theaterLoc = locations.getRandomGoodLocation(getLocation(self), 92.0f + searchDelta, 160.0f + searchDelta, 32.0f);
|
||||
if (theaterLoc != null)
|
||||
{
|
||||
float newDistance = theaterLoc.distance(FS_VILLAGE_LOCATION);
|
||||
if (newDistance < distanceToVillage)
|
||||
{
|
||||
theaterLoc = null;
|
||||
}
|
||||
else if (!theater.canSpawnTheaterAtLocation(theaterLoc))
|
||||
{
|
||||
theaterLoc = null;
|
||||
searchDelta += 256.0f;
|
||||
}
|
||||
}
|
||||
attempts++;
|
||||
}
|
||||
}
|
||||
if (theaterLoc == null)
|
||||
{
|
||||
float distanceToVillage = (getLocation(self)).distance(FS_VILLAGE_LOCATION);
|
||||
LOG("newquests", "OnPlayerTheaterFail tried to getRandomGoodLocation and failed, moving directly away");
|
||||
theaterLoc = locations.moveLocationTowardsLocation(FS_VILLAGE_LOCATION, getLocation(self), distanceToVillage + 256.0f);
|
||||
}
|
||||
boolean created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.fs_quests_sad.theater_controller", TLT_flatten);
|
||||
if (needUpdate)
|
||||
{
|
||||
if (utils.hasObjVar(self, geiger.OBJVAR_GEIGER_LOCATION))
|
||||
{
|
||||
LOG("newquests", "updating geiger");
|
||||
setupGeiger(self, iter, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "updating waypoint");
|
||||
setupWaypoint(self, iter, theaterLoc);
|
||||
}
|
||||
}
|
||||
if (created)
|
||||
{
|
||||
LOG("newquests", "OnPlayerTheaterFail created the flattened theater at " + theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "OnPlayerTheaterFail couldn't create the flatten theater");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnPlayerTheaterFail(obj_id self, String datatable, String name) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnPlayerTheaterFail");
|
||||
dictionary params = new dictionary();
|
||||
params.put("datatable", datatable);
|
||||
params.put("name", name);
|
||||
messageTo(self, "theaterFailed", params, 8.0f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogin(obj_id self) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnLogin");
|
||||
checkForPhaseChange(self);
|
||||
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.fs_quest_sad.basic_task"))
|
||||
{
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - quest is active");
|
||||
if (hasObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - removing objvar");
|
||||
removeObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
}
|
||||
if (hasObjVar(self, "quest." + questName + ".generate"))
|
||||
{
|
||||
removeObjVar(self, "quest." + questName + ".generate");
|
||||
}
|
||||
LOG("newquests", "fs_quest_sad.basic_task - setting up theater");
|
||||
setupTheater(self, iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnQuestActivated(+ " + questRow + ")");
|
||||
if (quests.isMyQuest(questRow, "quest.task.fs_quest_sad.basic_task"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
boolean success = true;
|
||||
setupTheater(self, questRow);
|
||||
fs_quests_sad.recordTookTask(self);
|
||||
LOG("newquests", "fs_quest_sad.basic_task - success = " + success);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnCreatedKillableObject(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnCreatedKillableObject");
|
||||
int quantityKillable = utils.getIntObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
quantityKillable++;
|
||||
utils.setObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE, quantityKillable);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnIncapacitatedKillableObject(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnIncapacitatedKillableObject");
|
||||
int quantityKillable = utils.getIntObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
quantityKillable--;
|
||||
if (quantityKillable < 0)
|
||||
{
|
||||
quantityKillable = 0;
|
||||
}
|
||||
utils.setObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE, quantityKillable);
|
||||
if (quantityKillable <= 1)
|
||||
{
|
||||
quantityKillable = 0;
|
||||
setObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE, quantityKillable);
|
||||
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.fs_quest_sad.basic_task"))
|
||||
{
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
completeTask(self, questName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void checkForPhaseChange(obj_id self) throws InterruptedException
|
||||
{
|
||||
fs_dyn_village.getRegisteredIntegerFromClusterWideData(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID, "findCurrentPhase", self);
|
||||
return;
|
||||
}
|
||||
public int findCurrentPhase(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!params.containsKey(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID))
|
||||
{
|
||||
LOG(fs_dyn_village.LOG_CHAN, "fs_quest_player::msgValidateFSQuestPhase: -> Error getting current phase from cluster data. Potentially on wrong quest phase.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int curUid = params.getInt(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID);
|
||||
int curPhase = fs_dyn_village.getPhaseFromVersionUid(curUid);
|
||||
String wpName = "waypoint";
|
||||
setObjVar(self, "current_phase", curPhase);
|
||||
int phase = getIntObjVar(self, "current_phase");
|
||||
String returnQuests = "fs_quests_sad_return_1";
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
if (quests.isActive("fs_quests_sad_return_" + i, self))
|
||||
{
|
||||
returnQuests = "fs_quests_sad_return_" + i;
|
||||
wpName = "quest." + returnQuests + ".waypoint";
|
||||
if (hasObjVar(self, wpName))
|
||||
{
|
||||
if (phase != 2)
|
||||
{
|
||||
obj_id point = getObjIdObjVar(self, wpName);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar(self, wpName);
|
||||
removeObjVar(self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String taskQuests = "fs_quests_sad_task_1";
|
||||
for (int x = 1; x <= 8; x++)
|
||||
{
|
||||
if (quests.isActive("fs_quests_sad_task_" + x, self))
|
||||
{
|
||||
taskQuests = "fs_quests_sad_task_" + x;
|
||||
wpName = "quest." + taskQuests + ".waypoint";
|
||||
if (hasObjVar(self, wpName))
|
||||
{
|
||||
if (phase != 2)
|
||||
{
|
||||
obj_id point = getObjIdObjVar(self, wpName);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar(self, wpName);
|
||||
removeObjVar(self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String returnQuests2 = "fs_quests_sad2_return_1";
|
||||
for (int a = 1; a <= 8; a++)
|
||||
{
|
||||
if (quests.isActive("fs_quests_sad2_return_" + a, self))
|
||||
{
|
||||
returnQuests2 = "fs_quests_sad2_return_" + a;
|
||||
wpName = "quest." + returnQuests2 + ".waypoint";
|
||||
if (hasObjVar(self, wpName))
|
||||
{
|
||||
if (phase != 3)
|
||||
{
|
||||
obj_id point = getObjIdObjVar(self, wpName);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar(self, wpName);
|
||||
removeObjVar(self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String taskQuests2 = "fs_quests_sad2_task_1";
|
||||
for (int z = 1; z <= 8; z++)
|
||||
{
|
||||
if (quests.isActive("fs_quests_sad2_task_" + z, self))
|
||||
{
|
||||
taskQuests2 = "fs_quests_sad2_task_" + z;
|
||||
wpName = "quest." + taskQuests2 + ".waypoint";
|
||||
if (hasObjVar(self, wpName))
|
||||
{
|
||||
if (phase != 3)
|
||||
{
|
||||
obj_id point = getObjIdObjVar(self, wpName);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar(self, wpName);
|
||||
removeObjVar(self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,503 +0,0 @@
|
||||
include library.fs_dyn_village;
|
||||
include library.create;
|
||||
include library.geiger;
|
||||
include library.locations;
|
||||
include library.quests;
|
||||
include library.theater;
|
||||
include library.utils;
|
||||
include library.fs_quests_sad;
|
||||
|
||||
const string FS_QUEST_SAD_QUANTITY_KILLABLE = "fs_quest_sad.quantity_killable";
|
||||
const string FS_QUEST_SAD_THEATER_LOCATION = "fs_quest_sad.theater_location";
|
||||
|
||||
const location FS_VILLAGE_LOCATION = new location(5238.26f, 78.5f, -4189.03f);
|
||||
|
||||
void completeTask(obj_id self, String questName, boolean succeeded) {
|
||||
|
||||
int killable = getIntObjVar (self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
killable = 0;
|
||||
setObjVar (self, FS_QUEST_SAD_QUANTITY_KILLABLE, killable);
|
||||
geiger.clearGeiger(self);
|
||||
|
||||
if(hasObjVar(self, "quest." + questName)) {
|
||||
|
||||
obj_id waypoint = getObjIdObjVar(self, "quest." + questName + ".waypoint");
|
||||
|
||||
if(isIdValid(waypoint)) {
|
||||
|
||||
destroyWaypointInDatapad(waypoint, self);
|
||||
}
|
||||
}
|
||||
|
||||
if(hasTheaterAssigned(self))
|
||||
unassignTheaterFromPlayer(self);
|
||||
|
||||
if(utils.hasObjVar(self, fs_quests_sad.SAD_OBJVAR_MASTER_THEATER))
|
||||
{
|
||||
obj_id theater = utils.getObjIdObjVar(self, fs_quests_sad.SAD_OBJVAR_MASTER_THEATER);
|
||||
messageTo(theater, "destroySelf", null, 90.0f, false);
|
||||
}
|
||||
|
||||
fs_quests_sad.recordTaskSuccess(self);
|
||||
|
||||
LOG("newquests", "fs_quest_sad.basic_task - completing");
|
||||
quests.complete(questName, self, succeeded);
|
||||
}
|
||||
|
||||
void setupTheater(obj_id self, int questRow) {
|
||||
|
||||
if(quests.isMyQuest(questRow, "quest.task.fs_quest_sad.basic_task")) {
|
||||
|
||||
string questName = quests.getDataEntry(questRow, "NAME");
|
||||
|
||||
if(questName == null || questName.equals("") || !quests.isActive(questName, self))
|
||||
return;
|
||||
|
||||
string target = null;
|
||||
|
||||
target = quests.getDataEntry(questRow, "TARGET");
|
||||
|
||||
if(target == null || target.equals(""))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - no target");
|
||||
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('/') <= 0) || (tokens[0].indexOf('\\') <= 0))
|
||||
datatable = tokens[0];
|
||||
else
|
||||
datatable = tokens[1];
|
||||
}
|
||||
|
||||
location theaterLoc = null;
|
||||
boolean hasLocInfo = false;
|
||||
|
||||
boolean created = false;
|
||||
|
||||
string parameterString = quests.getDataEntry(questRow, "PARAMETER");
|
||||
float radius = 0.0f;
|
||||
if(parameterString != null && !parameterString.equals(""))
|
||||
{
|
||||
radius = utils.stringToFloat(parameterString);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "row has no PARAMETER field");
|
||||
radius = 1.0f;
|
||||
}
|
||||
|
||||
int attempts = 0;
|
||||
float positiveRadius = (radius > 0.0f ? radius : -radius);
|
||||
float extension = 0.0f;
|
||||
while(theaterLoc == null && attempts < 150) {
|
||||
extension += 50.0f;
|
||||
++attempts;
|
||||
theaterLoc = locations.getRandomGoodLocation(getLocation(self), positiveRadius - 200.0f, positiveRadius + 200.0f + extension, 32.0f);
|
||||
}
|
||||
|
||||
if(theaterLoc != null)
|
||||
{
|
||||
LOG("newquests", "basic_task assigning theater to player");
|
||||
unassignTheaterFromPlayer(self);
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.fs_quests_sad.theater_controller", TLT_none);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "getTheaterLocationTarget failed to return a location, marking the player as a big winner");
|
||||
quests.complete(questName, self, true);
|
||||
}
|
||||
|
||||
|
||||
if(created)
|
||||
{
|
||||
if(radius >= 0.0f)
|
||||
{
|
||||
setupWaypoint(self, questRow, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
setupGeiger(self, questRow, theaterLoc);
|
||||
}
|
||||
utils.setScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
setupTheater(self, questRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setupGeiger(obj_id self, int questRow, location loc)
|
||||
{
|
||||
sendSystemMessage (self, "Target Moved -- Radiation Sensor Updated", null);
|
||||
if(loc != null)
|
||||
{
|
||||
geiger.setGeiger(self, loc);
|
||||
}
|
||||
}
|
||||
|
||||
void setupWaypoint(obj_id self, int questRow, location loc)
|
||||
{
|
||||
string questName = quests.getDataEntry(questRow, "NAME");
|
||||
string waypointObjVar = "quest." + questName + ".waypoint";
|
||||
|
||||
sendSystemMessage (self, "Waypoint Updated", null);
|
||||
if (hasObjVar (self, waypointObjVar))
|
||||
{
|
||||
obj_id point = getObjIdObjVar (self, waypointObjVar);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar (self, waypointObjVar);
|
||||
}
|
||||
|
||||
|
||||
if (loc != null)
|
||||
{
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
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, waypointObjVar, wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
messageHandler theaterFailed()
|
||||
{
|
||||
LOG("newquests", "inside theaterFailed");
|
||||
if ( params == null )
|
||||
return SCRIPT_CONTINUE;
|
||||
string name = params.getString("name");
|
||||
string paramDatatable = params.getString("datatable");
|
||||
|
||||
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.fs_quest_sad.basic_task")) {
|
||||
|
||||
if(quests.isActive(questName, self))
|
||||
{
|
||||
string target = null;
|
||||
|
||||
target = quests.getDataEntry(iter, "TARGET");
|
||||
|
||||
if(target == null || target.equals(""))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - no target");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
string[] tokens = split(target, ':');
|
||||
string datatable = null;
|
||||
datatable = tokens[0];
|
||||
|
||||
LOG("newquests", "fs_quest_sad.basic_task - quest is active");
|
||||
LOG("newquests", "fs_quest_sad.basic_task, datatable, paramDatatable = '" + datatable + "' , '" + paramDatatable + "'");
|
||||
unassignTheaterFromPlayer(self);
|
||||
location theaterLoc = null;
|
||||
boolean needUpdate = true;
|
||||
if(utils.hasScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION))
|
||||
{
|
||||
theaterLoc = utils.getLocationScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION);
|
||||
needUpdate = false;
|
||||
//Only try this once, don't get into an infinite loop
|
||||
utils.removeScriptVar(self, FS_QUEST_SAD_THEATER_LOCATION);
|
||||
}
|
||||
if(theaterLoc == null)
|
||||
{
|
||||
float distanceToVillage = getLocation(self).distance(FS_VILLAGE_LOCATION);
|
||||
int attempts = 0;
|
||||
float searchDelta = 0;
|
||||
while((theaterLoc == null) && (attempts < 32))
|
||||
{
|
||||
LOG("newquests", "theater is null, generating random good location");
|
||||
theaterLoc = locations.getRandomGoodLocation(getLocation(self), 92.0f + searchDelta, 160.0f + searchDelta, 32.0f);
|
||||
if(theaterLoc != null)
|
||||
{
|
||||
float newDistance = theaterLoc.distance(FS_VILLAGE_LOCATION);
|
||||
if(newDistance < distanceToVillage)
|
||||
{
|
||||
theaterLoc = null;
|
||||
}
|
||||
else if (!theater.canSpawnTheaterAtLocation(theaterLoc))
|
||||
{
|
||||
theaterLoc = null;
|
||||
// push the search area out, since regions are generally large
|
||||
searchDelta += 256.0f;
|
||||
}
|
||||
}
|
||||
attempts++;
|
||||
}
|
||||
}
|
||||
if(theaterLoc == null)
|
||||
{
|
||||
float distanceToVillage = getLocation(self).distance(FS_VILLAGE_LOCATION);
|
||||
LOG("newquests", "OnPlayerTheaterFail tried to getRandomGoodLocation and failed, moving directly away");
|
||||
theaterLoc = locations.moveLocationTowardsLocation(FS_VILLAGE_LOCATION, getLocation(self), distanceToVillage + 256.0f);
|
||||
}
|
||||
boolean created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.fs_quests_sad.theater_controller", TLT_flatten);
|
||||
if(needUpdate)
|
||||
{
|
||||
if(utils.hasObjVar(self, geiger.OBJVAR_GEIGER_LOCATION))
|
||||
{
|
||||
LOG("newquests", "updating geiger");
|
||||
setupGeiger(self, iter, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "updating waypoint");
|
||||
setupWaypoint(self, iter, theaterLoc);
|
||||
}
|
||||
}
|
||||
if(created)
|
||||
{
|
||||
LOG("newquests", "OnPlayerTheaterFail created the flattened theater at " + theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "OnPlayerTheaterFail couldn't create the flatten theater");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnPlayerTheaterFail(string datatable, string name)
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnPlayerTheaterFail");
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("datatable", datatable);
|
||||
params.put("name", name);
|
||||
|
||||
messageTo(self, "theaterFailed", params, 8.0f, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnLogin() {
|
||||
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnLogin");
|
||||
|
||||
checkForPhaseChange (self);
|
||||
|
||||
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.fs_quest_sad.basic_task")) {
|
||||
|
||||
if(quests.isActive(questName, self)) {
|
||||
|
||||
LOG("newquests", "fs_quest_sad.basic_task - quest is active");
|
||||
|
||||
if(hasObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE))
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - removing objvar");
|
||||
removeObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
}
|
||||
if(hasObjVar(self, "quest." + questName + ".generate")) {
|
||||
|
||||
removeObjVar(self, "quest." + questName + ".generate");
|
||||
}
|
||||
LOG("newquests", "fs_quest_sad.basic_task - setting up theater");
|
||||
setupTheater(self, iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnQuestActivated(+ " + questRow + ")");
|
||||
|
||||
// determine if the trigger is related to this particular script
|
||||
// more than one task script may be attached to the player
|
||||
if(quests.isMyQuest(questRow, "quest.task.fs_quest_sad.basic_task"))
|
||||
{
|
||||
|
||||
// get the name of the qust from the quests data table
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
boolean success = true;
|
||||
|
||||
//Spawn theater
|
||||
setupTheater(self, questRow);
|
||||
|
||||
fs_quests_sad.recordTookTask(self);
|
||||
|
||||
LOG("newquests", "fs_quest_sad.basic_task - success = " + success);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
//@TODO: This hasn't been augmented yet to handle having multiple basic_task at once
|
||||
messageHandler OnCreatedKillableObject()
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnCreatedKillableObject");
|
||||
int quantityKillable = utils.getIntObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
quantityKillable++;
|
||||
utils.setObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE, quantityKillable);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler OnIncapacitatedKillableObject()
|
||||
{
|
||||
LOG("newquests", "fs_quest_sad.basic_task - OnIncapacitatedKillableObject");
|
||||
int quantityKillable = utils.getIntObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE);
|
||||
quantityKillable--;
|
||||
if(quantityKillable < 0)
|
||||
quantityKillable = 0;
|
||||
utils.setObjVar(self, FS_QUEST_SAD_QUANTITY_KILLABLE, quantityKillable);
|
||||
if(quantityKillable <= 1)
|
||||
{
|
||||
quantityKillable = 0;
|
||||
setObjVar (self, FS_QUEST_SAD_QUANTITY_KILLABLE, quantityKillable);
|
||||
|
||||
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.fs_quest_sad.basic_task"))
|
||||
if(quests.isActive(questName, self))
|
||||
completeTask(self, questName, true);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void checkForPhaseChange (obj_id self)
|
||||
{
|
||||
fs_dyn_village.getRegisteredIntegerFromClusterWideData(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID, "findCurrentPhase", self);
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler findCurrentPhase()
|
||||
{
|
||||
if(!params.containsKey(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID))
|
||||
{
|
||||
LOG(fs_dyn_village.LOG_CHAN, "fs_quest_player::msgValidateFSQuestPhase: -> Error getting current phase from cluster data. Potentially on wrong quest phase.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int curUid = params.getInt(fs_dyn_village.CLUSTER_INT_KEY_PHASE_UID);
|
||||
int curPhase = fs_dyn_village.getPhaseFromVersionUid(curUid);
|
||||
string wpName = "waypoint";
|
||||
|
||||
setObjVar (self, "current_phase", curPhase);
|
||||
|
||||
int phase = getIntObjVar (self, "current_phase");
|
||||
|
||||
string returnQuests = "fs_quests_sad_return_1";
|
||||
for(int i = 1; i <= 8; i++)
|
||||
{
|
||||
if(quests.isActive("fs_quests_sad_return_" + i, self))
|
||||
{
|
||||
returnQuests = "fs_quests_sad_return_" + i;
|
||||
wpName = "quest." + returnQuests + ".waypoint";
|
||||
if (hasObjVar (self, wpName))
|
||||
if (phase != 2)
|
||||
{
|
||||
obj_id point = getObjIdObjVar (self, wpName);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar (self, wpName);
|
||||
removeObjVar (self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string taskQuests = "fs_quests_sad_task_1";
|
||||
for (int x = 1; x <= 8; x++)
|
||||
{
|
||||
if(quests.isActive("fs_quests_sad_task_" + x, self))
|
||||
{
|
||||
taskQuests = "fs_quests_sad_task_" + x;
|
||||
wpName = "quest." + taskQuests + ".waypoint";
|
||||
if (hasObjVar (self, wpName))
|
||||
if (phase != 2)
|
||||
{
|
||||
obj_id point = getObjIdObjVar (self, wpName );
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar (self, wpName);
|
||||
removeObjVar (self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string returnQuests2 = "fs_quests_sad2_return_1";
|
||||
for(int a = 1; a <= 8; a++)
|
||||
{
|
||||
if(quests.isActive("fs_quests_sad2_return_" + a, self))
|
||||
{
|
||||
returnQuests2 = "fs_quests_sad2_return_" + a;
|
||||
wpName = "quest." + returnQuests2 + ".waypoint";
|
||||
if (hasObjVar (self, wpName))
|
||||
if (phase != 3)
|
||||
{
|
||||
obj_id point = getObjIdObjVar (self, wpName);
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar (self, wpName);
|
||||
removeObjVar (self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string taskQuests2 = "fs_quests_sad2_task_1";
|
||||
for (int z = 1; z <= 8; z++)
|
||||
{
|
||||
if(quests.isActive("fs_quests_sad2_task_" + z, self))
|
||||
{
|
||||
taskQuests2 = "fs_quests_sad2_task_" + z;
|
||||
wpName = "quest." + taskQuests2 + ".waypoint";
|
||||
if (hasObjVar (self, wpName))
|
||||
if (phase != 3)
|
||||
{
|
||||
obj_id point = getObjIdObjVar (self, wpName );
|
||||
destroyWaypointInDatapad(point, self);
|
||||
removeObjVar (self, wpName);
|
||||
removeObjVar (self, "current_phase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.create;
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class give_object_to_player extends script.base_script
|
||||
{
|
||||
public give_object_to_player()
|
||||
{
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "give_object_to_player - OnQuestActivated(+ " + questRow + ")");
|
||||
if (quests.isMyQuest(questRow, "quest.task.give_object_to_player"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
if (questName != null)
|
||||
{
|
||||
String attachedScriptName;
|
||||
String parameterObjVarName = "quest." + questName + ".parameter";
|
||||
if (hasObjVar(self, parameterObjVarName))
|
||||
{
|
||||
attachedScriptName = getStringObjVar(self, parameterObjVarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
attachedScriptName = quests.getDataEntry(questRow, "PARAMETER");
|
||||
}
|
||||
String templateName;
|
||||
String targetObjVarName = "quest." + questName + ".target";
|
||||
if (hasObjVar(self, targetObjVarName))
|
||||
{
|
||||
templateName = getStringObjVar(self, targetObjVarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
templateName = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
LOG("newquests", "give_object_to_player - questName = " + questName + " templateName = " + templateName + " attachedScriptName = " + attachedScriptName);
|
||||
boolean success = true;
|
||||
obj_id createdObject = createObjectInInventoryAllowOverload(templateName, self);
|
||||
if (createdObject != null)
|
||||
{
|
||||
if ((attachedScriptName != null) && !attachedScriptName.equals(""))
|
||||
{
|
||||
attachScript(createdObject, attachedScriptName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("fs_quests", "give_object_to_player: failed to create " + templateName + " in inventory for %TU ", self, null);
|
||||
success = false;
|
||||
}
|
||||
LOG("newquests", "give_object_to_player - success = " + success);
|
||||
quests.complete(questName, self, success);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("fs_quests", "give_object_to_player: failed to retrieve quest name for quest id" + questRow + " for %TU ", self, null);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
include library.create;
|
||||
include library.locations;
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
LOG("newquests", "give_object_to_player - OnQuestActivated(+ " + questRow + ")");
|
||||
|
||||
// determine if the trigger is related to this particular script
|
||||
// more than one task script may be attached to the player
|
||||
if(quests.isMyQuest(questRow, "quest.task.give_object_to_player"))
|
||||
{
|
||||
|
||||
// get the name of the quest from the quests data table
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
|
||||
if (questName != null)
|
||||
{
|
||||
String attachedScriptName;
|
||||
String parameterObjVarName = "quest." + questName + ".parameter";
|
||||
if(hasObjVar(self, parameterObjVarName))
|
||||
{
|
||||
attachedScriptName = getStringObjVar(self, parameterObjVarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
attachedScriptName = quests.getDataEntry(questRow, "PARAMETER");
|
||||
}
|
||||
|
||||
String templateName;
|
||||
String targetObjVarName = "quest." + questName + ".target";
|
||||
if(hasObjVar(self, targetObjVarName))
|
||||
{
|
||||
templateName = getStringObjVar(self, targetObjVarName);
|
||||
}
|
||||
else
|
||||
{
|
||||
templateName = quests.getDataEntry(questRow, "TARGET");
|
||||
}
|
||||
|
||||
LOG("newquests", "give_object_to_player - questName = " + questName + " templateName = " + templateName + " attachedScriptName = " + attachedScriptName);
|
||||
|
||||
boolean success = true;
|
||||
obj_id createdObject = createObjectInInventoryAllowOverload(templateName, self);
|
||||
if(createdObject != null)
|
||||
{
|
||||
if((attachedScriptName != null) && !attachedScriptName.equals(""))
|
||||
{
|
||||
attachScript(createdObject, attachedScriptName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("fs_quests", "give_object_to_player: failed to create " + templateName + " in inventory for %TU ", self, null);
|
||||
success = false;
|
||||
}
|
||||
|
||||
LOG("newquests", "give_object_to_player - success = " + success);
|
||||
// complete the task. It is normal for log output to indicate
|
||||
// that the encounter failed to activate, because this call
|
||||
// will deactivate it while in the process of activating it.
|
||||
quests.complete(questName, self, success);
|
||||
}
|
||||
else
|
||||
{
|
||||
CustomerServiceLog("fs_quests", "give_object_to_player: failed to retrieve quest name for quest id" + questRow + " for %TU ", self, null);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class go_to_location extends script.base_script
|
||||
{
|
||||
public go_to_location()
|
||||
{
|
||||
}
|
||||
public void completeTask(obj_id self, String questName, boolean succeeded) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, "quest." + questName))
|
||||
{
|
||||
obj_id waypoint = getObjIdObjVar(self, "quest." + questName + ".waypoint");
|
||||
if (isIdValid(waypoint))
|
||||
{
|
||||
destroyWaypointInDatapad(waypoint, self);
|
||||
}
|
||||
}
|
||||
quests.complete(questName, self, succeeded);
|
||||
}
|
||||
public void setupWaypoint(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.go_to_location"))
|
||||
{
|
||||
location loc = quests.getLocationTarget(self, questRow);
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
if (loc != null)
|
||||
{
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
String wp_objvar = "quest." + questName + ".waypoint";
|
||||
if (hasObjVar(self, wp_objvar))
|
||||
{
|
||||
return;
|
||||
}
|
||||
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, wp_objvar, wp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "failed to retrieve a location target for quest " + questName);
|
||||
}
|
||||
}
|
||||
}
|
||||
public int OnLogin(obj_id self) throws InterruptedException
|
||||
{
|
||||
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.go_to_location"))
|
||||
{
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
if (hasObjVar(self, "quest." + questName + ".generate"))
|
||||
{
|
||||
removeObjVar(self, "quest." + questName + ".generate");
|
||||
setupWaypoint(self, iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
LOG("newquests", "go_to_location - OnQuestActivated(" + questRow + ")");
|
||||
if (quests.isMyQuest(questRow, "quest.task.go_to_location"))
|
||||
{
|
||||
LOG("newquests", "go_to_location attempting to generate waypoint");
|
||||
setupWaypoint(self, questRow);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnArrivedAtLocation(obj_id self, String locationName) throws InterruptedException
|
||||
{
|
||||
if (quests.isActive(locationName, self))
|
||||
{
|
||||
LOG("newquests", "go_to_location arrived at " + locationName);
|
||||
completeTask(self, locationName, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
include library.locations;
|
||||
include library.quests;
|
||||
include library.utils;
|
||||
|
||||
void completeTask(obj_id self, String questName, boolean succeeded)
|
||||
{
|
||||
// clean up the waypoint before completing the task
|
||||
if(hasObjVar(self, "quest." + questName))
|
||||
{
|
||||
// destroy the waypoint
|
||||
obj_id waypoint = getObjIdObjVar(self, "quest." + questName + ".waypoint");
|
||||
if(isIdValid(waypoint))
|
||||
{
|
||||
destroyWaypointInDatapad(waypoint, self);
|
||||
}
|
||||
}
|
||||
|
||||
quests.complete(questName, self, succeeded);
|
||||
}
|
||||
|
||||
void setupWaypoint(obj_id self, int questRow)
|
||||
{
|
||||
// attempt to generate a location and create a
|
||||
// waypoint in the player's datapad
|
||||
if(quests.isMyQuest(questRow, "quest.task.go_to_location"))
|
||||
{
|
||||
// this quest is a go_to_location, generate the target location
|
||||
location loc = quests.getLocationTarget(self, questRow);
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
if(loc != null)
|
||||
{
|
||||
// create a waypoint, save the waypoint id in an objvar
|
||||
// called quest.<questName>.waypoint so it can later
|
||||
// be destroyed when the player completes the task
|
||||
if(questName != null && questName.length() > 0)
|
||||
{
|
||||
string wp_objvar = "quest." + questName + ".waypoint";
|
||||
|
||||
if(hasObjVar(self, wp_objvar))
|
||||
return;
|
||||
|
||||
obj_id wp = createWaypointInDatapad(self, loc);
|
||||
|
||||
// attempt to label the waypoint using the localized
|
||||
// summary text defined in the JOURNAL_ENTRY_SUMMARY
|
||||
// column of the quests data table
|
||||
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, wp_objvar, wp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("newquests", "failed to retrieve a location target for quest " + questName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
String questName = quests.getDataEntry(iter, "NAME");
|
||||
if(quests.isMyQuest(iter, "quest.task.go_to_location"))
|
||||
{
|
||||
if(quests.isActive(questName, self))
|
||||
{
|
||||
if(hasObjVar(self, "quest." + questName + ".generate"))
|
||||
{
|
||||
removeObjVar(self, "quest." + questName + ".generate");
|
||||
setupWaypoint(self, iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnQuestActivated(int questRow)
|
||||
{
|
||||
LOG("newquests", "go_to_location - OnQuestActivated(" + questRow + ")");
|
||||
if(quests.isMyQuest(questRow, "quest.task.go_to_location"))
|
||||
{
|
||||
LOG("newquests", "go_to_location attempting to generate waypoint");
|
||||
setupWaypoint(self, questRow);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnArrivedAtLocation(string locationName)
|
||||
{
|
||||
if(quests.isActive(locationName, self))
|
||||
{
|
||||
LOG("newquests", "go_to_location arrived at " + locationName);
|
||||
completeTask(self, locationName, true);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package script.quest.task;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.locations;
|
||||
import script.library.quests;
|
||||
import script.library.utils;
|
||||
|
||||
public class go_to_theater extends script.base_script
|
||||
{
|
||||
public go_to_theater()
|
||||
{
|
||||
}
|
||||
public void completeTask(obj_id self, String questName, boolean succeeded) throws InterruptedException
|
||||
{
|
||||
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);
|
||||
}
|
||||
public void setupTheater(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.go_to_theater"))
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
if (questName == null || questName.equals("") || !quests.isActive(questName, self))
|
||||
{
|
||||
return;
|
||||
}
|
||||
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('/') <= 0) || (tokens[0].indexOf('\\') <= 0))
|
||||
{
|
||||
datatable = tokens[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
datatable = tokens[1];
|
||||
}
|
||||
}
|
||||
location theaterLoc = new location();
|
||||
boolean hasLocInfo = false;
|
||||
int theaterTest = dataTableGetInt(datatable, 0, 0);
|
||||
if (theaterTest > 0)
|
||||
{
|
||||
if (theaterTest == (1606908893))
|
||||
{
|
||||
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;
|
||||
int theaterLocationType = TLT_getGoodLocation;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
else if ("atloc" == params[i])
|
||||
{
|
||||
theaterLocationType = TLT_none;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasLocInfo)
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLocationType);
|
||||
}
|
||||
else
|
||||
{
|
||||
theaterLoc = quests.getTheaterLocationTarget(self, questRow);
|
||||
if (theaterLoc != null)
|
||||
{
|
||||
if (questName.equals("fs_theater_final"))
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.exit_quest.final_battle_theater", theaterLocationType);
|
||||
}
|
||||
else if (questName.equals("fs_theater_camp"))
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.camp_battle_theater", theaterLocationType);
|
||||
}
|
||||
else
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "quest.task.theater_controller", theaterLocationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (created)
|
||||
{
|
||||
setupWaypoint(self, questRow, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("quest", "!!!!!!!!!!!!!!( " + self + " )Can't create theater...");
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void setupWaypoint(obj_id self, int questRow, location loc) throws InterruptedException
|
||||
{
|
||||
if (loc != null)
|
||||
{
|
||||
String questName = quests.getDataEntry(questRow, "NAME");
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
public int OnLogin(obj_id self) throws InterruptedException
|
||||
{
|
||||
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.go_to_theater"))
|
||||
{
|
||||
if (quests.isActive(questName, self))
|
||||
{
|
||||
if (hasObjVar(self, "quest." + questName + ".generate"))
|
||||
{
|
||||
removeObjVar(self, "quest." + questName + ".generate");
|
||||
setupTheater(self, iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnQuestActivated(obj_id self, int questRow) throws InterruptedException
|
||||
{
|
||||
if (quests.isMyQuest(questRow, "quest.task.go_to_theater"))
|
||||
{
|
||||
setupTheater(self, questRow);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnArrivedAtLocation(obj_id self, String locationName) throws InterruptedException
|
||||
{
|
||||
if (quests.isActive(locationName, self))
|
||||
{
|
||||
completeTask(self, locationName, true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
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) {
|
||||
//LOG("quest", "!!!!!!!!!!!!!setupTheater");
|
||||
if(quests.isMyQuest(questRow, "quest.task.go_to_theater")) {
|
||||
string questName = quests.getDataEntry(questRow, "NAME");
|
||||
//LOG("quest", "!!!!!!!!!!!!!setupTheater 111111 --->" + quests.isActive(questName, self) + " " + questName);
|
||||
if(questName == null || questName.equals("") || !quests.isActive(questName, self))
|
||||
return;
|
||||
|
||||
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('/') <= 0) || (tokens[0].indexOf('\\') <= 0))
|
||||
datatable = tokens[0];
|
||||
else
|
||||
datatable = tokens[1];
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
int theaterLocationType = TLT_getGoodLocation;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
else if ("atloc" == params[i])
|
||||
{
|
||||
theaterLocationType = TLT_none;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(hasLocInfo) {
|
||||
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLocationType);
|
||||
|
||||
} else {
|
||||
|
||||
theaterLoc = quests.getTheaterLocationTarget(self, questRow);
|
||||
|
||||
if(theaterLoc != null)
|
||||
|
||||
// I realize this is very hacky - I am sorry
|
||||
{
|
||||
if (questName == "fs_theater_final")
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.exit_quest.final_battle_theater", theaterLocationType);
|
||||
}
|
||||
else if (questName == "fs_theater_camp")
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "systems.fs_quest.camp_battle_theater", theaterLocationType);
|
||||
}
|
||||
else
|
||||
{
|
||||
created = assignTheaterToPlayer(self, datatable, theaterLoc, "quest.task.theater_controller", theaterLocationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(created) {
|
||||
//LOG("quest", "!!!!!!!!!!!!!Theater created");
|
||||
|
||||
setupWaypoint(self, questRow, theaterLoc);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("quest", "!!!!!!!!!!!!!!( " + self + " )Can't create theater...");
|
||||
// We couldn't create the theater so fail it.
|
||||
quests.complete(questName, self, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setupWaypoint(obj_id self, int questRow, location loc) {
|
||||
|
||||
if(loc != null) {
|
||||
|
||||
string questName = quests.getDataEntry(questRow, "NAME");
|
||||
|
||||
if(questName != null && questName.length() > 0) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.go_to_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.go_to_theater")) {
|
||||
|
||||
setupTheater(self, questRow);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnArrivedAtLocation(string locationName) {
|
||||
|
||||
if(quests.isActive(locationName, self)) {
|
||||
|
||||
completeTask(self, locationName, true);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.quests;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.utils;
|
||||
|
||||
public class assassinate extends script.quest.task.ground.base_task
|
||||
{
|
||||
public assassinate()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
public static final String dataTableColumnDestinationNodeName = "DESTINATION_NODE_NAME";
|
||||
public static final String dataTableColumnMovementType = "MOVEMENT_TYPE";
|
||||
public static final String objvarAsassinateTarget = "target";
|
||||
public static final String taskType = "assassinate";
|
||||
public static final String dot = ".";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String serverTemplate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
location l = groundquests.getRandom2DLocationAroundPlayer(self, 5, 15);
|
||||
obj_id assassinateTarget = create.createCreature(serverTemplate, l, true);
|
||||
groundquests.addDestroyNotification(assassinateTarget, self);
|
||||
setObjVar(self, baseObjVar + dot + objvarAsassinateTarget, assassinateTarget);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int destroyNotification(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if (taskObjVarName != null)
|
||||
{
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String assassinateTargetObjVarName = questObjVarName + dot + taskName + dot + objvarAsassinateTarget;
|
||||
if (hasObjVar(self, assassinateTargetObjVarName))
|
||||
{
|
||||
obj_id assassinateTarget = getObjIdObjVar(self, assassinateTargetObjVarName);
|
||||
if (source == assassinateTarget)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String assassinateTargetObjVarName = baseObjVar + dot + objvarAsassinateTarget;
|
||||
obj_id assassinateTarget = getObjIdObjVar(player, assassinateTargetObjVarName);
|
||||
if (assassinateTarget != null)
|
||||
{
|
||||
removeObjVar(player, assassinateTargetObjVarName);
|
||||
if (!ai_lib.isAiDead(assassinateTarget))
|
||||
{
|
||||
destroyObject(assassinateTarget);
|
||||
}
|
||||
}
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.quests;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
const String dataTableColumnDestinationNodeName = "DESTINATION_NODE_NAME";
|
||||
const String dataTableColumnMovementType = "MOVEMENT_TYPE";
|
||||
|
||||
const String objvarAsassinateTarget = "target";
|
||||
|
||||
const String taskType = "assassinate";
|
||||
const String dot = ".";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
//gather data for this task
|
||||
String serverTemplate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
|
||||
location l = groundquests.getRandom2DLocationAroundPlayer(self, 5, 15);
|
||||
obj_id assassinateTarget = create.createCreature(serverTemplate, l, true);
|
||||
|
||||
groundquests.addDestroyNotification(assassinateTarget, self);
|
||||
|
||||
setObjVar(self, baseObjVar + dot + objvarAsassinateTarget, assassinateTarget);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler destroyNotification()
|
||||
{
|
||||
if(params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
|
||||
//get the base objvar for quests, all data is under that
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if(taskObjVarName != null)
|
||||
{
|
||||
//get the list of quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
//for each quest, check each task
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are of the right taskType
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
//check the data specific to this task type
|
||||
String assassinateTargetObjVarName = questObjVarName + dot + taskName + dot + objvarAsassinateTarget;
|
||||
if(hasObjVar(self, assassinateTargetObjVarName))
|
||||
{
|
||||
obj_id assassinateTarget = getObjIdObjVar(self, assassinateTargetObjVarName);
|
||||
if(source == assassinateTarget)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
// destroy the assassinate target
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String assassinateTargetObjVarName = baseObjVar + dot + objvarAsassinateTarget;
|
||||
|
||||
obj_id assassinateTarget = getObjIdObjVar(player, assassinateTargetObjVarName);
|
||||
|
||||
if (assassinateTarget!= null)
|
||||
{
|
||||
removeObjVar(player, assassinateTargetObjVarName);
|
||||
if(!ai_lib.isAiDead(assassinateTarget))
|
||||
destroyObject(assassinateTarget);
|
||||
}
|
||||
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,210 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class base_task extends script.base.remote_object_requester
|
||||
{
|
||||
public base_task()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "base_task";
|
||||
public static final String dataTableColumnQuestOnComplete = "GRANT_QUEST_ON_COMPLETE";
|
||||
public static final String dataTableColumnQuestOnFail = "GRANT_QUEST_ON_FAIL";
|
||||
public static final String dataTableColumnMusicOnActivate = "MUSIC_ON_ACTIVATE";
|
||||
public static final String dataTableColumnMusicOnComplete = "MUSIC_ON_COMPLETE";
|
||||
public static final String dataTableColumnMusicOnFail = "MUSIC_ON_FAIL";
|
||||
public static final String dataTableColumnQuestOnCompleteShowSystemMessage = "GRANT_QUEST_ON_COMPLETE_SHOW_SYSTEM_MESSAGE";
|
||||
public static final String dataTableColumnQuestOnFailShowSystemMessage = "GRANT_QUEST_ON_FAIL_SHOW_SYSTEM_MESSAGE";
|
||||
public static final String dataTableColumnTimerAmount = "TIMER_AMOUNT";
|
||||
public static final String dataTableColumnVisible = "IS_VISIBLE";
|
||||
public static final String dataTableColumnSignalsOnComplete = "SIGNALS_ON_COMPLETE";
|
||||
public static final String dataTableColumnSignalsOnFail = "SIGNALS_ON_FAIL";
|
||||
public static final String MUSIC_TASK_COMPLETED = "sound/music_themequest_victory_rebel.snd";
|
||||
public static final String MUSIC_TASK_FAILED = "sound/music_themequest_fail_criminal.snd";
|
||||
public static final String dot = ".";
|
||||
public static final String objvarWaypoint = "waypoint";
|
||||
public static final String objvarEntranceWaypoint = "entranceWaypoint";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
groundquests.createQuestWaypoints(questCrc, taskId, self);
|
||||
if (groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
String musicOnActivate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMusicOnActivate);
|
||||
if (musicOnActivate != null && musicOnActivate.length() > 0)
|
||||
{
|
||||
play2dNonLoopingMusic(self, musicOnActivate);
|
||||
}
|
||||
}
|
||||
int timerLength = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnTimerAmount);
|
||||
if (timerLength > 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Setting timer for " + timerLength + " seconds.");
|
||||
final float playerPlayedTimeWhenTimerEnds = (float)getPlayerPlayedTime(self) + (float)timerLength;
|
||||
final String objVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId) + dot + groundquests.timeObjVar;
|
||||
setObjVar(self, objVar, playerPlayedTimeWhenTimerEnds);
|
||||
dictionary params = new dictionary();
|
||||
params.put("questcrc", questCrc);
|
||||
params.put("taskid", taskId);
|
||||
params.put("endTime", (int)getFloatObjVar(self, objVar));
|
||||
messageTo(self, "QuestBaseTaskTimerTaskCompleted", params, timerLength, true);
|
||||
if (isVisible != 0)
|
||||
{
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", (int)playerPlayedTimeWhenTimerEnds);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int QuestBaseTaskTimerTaskCompleted(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
final int questCrc = params.getInt("questcrc");
|
||||
final int taskId = params.getInt("taskid");
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
final String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
final float playerPlayedTimeWhenTimerEnds = getFloatObjVar(self, baseObjVar + dot + groundquests.timeObjVar);
|
||||
if (params.containsKey("endTime"))
|
||||
{
|
||||
final int endTime = params.getInt("endTime");
|
||||
if (endTime != (int)playerPlayedTimeWhenTimerEnds)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
final float timeLeft = playerPlayedTimeWhenTimerEnds - (float)getPlayerPlayedTime(self);
|
||||
if (timeLeft <= 0)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary newParams = new dictionary();
|
||||
newParams.put("questcrc", questCrc);
|
||||
newParams.put("taskid", taskId);
|
||||
newParams.put("endTime", (int)playerPlayedTimeWhenTimerEnds);
|
||||
messageTo(self, "QuestBaseTaskTimerTaskCompleted", newParams, timeLeft, true);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String questOnComplete = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnQuestOnComplete);
|
||||
if (questOnComplete != null && questOnComplete.length() > 0)
|
||||
{
|
||||
boolean showSystemMessage = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnQuestOnCompleteShowSystemMessage, true);
|
||||
groundquests.grantQuestNoAcceptUI(self, questOnComplete, showSystemMessage);
|
||||
}
|
||||
if (groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
groundquests.sendTaskCompletedSystemMessage(questCrc, taskId, self);
|
||||
String musicOnComplete = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMusicOnComplete);
|
||||
if (musicOnComplete != null && musicOnComplete.length() > 0)
|
||||
{
|
||||
play2dNonLoopingMusic(self, musicOnComplete);
|
||||
}
|
||||
}
|
||||
sendTaskSignals(self, questCrc, taskId, dataTableColumnSignalsOnComplete);
|
||||
baseCleanup(self, questCrc, taskId);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String questOnFail = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnQuestOnFail);
|
||||
if (questOnFail != null && questOnFail.length() > 0)
|
||||
{
|
||||
boolean showSystemMessage = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnQuestOnFailShowSystemMessage, true);
|
||||
groundquests.grantQuest(self, questOnFail, showSystemMessage);
|
||||
}
|
||||
if (groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
groundquests.sendTaskFailedSystemMessage(questCrc, taskId, self);
|
||||
String musicOnFail = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMusicOnFail);
|
||||
if (musicOnFail != null && musicOnFail.length() > 0)
|
||||
{
|
||||
play2dNonLoopingMusic(self, musicOnFail);
|
||||
}
|
||||
}
|
||||
sendTaskSignals(self, questCrc, taskId, dataTableColumnSignalsOnFail);
|
||||
baseCleanup(self, questCrc, taskId);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
baseCleanup(self, questCrc, taskId);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void baseCleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id waypoint = getObjIdObjVar(player, baseObjVar + dot + objvarWaypoint);
|
||||
if (isIdValid(waypoint))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "baseCleanup", taskType + " destroying waypoint: " + waypoint);
|
||||
destroyWaypointInDatapad(waypoint, player);
|
||||
}
|
||||
obj_id entranceWaypoint = getObjIdObjVar(player, baseObjVar + dot + objvarEntranceWaypoint);
|
||||
if (isIdValid(entranceWaypoint))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "baseCleanup", taskType + " destroying entranceWaypoint: " + entranceWaypoint);
|
||||
destroyWaypointInDatapad(entranceWaypoint, player);
|
||||
}
|
||||
removeObjVar(player, baseObjVar);
|
||||
}
|
||||
public void sendTaskSignals(obj_id player, int questCrc, int taskId, String dataTableColumnName) throws InterruptedException
|
||||
{
|
||||
String signals = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnName);
|
||||
if (signals != null && signals.length() > 0)
|
||||
{
|
||||
groundquests.sendSignals(player, split(signals, ','));
|
||||
}
|
||||
}
|
||||
public int OnLogin(obj_id self) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (hasObjVar(self, baseObjVar + dot + groundquests.objvarWaypointInActive))
|
||||
{
|
||||
if (hasObjVar(self, baseObjVar + dot + groundquests.objvarEntranceWaypoint))
|
||||
{
|
||||
obj_id entranceWaypoint = getObjIdObjVar(self, baseObjVar + dot + groundquests.objvarEntranceWaypoint);
|
||||
if (isIdValid(entranceWaypoint))
|
||||
{
|
||||
groundquests.setQuestWaypointActive(entranceWaypoint, self, baseObjVar);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, baseObjVar + dot + groundquests.objvarWaypoint))
|
||||
{
|
||||
obj_id waypoint = getObjIdObjVar(self, baseObjVar + dot + groundquests.objvarWaypoint);
|
||||
if (isIdValid(waypoint))
|
||||
{
|
||||
groundquests.setQuestWaypointActive(waypoint, self, baseObjVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits base.remote_object_requester;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "base_task";
|
||||
|
||||
const String dataTableColumnQuestOnComplete = "GRANT_QUEST_ON_COMPLETE";
|
||||
const String dataTableColumnQuestOnFail = "GRANT_QUEST_ON_FAIL";
|
||||
const String dataTableColumnMusicOnActivate = "MUSIC_ON_ACTIVATE";
|
||||
const String dataTableColumnMusicOnComplete = "MUSIC_ON_COMPLETE";
|
||||
const String dataTableColumnMusicOnFail = "MUSIC_ON_FAIL";
|
||||
const String dataTableColumnQuestOnCompleteShowSystemMessage = "GRANT_QUEST_ON_COMPLETE_SHOW_SYSTEM_MESSAGE";
|
||||
const String dataTableColumnQuestOnFailShowSystemMessage = "GRANT_QUEST_ON_FAIL_SHOW_SYSTEM_MESSAGE";
|
||||
const String dataTableColumnTimerAmount = "TIMER_AMOUNT";
|
||||
const String dataTableColumnVisible = "IS_VISIBLE";
|
||||
const String dataTableColumnSignalsOnComplete = "SIGNALS_ON_COMPLETE";
|
||||
const String dataTableColumnSignalsOnFail = "SIGNALS_ON_FAIL";
|
||||
|
||||
const string MUSIC_TASK_COMPLETED = "sound/music_themequest_victory_rebel.snd";
|
||||
const string MUSIC_TASK_FAILED = "sound/music_themequest_fail_criminal.snd";
|
||||
|
||||
const String dot = ".";
|
||||
const String objvarWaypoint = "waypoint";
|
||||
const String objvarEntranceWaypoint = "entranceWaypoint";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
|
||||
groundquests.createQuestWaypoints(questCrc, taskId, self);
|
||||
|
||||
//only tell player things if task is visible
|
||||
if(groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
//maybe play music
|
||||
String musicOnActivate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMusicOnActivate);
|
||||
if(musicOnActivate != null && musicOnActivate.length() > 0)
|
||||
{
|
||||
play2dNonLoopingMusic(self, musicOnActivate);
|
||||
}
|
||||
}
|
||||
|
||||
//set the optional timer value
|
||||
int timerLength = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnTimerAmount);
|
||||
if(timerLength > 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Setting timer for " + timerLength + " seconds.");
|
||||
|
||||
const float playerPlayedTimeWhenTimerEnds = (float)getPlayerPlayedTime(self) + (float)timerLength;
|
||||
const String objVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId) + dot + groundquests.timeObjVar;
|
||||
setObjVar(self, objVar, playerPlayedTimeWhenTimerEnds);
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("questcrc", questCrc);
|
||||
params.put("taskid", taskId);
|
||||
|
||||
// we want the *EXACT* objvar value as it is stored in C++ to cover any sort
|
||||
// of float rounding/truncation when the Java float is saved as a float objvar
|
||||
params.put("endTime", (int)getFloatObjVar(self, objVar));
|
||||
|
||||
messageTo(self, "QuestBaseTaskTimerTaskCompleted", params, timerLength, true);
|
||||
|
||||
//only set a timer on the client for visible timers
|
||||
if(isVisible != 0)
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", (int)playerPlayedTimeWhenTimerEnds);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler QuestBaseTaskTimerTaskCompleted()
|
||||
{
|
||||
const int questCrc = params.getInt("questcrc");
|
||||
const int taskId = params.getInt("taskid");
|
||||
|
||||
if(questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
const String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
const float playerPlayedTimeWhenTimerEnds = getFloatObjVar(self, baseObjVar + dot + groundquests.timeObjVar);
|
||||
|
||||
// ignore message if not for the current quest, like it could be a
|
||||
// leftover message from a previously cancelled or completed quest;
|
||||
// legacy persisted messages may not have this value in the payload
|
||||
if (params.containsKey("endTime"))
|
||||
{
|
||||
const int endTime = params.getInt("endTime");
|
||||
if (endTime != (int)playerPlayedTimeWhenTimerEnds)
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
const float timeLeft = playerPlayedTimeWhenTimerEnds - (float)getPlayerPlayedTime(self);
|
||||
//dealing with client/server lag and messageto processing, end at 1 second
|
||||
|
||||
if(timeLeft <= 0)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary newParams = new dictionary();
|
||||
newParams.put("questcrc", questCrc);
|
||||
newParams.put("taskid", taskId);
|
||||
newParams.put("endTime", (int)playerPlayedTimeWhenTimerEnds);
|
||||
|
||||
messageTo(self, "QuestBaseTaskTimerTaskCompleted", newParams, timeLeft, true);
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
//grant any new quests on task completion
|
||||
String questOnComplete = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnQuestOnComplete);
|
||||
if(questOnComplete != null && questOnComplete.length() > 0)
|
||||
{
|
||||
boolean showSystemMessage = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnQuestOnCompleteShowSystemMessage, true);
|
||||
groundquests.grantQuestNoAcceptUI(self, questOnComplete, showSystemMessage);
|
||||
//debugSpeakMsg(self, "Granting new quest from base task");
|
||||
}
|
||||
|
||||
//only tell player things if task is visible
|
||||
if(groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
//maybe show system message
|
||||
groundquests.sendTaskCompletedSystemMessage(questCrc, taskId, self);
|
||||
|
||||
//maybe play music
|
||||
String musicOnComplete = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMusicOnComplete);
|
||||
if(musicOnComplete != null && musicOnComplete.length() > 0)
|
||||
{
|
||||
play2dNonLoopingMusic(self, musicOnComplete);
|
||||
}
|
||||
}
|
||||
|
||||
sendTaskSignals(self, questCrc, taskId, dataTableColumnSignalsOnComplete);
|
||||
|
||||
baseCleanup(self, questCrc, taskId);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
//grant any new quests on task failure
|
||||
String questOnFail = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnQuestOnFail);
|
||||
if(questOnFail != null && questOnFail.length() > 0)
|
||||
{
|
||||
boolean showSystemMessage = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnQuestOnFailShowSystemMessage, true);
|
||||
groundquests.grantQuest(self, questOnFail, showSystemMessage);
|
||||
}
|
||||
|
||||
//only tell player things if task is visible
|
||||
if(groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
//maybe show system message
|
||||
groundquests.sendTaskFailedSystemMessage(questCrc, taskId, self);
|
||||
|
||||
//maybe play music
|
||||
String musicOnFail = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMusicOnFail);
|
||||
if(musicOnFail != null && musicOnFail.length() > 0)
|
||||
{
|
||||
play2dNonLoopingMusic(self, musicOnFail);
|
||||
}
|
||||
}
|
||||
|
||||
sendTaskSignals(self, questCrc, taskId, dataTableColumnSignalsOnFail);
|
||||
|
||||
baseCleanup(self, questCrc, taskId);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// fires when the task is cleared (i.e. canceled)
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
baseCleanup(self, questCrc, taskId);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// cleanup code specific to this task
|
||||
void baseCleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id waypoint = getObjIdObjVar(player, baseObjVar + dot + objvarWaypoint);
|
||||
|
||||
if (isIdValid(waypoint))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "baseCleanup",
|
||||
taskType + " destroying waypoint: " + waypoint);
|
||||
|
||||
destroyWaypointInDatapad(waypoint, player);
|
||||
}
|
||||
|
||||
obj_id entranceWaypoint = getObjIdObjVar(player, baseObjVar + dot + objvarEntranceWaypoint);
|
||||
|
||||
if (isIdValid(entranceWaypoint))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "baseCleanup",
|
||||
taskType + " destroying entranceWaypoint: " + entranceWaypoint);
|
||||
|
||||
destroyWaypointInDatapad(entranceWaypoint, player);
|
||||
}
|
||||
|
||||
// remove entire objvar list
|
||||
removeObjVar(player, baseObjVar);
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void sendTaskSignals(obj_id player, int questCrc, int taskId, string dataTableColumnName)
|
||||
{
|
||||
string signals = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnName);
|
||||
|
||||
if (signals != null && signals.length() > 0)
|
||||
{
|
||||
groundquests.sendSignals(player, split(signals, ','));
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogin()
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ( (tasks != null) && !tasks.isEmpty() )
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
if ( hasObjVar(self, baseObjVar + dot + groundquests.objvarWaypointInActive) )
|
||||
{
|
||||
if ( hasObjVar(self, baseObjVar + dot + groundquests.objvarEntranceWaypoint) )
|
||||
{
|
||||
obj_id entranceWaypoint = getObjIdObjVar(self, baseObjVar + dot + groundquests.objvarEntranceWaypoint);
|
||||
if ( isIdValid(entranceWaypoint) )
|
||||
{
|
||||
groundquests.setQuestWaypointActive(entranceWaypoint, self, baseObjVar);
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasObjVar(self, baseObjVar + dot + groundquests.objvarWaypoint) )
|
||||
{
|
||||
obj_id waypoint = getObjIdObjVar(self, baseObjVar + dot + groundquests.objvarWaypoint);
|
||||
if ( isIdValid(waypoint) )
|
||||
{
|
||||
groundquests.setQuestWaypointActive(waypoint, self, baseObjVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,41 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
|
||||
public class clear_quest extends script.quest.task.ground.base_task
|
||||
{
|
||||
public clear_quest()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "clear_quest";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
questClearQuest(questCrc, self);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
include library.groundquests;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "clear_quest";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
|
||||
questClearQuest(questCrc, self);
|
||||
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,53 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class comm_player extends script.quest.task.ground.base_task
|
||||
{
|
||||
public comm_player()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnCommMessageText = "COMM_MESSAGE_TEXT";
|
||||
public static final String dataTableColumnNPCAppearanceServerTemplate = "NPC_APPEARANCE_SERVER_TEMPLATE";
|
||||
public static final String taskType = "comm_player";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
String message = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCommMessageText);
|
||||
String appearance = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnNPCAppearanceServerTemplate);
|
||||
prose_package pp = new prose_package();
|
||||
pp.stringId = utils.unpackString(message);
|
||||
commPlayer(self, self, pp, appearance);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnCommMessageText = "COMM_MESSAGE_TEXT";
|
||||
const String dataTableColumnNPCAppearanceServerTemplate = "NPC_APPEARANCE_SERVER_TEMPLATE";
|
||||
|
||||
const String taskType = "comm_player";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
//instantly complete
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
|
||||
//gather data for this task
|
||||
String message = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCommMessageText);
|
||||
String appearance = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnNPCAppearanceServerTemplate);
|
||||
|
||||
prose_package pp = new prose_package ();
|
||||
pp.stringId = utils.unpackString(message);
|
||||
|
||||
commPlayer(self, self, pp, appearance);
|
||||
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,41 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
|
||||
public class complete_quest extends script.quest.task.ground.base_task
|
||||
{
|
||||
public complete_quest()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "complete_quest";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
questCompleteQuest(questCrc, self);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
include library.groundquests;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "complete_quest";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
questCompleteQuest(questCrc, self);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,145 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class craft extends script.quest.task.ground.base_task
|
||||
{
|
||||
public craft()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnServerTemplate = "SERVER_OBJECT_TEMPLATE";
|
||||
public static final String dataTableColumnCount = "COUNT";
|
||||
public static final String objvarCount = "count";
|
||||
public static final String dot = ".";
|
||||
public static final String taskType = "craft";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, 0);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:crafting_counter", 0, count);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnCraftedPrototype(obj_id self, obj_id prototypeObject, draft_schematic manufacturingSchematic) throws InterruptedException
|
||||
{
|
||||
int prototypeObjectTemplateCrc = getObjectTemplateCrc(getTemplateName(prototypeObject));
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if (taskObjVarName != null)
|
||||
{
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String craftedObjectTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
int objectTemplateCrc = getObjectTemplateCrc(craftedObjectTemplateName);
|
||||
if (objectTemplateCrc != 0)
|
||||
{
|
||||
if (objectTemplateCrc == prototypeObjectTemplateCrc)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String countObjVar = baseObjVar + dot + objvarCount;
|
||||
int currentCount = getIntObjVar(self, countObjVar);
|
||||
++currentCount;
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
if (currentCount >= count)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnCraftedPrototype", currentCount + "/" + count + " crafted.");
|
||||
setObjVar(self, countObjVar, currentCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:crafting_counter", currentCount, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleClientLogin(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String countObjVar = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, countObjVar))
|
||||
{
|
||||
int currentCount = getIntObjVar(self, countObjVar);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:crafting_counter", 0, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnServerTemplate = "SERVER_OBJECT_TEMPLATE";
|
||||
const String dataTableColumnCount = "COUNT";
|
||||
|
||||
const String objvarCount = "count";
|
||||
const String dot = ".";
|
||||
|
||||
const String taskType = "craft";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, 0);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:crafting_counter", 0, count);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnCraftedPrototype(obj_id prototypeObject, draft_schematic manufacturingSchematic)
|
||||
{
|
||||
int prototypeObjectTemplateCrc = getObjectTemplateCrc(getTemplateName(prototypeObject));
|
||||
|
||||
//get the base objvar for craft quests, all data is under that
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if(taskObjVarName != null)
|
||||
{
|
||||
//get the list of craft quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
//for each craft quest, see if it cares about this object
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are crafting
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
String craftedObjectTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
int objectTemplateCrc = getObjectTemplateCrc(craftedObjectTemplateName);
|
||||
if(objectTemplateCrc != 0)
|
||||
{
|
||||
if(objectTemplateCrc == prototypeObjectTemplateCrc)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String countObjVar = baseObjVar + dot + objvarCount;
|
||||
int currentCount = getIntObjVar(self, countObjVar);
|
||||
++currentCount;
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
if(currentCount >= count)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnCraftedPrototype", currentCount + "/" + count + " crafted.");
|
||||
setObjVar(self, countObjVar, currentCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:crafting_counter", currentCount, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
commandHandler handleClientLogin()
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String countObjVar = baseObjVar + dot + objvarCount;
|
||||
|
||||
if(hasObjVar(self, countObjVar))
|
||||
{
|
||||
int currentCount = getIntObjVar(self, countObjVar);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:crafting_counter", 0, count);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.quests;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
|
||||
public class defend extends script.quest.task.ground.base_task
|
||||
{
|
||||
public defend()
|
||||
{
|
||||
}
|
||||
public static final String OBJVAR_DEFENSE_TARGET = "defend_target";
|
||||
public static final String DEFEND_TARGET = "defendTarget";
|
||||
public static final String QUEST_CRC = "questCrc";
|
||||
public static final String TASK_ID = "taskId";
|
||||
public static final String PLAYER = "player";
|
||||
public static final String OBJVAR_BEEN_WARNED_DISTANCE = "beenWarned";
|
||||
public static final String TASK_TYPE = "defend";
|
||||
public static final String DOT = ".";
|
||||
public static final float DEFEND_DISTANCE_TIME_CHECK = 10;
|
||||
public static final float MAX_ALLOWED_DISTANCE = 40;
|
||||
public static final float CLEANUP_TIME = 120;
|
||||
public static final boolean LOGGING_ON = false;
|
||||
public static final String LOG_CAT = "defense_ground_task";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
blog("OnTaskActivated init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskActivated", TASK_TYPE + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
blog("baseObjVar: " + baseObjVar);
|
||||
if (!hasObjVar(self, OBJVAR_DEFENSE_TARGET))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("has var");
|
||||
obj_id defendTarget = getObjIdObjVar(self, OBJVAR_DEFENSE_TARGET);
|
||||
if (!isValidId(defendTarget) || !exists(defendTarget))
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
blog("defendTarget: " + defendTarget);
|
||||
groundquests.addDestroyNotification(defendTarget, self);
|
||||
setObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET, defendTarget);
|
||||
removeObjVar(self, OBJVAR_DEFENSE_TARGET);
|
||||
dictionary distanceCheckParams = new dictionary();
|
||||
distanceCheckParams.put(PLAYER, self);
|
||||
distanceCheckParams.put(DEFEND_TARGET, defendTarget);
|
||||
distanceCheckParams.put(QUEST_CRC, questCrc);
|
||||
distanceCheckParams.put(TASK_ID, taskId);
|
||||
messageTo(self, "messageDefendCheckDistance", distanceCheckParams, DEFEND_DISTANCE_TIME_CHECK, false);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int destroyNotification(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("destroyNotification init");
|
||||
if (params == null)
|
||||
{
|
||||
blog("destroyNotification params null");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!params.containsKey("source"))
|
||||
{
|
||||
blog("destroyNotification params source NULL");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id source = params.getObjId("source");
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, TASK_TYPE);
|
||||
if (taskObjVarName == null || taskObjVarName.length() <= 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("destroyNotification taskObjVarName: " + taskObjVarName);
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("destroyNotification questList: " + questList);
|
||||
int countQuests = questList.getNumItems();
|
||||
blog("destroyNotification countQuests: " + countQuests);
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + DOT + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String escortTargetObjVarName = questObjVarName + DOT + taskName + DOT + OBJVAR_DEFENSE_TARGET;
|
||||
blog("destroyNotification escortTargetObjVarName: " + escortTargetObjVarName);
|
||||
if (hasObjVar(self, escortTargetObjVarName))
|
||||
{
|
||||
obj_id escortTarget = getObjIdObjVar(self, escortTargetObjVarName);
|
||||
if (source == escortTarget)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
else if (!exists(source) && !exists(escortTarget))
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageDefendCheckDistance(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
blog("messageDefendCheckDistance init");
|
||||
if (params == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!params.containsKey(PLAYER))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!params.containsKey(DEFEND_TARGET))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!params.containsKey(QUEST_CRC))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!params.containsKey(TASK_ID))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("messageDefendCheckDistance contains all keys needed");
|
||||
obj_id player = params.getObjId(PLAYER);
|
||||
obj_id defendTarget = params.getObjId(DEFEND_TARGET);
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
if (questIsTaskActive(questCrc, taskId, player))
|
||||
{
|
||||
blog("messageDefendCheckDistance questIsTaskActive == true");
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
blog("messageDefendCheckDistance baseObjVar: " + baseObjVar);
|
||||
if (isDefenseObjectNearby(questCrc, taskId, player, defendTarget))
|
||||
{
|
||||
blog("messageDefendCheckDistance isDefenseObjectNearby == true");
|
||||
if (hasObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE))
|
||||
{
|
||||
removeObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
blog("messageDefendCheckDistance isDefenseObjectNearby == FALSE");
|
||||
if (hasObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET))
|
||||
{
|
||||
obj_id defendTargetVar = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
if (defendTargetVar != defendTarget)
|
||||
{
|
||||
blog("messageDefendCheckDistance defendTargetVar is NOT the correct object.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("messageDefendCheckDistance defendTargetVar is the correct object.");
|
||||
blog("messageDefendCheckDistance defendTargetVar: " + defendTargetVar);
|
||||
}
|
||||
failDefenseDistanceCheck(player, questCrc, taskId, defendTarget);
|
||||
}
|
||||
messageTo(self, "messageDefendCheckDistance", params, DEFEND_DISTANCE_TIME_CHECK, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean isDefenseObjectNearby(int questCrc, int taskId, obj_id player, obj_id defendTarget) throws InterruptedException
|
||||
{
|
||||
blog("isDefenseObjectNearby init");
|
||||
boolean result = false;
|
||||
if (isIdValid(player) && isIdValid(defendTarget))
|
||||
{
|
||||
blog("isDefenseObjectNearby player and defendTarget are VALID");
|
||||
float distance = getDistance(player, defendTarget);
|
||||
if (distance < 0.0f)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result = distance <= MAX_ALLOWED_DISTANCE;
|
||||
blog("isDefenseObjectNearby DISTANCE: " + getDistance(player, defendTarget));
|
||||
}
|
||||
blog("isDefenseObjectNearby result: " + result);
|
||||
return result;
|
||||
}
|
||||
public void failDefenseDistanceCheck(obj_id player, int questCrc, int taskId, obj_id defenseTarget) throws InterruptedException
|
||||
{
|
||||
blog("failDefenseDistanceCheck init");
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
if (!hasObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE))
|
||||
{
|
||||
setObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE, "true");
|
||||
string_id message = new string_id("quest/groundquests", "static_defense_distance_warning");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
prose.setDF(pp, DEFEND_DISTANCE_TIME_CHECK);
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id("quest/groundquests", "static_defense_failed_due_to_distance");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
sendSystemMessageProse(player, pp);
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
blog("OnTaskCompleted init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskCompleted", TASK_TYPE + " task completed.");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
if (hasObjVar(escort, "questCallBack"))
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questComplete", true);
|
||||
webster.put("player", self);
|
||||
messageTo(escort, "handleQuestCallBack", webster, 0, false);
|
||||
}
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
blog("OnTaskFailed init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskFailed", TASK_TYPE + " task failed.");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
if (hasObjVar(escort, "questCallBack"))
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questComplete", false);
|
||||
webster.put("player", self);
|
||||
messageTo(escort, "handleQuestCallBack", webster, 0, false);
|
||||
}
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
blog("OnTaskCleared init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskCleared", TASK_TYPE + " task cleared.");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
if (hasObjVar(escort, "questCallBack"))
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questComplete", false);
|
||||
webster.put("player", self);
|
||||
messageTo(escort, "handleQuestCallBack", webster, 0, false);
|
||||
}
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
blog("cleanup init");
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
String escortTargetObjVarName = baseObjVar + DOT + OBJVAR_DEFENSE_TARGET;
|
||||
obj_id escortTarget = getObjIdObjVar(player, escortTargetObjVarName);
|
||||
if (escortTarget != null)
|
||||
{
|
||||
removeObjVar(player, escortTargetObjVarName);
|
||||
if (!ai_lib.isAiDead(escortTarget))
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageEscortCleanup", params, CLEANUP_TIME, false);
|
||||
ai_lib.aiStopFollowing(escortTarget);
|
||||
}
|
||||
}
|
||||
groundquests.clearBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
blog("OnLogout init");
|
||||
groundquests.failAllActiveTasksOfType(self, TASK_TYPE);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
blog("OnInitialize init");
|
||||
groundquests.failAllActiveTasksOfType(self, TASK_TYPE);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
blog("OnDetach init");
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, TASK_TYPE));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void blog(String text) throws InterruptedException
|
||||
{
|
||||
if (LOGGING_ON)
|
||||
{
|
||||
LOG(LOG_CAT, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,409 +0,0 @@
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.quests;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const string OBJVAR_DEFENSE_TARGET = "defend_target";
|
||||
const string DEFEND_TARGET = "defendTarget";
|
||||
const string QUEST_CRC = "questCrc";
|
||||
const string TASK_ID = "taskId";
|
||||
const string PLAYER = "player";
|
||||
const string OBJVAR_BEEN_WARNED_DISTANCE = "beenWarned";
|
||||
const string TASK_TYPE = "defend";
|
||||
const string DOT = ".";
|
||||
|
||||
const float DEFEND_DISTANCE_TIME_CHECK = 10;
|
||||
const float MAX_ALLOWED_DISTANCE = 40;
|
||||
const float CLEANUP_TIME = 120;
|
||||
|
||||
const boolean LOGGING_ON = false;
|
||||
const string LOG_CAT = "defense_ground_task";
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
blog("OnTaskActivated init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskActivated", TASK_TYPE + " task activated.");
|
||||
string baseObjVar = groundquests.setBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
blog("baseObjVar: "+baseObjVar);
|
||||
//check the player for the OID of the defense object
|
||||
if(!hasObjVar(self, OBJVAR_DEFENSE_TARGET))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("has var");
|
||||
|
||||
obj_id defendTarget = getObjIdObjVar(self, OBJVAR_DEFENSE_TARGET);
|
||||
if(!isValidId(defendTarget) || !exists(defendTarget))
|
||||
{
|
||||
//fail quest
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
|
||||
blog("defendTarget: "+defendTarget);
|
||||
groundquests.addDestroyNotification(defendTarget, self);
|
||||
setObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET, defendTarget);
|
||||
removeObjVar(self, OBJVAR_DEFENSE_TARGET);
|
||||
//set up first distance check pulse
|
||||
dictionary distanceCheckParams = new dictionary();
|
||||
distanceCheckParams.put(PLAYER, self);
|
||||
distanceCheckParams.put(DEFEND_TARGET, defendTarget);
|
||||
distanceCheckParams.put(QUEST_CRC, questCrc);
|
||||
distanceCheckParams.put(TASK_ID, taskId);
|
||||
messageTo(self, "messageDefendCheckDistance", distanceCheckParams, DEFEND_DISTANCE_TIME_CHECK, false);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler destroyNotification()
|
||||
{
|
||||
blog("destroyNotification init");
|
||||
|
||||
if(params == null)
|
||||
{
|
||||
blog("destroyNotification params null");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!params.containsKey("source"))
|
||||
{
|
||||
blog("destroyNotification params source NULL");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id source = params.getObjId("source");
|
||||
|
||||
//blog("destroyNotification source: "+source);
|
||||
|
||||
//get the base objvar for quests, all data is under that
|
||||
string taskObjVarName = groundquests.getTaskTypeObjVar(self, TASK_TYPE);
|
||||
if(taskObjVarName == null || taskObjVarName.length() <= 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("destroyNotification taskObjVarName: "+taskObjVarName);
|
||||
|
||||
//get the list of quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("destroyNotification questList: "+questList);
|
||||
|
||||
int countQuests = questList.getNumItems();
|
||||
blog("destroyNotification countQuests: "+countQuests);
|
||||
|
||||
//for each quest, check each task
|
||||
for(int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + DOT + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are of the right TASK_TYPE
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
//check the data specific to this task type
|
||||
string escortTargetObjVarName = questObjVarName + DOT + taskName + DOT + OBJVAR_DEFENSE_TARGET;
|
||||
blog("destroyNotification escortTargetObjVarName: "+escortTargetObjVarName);
|
||||
|
||||
if(hasObjVar(self, escortTargetObjVarName))
|
||||
{
|
||||
obj_id escortTarget = getObjIdObjVar(self, escortTargetObjVarName);
|
||||
if(source == escortTarget)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
else if(!exists(source) && !exists(escortTarget))
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageDefendCheckDistance()
|
||||
{
|
||||
blog("messageDefendCheckDistance init");
|
||||
if(params == null)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if(!params.containsKey(PLAYER))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if(!params.containsKey(DEFEND_TARGET))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if(!params.containsKey(QUEST_CRC))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if(!params.containsKey(TASK_ID))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
blog("messageDefendCheckDistance contains all keys needed");
|
||||
obj_id player = params.getObjId(PLAYER);
|
||||
obj_id defendTarget = params.getObjId(DEFEND_TARGET);
|
||||
int questCrc = params.getInt (QUEST_CRC);
|
||||
int taskId = params.getInt (TASK_ID);
|
||||
|
||||
if(questIsTaskActive(questCrc, taskId, player))
|
||||
{
|
||||
blog("messageDefendCheckDistance questIsTaskActive == true");
|
||||
string baseObjVar = groundquests.getBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
blog("messageDefendCheckDistance baseObjVar: "+baseObjVar);
|
||||
if(isDefenseObjectNearby(questCrc, taskId, player, defendTarget))
|
||||
{
|
||||
blog("messageDefendCheckDistance isDefenseObjectNearby == true");
|
||||
|
||||
if(hasObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE))
|
||||
removeObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE);
|
||||
}
|
||||
else
|
||||
{
|
||||
blog("messageDefendCheckDistance isDefenseObjectNearby == FALSE");
|
||||
|
||||
if(hasObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET))
|
||||
{
|
||||
obj_id defendTargetVar = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
if(defendTargetVar != defendTarget)
|
||||
{
|
||||
//unneeded check on old object
|
||||
blog("messageDefendCheckDistance defendTargetVar is NOT the correct object.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
blog("messageDefendCheckDistance defendTargetVar is the correct object.");
|
||||
blog("messageDefendCheckDistance defendTargetVar: "+defendTargetVar);
|
||||
}
|
||||
|
||||
failDefenseDistanceCheck(player, questCrc, taskId, defendTarget);
|
||||
|
||||
}
|
||||
//send message for next pulse
|
||||
//this is not an infinite loop because it checks distance each time, and fails the task if the distance check fails twice in a row
|
||||
messageTo(self, "messageDefendCheckDistance", params, DEFEND_DISTANCE_TIME_CHECK, false);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
boolean isDefenseObjectNearby(int questCrc, int taskId, obj_id player, obj_id defendTarget)
|
||||
{
|
||||
blog("isDefenseObjectNearby init");
|
||||
|
||||
boolean result = false;
|
||||
if(isIdValid(player) && isIdValid(defendTarget))
|
||||
{
|
||||
blog("isDefenseObjectNearby player and defendTarget are VALID");
|
||||
|
||||
float distance = getDistance(player, defendTarget);
|
||||
if(distance < 0.0f)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = distance <= MAX_ALLOWED_DISTANCE;
|
||||
blog("isDefenseObjectNearby DISTANCE: "+getDistance(player, defendTarget));
|
||||
}
|
||||
blog("isDefenseObjectNearby result: "+result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void failDefenseDistanceCheck(obj_id player, int questCrc, int taskId, obj_id defenseTarget)
|
||||
{
|
||||
blog("failDefenseDistanceCheck init");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
if(!hasObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE))
|
||||
{
|
||||
//set objvar and warn player
|
||||
setObjVar(player, baseObjVar + OBJVAR_BEEN_WARNED_DISTANCE, "true");
|
||||
|
||||
string_id message = new string_id ("quest/groundquests", "static_defense_distance_warning");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
prose.setDF(pp, DEFEND_DISTANCE_TIME_CHECK);
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id ("quest/groundquests", "static_defense_failed_due_to_distance");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
sendSystemMessageProse(player, pp);
|
||||
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
blog("OnTaskCompleted init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskCompleted", TASK_TYPE + " task completed.");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
|
||||
if(hasObjVar(escort, "questCallBack"))
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questComplete", true);
|
||||
webster.put("player", self);
|
||||
messageTo(escort, "handleQuestCallBack", webster, 0, false);
|
||||
}
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
blog("OnTaskFailed init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskFailed", TASK_TYPE + " task failed.");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
|
||||
if(hasObjVar(escort, "questCallBack"))
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questComplete", false);
|
||||
webster.put("player", self);
|
||||
messageTo(escort, "handleQuestCallBack", webster, 0, false);
|
||||
}
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
blog("OnTaskCleared init");
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, TASK_TYPE, "OnTaskCleared", TASK_TYPE + " task cleared.");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + DOT + OBJVAR_DEFENSE_TARGET);
|
||||
|
||||
if(hasObjVar(escort, "questCallBack"))
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questComplete", false);
|
||||
webster.put("player", self);
|
||||
messageTo(escort, "handleQuestCallBack", webster, 0, false);
|
||||
}
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
blog("cleanup init");
|
||||
// destroy the escort target
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
String escortTargetObjVarName = baseObjVar + DOT + OBJVAR_DEFENSE_TARGET;
|
||||
|
||||
obj_id escortTarget = getObjIdObjVar(player, escortTargetObjVarName);
|
||||
|
||||
if (escortTarget != null)
|
||||
{
|
||||
removeObjVar(player, escortTargetObjVarName);
|
||||
if(!ai_lib.isAiDead(escortTarget))
|
||||
{
|
||||
//cleanup live escort targets after 2 minutes
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageEscortCleanup", params, CLEANUP_TIME, false);
|
||||
ai_lib.aiStopFollowing(escortTarget);
|
||||
}
|
||||
}
|
||||
|
||||
groundquests.clearBaseObjVar(player, TASK_TYPE, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
blog("OnLogout init");
|
||||
groundquests.failAllActiveTasksOfType(self, TASK_TYPE);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
blog("OnInitialize init");
|
||||
groundquests.failAllActiveTasksOfType(self, TASK_TYPE);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
blog("OnDetach init");
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, TASK_TYPE));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
void blog(string text)
|
||||
{
|
||||
if(LOGGING_ON)
|
||||
{
|
||||
LOG(LOG_CAT, text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.library.groundquests;
|
||||
import script.library.money;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
import script.library.xp;
|
||||
|
||||
public class destroy_multi extends script.quest.task.ground.base_task
|
||||
{
|
||||
public destroy_multi()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "destroy_multiple";
|
||||
public static final String datatableColumnCount = "COUNT";
|
||||
public static final String dot = ".";
|
||||
public static final String objvarCount = "countleft";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, datatableColumnCount);
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, count);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_counter", 0, count);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int receiveCreditForKill(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String killedCreatureType = params.getString("creatureName");
|
||||
String killedCreatureSocialGroup = params.getString("socialGroup");
|
||||
location creatureLoc = params.getLocation("location");
|
||||
float distance = getDistance(self, creatureLoc);
|
||||
if (distance == -1.0f || distance > xp.MAX_DISTANCE)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if (taskObjVarName != null)
|
||||
{
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String requiredRegion = groundquests.getTaskStringDataEntry(questCrc, taskId, "REQUIRED_REGION");
|
||||
boolean regionAcceptable = groundquests.isInNamedRegion(self, requiredRegion);
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, "TARGET_SERVER_TEMPLATE");
|
||||
boolean creatureAcceptable = false;
|
||||
if (creatureType != null && killedCreatureType != null && creatureType.equals(killedCreatureType))
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
String creatureSocialGroup = groundquests.getTaskStringDataEntry(questCrc, taskId, "SOCIAL_GROUP");
|
||||
if (creatureSocialGroup != null && killedCreatureSocialGroup != null && creatureSocialGroup.equals(killedCreatureSocialGroup))
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
if (creatureAcceptable)
|
||||
{
|
||||
if (regionAcceptable)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int killCount = getIntObjVar(self, objvarNameCount);
|
||||
--killCount;
|
||||
if (killCount < 0)
|
||||
{
|
||||
killCount = 0;
|
||||
}
|
||||
int countMax = groundquests.getTaskIntDataEntry(questCrc, taskId, datatableColumnCount);
|
||||
string_id message = new string_id("quest/groundquests", "destroy_multiple_success");
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
prose.setDI(pp, killCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
if (killCount <= 0)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, objvarNameCount, killCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_counter", countMax - killCount, countMax);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
groundquests.playJournalUpdatedMusic(questCrc, taskId, self);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Killed a " + killedCreatureType + ", of social group " + killedCreatureSocialGroup + ", " + killCount + " left.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Killed a " + killedCreatureType + ", of social group " + killedCreatureSocialGroup + ", but not in required region " + requiredRegion + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
int bankCredits = groundquests.getTaskIntDataEntry(questCrc, taskId, "REWARD_CREDITS");
|
||||
if (bankCredits > 0)
|
||||
{
|
||||
money.bankTo(money.ACCT_NEW_PLAYER_QUESTS, self, bankCredits);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", "Deposited " + bankCredits + " credits into the bank.");
|
||||
}
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int handleClientLogin(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int killCount = getIntObjVar(self, objvarNameCount);
|
||||
int countMax = groundquests.getTaskIntDataEntry(questCrc, taskId, "COUNT");
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_counter", countMax - killCount, countMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
include library.ai_lib;
|
||||
include library.groundquests;
|
||||
include library.money;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
include library.xp;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "destroy_multiple";
|
||||
|
||||
const String datatableColumnCount = "COUNT";
|
||||
|
||||
const String dot = ".";
|
||||
const String objvarCount = "countleft";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
//gather data for this task type
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, datatableColumnCount);
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, count);
|
||||
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_counter", 0, count);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler receiveCreditForKill()
|
||||
{
|
||||
string killedCreatureType = params.getString( "creatureName" );
|
||||
string killedCreatureSocialGroup = params.getString( "socialGroup" );
|
||||
location creatureLoc = params.getLocation("location");
|
||||
float distance = getDistance(self, creatureLoc);
|
||||
|
||||
if (distance == -1.0f || distance > xp.MAX_DISTANCE)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
//get the base objvar for quests, all data is under that
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if(taskObjVarName != null)
|
||||
{
|
||||
//get the list of quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
//for each quest, check each task
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are of the right taskType
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
//test for the right region if defined
|
||||
String requiredRegion = groundquests.getTaskStringDataEntry(questCrc, taskId, "REQUIRED_REGION");
|
||||
boolean regionAcceptable = groundquests.isInNamedRegion(self, requiredRegion);
|
||||
|
||||
//test if the creature is correct
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, "TARGET_SERVER_TEMPLATE");
|
||||
boolean creatureAcceptable = false;
|
||||
if(creatureType != null && killedCreatureType != null && creatureType == killedCreatureType)
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
string creatureSocialGroup = groundquests.getTaskStringDataEntry(questCrc, taskId, "SOCIAL_GROUP");
|
||||
if(creatureSocialGroup != null && killedCreatureSocialGroup != null && creatureSocialGroup == killedCreatureSocialGroup)
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
|
||||
if(creatureAcceptable)
|
||||
{
|
||||
if(regionAcceptable)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int killCount = getIntObjVar(self, objvarNameCount);
|
||||
--killCount;
|
||||
if(killCount < 0)
|
||||
killCount = 0;
|
||||
|
||||
int countMax = groundquests.getTaskIntDataEntry(questCrc, taskId, datatableColumnCount);
|
||||
string_id message = new string_id ("quest/groundquests", "destroy_multiple_success");
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
prose.setDI(pp, killCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
|
||||
if(killCount <= 0)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, objvarNameCount, killCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_counter", countMax-killCount, countMax);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
groundquests.playJournalUpdatedMusic(questCrc, taskId, self);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Killed a " + killedCreatureType + ", of social group " + killedCreatureSocialGroup + ", " + killCount + " left.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Killed a " + killedCreatureType + ", of social group " + killedCreatureSocialGroup + ", but not in required region " + requiredRegion + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
|
||||
//give money if appropriate
|
||||
int bankCredits = groundquests.getTaskIntDataEntry(questCrc, taskId, "REWARD_CREDITS");
|
||||
if(bankCredits > 0)
|
||||
{
|
||||
money.bankTo(money.ACCT_NEW_PLAYER_QUESTS, self, bankCredits);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", "Deposited " + bankCredits + " credits into the bank.");
|
||||
}
|
||||
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
commandHandler handleClientLogin()
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int killCount = getIntObjVar(self, objvarNameCount);
|
||||
int countMax = groundquests.getTaskIntDataEntry(questCrc, taskId, "COUNT");
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_counter", countMax-killCount, countMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.library.groundquests;
|
||||
import script.library.money;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
import script.library.xp;
|
||||
|
||||
public class destroy_multi_and_loot extends script.quest.task.ground.base_task
|
||||
{
|
||||
public destroy_multi_and_loot()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "destroy_multiple_and_loot";
|
||||
public static final String dot = ".";
|
||||
public static final String objvarCount = "lootedItems";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_ITEMS_REQUIRED");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, 0);
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_and_loot_counter", 0, count);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int receiveCreditForKill(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String killedCreatureType = params.getString("creatureName");
|
||||
String killedCreatureSocialGroup = params.getString("socialGroup");
|
||||
location creatureLoc = params.getLocation("location");
|
||||
float distance = getDistance(getLocation(self), creatureLoc);
|
||||
if (distance == -1.0f || distance > xp.MAX_DISTANCE)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if (taskObjVarName != null)
|
||||
{
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String requiredRegion = groundquests.getTaskStringDataEntry(questCrc, taskId, "REQUIRED_REGION");
|
||||
boolean regionAcceptable = groundquests.isInNamedRegion(self, requiredRegion);
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, "TARGET_SERVER_TEMPLATE");
|
||||
boolean creatureAcceptable = false;
|
||||
if (creatureType != null && killedCreatureType != null && creatureType.equals(killedCreatureType))
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
String creatureSocialGroup = groundquests.getTaskStringDataEntry(questCrc, taskId, "SOCIAL_GROUP");
|
||||
if (creatureSocialGroup != null && killedCreatureSocialGroup != null && creatureSocialGroup.equals(killedCreatureSocialGroup))
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
if (creatureAcceptable)
|
||||
{
|
||||
if (regionAcceptable)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, "LOOT_ITEM_NAME");
|
||||
int dropPercent = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_DROP_PERCENT");
|
||||
int roll = rand(1, 100);
|
||||
boolean guaranteedSuccess = groundquests.checkForGuaranteedSuccess(self, baseObjVar);
|
||||
if (roll <= dropPercent || guaranteedSuccess)
|
||||
{
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
++lootedCount;
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_ITEMS_REQUIRED");
|
||||
if (lootedCount > itemsTotal)
|
||||
{
|
||||
lootedCount = itemsTotal;
|
||||
}
|
||||
string_id message = new string_id("quest/groundquests", "destroy_multiple_and_loot_success");
|
||||
prose_package pp = prose.getPackage(message, self, self, itemsTotal - lootedCount);
|
||||
prose.setTO(pp, itemName);
|
||||
prose.setDI(pp, itemsTotal - lootedCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
if (lootedCount >= itemsTotal)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, objvarNameCount, lootedCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_and_loot_counter", lootedCount, itemsTotal);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
groundquests.playJournalUpdatedMusic(questCrc, taskId, self);
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Looted " + lootedCount + "/" + itemsTotal + " " + itemName + "(s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id("quest/groundquests", "destroy_multiple_and_loot_fail");
|
||||
prose_package pp = prose.getPackage(message, self, self, 0);
|
||||
prose.setTO(pp, itemName);
|
||||
sendSystemMessageProse(self, pp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Killed a " + killedCreatureType + ", of social group " + killedCreatureSocialGroup + ", but not in required region " + requiredRegion + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
int bankCredits = groundquests.getTaskIntDataEntry(questCrc, taskId, "REWARD_CREDITS");
|
||||
if (bankCredits > 0)
|
||||
{
|
||||
money.bankTo(money.ACCT_NEW_PLAYER_QUESTS, self, bankCredits);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", "Deposited " + bankCredits + " credits into the bank.");
|
||||
}
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int handleClientLogin(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_ITEMS_REQUIRED");
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_and_loot_counter", lootedCount, itemsTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-238
@@ -1,238 +0,0 @@
|
||||
include library.ai_lib;
|
||||
include library.groundquests;
|
||||
include library.money;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
include library.xp;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "destroy_multiple_and_loot";
|
||||
|
||||
const String dot = ".";
|
||||
const String objvarCount = "lootedItems";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
//gather data for this task type
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_ITEMS_REQUIRED");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, 0);
|
||||
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_and_loot_counter", 0, count);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler receiveCreditForKill()
|
||||
{
|
||||
string killedCreatureType = params.getString( "creatureName" );
|
||||
string killedCreatureSocialGroup = params.getString( "socialGroup" );
|
||||
location creatureLoc = params.getLocation("location");
|
||||
float distance = getDistance(getLocation(self), creatureLoc);
|
||||
|
||||
if (distance == -1.0f || distance > xp.MAX_DISTANCE)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
//get the base objvar for quests, all data is under that
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if(taskObjVarName != null)
|
||||
{
|
||||
//get the list of quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
//for each quest, check each task
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are of the right taskType
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
//test for the right region if defined
|
||||
String requiredRegion = groundquests.getTaskStringDataEntry(questCrc, taskId, "REQUIRED_REGION");
|
||||
boolean regionAcceptable = groundquests.isInNamedRegion(self, requiredRegion);
|
||||
|
||||
//test if the creature is correct
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, "TARGET_SERVER_TEMPLATE");
|
||||
boolean creatureAcceptable = false;
|
||||
if(creatureType != null && killedCreatureType != null && creatureType == killedCreatureType)
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
String creatureSocialGroup = groundquests.getTaskStringDataEntry(questCrc, taskId, "SOCIAL_GROUP");
|
||||
if(creatureSocialGroup != null && killedCreatureSocialGroup != null && creatureSocialGroup == killedCreatureSocialGroup)
|
||||
{
|
||||
creatureAcceptable = true;
|
||||
}
|
||||
|
||||
if(creatureAcceptable)
|
||||
{
|
||||
if(regionAcceptable)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, "LOOT_ITEM_NAME");
|
||||
int dropPercent = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_DROP_PERCENT");
|
||||
int roll = rand (1, 100);
|
||||
|
||||
boolean guaranteedSuccess = groundquests.checkForGuaranteedSuccess(self, baseObjVar);
|
||||
|
||||
//if we make the random roll or are given a guaranteed success
|
||||
if(roll <= dropPercent || guaranteedSuccess )
|
||||
{
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
++lootedCount;
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_ITEMS_REQUIRED");
|
||||
|
||||
if(lootedCount > itemsTotal)
|
||||
lootedCount = itemsTotal;
|
||||
|
||||
string_id message = new string_id ("quest/groundquests", "destroy_multiple_and_loot_success");
|
||||
prose_package pp = prose.getPackage(message, self, self, itemsTotal - lootedCount);
|
||||
prose.setTO(pp, itemName);
|
||||
prose.setDI(pp, itemsTotal - lootedCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
|
||||
if(lootedCount >= itemsTotal)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, objvarNameCount, lootedCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_and_loot_counter", lootedCount, itemsTotal);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
groundquests.playJournalUpdatedMusic(questCrc, taskId, self);
|
||||
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Looted " + lootedCount + "/" + itemsTotal + " " + itemName + "(s)");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id ("quest/groundquests", "destroy_multiple_and_loot_fail");
|
||||
prose_package pp = prose.getPackage(message, self, self, 0);
|
||||
prose.setTO(pp, itemName);
|
||||
sendSystemMessageProse(self, pp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "receiveCreditForKill", "Killed a " + killedCreatureType + ", of social group " + killedCreatureSocialGroup + ", but not in required region " + requiredRegion + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
|
||||
//give money if appropriate
|
||||
int bankCredits = groundquests.getTaskIntDataEntry(questCrc, taskId, "REWARD_CREDITS");
|
||||
if(bankCredits > 0)
|
||||
{
|
||||
money.bankTo(money.ACCT_NEW_PLAYER_QUESTS, self, bankCredits);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", "Deposited " + bankCredits + " credits into the bank.");
|
||||
}
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
commandHandler handleClientLogin()
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, "LOOT_ITEMS_REQUIRED");
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:destroy_and_loot_counter", lootedCount, itemsTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.utils;
|
||||
|
||||
public class encounter extends script.quest.task.ground.base_task
|
||||
{
|
||||
public encounter()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnCreatureType = "CREATURE_TYPE";
|
||||
public static final String dataTableColumnCount = "COUNT";
|
||||
public static final String dataTableColumnMinDistance = "MIN_DISTANCE";
|
||||
public static final String dataTableColumnMaxDistance = "MAX_DISTANCE";
|
||||
public static final String dataTableColumnRelativeOffsetX = "RELATIVE_OFFSET_X";
|
||||
public static final String dataTableColumnRelativeOffsetZ = "RELATIVE_OFFSET_Z";
|
||||
public static final String objvarSpawnList = "spawnList";
|
||||
public static final String scriptNameEncounterOnCreature = "quest.task.ground.encounter_on_creature";
|
||||
public static final String objvarOnCreatureOwner = "quest.owner";
|
||||
public static final String objvarOnCreatureQuestCrc = "quest.questCrc";
|
||||
public static final String objvarOnCreatureTaskId = "quest.taskId";
|
||||
public static final String objvarAttackOnSpawn = "quest.attackOnSpawn";
|
||||
public static final String taskType = "encounter";
|
||||
public static final String dot = ".";
|
||||
public static final int cleanupTimeMin = 300;
|
||||
public static final int cleanupTimeMax = 600;
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCreatureType);
|
||||
int minCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnCount);
|
||||
int maxCount = minCount;
|
||||
float minRadius = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinDistance);
|
||||
float maxRadius = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxDistance);
|
||||
String relativeOffsetXString = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnRelativeOffsetX);
|
||||
String relativeOffsetZString = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnRelativeOffsetZ);
|
||||
float relativeOffsetX = 0;
|
||||
float relativeOffsetZ = 0;
|
||||
if (relativeOffsetXString != null)
|
||||
{
|
||||
relativeOffsetX = utils.stringToFloat(relativeOffsetXString);
|
||||
}
|
||||
if (relativeOffsetZString != null)
|
||||
{
|
||||
relativeOffsetZ = utils.stringToFloat(relativeOffsetZString);
|
||||
}
|
||||
Vector spawnList = new Vector();
|
||||
spawnList.setSize(0);
|
||||
spawnList.clear();
|
||||
int count = rand(minCount, maxCount);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
location l = null;
|
||||
location locTest = getLocation(self);
|
||||
if (!isIdValid(locTest.cell))
|
||||
{
|
||||
l = groundquests.getRandom2DLocationAroundLocation(self, relativeOffsetX, relativeOffsetZ, minRadius, maxRadius);
|
||||
}
|
||||
else
|
||||
{
|
||||
String strCell = getCellName(locTest.cell);
|
||||
obj_id objBuilding = getTopMostContainer(self);
|
||||
l = getGoodLocation(objBuilding, strCell);
|
||||
}
|
||||
obj_id creature = create.createCreature(creatureType, l, true);
|
||||
setObjVar(creature, objvarOnCreatureOwner, self);
|
||||
setObjVar(creature, objvarOnCreatureQuestCrc, questCrc);
|
||||
setObjVar(creature, objvarOnCreatureTaskId, taskId);
|
||||
attachScript(creature, scriptNameEncounterOnCreature);
|
||||
if (!hasCondition(creature, CONDITION_CONVERSABLE))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Spawned " + creature + " at [" + l.x + ", " + l.y + ", " + l.z + "] to attack " + self);
|
||||
startCombat(creature, self);
|
||||
}
|
||||
utils.addElement(spawnList, creature);
|
||||
}
|
||||
setObjVar(self, baseObjVar + dot + objvarSpawnList, spawnList);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int messageEncounterTaskCreatureDied(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id creature = params.getObjId("source");
|
||||
int questCrc = params.getInt("questCrc");
|
||||
int taskId = params.getInt("taskId");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String spawnListObjVarName = baseObjVar + dot + objvarSpawnList;
|
||||
if (hasObjVar(self, spawnListObjVarName))
|
||||
{
|
||||
obj_id[] spawnList = getObjIdArrayObjVar(self, spawnListObjVarName);
|
||||
if (spawnList != null)
|
||||
{
|
||||
for (int k = 0; k < spawnList.length; ++k)
|
||||
{
|
||||
obj_id spawn = spawnList[k];
|
||||
if (spawn == creature)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "messageEncounterTaskCreatureDied", "[" + creature + "] being tracked for an encounter task was killed.");
|
||||
if (spawnList.length == 1)
|
||||
{
|
||||
removeObjVar(self, spawnListObjVarName);
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector newSpawnListResizable = new Vector();
|
||||
newSpawnListResizable.setSize(0);
|
||||
for (int l = 0; l < spawnList.length; ++l)
|
||||
{
|
||||
if (spawnList[l] != spawnList[k])
|
||||
{
|
||||
utils.addElement(newSpawnListResizable, spawnList[l]);
|
||||
}
|
||||
}
|
||||
obj_id[] newSpawnList = new obj_id[0];
|
||||
if (newSpawnListResizable != null)
|
||||
{
|
||||
newSpawnList = new obj_id[newSpawnListResizable.size()];
|
||||
newSpawnListResizable.toArray(newSpawnList);
|
||||
}
|
||||
setObjVar(self, spawnListObjVarName, newSpawnList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String taskIdObjVarName = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (taskIdObjVarName != null)
|
||||
{
|
||||
String spawnListObjVarName = taskIdObjVarName + dot + objvarSpawnList;
|
||||
if (hasObjVar(player, spawnListObjVarName))
|
||||
{
|
||||
obj_id[] spawnList = getObjIdArrayObjVar(player, spawnListObjVarName);
|
||||
if (spawnList != null)
|
||||
{
|
||||
for (int k = 0; k < spawnList.length; ++k)
|
||||
{
|
||||
obj_id spawn = spawnList[k];
|
||||
if (!ai_lib.isAiDead(spawn))
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
int cleanupTime = rand(cleanupTimeMin, cleanupTimeMax);
|
||||
messageTo(spawn, "messageEncounterCleanup", params, cleanupTime, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDeath(obj_id self, obj_id killer, obj_id corpseId) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,252 +0,0 @@
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnCreatureType = "CREATURE_TYPE";
|
||||
const String dataTableColumnCount = "COUNT";
|
||||
const String dataTableColumnMinDistance = "MIN_DISTANCE";
|
||||
const String dataTableColumnMaxDistance = "MAX_DISTANCE";
|
||||
|
||||
const String dataTableColumnRelativeOffsetX = "RELATIVE_OFFSET_X";
|
||||
const String dataTableColumnRelativeOffsetZ = "RELATIVE_OFFSET_Z";
|
||||
|
||||
|
||||
const String objvarSpawnList = "spawnList";
|
||||
|
||||
const String scriptNameEncounterOnCreature = "quest.task.ground.encounter_on_creature";
|
||||
|
||||
const String objvarOnCreatureOwner = "quest.owner";
|
||||
const String objvarOnCreatureQuestCrc = "quest.questCrc";
|
||||
const String objvarOnCreatureTaskId = "quest.taskId";
|
||||
const String objvarAttackOnSpawn = "quest.attackOnSpawn";
|
||||
|
||||
const String taskType = "encounter";
|
||||
const String dot = ".";
|
||||
|
||||
const int cleanupTimeMin = 300;
|
||||
const int cleanupTimeMax = 600;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
//gather data for this task
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCreatureType);
|
||||
int minCount = groundquests.getTaskIntDataEntry (questCrc, taskId, dataTableColumnCount);
|
||||
int maxCount = minCount;
|
||||
float minRadius = groundquests.getTaskIntDataEntry (questCrc, taskId, dataTableColumnMinDistance);
|
||||
float maxRadius = groundquests.getTaskIntDataEntry (questCrc, taskId, dataTableColumnMaxDistance);
|
||||
|
||||
String relativeOffsetXString = groundquests.getTaskStringDataEntry (questCrc, taskId, dataTableColumnRelativeOffsetX);
|
||||
String relativeOffsetZString = groundquests.getTaskStringDataEntry (questCrc, taskId, dataTableColumnRelativeOffsetZ);
|
||||
float relativeOffsetX = 0;
|
||||
float relativeOffsetZ = 0;
|
||||
if(relativeOffsetXString != null)
|
||||
relativeOffsetX = utils.stringToFloat(relativeOffsetXString);
|
||||
if(relativeOffsetZString != null)
|
||||
relativeOffsetZ = utils.stringToFloat(relativeOffsetZString);
|
||||
|
||||
resizeable obj_id[] spawnList = new obj_id[0];
|
||||
spawnList.clear();
|
||||
|
||||
int count = rand(minCount, maxCount);
|
||||
for(int i = 0; i < count; ++i)
|
||||
{
|
||||
location l = null;
|
||||
location locTest = getLocation(self);
|
||||
|
||||
if(!isIdValid(locTest.cell))
|
||||
{
|
||||
l = groundquests.getRandom2DLocationAroundLocation(self, relativeOffsetX, relativeOffsetZ, minRadius, maxRadius);
|
||||
//sendSystemMessageTestingOnly(self, "Making an npc at location "+l);
|
||||
// in the world!
|
||||
}
|
||||
else
|
||||
{
|
||||
// BLDG!@!
|
||||
string strCell = getCellName(locTest.cell);
|
||||
obj_id objBuilding = getTopMostContainer(self);
|
||||
l = getGoodLocation(objBuilding, strCell);
|
||||
//sendSystemMessageTestingOnly(self, "Making an npc in "+objBuilding+" at location "+l);
|
||||
}
|
||||
|
||||
obj_id creature = create.createCreature(creatureType, l, true);
|
||||
setObjVar(creature, objvarOnCreatureOwner, self);
|
||||
setObjVar(creature, objvarOnCreatureQuestCrc, questCrc);
|
||||
setObjVar(creature, objvarOnCreatureTaskId, taskId);
|
||||
attachScript(creature, scriptNameEncounterOnCreature);
|
||||
|
||||
// if we can be talked to, that probably means we shouldn't be attacking.
|
||||
if(!hasCondition(creature, CONDITION_CONVERSABLE))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Spawned " + creature + " at [" + l.x + ", " + l.y + ", " + l.z + "] to attack " + self);
|
||||
startCombat(creature, self);
|
||||
}
|
||||
|
||||
|
||||
//put on spawn list, track kills so that they get removed eventually
|
||||
utils.addElement(spawnList, creature);
|
||||
}
|
||||
|
||||
setObjVar(self, baseObjVar + dot + objvarSpawnList, spawnList);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageEncounterTaskCreatureDied()
|
||||
{
|
||||
obj_id creature = params.getObjId("source");
|
||||
int questCrc = params.getInt ("questCrc");
|
||||
int taskId = params.getInt ("taskId");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String spawnListObjVarName = baseObjVar + dot + objvarSpawnList;
|
||||
if(hasObjVar(self, spawnListObjVarName))
|
||||
{
|
||||
obj_id[] spawnList = getObjIdArrayObjVar(self, spawnListObjVarName);
|
||||
if(spawnList != null)
|
||||
{
|
||||
for(int k = 0; k < spawnList.length; ++k)
|
||||
{
|
||||
obj_id spawn = spawnList[k];
|
||||
if(spawn == creature)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "messageEncounterTaskCreatureDied", "[" + creature + "] being tracked for an encounter task was killed.");
|
||||
|
||||
if(spawnList.length == 1)
|
||||
{
|
||||
removeObjVar(self, spawnListObjVarName);
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
resizeable obj_id[] newSpawnListResizable = new obj_id[0];
|
||||
for(int l = 0; l < spawnList.length; ++l)
|
||||
{
|
||||
if(spawnList[l] != spawnList[k])
|
||||
{
|
||||
utils.addElement(newSpawnListResizable, spawnList[l]);
|
||||
}
|
||||
}
|
||||
obj_id[] newSpawnList = newSpawnListResizable;
|
||||
setObjVar(self, spawnListObjVarName, newSpawnList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
//cleanup the creatures that still exist
|
||||
String taskIdObjVarName = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if(taskIdObjVarName != null)
|
||||
{
|
||||
String spawnListObjVarName = taskIdObjVarName + dot + objvarSpawnList;
|
||||
if(hasObjVar(player, spawnListObjVarName))
|
||||
{
|
||||
obj_id[] spawnList = getObjIdArrayObjVar(player, spawnListObjVarName);
|
||||
if(spawnList != null)
|
||||
{
|
||||
for(int k = 0; k < spawnList.length; ++k)
|
||||
{
|
||||
obj_id spawn = spawnList[k];
|
||||
if(!ai_lib.isAiDead(spawn))
|
||||
{
|
||||
//cleanup live encounter targets after a few minutes
|
||||
dictionary params = new dictionary();
|
||||
int cleanupTime = rand(cleanupTimeMin, cleanupTimeMax);
|
||||
messageTo(spawn, "messageEncounterCleanup", params, cleanupTime, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDeath(obj_id killer, obj_id corpseId)
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,116 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.utils;
|
||||
import script.library.groundquests;
|
||||
|
||||
public class encounter_on_creature extends script.base_script
|
||||
{
|
||||
public encounter_on_creature()
|
||||
{
|
||||
}
|
||||
public static final String objvarOnCreatureOwner = "quest.owner";
|
||||
public static final String objvarOnCreatureQuestCrc = "quest.questCrc";
|
||||
public static final String objvarOnCreatureTaskId = "quest.taskId";
|
||||
public static final String objvarAttackOnSpawn = "quest.attackOnSpawn";
|
||||
public static final String scriptVarNumAttempts = "quest.encounterOnCreaturePathCheck";
|
||||
public static final String objvarOnCreatureStartLocation = "quest.startLocation";
|
||||
public static final String objvarOnCreatureStartDistanceToPlayer = "quest.startDistanceToPlayer";
|
||||
public static final String taskType = "encounter";
|
||||
public static float combatDistance = 64;
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
location currentLocation = getLocation(self);
|
||||
location playerLocation = getLocation(player);
|
||||
float distanceToPlayer = currentLocation.distance(playerLocation);
|
||||
setObjVar(self, objvarOnCreatureStartLocation, currentLocation);
|
||||
setObjVar(self, objvarOnCreatureStartDistanceToPlayer, distanceToPlayer);
|
||||
dictionary params = new dictionary();
|
||||
messageTo(self, "messageEncounterTaskCheckCreatureDistance", params, 15, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageEncounterTaskCheckCreatureDistance(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
location currentLocation = getLocation(self);
|
||||
location playerLocation = getLocation(player);
|
||||
float distanceToPlayer = currentLocation.distance(playerLocation);
|
||||
boolean isDead = ai_lib.isAiDead(self);
|
||||
if (isDead)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
boolean isConversing = hasCondition(self, CONDITION_CONVERSABLE);
|
||||
int numTries = 0;
|
||||
if (utils.hasScriptVar(self, scriptVarNumAttempts))
|
||||
{
|
||||
numTries = utils.getIntScriptVar(self, scriptVarNumAttempts);
|
||||
}
|
||||
if ((distanceToPlayer > combatDistance) || distanceToPlayer == -1)
|
||||
{
|
||||
location startLocation = getLocationObjVar(self, objvarOnCreatureStartLocation);
|
||||
float startDistanceToPlayer = getFloatObjVar(self, objvarOnCreatureStartDistanceToPlayer);
|
||||
if (startDistanceToPlayer < .1f)
|
||||
{
|
||||
startDistanceToPlayer = .1f;
|
||||
}
|
||||
float distanceTraveled = startLocation.distance(currentLocation);
|
||||
if ((distanceTraveled == 0) || (distanceToPlayer / startDistanceToPlayer > 0.9))
|
||||
{
|
||||
int questCrc = getIntObjVar(self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar(self, objvarOnCreatureTaskId);
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "messageEncounterTaskCheckCreatureDistance", "[" + self + "] not closing on player [" + player + "], warping to player location.");
|
||||
setLocation(self, playerLocation);
|
||||
if (!isConversing)
|
||||
{
|
||||
startCombat(self, player);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
if (!isConversing)
|
||||
{
|
||||
startCombat(self, player);
|
||||
}
|
||||
setObjVar(self, objvarOnCreatureStartLocation, currentLocation);
|
||||
setObjVar(self, objvarOnCreatureStartDistanceToPlayer, distanceToPlayer);
|
||||
numTries++;
|
||||
utils.setScriptVar(self, scriptVarNumAttempts, numTries);
|
||||
dictionary paramsOut = new dictionary();
|
||||
if (numTries < 4)
|
||||
{
|
||||
messageTo(self, "messageEncounterTaskCheckCreatureDistance", paramsOut, 15, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDeath(obj_id self, obj_id killer, obj_id corpseId) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, objvarOnCreatureOwner) && hasObjVar(self, objvarOnCreatureQuestCrc) && hasObjVar(self, objvarOnCreatureTaskId))
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar(self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar(self, objvarOnCreatureTaskId);
|
||||
dictionary params = new dictionary();
|
||||
params.put("source", self);
|
||||
params.put("questCrc", questCrc);
|
||||
params.put("taskId", taskId);
|
||||
messageTo(player, "messageEncounterTaskCreatureDied", params, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageEncounterCleanup(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
// This script goes on a creature spawned by the encounter quest task type.
|
||||
// It messages the player when the creature is killed.
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.utils;
|
||||
include library.groundquests;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String objvarOnCreatureOwner = "quest.owner";
|
||||
const String objvarOnCreatureQuestCrc = "quest.questCrc";
|
||||
const String objvarOnCreatureTaskId = "quest.taskId";
|
||||
const String objvarAttackOnSpawn = "quest.attackOnSpawn";
|
||||
|
||||
const String scriptVarNumAttempts = "quest.encounterOnCreaturePathCheck";
|
||||
|
||||
const String objvarOnCreatureStartLocation = "quest.startLocation";
|
||||
const String objvarOnCreatureStartDistanceToPlayer = "quest.startDistanceToPlayer";
|
||||
|
||||
const String taskType = "encounter";
|
||||
|
||||
float combatDistance = 64;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
location currentLocation = getLocation(self);
|
||||
location playerLocation = getLocation(player);
|
||||
float distanceToPlayer = currentLocation.distance(playerLocation);
|
||||
setObjVar(self, objvarOnCreatureStartLocation, currentLocation);
|
||||
setObjVar(self, objvarOnCreatureStartDistanceToPlayer, distanceToPlayer);
|
||||
|
||||
dictionary params = new dictionary();
|
||||
messageTo(self, "messageEncounterTaskCheckCreatureDistance", params, 15, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageEncounterTaskCheckCreatureDistance()
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
location currentLocation = getLocation(self);
|
||||
location playerLocation = getLocation(player);
|
||||
float distanceToPlayer = currentLocation.distance(playerLocation);
|
||||
boolean isDead = ai_lib.isAiDead(self);
|
||||
if (isDead)
|
||||
return SCRIPT_CONTINUE; // we're dead, no need to keep checking
|
||||
|
||||
boolean isConversing = hasCondition(self, CONDITION_CONVERSABLE);
|
||||
|
||||
int numTries = 0;
|
||||
if (utils.hasScriptVar(self, scriptVarNumAttempts))
|
||||
numTries = utils.getIntScriptVar(self, scriptVarNumAttempts);
|
||||
|
||||
// only do a teleport if we can't path to the player.
|
||||
if((distanceToPlayer > combatDistance) || distanceToPlayer == -1)
|
||||
{
|
||||
location startLocation = getLocationObjVar(self, objvarOnCreatureStartLocation);
|
||||
float startDistanceToPlayer = getFloatObjVar(self, objvarOnCreatureStartDistanceToPlayer);
|
||||
if (startDistanceToPlayer < .1f)
|
||||
startDistanceToPlayer = .1f;
|
||||
float distanceTraveled = startLocation.distance(currentLocation);
|
||||
//warp the creature to the player if
|
||||
//1: creature is in a different area, or
|
||||
//2: they can't move, or
|
||||
//3: they've gone in the wrong direction, or
|
||||
//4: they haven't moved at least 10% of the distance to the player
|
||||
if((distanceTraveled == 0) || (distanceToPlayer/startDistanceToPlayer > 0.9))
|
||||
{
|
||||
int questCrc = getIntObjVar(self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar(self, objvarOnCreatureTaskId);
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "messageEncounterTaskCheckCreatureDistance", "[" + self + "] not closing on player [" + player + "], warping to player location.");
|
||||
setLocation(self, playerLocation);
|
||||
if(!isConversing)
|
||||
{
|
||||
startCombat(self, player);
|
||||
}
|
||||
|
||||
// only teleport once.
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
//re-aggro if necessary
|
||||
if(!isConversing)
|
||||
{
|
||||
startCombat(self, player);
|
||||
}
|
||||
|
||||
setObjVar(self, objvarOnCreatureStartLocation, currentLocation);
|
||||
setObjVar(self, objvarOnCreatureStartDistanceToPlayer, distanceToPlayer);
|
||||
|
||||
// increase number of tries. We only want to do this 4 times total.
|
||||
numTries++;
|
||||
utils.setScriptVar(self, scriptVarNumAttempts, numTries);
|
||||
dictionary paramsOut = new dictionary();
|
||||
if( numTries < 4 )
|
||||
messageTo(self, "messageEncounterTaskCheckCreatureDistance", paramsOut, 15, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDeath(obj_id killer, obj_id corpseId)
|
||||
{
|
||||
if(hasObjVar(self, objvarOnCreatureOwner) && hasObjVar(self, objvarOnCreatureQuestCrc) && hasObjVar(self, objvarOnCreatureTaskId))
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar (self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar (self, objvarOnCreatureTaskId);
|
||||
dictionary params = new dictionary();
|
||||
params.put("source", self);
|
||||
params.put("questCrc", questCrc);
|
||||
params.put("taskId", taskId);
|
||||
|
||||
messageTo(player, "messageEncounterTaskCreatureDied", params, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageEncounterCleanup()
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,217 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.quests;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
|
||||
public class escort extends script.quest.task.ground.base_task
|
||||
{
|
||||
public escort()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
public static final String dataTableColumnDestinationNodeName = "DESTINATION_NODE_NAME";
|
||||
public static final String dataTableColumnMovementType = "MOVEMENT_TYPE";
|
||||
public static final String objvarEscortTarget = "target";
|
||||
public static final String objvarBeenWarnedDistance = "beenWarned";
|
||||
public static final String scriptNameEscortOnTarget = "quest.task.ground.escort_on_target";
|
||||
public static final String taskType = "escort";
|
||||
public static final String dot = ".";
|
||||
public static final float escortDistanceTimeCheck = 10;
|
||||
public static final float maximumAllowedDistance = 25;
|
||||
public static final float cleanupTime = 120;
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String serverTemplate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
String destinationNodeName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnDestinationNodeName);
|
||||
String movementType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMovementType);
|
||||
location l = groundquests.getRandom2DLocationAroundPlayer(self, 5, 15);
|
||||
obj_id escortTarget = create.createCreature(serverTemplate, l, true);
|
||||
attachScript(escortTarget, scriptNameEscortOnTarget);
|
||||
setMaster(escortTarget, self);
|
||||
ai_lib.aiFollow(escortTarget, self, 1.0f, 8.0f);
|
||||
groundquests.addDestroyNotification(escortTarget, self);
|
||||
setObjVar(self, baseObjVar + dot + objvarEscortTarget, escortTarget);
|
||||
dictionary distanceCheckParams = new dictionary();
|
||||
distanceCheckParams.put("player", self);
|
||||
distanceCheckParams.put("escortTarget", escortTarget);
|
||||
distanceCheckParams.put("questCrc", questCrc);
|
||||
distanceCheckParams.put("taskId", taskId);
|
||||
messageTo(self, "messageEscortCheckDistance", distanceCheckParams, escortDistanceTimeCheck, false);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int destroyNotification(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if (taskObjVarName != null)
|
||||
{
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String escortTargetObjVarName = questObjVarName + dot + taskName + dot + objvarEscortTarget;
|
||||
if (hasObjVar(self, escortTargetObjVarName))
|
||||
{
|
||||
obj_id escortTarget = getObjIdObjVar(self, escortTargetObjVarName);
|
||||
if (source == escortTarget)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageEscortCheckDistance(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id player = params.getObjId("player");
|
||||
obj_id escortTarget = params.getObjId("escortTarget");
|
||||
int questCrc = params.getInt("questCrc");
|
||||
int taskId = params.getInt("taskId");
|
||||
if (questIsTaskActive(questCrc, taskId, player))
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (isEscortNearby(questCrc, taskId, player, escortTarget))
|
||||
{
|
||||
if (hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
{
|
||||
removeObjVar(player, baseObjVar + objvarBeenWarnedDistance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
failEscortDistanceCheck(player, questCrc, taskId, escortTarget);
|
||||
}
|
||||
ai_lib.aiFollow(escortTarget, self, 1.0f, 8.0f);
|
||||
messageTo(self, "messageEscortCheckDistance", params, escortDistanceTimeCheck, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean isEscortNearby(int questCrc, int taskId, obj_id player, obj_id escortTarget) throws InterruptedException
|
||||
{
|
||||
boolean result = false;
|
||||
if (isIdValid(player) && isIdValid(escortTarget))
|
||||
{
|
||||
result = getDistance(player, escortTarget) <= maximumAllowedDistance;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public void failEscortDistanceCheck(obj_id player, int questCrc, int taskId, obj_id escortTarget) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (!hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
{
|
||||
setObjVar(player, baseObjVar + objvarBeenWarnedDistance, "true");
|
||||
string_id message = new string_id("quest/groundquests", "static_escort_distance_warning");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
prose.setDF(pp, escortDistanceTimeCheck);
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id("quest/groundquests", "static_escort_failed_due_to_distance");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
sendSystemMessageProse(player, pp);
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
ai_lib.aiStopFollowing(escort);
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
ai_lib.aiStopFollowing(escort);
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
ai_lib.aiStopFollowing(escort);
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String escortTargetObjVarName = baseObjVar + dot + objvarEscortTarget;
|
||||
obj_id escortTarget = getObjIdObjVar(player, escortTargetObjVarName);
|
||||
if (escortTarget != null)
|
||||
{
|
||||
removeObjVar(player, escortTargetObjVarName);
|
||||
if (!ai_lib.isAiDead(escortTarget))
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageEscortCleanup", params, cleanupTime, false);
|
||||
ai_lib.aiStopFollowing(escortTarget);
|
||||
}
|
||||
}
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.quests;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
const String dataTableColumnDestinationNodeName = "DESTINATION_NODE_NAME";
|
||||
const String dataTableColumnMovementType = "MOVEMENT_TYPE";
|
||||
|
||||
const String objvarEscortTarget = "target";
|
||||
const String objvarBeenWarnedDistance = "beenWarned";
|
||||
|
||||
const String scriptNameEscortOnTarget = "quest.task.ground.escort_on_target";
|
||||
|
||||
const String taskType = "escort";
|
||||
const String dot = ".";
|
||||
|
||||
const float escortDistanceTimeCheck = 10;
|
||||
const float maximumAllowedDistance = 25;
|
||||
const float cleanupTime = 120;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
//gather data for this task
|
||||
String serverTemplate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
String destinationNodeName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnDestinationNodeName);
|
||||
String movementType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMovementType);
|
||||
|
||||
location l = groundquests.getRandom2DLocationAroundPlayer(self, 5, 15);
|
||||
obj_id escortTarget = create.createCreature(serverTemplate, l, true);
|
||||
attachScript(escortTarget, scriptNameEscortOnTarget);
|
||||
|
||||
setMaster(escortTarget, self);
|
||||
ai_lib.aiFollow(escortTarget, self, 1.0f, 8.0f);
|
||||
|
||||
groundquests.addDestroyNotification(escortTarget, self);
|
||||
|
||||
setObjVar(self, baseObjVar + dot + objvarEscortTarget, escortTarget);
|
||||
|
||||
//set up first distance check pulse
|
||||
dictionary distanceCheckParams = new dictionary();
|
||||
distanceCheckParams.put("player", self);
|
||||
distanceCheckParams.put("escortTarget", escortTarget);
|
||||
distanceCheckParams.put("questCrc", questCrc);
|
||||
distanceCheckParams.put("taskId", taskId);
|
||||
messageTo(self, "messageEscortCheckDistance", distanceCheckParams, escortDistanceTimeCheck, false);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler destroyNotification()
|
||||
{
|
||||
if(params != null)
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
|
||||
//get the base objvar for quests, all data is under that
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if(taskObjVarName != null)
|
||||
{
|
||||
//get the list of quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
//for each quest, check each task
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are of the right taskType
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
//check the data specific to this task type
|
||||
String escortTargetObjVarName = questObjVarName + dot + taskName + dot + objvarEscortTarget;
|
||||
if(hasObjVar(self, escortTargetObjVarName))
|
||||
{
|
||||
obj_id escortTarget = getObjIdObjVar(self, escortTargetObjVarName);
|
||||
if(source == escortTarget)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageEscortCheckDistance()
|
||||
{
|
||||
obj_id player = params.getObjId("player");
|
||||
obj_id escortTarget = params.getObjId("escortTarget");
|
||||
int questCrc = params.getInt ("questCrc");
|
||||
int taskId = params.getInt ("taskId");
|
||||
|
||||
if ( questIsTaskActive(questCrc, taskId, player) )
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if(isEscortNearby(questCrc, taskId, player, escortTarget))
|
||||
{
|
||||
if(hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
removeObjVar(player, baseObjVar + objvarBeenWarnedDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
failEscortDistanceCheck(player, questCrc, taskId, escortTarget);
|
||||
}
|
||||
|
||||
//re-set follow, this is necessary since going incap causes follow to break. This ensures that they'll re-follow you (after up to escortDistanceTimeCheck seconds)
|
||||
ai_lib.aiFollow(escortTarget, self, 1.0f, 8.0f);
|
||||
//send message for next pulse
|
||||
//this is not an infinite loop because it checks distance each time, and fails the task if the distance check fails twice in a row
|
||||
messageTo(self, "messageEscortCheckDistance", params, escortDistanceTimeCheck, false);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
boolean isEscortNearby(int questCrc, int taskId, obj_id player, obj_id escortTarget)
|
||||
{
|
||||
boolean result = false;
|
||||
if(isIdValid(player) && isIdValid(escortTarget))
|
||||
{
|
||||
result = getDistance(player, escortTarget) <= maximumAllowedDistance;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void failEscortDistanceCheck(obj_id player, int questCrc, int taskId, obj_id escortTarget)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if(!hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
{
|
||||
//set objvar and warn player
|
||||
setObjVar(player, baseObjVar + objvarBeenWarnedDistance, "true");
|
||||
|
||||
string_id message = new string_id ("quest/groundquests", "static_escort_distance_warning");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
prose.setDF(pp, escortDistanceTimeCheck);
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id ("quest/groundquests", "static_escort_failed_due_to_distance");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
sendSystemMessageProse(player, pp);
|
||||
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
|
||||
ai_lib.aiStopFollowing(escort);
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
|
||||
ai_lib.aiStopFollowing(escort);
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escort = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
|
||||
ai_lib.aiStopFollowing(escort);
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
// destroy the escort target
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String escortTargetObjVarName = baseObjVar + dot + objvarEscortTarget;
|
||||
|
||||
obj_id escortTarget = getObjIdObjVar(player, escortTargetObjVarName);
|
||||
|
||||
if (escortTarget != null)
|
||||
{
|
||||
removeObjVar(player, escortTargetObjVarName);
|
||||
if(!ai_lib.isAiDead(escortTarget))
|
||||
{
|
||||
//cleanup live escort targets after 2 minutes
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageEscortCleanup", params, cleanupTime, false);
|
||||
ai_lib.aiStopFollowing(escortTarget);
|
||||
}
|
||||
}
|
||||
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,21 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
public class escort_on_target extends script.base_script
|
||||
{
|
||||
public escort_on_target()
|
||||
{
|
||||
}
|
||||
public int messageEscortCleanup(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageEscortCleanup()
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,232 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.prose;
|
||||
import script.library.static_item;
|
||||
import script.library.travel;
|
||||
import script.library.utils;
|
||||
|
||||
public class give_item extends script.quest.task.ground.base_task
|
||||
{
|
||||
public give_item()
|
||||
{
|
||||
}
|
||||
public static final String dataTableNumToGive = "NUM_TO_GIVE";
|
||||
public static final String dataTableItemToGive = "ITEM_TO_GIVE";
|
||||
public static final String dataTableCreateItem = "CREATE_ITEM";
|
||||
public static final String dataTableDestroyItem = "DESTROY_ITEM";
|
||||
public static final String dataTableFailOnLogout = "FAIL_ON_LOGOUT";
|
||||
public static final String dataTableTravelBlock = "TRAVEL_BLOCK";
|
||||
public static final String dataTableTravelBlockAllowLaunch = "TRAVEL_BLOCK_ALLOW_LAUNCH";
|
||||
public static final String dataTableTextType = "TEXT_TYPE";
|
||||
public static final String objVarCount = "count";
|
||||
public static final String objVarCreatedItem = "createdItem";
|
||||
public static final String taskType = "give_item";
|
||||
public static final int textGive = 0;
|
||||
public static final int textDeliver = 1;
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableNumToGive);
|
||||
setObjVar(self, baseObjVar + "." + objVarCount, count);
|
||||
int textType = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableTextType));
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, getCounterText(textType), 0, count);
|
||||
boolean createItem = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableCreateItem, false);
|
||||
if (createItem)
|
||||
{
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableItemToGive);
|
||||
if (itemName != null && itemName.length() > 0)
|
||||
{
|
||||
itemName = split(itemName, ',')[0];
|
||||
if (itemName != null && itemName.length() > 0)
|
||||
{
|
||||
obj_id newItem;
|
||||
if (static_item.isStaticItem(itemName))
|
||||
{
|
||||
newItem = static_item.createNewItemFunction(itemName, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
newItem = createObjectInInventoryAllowOverload(itemName, self);
|
||||
}
|
||||
if (isValidId(newItem))
|
||||
{
|
||||
groundquests.sendPlacedInInventorySystemMessage(self, newItem, itemName);
|
||||
CustomerServiceLog("QUEST", self + " given item '" + itemName + "' (" + newItem + ")");
|
||||
setObjVar(self, baseObjVar + "." + objVarCreatedItem, newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean travelBlock = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableTravelBlock, false);
|
||||
if (travelBlock)
|
||||
{
|
||||
boolean allowLaunch = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableTravelBlockAllowLaunch, false);
|
||||
travel.setTravelBlock(self, allowLaunch);
|
||||
}
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int itemGivenToNpc(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
String questName = params.getString("questName");
|
||||
String taskName = params.getString("taskName");
|
||||
String itemName = params.getString("itemName");
|
||||
groundquests.questOutputDebugLog(taskType, "giveItem", "start");
|
||||
int questCrc = groundquests.getQuestIdFromString(questName);
|
||||
int taskId = groundquests.getTaskId(questCrc, taskName);
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
String item = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableItemToGive);
|
||||
if (item != null && item.length() > 0)
|
||||
{
|
||||
String[] itemsNeeded = split(item, ',');
|
||||
int textType = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableTextType));
|
||||
for (int i = 0; i < itemsNeeded.length; ++i)
|
||||
{
|
||||
if (itemsNeeded[i] != null && itemsNeeded[i].equals(itemName))
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + "." + objVarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int giveCount = getIntObjVar(self, objvarNameCount);
|
||||
--giveCount;
|
||||
if (giveCount < 0)
|
||||
{
|
||||
giveCount = 0;
|
||||
}
|
||||
int countMax = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableNumToGive);
|
||||
string_id message = new string_id("quest/groundquests", getMultipleSuccessTextKey(textType));
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
prose.setDI(pp, giveCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
if (giveCount <= 0)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, objvarNameCount, giveCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, getCounterText(textType), countMax - giveCount, countMax);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "itemGivenToNpc", "Gave a " + itemName + ", " + giveCount + " left.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
failIfFailOnLogout(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
failIfFailOnLogout(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.setBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (hasObjVar(player, baseObjVar + "." + objVarCreatedItem))
|
||||
{
|
||||
obj_id createdItem = getObjIdObjVar(player, baseObjVar + "." + objVarCreatedItem);
|
||||
if (isIdValid(createdItem) && exists(createdItem))
|
||||
{
|
||||
boolean destroyItem = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableDestroyItem, false);
|
||||
if (destroyItem)
|
||||
{
|
||||
groundquests.sendRemovedFromInventorySystemMessage(player, createdItem);
|
||||
destroyObject(createdItem);
|
||||
CustomerServiceLog("QUEST", player + " destroyed item (" + createdItem + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean travelBlock = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableTravelBlock, false);
|
||||
if (travelBlock)
|
||||
{
|
||||
travel.clearTravelBlock(player);
|
||||
}
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void failIfFailOnLogout(obj_id player) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, taskType);
|
||||
if (tasks != null && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
boolean shouldFailOnLogout = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableFailOnLogout, false);
|
||||
if (shouldFailOnLogout)
|
||||
{
|
||||
LOG("QUEST_LOG", "Quest task failed due to log out.");
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public String getCounterText(int textType) throws InterruptedException
|
||||
{
|
||||
switch (textType)
|
||||
{
|
||||
case textDeliver:
|
||||
return "quest/groundquests:deliver_counter";
|
||||
case textGive:
|
||||
default:
|
||||
return "quest/groundquests:give_counter";
|
||||
}
|
||||
}
|
||||
public String getMultipleSuccessTextKey(int textType) throws InterruptedException
|
||||
{
|
||||
switch (textType)
|
||||
{
|
||||
case textDeliver:
|
||||
return "deliver_to_npc_multiple_success";
|
||||
case textGive:
|
||||
default:
|
||||
return "give_item_to_npc_multiple_success";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.prose;
|
||||
include library.static_item;
|
||||
include library.travel;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const string dataTableNumToGive = "NUM_TO_GIVE";
|
||||
const string dataTableItemToGive = "ITEM_TO_GIVE";
|
||||
const string dataTableCreateItem = "CREATE_ITEM";
|
||||
const string dataTableDestroyItem = "DESTROY_ITEM";
|
||||
const string dataTableFailOnLogout = "FAIL_ON_LOGOUT";
|
||||
const string dataTableTravelBlock = "TRAVEL_BLOCK";
|
||||
const string dataTableTravelBlockAllowLaunch = "TRAVEL_BLOCK_ALLOW_LAUNCH";
|
||||
const string dataTableTextType = "TEXT_TYPE";
|
||||
|
||||
const string objVarCount = "count";
|
||||
const string objVarCreatedItem = "createdItem";
|
||||
|
||||
const string taskType = "give_item";
|
||||
|
||||
const int textGive = 0;
|
||||
const int textDeliver = 1;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableNumToGive);
|
||||
setObjVar (self, baseObjVar + "." + objVarCount, count);
|
||||
|
||||
int textType = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableTextType));
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, getCounterText(textType), 0, count);
|
||||
|
||||
boolean createItem = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableCreateItem, false);
|
||||
|
||||
if (createItem)
|
||||
{
|
||||
string itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableItemToGive);
|
||||
|
||||
if (itemName != null && itemName.length() > 0)
|
||||
{
|
||||
itemName = split(itemName, ',')[0];
|
||||
|
||||
if (itemName != null && itemName.length() > 0)
|
||||
{
|
||||
obj_id newItem;
|
||||
|
||||
if (static_item.isStaticItem(itemName))
|
||||
newItem = static_item.createNewItemFunction(itemName, self);
|
||||
else
|
||||
newItem = createObjectInInventoryAllowOverload(itemName, self);
|
||||
|
||||
if (isValidId(newItem))
|
||||
{
|
||||
groundquests.sendPlacedInInventorySystemMessage(self, newItem, itemName);
|
||||
CustomerServiceLog("QUEST", self + " given item '" + itemName + "' (" + newItem + ")");
|
||||
setObjVar(self, baseObjVar + "." + objVarCreatedItem, newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean travelBlock = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableTravelBlock, false);
|
||||
|
||||
if (travelBlock)
|
||||
{
|
||||
boolean allowLaunch = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableTravelBlockAllowLaunch, false);
|
||||
travel.setTravelBlock(self, allowLaunch);
|
||||
}
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler itemGivenToNpc ()
|
||||
{
|
||||
string questName = params.getString ("questName");
|
||||
string taskName = params.getString ("taskName");
|
||||
string itemName = params.getString ("itemName");
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "giveItem", "start");
|
||||
|
||||
int questCrc = groundquests.getQuestIdFromString (questName);
|
||||
int taskId = groundquests.getTaskId (questCrc, taskName);
|
||||
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
string item = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableItemToGive);
|
||||
|
||||
if(item != null && item.length() > 0)
|
||||
{
|
||||
String[] itemsNeeded = split(item, ',');
|
||||
int textType = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableTextType));
|
||||
|
||||
for(int i = 0; i < itemsNeeded.length; ++i)
|
||||
{
|
||||
|
||||
if (itemsNeeded[i] != null && itemsNeeded[i].equals(itemName))
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + "." + objVarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int giveCount = getIntObjVar(self, objvarNameCount);
|
||||
--giveCount;
|
||||
if(giveCount < 0)
|
||||
giveCount = 0;
|
||||
|
||||
int countMax = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableNumToGive);
|
||||
string_id message = new string_id ("quest/groundquests", getMultipleSuccessTextKey(textType));
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
prose.setDI(pp, giveCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
|
||||
if(giveCount <= 0)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
setObjVar(self, objvarNameCount, giveCount);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, getCounterText(textType), countMax-giveCount, countMax);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "itemGivenToNpc", "Gave a " + itemName + ", " + giveCount + " left.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
failIfFailOnLogout(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
failIfFailOnLogout(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
String baseObjVar = groundquests.setBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
if (hasObjVar(player, baseObjVar + "." + objVarCreatedItem))
|
||||
{
|
||||
obj_id createdItem = getObjIdObjVar(player, baseObjVar + "." + objVarCreatedItem);
|
||||
|
||||
if (isIdValid(createdItem) && exists(createdItem))
|
||||
{
|
||||
boolean destroyItem = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableDestroyItem, false);
|
||||
|
||||
if (destroyItem)
|
||||
{
|
||||
groundquests.sendRemovedFromInventorySystemMessage(player, createdItem);
|
||||
destroyObject(createdItem);
|
||||
CustomerServiceLog("QUEST", player + " destroyed item (" + createdItem + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean travelBlock = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableTravelBlock, false);
|
||||
|
||||
if (travelBlock)
|
||||
travel.clearTravelBlock(player);
|
||||
|
||||
//clear tracking objvars
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void failIfFailOnLogout(obj_id player)
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, taskType);
|
||||
if (tasks != null && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
boolean shouldFailOnLogout = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableFailOnLogout, false);
|
||||
|
||||
if (shouldFailOnLogout)
|
||||
{
|
||||
LOG("QUEST_LOG", "Quest task failed due to log out.");
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
string getCounterText(int textType)
|
||||
{
|
||||
switch (textType)
|
||||
{
|
||||
case textDeliver:
|
||||
return "quest/groundquests:deliver_counter";
|
||||
case textGive:
|
||||
default:
|
||||
return "quest/groundquests:give_counter";
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
string getMultipleSuccessTextKey(int textType)
|
||||
{
|
||||
switch (textType)
|
||||
{
|
||||
case textDeliver:
|
||||
return "deliver_to_npc_multiple_success";
|
||||
case textGive:
|
||||
default:
|
||||
return "give_item_to_npc_multiple_success";
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,80 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.library.groundquests;
|
||||
import script.library.static_item;
|
||||
|
||||
public class give_item_to_npc extends script.base_script
|
||||
{
|
||||
public give_item_to_npc()
|
||||
{
|
||||
}
|
||||
public static final String dataTableItemToGive = "ITEM_TO_GIVE";
|
||||
public static final string_id noGiveDuringCombat = new string_id("quest/ground/system_message", "no_give_during_combat");
|
||||
public int OnGiveItem(obj_id self, obj_id item, obj_id giver) throws InterruptedException
|
||||
{
|
||||
String questName = getStringObjVar(self, "quest_name");
|
||||
String taskName = getStringObjVar(self, "task_name");
|
||||
String itemName = getTemplateName(item);
|
||||
if (static_item.isStaticItem(item))
|
||||
{
|
||||
itemName = getStaticItemName(item);
|
||||
}
|
||||
int questCrc = groundquests.getQuestIdFromString(questName);
|
||||
int taskId = groundquests.getTaskId(questCrc, taskName);
|
||||
if (!questIsTaskActive(questCrc, taskId, giver))
|
||||
{
|
||||
if (hasObjVar(self, "alternate_quest_name"))
|
||||
{
|
||||
questName = getStringObjVar(self, "alternate_quest_name");
|
||||
}
|
||||
else
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
questCrc = groundquests.getQuestIdFromString(questName);
|
||||
if (!questIsTaskActive(questCrc, taskId, giver))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
if (groundquests.isTimeRemainingBeforeCompletion(giver, questCrc, taskId))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String itemToGive = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableItemToGive);
|
||||
if (itemToGive != null && itemToGive.length() > 0)
|
||||
{
|
||||
String[] itemsNeeded = split(itemToGive, ',');
|
||||
for (int i = 0; i < itemsNeeded.length; ++i)
|
||||
{
|
||||
if (itemsNeeded[i].equals(itemName))
|
||||
{
|
||||
if (ai_lib.isInCombat(giver))
|
||||
{
|
||||
sendQuestSystemMessage(giver, noGiveDuringCombat);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("questName", questName);
|
||||
webster.put("taskName", taskName);
|
||||
webster.put("itemName", itemName);
|
||||
messageTo(giver, "itemGivenToNpc", webster, 0, false);
|
||||
return SCRIPT_OVERRIDE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
include library.ai_lib;
|
||||
include library.groundquests;
|
||||
include library.static_item;
|
||||
|
||||
const string dataTableItemToGive = "ITEM_TO_GIVE";
|
||||
const string_id noGiveDuringCombat = new string_id("quest/ground/system_message", "no_give_during_combat");
|
||||
|
||||
trigger OnGiveItem (obj_id item, obj_id giver)
|
||||
{
|
||||
/*if ( isGod(giver) )
|
||||
{
|
||||
debugSpeakMsg (giver, "The item is " + item);
|
||||
}*/
|
||||
string questName = getStringObjVar (self, "quest_name");
|
||||
string taskName = getStringObjVar (self, "task_name");
|
||||
string itemName = getTemplateName (item);
|
||||
|
||||
if(static_item.isStaticItem(item))
|
||||
itemName = getStaticItemName(item);
|
||||
|
||||
int questCrc = groundquests.getQuestIdFromString (questName);
|
||||
int taskId = groundquests.getTaskId (questCrc, taskName);
|
||||
|
||||
if (!questIsTaskActive(questCrc, taskId, giver))
|
||||
{
|
||||
// Need to check for alternate quest here
|
||||
if (hasObjVar(self, "alternate_quest_name"))
|
||||
{
|
||||
questName = getStringObjVar (self, "alternate_quest_name");
|
||||
}
|
||||
else
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
questCrc = groundquests.getQuestIdFromString (questName);
|
||||
|
||||
if (!questIsTaskActive(questCrc, taskId, giver))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (groundquests.isTimeRemainingBeforeCompletion(giver, questCrc, taskId))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
string itemToGive = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableItemToGive);
|
||||
|
||||
if(itemToGive != null && itemToGive.length() > 0)
|
||||
{
|
||||
String[] itemsNeeded = split(itemToGive, ',');
|
||||
|
||||
for(int i = 0; i < itemsNeeded.length; ++i)
|
||||
{
|
||||
if(itemsNeeded[i] == itemName)
|
||||
{
|
||||
if (ai_lib.isInCombat(giver))
|
||||
{
|
||||
sendQuestSystemMessage(giver, noGiveDuringCombat);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
|
||||
webster.put ("questName", questName);
|
||||
webster.put ("taskName", taskName);
|
||||
webster.put ("itemName", itemName);
|
||||
|
||||
messageTo (giver, "itemGivenToNpc", webster, 0, false);
|
||||
return SCRIPT_OVERRIDE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class go_to_location extends script.quest.task.ground.base_task
|
||||
{
|
||||
public go_to_location()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnPlanetName = "PLANET_NAME";
|
||||
public static final String dataTableColumnLocationX = "LOCATION_X";
|
||||
public static final String dataTableColumnLocationY = "LOCATION_Y";
|
||||
public static final String dataTableColumnLocationZ = "LOCATION_Z";
|
||||
public static final String dataTableColumnSphereSize = "RADIUS";
|
||||
public static final String objvarBase = "quest.go_to_location";
|
||||
public static final String objvarLocation = "location";
|
||||
public static final String objvarQuestName = "quest_name";
|
||||
public static final String objvarTaskId = "taskId";
|
||||
public static final String dot = ".";
|
||||
public static final String taskType = "go_to_location";
|
||||
public static final String JOURNAL_UPDATED_MUSIC = "sound/ui_objective_reached.snd";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task activated.");
|
||||
String planetName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnPlanetName);
|
||||
float locationX = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationX));
|
||||
float locationY = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationY));
|
||||
float locationZ = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationZ));
|
||||
float sphereSize = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnSphereSize));
|
||||
String questName = questGetQuestName(questCrc);
|
||||
String objvarQuestName = objvarBase + dot + questName;
|
||||
String objvarTaskIdName = objvarQuestName + dot + objvarTaskId;
|
||||
setObjVar(self, objvarTaskIdName, taskId);
|
||||
location loc = new location(locationX, locationY, locationZ, planetName, null);
|
||||
addLocationTarget(questName + ":" + taskId, loc, sphereSize);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Must reach within " + sphereSize + " meters of " + locationX + ", " + locationY + ", " + locationZ + " on " + planetName + ".");
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnArrivedAtLocation(obj_id self, String locationName) throws InterruptedException
|
||||
{
|
||||
String questName = locationName;
|
||||
int taskId = -1;
|
||||
int index = locationName.lastIndexOf(":");
|
||||
if (index != -1)
|
||||
{
|
||||
questName = locationName.substring(0, index);
|
||||
taskId = utils.stringToInt(locationName.substring(index + 1));
|
||||
}
|
||||
String objvarName = objvarBase + dot + questName;
|
||||
boolean result = hasObjVar(self, objvarName);
|
||||
if (result)
|
||||
{
|
||||
if (taskId == -1)
|
||||
{
|
||||
String objvarQuestName = objvarBase + dot + questName;
|
||||
String objvarTaskIdName = objvarQuestName + dot + objvarTaskId;
|
||||
taskId = getIntObjVar(self, objvarTaskIdName);
|
||||
}
|
||||
int questCrc = questGetQuestId(questName);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnArrivedAtLocation", "Arrived at location for go_to_location quest. Location name is " + questName);
|
||||
removeLocationTarget(locationName);
|
||||
if (groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
play2dNonLoopingSound(self, JOURNAL_UPDATED_MUSIC);
|
||||
}
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnPlanetName = "PLANET_NAME";
|
||||
const String dataTableColumnLocationX = "LOCATION_X";
|
||||
const String dataTableColumnLocationY = "LOCATION_Y";
|
||||
const String dataTableColumnLocationZ = "LOCATION_Z";
|
||||
const String dataTableColumnSphereSize = "RADIUS";
|
||||
|
||||
const String objvarBase = "quest.go_to_location";
|
||||
const String objvarLocation = "location";
|
||||
const String objvarQuestName = "quest_name";
|
||||
const String objvarTaskId = "taskId";
|
||||
const String dot = ".";
|
||||
|
||||
const String taskType = "go_to_location";
|
||||
|
||||
const String JOURNAL_UPDATED_MUSIC = "sound/ui_objective_reached.snd";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task activated.");
|
||||
|
||||
//gather data for this task
|
||||
String planetName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnPlanetName);
|
||||
float locationX = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationX));
|
||||
float locationY = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationY));
|
||||
float locationZ = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationZ));
|
||||
float sphereSize = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnSphereSize));
|
||||
|
||||
//TODO EAS normalize objvar use, remove taskId
|
||||
|
||||
//set tracking objvars
|
||||
String questName = questGetQuestName(questCrc);
|
||||
String objvarQuestName = objvarBase + dot + questName;
|
||||
String objvarTaskIdName = objvarQuestName + dot + objvarTaskId;
|
||||
setObjVar(self, objvarTaskIdName, taskId);
|
||||
|
||||
//set the location target
|
||||
//NOTE: all locations must be in the world cell for now
|
||||
location loc = new location (locationX, locationY, locationZ, planetName, null);
|
||||
addLocationTarget (questName + ":" + taskId, loc, sphereSize);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Must reach within " + sphereSize + " meters of " + locationX + ", " + locationY + ", " + locationZ + " on " + planetName + ".");
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnArrivedAtLocation(string locationName)
|
||||
{
|
||||
String questName = locationName;
|
||||
int taskId = -1;
|
||||
|
||||
int index = locationName.lastIndexOf(":");
|
||||
if (index != -1)
|
||||
{
|
||||
// new naming convention - questName:taskId
|
||||
questName = locationName.substring(0, index);
|
||||
taskId = utils.stringToInt(locationName.substring(index + 1));
|
||||
}
|
||||
|
||||
//see if the location reached is one this script cares about
|
||||
String objvarName = objvarBase + dot + questName;
|
||||
boolean result = hasObjVar(self, objvarName);
|
||||
|
||||
if(result)
|
||||
{
|
||||
// support active tasks that used the original naming convention
|
||||
if (taskId == -1)
|
||||
{
|
||||
String objvarQuestName = objvarBase + dot + questName;
|
||||
String objvarTaskIdName = objvarQuestName + dot + objvarTaskId;
|
||||
taskId = getIntObjVar(self, objvarTaskIdName);
|
||||
}
|
||||
int questCrc = questGetQuestId(questName);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnArrivedAtLocation", "Arrived at location for go_to_location quest. Location name is " + questName);
|
||||
//clean up the location target
|
||||
removeLocationTarget(locationName);
|
||||
|
||||
//only tell player things if task is visible
|
||||
if(groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
play2dNonLoopingSound(self, JOURNAL_UPDATED_MUSIC);
|
||||
}
|
||||
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
//clear tracking objvars
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,126 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.prose;
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
import script.library.space_quest;
|
||||
|
||||
public class grant_space_quest extends script.quest.task.ground.base_task
|
||||
{
|
||||
public grant_space_quest()
|
||||
{
|
||||
}
|
||||
public static final int winner = 1;
|
||||
public static final int failure = 2;
|
||||
public static final int split = 3;
|
||||
public static final String spaceQuestIdentifier = ".spaceQuestIdentifier";
|
||||
public static final String spaceQuestName = "SPACE_QUEST_NAME";
|
||||
public static final String spaceQuestType = "SPACE_QUEST_TYPE";
|
||||
public static final String ignoreSplit = "IGNORE_SPLIT";
|
||||
public static final String taskType = "grantSpaceQuest";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String spaceName = groundquests.getTaskStringDataEntry(questCrc, taskId, spaceQuestName);
|
||||
String spaceType = groundquests.getTaskStringDataEntry(questCrc, taskId, spaceQuestType);
|
||||
setObjVar(self, baseObjVar + ".spaceQuestIdentifier", spaceName);
|
||||
space_quest.grantQuest(self, spaceType, spaceName);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int groundSpaceWinner(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
handleSpaceQuestMessaging(self, params, winner);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int groundSpaceSplit(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
handleSpaceQuestMessaging(self, params, split);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int groundSpaceFailed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
handleSpaceQuestMessaging(self, params, failure);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void handleSpaceQuestMessaging(obj_id self, dictionary params, int spaceQuestValue) throws InterruptedException
|
||||
{
|
||||
String spaceQuestName = params.getString("questName");
|
||||
String splitQuestName = "";
|
||||
if (spaceQuestValue == split)
|
||||
{
|
||||
splitQuestName = params.getString("splitQuestName");
|
||||
}
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String spaceQuestIdentifierVariableName = baseObjVar + spaceQuestIdentifier;
|
||||
if (hasObjVar(self, spaceQuestIdentifierVariableName))
|
||||
{
|
||||
String spaceQuest = getStringObjVar(self, spaceQuestIdentifierVariableName);
|
||||
if (spaceQuest.equals(spaceQuestName))
|
||||
{
|
||||
if (spaceQuestValue == winner)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else if (spaceQuestValue == failure)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
else if (spaceQuestValue == split)
|
||||
{
|
||||
setObjVar(self, spaceQuestIdentifierVariableName, splitQuestName);
|
||||
}
|
||||
groundquests.questOutputDebugLog(taskType, "grantSpaceQuest", "start");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
include library.prose;
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
include library.space_quest;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const int winner = 1;
|
||||
const int failure = 2;
|
||||
const int split = 3;
|
||||
|
||||
const string spaceQuestIdentifier = ".spaceQuestIdentifier";
|
||||
const string spaceQuestName = "SPACE_QUEST_NAME";
|
||||
const string spaceQuestType = "SPACE_QUEST_TYPE";
|
||||
const string ignoreSplit = "IGNORE_SPLIT";
|
||||
const String taskType = "grantSpaceQuest";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
string spaceName = groundquests.getTaskStringDataEntry(questCrc, taskId, spaceQuestName);
|
||||
string spaceType = groundquests.getTaskStringDataEntry(questCrc, taskId, spaceQuestType);
|
||||
|
||||
setObjVar (self, baseObjVar + ".spaceQuestIdentifier" , spaceName );
|
||||
|
||||
space_quest.grantQuest( self, spaceType, spaceName);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler groundSpaceWinner ()
|
||||
{
|
||||
handleSpaceQuestMessaging(self, params, winner);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler groundSpaceSplit ()
|
||||
{
|
||||
handleSpaceQuestMessaging(self, params, split);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler groundSpaceFailed ()
|
||||
{
|
||||
handleSpaceQuestMessaging(self, params, failure);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
//clear tracking objvars
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void handleSpaceQuestMessaging (obj_id self, dictionary params, int spaceQuestValue)
|
||||
{
|
||||
string spaceQuestName = params.getString ("questName");
|
||||
string splitQuestName = "";
|
||||
|
||||
if (spaceQuestValue == split)
|
||||
{
|
||||
splitQuestName = params.getString ("splitQuestName");
|
||||
}
|
||||
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String spaceQuestIdentifierVariableName = baseObjVar + spaceQuestIdentifier;
|
||||
if(hasObjVar(self, spaceQuestIdentifierVariableName))
|
||||
{
|
||||
string spaceQuest = getStringObjVar (self, spaceQuestIdentifierVariableName);
|
||||
if (spaceQuest.equals(spaceQuestName))
|
||||
{
|
||||
if (spaceQuestValue == winner)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else if (spaceQuestValue == failure)
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
else if (spaceQuestValue == split)
|
||||
{
|
||||
setObjVar (self, spaceQuestIdentifierVariableName, splitQuestName);
|
||||
}
|
||||
groundquests.questOutputDebugLog(taskType, "grantSpaceQuest", "start");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
|
||||
public class nothing extends script.quest.task.ground.base_task
|
||||
{
|
||||
public nothing()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "nothing";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + "task entered.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
include library.groundquests;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "nothing";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + "task entered.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,254 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.performance;
|
||||
import script.library.utils;
|
||||
|
||||
public class perform extends script.quest.task.ground.base_task
|
||||
{
|
||||
public perform()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnPerformBuilding = "PERFORM_BUILDING";
|
||||
public static final String dataTableColumnPerformCellname = "PERFORM_CELLNAME";
|
||||
public static final String dataTableColumnPerformDuration = "PERFORM_DURATION";
|
||||
public static final String dataTableColumnPerformType = "PERFORM_TYPE";
|
||||
public static final String dataTableColumnVisible = "IS_VISIBLE";
|
||||
public static final String performEndTimeVarName = "performEndTime";
|
||||
public static final String performCurrentlyPerformingVarName = "performCurrentlyPerforming";
|
||||
public static final String taskType = "perform";
|
||||
public static final String dot = ".";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
clearPerformObjVars(self, questCrc, taskId);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "OnLogout", "start");
|
||||
playerStoppedPerforming(self, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
playerStoppedPerforming(self, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleClientLogin(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "start");
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "Processing task " + taskId);
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
boolean isCurrentlyPerforming = getBooleanObjVar(self, baseObjVar + dot + performCurrentlyPerformingVarName);
|
||||
boolean isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible) != 0;
|
||||
if (!isCurrentlyPerforming || !isVisible)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int endTime = getIntObjVar(self, baseObjVar + dot + performEndTimeVarName);
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "Updating client journal timer: " + endTime);
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int startPerform(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "start");
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "Processing task " + taskId);
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
int desiredPerformType = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPerformType);
|
||||
int currentPerformType = params.getInt(groundquests.PERFORM_TYPE);
|
||||
boolean rightType = desiredPerformType == 0 || desiredPerformType == currentPerformType;
|
||||
if (!rightType)
|
||||
{
|
||||
clearPerformObjVars(self, questCrc, taskId);
|
||||
continue;
|
||||
}
|
||||
boolean rightLocation = true;
|
||||
String cellname = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnPerformCellname);
|
||||
if (cellname != null && cellname.length() != 0)
|
||||
{
|
||||
location playerLocation = getLocation(self);
|
||||
rightLocation = (getCellName(playerLocation.cell)).equals(cellname);
|
||||
}
|
||||
else
|
||||
{
|
||||
String building = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnPerformBuilding);
|
||||
if (utils.stringToInt(building) != 0)
|
||||
{
|
||||
obj_id buildingObjId = utils.stringToObjId(building);
|
||||
rightLocation = performance.isInRightBuilding(self, buildingObjId);
|
||||
}
|
||||
}
|
||||
if (!rightLocation)
|
||||
{
|
||||
clearPerformObjVars(self, questCrc, taskId);
|
||||
continue;
|
||||
}
|
||||
int performDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPerformDuration);
|
||||
if (performDuration <= 0)
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "performDuration invalid, set to 10 seconds");
|
||||
performDuration = 10;
|
||||
}
|
||||
int performEndTime = performDuration + performGetTime(self);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Setting performance end time to " + performEndTime + " seconds.");
|
||||
setObjVar(self, baseObjVar + dot + performEndTimeVarName, performEndTime);
|
||||
setObjVar(self, baseObjVar + dot + performCurrentlyPerformingVarName, true);
|
||||
sendCheckPerformanceComplete(self, questCrc, taskId, performDuration);
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
if (isVisible != 0)
|
||||
{
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", performEndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "end");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int stopPerform(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "stopPerform", "start");
|
||||
playerStoppedPerforming(self, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int CheckPerformanceComplete(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "start");
|
||||
int questCrc = params.getInt("questcrc");
|
||||
int taskId = params.getInt("taskid");
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "quest task is active");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
boolean isCurrentlyPerforming = getBooleanObjVar(self, baseObjVar + dot + performCurrentlyPerformingVarName);
|
||||
if (isCurrentlyPerforming)
|
||||
{
|
||||
int endTime = getIntObjVar(self, baseObjVar + dot + performEndTimeVarName);
|
||||
int remainingTime = endTime - performGetTime(self);
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "endTime = " + endTime);
|
||||
if (endTime > 0 && remainingTime <= 1)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "not finished yet");
|
||||
sendCheckPerformanceComplete(self, questCrc, taskId, remainingTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "player currently not performing");
|
||||
}
|
||||
}
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "end");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void clearPerformObjVars(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(player, baseObjVar + dot + performEndTimeVarName, 0);
|
||||
setObjVar(player, baseObjVar + dot + performCurrentlyPerformingVarName, false);
|
||||
}
|
||||
public void playerStoppedPerforming(obj_id player, boolean updateQuestTimer) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
clearPerformObjVars(player, questCrc, taskId);
|
||||
boolean isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible) != 0;
|
||||
if (updateQuestTimer && isVisible)
|
||||
{
|
||||
questSetQuestTaskTimer(player, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", performGetTime(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public int performGetTime(obj_id player) throws InterruptedException
|
||||
{
|
||||
return getPlayerPlayedTime(player);
|
||||
}
|
||||
public void sendCheckPerformanceComplete(obj_id player, int questCrc, int taskId, int delay) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "sendCheckPerformanceComplete", "sending check message for delay [" + delay + "]");
|
||||
dictionary params = new dictionary();
|
||||
params.put("questcrc", questCrc);
|
||||
params.put("taskid", taskId);
|
||||
messageTo(player, "CheckPerformanceComplete", params, delay, false);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
}
|
||||
@@ -1,359 +0,0 @@
|
||||
// ======================================================================
|
||||
|
||||
include library.groundquests;
|
||||
include library.performance;
|
||||
include library.utils;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//-- data table columns
|
||||
const String dataTableColumnPerformBuilding = "PERFORM_BUILDING";
|
||||
const String dataTableColumnPerformCellname = "PERFORM_CELLNAME";
|
||||
const String dataTableColumnPerformDuration = "PERFORM_DURATION";
|
||||
const String dataTableColumnPerformType = "PERFORM_TYPE";
|
||||
const String dataTableColumnVisible = "IS_VISIBLE";
|
||||
|
||||
//-- object variables
|
||||
const String performEndTimeVarName = "performEndTime";
|
||||
const String performCurrentlyPerformingVarName = "performCurrentlyPerforming";
|
||||
|
||||
//-- task info
|
||||
const String taskType = "perform";
|
||||
const String dot = ".";
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
clearPerformObjVars(self, questCrc, taskId);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "OnLogout", "start");
|
||||
|
||||
playerStoppedPerforming(self, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
playerStoppedPerforming(self, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
commandHandler handleClientLogin()
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "start");
|
||||
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "Processing task " + taskId);
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
boolean isCurrentlyPerforming = getBooleanObjVar(self, baseObjVar + dot + performCurrentlyPerformingVarName);
|
||||
boolean isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible) != 0;
|
||||
|
||||
//-- only set a timer on the client for visible timers if the player is still performing
|
||||
if (!isCurrentlyPerforming || !isVisible)
|
||||
continue;
|
||||
|
||||
int endTime = getIntObjVar(self, baseObjVar + dot + performEndTimeVarName);
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "Updating client journal timer: " + endTime);
|
||||
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler startPerform()
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "start");
|
||||
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "Processing task " + taskId);
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
int desiredPerformType = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPerformType);
|
||||
int currentPerformType = params.getInt(groundquests.PERFORM_TYPE);
|
||||
boolean rightType = desiredPerformType == 0 || desiredPerformType == currentPerformType;
|
||||
|
||||
if (!rightType)
|
||||
{
|
||||
clearPerformObjVars(self, questCrc, taskId);
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean rightLocation = true;
|
||||
|
||||
String cellname = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnPerformCellname);
|
||||
|
||||
//-- if a cellname is specified in the quest, use that to determine right location
|
||||
if (cellname != null && cellname.length() != 0)
|
||||
{
|
||||
location playerLocation = getLocation(self);
|
||||
rightLocation = getCellName(playerLocation.cell).equals(cellname);
|
||||
}
|
||||
else
|
||||
{
|
||||
String building = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnPerformBuilding);
|
||||
|
||||
if (utils.stringToInt(building) != 0)
|
||||
{
|
||||
obj_id buildingObjId = utils.stringToObjId(building);
|
||||
|
||||
rightLocation = performance.isInRightBuilding(self, buildingObjId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!rightLocation)
|
||||
{
|
||||
clearPerformObjVars(self, questCrc, taskId);
|
||||
continue;
|
||||
}
|
||||
|
||||
int performDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPerformDuration);
|
||||
|
||||
if (performDuration <= 0)
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "performDuration invalid, set to 10 seconds");
|
||||
performDuration = 10;
|
||||
}
|
||||
|
||||
int performEndTime = performDuration + performGetTime(self);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Setting performance end time to " + performEndTime + " seconds.");
|
||||
|
||||
setObjVar(self, baseObjVar + dot + performEndTimeVarName, performEndTime);
|
||||
setObjVar(self, baseObjVar + dot + performCurrentlyPerformingVarName, true);
|
||||
|
||||
sendCheckPerformanceComplete(self, questCrc, taskId, performDuration);
|
||||
|
||||
//-- only set a timer on the client for visible timers
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
if(isVisible != 0)
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", performEndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "startPerform", "end");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler stopPerform()
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "stopPerform", "start");
|
||||
|
||||
playerStoppedPerforming(self, true);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler CheckPerformanceComplete()
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "start");
|
||||
|
||||
int questCrc = params.getInt("questcrc");
|
||||
int taskId = params.getInt("taskid");
|
||||
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "quest task is active");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
boolean isCurrentlyPerforming = getBooleanObjVar(self, baseObjVar + dot + performCurrentlyPerformingVarName);
|
||||
|
||||
if (isCurrentlyPerforming)
|
||||
{
|
||||
int endTime = getIntObjVar(self, baseObjVar + dot + performEndTimeVarName);
|
||||
int remainingTime = endTime - performGetTime(self);
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "endTime = " + endTime);
|
||||
|
||||
if (endTime > 0 && remainingTime <= 1)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "not finished yet");
|
||||
sendCheckPerformanceComplete(self, questCrc, taskId, remainingTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "player currently not performing");
|
||||
}
|
||||
}
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "CheckPerformanceComplete", "end");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void clearPerformObjVars(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
setObjVar(player, baseObjVar + dot + performEndTimeVarName, 0);
|
||||
setObjVar(player, baseObjVar + dot + performCurrentlyPerformingVarName, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void playerStoppedPerforming(obj_id player, boolean updateQuestTimer)
|
||||
{
|
||||
//-- run through every active task of this type clear the perform object vars
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
clearPerformObjVars(player, questCrc, taskId);
|
||||
|
||||
boolean isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible) != 0;
|
||||
if (updateQuestTimer && isVisible)
|
||||
questSetQuestTaskTimer(player, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", performGetTime(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int performGetTime(obj_id player)
|
||||
{
|
||||
return getPlayerPlayedTime(player);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void sendCheckPerformanceComplete(obj_id player, int questCrc, int taskId, int delay)
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "sendCheckPerformanceComplete", "sending check message for delay [" + delay + "]");
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("questcrc", questCrc);
|
||||
params.put("taskid", taskId);
|
||||
|
||||
messageTo(player, "CheckPerformanceComplete", params, delay, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,65 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
|
||||
public class perform_action_on_npc extends script.quest.task.ground.base_task
|
||||
{
|
||||
public perform_action_on_npc()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnActionName = "ACTION_NAME";
|
||||
public static final String taskType = "perform_action_on_npc";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int questActionCompleted(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int questCrc = params.getInt(groundquests.QUEST_CRC);
|
||||
int taskId = params.getInt(groundquests.TASK_ID);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "questActionCompleted", taskType + " quest actionc complete received.");
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "questActionCompleted", "Action completed successfully. Quest complete.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
// ======================================================================
|
||||
|
||||
include library.groundquests;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//-- data table columns
|
||||
const String dataTableColumnActionName = "ACTION_NAME";
|
||||
|
||||
//-- task info
|
||||
const String taskType = "perform_action_on_npc";
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler questActionCompleted()
|
||||
{
|
||||
int questCrc = params.getInt(groundquests.QUEST_CRC);
|
||||
int taskId = params.getInt(groundquests.TASK_ID);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "questActionCompleted", taskType + " quest actionc complete received.");
|
||||
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "questActionCompleted", "Action completed successfully. Quest complete.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,378 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
|
||||
public class remote_encounter extends script.quest.task.ground.base_task
|
||||
{
|
||||
public remote_encounter()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "remote_encounter";
|
||||
public static final String dataTableColumnCreatureName = "CREATURE_NAME";
|
||||
public static final String dataTableColumnEncounterSceneName = "ENCOUNTER_SCENE_NAME";
|
||||
public static final String dataTableColumnMinDifficulty = "MIN_DIFFICULTY";
|
||||
public static final String dataTableColumnMaxDifficulty = "MAX_DIFFICULTY";
|
||||
public static final String dataTableColumnInSpace = "IN_SPACE";
|
||||
public static final String dataTableColumnEncounterDuration = "ENCOUNTER_DURATION";
|
||||
public static final String dataTableColumnVisible = "IS_VISIBLE";
|
||||
public static final String dataTableColumnEncounterWhereMessage = "ENCOUNTER_WHERE_MESSAGE";
|
||||
public static final String dataTableColumnItemUsedSystemMessage = "ITEM_USED_SYSTEM_MESSAGE";
|
||||
public static final String dataTableColumnAttachScript = "ATTACH_SCRIPT";
|
||||
public static final String remoteEncounterScriptName = "quest.task.ground.remote_encounter";
|
||||
public static final String MISSION_CRITICAL_ADD_OBJECTS = "addObjects";
|
||||
public static final String MISSION_CRITICAL_REMOVE_OBJECTS = "removeObjects";
|
||||
public static final String QUEST_CRC = "questCrc";
|
||||
public static final String TASK_ID = "taskId";
|
||||
public static final String REMOTE_OBJECT_ID = "remoteObjectId";
|
||||
public static final String MESSAGE_SEND_QUEST_SYSTEM_MESSAGE = "messageSendQuestSystemMessage";
|
||||
public static final String MESSAGE_UPDATE_MISSION_CIRTICAL_OBJECTS = "messageUpdateMissionCriticalObjects";
|
||||
public static final String REMOTE_ENCOUNTER_CLEANUP = "remoteEncounterCleanup";
|
||||
public static final String REMOTE_ENCOUNTER_CREATURE_DIED = "remoteEncounterCreatureDied";
|
||||
public static final String REMOTE_ENCOUNTER_CREATURE_ESCAPED = "remoteEncounterCreatureEscaped";
|
||||
public static final String REMOTE_ENCOUNTER_ESCAPE = "remoteEncounterEscape";
|
||||
public static final String REMOTE_ENCOUNTER_FAILSAFE_TIMEOUT = "remoteEncounterFailsafeTimeout";
|
||||
public static final String REMOTE_ENCOUNTER_SIGNALED = "remoteEncounterSignaled";
|
||||
public static final String dataTableSceneDifficulty = "datatables/quest/ground/scene_difficulty.iff";
|
||||
public static final int FAILSAFE_TIMEOUT = 5 * 60;
|
||||
public static final String REMOTE_ENCOUNTER_CREATURE_SCRIPT = "quest.task.ground.util.remote_encounter_creature";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
int requestId = remoteCreate();
|
||||
setQuestCrcScriptVar(self, requestId, questCrc);
|
||||
setTaskIdScriptVar(self, requestId, taskId);
|
||||
dictionary params = new dictionary();
|
||||
params.put(QUEST_CRC, questCrc);
|
||||
params.put(TASK_ID, taskId);
|
||||
int encounterDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnEncounterDuration);
|
||||
messageTo(self, REMOTE_ENCOUNTER_FAILSAFE_TIMEOUT, params, encounterDuration + FAILSAFE_TIMEOUT, false);
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
if (isVisible != 0)
|
||||
{
|
||||
float playerPlayedTimeWhenTimerEnds = (float)getPlayerPlayedTime(self) + encounterDuration;
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext", (int)playerPlayedTimeWhenTimerEnds);
|
||||
}
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDeath(obj_id self, obj_id killer, obj_id corpseId) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int remoteEncounterFailsafeTimeout(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
log("remoteEncounterFailsafeTimeout");
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
logError("Failsafe timeout caused quest to fail!");
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int questItemUsed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
log("questItemUsed");
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
if (questIsTaskActive(questCrc, taskId, self) && isRemoteEncounter(questCrc, taskId))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "questItemUsed", "Quest item used. Sending message to remote object.");
|
||||
messageToRemote(self, questCrc, taskId, REMOTE_ENCOUNTER_SIGNALED);
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
if (isVisible != 0)
|
||||
{
|
||||
String itemUsedSystemMessage = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnItemUsedSystemMessage);
|
||||
string_id itemUsedSystemMessageId = utils.unpackString(itemUsedSystemMessage);
|
||||
sendQuestSystemMessage(self, itemUsedSystemMessageId);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int createRemoteObjectResponse(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
obj_id remoteObject = params.getObjId(REMOTE_OBJECT);
|
||||
if (isValidId(remoteObject))
|
||||
{
|
||||
setRemoteObjectScriptVar(self, questCrc, taskId, remoteObject);
|
||||
setRemoteObjectAsMissionCriticalToGroup(self, remoteObject);
|
||||
String sceneName = params.getString(SCENE_NAME);
|
||||
float x = params.getFloat(X);
|
||||
float y = params.getFloat(Y);
|
||||
float z = params.getFloat(Z);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "createRemoteObjectResponse", "Remote Object created in " + sceneName + " at [" + x + "," + y + "," + z + "]");
|
||||
sendEncounterWhereMessageToGroup(self, questCrc, taskId, sceneName);
|
||||
}
|
||||
else
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int remoteEncounterCreatureDied(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int remoteEncounterCreatureEscaped(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public String getQuestCrcVarName(int id) throws InterruptedException
|
||||
{
|
||||
return taskType + "." + QUEST_CRC + "." + id;
|
||||
}
|
||||
public String getTaskIdVarName(int id) throws InterruptedException
|
||||
{
|
||||
return taskType + "." + TASK_ID + "." + id;
|
||||
}
|
||||
public String getRemoteObjectVarName(int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
return taskType + "." + REMOTE_OBJECT_ID + "." + questCrc + "." + taskId;
|
||||
}
|
||||
public int getQuestCrcScriptVar(obj_id self, int id) throws InterruptedException
|
||||
{
|
||||
return utils.getIntScriptVar(self, getQuestCrcVarName(id));
|
||||
}
|
||||
public int getTaskIdScriptVar(obj_id self, int id) throws InterruptedException
|
||||
{
|
||||
return utils.getIntScriptVar(self, getTaskIdVarName(id));
|
||||
}
|
||||
public obj_id getRemoteObjectScriptVar(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
return utils.getObjIdScriptVar(self, getRemoteObjectVarName(questCrc, taskId));
|
||||
}
|
||||
public void setQuestCrcScriptVar(obj_id self, int id, int questCrc) throws InterruptedException
|
||||
{
|
||||
utils.setScriptVar(self, getQuestCrcVarName(id), questCrc);
|
||||
}
|
||||
public void setTaskIdScriptVar(obj_id self, int id, int taskId) throws InterruptedException
|
||||
{
|
||||
utils.setScriptVar(self, getTaskIdVarName(id), taskId);
|
||||
}
|
||||
public void setRemoteObjectScriptVar(obj_id self, int questCrc, int taskId, obj_id objectId) throws InterruptedException
|
||||
{
|
||||
utils.setScriptVar(self, getRemoteObjectVarName(questCrc, taskId), objectId);
|
||||
}
|
||||
public boolean hasValidScriptVars(obj_id self, int id) throws InterruptedException
|
||||
{
|
||||
return utils.hasScriptVar(self, getQuestCrcVarName(id)) && utils.hasScriptVar(self, getTaskIdVarName(id));
|
||||
}
|
||||
public void cleanup(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
messageToRemote(self, questCrc, taskId, REMOTE_ENCOUNTER_CLEANUP);
|
||||
obj_id remoteObject = getRemoteObjectScriptVar(self, questCrc, taskId);
|
||||
if (isValidId(remoteObject))
|
||||
{
|
||||
removeRemoteObjectFromMissionCriticalToGroup(self, remoteObject);
|
||||
}
|
||||
utils.removeScriptVar(self, getRemoteObjectVarName(questCrc, taskId));
|
||||
groundquests.clearBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public void messageToRemote(obj_id self, int questCrc, int taskId, String message) throws InterruptedException
|
||||
{
|
||||
obj_id remoteObject = getRemoteObjectScriptVar(self, questCrc, taskId);
|
||||
if (isValidId(remoteObject))
|
||||
{
|
||||
messageTo(remoteObject, message, null, 0, false);
|
||||
}
|
||||
}
|
||||
public dictionary getRemoteCreateParams(obj_id self, int requestId) throws InterruptedException
|
||||
{
|
||||
dictionary createParams = new dictionary();
|
||||
int questCrc = getQuestCrcScriptVar(self, requestId);
|
||||
int taskId = getTaskIdScriptVar(self, requestId);
|
||||
String creatureName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCreatureName);
|
||||
createParams.put(REQUESTER, self);
|
||||
createParams.put(OBJECT_NAME, creatureName);
|
||||
createParams.put(USE_RANDOM_LOCATION, true);
|
||||
createParams.put(ATTACH_SCRIPTS, REMOTE_ENCOUNTER_CREATURE_SCRIPT);
|
||||
createParams.put(QUEST_CRC, questCrc);
|
||||
createParams.put(TASK_ID, taskId);
|
||||
return createParams;
|
||||
}
|
||||
public void removeRemoteCreateScriptVars(obj_id self, int requestId) throws InterruptedException
|
||||
{
|
||||
super.removeRemoteCreateScriptVars(self, requestId);
|
||||
utils.removeScriptVar(self, getQuestCrcVarName(requestId));
|
||||
utils.removeScriptVar(self, getTaskIdVarName(requestId));
|
||||
}
|
||||
public boolean hasValidCreateScriptVars(obj_id self, int requestId) throws InterruptedException
|
||||
{
|
||||
int questCrc = getQuestCrcScriptVar(self, requestId);
|
||||
int taskId = getTaskIdScriptVar(self, requestId);
|
||||
if (!questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return hasValidScriptVars(self, requestId);
|
||||
}
|
||||
public obj_id getRemoteObjectCreator(obj_id self, int requestId, String[] elementNameList, dictionary[] dictionaryList) throws InterruptedException
|
||||
{
|
||||
int questCrc = getQuestCrcScriptVar(self, requestId);
|
||||
int taskId = getTaskIdScriptVar(self, requestId);
|
||||
int minDifficulty = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinDifficulty);
|
||||
int maxDifficulty = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxDifficulty);
|
||||
boolean inSpace = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnInSpace, true);
|
||||
String encounterSceneName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnEncounterSceneName);
|
||||
if (encounterSceneName != null && encounterSceneName.length() > 0)
|
||||
{
|
||||
for (int i = 0; i < elementNameList.length; ++i)
|
||||
{
|
||||
if (encounterSceneName.equals(elementNameList[i]))
|
||||
{
|
||||
log("getRemoteObjectCreator - using specific scene: " + encounterSceneName);
|
||||
return dictionaryList[i].getObjId(CREATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
Vector remoteCreatorsSpace = new Vector();
|
||||
remoteCreatorsSpace.setSize(0);
|
||||
Vector remoteCreatorsSpaceDifficulty = new Vector();
|
||||
remoteCreatorsSpaceDifficulty.setSize(0);
|
||||
for (int i = 0; i < dictionaryList.length; ++i)
|
||||
{
|
||||
obj_id creator = dictionaryList[i].getObjId(CREATOR);
|
||||
boolean creatorInSpace = dictionaryList[i].getBoolean(IN_SPACE);
|
||||
int difficultyRow = dataTableSearchColumnForString(elementNameList[i], "SCENE_NAME", dataTableSceneDifficulty);
|
||||
int difficulty = dataTableGetInt(dataTableSceneDifficulty, difficultyRow, "DIFFICULTY");
|
||||
if (creatorInSpace == inSpace)
|
||||
{
|
||||
remoteCreatorsSpace = utils.addElement(remoteCreatorsSpace, creator);
|
||||
if (difficulty >= minDifficulty && difficulty <= maxDifficulty)
|
||||
{
|
||||
remoteCreatorsSpaceDifficulty = utils.addElement(remoteCreatorsSpaceDifficulty, creator);
|
||||
}
|
||||
}
|
||||
}
|
||||
int size = remoteCreatorsSpaceDifficulty.size();
|
||||
if (size > 0)
|
||||
{
|
||||
return ((obj_id)remoteCreatorsSpaceDifficulty.get(rand(0, size - 1)));
|
||||
}
|
||||
size = remoteCreatorsSpace.size();
|
||||
if (size > 0)
|
||||
{
|
||||
return ((obj_id)remoteCreatorsSpace.get(rand(0, size - 1)));
|
||||
}
|
||||
logError("Failed to find remote creator!");
|
||||
questFailTask(questCrc, taskId, self);
|
||||
return null;
|
||||
}
|
||||
public void setRemoteObjectAsMissionCriticalToGroup(obj_id self, obj_id remoteObject) throws InterruptedException
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
obj_id[] addObjects = new obj_id[1];
|
||||
addObjects[0] = remoteObject;
|
||||
params.put(MISSION_CRITICAL_ADD_OBJECTS, addObjects);
|
||||
sendMessageToGroup(self, params, MESSAGE_UPDATE_MISSION_CIRTICAL_OBJECTS);
|
||||
}
|
||||
public void removeRemoteObjectFromMissionCriticalToGroup(obj_id self, obj_id remoteObject) throws InterruptedException
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
obj_id[] removeObjects = new obj_id[1];
|
||||
removeObjects[0] = remoteObject;
|
||||
params.put(MISSION_CRITICAL_REMOVE_OBJECTS, removeObjects);
|
||||
sendMessageToGroup(self, params, MESSAGE_UPDATE_MISSION_CIRTICAL_OBJECTS);
|
||||
}
|
||||
public void sendEncounterWhereMessageToGroup(obj_id self, int questCrc, int taskId, String sceneName) throws InterruptedException
|
||||
{
|
||||
String encounterWhereMessage = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnEncounterWhereMessage);
|
||||
string_id encounterWhereMessageId = utils.unpackString(encounterWhereMessage);
|
||||
string_id planetId = new string_id("planet_n", sceneName);
|
||||
dictionary params = new dictionary();
|
||||
params.put("sid", encounterWhereMessageId);
|
||||
params.put("to", planetId);
|
||||
sendMessageToGroup(self, params, MESSAGE_SEND_QUEST_SYSTEM_MESSAGE);
|
||||
}
|
||||
public void sendMessageToGroup(obj_id self, dictionary params, String message) throws InterruptedException
|
||||
{
|
||||
obj_id groupObj = getGroupObject(self);
|
||||
if (isIdValid(groupObj))
|
||||
{
|
||||
obj_id[] groupMembers = getGroupMemberIds(groupObj);
|
||||
int numGroupMembers = groupMembers.length;
|
||||
for (int i = 0; i < numGroupMembers; i++)
|
||||
{
|
||||
obj_id groupMember = groupMembers[i];
|
||||
if (isIdValid(groupMember))
|
||||
{
|
||||
messageTo(groupMember, message, params, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
messageTo(self, message, params, 0, false);
|
||||
}
|
||||
}
|
||||
public boolean isRemoteEncounter(int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
return (groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnAttachScript)).equals(remoteEncounterScriptName);
|
||||
}
|
||||
}
|
||||
@@ -1,584 +0,0 @@
|
||||
// =====================================================================
|
||||
//
|
||||
// remote_encounter.script
|
||||
//
|
||||
// =====================================================================
|
||||
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "remote_encounter";
|
||||
|
||||
//-- name of the remote object to spawn
|
||||
const String dataTableColumnCreatureName = "CREATURE_NAME";
|
||||
|
||||
//-- optional field to allow the scene choice to be fixed
|
||||
const String dataTableColumnEncounterSceneName = "ENCOUNTER_SCENE_NAME";
|
||||
|
||||
//-- min/max difficulty to use to select random scene to spawn encounter
|
||||
const String dataTableColumnMinDifficulty = "MIN_DIFFICULTY";
|
||||
const String dataTableColumnMaxDifficulty = "MAX_DIFFICULTY";
|
||||
|
||||
//-- whether or not the encounter should be in space
|
||||
const String dataTableColumnInSpace = "IN_SPACE";
|
||||
|
||||
//-- duration in seconds of the encounter
|
||||
const String dataTableColumnEncounterDuration = "ENCOUNTER_DURATION";
|
||||
|
||||
//-- whether or not to show the timer in the journal
|
||||
const String dataTableColumnVisible = "IS_VISIBLE";
|
||||
|
||||
//-- system message with planet name (must have a %TO which will be replaced by the planet)
|
||||
const String dataTableColumnEncounterWhereMessage = "ENCOUNTER_WHERE_MESSAGE";
|
||||
|
||||
//-- system message sent to player when the quest item is used
|
||||
const String dataTableColumnItemUsedSystemMessage = "ITEM_USED_SYSTEM_MESSAGE";
|
||||
|
||||
//-- script validation
|
||||
const String dataTableColumnAttachScript = "ATTACH_SCRIPT";
|
||||
const String remoteEncounterScriptName = "quest.task.ground.remote_encounter";
|
||||
|
||||
//-- variable and parameter name qualifiers
|
||||
const String MISSION_CRITICAL_ADD_OBJECTS = "addObjects";
|
||||
const String MISSION_CRITICAL_REMOVE_OBJECTS = "removeObjects";
|
||||
const String QUEST_CRC = "questCrc";
|
||||
const String TASK_ID = "taskId";
|
||||
const String REMOTE_OBJECT_ID = "remoteObjectId";
|
||||
|
||||
//-- message handlers
|
||||
const String MESSAGE_SEND_QUEST_SYSTEM_MESSAGE = "messageSendQuestSystemMessage";
|
||||
const String MESSAGE_UPDATE_MISSION_CIRTICAL_OBJECTS = "messageUpdateMissionCriticalObjects";
|
||||
const String REMOTE_ENCOUNTER_CLEANUP = "remoteEncounterCleanup";
|
||||
const String REMOTE_ENCOUNTER_CREATURE_DIED = "remoteEncounterCreatureDied";
|
||||
const String REMOTE_ENCOUNTER_CREATURE_ESCAPED = "remoteEncounterCreatureEscaped";
|
||||
const String REMOTE_ENCOUNTER_ESCAPE = "remoteEncounterEscape";
|
||||
const String REMOTE_ENCOUNTER_FAILSAFE_TIMEOUT = "remoteEncounterFailsafeTimeout";
|
||||
const String REMOTE_ENCOUNTER_SIGNALED = "remoteEncounterSignaled";
|
||||
|
||||
//-- scene difficulty data table for remote scene determination
|
||||
const String dataTableSceneDifficulty = "datatables/quest/ground/scene_difficulty.iff";
|
||||
|
||||
//-- failsafe timer
|
||||
const int FAILSAFE_TIMEOUT = 5*60;
|
||||
|
||||
//-- script for remote spawned creature
|
||||
const String REMOTE_ENCOUNTER_CREATURE_SCRIPT = "quest.task.ground.util.remote_encounter_creature";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
//-- request remote object objection
|
||||
int requestId = remoteCreate();
|
||||
|
||||
setQuestCrcScriptVar(self, requestId, questCrc);
|
||||
setTaskIdScriptVar(self, requestId, taskId);
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put(QUEST_CRC, questCrc);
|
||||
params.put(TASK_ID, taskId);
|
||||
|
||||
int encounterDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnEncounterDuration);
|
||||
|
||||
//-- failsafe timer to make sure the quest task fails
|
||||
messageTo(self, REMOTE_ENCOUNTER_FAILSAFE_TIMEOUT, params, encounterDuration + FAILSAFE_TIMEOUT, false);
|
||||
|
||||
//-- only set a timer on the client for visible timers
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
if (isVisible != 0)
|
||||
{
|
||||
float playerPlayedTimeWhenTimerEnds = (float)getPlayerPlayedTime(self) + encounterDuration;
|
||||
questSetQuestTaskTimer(self, questGetQuestName(questCrc), taskId, "quest/groundquests:timer_timertext",
|
||||
(int)playerPlayedTimeWhenTimerEnds);
|
||||
}
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDeath(obj_id killer, obj_id corpseId)
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler remoteEncounterFailsafeTimeout()
|
||||
{
|
||||
log("remoteEncounterFailsafeTimeout");
|
||||
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
logError("Failsafe timeout caused quest to fail!");
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler questItemUsed()
|
||||
{
|
||||
log("questItemUsed");
|
||||
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
|
||||
//-- need to check that there is an active task and it is a remote encounter
|
||||
//-- as future quest tasks can implement this message handler.
|
||||
if (questIsTaskActive(questCrc, taskId, self) && isRemoteEncounter(questCrc, taskId))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "questItemUsed", "Quest item used. Sending message to remote object.");
|
||||
|
||||
//-- send a message to the remote object
|
||||
messageToRemote(self, questCrc, taskId, REMOTE_ENCOUNTER_SIGNALED);
|
||||
|
||||
int isVisible = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnVisible);
|
||||
if (isVisible != 0)
|
||||
{
|
||||
string itemUsedSystemMessage = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnItemUsedSystemMessage);
|
||||
string_id itemUsedSystemMessageId = utils.unpackString(itemUsedSystemMessage);
|
||||
sendQuestSystemMessage(self, itemUsedSystemMessageId);
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
messageHandler createRemoteObjectResponse()
|
||||
{
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
obj_id remoteObject = params.getObjId(REMOTE_OBJECT);
|
||||
|
||||
if (isValidId(remoteObject))
|
||||
{
|
||||
//-- store the object id
|
||||
setRemoteObjectScriptVar(self, questCrc, taskId, remoteObject);
|
||||
|
||||
setRemoteObjectAsMissionCriticalToGroup(self, remoteObject);
|
||||
|
||||
String sceneName = params.getString(SCENE_NAME);
|
||||
float x = params.getFloat(X);
|
||||
float y = params.getFloat(Y);
|
||||
float z = params.getFloat(Z);
|
||||
|
||||
//-- debugging
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "createRemoteObjectResponse",
|
||||
"Remote Object created in " + sceneName + " at [" + x + "," + y + "," + z + "]");
|
||||
|
||||
sendEncounterWhereMessageToGroup(self, questCrc, taskId, sceneName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//-- failed to create object, fail the task
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler remoteEncounterCreatureDied()
|
||||
{
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
|
||||
if(questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
//-- you win!
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler remoteEncounterCreatureEscaped()
|
||||
{
|
||||
int questCrc = params.getInt(QUEST_CRC);
|
||||
int taskId = params.getInt(TASK_ID);
|
||||
|
||||
if(questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
//-- you failed!
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String getQuestCrcVarName(int id)
|
||||
{
|
||||
return taskType + "." + QUEST_CRC + "." + id;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String getTaskIdVarName(int id)
|
||||
{
|
||||
return taskType + "." + TASK_ID + "." + id;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String getRemoteObjectVarName(int questCrc, int taskId)
|
||||
{
|
||||
return taskType + "." + REMOTE_OBJECT_ID + "." + questCrc + "." + taskId;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
int getQuestCrcScriptVar(obj_id self, int id)
|
||||
{
|
||||
return utils.getIntScriptVar(self, getQuestCrcVarName(id));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
int getTaskIdScriptVar(obj_id self, int id)
|
||||
{
|
||||
return utils.getIntScriptVar(self, getTaskIdVarName(id));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
obj_id getRemoteObjectScriptVar(obj_id self, int questCrc, int taskId)
|
||||
{
|
||||
return utils.getObjIdScriptVar(self, getRemoteObjectVarName(questCrc, taskId));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void setQuestCrcScriptVar(obj_id self, int id, int questCrc)
|
||||
{
|
||||
utils.setScriptVar(self, getQuestCrcVarName(id), questCrc);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void setTaskIdScriptVar(obj_id self, int id, int taskId)
|
||||
{
|
||||
utils.setScriptVar(self, getTaskIdVarName(id), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void setRemoteObjectScriptVar(obj_id self, int questCrc, int taskId, obj_id objectId)
|
||||
{
|
||||
utils.setScriptVar(self, getRemoteObjectVarName(questCrc, taskId), objectId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
boolean hasValidScriptVars(obj_id self, int id)
|
||||
{
|
||||
return utils.hasScriptVar(self, getQuestCrcVarName(id)) &&
|
||||
utils.hasScriptVar(self, getTaskIdVarName(id));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id self, int questCrc, int taskId)
|
||||
{
|
||||
//-- clean up the remote object
|
||||
messageToRemote(self, questCrc, taskId, REMOTE_ENCOUNTER_CLEANUP);
|
||||
|
||||
//-- update mission critical objects
|
||||
obj_id remoteObject = getRemoteObjectScriptVar(self, questCrc, taskId);
|
||||
if (isValidId(remoteObject))
|
||||
removeRemoteObjectFromMissionCriticalToGroup(self, remoteObject);
|
||||
|
||||
utils.removeScriptVar(self, getRemoteObjectVarName(questCrc, taskId));
|
||||
|
||||
groundquests.clearBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void messageToRemote(obj_id self, int questCrc, int taskId, string message)
|
||||
{
|
||||
obj_id remoteObject = getRemoteObjectScriptVar(self, questCrc, taskId);
|
||||
|
||||
if (isValidId(remoteObject))
|
||||
{
|
||||
messageTo(remoteObject, message, null, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
dictionary getRemoteCreateParams(obj_id self, int requestId)
|
||||
{
|
||||
dictionary createParams = new dictionary();
|
||||
|
||||
int questCrc = getQuestCrcScriptVar(self, requestId);
|
||||
int taskId = getTaskIdScriptVar(self, requestId);
|
||||
|
||||
String creatureName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCreatureName);
|
||||
|
||||
createParams.put(REQUESTER, self);
|
||||
createParams.put(OBJECT_NAME, creatureName);
|
||||
createParams.put(USE_RANDOM_LOCATION, true);
|
||||
createParams.put(ATTACH_SCRIPTS, REMOTE_ENCOUNTER_CREATURE_SCRIPT);
|
||||
|
||||
//-- add quest/task data that will be echoed back in subsequent messages
|
||||
createParams.put(QUEST_CRC, questCrc);
|
||||
createParams.put(TASK_ID, taskId);
|
||||
|
||||
return createParams;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void removeRemoteCreateScriptVars(obj_id self, int requestId)
|
||||
{
|
||||
super.removeRemoteCreateScriptVars(self, requestId);
|
||||
|
||||
utils.removeScriptVar(self, getQuestCrcVarName(requestId));
|
||||
utils.removeScriptVar(self, getTaskIdVarName(requestId));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
boolean hasValidCreateScriptVars(obj_id self, int requestId)
|
||||
{
|
||||
int questCrc = getQuestCrcScriptVar(self, requestId);
|
||||
int taskId = getTaskIdScriptVar(self, requestId);
|
||||
|
||||
if (!questIsTaskActive(questCrc, taskId, self))
|
||||
return false;
|
||||
|
||||
return hasValidScriptVars(self, requestId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
obj_id getRemoteObjectCreator(obj_id self, int requestId, String[] elementNameList, dictionary[] dictionaryList)
|
||||
{
|
||||
int questCrc = getQuestCrcScriptVar(self, requestId);
|
||||
int taskId = getTaskIdScriptVar(self, requestId);
|
||||
|
||||
int minDifficulty = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinDifficulty);
|
||||
int maxDifficulty = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxDifficulty);
|
||||
boolean inSpace = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnInSpace, true);
|
||||
|
||||
//-- first check if a specific scene is requested, and if it's avaliable use it
|
||||
String encounterSceneName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnEncounterSceneName);
|
||||
|
||||
if (encounterSceneName != null && encounterSceneName.length() > 0)
|
||||
{
|
||||
for (int i=0; i<elementNameList.length; ++i)
|
||||
{
|
||||
if (encounterSceneName.equals(elementNameList[i]))
|
||||
{
|
||||
log("getRemoteObjectCreator - using specific scene: " + encounterSceneName);
|
||||
return dictionaryList[i].getObjId(CREATOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- given a list of all the registered remote creators, pick one based on the requirements of the quest
|
||||
resizeable obj_id[] remoteCreatorsSpace = new obj_id[0];
|
||||
resizeable obj_id[] remoteCreatorsSpaceDifficulty = new obj_id[0];
|
||||
|
||||
for (int i=0; i<dictionaryList.length; ++i)
|
||||
{
|
||||
obj_id creator = dictionaryList[i].getObjId(CREATOR);
|
||||
boolean creatorInSpace = dictionaryList[i].getBoolean(IN_SPACE);
|
||||
int difficultyRow = dataTableSearchColumnForString(elementNameList[i], "SCENE_NAME", dataTableSceneDifficulty);
|
||||
int difficulty = dataTableGetInt(dataTableSceneDifficulty, difficultyRow, "DIFFICULTY");
|
||||
|
||||
if (creatorInSpace == inSpace)
|
||||
{
|
||||
//-- add ids that meet the space or not space requirement
|
||||
remoteCreatorsSpace = utils.addElement(remoteCreatorsSpace, creator);
|
||||
|
||||
if (difficulty >= minDifficulty && difficulty <= maxDifficulty)
|
||||
{
|
||||
//-- add ids that meet the space and difficulty requirement
|
||||
remoteCreatorsSpaceDifficulty = utils.addElement(remoteCreatorsSpaceDifficulty, creator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-- try to find a creator that meets both requirements
|
||||
int size = remoteCreatorsSpaceDifficulty.size();
|
||||
if (size > 0)
|
||||
{
|
||||
return remoteCreatorsSpaceDifficulty[rand(0, size-1)];
|
||||
}
|
||||
|
||||
//-- fallback to just the space requirement
|
||||
size = remoteCreatorsSpace.size();
|
||||
if (size > 0)
|
||||
{
|
||||
return remoteCreatorsSpace[rand(0, size-1)];
|
||||
}
|
||||
|
||||
//-- big trouble
|
||||
logError("Failed to find remote creator!");
|
||||
questFailTask(questCrc, taskId, self);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void setRemoteObjectAsMissionCriticalToGroup(obj_id self, obj_id remoteObject)
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
obj_id[] addObjects = new obj_id[1];
|
||||
|
||||
addObjects[0] = remoteObject;
|
||||
params.put(MISSION_CRITICAL_ADD_OBJECTS, addObjects);
|
||||
|
||||
sendMessageToGroup(self, params, MESSAGE_UPDATE_MISSION_CIRTICAL_OBJECTS);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void removeRemoteObjectFromMissionCriticalToGroup(obj_id self, obj_id remoteObject)
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
obj_id[] removeObjects = new obj_id[1];
|
||||
|
||||
removeObjects[0] = remoteObject;
|
||||
params.put(MISSION_CRITICAL_REMOVE_OBJECTS, removeObjects);
|
||||
|
||||
sendMessageToGroup(self, params, MESSAGE_UPDATE_MISSION_CIRTICAL_OBJECTS);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void sendEncounterWhereMessageToGroup(obj_id self, int questCrc, int taskId, String sceneName)
|
||||
{
|
||||
String encounterWhereMessage = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnEncounterWhereMessage);
|
||||
|
||||
string_id encounterWhereMessageId = utils.unpackString(encounterWhereMessage);
|
||||
string_id planetId = new string_id("planet_n", sceneName);
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("sid", encounterWhereMessageId);
|
||||
params.put("to", planetId);
|
||||
|
||||
sendMessageToGroup(self, params, MESSAGE_SEND_QUEST_SYSTEM_MESSAGE);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void sendMessageToGroup(obj_id self, dictionary params, String message)
|
||||
{
|
||||
obj_id groupObj = getGroupObject(self);
|
||||
|
||||
if (isIdValid(groupObj))
|
||||
{
|
||||
obj_id[] groupMembers = getGroupMemberIds(groupObj);
|
||||
int numGroupMembers = groupMembers.length;
|
||||
|
||||
for (int i = 0; i < numGroupMembers; i++)
|
||||
{
|
||||
obj_id groupMember = groupMembers[i];
|
||||
if (isIdValid(groupMember))
|
||||
{
|
||||
messageTo(groupMember, message, params, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
messageTo(self, message, params, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
boolean isRemoteEncounter(int questCrc, int taskId)
|
||||
{
|
||||
//-- TODO: Find a better way to check the quest task type.
|
||||
return groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnAttachScript).equals(remoteEncounterScriptName);
|
||||
}
|
||||
|
||||
// =====================================================================
|
||||
@@ -0,0 +1,193 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.quests;
|
||||
import script.library.groundquests;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
|
||||
public class retrieve_item extends script.quest.task.ground.base_task
|
||||
{
|
||||
public retrieve_item()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
public static final String dataTableColumnNumRequired = "NUM_REQUIRED";
|
||||
public static final String dataTableColumnDropPercent = "DROP_PERCENT";
|
||||
public static final String dataTableColumnItemName = "ITEM_NAME";
|
||||
public static final String objvarCount = "count";
|
||||
public static final String objvarRetrieved = "retrieved_items";
|
||||
public static final String taskType = "retrieve_item";
|
||||
public static final String dot = ".";
|
||||
public static final String RETRIEVE_ITEM_MUSIC = "sound/ui_received_quest_item.snd";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, 0);
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnNumRequired);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:retrieve_item_counter", 0, count);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int questRetrieveItemObjectFound(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
if (!groundquests.playerNeedsToRetrieveThisItem(self, source))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, taskType, "questRetrieveItemObjectFound", "Player [" + self + "] Retrieved item [" + source + "] that we've already retrieved, this shouldn't happen.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
String sourceTemplateName = getTemplateName(source);
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String retrieveTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
if (sourceTemplateName.equals(retrieveTemplateName))
|
||||
{
|
||||
Vector retrievedItemsResizable = new Vector();
|
||||
retrievedItemsResizable.setSize(0);
|
||||
String objvarRetrievedFull = baseObjVar + dot + objvarRetrieved;
|
||||
if (hasObjVar(self, objvarRetrievedFull))
|
||||
{
|
||||
obj_id[] itemsAlreadyRetrieved = getObjIdArrayObjVar(self, objvarRetrievedFull);
|
||||
for (int k = 0; k < itemsAlreadyRetrieved.length; ++k)
|
||||
{
|
||||
utils.addElement(retrievedItemsResizable, itemsAlreadyRetrieved[k]);
|
||||
}
|
||||
}
|
||||
utils.addElement(retrievedItemsResizable, source);
|
||||
setObjVar(self, objvarRetrievedFull, retrievedItemsResizable);
|
||||
int dropPercent = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnDropPercent);
|
||||
int roll = rand(1, 100);
|
||||
boolean guaranteedSuccess = groundquests.checkForGuaranteedSuccess(self, baseObjVar);
|
||||
if (roll <= dropPercent || guaranteedSuccess)
|
||||
{
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
++lootedCount;
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnNumRequired);
|
||||
if (lootedCount > itemsTotal)
|
||||
{
|
||||
lootedCount = itemsTotal;
|
||||
}
|
||||
if (groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnItemName);
|
||||
string_id message = new string_id("quest/groundquests", "retrieve_item_success");
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
if (itemName != null && itemName.length() > 0)
|
||||
{
|
||||
message = new string_id("quest/groundquests", "retrieve_item_success_named");
|
||||
pp = prose.getPackage(message, self, self);
|
||||
prose.setTO(pp, itemName);
|
||||
}
|
||||
prose.setDI(pp, itemsTotal - lootedCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
play2dNonLoopingSound(self, RETRIEVE_ITEM_MUSIC);
|
||||
}
|
||||
if (lootedCount == itemsTotal)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:retrieve_item_counter", lootedCount, itemsTotal);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
setObjVar(self, objvarNameCount, lootedCount);
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "questRetrieveItemObjectFound", "Retrieved " + lootedCount + "/" + itemsTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, taskType, "questRetrieveItemObjectFound", "Didn't find one.");
|
||||
if (groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnItemName);
|
||||
string_id message = new string_id("quest/groundquests", "retrieve_item_fail");
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
sendSystemMessageProse(self, pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int handleClientLogin(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if (hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnNumRequired);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:retrieve_item_counter", lootedCount, itemsTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
include library.quests;
|
||||
include library.groundquests;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
const String dataTableColumnNumRequired = "NUM_REQUIRED";
|
||||
const String dataTableColumnDropPercent = "DROP_PERCENT";
|
||||
const String dataTableColumnItemName = "ITEM_NAME";
|
||||
|
||||
const String objvarCount = "count";
|
||||
const String objvarRetrieved = "retrieved_items";
|
||||
|
||||
const String taskType = "retrieve_item";
|
||||
const String dot = ".";
|
||||
|
||||
const String RETRIEVE_ITEM_MUSIC = "sound/ui_received_quest_item.snd";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
setObjVar(self, baseObjVar + dot + objvarCount, 0);
|
||||
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
|
||||
int count = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnNumRequired);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:retrieve_item_counter", 0, count);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler questRetrieveItemObjectFound()
|
||||
{
|
||||
obj_id source = params.getObjId("source");
|
||||
|
||||
//don't let player retrieve > 1 time from the same item
|
||||
if(!groundquests.playerNeedsToRetrieveThisItem(self, source))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, taskType, "questRetrieveItemObjectFound", "Player [" + self + "] Retrieved item [" + source + "] that we've already retrieved, this shouldn't happen.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
String sourceTemplateName = getTemplateName(source);
|
||||
|
||||
//iterate over each quest/task item that is a retrieve_item
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String retrieveTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
//if it's the right item for this task
|
||||
if(sourceTemplateName == retrieveTemplateName)
|
||||
{
|
||||
//add the item to our "already attempted" list
|
||||
resizeable obj_id[] retrievedItemsResizable = new obj_id[0];
|
||||
String objvarRetrievedFull = baseObjVar + dot + objvarRetrieved;
|
||||
if (hasObjVar(self, objvarRetrievedFull))
|
||||
{
|
||||
obj_id[] itemsAlreadyRetrieved = getObjIdArrayObjVar(self, objvarRetrievedFull);
|
||||
for (int k = 0; k < itemsAlreadyRetrieved.length; ++k)
|
||||
{
|
||||
utils.addElement(retrievedItemsResizable, itemsAlreadyRetrieved[k]);
|
||||
}
|
||||
}
|
||||
utils.addElement(retrievedItemsResizable, source);
|
||||
setObjVar(self, objvarRetrievedFull, retrievedItemsResizable);
|
||||
|
||||
int dropPercent = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnDropPercent);
|
||||
int roll = rand (1, 100);
|
||||
|
||||
boolean guaranteedSuccess = groundquests.checkForGuaranteedSuccess(self, baseObjVar);
|
||||
|
||||
//if we make the random roll or are given a guaranteed success
|
||||
if(roll <= dropPercent || guaranteedSuccess )
|
||||
{
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
++lootedCount;
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnNumRequired);
|
||||
if(lootedCount > itemsTotal)
|
||||
lootedCount = itemsTotal;
|
||||
|
||||
//only tell player things if task is visible
|
||||
if(groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnItemName);
|
||||
string_id message = new string_id ("quest/groundquests", "retrieve_item_success");
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
|
||||
// if itemName is valid, use the string that gives the item's name given in the quest data
|
||||
if ( itemName != null && itemName.length() > 0 )
|
||||
{
|
||||
message = new string_id ("quest/groundquests", "retrieve_item_success_named");
|
||||
pp = prose.getPackage(message, self, self);
|
||||
prose.setTO(pp, itemName);
|
||||
}
|
||||
|
||||
//send system message
|
||||
prose.setDI(pp, itemsTotal - lootedCount);
|
||||
sendSystemMessageProse(self, pp);
|
||||
|
||||
play2dNonLoopingSound(self, RETRIEVE_ITEM_MUSIC);
|
||||
|
||||
}
|
||||
|
||||
if(lootedCount == itemsTotal)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:retrieve_item_counter", lootedCount, itemsTotal);
|
||||
play2dNonLoopingSound(self, groundquests.MUSIC_QUEST_INCREMENT_COUNTER);
|
||||
setObjVar(self, objvarNameCount, lootedCount);
|
||||
|
||||
groundquests.setGuaranteedSuccessTarget(self, questCrc, taskId, baseObjVar);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "questRetrieveItemObjectFound", "Retrieved " + lootedCount + "/" + itemsTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, taskType, "questRetrieveItemObjectFound", "Didn't find one.");
|
||||
|
||||
//only tell player things if task is visible
|
||||
if(groundquests.isTaskVisible(questCrc, taskId))
|
||||
{
|
||||
String itemName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnItemName);
|
||||
string_id message = new string_id ("quest/groundquests", "retrieve_item_fail");
|
||||
prose_package pp = prose.getPackage(message, self, self);
|
||||
|
||||
sendSystemMessageProse(self, pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
commandHandler handleClientLogin()
|
||||
{
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String objvarNameCount = baseObjVar + dot + objvarCount;
|
||||
if(hasObjVar(self, objvarNameCount))
|
||||
{
|
||||
int lootedCount = getIntObjVar(self, objvarNameCount);
|
||||
int itemsTotal = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnNumRequired);
|
||||
questSetQuestTaskCounter(self, questGetQuestName(questCrc), taskId, "quest/groundquests:retrieve_item_counter", lootedCount, itemsTotal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,229 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.sui;
|
||||
import script.library.stealth;
|
||||
import script.library.utils;
|
||||
|
||||
public class retrieve_item_on_item extends script.base_script
|
||||
{
|
||||
public retrieve_item_on_item()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (isMob(self))
|
||||
{
|
||||
setCondition(self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (isMob(self))
|
||||
{
|
||||
setCondition(self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (isIncapacitated(self))
|
||||
{
|
||||
if (!hasScript(self, "npc.static_npc.npc_dead"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
int menu = 0;
|
||||
if (isMob(self))
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.ITEM_USE, new string_id("ui_radial", "item_use"));
|
||||
}
|
||||
if (hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
if (isMob(self))
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, menuStringId);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.ITEM_USE, menuStringId);
|
||||
}
|
||||
}
|
||||
}
|
||||
menu_info_data menuInfoData = menuInfo.getMenuItemById(menu);
|
||||
if (menuInfoData != null)
|
||||
{
|
||||
menuInfoData.setServerNotify(true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
|
||||
{
|
||||
location here = getLocation(player);
|
||||
location term = getLocation(self);
|
||||
float dist = getDistance(here, term);
|
||||
if (item == menu_info_types.ITEM_USE || item == menu_info_types.CONVERSE_START)
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player) || dist > 5.0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
if (groundquests.gcwActiveDutyCheck(self, player))
|
||||
{
|
||||
int countdownTimer = groundquests.getQuestCountdownTime(player, self);
|
||||
if (countdownTimer > 0)
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
String handler = "handleQuestCountdownTimer";
|
||||
int startTime = 0;
|
||||
int range = 3;
|
||||
int flags = 0;
|
||||
flags |= sui.CD_EVENT_INCAPACITATE;
|
||||
flags |= sui.CD_EVENT_DAMAGED;
|
||||
stealth.testInvisNonCombatAction(player, self);
|
||||
int countdownSui = sui.smartCountdownTimerSUI(self, player, "quest_countdown_timer", menuStringId, startTime, countdownTimer, handler, range, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_not_active_duty"));
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
String itemTemplateName = getTemplateName(self);
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, "retrieve_item");
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, "retrieve_item", questGetQuestName(questCrc), taskId);
|
||||
String retrieveTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, "SERVER_TEMPLATE");
|
||||
if (itemTemplateName.equals(retrieveTemplateName))
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_already_used"));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
string_id msg = new string_id("quest/groundquests", "retrieve_item_no_interest");
|
||||
if (isMob(self))
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob");
|
||||
if (isIncapacitated(self) || hasScript(self, "npc.static_npc.npc_dead"))
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob_dead");
|
||||
}
|
||||
}
|
||||
sendSystemMessage(player, msg);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleQuestCountdownTimer(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int pid = params.getInt("id");
|
||||
obj_id player = params.getObjId("player");
|
||||
if (!isIdValid(player))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int bp = sui.getIntButtonPressed(params);
|
||||
if (bp == sui.BP_CANCEL)
|
||||
{
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else if (bp == sui.BP_REVERT)
|
||||
{
|
||||
int event = params.getInt("event");
|
||||
if (event == sui.CD_EVENT_LOCOMOTION)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_locomotion"));
|
||||
}
|
||||
else if (event == sui.CD_EVENT_INCAPACITATE)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_incapacitated"));
|
||||
}
|
||||
else if (event == sui.CD_EVENT_DAMAGED)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_damaged"));
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!hasObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int test_pid = getIntObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR);
|
||||
if (pid != test_pid)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
forceCloseSUIPage(pid);
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void sendRetrieveObjectFoundMessage(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("source", self);
|
||||
webster.put("player", player);
|
||||
messageTo(player, "questRetrieveItemObjectFound", webster, 0, false);
|
||||
if (hasObjVar(self, "questRetrieveSignal"))
|
||||
{
|
||||
String questRetrieveSignal = getStringObjVar(self, "questRetrieveSignal");
|
||||
if (questRetrieveSignal != null && questRetrieveSignal.length() > 0)
|
||||
{
|
||||
groundquests.sendSignal(player, questRetrieveSignal);
|
||||
}
|
||||
}
|
||||
if (hasObjVar(self, "questFlavorObject"))
|
||||
{
|
||||
messageTo(self, "handleQuestFlavorObject", webster, 0, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,266 +0,0 @@
|
||||
//This script is used in conjunction with quest.task.ground.retrieve_item.
|
||||
|
||||
//This script is attached to the object from which you wish to retrieve items. It adds a radial menu item that sends a messageto
|
||||
//to the player that quest.task.ground.retrieve_item will pick up and handle appropriately.
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
include library.groundquests;
|
||||
include library.sui;
|
||||
include library.stealth;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
if ( isMob(self) )
|
||||
{
|
||||
setCondition (self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
if ( isMob(self) )
|
||||
{
|
||||
setCondition (self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo)
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if ( isIncapacitated(self) )
|
||||
{
|
||||
if ( !hasScript(self, "npc.static_npc.npc_dead") )
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
int menu = 0;
|
||||
if ( isMob(self) )
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.CONVERSE_START, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.ITEM_USE, new string_id("ui_radial", "item_use"));
|
||||
}
|
||||
|
||||
if(hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
|
||||
if ( isMob(self) )
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.CONVERSE_START, menuStringId);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.ITEM_USE, menuStringId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu_info_data menuInfoData = menuInfo.getMenuItemById (menu);
|
||||
|
||||
if ( menuInfoData != null )
|
||||
{
|
||||
menuInfoData.setServerNotify(true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnObjectMenuSelect(obj_id player, int item)
|
||||
{
|
||||
location here = getLocation (player);
|
||||
location term = getLocation (self);
|
||||
float dist = getDistance(here, term);
|
||||
|
||||
if( item == menu_info_types.ITEM_USE || item == menu_info_types.CONVERSE_START )
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player) || dist > 5.0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if(hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
if ( groundquests.gcwActiveDutyCheck(self, player) )
|
||||
{
|
||||
int countdownTimer = groundquests.getQuestCountdownTime(player, self);
|
||||
if ( countdownTimer > 0 )
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
|
||||
string handler = "handleQuestCountdownTimer";
|
||||
int startTime = 0;
|
||||
int range = 3;
|
||||
|
||||
int flags = 0;
|
||||
//flags |= sui.CD_EVENT_LOCOMOTION;
|
||||
flags |= sui.CD_EVENT_INCAPACITATE;
|
||||
flags |= sui.CD_EVENT_DAMAGED;
|
||||
|
||||
stealth.testInvisNonCombatAction(player, self);
|
||||
|
||||
int countdownSui = sui.smartCountdownTimerSUI(self, player, "quest_countdown_timer", menuStringId, startTime, countdownTimer, handler, range, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_not_active_duty"));
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
String itemTemplateName = getTemplateName(self);
|
||||
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, "retrieve_item");
|
||||
if ( (tasks != null) && !tasks.isEmpty() )
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, "retrieve_item", questGetQuestName(questCrc), taskId);
|
||||
String retrieveTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, "SERVER_TEMPLATE");
|
||||
if(itemTemplateName == retrieveTemplateName)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_already_used"));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string_id msg = new string_id("quest/groundquests", "retrieve_item_no_interest");
|
||||
if( isMob(self) )
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob");
|
||||
|
||||
if ( isIncapacitated(self) || hasScript(self, "npc.static_npc.npc_dead") )
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob_dead");
|
||||
}
|
||||
}
|
||||
|
||||
sendSystemMessage(player, msg);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler handleQuestCountdownTimer()
|
||||
{
|
||||
int pid = params.getInt("id");
|
||||
obj_id player = params.getObjId("player");
|
||||
|
||||
if( !isIdValid(player) )
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int bp = sui.getIntButtonPressed(params);
|
||||
|
||||
// Cancel button is sent when player manually closes the countdown window,
|
||||
// or when he/she moves out of range.
|
||||
if(bp == sui.BP_CANCEL)
|
||||
{
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
else if(bp == sui.BP_REVERT)
|
||||
{
|
||||
// Gets the reason why the timer was aborted
|
||||
int event = params.getInt("event");
|
||||
|
||||
// You can handle the situation differently depending on the reason
|
||||
if(event == sui.CD_EVENT_LOCOMOTION)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_locomotion"));
|
||||
}
|
||||
else if(event == sui.CD_EVENT_INCAPACITATE)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_incapacitated"));
|
||||
}
|
||||
else if(event == sui.CD_EVENT_DAMAGED)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_damaged"));
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!hasObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
int test_pid = getIntObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR);
|
||||
|
||||
if(pid != test_pid)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
forceCloseSUIPage(pid);
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
|
||||
// Retrieve Item target found
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void sendRetrieveObjectFoundMessage(obj_id self, obj_id player)
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("source", self);
|
||||
webster.put("player", player);
|
||||
messageTo(player, "questRetrieveItemObjectFound", webster, 0, false);
|
||||
|
||||
if(hasObjVar(self, "questRetrieveSignal"))
|
||||
{
|
||||
string questRetrieveSignal = getStringObjVar(self, "questRetrieveSignal");
|
||||
|
||||
if(questRetrieveSignal != null && questRetrieveSignal.length() > 0)
|
||||
{
|
||||
groundquests.sendSignal(player, questRetrieveSignal);
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasObjVar(self, "questFlavorObject") )
|
||||
{
|
||||
messageTo(self, "handleQuestFlavorObject", webster, 0, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class retrieve_item_on_item_inventory extends script.base_script
|
||||
{
|
||||
public retrieve_item_on_item_inventory()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "getQuestPlayerName", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int getQuestPlayerName(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id questPlayer = utils.getContainingPlayer(self);
|
||||
if (isIdValid(questPlayer))
|
||||
{
|
||||
setObjVar(self, "questPlayer", questPlayer);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException
|
||||
{
|
||||
if (hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
int menu = menuInfo.addRootMenu(menu_info_types.ITEM_USE, menuStringId);
|
||||
menu_info_data menuInfoData = menuInfo.getMenuItemById(menu);
|
||||
menuInfoData.setServerNotify(true);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
|
||||
{
|
||||
if (hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
if (item == menu_info_types.ITEM_USE)
|
||||
{
|
||||
setObjVar(self, "questItemUsed", true);
|
||||
dictionary params = new dictionary();
|
||||
params.put("source", self);
|
||||
messageTo(player, "questRetrieveItemObjectFound", params, 0, false);
|
||||
if (!hasObjVar(self, "doNotDestroyMe"))
|
||||
{
|
||||
messageTo(self, "destroyMe", null, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int destroyMe(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "doNotDestroyMe"))
|
||||
{
|
||||
destroyObject(self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, "questItemUsed"))
|
||||
{
|
||||
if (hasObjVar(self, "questPlayer"))
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, "questPlayer");
|
||||
if (isIdValid(player))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String template = getTemplateName(self);
|
||||
obj_id newItem = createObjectInInventoryAllowOverload(template, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
//This script is used in conjunction with quest.task.ground.retrieve_item.
|
||||
|
||||
//This script is attached to the object from which you wish to retrieve items. It adds a radial menu item that sends a messageto
|
||||
//to the player that quest.task.ground.retrieve_item will pick up and handle appropriately.
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
messageTo(self, "getQuestPlayerName", null, 1, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler getQuestPlayerName()
|
||||
{
|
||||
obj_id questPlayer = utils.getContainingPlayer(self);
|
||||
if( isIdValid(questPlayer) )
|
||||
{
|
||||
setObjVar(self, "questPlayer", questPlayer);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo)
|
||||
{
|
||||
if(hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
int menu = menuInfo.addRootMenu (menu_info_types.ITEM_USE, menuStringId);
|
||||
menu_info_data menuInfoData = menuInfo.getMenuItemById (menu);
|
||||
menuInfoData.setServerNotify(true);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnObjectMenuSelect(obj_id player, int item)
|
||||
{
|
||||
if(hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
if(item == menu_info_types.ITEM_USE)
|
||||
{
|
||||
setObjVar(self,"questItemUsed", true);
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("source", self);
|
||||
messageTo(player, "questRetrieveItemObjectFound", params, 0, false);
|
||||
|
||||
if ( !hasObjVar(self, "doNotDestroyMe") )
|
||||
{
|
||||
messageTo(self, "destroyMe", null, 1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler destroyMe()
|
||||
{
|
||||
if ( !hasObjVar(self, "doNotDestroyMe") )
|
||||
{
|
||||
destroyObject(self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if ( !hasObjVar(self, "questItemUsed") )
|
||||
{
|
||||
if ( hasObjVar(self, "questPlayer") )
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, "questPlayer");
|
||||
if ( isIdValid(player) )
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
string template = getTemplateName(self);
|
||||
obj_id newItem = createObjectInInventoryAllowOverload(template, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.sui;
|
||||
import script.library.stealth;
|
||||
import script.library.utils;
|
||||
|
||||
public class retrieve_item_on_item_spawned extends script.base_script
|
||||
{
|
||||
public retrieve_item_on_item_spawned()
|
||||
{
|
||||
}
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (isMob(self))
|
||||
{
|
||||
setCondition(self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (isMob(self))
|
||||
{
|
||||
setCondition(self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info menuInfo) throws InterruptedException
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (isIncapacitated(self))
|
||||
{
|
||||
if (!hasScript(self, "npc.static_npc.npc_dead"))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
int menu = 0;
|
||||
if (isMob(self))
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.ITEM_USE, new string_id("ui_radial", "item_use"));
|
||||
}
|
||||
if (hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
if (isMob(self))
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.CONVERSE_START, menuStringId);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu(menu_info_types.ITEM_USE, menuStringId);
|
||||
}
|
||||
}
|
||||
}
|
||||
menu_info_data menuInfoData = menuInfo.getMenuItemById(menu);
|
||||
if (menuInfoData != null)
|
||||
{
|
||||
menuInfoData.setServerNotify(true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (item == menu_info_types.ITEM_USE || item == menu_info_types.CONVERSE_START)
|
||||
{
|
||||
if (hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if (groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
if (groundquests.gcwActiveDutyCheck(self, player))
|
||||
{
|
||||
int countdownTimer = groundquests.getQuestCountdownTime(player, self);
|
||||
if (countdownTimer > 0)
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
String handler = "handleQuestCountdownTimer";
|
||||
int startTime = 0;
|
||||
int range = 3;
|
||||
int flags = 0;
|
||||
flags |= sui.CD_EVENT_INCAPACITATE;
|
||||
flags |= sui.CD_EVENT_DAMAGED;
|
||||
stealth.testInvisNonCombatAction(player, self);
|
||||
int countdownSui = sui.smartCountdownTimerSUI(self, player, "quest_countdown_timer", menuStringId, startTime, countdownTimer, handler, range, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_not_active_duty"));
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
String itemTemplateName = getTemplateName(self);
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, "retrieve_item");
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, "retrieve_item", questGetQuestName(questCrc), taskId);
|
||||
String retrieveTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, "SERVER_TEMPLATE");
|
||||
if (itemTemplateName.equals(retrieveTemplateName))
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_already_used"));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
string_id msg = new string_id("quest/groundquests", "retrieve_item_no_interest");
|
||||
if (isMob(self))
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob");
|
||||
if (isIncapacitated(self) || hasScript(self, "npc.static_npc.npc_dead"))
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob_dead");
|
||||
}
|
||||
}
|
||||
sendSystemMessage(player, msg);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleQuestCountdownTimer(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int pid = params.getInt("id");
|
||||
obj_id player = params.getObjId("player");
|
||||
if (!isIdValid(player))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int bp = sui.getIntButtonPressed(params);
|
||||
if (bp == sui.BP_CANCEL)
|
||||
{
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else if (bp == sui.BP_REVERT)
|
||||
{
|
||||
int event = params.getInt("event");
|
||||
if (event == sui.CD_EVENT_LOCOMOTION)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_locomotion"));
|
||||
}
|
||||
else if (event == sui.CD_EVENT_INCAPACITATE)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_incapacitated"));
|
||||
}
|
||||
else if (event == sui.CD_EVENT_DAMAGED)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_damaged"));
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (!hasObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int test_pid = getIntObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR);
|
||||
if (pid != test_pid)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
forceCloseSUIPage(pid);
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void sendRetrieveObjectFoundMessage(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("source", self);
|
||||
messageTo(player, "questRetrieveItemObjectFound", webster, 0, false);
|
||||
if (hasObjVar(self, "questRetrieveSignal"))
|
||||
{
|
||||
String questRetrieveSignal = getStringObjVar(self, "questRetrieveSignal");
|
||||
if (questRetrieveSignal != null && questRetrieveSignal.length() > 0)
|
||||
{
|
||||
groundquests.sendSignal(player, questRetrieveSignal);
|
||||
}
|
||||
}
|
||||
messageTo(self, "destroyMe", null, 1, false);
|
||||
return;
|
||||
}
|
||||
public int destroyMe(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!utils.hasScriptVar(self, "intCleanedUp"))
|
||||
{
|
||||
utils.setScriptVar(self, "intCleanedUp", 1);
|
||||
obj_id objParent = getObjIdObjVar(self, "objParent");
|
||||
messageTo(objParent, "spawnDestroyed", null, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-276
@@ -1,276 +0,0 @@
|
||||
//This script is used in conjunction with quest.task.ground.retrieve_item.
|
||||
|
||||
//This script is attached to the object from which you wish to retrieve items. It adds a radial menu item that sends a messageto
|
||||
//to the player that quest.task.ground.retrieve_item will pick up and handle appropriately.
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
include library.groundquests;
|
||||
include library.sui;
|
||||
include library.stealth;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
if ( isMob(self) )
|
||||
{
|
||||
setCondition (self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
if ( isMob(self) )
|
||||
{
|
||||
setCondition (self, CONDITION_CONVERSABLE);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
trigger OnObjectMenuRequest (obj_id player, menu_info menuInfo)
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if ( isIncapacitated(self) )
|
||||
{
|
||||
if ( !hasScript(self, "npc.static_npc.npc_dead") )
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
int menu = 0;
|
||||
if ( isMob(self) )
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.CONVERSE_START, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.ITEM_USE, new string_id("ui_radial", "item_use"));
|
||||
}
|
||||
|
||||
if(hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
|
||||
if ( isMob(self) )
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.CONVERSE_START, menuStringId);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = menuInfo.addRootMenu (menu_info_types.ITEM_USE, menuStringId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu_info_data menuInfoData = menuInfo.getMenuItemById (menu);
|
||||
|
||||
if ( menuInfoData != null )
|
||||
{
|
||||
menuInfoData.setServerNotify(true);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnObjectMenuSelect(obj_id player, int item)
|
||||
{
|
||||
if (isDead(player) || isIncapacitated(player))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
if( item == menu_info_types.ITEM_USE || item == menu_info_types.CONVERSE_START )
|
||||
{
|
||||
if(hasScript(player, "quest.task.ground.retrieve_item"))
|
||||
{
|
||||
if(groundquests.playerNeedsToRetrieveThisItem(player, self))
|
||||
{
|
||||
if ( groundquests.gcwActiveDutyCheck(self, player) )
|
||||
{
|
||||
int countdownTimer = groundquests.getQuestCountdownTime(player, self);
|
||||
if ( countdownTimer > 0 )
|
||||
{
|
||||
String menuText = groundquests.getRetrieveMenuText(player, self);
|
||||
string_id menuStringId = utils.unpackString(menuText);
|
||||
|
||||
string handler = "handleQuestCountdownTimer";
|
||||
int startTime = 0;
|
||||
int range = 3;
|
||||
|
||||
int flags = 0;
|
||||
//flags |= sui.CD_EVENT_LOCOMOTION;
|
||||
flags |= sui.CD_EVENT_INCAPACITATE;
|
||||
flags |= sui.CD_EVENT_DAMAGED;
|
||||
|
||||
stealth.testInvisNonCombatAction(player, self);
|
||||
|
||||
int countdownSui = sui.smartCountdownTimerSUI(self, player, "quest_countdown_timer", menuStringId, startTime, countdownTimer, handler, range, flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_not_active_duty"));
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
String itemTemplateName = getTemplateName(self);
|
||||
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(player, "retrieve_item");
|
||||
if ( (tasks != null) && !tasks.isEmpty() )
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, "retrieve_item", questGetQuestName(questCrc), taskId);
|
||||
String retrieveTemplateName = groundquests.getTaskStringDataEntry(questCrc, taskId, "SERVER_TEMPLATE");
|
||||
if(itemTemplateName == retrieveTemplateName)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "retrieve_item_already_used"));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string_id msg = new string_id("quest/groundquests", "retrieve_item_no_interest");
|
||||
if( isMob(self) )
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob");
|
||||
|
||||
if ( isIncapacitated(self) || hasScript(self, "npc.static_npc.npc_dead") )
|
||||
{
|
||||
msg = new string_id("quest/groundquests", "retrieve_item_no_interest_mob_dead");
|
||||
}
|
||||
}
|
||||
|
||||
sendSystemMessage(player, msg);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
messageHandler handleQuestCountdownTimer()
|
||||
{
|
||||
int pid = params.getInt("id");
|
||||
obj_id player = params.getObjId("player");
|
||||
|
||||
if( !isIdValid(player) )
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int bp = sui.getIntButtonPressed(params);
|
||||
|
||||
// Cancel button is sent when player manually closes the countdown window,
|
||||
// or when he/she moves out of range.
|
||||
if(bp == sui.BP_CANCEL)
|
||||
{
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
else if(bp == sui.BP_REVERT)
|
||||
{
|
||||
// Gets the reason why the timer was aborted
|
||||
int event = params.getInt("event");
|
||||
|
||||
// You can handle the situation differently depending on the reason
|
||||
if(event == sui.CD_EVENT_LOCOMOTION)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_locomotion"));
|
||||
}
|
||||
else if(event == sui.CD_EVENT_INCAPACITATE)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_incapacitated"));
|
||||
}
|
||||
else if(event == sui.CD_EVENT_DAMAGED)
|
||||
{
|
||||
sendSystemMessage(player, new string_id("quest/groundquests", "countdown_interrupted_damaged"));
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if(!hasObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR))
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
int test_pid = getIntObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR);
|
||||
|
||||
if(pid != test_pid)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
forceCloseSUIPage(pid);
|
||||
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
||||
|
||||
// Retrieve Item target found
|
||||
sendRetrieveObjectFoundMessage(self, player);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
void sendRetrieveObjectFoundMessage(obj_id self, obj_id player)
|
||||
{
|
||||
dictionary webster = new dictionary();
|
||||
webster.put("source", self);
|
||||
messageTo(player, "questRetrieveItemObjectFound", webster, 0, false);
|
||||
|
||||
if(hasObjVar(self, "questRetrieveSignal"))
|
||||
{
|
||||
string questRetrieveSignal = getStringObjVar(self, "questRetrieveSignal");
|
||||
|
||||
if(questRetrieveSignal != null && questRetrieveSignal.length() > 0)
|
||||
{
|
||||
groundquests.sendSignal(player, questRetrieveSignal);
|
||||
}
|
||||
}
|
||||
|
||||
messageTo(self, "destroyMe", null, 1, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messageHandler destroyMe()
|
||||
{
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
if(!utils.hasScriptVar(self, "intCleanedUp"))
|
||||
{
|
||||
utils.setScriptVar(self, "intCleanedUp", 1);
|
||||
obj_id objParent = getObjIdObjVar(self, "objParent");
|
||||
messageTo(objParent, "spawnDestroyed", null, 0, false);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.factions;
|
||||
import script.library.loot;
|
||||
import script.library.money;
|
||||
import script.library.prose;
|
||||
import script.library.static_item;
|
||||
import script.library.utils;
|
||||
import script.library.weapons;
|
||||
import script.library.xp;
|
||||
|
||||
public class reward extends script.quest.task.ground.base_task
|
||||
{
|
||||
public reward()
|
||||
{
|
||||
}
|
||||
public static final String taskType = "reward";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
String experienceType = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnExperienceType);
|
||||
int experienceAmount = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnExperienceAmount);
|
||||
String factionName = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnFactionName);
|
||||
int factionAmount = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnFactionAmount);
|
||||
int bankCredits = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnBankCredits);
|
||||
String item = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnItem);
|
||||
int itemCount = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnCount);
|
||||
String weapon = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnWeapon);
|
||||
int weaponCount = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnCountWeapon);
|
||||
float weaponSpeed = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnSpeed));
|
||||
float weaponDamage = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnDamage));
|
||||
float weaponEfficiency = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnEfficiency));
|
||||
float weaponElementalValue = utils.stringToFloat(groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnElementalValue));
|
||||
String armor = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnArmor);
|
||||
int armorCount = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnCountArmor);
|
||||
int armorQuality = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnQuality);
|
||||
String lootName = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnLootName);
|
||||
int lootCount = groundquests.getTaskIntDataEntry(questCrc, taskId, groundquests.dataTableColumnLootCount);
|
||||
String badge = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnBadge);
|
||||
String[] lootNames =
|
||||
{
|
||||
lootName
|
||||
};
|
||||
int[] lootCounts =
|
||||
{
|
||||
lootCount
|
||||
};
|
||||
groundquests.grantQuestReward(self, questCrc, -1, -1, experienceType, experienceAmount, factionName, factionAmount, false, bankCredits, item, itemCount, weapon, weaponCount, weaponSpeed, weaponDamage, weaponEfficiency, weaponElementalValue, armor, armorCount, armorQuality, lootNames, lootCounts, null, 1, badge, (questIsQuestForceAccept(questCrc) || !questDoesUseAcceptanceUI(questCrc)));
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.factions;
|
||||
include library.loot;
|
||||
include library.money;
|
||||
include library.prose;
|
||||
include library.static_item;
|
||||
include library.utils;
|
||||
include library.weapons;
|
||||
include library.xp;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String taskType = "reward";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
//instantly complete
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
|
||||
//gather data for this task
|
||||
String experienceType = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnExperienceType);
|
||||
int experienceAmount = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnExperienceAmount);
|
||||
String factionName = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnFactionName);
|
||||
int factionAmount = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnFactionAmount);
|
||||
int bankCredits = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnBankCredits);
|
||||
String item = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnItem);
|
||||
int itemCount = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnCount);
|
||||
String weapon = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnWeapon);
|
||||
int weaponCount = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnCountWeapon);
|
||||
float weaponSpeed = utils.stringToFloat(groundquests.getTaskStringDataEntry (questCrc, taskId, groundquests.dataTableColumnSpeed));
|
||||
float weaponDamage = utils.stringToFloat(groundquests.getTaskStringDataEntry (questCrc, taskId, groundquests.dataTableColumnDamage));
|
||||
float weaponEfficiency = utils.stringToFloat(groundquests.getTaskStringDataEntry (questCrc, taskId, groundquests.dataTableColumnEfficiency));
|
||||
float weaponElementalValue = utils.stringToFloat(groundquests.getTaskStringDataEntry (questCrc, taskId, groundquests.dataTableColumnElementalValue));
|
||||
String armor = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnArmor);
|
||||
int armorCount = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnCountArmor);
|
||||
int armorQuality = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnQuality);
|
||||
String lootName = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnLootName);
|
||||
int lootCount = groundquests.getTaskIntDataEntry (questCrc, taskId, groundquests.dataTableColumnLootCount);
|
||||
string badge = groundquests.getTaskStringDataEntry(questCrc, taskId, groundquests.dataTableColumnBadge);
|
||||
|
||||
String[] lootNames = {lootName};
|
||||
int[] lootCounts = {lootCount};
|
||||
groundquests.grantQuestReward(self, questCrc, -1, -1, experienceType, experienceAmount, factionName, factionAmount, false, bankCredits, item, itemCount, weapon, weaponCount, weaponSpeed, weaponDamage, weaponEfficiency, weaponElementalValue, armor, armorCount, armorQuality, lootNames, lootCounts, null, 1, badge, ( questIsQuestForceAccept(questCrc) || !questDoesUseAcceptanceUI(questCrc) ));
|
||||
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,153 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
|
||||
public class show_message_box extends script.quest.task.ground.base_task
|
||||
{
|
||||
public show_message_box()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnMessageBoxTitle = "MESSAGE_BOX_TITLE";
|
||||
public static final String dataTableColumnMessageBoxText = "MESSAGE_BOX_TEXT";
|
||||
public static final String dataTableColumnMessageBoxSound = "MESSAGE_BOX_SOUND";
|
||||
public static final String dataTableColumnMessageBoxSizeWidth = "MESSAGE_BOX_SIZE_WIDTH";
|
||||
public static final String dataTableColumnMessageBoxSizeHeight = "MESSAGE_BOX_SIZE_HEIGHT";
|
||||
public static final String dataTableColumnMessageBoxLocationX = "MESSAGE_BOX_LOCATION_X";
|
||||
public static final String dataTableColumnMessageBoxLocationY = "MESSAGE_BOX_LOCATION_Y";
|
||||
public static final String taskType = "show_message_box";
|
||||
public static final int defaultMessageBoxSizeWidth = 384;
|
||||
public static final int defaultMessageBoxSizeHeight = 256;
|
||||
public static final int defaultMessageBoxLocationX = 320;
|
||||
public static final int defaultMessageBoxLocationY = 256;
|
||||
public String getQuestCrcVarName(int pageId) throws InterruptedException
|
||||
{
|
||||
return taskType + ".questCrc." + pageId;
|
||||
}
|
||||
public String getTaskIdVarName(int pageId) throws InterruptedException
|
||||
{
|
||||
return taskType + ".taskId." + pageId;
|
||||
}
|
||||
public void displayMessageBox(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String messageBoxTitle = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMessageBoxTitle);
|
||||
String messageBoxText = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMessageBoxText);
|
||||
String messageBoxSound = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMessageBoxSound);
|
||||
int messageBoxSizeWidth = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxSizeWidth);
|
||||
int messageBoxSizeHeight = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxSizeHeight);
|
||||
int messageBoxLocationX = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxLocationX);
|
||||
int messageBoxLocationY = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxLocationY);
|
||||
int pageId = sui.createSUIPage(sui.SUI_MSGBOX, player, player, "QuestShowMessageBoxCompleted");
|
||||
sui.setAutosaveProperty(pageId, false);
|
||||
if (messageBoxSizeWidth != -1 && messageBoxSizeHeight != -1)
|
||||
{
|
||||
sui.setSizeProperty(pageId, messageBoxSizeWidth, messageBoxSizeHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
sui.setSizeProperty(pageId, defaultMessageBoxSizeWidth, defaultMessageBoxSizeHeight);
|
||||
}
|
||||
if (messageBoxLocationX != -1 && messageBoxLocationY != -1)
|
||||
{
|
||||
sui.setLocationProperty(pageId, messageBoxLocationX, messageBoxLocationY);
|
||||
}
|
||||
else
|
||||
{
|
||||
sui.setLocationProperty(pageId, defaultMessageBoxLocationX, defaultMessageBoxLocationY);
|
||||
}
|
||||
if (messageBoxSound != null && messageBoxSound.length() > 0)
|
||||
{
|
||||
sui.setSoundProperty(pageId, messageBoxSound);
|
||||
}
|
||||
setSUIProperty(pageId, sui.MSGBOX_TITLE, sui.PROP_TEXT, messageBoxTitle);
|
||||
setSUIProperty(pageId, sui.MSGBOX_PROMPT, sui.PROP_TEXT, messageBoxText);
|
||||
sui.msgboxButtonSetup(pageId, sui.OK_ONLY);
|
||||
sui.showSUIPage(pageId);
|
||||
utils.setScriptVar(player, getQuestCrcVarName(pageId), questCrc);
|
||||
utils.setScriptVar(player, getTaskIdVarName(pageId), taskId);
|
||||
groundquests.questOutputDebugLog(taskType, "displayMessageBox", "pageId = " + pageId);
|
||||
}
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + "task activated.");
|
||||
displayMessageBox(self, questCrc, taskId);
|
||||
groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int QuestShowMessageBoxCompleted(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int pageId = params.getInt("pageId");
|
||||
if (pageId < 0)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int questCrc = utils.getIntScriptVar(self, getQuestCrcVarName(pageId));
|
||||
int taskId = utils.getIntScriptVar(self, getTaskIdVarName(pageId));
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
utils.removeScriptVar(self, getQuestCrcVarName(pageId));
|
||||
utils.removeScriptVar(self, getTaskIdVarName(pageId));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + "task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int handleClientLogin(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "start");
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "task count = " + tasks.size());
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (String)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
for (int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
displayMessageBox(self, questCrc, taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "end");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
include library.groundquests;
|
||||
include library.sui;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnMessageBoxTitle = "MESSAGE_BOX_TITLE";
|
||||
const String dataTableColumnMessageBoxText = "MESSAGE_BOX_TEXT";
|
||||
const String dataTableColumnMessageBoxSound = "MESSAGE_BOX_SOUND";
|
||||
const String dataTableColumnMessageBoxSizeWidth = "MESSAGE_BOX_SIZE_WIDTH";
|
||||
const String dataTableColumnMessageBoxSizeHeight = "MESSAGE_BOX_SIZE_HEIGHT";
|
||||
const String dataTableColumnMessageBoxLocationX = "MESSAGE_BOX_LOCATION_X";
|
||||
const String dataTableColumnMessageBoxLocationY = "MESSAGE_BOX_LOCATION_Y";
|
||||
|
||||
const String taskType = "show_message_box";
|
||||
|
||||
const int defaultMessageBoxSizeWidth = 384;
|
||||
const int defaultMessageBoxSizeHeight = 256;
|
||||
const int defaultMessageBoxLocationX = 320;
|
||||
const int defaultMessageBoxLocationY = 256;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String getQuestCrcVarName(int pageId)
|
||||
{
|
||||
return taskType + ".questCrc." + pageId;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
String getTaskIdVarName(int pageId)
|
||||
{
|
||||
return taskType + ".taskId." + pageId;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void displayMessageBox(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
//gather data for this task
|
||||
String messageBoxTitle = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMessageBoxTitle);
|
||||
String messageBoxText = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMessageBoxText);
|
||||
String messageBoxSound = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMessageBoxSound);
|
||||
int messageBoxSizeWidth = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxSizeWidth);
|
||||
int messageBoxSizeHeight = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxSizeHeight);
|
||||
int messageBoxLocationX = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxLocationX);
|
||||
int messageBoxLocationY = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMessageBoxLocationY);
|
||||
|
||||
int pageId = sui.createSUIPage(sui.SUI_MSGBOX, player, player, "QuestShowMessageBoxCompleted");
|
||||
|
||||
//do not save the position and size settings for this window
|
||||
sui.setAutosaveProperty(pageId, false);
|
||||
|
||||
//size
|
||||
if (messageBoxSizeWidth != -1 && messageBoxSizeHeight != -1)
|
||||
{
|
||||
sui.setSizeProperty(pageId, messageBoxSizeWidth, messageBoxSizeHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
sui.setSizeProperty(pageId, defaultMessageBoxSizeWidth, defaultMessageBoxSizeHeight);
|
||||
}
|
||||
|
||||
//location
|
||||
if (messageBoxLocationX != -1 && messageBoxLocationY != -1)
|
||||
{
|
||||
sui.setLocationProperty(pageId, messageBoxLocationX, messageBoxLocationY);
|
||||
}
|
||||
else
|
||||
{
|
||||
sui.setLocationProperty(pageId, defaultMessageBoxLocationX, defaultMessageBoxLocationY);
|
||||
}
|
||||
|
||||
//sound
|
||||
if (messageBoxSound != null && messageBoxSound.length() > 0)
|
||||
{
|
||||
sui.setSoundProperty(pageId, messageBoxSound);
|
||||
}
|
||||
|
||||
setSUIProperty(pageId, sui.MSGBOX_TITLE, sui.PROP_TEXT, messageBoxTitle);
|
||||
setSUIProperty(pageId, sui.MSGBOX_PROMPT, sui.PROP_TEXT, messageBoxText);
|
||||
|
||||
sui.msgboxButtonSetup(pageId, sui.OK_ONLY);
|
||||
sui.showSUIPage(pageId);
|
||||
|
||||
//store crc and task id using the unique page id for later reference in the message handler
|
||||
utils.setScriptVar(player, getQuestCrcVarName(pageId), questCrc);
|
||||
utils.setScriptVar(player, getTaskIdVarName(pageId), taskId);
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "displayMessageBox", "pageId = " + pageId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + "task activated.");
|
||||
|
||||
displayMessageBox(self, questCrc, taskId);
|
||||
|
||||
groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler QuestShowMessageBoxCompleted()
|
||||
{
|
||||
int pageId = params.getInt("pageId");
|
||||
if(pageId < 0)
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
int questCrc = utils.getIntScriptVar(self, getQuestCrcVarName(pageId));
|
||||
int taskId = utils.getIntScriptVar(self, getTaskIdVarName(pageId));
|
||||
|
||||
if(questIsTaskActive(questCrc, taskId, self))
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
|
||||
utils.removeScriptVar(self, getQuestCrcVarName(pageId));
|
||||
utils.removeScriptVar(self, getTaskIdVarName(pageId));
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + "task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
commandHandler handleClientLogin()
|
||||
{
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "start");
|
||||
|
||||
dictionary tasks = groundquests.getActiveTasksForTaskType(self, taskType);
|
||||
if ((tasks != null) && !tasks.isEmpty())
|
||||
{
|
||||
java.util.Enumeration keys = tasks.keys();
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "task count = " + tasks.size());
|
||||
|
||||
while (keys.hasMoreElements())
|
||||
{
|
||||
String questCrcString = (string)keys.nextElement();
|
||||
int questCrc = utils.stringToInt(questCrcString);
|
||||
|
||||
int[] tasksForCurrentQuest = tasks.getIntArray(questCrcString);
|
||||
|
||||
for(int i = 0; i < tasksForCurrentQuest.length; ++i)
|
||||
{
|
||||
int taskId = tasksForCurrentQuest[i];
|
||||
|
||||
displayMessageBox(self, questCrc, taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
groundquests.questOutputDebugLog(taskType, "handleClientLogin", "end");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,184 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
|
||||
public class som_kenobi_fragments extends script.base_script
|
||||
{
|
||||
public som_kenobi_fragments()
|
||||
{
|
||||
}
|
||||
public static final string_id RADIAL_INSPECT = new string_id("quest/ground/util/quest_giver_object", "radial_inspect");
|
||||
public static final string_id OFFER_QUEST_MSG = new string_id("quest/ground/util/quest_giver_object", "offer_quest");
|
||||
public static final string_id SUI_TITLE = new string_id("quest/ground/util/quest_giver_object", "sui_title");
|
||||
public static final string_id BUTTON_DECLINE = new string_id("quest/ground/util/quest_giver_object", "button_decline");
|
||||
public static final string_id BUTTON_ACCEPT = new string_id("quest/ground/util/quest_giver_object", "button_accept");
|
||||
public static final string_id ALREADY_COMPLETED_QUEST = new string_id("quest/ground/util/quest_giver_object", "already_completed_quest");
|
||||
public static final string_id ALREADY_HAS_QUEST = new string_id("quest/ground/util/quest_giver_object", "already_has_quest");
|
||||
public static final string_id DECLINED_QUEST = new string_id("quest/ground/util/quest_giver_object", "declined_quest");
|
||||
public static final string_id OBJECT_UPLOADED = new string_id("quest/ground/util/quest_giver_object", "object_uploaded");
|
||||
public static final string_id IMPERIAL_FACTION_REQ = new string_id("quest/ground/util/quest_giver_object", "imperial_faction_required");
|
||||
public static final string_id REBEL_FACTION_REQ = new string_id("quest/ground/util/quest_giver_object", "rebel_faction_required");
|
||||
public static final String DATATABLE = "datatables/quest/ground/quest_giver_object.iff";
|
||||
public static final String QUEST_NAME = "quest_name";
|
||||
public static final String QUEST_OFFER_TEXT = "quest_offer_text";
|
||||
public static final String QUEST_IS_REPEATABLE = "quest_is_repeatable";
|
||||
public static final String DO_NOT_DESTROY = "do_not_destroy";
|
||||
public static final String IMPERIAL_ONLY = "imperial_only";
|
||||
public static final String REBEL_ONLY = "rebel_only";
|
||||
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
|
||||
{
|
||||
String myTemplate = getTemplateName(self);
|
||||
dictionary objectQuestData = dataTableGetRow(DATATABLE, myTemplate);
|
||||
if (objectQuestData != null)
|
||||
{
|
||||
String questName = objectQuestData.getString(QUEST_NAME);
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
if (groundquests.isValidQuestName(questName))
|
||||
{
|
||||
int menuOption = mi.addRootMenu(menu_info_types.ITEM_USE, RADIAL_INSPECT);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isGod(player))
|
||||
{
|
||||
String errorMsg = "GODMODE MSG: questName provided for " + getTemplateName(self) + " in " + DATATABLE + " is invalid.";
|
||||
sendSystemMessageTestingOnly(player, errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnObjectMenuSelect(obj_id self, obj_id player, int item) throws InterruptedException
|
||||
{
|
||||
if (item == menu_info_types.ITEM_USE)
|
||||
{
|
||||
if (utils.hasScriptVar(player, "questGiver.openSui"))
|
||||
{
|
||||
int oldSui = utils.getIntScriptVar(player, "questGiver.openSui");
|
||||
utils.removeScriptVar(player, "questGiver.openSui");
|
||||
if (oldSui > -1)
|
||||
{
|
||||
forceCloseSUIPage(oldSui);
|
||||
}
|
||||
}
|
||||
string_id sid_offerText = SUI_TITLE;
|
||||
String myTemplate = getTemplateName(self);
|
||||
dictionary objectQuestData = dataTableGetRow(DATATABLE, myTemplate);
|
||||
if (objectQuestData != null)
|
||||
{
|
||||
String newOfferText = objectQuestData.getString(QUEST_OFFER_TEXT);
|
||||
if (newOfferText != null && newOfferText.length() > 0)
|
||||
{
|
||||
sid_offerText = new string_id("quest/ground/util/quest_giver_object", newOfferText);
|
||||
}
|
||||
}
|
||||
String title = utils.packStringId(sid_offerText);
|
||||
String testMsg = utils.packStringId(OFFER_QUEST_MSG);
|
||||
String ok_button = utils.packStringId(BUTTON_ACCEPT);
|
||||
String cancel_button = utils.packStringId(BUTTON_DECLINE);
|
||||
int pid = sui.createSUIPage(sui.SUI_MSGBOX, self, player, "handleQuestOfferResponse");
|
||||
setSUIProperty(pid, sui.MSGBOX_TITLE, sui.PROP_TEXT, title);
|
||||
setSUIProperty(pid, sui.MSGBOX_PROMPT, sui.PROP_TEXT, testMsg);
|
||||
sui.msgboxButtonSetup(pid, sui.YES_NO);
|
||||
setSUIProperty(pid, sui.MSGBOX_BTN_OK, sui.PROP_TEXT, ok_button);
|
||||
setSUIProperty(pid, sui.MSGBOX_BTN_CANCEL, sui.PROP_TEXT, cancel_button);
|
||||
utils.setScriptVar(player, "questGiver.openSui", pid);
|
||||
sui.showSUIPage(pid);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int handleQuestOfferResponse(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if ((params == null) || (params.isEmpty()))
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
obj_id player = sui.getPlayerId(params);
|
||||
String myTemplate = getTemplateName(self);
|
||||
dictionary objectQuestData = dataTableGetRow(DATATABLE, myTemplate);
|
||||
if (objectQuestData != null)
|
||||
{
|
||||
String questName = objectQuestData.getString(QUEST_NAME);
|
||||
if (questName != null && questName.length() > 0)
|
||||
{
|
||||
int bp = sui.getIntButtonPressed(params);
|
||||
int imperialOnly = objectQuestData.getInt(IMPERIAL_ONLY);
|
||||
int rebelOnly = objectQuestData.getInt(REBEL_ONLY);
|
||||
int playerFaction = pvpGetAlignedFaction(player);
|
||||
if (imperialOnly > 0)
|
||||
{
|
||||
if (playerFaction != (-615855020))
|
||||
{
|
||||
sendSystemMessage(player, IMPERIAL_FACTION_REQ);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
else if (rebelOnly > 0)
|
||||
{
|
||||
if (playerFaction != (370444368))
|
||||
{
|
||||
sendSystemMessage(player, REBEL_FACTION_REQ);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
int questIsRepeatable = objectQuestData.getInt(QUEST_IS_REPEATABLE);
|
||||
if (!groundquests.hasCompletedQuest(player, "som_kenobi_reunite_shard_3"))
|
||||
{
|
||||
if (!groundquests.isQuestActive(player, "som_kenobi_reunite_shard_1"))
|
||||
{
|
||||
if (!groundquests.isQuestActive(player, "som_kenobi_reunite_shard_2"))
|
||||
{
|
||||
if (!groundquests.isQuestActive(player, "som_kenobi_reunite_shard_3"))
|
||||
{
|
||||
switch (bp)
|
||||
{
|
||||
case sui.BP_OK:
|
||||
groundquests.grantQuest(player, questName);
|
||||
int doNotDestroy = objectQuestData.getInt(DO_NOT_DESTROY);
|
||||
if (doNotDestroy < 1)
|
||||
{
|
||||
sendSystemMessage(player, OBJECT_UPLOADED);
|
||||
destroyObject(self);
|
||||
}
|
||||
break;
|
||||
case sui.BP_CANCEL:
|
||||
sendSystemMessage(player, DECLINED_QUEST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_HAS_QUEST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_HAS_QUEST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_HAS_QUEST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_COMPLETED_QUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
include library.groundquests;
|
||||
include library.sui;
|
||||
include library.utils;
|
||||
|
||||
/************************************************************/
|
||||
|
||||
const string_id RADIAL_INSPECT = new string_id ("quest/ground/util/quest_giver_object", "radial_inspect");
|
||||
const string_id OFFER_QUEST_MSG = new string_id ("quest/ground/util/quest_giver_object", "offer_quest");
|
||||
const string_id SUI_TITLE = new string_id ("quest/ground/util/quest_giver_object", "sui_title");
|
||||
const string_id BUTTON_DECLINE = new string_id ("quest/ground/util/quest_giver_object", "button_decline");
|
||||
const string_id BUTTON_ACCEPT = new string_id ("quest/ground/util/quest_giver_object", "button_accept");
|
||||
|
||||
const string_id ALREADY_COMPLETED_QUEST = new string_id ("quest/ground/util/quest_giver_object", "already_completed_quest");
|
||||
const string_id ALREADY_HAS_QUEST = new string_id ("quest/ground/util/quest_giver_object", "already_has_quest");
|
||||
const string_id DECLINED_QUEST = new string_id ("quest/ground/util/quest_giver_object", "declined_quest");
|
||||
const string_id OBJECT_UPLOADED = new string_id ("quest/ground/util/quest_giver_object", "object_uploaded");
|
||||
|
||||
const string_id IMPERIAL_FACTION_REQ = new string_id ("quest/ground/util/quest_giver_object", "imperial_faction_required");
|
||||
const string_id REBEL_FACTION_REQ = new string_id ("quest/ground/util/quest_giver_object", "rebel_faction_required");
|
||||
|
||||
const string DATATABLE = "datatables/quest/ground/quest_giver_object.iff";
|
||||
const string QUEST_NAME = "quest_name";
|
||||
const string QUEST_OFFER_TEXT = "quest_offer_text";
|
||||
const string QUEST_IS_REPEATABLE = "quest_is_repeatable";
|
||||
const string DO_NOT_DESTROY = "do_not_destroy";
|
||||
const string IMPERIAL_ONLY = "imperial_only";
|
||||
const string REBEL_ONLY = "rebel_only";
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
||||
{
|
||||
string myTemplate = getTemplateName(self);
|
||||
dictionary objectQuestData = dataTableGetRow(DATATABLE, myTemplate);
|
||||
if ( objectQuestData != null )
|
||||
{
|
||||
string questName = objectQuestData.getString(QUEST_NAME);
|
||||
if ( questName != null && questName.length() > 0 )
|
||||
{
|
||||
if ( groundquests.isValidQuestName(questName) )
|
||||
{
|
||||
int menuOption = mi.addRootMenu ( menu_info_types.ITEM_USE, RADIAL_INSPECT);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isGod(player) )
|
||||
{
|
||||
string errorMsg = "GODMODE MSG: questName provided for " + getTemplateName(self) + " in " + DATATABLE + " is invalid.";
|
||||
sendSystemMessageTestingOnly(player, errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
|
||||
trigger OnObjectMenuSelect(obj_id player, int item)
|
||||
{
|
||||
if ( item == menu_info_types.ITEM_USE)
|
||||
{
|
||||
// Construct Quest Offer sui
|
||||
if ( utils.hasScriptVar(player, "questGiver.openSui") )
|
||||
{
|
||||
int oldSui = utils.getIntScriptVar(player, "questGiver.openSui");
|
||||
utils.removeScriptVar(player, "questGiver.openSui");
|
||||
if ( oldSui > -1 )
|
||||
{
|
||||
forceCloseSUIPage(oldSui);
|
||||
}
|
||||
}
|
||||
|
||||
string_id sid_offerText = SUI_TITLE;
|
||||
|
||||
// To use non-default text for offering the quest, use the "quest_offer_text" column
|
||||
// in the datatable of an entry in quest/ground/util/quest_giver_object.stf
|
||||
string myTemplate = getTemplateName(self);
|
||||
dictionary objectQuestData = dataTableGetRow(DATATABLE, myTemplate);
|
||||
if ( objectQuestData != null )
|
||||
{
|
||||
string newOfferText = objectQuestData.getString(QUEST_OFFER_TEXT);
|
||||
if ( newOfferText != null && newOfferText.length() > 0 )
|
||||
{
|
||||
sid_offerText = new string_id ("quest/ground/util/quest_giver_object", newOfferText);
|
||||
}
|
||||
}
|
||||
|
||||
string title = utils.packStringId(sid_offerText);
|
||||
string testMsg = utils.packStringId(OFFER_QUEST_MSG);
|
||||
string ok_button = utils.packStringId(BUTTON_ACCEPT);
|
||||
string cancel_button = utils.packStringId(BUTTON_DECLINE);
|
||||
|
||||
// Create the dialog page.
|
||||
int pid = sui.createSUIPage( sui.SUI_MSGBOX, self, player, "handleQuestOfferResponse");
|
||||
|
||||
// Add elements text.
|
||||
setSUIProperty(pid, sui.MSGBOX_TITLE, sui.PROP_TEXT, title);
|
||||
setSUIProperty(pid, sui.MSGBOX_PROMPT, sui.PROP_TEXT, testMsg);
|
||||
|
||||
// Add buttons.
|
||||
sui.msgboxButtonSetup(pid, sui.YES_NO);
|
||||
setSUIProperty(pid, sui.MSGBOX_BTN_OK, sui.PROP_TEXT, ok_button);
|
||||
setSUIProperty(pid, sui.MSGBOX_BTN_CANCEL, sui.PROP_TEXT, cancel_button);
|
||||
|
||||
// Show dialog.
|
||||
utils.setScriptVar(player, "questGiver.openSui", pid);
|
||||
sui.showSUIPage( pid );
|
||||
// End sui construction
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
|
||||
messageHandler handleQuestOfferResponse()
|
||||
{
|
||||
if ( (params == null) || (params.isEmpty()) )
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
obj_id player = sui.getPlayerId( params );
|
||||
|
||||
string myTemplate = getTemplateName(self);
|
||||
dictionary objectQuestData = dataTableGetRow(DATATABLE, myTemplate);
|
||||
if ( objectQuestData != null )
|
||||
{
|
||||
string questName = objectQuestData.getString(QUEST_NAME);
|
||||
if ( questName != null && questName.length() > 0 )
|
||||
{
|
||||
int bp = sui.getIntButtonPressed( params );
|
||||
|
||||
// Check for Imperial only or Rebel only settings
|
||||
int imperialOnly = objectQuestData.getInt(IMPERIAL_ONLY);
|
||||
int rebelOnly = objectQuestData.getInt(REBEL_ONLY);
|
||||
|
||||
int playerFaction = pvpGetAlignedFaction(player);
|
||||
|
||||
if ( imperialOnly > 0 )
|
||||
{
|
||||
if ( playerFaction != ##"imperial" )
|
||||
{
|
||||
sendSystemMessage(player, IMPERIAL_FACTION_REQ);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
else if ( rebelOnly > 0 )
|
||||
{
|
||||
if ( playerFaction != ##"rebel" )
|
||||
{
|
||||
sendSystemMessage(player, REBEL_FACTION_REQ);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the quest is set as repeatable.
|
||||
int questIsRepeatable = objectQuestData.getInt(QUEST_IS_REPEATABLE);
|
||||
if (!groundquests.hasCompletedQuest(player, "som_kenobi_reunite_shard_3"))
|
||||
{
|
||||
if (!groundquests.isQuestActive(player, "som_kenobi_reunite_shard_1"))
|
||||
{
|
||||
if (!groundquests.isQuestActive(player, "som_kenobi_reunite_shard_2"))
|
||||
{
|
||||
if (!groundquests.isQuestActive(player, "som_kenobi_reunite_shard_3"))
|
||||
{
|
||||
switch ( bp )
|
||||
{
|
||||
case sui.BP_OK: // "Accept"
|
||||
groundquests.grantQuest(player, questName);
|
||||
|
||||
// Check to see if the quest object should be destroyed or not.
|
||||
int doNotDestroy = objectQuestData.getInt(DO_NOT_DESTROY);
|
||||
if ( doNotDestroy < 1 )
|
||||
{
|
||||
sendSystemMessage(player, OBJECT_UPLOADED);
|
||||
destroyObject(self);
|
||||
}
|
||||
break;
|
||||
case sui.BP_CANCEL: // "Decline"
|
||||
sendSystemMessage(player, DECLINED_QUEST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_HAS_QUEST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_HAS_QUEST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_HAS_QUEST);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessage(player, ALREADY_COMPLETED_QUEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.buff;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.utils;
|
||||
import script.library.ship_ai;
|
||||
import script.library.space_quest;
|
||||
import script.library.space_utils;
|
||||
import script.library.space_create;
|
||||
import script.library.space_transition;
|
||||
|
||||
public class spawn extends script.quest.task.ground.base_task
|
||||
{
|
||||
public spawn()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnCreatureType = "CREATURE_TYPE";
|
||||
public static final String dataTableColumnMinCount = "MIN_COUNT";
|
||||
public static final String dataTableColumnMaxCount = "MAX_COUNT";
|
||||
public static final String dataTableColumnMinDistance = "MIN_DISTANCE";
|
||||
public static final String dataTableColumnMaxDistance = "MAX_DISTANCE";
|
||||
public static final String dataTableColumnMinLevelDifference = "MIN_LEVEL_DIFFERENCE";
|
||||
public static final String dataTableColumnMaxLevelDifference = "MAX_LEVEL_DIFFERENCE";
|
||||
public static final String dataTableColumnGroundStartCombat = "GROUND_START_COMBAT";
|
||||
public static final String dataTableColumnDismountPlayer = "DISMOUNT_PLAYER";
|
||||
public static final String dataTableColumnMountBlockDuration = "MOUNT_BLOCK_DURATION";
|
||||
public static final String dataTableColumnBuffName = "BUFF_NAME";
|
||||
public static final String dataTableColumnShipType = "SHIP_TYPE";
|
||||
public static final String dataTableColumnShipMinCount = "SHIP_MIN_COUNT";
|
||||
public static final String dataTableColumnShipMaxCount = "SHIP_MAX_COUNT";
|
||||
public static final String dataTableColumnSpaceStartCombat = "SPACE_START_COMBAT";
|
||||
public static final String dataTableColumnHyperspaceBlockDuration = "HYPERSPACE_BLOCK_DURATION";
|
||||
public static final String dataTableColumnMinStartDelay = "MIN_START_DELAY";
|
||||
public static final String dataTableColumnMaxStartDelay = "MAX_START_DELAY";
|
||||
public static final String dataTableColumnChanceToSkip = "CHANCE_TO_SKIP";
|
||||
public static final String objvarPlayedTimeEnd = "playedTimeEnd";
|
||||
public static final String objvarOnCreatureOwner = "quest.owner";
|
||||
public static final String objvarOnCreatureQuestCrc = "quest.questCrc";
|
||||
public static final String objvarOnCreatureTaskId = "quest.taskId";
|
||||
public static final String objvarOnCreatureCount = "quest.count";
|
||||
public static final String taskType = "spawn";
|
||||
public static final String dot = ".";
|
||||
public static final float cleanupTime = 300.f;
|
||||
public static final float cleanupRetryTime = 60.f;
|
||||
public static final String scriptSpawnOnCreature = "quest.task.ground.spawn_on_creature";
|
||||
public static final String scriptSpawnOnShip = "quest.task.ground.spawn_on_ship";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
int minStartDelay = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinStartDelay));
|
||||
int maxStartDelay = Math.max(minStartDelay, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxStartDelay));
|
||||
int timeLeft = 0;
|
||||
if (minStartDelay > 0 && maxStartDelay > 0)
|
||||
{
|
||||
timeLeft = rand(minStartDelay, maxStartDelay);
|
||||
}
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Spawn will start in " + timeLeft + " seconds.");
|
||||
dictionary params = new dictionary();
|
||||
params.put("questCrc", questCrc);
|
||||
params.put("taskId", taskId);
|
||||
float playerPlayedTimeWhenTimerEnds = (float)getPlayerPlayedTime(self) + timeLeft;
|
||||
setObjVar(self, baseObjVar + "." + objvarPlayedTimeEnd, playerPlayedTimeWhenTimerEnds);
|
||||
messageTo(self, "messageStartQuestSpawn", params, timeLeft, true);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int messageStartQuestSpawn(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
int questCrc = params.getInt("questCrc");
|
||||
int taskId = params.getInt("taskId");
|
||||
if (questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
float playerPlayedTimeWhenTimerEnds = getFloatObjVar(self, baseObjVar + "." + objvarPlayedTimeEnd);
|
||||
float timeLeft = playerPlayedTimeWhenTimerEnds - (float)getPlayerPlayedTime(self);
|
||||
if (timeLeft > 1)
|
||||
{
|
||||
messageTo(self, "messageStartQuestSpawn", params, timeLeft, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int chanceToSkip = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnChanceToSkip);
|
||||
int chanceRoll = rand(0, 99);
|
||||
if (chanceToSkip > chanceRoll)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (isSpaceScene())
|
||||
{
|
||||
startSpaceQuestSpawn(self, questCrc, taskId);
|
||||
}
|
||||
else
|
||||
{
|
||||
startGroundQuestSpawn(self, questCrc, taskId);
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void startGroundQuestSpawn(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCreatureType);
|
||||
int minCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinCount);
|
||||
int maxCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxCount);
|
||||
float minRadius = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinDistance);
|
||||
float maxRadius = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxDistance);
|
||||
boolean shouldDismountPlayer = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnDismountPlayer, false);
|
||||
int mountBlockDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMountBlockDuration);
|
||||
String buffName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnBuffName);
|
||||
int minLevelDifference = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinLevelDifference));
|
||||
int maxLevelDifference = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxLevelDifference));
|
||||
boolean doAutoLeveling = minLevelDifference > 0 || maxLevelDifference > 0;
|
||||
location l = null;
|
||||
location locTest = getLocation(player);
|
||||
if (!isIdValid(locTest.cell))
|
||||
{
|
||||
location locA = locTest;
|
||||
location locB = locTest;
|
||||
locA.x -= 5;
|
||||
locA.y -= 5;
|
||||
locA.z -= 5;
|
||||
locB.x += 5;
|
||||
locB.y += 5;
|
||||
locB.z += 5;
|
||||
l = getGoodLocation(1, 1, locA, locB, false, true);
|
||||
if (getDistance(l, locTest) < 0.0f || getDistance(l, locTest) > 10.0f)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (shouldDismountPlayer)
|
||||
{
|
||||
utils.dismountRiderJetpackCheck(player);
|
||||
}
|
||||
if (mountBlockDuration > 0)
|
||||
{
|
||||
utils.setScriptVar(player, "mountBlock", getPlayerPlayedTime(player) + mountBlockDuration);
|
||||
}
|
||||
if (buffName != null && buffName.length() > 0)
|
||||
{
|
||||
buff.applyBuff(player, buffName);
|
||||
}
|
||||
if (maxCount < minCount)
|
||||
{
|
||||
maxCount = minCount;
|
||||
}
|
||||
int count = rand(minCount, maxCount);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
l = null;
|
||||
if (!isIdValid(locTest.cell))
|
||||
{
|
||||
l = groundquests.getRandom2DLocationAroundPlayer(player, minRadius, maxRadius);
|
||||
}
|
||||
else
|
||||
{
|
||||
String strCell = getCellName(locTest.cell);
|
||||
obj_id objBuilding = getTopMostContainer(player);
|
||||
l = getGoodLocation(objBuilding, strCell);
|
||||
}
|
||||
obj_id creature;
|
||||
int creatureLevel = 0;
|
||||
if (doAutoLeveling)
|
||||
{
|
||||
int minLevel = Math.max(1, getLevel(player) - minLevelDifference);
|
||||
int maxLevel = Math.max(minLevel, getLevel(player) + maxLevelDifference);
|
||||
creatureLevel = rand(minLevel, maxLevel);
|
||||
if (creatureLevel > 90)
|
||||
{
|
||||
creatureLevel = 90;
|
||||
}
|
||||
else if (creatureLevel < 1)
|
||||
{
|
||||
creatureLevel = 1;
|
||||
}
|
||||
creature = create.createCreature(creatureType, l, creatureLevel, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
creature = create.createCreature(creatureType, l, true);
|
||||
}
|
||||
setObjVar(creature, objvarOnCreatureOwner, player);
|
||||
setObjVar(creature, objvarOnCreatureQuestCrc, questCrc);
|
||||
setObjVar(creature, objvarOnCreatureTaskId, taskId);
|
||||
setObjVar(creature, objvarOnCreatureCount, i);
|
||||
attachScript(creature, scriptSpawnOnCreature);
|
||||
if (!hasCondition(creature, CONDITION_CONVERSABLE))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startGroundQuestSpawn", "Spawned " + creature + "(" + creatureLevel + ") at [" + l.x + ", " + l.y + ", " + l.z + "] to attack " + player);
|
||||
boolean shouldStartCombat = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnGroundStartCombat, false);
|
||||
if (shouldStartCombat)
|
||||
{
|
||||
startCombat(creature, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
public void startSpaceQuestSpawn(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startSpaceQuestSpawn", "Space spawn started!");
|
||||
boolean shouldStartCombat = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnSpaceStartCombat, false);
|
||||
if (shouldStartCombat && !space_utils.isPlayerShipAttackable(player))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startSpaceQuestSpawn", "Spawn failed due to player's ship being unattackable.");
|
||||
questFailTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String shipType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnShipType);
|
||||
if (shipType == null || shipType.length() == 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startSpaceQuestSpawn", "Spawn failed due to starting in space with no shipType defined.");
|
||||
questFailTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
int hyperspaceBlockDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnHyperspaceBlockDuration);
|
||||
if (hyperspaceBlockDuration > 0)
|
||||
{
|
||||
space_utils.setHyperspaceBlock(player, hyperspaceBlockDuration, true);
|
||||
}
|
||||
int minCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnShipMinCount);
|
||||
int maxCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnShipMaxCount);
|
||||
if (maxCount < minCount)
|
||||
{
|
||||
maxCount = minCount;
|
||||
}
|
||||
int squad = ship_ai.squadCreateSquadId();
|
||||
int count = rand(minCount, maxCount);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
transform gloc = getTransform_o2w(space_transition.getContainingShip(player));
|
||||
float dist = rand(700.f, 800.f);
|
||||
vector n = ((gloc.getLocalFrameK_p()).normalize()).multiply(dist);
|
||||
gloc = gloc.move_p(n);
|
||||
gloc = gloc.yaw_l(3.14f);
|
||||
vector vi = ((gloc.getLocalFrameI_p()).normalize()).multiply(rand(-150.f, 150.f));
|
||||
vector vj = ((gloc.getLocalFrameJ_p()).normalize()).multiply(rand(-150.f, 150.f));
|
||||
vector vd = vi.add(vj);
|
||||
gloc = gloc.move_p(vd);
|
||||
obj_id newship = space_create.createShipHyperspace(shipType, gloc);
|
||||
ship_ai.unitSetLeashDistance(newship, 16000);
|
||||
if (count > 3)
|
||||
{
|
||||
ship_ai.unitSetSquadId(newship, squad);
|
||||
}
|
||||
attachScript(newship, scriptSpawnOnShip);
|
||||
if (shouldStartCombat)
|
||||
{
|
||||
setObjVar(newship, "objMissionOwner", player);
|
||||
ship_ai.unitAddExclusiveAggro(newship, player);
|
||||
dictionary dict = new dictionary();
|
||||
dict.put("player", space_transition.getContainingShip(player));
|
||||
messageTo(newship, "spawnAttackPlayerShip", dict, 4.0f, false);
|
||||
}
|
||||
}
|
||||
if (count > 3)
|
||||
{
|
||||
ship_ai.squadSetFormationRandom(squad);
|
||||
}
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDeath(obj_id self, obj_id killer, obj_id corpseId) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,406 +0,0 @@
|
||||
// ================================================================================
|
||||
//
|
||||
// spawn.script
|
||||
//
|
||||
// ================================================================================
|
||||
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.buff;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.utils;
|
||||
include library.ship_ai;
|
||||
include library.space_quest;
|
||||
include library.space_utils;
|
||||
include library.space_create;
|
||||
include library.space_transition;
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnCreatureType = "CREATURE_TYPE";
|
||||
const String dataTableColumnMinCount = "MIN_COUNT";
|
||||
const String dataTableColumnMaxCount = "MAX_COUNT";
|
||||
const String dataTableColumnMinDistance = "MIN_DISTANCE";
|
||||
const String dataTableColumnMaxDistance = "MAX_DISTANCE";
|
||||
const String dataTableColumnMinLevelDifference = "MIN_LEVEL_DIFFERENCE";
|
||||
const String dataTableColumnMaxLevelDifference = "MAX_LEVEL_DIFFERENCE";
|
||||
const String dataTableColumnGroundStartCombat = "GROUND_START_COMBAT";
|
||||
const String dataTableColumnDismountPlayer = "DISMOUNT_PLAYER";
|
||||
const String dataTableColumnMountBlockDuration = "MOUNT_BLOCK_DURATION";
|
||||
const String dataTableColumnBuffName = "BUFF_NAME";
|
||||
|
||||
const String dataTableColumnShipType = "SHIP_TYPE";
|
||||
const String dataTableColumnShipMinCount = "SHIP_MIN_COUNT";
|
||||
const String dataTableColumnShipMaxCount = "SHIP_MAX_COUNT";
|
||||
const String dataTableColumnSpaceStartCombat = "SPACE_START_COMBAT";
|
||||
const String dataTableColumnHyperspaceBlockDuration = "HYPERSPACE_BLOCK_DURATION";
|
||||
|
||||
const String dataTableColumnMinStartDelay = "MIN_START_DELAY";
|
||||
const String dataTableColumnMaxStartDelay = "MAX_START_DELAY";
|
||||
const String dataTableColumnChanceToSkip = "CHANCE_TO_SKIP";
|
||||
|
||||
const String objvarPlayedTimeEnd = "playedTimeEnd";
|
||||
|
||||
const String objvarOnCreatureOwner = "quest.owner";
|
||||
const String objvarOnCreatureQuestCrc = "quest.questCrc";
|
||||
const String objvarOnCreatureTaskId = "quest.taskId";
|
||||
const String objvarOnCreatureCount = "quest.count";
|
||||
|
||||
const String taskType = "spawn";
|
||||
const String dot = ".";
|
||||
|
||||
const float cleanupTime = 300.f;
|
||||
const float cleanupRetryTime = 60.f;
|
||||
|
||||
const String scriptSpawnOnCreature = "quest.task.ground.spawn_on_creature";
|
||||
const String scriptSpawnOnShip = "quest.task.ground.spawn_on_ship";
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
int minStartDelay = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinStartDelay));
|
||||
int maxStartDelay = Math.max(minStartDelay, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxStartDelay));
|
||||
|
||||
int timeLeft = 0;
|
||||
|
||||
if (minStartDelay > 0 && maxStartDelay > 0)
|
||||
timeLeft = rand(minStartDelay, maxStartDelay);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Spawn will start in " + timeLeft + " seconds.");
|
||||
|
||||
dictionary params = new dictionary();
|
||||
params.put("questCrc", questCrc);
|
||||
params.put("taskId", taskId);
|
||||
|
||||
float playerPlayedTimeWhenTimerEnds = (float)getPlayerPlayedTime(self) + timeLeft;
|
||||
setObjVar(self, baseObjVar + "." + objvarPlayedTimeEnd, playerPlayedTimeWhenTimerEnds);
|
||||
|
||||
messageTo(self, "messageStartQuestSpawn", params, timeLeft, true);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
messageHandler messageStartQuestSpawn()
|
||||
{
|
||||
int questCrc = params.getInt ("questCrc");
|
||||
int taskId = params.getInt ("taskId");
|
||||
|
||||
if(questIsTaskActive(questCrc, taskId, self))
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
float playerPlayedTimeWhenTimerEnds = getFloatObjVar(self, baseObjVar + "." + objvarPlayedTimeEnd);
|
||||
float timeLeft = playerPlayedTimeWhenTimerEnds - (float)getPlayerPlayedTime(self);
|
||||
|
||||
if(timeLeft > 1)
|
||||
{
|
||||
messageTo(self, "messageStartQuestSpawn", params, timeLeft, true);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
int chanceToSkip = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnChanceToSkip);
|
||||
|
||||
int chanceRoll = rand(0, 99);
|
||||
|
||||
if(chanceToSkip > chanceRoll)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if (isSpaceScene())
|
||||
startSpaceQuestSpawn(self, questCrc, taskId);
|
||||
else
|
||||
startGroundQuestSpawn(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
void startGroundQuestSpawn(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
String creatureType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnCreatureType);
|
||||
int minCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinCount);
|
||||
int maxCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxCount);
|
||||
float minRadius = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinDistance);
|
||||
float maxRadius = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxDistance);
|
||||
boolean shouldDismountPlayer = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnDismountPlayer, false);
|
||||
int mountBlockDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMountBlockDuration);
|
||||
String buffName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnBuffName);
|
||||
|
||||
int minLevelDifference = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMinLevelDifference));
|
||||
int maxLevelDifference = Math.max(0, groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxLevelDifference));
|
||||
boolean doAutoLeveling = minLevelDifference > 0 || maxLevelDifference > 0;
|
||||
|
||||
location l = null;
|
||||
location locTest = getLocation(player);
|
||||
|
||||
if(!isIdValid(locTest.cell))
|
||||
{
|
||||
location locA = locTest;
|
||||
location locB = locTest;
|
||||
|
||||
locA.x -= 5;
|
||||
locA.y -= 5;
|
||||
locA.z -= 5;
|
||||
|
||||
locB.x += 5;
|
||||
locB.y += 5;
|
||||
locB.z += 5;
|
||||
|
||||
// getGoodLocation(float hintX, float hintZ, location searchRectLL, location searchRectUR, boolean dontCheckWater, boolean dontCheckSlope)
|
||||
l = getGoodLocation(1, 1, locA, locB, false, true);
|
||||
|
||||
// Bad location found?
|
||||
if(getDistance(l, locTest) < 0.0f || getDistance(l, locTest) > 10.0f)
|
||||
{
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldDismountPlayer)
|
||||
utils.dismountRiderJetpackCheck(player);
|
||||
|
||||
if (mountBlockDuration > 0)
|
||||
utils.setScriptVar(player, "mountBlock", getPlayerPlayedTime(player) + mountBlockDuration);
|
||||
|
||||
if (buffName != null && buffName.length() > 0)
|
||||
buff.applyBuff(player, buffName);
|
||||
|
||||
if (maxCount < minCount)
|
||||
maxCount = minCount;
|
||||
|
||||
int count = rand(minCount, maxCount);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
l = null;
|
||||
|
||||
if(!isIdValid(locTest.cell))
|
||||
{
|
||||
l = groundquests.getRandom2DLocationAroundPlayer(player, minRadius, maxRadius);
|
||||
}
|
||||
else
|
||||
{
|
||||
// handle the case where the player is inside a building
|
||||
string strCell = getCellName(locTest.cell);
|
||||
obj_id objBuilding = getTopMostContainer(player);
|
||||
l = getGoodLocation(objBuilding, strCell);
|
||||
}
|
||||
|
||||
|
||||
obj_id creature;
|
||||
int creatureLevel = 0;
|
||||
|
||||
if (doAutoLeveling)
|
||||
{
|
||||
int minLevel = Math.max(1, getLevel(player) - minLevelDifference);
|
||||
int maxLevel = Math.max(minLevel, getLevel(player) + maxLevelDifference);
|
||||
|
||||
creatureLevel = rand(minLevel, maxLevel);
|
||||
|
||||
if(creatureLevel > 90)
|
||||
{
|
||||
creatureLevel = 90;
|
||||
}
|
||||
else if(creatureLevel < 1)
|
||||
{
|
||||
creatureLevel = 1;
|
||||
}
|
||||
|
||||
creature = create.createCreature(creatureType, l, creatureLevel, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
creature = create.createCreature(creatureType, l, true);
|
||||
}
|
||||
|
||||
setObjVar(creature, objvarOnCreatureOwner, player);
|
||||
setObjVar(creature, objvarOnCreatureQuestCrc, questCrc);
|
||||
setObjVar(creature, objvarOnCreatureTaskId, taskId);
|
||||
setObjVar(creature, objvarOnCreatureCount, i);
|
||||
attachScript(creature, scriptSpawnOnCreature);
|
||||
|
||||
// if we can be talked to, that probably means we shouldn't be attacking.
|
||||
if (!hasCondition(creature, CONDITION_CONVERSABLE))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startGroundQuestSpawn",
|
||||
"Spawned " + creature + "(" + creatureLevel + ") at [" + l.x + ", " + l.y + ", " + l.z + "] to attack " + player);
|
||||
|
||||
boolean shouldStartCombat = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnGroundStartCombat, false);
|
||||
|
||||
if (shouldStartCombat)
|
||||
startCombat(creature, player);
|
||||
}
|
||||
}
|
||||
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
void startSpaceQuestSpawn(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startSpaceQuestSpawn",
|
||||
"Space spawn started!");
|
||||
|
||||
boolean shouldStartCombat = groundquests.getTaskBoolDataEntry(questCrc, taskId, dataTableColumnSpaceStartCombat, false);
|
||||
|
||||
if (shouldStartCombat && !space_utils.isPlayerShipAttackable(player))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startSpaceQuestSpawn",
|
||||
"Spawn failed due to player's ship being unattackable.");
|
||||
questFailTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
String shipType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnShipType);
|
||||
|
||||
if (shipType == null || shipType.length() == 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "startSpaceQuestSpawn",
|
||||
"Spawn failed due to starting in space with no shipType defined.");
|
||||
questFailTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
|
||||
int hyperspaceBlockDuration = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnHyperspaceBlockDuration);
|
||||
|
||||
if (hyperspaceBlockDuration > 0)
|
||||
space_utils.setHyperspaceBlock(player, hyperspaceBlockDuration, true);
|
||||
|
||||
int minCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnShipMinCount);
|
||||
int maxCount = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnShipMaxCount);
|
||||
|
||||
if (maxCount < minCount)
|
||||
maxCount = minCount;
|
||||
|
||||
int squad = ship_ai.squadCreateSquadId();
|
||||
int count = rand(minCount, maxCount);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
transform gloc = getTransform_o2w(space_transition.getContainingShip(player));
|
||||
|
||||
// Move the starting spot out in front of us.
|
||||
float dist = rand(700.f, 800.f);
|
||||
vector n = gloc.getLocalFrameK_p().normalize().multiply(dist); // Project a point out in front of us.
|
||||
gloc = gloc.move_p(n);
|
||||
|
||||
// Flip the starting spot around so its facing us.
|
||||
gloc = gloc.yaw_l(3.14f);
|
||||
|
||||
// Find a spot on the IJ plane for deviation in a cone shape.
|
||||
vector vi = gloc.getLocalFrameI_p().normalize().multiply(rand(-150.f, 150.f));
|
||||
vector vj = gloc.getLocalFrameJ_p().normalize().multiply(rand(-150.f, 150.f));
|
||||
vector vd = vi.add(vj);
|
||||
gloc = gloc.move_p(vd);
|
||||
|
||||
obj_id newship = space_create.createShipHyperspace(shipType, gloc);
|
||||
ship_ai.unitSetLeashDistance(newship, 16000);
|
||||
if (count > 3)
|
||||
ship_ai.unitSetSquadId(newship, squad);
|
||||
|
||||
attachScript(newship, scriptSpawnOnShip);
|
||||
|
||||
if (shouldStartCombat)
|
||||
{
|
||||
// This guy can only be harmed by the player or his group.
|
||||
setObjVar(newship, "objMissionOwner", player);
|
||||
ship_ai.unitAddExclusiveAggro(newship, player);
|
||||
dictionary dict = new dictionary ();
|
||||
dict.put("player", space_transition.getContainingShip(player));
|
||||
messageTo(newship, "spawnAttackPlayerShip", dict, 4.0f, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Set a formation.
|
||||
if (count > 3)
|
||||
ship_ai.squadSetFormationRandom(squad);
|
||||
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
return;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnDeath(obj_id killer, obj_id corpseId)
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
// make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -0,0 +1,53 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ai_lib;
|
||||
import script.quest.task.ground.spawn;
|
||||
|
||||
public class spawn_on_creature extends script.base_script
|
||||
{
|
||||
public spawn_on_creature()
|
||||
{
|
||||
}
|
||||
public static final int maxRetries = 5;
|
||||
public static final String retryCountName = "retryCount";
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
params.put(retryCountName, 0);
|
||||
messageTo(self, "messageSpawnCreatureCleanup", params, spawn.cleanupTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageSpawnCreatureCleanup(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (isDead(self))
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Creature is dead!");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (ai_lib.isInCombat(self))
|
||||
{
|
||||
int retryCount = params.getInt(retryCountName) + 1;
|
||||
if (retryCount <= maxRetries)
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Creature in combat - trying again. retryCount = " + retryCount + "/" + maxRetries);
|
||||
params.put(retryCountName, retryCount);
|
||||
messageTo(self, "messageSpawnCreatureCleanup", params, spawn.cleanupRetryTime, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Creature in combat - no more retries left.");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
// ================================================================================
|
||||
//
|
||||
// spawn_on_creature.script
|
||||
//
|
||||
// This script goes on a creature spawned by the spawn quest task type.
|
||||
//
|
||||
// ================================================================================
|
||||
|
||||
include library.ai_lib;
|
||||
include quest.task.ground.spawn;
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
const int maxRetries = 5;
|
||||
|
||||
const String retryCountName = "retryCount";
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
params.put(retryCountName, 0);
|
||||
messageTo(self, "messageSpawnCreatureCleanup", params, spawn.cleanupTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
messageHandler messageSpawnCreatureCleanup()
|
||||
{
|
||||
if (isDead(self))
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Creature is dead!");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
if (ai_lib.isInCombat(self))
|
||||
{
|
||||
int retryCount = params.getInt(retryCountName) + 1;
|
||||
|
||||
if (retryCount <= maxRetries)
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Creature in combat - trying again. retryCount = " + retryCount + "/" + maxRetries);
|
||||
|
||||
params.put(retryCountName, retryCount);
|
||||
messageTo(self, "messageSpawnCreatureCleanup", params, spawn.cleanupRetryTime, false);
|
||||
}
|
||||
else
|
||||
LOG("QUEST_SPAWN_LOG", "Creature in combat - no more retries left.");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
destroyObject(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -0,0 +1,66 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.ship_ai;
|
||||
import script.quest.task.ground.spawn;
|
||||
|
||||
public class spawn_on_ship extends script.base_script
|
||||
{
|
||||
public spawn_on_ship()
|
||||
{
|
||||
}
|
||||
public static final int maxRetries = 5;
|
||||
public static final String retryCountName = "retryCount";
|
||||
public int OnAttach(obj_id self) throws InterruptedException
|
||||
{
|
||||
messageTo(self, "pendingWarp", null, spawn.cleanupTime, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int spawnAttackPlayerShip(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id playerShip = params.getObjId("player");
|
||||
LOG("QUEST_SPAWN_LOG", "Attack! " + playerShip + ":" + self);
|
||||
ship_ai.spaceAttack(self, playerShip);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int pendingWarp(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
if (ship_ai.spaceIsInCombat(self))
|
||||
{
|
||||
int retryCount = params.getInt(retryCountName) + 1;
|
||||
if (retryCount <= maxRetries)
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Ship in combat - trying again. retryCount = " + retryCount + "/" + maxRetries);
|
||||
params.put(retryCountName, retryCount);
|
||||
messageTo(self, "pendingWarp", params, spawn.cleanupRetryTime, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Ship in combat - no more retries left.");
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
LOG("QUEST_SPAWN_LOG", "Destroying self = " + self);
|
||||
destroyObjectHyperspace(self);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int objectDestroyed(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int missionAbort(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDestroy(obj_id self) throws InterruptedException
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
// ================================================================================
|
||||
//
|
||||
// spawn_on_ship.script
|
||||
//
|
||||
// The script for managing ships dynamically spawned by the quest system.
|
||||
//
|
||||
// ================================================================================
|
||||
|
||||
include library.ship_ai;
|
||||
include quest.task.ground.spawn;
|
||||
|
||||
const int maxRetries = 5;
|
||||
const String retryCountName = "retryCount";
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnAttach()
|
||||
{
|
||||
messageTo( self, "pendingWarp", null, spawn.cleanupTime, false );
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
messageHandler spawnAttackPlayerShip()
|
||||
{
|
||||
obj_id playerShip = params.getObjId ("player");
|
||||
|
||||
LOG("QUEST_SPAWN_LOG", "Attack! " + playerShip + ":" + self);
|
||||
|
||||
ship_ai.spaceAttack(self, playerShip);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
messageHandler pendingWarp()
|
||||
{
|
||||
if (ship_ai.spaceIsInCombat(self))
|
||||
{
|
||||
int retryCount = params.getInt(retryCountName) + 1;
|
||||
|
||||
if (retryCount <= maxRetries)
|
||||
{
|
||||
LOG("QUEST_SPAWN_LOG", "Ship in combat - trying again. retryCount = " + retryCount + "/" + maxRetries);
|
||||
|
||||
params.put(retryCountName, retryCount);
|
||||
messageTo(self, "pendingWarp", params, spawn.cleanupRetryTime, false);
|
||||
}
|
||||
else
|
||||
LOG("QUEST_SPAWN_LOG", "Ship in combat - no more retries left.");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
LOG("QUEST_SPAWN_LOG", "Destroying self = " + self);
|
||||
destroyObjectHyperspace(self);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
messageHandler objectDestroyed()
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
messageHandler missionAbort()
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
trigger OnDestroy()
|
||||
{
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@@ -0,0 +1,197 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.ai.ai_combat;
|
||||
import script.library.ai_lib;
|
||||
import script.library.quests;
|
||||
import script.library.create;
|
||||
import script.library.groundquests;
|
||||
import script.library.locations;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
|
||||
public class static_escort extends script.quest.task.ground.base_task
|
||||
{
|
||||
public static_escort()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
public static final String dataTableColumnMovementType = "MOVEMENT_TYPE";
|
||||
public static final String dataTableColumnMaxAllowedDistance = "MAX_ALLOWED_ESCORT_DISTANCE";
|
||||
public static final String dataTableColumnPathToPointPre = "PATH_TO_POINT_POINT_";
|
||||
public static final String dataTableColumnLocationXPre = "LOCATION_X_POINT_";
|
||||
public static final String dataTableColumnLocationYPre = "LOCATION_Y_POINT_";
|
||||
public static final String dataTableColumnLocationZPre = "LOCATION_Z_POINT_";
|
||||
public static final String objvarEscortTarget = "target";
|
||||
public static final String objvarBeenWarnedDistance = "beenWarned";
|
||||
public static final String scriptNameEscortOnTarget = "quest.task.ground.static_escort_on_target";
|
||||
public static final String objvarOnCreatureOwner = "quest.static_escort.owner";
|
||||
public static final String objvarOnCreatureQuestCrc = "quest.static_escort.questCrc";
|
||||
public static final String objvarOnCreatureTaskId = "quest.static_escort.taskId";
|
||||
public static final String objvarPathToPoint = "quest.static_escort.pathToPoint";
|
||||
public static final String taskType = "static_escort";
|
||||
public static final String dot = ".";
|
||||
public static final float escortDistanceTimeCheck = 10;
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
String serverTemplate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
String movementType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMovementType);
|
||||
int pointIndex = 1;
|
||||
obj_id escortTarget = groundquests.getPendingStaticEscortTarget(self);
|
||||
groundquests.clearPendingStaticEscortTarget(self);
|
||||
if (escortTarget == null)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Could not get static escort target for this player from objvar, did you call groundquests.setPendingStaticEscortTarget(player, escortTarget) first?");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
attachScript(escortTarget, scriptNameEscortOnTarget);
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageStartStaticEscort", params, 0, false);
|
||||
detachScript(escortTarget, "ai.ai");
|
||||
setObjVar(escortTarget, objvarOnCreatureOwner, self);
|
||||
setObjVar(escortTarget, objvarOnCreatureQuestCrc, questCrc);
|
||||
setObjVar(escortTarget, objvarOnCreatureTaskId, taskId);
|
||||
setObjVar(escortTarget, objvarPathToPoint, pointIndex);
|
||||
setObjVar(self, baseObjVar + dot + objvarEscortTarget, escortTarget);
|
||||
int useFirstPoint = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPathToPointPre + pointIndex);
|
||||
if (useFirstPoint == 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "The first escort point is flagged as unused, so autocomplete the task");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
String xLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationXPre + pointIndex);
|
||||
String yLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationYPre + pointIndex);
|
||||
String zLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationZPre + pointIndex);
|
||||
location escortPoint = new location(utils.stringToFloat(xLoc), utils.stringToFloat(yLoc), utils.stringToFloat(zLoc), getCurrentSceneName());
|
||||
pathTo(escortTarget, escortPoint);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "pathing to new point " + escortPoint.x + ", " + escortPoint.y + ", " + escortPoint.z);
|
||||
}
|
||||
dictionary distanceCheckParams = new dictionary();
|
||||
distanceCheckParams.put("player", self);
|
||||
distanceCheckParams.put("escortTarget", escortTarget);
|
||||
distanceCheckParams.put("questCrc", questCrc);
|
||||
distanceCheckParams.put("taskId", taskId);
|
||||
messageTo(self, "messageStaticEscortCheckDistance", distanceCheckParams, escortDistanceTimeCheck, false);
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int messageStaticEscortCheckDistance(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id player = params.getObjId("player");
|
||||
obj_id escortTarget = params.getObjId("escortTarget");
|
||||
int questCrc = params.getInt("questCrc");
|
||||
int taskId = params.getInt("taskId");
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (isEscortNearby(questCrc, taskId, player, escortTarget))
|
||||
{
|
||||
if (hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
{
|
||||
removeObjVar(player, baseObjVar + objvarBeenWarnedDistance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
failEscortDistanceCheck(player, questCrc, taskId, escortTarget);
|
||||
}
|
||||
messageTo(self, "messageStaticEscortCheckDistance", params, escortDistanceTimeCheck, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageEscortTaskCreatureDied(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id deadCreature = params.getObjId("source");
|
||||
int questCrc = params.getInt("questCrc");
|
||||
int taskId = params.getInt("taskId");
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escortTarget = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
if (escortTarget == deadCreature)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "messageEscortTaskCreatureDied", "[" + deadCreature + "] being tracked for a static_escort has died.");
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean isEscortNearby(int questCrc, int taskId, obj_id player, obj_id escortTarget) throws InterruptedException
|
||||
{
|
||||
boolean result = false;
|
||||
if (isIdValid(player) && isIdValid(escortTarget))
|
||||
{
|
||||
int maxEscortDistance = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxAllowedDistance);
|
||||
result = getDistance(player, escortTarget) <= maxEscortDistance;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public void failEscortDistanceCheck(obj_id player, int questCrc, int taskId, obj_id escortTarget) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if (!hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
{
|
||||
setObjVar(player, baseObjVar + objvarBeenWarnedDistance, "true");
|
||||
string_id message = new string_id("quest/groundquests", "static_escort_distance_warning");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
prose.setDF(pp, escortDistanceTimeCheck);
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id("quest/groundquests", "static_escort_failed_due_to_distance");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
sendSystemMessageProse(player, pp);
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String escortTargetObjVarName = baseObjVar + dot + objvarEscortTarget;
|
||||
obj_id escortTarget = getObjIdObjVar(player, escortTargetObjVarName);
|
||||
if (escortTarget != null)
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageResetStaticEscortTarget", params, 0, false);
|
||||
}
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnLogout(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
include ai.ai_combat;
|
||||
include library.ai_lib;
|
||||
include library.quests;
|
||||
include library.create;
|
||||
include library.groundquests;
|
||||
include library.locations;
|
||||
include library.prose;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnServerTemplate = "SERVER_TEMPLATE";
|
||||
const String dataTableColumnMovementType = "MOVEMENT_TYPE";
|
||||
const String dataTableColumnMaxAllowedDistance = "MAX_ALLOWED_ESCORT_DISTANCE";
|
||||
const String dataTableColumnPathToPointPre = "PATH_TO_POINT_POINT_";
|
||||
const String dataTableColumnLocationXPre = "LOCATION_X_POINT_";
|
||||
const String dataTableColumnLocationYPre = "LOCATION_Y_POINT_";
|
||||
const String dataTableColumnLocationZPre = "LOCATION_Z_POINT_";
|
||||
|
||||
//objvars on player
|
||||
const String objvarEscortTarget = "target";
|
||||
const String objvarBeenWarnedDistance = "beenWarned";
|
||||
|
||||
//objvars on escort target
|
||||
const String scriptNameEscortOnTarget = "quest.task.ground.static_escort_on_target";
|
||||
const String objvarOnCreatureOwner = "quest.static_escort.owner";
|
||||
const String objvarOnCreatureQuestCrc = "quest.static_escort.questCrc";
|
||||
const String objvarOnCreatureTaskId = "quest.static_escort.taskId";
|
||||
const String objvarPathToPoint = "quest.static_escort.pathToPoint";
|
||||
|
||||
const String taskType = "static_escort";
|
||||
const String dot = ".";
|
||||
|
||||
const float escortDistanceTimeCheck = 10;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + " task activated.");
|
||||
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
|
||||
//gather data for this task
|
||||
String serverTemplate = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnServerTemplate);
|
||||
String movementType = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnMovementType);
|
||||
|
||||
int pointIndex = 1;
|
||||
|
||||
obj_id escortTarget = groundquests.getPendingStaticEscortTarget(self);
|
||||
groundquests.clearPendingStaticEscortTarget(self);
|
||||
if(escortTarget == null)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "Could not get static escort target for this player from objvar, did you call groundquests.setPendingStaticEscortTarget(player, escortTarget) first?");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
|
||||
attachScript(escortTarget, scriptNameEscortOnTarget);
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageStartStaticEscort", params, 0, false);
|
||||
|
||||
//TODO don't do this
|
||||
detachScript(escortTarget, "ai.ai");
|
||||
|
||||
setObjVar(escortTarget, objvarOnCreatureOwner, self);
|
||||
setObjVar(escortTarget, objvarOnCreatureQuestCrc, questCrc);
|
||||
setObjVar(escortTarget, objvarOnCreatureTaskId, taskId);
|
||||
setObjVar(escortTarget, objvarPathToPoint, pointIndex);
|
||||
setObjVar(self, baseObjVar + dot + objvarEscortTarget, escortTarget);
|
||||
|
||||
//get the first point, path to it
|
||||
int useFirstPoint = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPathToPointPre + pointIndex);
|
||||
if(useFirstPoint == 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "The first escort point is flagged as unused, so autocomplete the task");
|
||||
questCompleteTask(questCrc, taskId, self);
|
||||
}
|
||||
else
|
||||
{
|
||||
String xLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationXPre + pointIndex);
|
||||
String yLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationYPre + pointIndex);
|
||||
String zLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationZPre + pointIndex);
|
||||
location escortPoint = new location(utils.stringToFloat(xLoc), utils.stringToFloat(yLoc), utils.stringToFloat(zLoc), getCurrentSceneName());
|
||||
pathTo(escortTarget, escortPoint);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", "pathing to new point " + escortPoint.x + ", " + escortPoint.y + ", " + escortPoint.z);
|
||||
}
|
||||
|
||||
//set up first distance check pulse
|
||||
dictionary distanceCheckParams = new dictionary();
|
||||
distanceCheckParams.put("player", self);
|
||||
distanceCheckParams.put("escortTarget", escortTarget);
|
||||
distanceCheckParams.put("questCrc", questCrc);
|
||||
distanceCheckParams.put("taskId", taskId);
|
||||
messageTo(self, "messageStaticEscortCheckDistance", distanceCheckParams, escortDistanceTimeCheck, false);
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageStaticEscortCheckDistance()
|
||||
{
|
||||
obj_id player = params.getObjId("player");
|
||||
obj_id escortTarget = params.getObjId("escortTarget");
|
||||
int questCrc = params.getInt ("questCrc");
|
||||
int taskId = params.getInt ("taskId");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if(isEscortNearby(questCrc, taskId, player, escortTarget))
|
||||
{
|
||||
if(hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
removeObjVar(player, baseObjVar + objvarBeenWarnedDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
failEscortDistanceCheck(player, questCrc, taskId, escortTarget);
|
||||
}
|
||||
|
||||
//send message for next pulse
|
||||
//this is not an infinite loop because it checks distance each time, and fails the task if the distance check fails twice in a row
|
||||
messageTo(self, "messageStaticEscortCheckDistance", params, escortDistanceTimeCheck, false);
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageEscortTaskCreatureDied()
|
||||
{
|
||||
obj_id deadCreature = params.getObjId("source");
|
||||
int questCrc = params.getInt ("questCrc");
|
||||
int taskId = params.getInt ("taskId");
|
||||
|
||||
String baseObjVar = groundquests.getBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
obj_id escortTarget = getObjIdObjVar(self, baseObjVar + dot + objvarEscortTarget);
|
||||
if(escortTarget == deadCreature)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "messageEscortTaskCreatureDied", "[" + deadCreature + "] being tracked for a static_escort has died.");
|
||||
questFailTask(questCrc, taskId, self);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
boolean isEscortNearby(int questCrc, int taskId, obj_id player, obj_id escortTarget)
|
||||
{
|
||||
boolean result = false;
|
||||
if(isIdValid(player) && isIdValid(escortTarget))
|
||||
{
|
||||
int maxEscortDistance = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnMaxAllowedDistance);
|
||||
result = getDistance(player, escortTarget) <= maxEscortDistance;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void failEscortDistanceCheck(obj_id player, int questCrc, int taskId, obj_id escortTarget)
|
||||
{
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
if(!hasObjVar(player, baseObjVar + objvarBeenWarnedDistance))
|
||||
{
|
||||
//set objvar and warn player
|
||||
setObjVar(player, baseObjVar + objvarBeenWarnedDistance, "true");
|
||||
|
||||
string_id message = new string_id ("quest/groundquests", "static_escort_distance_warning");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
prose.setDF(pp, escortDistanceTimeCheck);
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_id message = new string_id ("quest/groundquests", "static_escort_failed_due_to_distance");
|
||||
prose_package pp = prose.getPackage(message, player, player, 0);
|
||||
sendSystemMessageProse(player, pp);
|
||||
|
||||
questFailTask(questCrc, taskId, player);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + " task completed.");
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + " task failed.");
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is cleared
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
|
||||
cleanup(self, questCrc, taskId);
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
// destroy the escort target
|
||||
String baseObjVar = groundquests.getBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
String escortTargetObjVarName = baseObjVar + dot + objvarEscortTarget;
|
||||
|
||||
obj_id escortTarget = getObjIdObjVar(player, escortTargetObjVarName);
|
||||
if(escortTarget != null)
|
||||
{
|
||||
dictionary params = new dictionary();
|
||||
messageTo(escortTarget, "messageResetStaticEscortTarget", params, 0, false);
|
||||
}
|
||||
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnLogout()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnInitialize()
|
||||
{
|
||||
groundquests.failAllActiveTasksOfType(self, taskType);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,108 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class static_escort_on_target extends script.base_script
|
||||
{
|
||||
public static_escort_on_target()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnPathToPointPre = "PATH_TO_POINT_POINT_";
|
||||
public static final String dataTableColumnLocationXPre = "LOCATION_X_POINT_";
|
||||
public static final String dataTableColumnLocationYPre = "LOCATION_Y_POINT_";
|
||||
public static final String dataTableColumnLocationZPre = "LOCATION_Z_POINT_";
|
||||
public static final String objvarQuest = "quest.static_escort";
|
||||
public static final String objvarOnCreatureOwner = "quest.static_escort.owner";
|
||||
public static final String objvarOnCreatureQuestCrc = "quest.static_escort.questCrc";
|
||||
public static final String objvarOnCreatureTaskId = "quest.static_escort.taskId";
|
||||
public static final String objvarPathToPoint = "quest.static_escort.pathToPoint";
|
||||
public static final String objvarStartingX = "quest.static_escort.startingX";
|
||||
public static final String objvarStartingY = "quest.static_escort.startingY";
|
||||
public static final String objvarStartingZ = "quest.static_escort.startingZ";
|
||||
public static final String objvarGoingHome = "quest.static_escort.goingHome";
|
||||
public static final String objvarOnEscort = "quest.static_escort.onEscort";
|
||||
public static final String taskType = "static_escort_on_target";
|
||||
public static final String scriptNameEscortOnTarget = "quest.task.ground.static_escort_on_target";
|
||||
public int messageStartStaticEscort(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
location l = getLocation(self);
|
||||
setObjVar(self, objvarStartingX, l.x);
|
||||
setObjVar(self, objvarStartingY, l.y);
|
||||
setObjVar(self, objvarStartingZ, l.z);
|
||||
setObjVar(self, objvarOnEscort, "true");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnDeath(obj_id self, obj_id killer, obj_id corpseId) throws InterruptedException
|
||||
{
|
||||
if (hasObjVar(self, objvarOnCreatureOwner) && hasObjVar(self, objvarOnCreatureQuestCrc) && hasObjVar(self, objvarOnCreatureTaskId))
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar(self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar(self, objvarOnCreatureTaskId);
|
||||
dictionary params = new dictionary();
|
||||
params.put("source", self);
|
||||
params.put("questCrc", questCrc);
|
||||
params.put("taskId", taskId);
|
||||
messageTo(player, "messageEscortTaskCreatureDied", params, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnMovePathComplete(obj_id self) throws InterruptedException
|
||||
{
|
||||
String goingHome = getStringObjVar(self, objvarGoingHome);
|
||||
if (goingHome != null && goingHome.equals("true"))
|
||||
{
|
||||
removeObjVar(self, objvarQuest);
|
||||
detachScript(self, scriptNameEscortOnTarget);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar(self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar(self, objvarOnCreatureTaskId);
|
||||
int reachedPathPoint = getIntObjVar(self, objvarPathToPoint);
|
||||
int nextPathPoint = reachedPathPoint + 1;
|
||||
int useNextPoint = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPathToPointPre + nextPathPoint);
|
||||
if (useNextPoint == 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "OnMovePathComplete", "The next escort point is flagged as unused, so completing the task");
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
String xLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationXPre + nextPathPoint);
|
||||
String yLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationYPre + nextPathPoint);
|
||||
String zLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationZPre + nextPathPoint);
|
||||
location escortPoint = new location(utils.stringToFloat(xLoc), utils.stringToFloat(yLoc), utils.stringToFloat(zLoc), getCurrentSceneName());
|
||||
setObjVar(self, objvarPathToPoint, nextPathPoint);
|
||||
pathTo(self, escortPoint);
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "OnMovePathComplete", "escort target + " + self + " pathing to new point [" + escortPoint.x + ", " + escortPoint.y + ", " + escortPoint.z + "]");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int messageResetStaticEscortTarget(obj_id self, dictionary params) throws InterruptedException
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar(self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar(self, objvarOnCreatureTaskId);
|
||||
float x = getFloatObjVar(self, objvarStartingX);
|
||||
float y = getFloatObjVar(self, objvarStartingY);
|
||||
float z = getFloatObjVar(self, objvarStartingZ);
|
||||
location startingPoint = new location(x, y, z, getCurrentSceneName());
|
||||
pathTo(self, startingPoint);
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "messageResetStaticEscortTarget", "escort target " + self + " going home to [" + startingPoint.x + ", " + startingPoint.y + ", " + startingPoint.z + "]");
|
||||
removeObjVar(self, objvarQuest);
|
||||
setObjVar(self, objvarGoingHome, "true");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
// This script goes on a creature spawned by the static_escort quest task type.
|
||||
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnPathToPointPre ="PATH_TO_POINT_POINT_";
|
||||
const String dataTableColumnLocationXPre ="LOCATION_X_POINT_";
|
||||
const String dataTableColumnLocationYPre ="LOCATION_Y_POINT_";
|
||||
const String dataTableColumnLocationZPre ="LOCATION_Z_POINT_";
|
||||
|
||||
//objvars on escort target
|
||||
const String objvarQuest = "quest.static_escort";
|
||||
const String objvarOnCreatureOwner = "quest.static_escort.owner";
|
||||
const String objvarOnCreatureQuestCrc = "quest.static_escort.questCrc";
|
||||
const String objvarOnCreatureTaskId = "quest.static_escort.taskId";
|
||||
const String objvarPathToPoint = "quest.static_escort.pathToPoint";
|
||||
const String objvarStartingX = "quest.static_escort.startingX";
|
||||
const String objvarStartingY = "quest.static_escort.startingY";
|
||||
const String objvarStartingZ = "quest.static_escort.startingZ";
|
||||
const String objvarGoingHome = "quest.static_escort.goingHome";
|
||||
const String objvarOnEscort = "quest.static_escort.onEscort";
|
||||
|
||||
const String taskType = "static_escort_on_target";
|
||||
|
||||
const String scriptNameEscortOnTarget = "quest.task.ground.static_escort_on_target";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageStartStaticEscort()
|
||||
{
|
||||
//store current position, so we can come back here at the end
|
||||
location l = getLocation(self);
|
||||
setObjVar(self, objvarStartingX, l.x);
|
||||
setObjVar(self, objvarStartingY, l.y);
|
||||
setObjVar(self, objvarStartingZ, l.z);
|
||||
setObjVar(self, objvarOnEscort, "true");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDeath(obj_id killer, obj_id corpseId)
|
||||
{
|
||||
//tell owner that we died
|
||||
if(hasObjVar(self, objvarOnCreatureOwner) && hasObjVar(self, objvarOnCreatureQuestCrc) && hasObjVar(self, objvarOnCreatureTaskId))
|
||||
{
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar (self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar (self, objvarOnCreatureTaskId);
|
||||
dictionary params = new dictionary();
|
||||
params.put("source", self);
|
||||
params.put("questCrc", questCrc);
|
||||
params.put("taskId", taskId);
|
||||
|
||||
messageTo(player, "messageEscortTaskCreatureDied", params, 0, false);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnMovePathComplete()
|
||||
{
|
||||
//see if we're returning to start location
|
||||
String goingHome = getStringObjVar(self, objvarGoingHome);
|
||||
if(goingHome != null && goingHome == "true")
|
||||
{
|
||||
//clear all objvar data, so we're ready for next escort
|
||||
removeObjVar(self, objvarQuest);
|
||||
detachScript(self, scriptNameEscortOnTarget);
|
||||
}
|
||||
//otherwise, we hit an escort location
|
||||
else
|
||||
{
|
||||
//get the quest and task we're involved in
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar (self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar (self, objvarOnCreatureTaskId);
|
||||
|
||||
//determine the next path point index
|
||||
int reachedPathPoint = getIntObjVar(self, objvarPathToPoint);
|
||||
int nextPathPoint = reachedPathPoint + 1;
|
||||
|
||||
//get the next point, path to it
|
||||
int useNextPoint = groundquests.getTaskIntDataEntry(questCrc, taskId, dataTableColumnPathToPointPre + nextPathPoint);
|
||||
if(useNextPoint == 0)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "OnMovePathComplete", "The next escort point is flagged as unused, so completing the task");
|
||||
questCompleteTask(questCrc, taskId, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
String xLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationXPre + nextPathPoint);
|
||||
String yLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationYPre + nextPathPoint);
|
||||
String zLoc = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnLocationZPre + nextPathPoint);
|
||||
location escortPoint = new location(utils.stringToFloat(xLoc), utils.stringToFloat(yLoc), utils.stringToFloat(zLoc), getCurrentSceneName());
|
||||
setObjVar(self, objvarPathToPoint, nextPathPoint);
|
||||
pathTo(self, escortPoint);
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "OnMovePathComplete", "escort target + " + self + " pathing to new point [" + escortPoint.x + ", " + escortPoint.y + ", " + escortPoint.z + "]");
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
messageHandler messageResetStaticEscortTarget()
|
||||
{
|
||||
//get the quest and task we're involved in
|
||||
obj_id player = getObjIdObjVar(self, objvarOnCreatureOwner);
|
||||
int questCrc = getIntObjVar (self, objvarOnCreatureQuestCrc);
|
||||
int taskId = getIntObjVar (self, objvarOnCreatureTaskId);
|
||||
|
||||
//send target back to starting point
|
||||
float x = getFloatObjVar(self, objvarStartingX);
|
||||
float y = getFloatObjVar(self, objvarStartingY);
|
||||
float z = getFloatObjVar(self, objvarStartingZ);
|
||||
location startingPoint = new location(x, y, z, getCurrentSceneName());
|
||||
pathTo(self, startingPoint);
|
||||
|
||||
groundquests.questOutputDebugInfo(player, questCrc, taskId, taskType, "messageResetStaticEscortTarget", "escort target " + self + " going home to [" + startingPoint.x + ", " + startingPoint.y + ", " + startingPoint.z + "]");
|
||||
|
||||
//remove static_escort specific objvars
|
||||
removeObjVar(self, objvarQuest);
|
||||
|
||||
//now put one back to say that we're walking home
|
||||
setObjVar(self, objvarGoingHome, "true");
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -0,0 +1,109 @@
|
||||
package script.quest.task.ground;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.groundquests;
|
||||
import script.library.utils;
|
||||
|
||||
public class talk_to_npc extends script.quest.task.ground.base_task
|
||||
{
|
||||
public talk_to_npc()
|
||||
{
|
||||
}
|
||||
public static final String dataTableColumnExperienceType = "NPC_NAME";
|
||||
public static final String taskType = "talk_to_npc";
|
||||
public static final String dot = ".";
|
||||
public static final String objvarNPCName = "npcName";
|
||||
public int OnTaskActivated(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + "task activated.");
|
||||
String npcName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnExperienceType);
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarNPCName, npcName);
|
||||
groundquests.questOutputDebugInfo(self, taskType, "OnStartConversation", "Player must talk to " + npcName + ".");
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
public int OnStartConversation(obj_id self, obj_id conversant) throws InterruptedException
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, taskType, "OnStartConversation", "Checking for talk_to_npc quest task completion.");
|
||||
String name = getName(conversant);
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if (taskObjVarName != null)
|
||||
{
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if (questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
String questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if (hasObjVar(self, questObjVarName))
|
||||
{
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if (taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
String taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
String nameObjVarName = questObjVarName + dot + taskName + dot + objvarNPCName;
|
||||
if (hasObjVar(self, nameObjVarName))
|
||||
{
|
||||
String npcName = getStringObjVar(self, nameObjVarName);
|
||||
if (name.equals(npcName))
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnStartConversation", "Target NPC " + npcName + " found.");
|
||||
questCompleteTask(questGetQuestId(questName), utils.stringToInt(taskName), self);
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnStartConversation", "NPC spoken to (" + name + ") does not match target (" + npcName + ").");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public int OnTaskCompleted(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskFailed(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
public int OnTaskCleared(obj_id self, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
public void cleanup(obj_id player, int questCrc, int taskId) throws InterruptedException
|
||||
{
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
public int OnDetach(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
include library.groundquests;
|
||||
include library.utils;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
inherits quest.task.ground.base_task;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
const String dataTableColumnExperienceType = "NPC_NAME";
|
||||
|
||||
const String taskType = "talk_to_npc";
|
||||
const String dot = ".";
|
||||
const String objvarNPCName = "npcName";
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when this task is added to the player
|
||||
trigger OnTaskActivated(int questCrc, int taskId)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskActivated", taskType + "task activated.");
|
||||
|
||||
//gather data for this task
|
||||
String npcName = groundquests.getTaskStringDataEntry(questCrc, taskId, dataTableColumnExperienceType);
|
||||
|
||||
//store objvar data for this task type
|
||||
String baseObjVar = groundquests.setBaseObjVar(self, taskType, questGetQuestName(questCrc), taskId);
|
||||
setObjVar(self, baseObjVar + dot + objvarNPCName, npcName);
|
||||
|
||||
groundquests.questOutputDebugInfo(self, taskType, "OnStartConversation", "Player must talk to " + npcName + ".");
|
||||
|
||||
return super.OnTaskActivated(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnStartConversation(obj_id conversant)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, taskType, "OnStartConversation", "Checking for talk_to_npc quest task completion.");
|
||||
|
||||
String name = getName(conversant);
|
||||
|
||||
//get the base objvar for talk_to_npcs quests, all data is under that
|
||||
String taskObjVarName = groundquests.getTaskTypeObjVar(self, taskType);
|
||||
if(taskObjVarName != null)
|
||||
{
|
||||
//get the list of talk_to_npcs quests
|
||||
obj_var_list questList = getObjVarList(self, taskObjVarName);
|
||||
if(questList != null)
|
||||
{
|
||||
int countQuests = questList.getNumItems();
|
||||
//for each talk_to_npcs quest, see if it cares about this object
|
||||
for (int i = 0; i < countQuests; ++i)
|
||||
{
|
||||
obj_var ov = questList.getObjVar(i);
|
||||
string questName = ov.getName();
|
||||
int questCrc = questGetQuestId(questName);
|
||||
|
||||
String questObjVarName = taskObjVarName + dot + questName;
|
||||
if(hasObjVar(self, questObjVarName))
|
||||
{
|
||||
//get the list of tasks for this quest that are talk_to_npcs
|
||||
obj_var_list taskList = getObjVarList(self, questObjVarName);
|
||||
if(taskList != null)
|
||||
{
|
||||
int countTasks = taskList.getNumItems();
|
||||
for (int j = 0; j < countTasks; ++j)
|
||||
{
|
||||
obj_var ov2 = taskList.getObjVar(j);
|
||||
string taskName = ov2.getName();
|
||||
int taskId = utils.stringToInt(taskName);
|
||||
|
||||
//get the spawn list for this talk_to_npcs task
|
||||
String nameObjVarName = questObjVarName + dot + taskName + dot + objvarNPCName;
|
||||
if(hasObjVar(self, nameObjVarName))
|
||||
{
|
||||
String npcName = getStringObjVar(self, nameObjVarName);
|
||||
if(name == npcName)
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnStartConversation", "Target NPC " + npcName + " found.");
|
||||
questCompleteTask(questGetQuestId(questName), utils.stringToInt(taskName), self);
|
||||
}
|
||||
else
|
||||
{
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnStartConversation", "NPC spoken to (" + name + ") does not match target (" + npcName + ").");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is completed
|
||||
trigger OnTaskCompleted(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCompleted", taskType + "task completed.");
|
||||
return super.OnTaskCompleted(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
//fires when the task is failed
|
||||
trigger OnTaskFailed(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskFailed", taskType + "task failed.");
|
||||
return super.OnTaskFailed(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnTaskCleared(int questCrc, int taskId)
|
||||
{
|
||||
cleanup(self, questCrc, taskId);
|
||||
groundquests.questOutputDebugInfo(self, questCrc, taskId, taskType, "OnTaskCleared", taskType + " task cleared.");
|
||||
return super.OnTaskCleared(self, questCrc, taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
void cleanup(obj_id player, int questCrc, int taskId)
|
||||
{
|
||||
//clear tracking objvars
|
||||
groundquests.clearBaseObjVar(player, taskType, questGetQuestName(questCrc), taskId);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
trigger OnDetach()
|
||||
{
|
||||
//make sure the base objvar is removed
|
||||
removeObjVar(self, groundquests.getTaskTypeObjVar(self, taskType));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user