diff options
| author | historia <[not public]> | 2026-06-28 02:40:30 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-28 02:40:30 -0400 |
| commit | a1b6613c6c6a2f8d6e1ecd47e766bd40f92ac295 (patch) | |
| tree | 4ff8fefb029c93f2aa3db7361658b0b4e9805b66 /internal/game/cmd_summon.go | |
| parent | 87dacfbb3dd16e7f55a82361eace98f9a39d75c8 (diff) | |
| download | thehouseoficarus-a1b6613c6c6a2f8d6e1ecd47e766bd40f92ac295.tar.gz | |
feat: admin accounts, god mode, OLC commands like dig/room, 'inline' objects changed to 'local' objects
Diffstat (limited to 'internal/game/cmd_summon.go')
| -rw-r--r-- | internal/game/cmd_summon.go | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/internal/game/cmd_summon.go b/internal/game/cmd_summon.go new file mode 100644 index 0000000..3aa8d7b --- /dev/null +++ b/internal/game/cmd_summon.go @@ -0,0 +1,92 @@ +package game + +import ( + "fmt" + "strings" + + "thehouseoficarus/internal/net" +) + +func (g *Game) executeSummon(sess *net.Session, args []string, rawInput string) { + if !g.checkAdmin(sess) { + sess.WriteLine("Unknown command.") + return + } + adminP := sess.Player + if adminP == nil { + return + } + if len(args) == 0 { + sess.WriteLine("Summon whom?") + return + } + targetName := args[0] + + g.charsMu.Lock() + targetSess, ok := g.loggedInChars[targetName] + g.charsMu.Unlock() + if !ok { + for _, other := range g.Hub.AllSessions() { + if other.Player != nil && strings.EqualFold(other.Player.Name, targetName) { + targetSess = other + break + } + } + } + if targetSess == nil || targetSess.Player == nil { + sess.WriteLine("Player not found.") + return + } + if targetSess == sess { + sess.WriteLine("You can't summon yourself.") + return + } + + tp := targetSess.Player + adminRoom := adminP.RoomID + oldRoom := tp.RoomID + + tp.ClearMoveState() + if g.Combat.Get(tp.Name) != nil { + g.stopCombat(tp.Name) + } + tp.Action = nil + g.cancelRest(tp.Name) + g.cancelEnterSeq(tp.Name) + if tp.EnterSeqRoom != 0 && tp.EnterSeqRoom == oldRoom { + tp.EnterSeqRoom = 0 + } + if ss, ok := g.safespot.Get(tp.Name); ok { + g.forceLeaveSafespot(targetSess, tp, &ss, "") + } + + tp.RoomID = adminRoom + tp.HazardTimer = 0 + tp.Stats.RecordRoomVisit(adminRoom) + g.AccountStore.SaveCharacter(tp) + + g.World.SeedGroundItems(adminRoom) + g.seedRoomMobs(adminRoom) + g.seedRoomObjects(adminRoom) + + if g.Hub != nil { + for _, other := range g.Hub.PlayersInRoom(oldRoom) { + if other != targetSess { + other.WriteLine(fmt.Sprintf("%s vanishes.", tp.Name)) + } + } + g.Hub.EnterRoom(targetSess, adminRoom) + for _, other := range g.Hub.PlayersInRoom(adminRoom) { + if other != targetSess { + other.WriteLine(fmt.Sprintf("%s appears.", tp.Name)) + } + } + } + + targetSess.WriteLine(fmt.Sprintf("You have been summoned by %s.", adminP.Name)) + sess.WriteLine(fmt.Sprintf("Summoned %s.", tp.Name)) + + g.doLook(targetSess) + g.runEnterSteps(targetSess, adminRoom) + g.checkAggro(targetSess) +} |
