aboutsummaryrefslogtreecommitdiff
path: root/internal/game/action_steal.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 18:20:26 -0400
committerhistoria <[not public]>2026-06-19 18:20:26 -0400
commit0ea4eec5dd2122c6704216971eb1249276297867 (patch)
tree430fbbef04e837820f1d031c190f52ecd6112e25 /internal/game/action_steal.go
parent3a58125d14bb307f861b38c6c5b0a63babde7e08 (diff)
downloadthehouseoficarus-0ea4eec5dd2122c6704216971eb1249276297867.tar.gz
shop fixes, 'toggle' completely removed, movement speed increased
Diffstat (limited to 'internal/game/action_steal.go')
-rw-r--r--internal/game/action_steal.go67
1 files changed, 43 insertions, 24 deletions
diff --git a/internal/game/action_steal.go b/internal/game/action_steal.go
index 5347c2a..ee5456c 100644
--- a/internal/game/action_steal.go
+++ b/internal/game/action_steal.go
@@ -16,6 +16,34 @@ import (
"thehouseoficarus/internal/world"
)
+var stallGuardTalk = &action.TalkConfig{
+ Nodes: map[string]action.TalkNode{
+ "start": {
+ Message: "Caught you red-handed! You have three options, thief.",
+ Options: []action.TalkOption{
+ {Text: "\"I'll pay a fine. (500 credits)\"", Goto: "bribe", Condition: &action.Condition{MinCredits: 500}},
+ {Text: "\"Take me to jail.\"", Goto: "jail"},
+ {Text: "\"You'll have to catch me first!\"", Goto: "fight"},
+ },
+ },
+ "bribe": {
+ Message: "Smart choice. Hand over 500 credits and we'll forget this happened.",
+ Action: &action.NodeAction{Cost: 500},
+ Options: []action.TalkOption{{Text: "\"Fine, take it.\"", End: true}},
+ },
+ "jail": {
+ Message: "Off to the detention cell with you!",
+ Action: &action.NodeAction{Teleport: 162},
+ Options: []action.TalkOption{{Text: "(You are dragged away)", End: true}},
+ },
+ "fight": {
+ Message: "Then defend yourself!",
+ Action: &action.NodeAction{SetFlags: map[string]any{"guard_hostile": true}},
+ Options: []action.TalkOption{{Text: "(The guard attacks!)", End: true}},
+ },
+ },
+}
+
var stealSuccess = action.SuccessFormula{
Base: 0.5,
PerLevel: 0.03,
@@ -23,14 +51,14 @@ var stealSuccess = action.SuccessFormula{
}
func (g *Game) doSteal(sess *net.Session, input string) {
- p := sess.Player.(*player.Player)
+ p := sess.Player
if combat.GetCombat(p.Name) != nil {
sess.WriteLine("You can't do that during combat!")
return
}
- g.CancelAction(p)
+ g.cancelAction(p)
targetType, mob, objDef, errMsg := g.resolveStealTarget(sess, p, input)
if errMsg != "" {
@@ -131,7 +159,7 @@ func (g *Game) resolveStealTarget(sess *net.Session, p *player.Player, input str
var matchingObjs []*object.ObjectDef
for _, o := range stealObjs {
- if world.WordPrefixMatch(searchName, o.Name) {
+ if action.WordPrefixMatch(searchName, o.Name) {
matchingObjs = append(matchingObjs, o)
}
}
@@ -265,12 +293,12 @@ func (g *Game) advanceSteal(sess *net.Session, p *player.Player) {
mob := g.MobStore.GetInstance(mobInstanceID)
if mob == nil || mob.HP <= 0 || mob.RoomID != p.RoomID {
sess.WriteLine("Your target is gone.")
- g.CancelAction(p)
+ g.cancelAction(p)
return
}
if combat.IsMobInCombat(mob.InstanceID) {
sess.WriteLine(fmt.Sprintf("The %s is busy.", targetName))
- g.CancelAction(p)
+ g.cancelAction(p)
return
}
data["steal_level"] = mob.StealLevel
@@ -290,7 +318,7 @@ func (g *Game) advanceSteal(sess *net.Session, p *player.Player) {
}
if !found {
sess.WriteLine("Your target is gone.")
- g.CancelAction(p)
+ g.cancelAction(p)
return
}
objDef, err := g.ObjectStore.Load(objDefID)
@@ -328,11 +356,11 @@ func (g *Game) advanceSteal(sess *net.Session, p *player.Player) {
}
if rand.Float64() < chance {
- dt, err := g.BehaviorStore.LoadDropTable(stealTable)
+ dt, err := action.LoadDropTable(g.DataDir, stealTable)
if err != nil || len(dt.Drops) == 0 {
sess.WriteLine("You steal nothing of value.")
} else {
- drop := g.BehaviorStore.ResolveDrop(dt.Drops)
+ drop := action.ResolveDrop(g.DataDir, dt.Drops)
if drop == nil || drop.ItemID == "" {
sess.WriteLine("You steal nothing of value.")
} else {
@@ -341,19 +369,14 @@ func (g *Game) advanceSteal(sess *net.Session, p *player.Player) {
}
if stealXP > 0 {
- prevLevel := p.Level(player.Thieving)
- p.AddSkillXP(player.Thieving, stealXP)
- newLevel := p.Level(player.Thieving)
- if newLevel > prevLevel {
- sess.WriteLine(g.colorize(sess, "level_up", fmt.Sprintf("*** You are now level %d thieving! ***", newLevel)))
- }
+ g.awardSkillXP(sess, p, player.Thieving, stealXP)
}
g.AccountStore.SaveCharacter(p)
if p.FirstFreeSlot() == -1 {
sess.WriteLine("Your inventory is full.")
- g.CancelAction(p)
+ g.cancelAction(p)
return
}
@@ -363,7 +386,7 @@ func (g *Game) advanceSteal(sess *net.Session, p *player.Player) {
mobInstanceID := data["mob_instance_id"].(string)
mob := g.MobStore.GetInstance(mobInstanceID)
sess.WriteLine(fmt.Sprintf("The %s notices you! They attack!", targetName))
- g.CancelAction(p)
+ g.cancelAction(p)
if mob != nil && mob.HP > 0 {
g.startCombat(sess, p, mob)
}
@@ -372,7 +395,7 @@ func (g *Game) advanceSteal(sess *net.Session, p *player.Player) {
guard := g.findGuardInRoom(p.RoomID, guardMob)
if guard != nil {
sess.WriteLine("You fumble and the Guard spots you!")
- g.CancelAction(p)
+ g.cancelAction(p)
g.startStealGuardTalk(sess, p, guard)
return
}
@@ -433,14 +456,10 @@ func (g *Game) isGuardWatching(roomID int, objDefID string) bool {
}
func (g *Game) startStealGuardTalk(sess *net.Session, p *player.Player, guardMob *world.MobInstance) {
- cfg, err := g.BehaviorStore.LoadTalk("stall_guard_talk")
- if err != nil {
- sess.WriteLine("The Guard glares at you but says nothing.")
- return
- }
-
+ cfg := stallGuardTalk
node, ok := cfg.Nodes["start"]
if !ok {
+ sess.WriteLine("The Guard glares at you but says nothing.")
return
}
@@ -450,7 +469,7 @@ func (g *Game) startStealGuardTalk(sess *net.Session, p *player.Player, guardMob
Type: "talk",
TargetID: guardMob.DefID,
TargetName: guardMob.Name,
- Data: map[string]any{"node": "start", "behavior_id": "stall_guard_talk", "steal_guard": true},
+ Data: map[string]any{"node": "start", "talk_cfg": cfg, "steal_guard": true},
}
g.showTalkNode(sess, node)