TourGuide

What it does
Instructs an NPC TourGuide to follow behind a PC and offer area-specific comments.

Note
Triggers are used to indicate positions at which comments are made. See comments at top of script for instructions on use.

The script
//:://///////////////////////////////////////////// //:: TourGuide script //:: Copyright (c) 2002 Bioware Corp. //::////////////////////////////////////////////// /*   Instructs a TourGuide NPC to follow PC around and offer hints when the PC steps on triggers place this script - in each trigger's OnEnter event (use Name of trigger to distiguish multiple triggers in same area) - in TourGuide's Conversation End files to initiate behavior (i.e., to follow PC) - in TourGuide's Heartbeat to recover behavior if the TourGuide already has Heartbeat or ConversationEnd scripts, add the line ExecuteScript("TourGuide",OBJECT_SELF); To activate the TourGuide, use the command SetLocalInt( oTourGuide, "Active", TRUE ), comment out nActive=TRUE line below, and cause this script to run OR leave the nActive=TRUE line below and cause this script to run (via conversation with TourGuide) TourGuide should have Tag "TourGuide" and should be given an appropriate Voice Set Customize text and behavior in TourGuideText function at bottom of script //::////////////////////////////////////////////// //:: Created By: Keith Voss (fendis_khan) //:: Created On: 16 Dec 2002 //::////////////////////////////////////////////// // FUNCTION DECLARATIONS // returns text appropriate to the current area // - position of oTrigger deteremines area string TourGuideText( object oTrigger ); // tells oTourGuide how to behave toward oPC; // - bTalk indicates whether to speak when called // - bHello indicates whether to greet with a hello // - oTrigger indicates trigger that called script void TourGuideBehavior( object oPC, int bTalk=TRUE, int bHello=TRUE, object oTrigger=OBJECT_INVALID ); void main {   object oPC; object oTourGuide = GetObjectByTag("TourGuide"); int nActive = GetLocalInt( oTourGuide, "Active" ); nActive = TRUE; // *** keep this line, unless you want to set TourGuide "Active" in another script *** if ( nActive == FALSE ) return; // do not run script if TourGuide not active if ( GetIsObjectValid(GetEnteringObject) )   // script is called from trigger {       object oTrigger = OBJECT_SELF; oPC = GetEnteringObject; if ( !GetIsPC(oPC) || IsInConversation(oTourGuide) ) return;                // do not run if entering object is not PC or if TourGuide is in a conversation if ( !GetIsObjectValid(oTourGuide) || GetIsDead(oTourGuide) ) return;                // do not run script if TourGuide does not exist, or is dead SetLocalObject( oTourGuide, "FollowPC", oPC ); AssignCommand( oTourGuide, TourGuideBehavior(oPC,TRUE,TRUE,oTrigger) ); // initiate behavior }   else if ( GetIsObjectValid(GetPCSpeaker) )    // script is called from conversation {       oPC = GetPCSpeaker; SetLocalObject( oTourGuide, "FollowPC", oPC ); AssignCommand( oTourGuide, TourGuideBehavior(oPC,FALSE) ); // initiate behavior, do not talk yet }   else                                            // assumes script is called from heartbeat {       oPC = GetLocalObject( oTourGuide, "FollowPC" ); if ( GetDistanceBetween( oTourGuide, oPC ) > 4.0 ) {           AssignCommand( oTourGuide, TourGuideBehavior(oPC,FALSE,FALSE) );  // recover follow behavior, no talking }   } }