aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_summon.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_summon.go')
-rw-r--r--internal/game/cmd_summon.go92
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)
+}