SCRIPT-CONVERSATION-EXAMPLE
The Script behavior can also be used to simulate a conversation between two or more mobs pretty easily. For example, let's say you had three mobiles, Arast, Grunde, and Belmonte that were to have a conversation in front of a player upon a player completing a quest and entering the room to return to the quest givers. Say for example that the three mobiles spawn in room 1000. Enter in the following ("js" has been abbreviated to "j", and "gojs" has been abbreviated to "g"):
> mb grunde javascript created Room.at( 1000 ).grunde = self;
> mb belmonte javascript created Room.at( 1000 ).belmonte = self;
> mb araste javascript (enterroom js 'actor.db.arastesGambit') .
speed 1d4+2
g .
araste = self;
// arastesGambit == 0 means they haven't taken the quest
// arastesGambit == 1 means they completed the quest, but haven't been rewarded yet
// arastesGambit == 2 means they completed the quest and were rewarded
if ( actor.db.arastesGambit == 2 ) {
araste.talk( actor, "I hope the sword is serving you well!" );
return "end";
}
grunde = Room.at( 1000 ).grunde;
belmonte = Room.at( 1000 ).belmonte;
araste.say( "Ahhh ... our little apprentice has returned victorious!" );
return "next";
!
j belmonte.talk( actor, "We are quite proud of you!" );
j grunde.say( "Bah! I knew ' + actor + ' could do it!' );
j araste.say( "Nevertheless, it is still impressive." );
j araste.act( "smile", grunde );
j araste.act( "shake", actor );
j grunde.act( "shake", actor );
j belmonte.act( "shake", actor );
j araste.say( "Let's go upstairs ... I have something to show you." );
j .
grunde.act( "follow", araste );
belmonte.act( "follow", araste );
actor.act( "follow", araste );
!
j araste.act( "u" );
j araste.say( "Here ... take this sword!" );
j araste.act( "me pulls an ancient sword off the mantle." );
j .
sword = Obj.invoke( 1003, araste ); // 1003 is the vnum of the sword
sword.shortDesc = Mud.possessionDesc( actor.shortDesc, sword.shortDesc );
sword.setFlag( 'nodrop', true );
actor.db.arastesGambit = 2;
araste.act( "give sword", actor );
!
j belmonte.say( "Use the sword well!" );
j grunde.act( "smile", actor );
j araste.say( "Well, our purpose here in these realms is done. Take care!" );
j araste.act( "wave", actor );
j belmonte.act( "wave", actor ); grunde.act( "wave", actor );
j inRoom.amsg( "And with their task completed ... the three wizards teleport away..." );
j belmonte.purge(); grunde.purge(); araste.purge();