This script is made up of two scripts, taskmaster.js and global.js. Notably the global.js must be incorporated into whatever script you have set to ID 0 (if none, then simply set it to script ID 0). taskmaster.js simply needs to be assigned to whatever NPC you choose to offer these quests.
taskmaster.js
// v1.2+
// Last Update: September 22, 2008
// This script is designed to reward players with gold for completing kill tasks at varying levels
// Note that this script will not function properly without the accompanying onDeathBlow() global script.
// Thanks goes to the default UOX3 speech.js writers for the speech handling code.
// Please note that this script is designed for use with UOX3 v0.98-3.2l and above.
function onSpeech( myString, myPlayer, myNPC )
{
if( !myNPC.InRange( myPlayer, 2 ) )
return;
var startQuest = myPlayer.GetTag( "KT_START" );
var Speech_Array = myString.split(" ");
var i = 0, currObj = 0;
for( i = 1; i <Speech_Array> 0 )
myNPC.TextMessage( "Alas, you still have "+NumToString( numToKill )+" more monsters to slay before you receive your reward!" );
else
{
myNPC.TextMessage( "Wonderful work my friend, here is your reward." );
var goldToGive = 0;
switch( taskLevel )
{
case 1: goldToGive = 500; break;
case 2: goldToGive = 1000; break;
case 3: goldToGive = 2000; break;
case 4: goldToGive = 4000; break;
}
CreateDFNItem( myPlayer.socket, myPlayer, "0x0EED", goldToGive, "ITEM", true );
myPlayer.SoundEffect( 0x0037, false );
myPlayer.SetTag( "KT_NUMTOKILL", 0 );
myPlayer.SetTag( "KT_IDTOKILL", 0 );
myPlayer.SetTag( "KT_LEVEL", 0 );
}
}
else
myNPC.TextMessage( "You must first take on a task to receive a reward." );
}
else if( startQuest )
{
if( Speech_Array[currObj].match( /\bNovice\b/i ) )
{
myNPC.TurnToward( myPlayer );
var numToKill = RandomNumber( 3, 7 );
var typeToKill = CreateGenericQuest( myPlayer, 1, numToKill );
myNPC.TextMessage( "Excellent, please return to me after you have slain "+NumToString( numToKill )+" "+typeToKill+"." );
}
else if( Speech_Array[currObj].match( /\bJourneyman\b/i ) )
{
myNPC.TurnToward( myPlayer );
var numToKill = RandomNumber( 3, 7 );
var typeToKill = CreateGenericQuest( myPlayer, 2, numToKill );
myNPC.TextMessage( "Excellent, please return to me after you have slain "+NumToString( numToKill )+" "+typeToKill+"." );
}
else if( Speech_Array[currObj].match( /\bAdept\b/i ) )
{
myNPC.TurnToward( myPlayer );
var numToKill = RandomNumber( 3, 7 );
var typeToKill = CreateGenericQuest( myPlayer, 3, numToKill );
myNPC.TextMessage( "Excellent, please return to me after you have slain "+NumToString( numToKill )+" "+typeToKill+"." );
}
else if( Speech_Array[currObj].match( /\bGrandmaster\b/i ) )
{
myNPC.TurnToward( myPlayer );
var numToKill = RandomNumber( 3, 7 );
var typeToKill = CreateGenericQuest( myPlayer, 4, numToKill );
myNPC.TextMessage( "Excellent, please return to me after you have slain "+NumToString( numToKill )+" "+typeToKill+"." );
}
}
++currObj;
}
}
function CreateGenericQuest( myPlayer, questLevel, numToKill )
{
var typeToKill = GetMonsterType( myPlayer, questLevel );
myPlayer.SetTag( "KT_NUMTOKILL", numToKill );
myPlayer.SetTag( "KT_LEVEL", questLevel );
myPlayer.SetTag( "KT_START", 0 );
return typeToKill;
}
function GetMonsterType( myPlayer, questLevel )
{
var retVal = "";
switch( questLevel )
{
case 1:
switch( RandomNumber( 0, 2 ) )
{
case 0:
myPlayer.SetTag( "KT_IDTOKILL", 0x008c );
retVal = "orcish mages";
break;
case 1:
myPlayer.SetTag( "KT_IDTOKILL", 0x008f );
retVal = "ratman shaman";
break;
case 2:
myPlayer.SetTag( "KT_IDTOKILL", 0x0002 );
retVal = "ettins";
break;
}
break;
case 2:
switch( RandomNumber( 0, 2 ) )
{
case 0:
myPlayer.SetTag( "KT_IDTOKILL", 0x0004 );
retVal = "gargoyles";
break;
case 1:
myPlayer.SetTag( "KT_IDTOKILL", 0x0016 );
retVal = "gazers";
break;
case 2:
myPlayer.SetTag( "KT_IDTOKILL", 0x008a );
retVal = "orc lords";
break;
}
break;
case 3:
switch( RandomNumber( 0, 2 ) )
{
case 0:
myPlayer.SetTag( "KT_IDTOKILL", 0x0018 );
retVal = "liches";
break;
case 1:
myPlayer.SetTag( "KT_IDTOKILL", 0x0089 );
retVal = "ophidian avengers";
break;
case 2:
myPlayer.SetTag( "KT_IDTOKILL", 0x004c );
retVal = "titans";
break;
}
break;
case 4:
switch( RandomNumber( 0, 2 ) )
{
case 0:
myPlayer.SetTag( "KT_IDTOKILL", 0x002e );
retVal = "ancient wyrms";
break;
case 1:
myPlayer.SetTag( "KT_IDTOKILL", 0x0028 );
retVal = "balrons";
break;
case 2:
myPlayer.SetTag( "KT_IDTOKILL", 0x0054 );
retVal = "ogre lords";
break;
}
break;
}
return retVal;
}
{
var oldNumToKill = pKiller.GetTag( "KT_NUMTOKILL" );
if( oldNumToKill && pKiller.GetTag( "KT_IDTOKILL" ) == pKilled.id )
{
var newNumToKill = (oldNumToKill-1);
pKiller.SetTag( "KT_NUMTOKILL", newNumToKill );
if( newNumToKill )
pKiller.SysMessage( "You have "+NumToString( newNumToKill )+" more creatures to kill." );
else
pKiller.SysMessage( "You have completed your task, return to the taskmaster for your reward." );
}
}