Skip to content

Commit 84037aa

Browse files
authored
Ephemeral room support (#367)
# Description This adds support for Ephemeral rooms. Ephemeral rooms are instances of rooms that are unique and get their own RoomId's. They cannot be saved to disk, and are cleaned up when all players leave the group of instanced/ephemeral rooms. This is accomplished by allocating a range of RoomId's that are used only by ephemeral ID's. Room's being copied get their RoomId replaced with a newly generated one. ## Changes - Eliminated Tutorial Room copies so there is now only one of each tutorial room. - Starting the tutorial now creates an ephemeral copy and puts the player in it. - Fixed up tutorial scripts to add a little more delay in tutorial instructions. - Updated config.yaml so that `TutorialStartRooms` is now a complete list of all tutorial rooms, starting with the "tutorial start" room. - `rooms/ephemeral.go` handles ephemeral room specifics. - Added some script cleanup to scripting, various event handlers, etc. all for managing the pieces of this. - Cleaned up some code and moved to its own event handlers, such as the Guide spawning checks.
1 parent 31e5425 commit 84037aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+792
-8231
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ clean-instances: ### Deletes all room instance data. Starts the world fresh.
7474
run: generate ### Build and run server.
7575
@go run .
7676

77+
.PHONY: run-new
78+
run-new: clean-instances generate run ### Deletes instance data and runs server
79+
7780
.PHONY: run-docker
7881
run-docker: ### Build and run server in docker.
7982
$(DOCKER_COMPOSE) up --build --remove-orphans server

_datafiles/config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,12 @@ SpecialRooms:
457457
# This should have some way of healing them and (eventually)
458458
# sending them back into the main world.
459459
DeathRecoveryRoom: 75
460-
# - TutorialStartRooms -
461-
# RoomIds players will be put in when starting the game/tutorial
462-
# RoomIds 900-999 are reserved for Tutorial rooms.
463-
TutorialStartRooms: [900, 910, 920, 930, 940, 990]
460+
# - TutorialRooms -
461+
# This should be an array of all room id's for the pre-start tutorial.
462+
# The first one on the list is the room they will be placed in when beginning
463+
# Rooms 900-999 are a special range of RoomId's that tell GoMud the user is
464+
# in a tutorial.
465+
TutorialRooms: [900, 901, 902, 903]
464466

465467
################################################################################
466468
#

_datafiles/guides/building/scripting/FUNCTIONS_ROOMS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Room Specific Functions
22

33
- [Room Specific Functions](#room-specific-functions)
4+
- [CreateInstancesFromRoomIds(RoomIds \[int, int...\]) Object ](#createinstancesfromroomidsroomids-int-int-object-)
5+
- [CreateInstancesFromZone(zoneName string) Object ](#createinstancesfromzonezonename-string-object-)
46
- [GetRoom(roomId int) RoomObject ](#getroomroomid-int-roomobject-)
57
- [RoomObject.RoomId() int](#roomobjectroomid-int)
68
- [RoomObject.SendText(msg string\[, excludeUserIds int\])](#roomobjectsendtextmsg-string-excludeuserids-int)
@@ -27,6 +29,22 @@
2729
- [RoomObject.RepeatSpawnItem(itemId int, roundInterval int \[, containerName\]](#roomobjectrepeatspawnitemitemid-int-roundinterval-int--containername)
2830
- [RoomObject.SetLocked(exitName string, lockIt bool)](#roomobjectsetlockedexitname-string-lockit-bool)
2931

32+
## [CreateInstancesFromRoomIds(RoomIds [int, int...]) Object ](/internal/scripting/room_func.go)
33+
Returns an Object with key/value pairs of `ProvidedRoomId`=>`NewRoomId`
34+
Creates ephemeral instances of the RoomId's provided.
35+
36+
| Argument | Explanation |
37+
| --- | --- |
38+
| RoomIds | an array of integers containing RoomId's you want instanced |
39+
40+
## [CreateInstancesFromZone(zoneName string) Object ](/internal/scripting/room_func.go)
41+
Returns an Object with key/value pairs of `ProvidedRoomId`=>`NewRoomId`
42+
Creates ephemeral instances of the RoomIds of the zone provided.
43+
44+
| Argument | Explanation |
45+
| --- | --- |
46+
| zoneName | The name of the zone to create instances from the zone rooms |
47+
3048
## [GetRoom(roomId int) RoomObject ](/internal/scripting/room_func.go)
3149
Retrieves a RoomObject for a given roomId.
3250

_datafiles/world/default/rooms/tutorial/900.js

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ function onCommand(cmd, rest, user, room) {
1818

1919
teacherMob = getTeacher(room);
2020

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

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

@@ -32,17 +34,21 @@ function onCommand(cmd, rest, user, room) {
3234

3335
if ( teach_commands[commandNow] == fullCommand ) {
3436

35-
teacherMob.Command("say Good job!");
37+
teacherMob.Command("say Good job!", 1.0);
3638

37-
if ( cmd == "look orb" ) {
38-
teacherMob.Command('say As you can see, looking at me shows you a description and some information about what I\'m carrying.');
39+
extraDelay = 1.0;
40+
41+
if ( fullCommand == "look orb" ) {
42+
teacherMob.Command('say As you can see, looking at me shows you a description and some information about what I\'m carrying.', 2.0);
43+
extraDelay = 2.0;
3944
}
4045

41-
if ( cmd == "look east" ) {
42-
teacherMob.Command('say Looking into exits like that shows you what (or who) is in a room before you visit it.');
43-
teacherMob.Command('say Later when you find objects, you can look at them in the same manner.');
44-
teacherMob.Command('say It\'s always worth trying to look at something you\'re curious about, just in case.');
45-
teacherMob.Command('emote considers for a moment.');
46+
if ( fullCommand == "look east" ) {
47+
teacherMob.Command('say Looking into exits like that shows you what (or who) is in a room before you visit it.', 2.0);
48+
teacherMob.Command('say Later when you find objects, you can look at them in the same manner.', 3.0);
49+
teacherMob.Command('say It\'s always worth trying to look at something you\'re curious about, just in case.', 4.0);
50+
teacherMob.Command('emote considers for a moment.', 5.0);
51+
extraDelay = 7.0;
4652
}
4753

4854
commandNow++;
@@ -57,28 +63,28 @@ function onCommand(cmd, rest, user, room) {
5763

5864
switch (commandNow) {
5965
case 0:
60-
teacherMob.Command('say The first thing you need to learn is how to inspect your surroundings');
61-
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.');
66+
teacherMob.Command('say The first thing you need to learn is how to inspect your surroundings', extraDelay+1.0);
67+
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);
6268
break;
6369
case 1:
64-
teacherMob.Command('say You can also look at creatures or people in the room.');
65-
teacherMob.Command('say type <ansi fg="command">look orb</ansi> to look at me, ' + teacherMob.GetCharacterName(true) + '.');
70+
teacherMob.Command('say You can also look at creatures or people in the room.', extraDelay+1.0);
71+
teacherMob.Command('say type <ansi fg="command">look orb</ansi> to look at me, ' + teacherMob.GetCharacterName(true) + '.', extraDelay+2.0);
6672
break;
6773
case 2:
68-
teacherMob.Command('say Try the <ansi fg="command">look</ansi> command again, but this time, pay attention to any Exits.');
74+
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);
6975
break;
7076
case 3:
71-
teacherMob.Command('say Did you notice there is an exit to the <ansi fg="exit">east</ansi>?');
72-
teacherMob.Command('say type <ansi fg="command">look east</ansi> to look into the <ansi fg="exit">east</ansi> room.');
77+
teacherMob.Command('say Did you notice there is an exit to the <ansi fg="exit">east</ansi>?', extraDelay+1.0);
78+
teacherMob.Command('say type <ansi fg="command">look east</ansi> to look into the <ansi fg="exit">east</ansi> room.', extraDelay+2.0);
7379
break;
7480
case 4:
7581
canGoEast = true;
76-
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.');
77-
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.');
82+
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.', extraDelay+1.0);
83+
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.', extraDelay+2.0);
7884
break;
7985
default:
80-
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.');
81-
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.');
86+
teacherMob.Command('say It\'s time to move on to the next thing you\'ll learn about.', extraDelay+1.0);
87+
teacherMob.Command('say type <ansi fg="command">east</ansi> to travel through the <ansi fg="command">east</ansi> exit.', extraDelay+2.0);
8288
break;
8389
}
8490

@@ -98,10 +104,10 @@ function onEnter(user, room) {
98104

99105
teacherMob.Command('emote appears in a ' + UtilApplyColorPattern("flash of light!", "glowing"));
100106

101-
teacherMob.Command('say Welcome to the Newbie School!');
102-
teacherMob.Command('say I\'ll give you some tips to help you get started.');
103-
teacherMob.Command('say In this area you\'ll learn the basics of inspecting your environment with the <ansi fg="command">look</ansi> command.');
104-
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.');
107+
teacherMob.Command('say Welcome to the Newbie School!', 1.0);
108+
teacherMob.Command('say I\'ll give you some tips to help you get started.', 2.0);
109+
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);
110+
teacherMob.Command('say type <ansi fg="command">look</ansi> and hit enter to see a description of the area you are in.', 5.0);
105111
}
106112

107113

_datafiles/world/default/rooms/tutorial/901.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function onCommand(cmd, rest, user, room) {
1919

2020
teacherMob = getTeacher(room);
2121

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

2425
if ( cmd == "south" && !canGoSouth ) {
@@ -33,16 +34,19 @@ function onCommand(cmd, rest, user, room) {
3334

3435
if ( teach_commands[commandNow] == fullCommand ) {
3536

36-
teacherMob.Command("say Good job!");
37+
teacherMob.Command("say Good job!", 1.0);
38+
extraDelay = 1.0;
3739

3840
if ( cmd == "status" ) {
39-
teacherMob.Command('say You can see how much gold you carry, your Level, and even attributes like Strength and Smarts.');
40-
teacherMob.Command('say It\'s a lot of information, but you quickly learn to only pay attention to the important stuff.');
41+
teacherMob.Command('say You can see how much gold you carry, your Level, and even attributes like Strength and Smarts.', 2.0);
42+
teacherMob.Command('say It\'s a lot of information, but you quickly learn to only pay attention to the important stuff.', 3.0);
43+
extraDelay = 3.0;
4144
}
4245

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

4852
commandNow++;
@@ -63,24 +67,24 @@ function onCommand(cmd, rest, user, room) {
6367
user.GiveItem(itm);
6468
}
6569

66-
teacherMob.Command('say To see all of your characters stats, type <ansi fg="command">status</ansi>.');
70+
teacherMob.Command('say To see all of your characters stats, type <ansi fg="command">status</ansi>.', extraDelay+1.0);
6771
break;
6872
case 1:
69-
teacherMob.Command('say To only peek at your inventory, type <ansi fg="command">inventory</ansi>.');
73+
teacherMob.Command('say To only peek at your inventory, type <ansi fg="command">inventory</ansi>.', extraDelay+1.0);
7074
break;
7175
case 2:
72-
teacherMob.Command('say As you solve quests and defeat enemies in combat, you\'ll gain experience points and your character will "Level up".');
73-
teacherMob.Command('say For quick look at your progress, type <ansi fg="command">experience</ansi>.');
76+
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);
77+
teacherMob.Command('say For quick look at your progress, type <ansi fg="command">experience</ansi>.', extraDelay+2.0);
7478
break;
7579
case 3:
7680
teacherMob.Command('emote touches you and you feel more focused.');
7781
user.GiveBuff(32, "training");
78-
teacherMob.Command('say Sometimes you might become afflicted with a condition. Conditions can have good or bad effects.');
79-
teacherMob.Command('say type <ansi fg="command">conditions</ansi> to see any statuses affecting you.');
82+
teacherMob.Command('say Sometimes you might become afflicted with a condition. Conditions can have good or bad effects.',extraDelay+1.0);
83+
teacherMob.Command('say type <ansi fg="command">conditions</ansi> to see any statuses affecting you.', extraDelay+2.0);
8084
break;
8185
case 4:
8286
user.GiveBuff(-32, "training");
83-
teacherMob.Command('say head <ansi fg="command">south</ansi> for the next lesson.');
87+
teacherMob.Command('say head <ansi fg="command">south</ansi> for the next lesson.', extraDelay+1.0);
8488
canGoSouth = true;
8589
room.SetLocked("south", false);
8690
break;
@@ -105,8 +109,8 @@ function onEnter(user, room) {
105109

106110
teacherMob.Command('emote appears in a ' + UtilApplyColorPattern("flash of light!", "glowing"));
107111

108-
teacherMob.Command('say Hi! I\'m here to teach you about inspecting your characters information.');
109-
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.');
112+
teacherMob.Command('say Hi! I\'m here to teach you about inspecting your characters information.', 1.0);
113+
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);
110114
}
111115

112116

_datafiles/world/default/rooms/tutorial/902.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function onCommand(cmd, rest, user, room) {
1717

1818
teacherMob = getTeacher(room);
1919

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

2223
if ( cmd == "south" && !canGoSouth ) {
@@ -31,15 +32,19 @@ function onCommand(cmd, rest, user, room) {
3132

3233
if ( teach_commands[commandNow] == fullCommand ) {
3334

34-
teacherMob.Command("say Good job!");
35+
teacherMob.Command("say Good job!", 1.0);
36+
37+
extraDelay = 1.0;
3538

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

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

4550
commandNow++;
@@ -65,14 +70,14 @@ function onCommand(cmd, rest, user, room) {
6570
user.GiveItem(itm);
6671
}
6772

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

7277
getDummy(room);
7378

74-
teacherMob.Command('say You may have noticed the <ansi fg="mobname">training dummy</ansi> here.');
75-
teacherMob.Command('say Go ahead and engage in combat by typing <ansi fg="command">attack dummy</ansi>.');
79+
teacherMob.Command('say You may have noticed the <ansi fg="mobname">training dummy</ansi> here.', extraDelay+1.0);
80+
teacherMob.Command('say Go ahead and engage in combat by typing <ansi fg="command">attack dummy</ansi>.', extraDelay+2.0);
7681
break;
7782
case 2:
7883
// teacherMob.Command('say Head <ansi fg="exit">west</ansi> to complete your training.');
@@ -98,14 +103,14 @@ function onEnter(user, room) {
98103

99104
teacherMob.Command('emote appears in a ' + UtilApplyColorPattern("flash of light!", "glowing"));
100105

101-
teacherMob.Command('say It looks like it\'s time for the most dangerous part of your lesson!');
106+
teacherMob.Command('say It looks like it\'s time for the most dangerous part of your lesson!', 1.0);
102107

103108
if ( !user.HasItemId(firstItemId) ) {
104109
itm = CreateItem(firstItemId);
105110
user.GiveItem(itm);
106111
}
107112

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

111116

0 commit comments

Comments
 (0)