Page 1 of 1

Town Crier: 1.0

Posted: Sun Sep 10, 2006 11:30 pm
by stranf
This script takes Xuri's wonderful Wandering Healer Script and switches some things around to make it work with town criers. If the town crier is attached to this script, the town crier will:
Town crier speaks 1 text string when a PC approaches
Town crier speaks 1 text string when a PC leaves
Town crier will give 4 random responses when a PC says "news" to the crier.

Posted: Sun Sep 10, 2006 11:35 pm
by stranf
Install the script. to customize what the town crier says, scroll to PUT TEXT HERE, and follow the comments on which lines you can put in your custom text strings. The crier will not say the new texts until after the server has been restarted, or the JS scripts are loaded via GM or console command.
// Town Crier
// v1.00
// by Stranf (stranf@hotmail.com
// using Xuri's Wandering Healer Script as a template.
// by Xuri (xuri@sensewave.com)


// The town crier script will force town criers to shout out the message encoded in the script
// scroll down to the **INSERT TEXT HERE** and change the text in the quotes to make the town crier speak.
//
//
//

// DON'T CHANGE THIS VALUE:
var i = 0;

// searchAmount = Number of times healer will look around for chars to heal/resurrect before stopping
// searchInterval = The interval at wihch the healer looks around for chars to heal/resurrect after having started searching
// searchRange = The radius in which the healer searches for wounded people
// searchTimer = Amount of time between each time the healer initiates his searches
// resTimer = Minimum time that must pass before healer will resurrect same char again (1000 = 1 second)
// healTimer = Minimum time that must pass before healer will heal same char again (1000 = 1 second)
// manaCostHeal = the amount of mana the NPC uses for healing
// manaCostRes = the amount of mana the NPC uses for resurrecting
var searchAmount = 3;
var searchInterval = 2500;
var searchRange = 4;
var searchTimer = 7500;
var resTimer = 15000;
var healTimer = 30000;
var manaCostHeal = 11;
var manaCostRes = 50;

// These variables can be customized or commented out if you don't want to use them
//var healSoundFX = 0x01f2;
//var healGFXEffect = 0x376A;
//var resSoundFX = 0x376A;
//var resGFXEffect = 0x376A;

// These messages can be customized. If you don't want to use them at all, comment them out

// **PUT TEXT HERE**

// these scripts are activated when the PC says "news"
var crierMsg1= "The quest for 8 virtues will take a lifetime.";
var crierMsg2 = "The king is searching for one who can conquer the virtues.";
var crierMsg3 = "The rumor is the quest is not for wealth or riches.";
var crierMsg4 = "It is said, only the pure in heart can accomplish the task.";

// This message is fired if the PC is criminal.
var criminalReply = "Thou art a criminal and I will not assist thee!";

// These two messages start and begin when the pc approaches the crier.
var startSearchEmote = "*Shouts* Hear ye!  Hear ye!  The King seeks adventurers!";
var endSearchEmote = "All who wish to respond, go to Castle British.";


function inRange( pCharacter, objInRange )
{
   if( objInRange.isChar )
   {
      // Get the current server clock, and if it exists, the time for when the last search was started
      // Compare the two, and the script will see if enough time has passed to initiate a new search
      // This also ensures that the script stays working even if the server saves in the middle of a
      // search, but crashes before the next save.
      var iTime = GetCurrentClock();
      var initSearchTime = pCharacter.GetTag( "initSearchTime" );
      //If search has already been initiated, don't start a new search, unless an abnormal amount of time has passed
      if(( initSearchTime != null && initSearchTime != 0 ) && ((( iTime - initSearchTime ) <searchTimer> iTime )))
      {
        // pCharacter.TextMessage( initSearchTime + " " + iTime + " " + searchTimer );
        // return;
      }
      else if((( iTime - initSearchTime ) > searchTimer ) || initSearchTime > iTime )
      {
         pCharacter.SetTag( "initSearchTime", iTime );
         if( startSearchEmote )
            pCharacter.EmoteMessage( startSearchEmote );
         pCharacter.StartTimer( searchInterval, 1, true );
      }
   }
}

// This triggers the keyword-based healing/resurrection
function onSpeech( strSaid, pTalking, npcHealer )
{
   if( strSaid == "news" )
   {
      npcHealer.TurnToward( pTalking );
      doHeal( pTalking, npcHealer );
   }
   return false;
}

// This is the general function for healing characters
function doHeal( woundedChar, npcHealer )
{
   var dice;
   dice = RollDice(1,20,0);

   if (dice < 6)
   {
     npcHealer.TextMessage(crierMsg1);
     return;
   }
   if (dice < 11)
   {
     npcHealer.TextMessage(crierMsg2);
     return;
   }
   if (dice < 16)
   {
     npcHealer.TextMessage(crierMsg3);
     return;
   }
     npcHealer.TextMessage(crierMsg4);






}


function onTimer( srcChar, timerID )
{
   if( timerID == 1 )
   { //Search for nearby wounded characters the specified amount of times
      if( i < searchAmount )
      {

         i++;
      }
      else
      {
         i = 0;
         srcChar.EmoteMessage( endSearchEmote );
      }
   }
}


Posted: Tue Jul 17, 2007 5:28 am
by neynadia
Thank you for the script. :) It was very easy to install.