Skip to content

Commit fe2a7e9

Browse files
authored
Death recovery room now an ephemeral copy for each player. (#375)
# Description This puts every player into a copy of the `DeathRecoveryRoom` when they die, instead of players sharing a room. ## Changes - On death, players go to an ephemeral copy of the death recovery room. - Fixed a small logic in auto-healing
1 parent ad9235c commit fe2a7e9

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

internal/hooks/NewRound_AutoHeal.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package hooks
33
import (
44
"fmt"
55

6+
"github.com/GoMudEngine/GoMud/internal/configs"
67
"github.com/GoMudEngine/GoMud/internal/events"
78
"github.com/GoMudEngine/GoMud/internal/rooms"
89
"github.com/GoMudEngine/GoMud/internal/users"
@@ -22,6 +23,8 @@ func AutoHeal(e events.Event) events.ListenerReturn {
2223
return events.Continue
2324
}
2425

26+
deathRecoveryRoomId := int(configs.GetSpecialRoomsConfig().DeathRecoveryRoom)
27+
2528
onlineIds := users.GetOnlineUserIds()
2629
for _, userId := range onlineIds {
2730
user := users.GetByUserId(userId)
@@ -31,24 +34,26 @@ func AutoHeal(e events.Event) events.ListenerReturn {
3134
continue
3235
}
3336

37+
if user.Character.RoomId == deathRecoveryRoomId {
38+
continue
39+
}
40+
3441
healthStart := user.Character.Health
3542

3643
if user.Character.Health < 1 {
37-
if user.Character.RoomId != 75 {
3844

39-
if user.Character.Health <= -10 {
45+
if user.Character.Health <= -10 {
4046

41-
user.Command(`suicide`) // suicide drops all money/items and transports to land of the dead.
47+
user.Command(`suicide`) // suicide drops all money/items and transports to land of the dead.
4248

43-
} else {
44-
user.Character.Health--
45-
user.SendText(`<ansi fg="red">you are bleeding out!</ansi>`)
46-
if room := rooms.LoadRoom(user.Character.RoomId); room != nil {
47-
room.SendText(fmt.Sprintf(`<ansi fg="username">%s</ansi> is <ansi fg="red">bleeding out</ansi>! Somebody needs to provide aid!`, user.Character.Name), user.UserId)
48-
}
49+
} else {
50+
user.Character.Health--
51+
user.SendText(`<ansi fg="red">you are bleeding out!</ansi>`)
52+
if room := rooms.LoadRoom(user.Character.RoomId); room != nil {
53+
room.SendText(fmt.Sprintf(`<ansi fg="username">%s</ansi> is <ansi fg="red">bleeding out</ansi>! Somebody needs to provide aid!`, user.Character.Name), user.UserId)
4954
}
50-
5155
}
56+
5257
} else {
5358

5459
if user.Character.Health > 0 {

internal/rooms/roommanager.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ func MoveToRoom(userId int, toRoomId int, isSpawn ...bool) error {
267267

268268
cfg := configs.GetSpecialRoomsConfig()
269269

270+
// If they are being moved to the death recovery room
271+
// Put them in their own instance of it.
272+
deathRecoveryRoomId := int(cfg.DeathRecoveryRoom)
273+
if toRoomId == deathRecoveryRoomId {
274+
if newRooms, err := CreateEphemeralRoomIds(deathRecoveryRoomId); err == nil {
275+
toRoomId = newRooms[deathRecoveryRoomId]
276+
}
277+
}
278+
270279
if toRoomId == StartRoomIdAlias {
271280

272281
// If "StartRoom" is set for MiscData on the char, use that.

0 commit comments

Comments
 (0)