Skip to content

Commit 516c427

Browse files
authored
Room Exit Messages (#232)
# Changes * Added room exit messages to exit definitions * Added prompt for customizing exit message in `room edit exits` command * Exit messages display and then wait 1 second before continuing through the exit. * Fixing `zone edit` prompt around music to allow for no music, and provides relative path if needed.
1 parent a4d09fe commit 516c427

File tree

135 files changed

+324
-215
lines changed

Some content is hidden

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

135 files changed

+324
-215
lines changed

_datafiles/guides/building/scripting/FUNCTIONS_ACTORS.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ ActorObjects are the basic object that represents Users and NPCs
2929
- [ActorObject.AddGold(amt int \[, bankAmt int\])](#actorobjectaddgoldamt-int--bankamt-int)
3030
- [ActorObject.AddHealth(amt int) int](#actorobjectaddhealthamt-int-int)
3131
- [ActorObject.Sleep(seconds int)](#actorobjectsleepseconds-int)
32-
- [ActorObject.Command(cmd string, waitTurns ...int)](#actorobjectcommandcmd-string-waitturns-int)
32+
- [ActorObject.Command(cmd string \[, waitTurns int\])](#actorobjectcommandcmd-string--waitturns-int)
33+
- [ActorObject.CommandFlagged(cmd string, flag int \[, waitTurns int\])](#actorobjectcommandflaggedcmd-string-flag-int--waitturns-int)
3334
- [ActorObject.IsTameable() bool](#actorobjectistameable-bool)
3435
- [ActorObject.TrainSkill(skillName string, skillLevel int)](#actorobjecttrainskillskillname-string-skilllevel-int)
3536
- [ActorObject.GetSkillLevel(skillName string)](#actorobjectgetskilllevelskillname-string)
@@ -259,7 +260,7 @@ _Note: Only works on mobs._
259260
| --- | --- |
260261
| seconds | How many seconds to wait. |
261262

262-
## [ActorObject.Command(cmd string, waitTurns ...int)](/internal/scripting/actor_func.go)
263+
## [ActorObject.Command(cmd string [, waitTurns int])](/internal/scripting/actor_func.go)
263264
Forces an ActorObject to execute a command as if they entered it
264265

265266
_Note: Don't underestimate the power of this function! Complex and interesting behaviors or interactions can emerge from using it._
@@ -269,6 +270,18 @@ _Note: Don't underestimate the power of this function! Complex and interesting b
269270
| cmd | The command to execute such as `look west` or `say goodbye`. |
270271
| waitTurns (optional) | The number of turns (NOT rounds) to wait before executing the command. |
271272

273+
## [ActorObject.CommandFlagged(cmd string, flag int [, waitTurns int])](/internal/scripting/actor_func.go)
274+
Forces an ActorObject to execute a command as if they entered it.
275+
WARNING: Advanced Usage. Required a flag integer.
276+
277+
_Note: Don't underestimate the power of this function! Complex and interesting behaviors or interactions can emerge from using it._
278+
279+
| Argument | Explanation |
280+
| --- | --- |
281+
| cmd | The command to execute such as `look west` or `say goodbye`. |
282+
| flag | The special control flag to pass to the command. |
283+
| waitTurns (optional) | The number of turns (NOT rounds) to wait before executing the command. |
284+
272285
## [ActorObject.IsTameable() bool](/internal/scripting/actor_func.go)
273286
Returns `true` if actor can be tamed.
274287

_datafiles/world/default/users/admin.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ character:
6363
- buffid: 28
6464
onstartevent: true
6565
permabuff: true
66-
roundcounter: 28
66+
roundcounter: 23
6767
triggersleft: 1000000000
6868
- buffid: 29
6969
onstartevent: true
7070
permabuff: true
71-
roundcounter: 36
71+
roundcounter: 16
7272
triggersleft: 1000000000
7373
- buffid: 39
7474
onstartevent: false
7575
permabuff: true
76-
roundcounter: 10
76+
roundcounter: 5
7777
triggersleft: 1000000000
7878
equipment:
7979
weapon:

internal/events/eventtypes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Input struct {
3535
MobInstanceId int
3636
InputText string
3737
WaitTurns int
38+
Flags uint64
3839
}
3940

4041
func (i Input) Type() string { return `Input` }

internal/exit/exit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type RoomExit struct {
1616
RoomId int
1717
Secret bool `yaml:"secret,omitempty"`
1818
MapDirection string `yaml:"mapdirection,omitempty"` // Optionaly indicate the direction of this exit for mapping purposes
19+
ExitMessage string `yaml:"exitmessage,omitempty"` // If set, this message is sent to the user, followed by a delay, before they actually go through the exit.
1920
Lock gamelock.Lock `yaml:"lock,omitempty"` // 0 - no lock. greater than zero = difficulty to unlock.
2021
}
2122

internal/scripting/actor_func.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,17 @@ func (a ScriptActor) Command(cmd string, waitTurns ...int) {
309309
}
310310
}
311311

312+
func (a ScriptActor) CommandFlagged(cmd string, flags int, waitTurns ...int) {
313+
if len(waitTurns) < 1 {
314+
waitTurns = append(waitTurns, 0)
315+
}
316+
if a.userId > 0 {
317+
a.userRecord.CommandFlagged(cmd, uint64(flags), waitTurns[0])
318+
} else {
319+
a.mobRecord.Command(cmd, waitTurns[0])
320+
}
321+
}
322+
312323
func (a ScriptActor) TrainSkill(skillName string, skillLevel int) bool {
313324

314325
if a.userRecord == nil {

internal/usercommands/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The `usercommands` package defines a function type and contains all of the commands a user can enter.
44

55
```
6-
type UserCommand func(rest string, user *users.UserRecord, room *rooms.Room) (bool, error)
6+
type UserCommand func(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error)
77
```
88

99
All commands follow that definition, where
@@ -13,7 +13,7 @@ All commands follow that definition, where
1313

1414
```
1515
16-
func Glarble(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
16+
func Glarble(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {
1717
1818
room.SendText(`This glarble text goes out to all players in room`)
1919

internal/usercommands/admin.badcommands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/volte6/gomud/internal/users"
1010
)
1111

12-
func BadCommands(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
12+
func BadCommands(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {
1313

1414
if rest == "clear" {
1515
badinputtracker.Clear()

internal/usercommands/admin.buff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/volte6/gomud/internal/users"
1717
)
1818

19-
func Buff(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
19+
func Buff(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {
2020

2121
// args should look like one of the following:
2222
// target buffId - put buff on target if in the room

internal/usercommands/admin.build.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/volte6/gomud/internal/util"
1313
)
1414

15-
func IBuild(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
15+
func IBuild(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {
1616

1717
// args should look like one of the following:
1818
// info <optional room id>
@@ -115,7 +115,7 @@ func IBuild(rest string, user *users.UserRecord, room *rooms.Room) (bool, error)
115115
return true, nil
116116
}
117117

118-
func Build(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
118+
func Build(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {
119119

120120
// args should look like one of the following:
121121
// info <optional room id>

internal/usercommands/admin.command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/volte6/gomud/internal/users"
1313
)
1414

15-
func Command(rest string, user *users.UserRecord, room *rooms.Room) (bool, error) {
15+
func Command(rest string, user *users.UserRecord, room *rooms.Room, flags UserCommandFlag) (bool, error) {
1616

1717
// args should look like one of the following:
1818
// target buffId - put buff on target if in the room

0 commit comments

Comments
 (0)