mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-29 23:15:55 -04:00
137 lines
4.4 KiB
Plaintext
137 lines
4.4 KiB
Plaintext
|
|
include library.space_quest;
|
|
include library.utils;
|
|
|
|
trigger OnAttach()
|
|
{
|
|
sendSystemMessageTestingOnly( self, "MISSION TEST SCRIPT ATTACHED" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnSpeaking( string text )
|
|
{
|
|
string[] commands = split( text, ' ' );
|
|
|
|
if (commands[0].equalsIgnoreCase("namequest"))
|
|
{
|
|
obj_id datapad = utils.getPlayerDatapad( self );
|
|
if ( isIdValid( datapad ) )
|
|
{
|
|
// Search for a quest in the datapad that has a specific name.
|
|
obj_id[] dpobjs = getContents( datapad );
|
|
for ( int i=0; i<dpobjs.length; i++ )
|
|
{
|
|
if ( hasObjVar( dpobjs[i], space_quest.QUEST_TYPE ) )
|
|
{
|
|
string tname = getStringObjVar( dpobjs[i], space_quest.QUEST_TYPE );
|
|
string qname = getStringObjVar( dpobjs[i], space_quest.QUEST_NAME );
|
|
sendSystemMessageTestingOnly( self, "Found: " + tname + ":" + qname );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (commands[0].equalsIgnoreCase("grantquest"))
|
|
{
|
|
if ( commands.length < 3 )
|
|
{
|
|
sendSystemMessageTestingOnly(self, "unable to parse: " + text );
|
|
sendSystemMessageTestingOnly(self, "say GRANTQUEST QUESTTYPE QUESTNAME" + text );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (!space_quest.grantQuest( self, commands[1], commands[2] ))
|
|
{
|
|
sendSystemMessageTestingOnly(self, "FAILED: " + text );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
else if (commands[0].equalsIgnoreCase("checkquest"))
|
|
{
|
|
if ( commands.length < 3 )
|
|
{
|
|
sendSystemMessageTestingOnly(self, "unable to parse: " + text );
|
|
sendSystemMessageTestingOnly(self, "say CHECKQUEST QUESTTYPE QUESTNAME" + text );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if ( space_quest.hasQuest( self, commands[1], commands[2] ) )
|
|
sendSystemMessageTestingOnly(self, "hasQuest: TRUE" );
|
|
else
|
|
sendSystemMessageTestingOnly(self, "hasQuest: FALSE" );
|
|
|
|
if ( space_quest.hasCompletedQuest( self, commands[1], commands[2] ) )
|
|
sendSystemMessageTestingOnly(self, "hasCompletedQuest: TRUE" );
|
|
else
|
|
sendSystemMessageTestingOnly(self, "hasCompletedQuest: FALSE" );
|
|
|
|
if ( space_quest.hasFailedQuest( self, commands[1], commands[2] ) )
|
|
sendSystemMessageTestingOnly(self, "hasFailedQuest: TRUE" );
|
|
else
|
|
sendSystemMessageTestingOnly(self, "hasFailedQuest: FALSE" );
|
|
|
|
if ( space_quest.hasWonQuest( self, commands[1], commands[2] ) )
|
|
sendSystemMessageTestingOnly(self, "hasWonQuest: TRUE" );
|
|
else
|
|
sendSystemMessageTestingOnly(self, "hasWonQuest: FALSE" );
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if (commands[0].equalsIgnoreCase("clearquest"))
|
|
{
|
|
if ( commands.length < 3 )
|
|
{
|
|
sendSystemMessageTestingOnly(self, "unable to parse: " + text );
|
|
sendSystemMessageTestingOnly(self, "say CLEARQUEST QUESTTYPE QUESTNAME" + text );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
space_quest.clearQuestFlags( self, commands[1], commands[2] );
|
|
sendSystemMessageTestingOnly(self, commands[1] + ":" + commands[2] + " quest flags cleared" );
|
|
}
|
|
else if (commands[0].equalsIgnoreCase("winquest"))
|
|
{
|
|
if ( commands.length < 3 )
|
|
{
|
|
sendSystemMessageTestingOnly(self, "unable to parse: " + text );
|
|
sendSystemMessageTestingOnly(self, "say WINQUEST QUESTTYPE QUESTNAME" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
string questType = commands[1];
|
|
string questName = commands[2];
|
|
string qTable = "datatables/spacequest/"+questType+"/"+questName+".iff";
|
|
dictionary questInfo = dataTableGetRow( qTable, 0 );
|
|
if ( questInfo == null )
|
|
{
|
|
sendSystemMessageTestingOnly( self, "Unable to find quest data for " + questType + ":" + questName + "!" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id missionObj = space_quest._getQuest( self, questType, questName );
|
|
if ( missionObj == null )
|
|
{
|
|
sendSystemMessageTestingOnly( self, "You don't have that quest." );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
int splittype = questInfo.getInt( "triggerSplitCondition" );
|
|
string splitmission = questInfo.getString( "triggerArg" );
|
|
if ( (splitmission == null) || splitmission.equals( "" ) || (splittype == 2) )
|
|
{
|
|
// There is no split. Just win the mission.
|
|
space_quest.setQuestWon( self, missionObj, false );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
// There is a split in this quest.
|
|
space_quest.setQuestWon( self, missionObj, false );
|
|
|
|
sendSystemMessageTestingOnly( self, "--- Forced Victory on Split Mission, Assigning Split ---" );
|
|
|
|
// Split.
|
|
java.util.StringTokenizer st = new java.util.StringTokenizer( splitmission, ":" );
|
|
string rtype = st.nextToken();
|
|
string rname = st.nextToken();
|
|
space_quest.grantQuest( self, rtype, rname );
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|