Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function onDie(mob, room, eventDetails) {

teacherMob = getTeacher(room);

teacherMob.Command('say You did it! Head <ansi fg="exit">west</ansi> to complete your training.');
teacherMob.Command('say You did it! As you can see you gain <ansi fg="experience">experience points</ansi> for combat victories.');
teacherMob.Command('say Now head <ansi fg="exit">west</ansi> to complete your training.', 2.0);
}


Expand Down
45 changes: 20 additions & 25 deletions _datafiles/world/default/rooms/tutorial/900.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ function onCommand(cmd, rest, user, room) {

teacherMob = getTeacher(room);

var extraDelay = 0;
// Make sure they are only doing stuff that's allowed.

if ( cmd == "east" && !canGoEast ) {
teacherMob.Command("say Not so hasty! Lets finish the basics before you leave this area.");
extraDelay = 1.0;
ignoreCommand = true;
}

Expand All @@ -36,19 +34,16 @@ function onCommand(cmd, rest, user, room) {

teacherMob.Command("say Good job!", 1.0);

extraDelay = 1.0;

if ( fullCommand == "look orb" ) {
teacherMob.Command('say As you can see, looking at me shows you a description and some information about what I\'m carrying.', 2.0);
extraDelay = 2.0;
teacherMob.Command('say As you can see, looking at me shows you a description and some information about what I\'m carrying.', 1.0);
}

if ( fullCommand == "look east" ) {
teacherMob.Command('say Looking into exits like that shows you what (or who) is in a room before you visit it.', 2.0);
teacherMob.Command('say Later when you find objects, you can look at them in the same manner.', 3.0);
teacherMob.Command('say It\'s always worth trying to look at something you\'re curious about, just in case.', 4.0);
teacherMob.Command('emote considers for a moment.', 5.0);
extraDelay = 7.0;
teacherMob.Command('say Looking into exits like that shows you what (or who) is in a room before you visit it.', 1.0);
teacherMob.Command('say Later when you find objects, you can look at them in the same manner.', 1.0);
teacherMob.Command('say It\'s always worth trying to look at something you\'re curious about, just in case.', 1.0);
teacherMob.Command('emote considers for a moment.', 1.0);
teacherMob.Command('noop', 3.0);
}

commandNow++;
Expand All @@ -63,28 +58,28 @@ function onCommand(cmd, rest, user, room) {

switch (commandNow) {
case 0:
teacherMob.Command('say The first thing you need to learn is how to inspect your surroundings', extraDelay+1.0);
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.', extraDelay+2.0);
teacherMob.Command('say The first thing you need to learn is how to inspect your surroundings', 1.0);
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.', 1.0);
break;
case 1:
teacherMob.Command('say You can also look at creatures or people in the room.', extraDelay+1.0);
teacherMob.Command('say type <ansi fg="command">look orb</ansi> to look at me, ' + teacherMob.GetCharacterName(true) + '.', extraDelay+2.0);
teacherMob.Command('say You can also look at creatures or people in the room.', 1.0);
teacherMob.Command('say type <ansi fg="command">look orb</ansi> to look at me, ' + teacherMob.GetCharacterName(true) + '.', 1.0);
break;
case 2:
teacherMob.Command('say Try the <ansi fg="command">look</ansi> command again, but this time, pay attention to any <ansi fg="exit">exits</ansi>.', extraDelay+1.0);
teacherMob.Command('say Try the <ansi fg="command">look</ansi> command again, but this time, pay attention to any <ansi fg="exit">exits</ansi>.', 1.0);
break;
case 3:
teacherMob.Command('say Did you notice there is an exit to the <ansi fg="exit">east</ansi>?', extraDelay+1.0);
teacherMob.Command('say type <ansi fg="command">look east</ansi> to look into the <ansi fg="exit">east</ansi> room.', extraDelay+2.0);
teacherMob.Command('say Did you notice there is an exit to the <ansi fg="exit">east</ansi>?', 1.0);
teacherMob.Command('say type <ansi fg="command">look east</ansi> to look into the <ansi fg="exit">east</ansi> room.', 1.0);
break;
case 4:
canGoEast = true;
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.', extraDelay+1.0);
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.', extraDelay+2.0);
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.', 1.0);
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.', 1.0);
break;
default:
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.', extraDelay+1.0);
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.', extraDelay+2.0);
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.', 1.0);
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.', 1.0);
break;
}

Expand All @@ -105,9 +100,9 @@ function onEnter(user, room) {
teacherMob.Command('emote appears in a ' + UtilApplyColorPattern("flash of light!", "glowing"));

teacherMob.Command('say Welcome to the Newbie School!', 1.0);
teacherMob.Command('say I\'ll give you some tips to help you get started.', 2.0);
teacherMob.Command('say In this area you\'ll learn the basics of inspecting your environment with the <ansi fg="command">look</ansi> command.', 3.0);
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.', 5.0);
teacherMob.Command('say I\'ll give you some tips to help you get started.', 1.0);
teacherMob.Command('say In this area you\'ll learn the basics of inspecting your environment with the <ansi fg="command">look</ansi> command.', 1.0);
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.', 1.0);
}


Expand Down
30 changes: 14 additions & 16 deletions _datafiles/world/default/rooms/tutorial/901.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function onCommand(cmd, rest, user, room) {

teacherMob = getTeacher(room);

var extraDelay = 0;
// Make sure they are only doing stuff that's allowed.

if ( cmd == "south" && !canGoSouth ) {
Expand All @@ -35,18 +34,15 @@ function onCommand(cmd, rest, user, room) {
if ( teach_commands[commandNow] == fullCommand ) {

teacherMob.Command("say Good job!", 1.0);
extraDelay = 1.0;

if ( cmd == "status" ) {
teacherMob.Command('say You can see how much gold you carry, your Level, and even attributes like Strength and Smarts.', 2.0);
teacherMob.Command('say It\'s a lot of information, but you quickly learn to only pay attention to the important stuff.', 3.0);
extraDelay = 3.0;
teacherMob.Command('say You can see how much <ansi fg="yellow">Gold</ansi> you carry, your <ansi fg="yellow">Level</ansi>, and even attributes like <ansi fg="yellow">Strength</ansi> and <ansi fg="yellow">Smarts</ansi>.', 1.0);
teacherMob.Command('say It\'s a lot of information, but you\'ll quickly learn to only pay attention to the important stuff.', 1.0);
}

if ( cmd == "inventory" ) {
teacherMob.Command('say Hmm, it doesn\'t look like you\'re carrying much other than that sharp stick.', 2.0);
teacherMob.Command('say Remember, you can <ansi fg="command">look</ansi> at stuff you\'re carrying any time you want.', 3.0);
extraDelay = 3.0;
teacherMob.Command('say Hmm, it doesn\'t look like you\'re carrying much other than that <ansi fg="item">sharp stick</ansi>.', 1.0);
teacherMob.Command('say Remember, you can <ansi fg="command">look</ansi> at stuff you\'re carrying any time you want.', 1.0);
}

commandNow++;
Expand All @@ -67,24 +63,26 @@ function onCommand(cmd, rest, user, room) {
user.GiveItem(itm);
}

teacherMob.Command('say To see all of your characters stats, type <ansi fg="command">status</ansi>.', extraDelay+1.0);
teacherMob.Command('say To see all of your characters stats, type <ansi fg="command">status</ansi>.', 1.0);
break;
case 1:
teacherMob.Command('say To only peek at your inventory, type <ansi fg="command">inventory</ansi>.', extraDelay+1.0);
teacherMob.Command('say To only peek at your inventory, type <ansi fg="command">inventory</ansi>.', 1.0);
break;
case 2:
teacherMob.Command('say As you solve quests and defeat enemies in combat, you\'ll gain experience points and your character will "Level up".', extraDelay+1.0);
teacherMob.Command('say For quick look at your progress, type <ansi fg="command">experience</ansi>.', extraDelay+2.0);
teacherMob.Command('say As you solve quests and defeat enemies in combat, you\'ll gain experience points and your character will "Level up".', 1.0);
teacherMob.Command('say For quick look at your progress, type <ansi fg="command">experience</ansi>.', 1.0);
break;
case 3:
teacherMob.Command('emote touches you and you feel more focused.');
user.GiveBuff(32, "training");
teacherMob.Command('say Sometimes you might become afflicted with a condition. Conditions can have good or bad effects.',extraDelay+1.0);
teacherMob.Command('say type <ansi fg="command">conditions</ansi> to see any statuses affecting you.', extraDelay+2.0);
teacherMob.Command('noop', 2);
teacherMob.Command('say Sometimes you might become afflicted with a condition. Conditions can have good or bad effects (and sometimes both!).',1.0);
teacherMob.Command('say type <ansi fg="command">conditions</ansi> to see any statuses affecting you.', 1.0);
break;
case 4:
user.GiveBuff(-32, "training");
teacherMob.Command('say head <ansi fg="command">south</ansi> for the next lesson.', extraDelay+1.0);
teacherMob.Command('say Some special conditions might last indefinitely, such as natural abilities like night vision. Others may expire after enough time passes.', 1.0);
teacherMob.Command('say head <ansi fg="command">south</ansi> for the next lesson.', 1.0);
canGoSouth = true;
room.SetLocked("south", false);
break;
Expand All @@ -110,7 +108,7 @@ function onEnter(user, room) {
teacherMob.Command('emote appears in a ' + UtilApplyColorPattern("flash of light!", "glowing"));

teacherMob.Command('say Hi! I\'m here to teach you about inspecting your characters information.', 1.0);
teacherMob.Command('say To get a detailed view of a LOT of information all at once, type <ansi fg="command">status</ansi> and hit enter.', 2.0);
teacherMob.Command('say To get a detailed view of a LOT of information all at once, type <ansi fg="command">status</ansi> and hit enter.', 1.0);
}


Expand Down
19 changes: 7 additions & 12 deletions _datafiles/world/default/rooms/tutorial/902.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function onCommand(cmd, rest, user, room) {

teacherMob = getTeacher(room);

var extraDelay = 0;
// Make sure they are only doing stuff that's allowed.

if ( cmd == "south" && !canGoSouth ) {
Expand All @@ -34,17 +33,13 @@ function onCommand(cmd, rest, user, room) {

teacherMob.Command("say Good job!", 1.0);

extraDelay = 1.0;

if ( cmd == "equip stick" ) {
teacherMob.Command('say Check it out! If you type <ansi fg="command">status</ansi> you\'ll see the stick is equipped!', 2.0);
extraDelay = 2.0;
teacherMob.Command('say Check it out! If you type <ansi fg="command">status</ansi> you\'ll see the stick is equipped!', 1.0);
}

if ( cmd == "inventory" ) {
teacherMob.Command('say Hmm, it doesn\'t look like you\'re carrying much other than that sharp stick.', 2.0);
teacherMob.Command('say Remember, you can <ansi fg="command">look</ansi> at stuff you\'re carrying any time you want.', 3.0);
extraDelay = 3.0;
teacherMob.Command('say Hmm, it doesn\'t look like you\'re carrying much other than that sharp stick.', 1.0);
teacherMob.Command('say Remember, you can <ansi fg="command">look</ansi> at stuff you\'re carrying any time you want.', 1.0);
}

commandNow++;
Expand All @@ -70,14 +65,14 @@ function onCommand(cmd, rest, user, room) {
user.GiveItem(itm);
}

teacherMob.Command('say Go ahead and equip that sharp stick you\'ve got. Type <ansi fg="command">equip stick</ansi>.', extraDelay+1.0);
teacherMob.Command('say Go ahead and equip that sharp stick you\'ve got. Type <ansi fg="command">equip stick</ansi>.', 1.0);
break;
case 1:

getDummy(room);

teacherMob.Command('say You may have noticed the <ansi fg="mobname">training dummy</ansi> here.', extraDelay+1.0);
teacherMob.Command('say Go ahead and engage in combat by typing <ansi fg="command">attack dummy</ansi>.', extraDelay+2.0);
teacherMob.Command('say You may have noticed the <ansi fg="mobname">training dummy</ansi> here.', 1.0);
teacherMob.Command('say Go ahead and engage in combat by typing <ansi fg="command">attack dummy</ansi>. Don\'t worry, it can\'t hurt you.', 1.0);
break;
case 2:
// teacherMob.Command('say Head <ansi fg="exit">west</ansi> to complete your training.');
Expand Down Expand Up @@ -110,7 +105,7 @@ function onEnter(user, room) {
user.GiveItem(itm);
}

teacherMob.Command('say Go ahead and equip that sharp stick you\'ve got. Type <ansi fg="command">equip stick</ansi>.', 2.0);
teacherMob.Command('say Go ahead and equip that sharp stick you\'ve got. Type <ansi fg="command">equip stick</ansi>.', 1.0);
}


Expand Down
24 changes: 10 additions & 14 deletions _datafiles/world/default/rooms/tutorial/903.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ function onCommand(cmd, rest, user, room) {

teacherMob = getTeacher(room);

var extraDelay = 0;

fullCommand = cmd;
if ( rest.length > 0 ) {
fullCommand = cmd + ' ' + rest;
Expand All @@ -35,8 +33,6 @@ function onCommand(cmd, rest, user, room) {
teacherMob.Command("say Good job! You earned it!", 1.0);
}

extraDelay = 1.0;

commandNow++;

} else {
Expand All @@ -50,24 +46,24 @@ function onCommand(cmd, rest, user, room) {

switch (commandNow) {
case 0:
teacherMob.Command('emote gestures to the <ansi fg="item">graduation cap</ansi> on the ground.', extraDelay+2.0);
teacherMob.Command('say type <ansi fg="command">get cap</ansi> to pick up the <ansi fg="item">graduation cap</ansi>.', extraDelay+3.0);
teacherMob.Command('emote gestures to the <ansi fg="item">graduation cap</ansi> on the ground.', 1.0);
teacherMob.Command('say type <ansi fg="command">get cap</ansi> to pick up the <ansi fg="item">graduation cap</ansi>.', 1.0);
break;
case 1:
teacherMob.Command('say Go ahead and wear the <ansi fg="item">graduation cap</ansi> by typing <ansi fg="command">equip cap</ansi>.', extraDelay+2.0);
teacherMob.Command('say Go ahead and wear the <ansi fg="item">graduation cap</ansi> by typing <ansi fg="command">equip cap</ansi>.', 1.0);
break;
case 2:

teacherMob.Command('say It\'s time to say goodbye', extraDelay+1.0);
teacherMob.Command('say I\ll summon a portal to send you to the heart of Frostfang city, where your adventure begins.', extraDelay+2.0);
teacherMob.Command('say It\'s time to say goodbye', 1.0);
teacherMob.Command('say I\'ll summon a portal to send you to the heart of <ansi fg="zone">Frostfang city</ansi>, where your adventure begins.', 1.0);

exits = room.GetExits();
if ( !exits.portal ) {
teacherMob.Command('emote glows intensely, and a ' + UtilApplyColorPattern('swirling portal', 'pink') + ' appears!', extraDelay+3.0);
room.AddTemporaryExit('swirling portal', ':pink', 0, 9000); // RoomId 0 is an alias for start room
teacherMob.Command('emote glows intensely, and a ' + UtilApplyColorPattern('swirling portal', 'pink') + ' appears!', 1.0);
room.AddTemporaryExit('swirling portal', ':pink', 0, "1 real day"); // RoomId 0 is an alias for start room. Portal can live a long time since the room is ephemeral.
}

teacherMob.Command('say Enter the portal by typing <ansi fg="command">swirling portal</ansi> (or just <ansi fg="command">portal</ansi>) when you are ready.', extraDelay+4.0);
teacherMob.Command('say Enter the portal by typing <ansi fg="command">swirling portal</ansi> (or just <ansi fg="command">portal</ansi>) when you are ready.', 1.0);

break;
default:
Expand All @@ -94,9 +90,9 @@ function onEnter(user, room) {
teacherMob.Command('emote appears in a ' + UtilApplyColorPattern("flash of light!", "glowing"));

teacherMob.Command('say Congratulation on getting to the end of the training course!', 1.0);
teacherMob.Command('drop cap', 2.0);
teacherMob.Command('drop cap', 1.0);
teacherMob.Command('emote gestures to the <ansi fg="item">graduation cap</ansi> on the ground.', 3.0);
teacherMob.Command('say type <ansi fg="command">get cap</ansi> to pick up the <ansi fg="item">graduation cap</ansi>.', 4.0);
teacherMob.Command('say type <ansi fg="command">get cap</ansi> to pick up the <ansi fg="item">graduation cap</ansi>.', 1.0);

}

Expand Down
24 changes: 20 additions & 4 deletions internal/mobs/mobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Mob struct {
tempDataStore map[string]any
conversationId int // Identifier of conversation currently involved in.
Path PathQueue `yaml:"-"` // a pre-calculated path the mob is following.
lastCommandTurn uint64 // The last turn a command was scheduled for
}

func MobInstanceExists(instanceId int) bool {
Expand Down Expand Up @@ -324,17 +325,32 @@ func (m *Mob) Sleep(seconds int) {
func (m *Mob) Command(inputTxt string, waitSeconds ...float64) {

readyTurn := util.GetTurnCount()
turnDelay := uint64(0)

// m.lastCommandTurn is used so that subsequent calls to Command()
// are scheduled from this period forward.
// If it's been long enough that the current turn has surpassed the lastCommandTurn, we failover to that.
if readyTurn > m.lastCommandTurn {
m.lastCommandTurn = readyTurn
} else {
readyTurn = m.lastCommandTurn
}

if len(waitSeconds) > 0 {
readyTurn += uint64(float64(configs.GetTimingConfig().SecondsToTurns(1)) * waitSeconds[0])
turnDelay = uint64(float64(configs.GetTimingConfig().SecondsToTurns(1)) * waitSeconds[0])
}

for _, cmd := range strings.Split(inputTxt, `;`) {
for i, cmd := range strings.Split(inputTxt, `;`) {

// Update lastCommandTurn to whenever this command is scheduled for
m.lastCommandTurn = readyTurn + turnDelay + uint64(i)

events.AddToQueue(events.Input{
MobInstanceId: m.InstanceId,
InputText: cmd,
ReadyTurn: readyTurn,
ReadyTurn: m.lastCommandTurn,
})
readyTurn++

}

}
Expand Down
Loading