aboutsummaryrefslogtreecommitdiff
path: root/internal/game/aggro.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 02:18:53 -0400
committerhistoria <[not public]>2026-06-19 02:18:53 -0400
commit86aec0e14eb6fec0a39d742bab1761dad8d7012c (patch)
treeaa0d9511c73ed86ffebc5de5ab862a62afd730f8 /internal/game/aggro.go
parent458916fb78dcef3ff77cb29b7ba98d9f646819fc (diff)
downloadthehouseoficarus-86aec0e14eb6fec0a39d742bab1761dad8d7012c.tar.gz
feat: hostile mobs, equipment prereqs
Diffstat (limited to 'internal/game/aggro.go')
-rw-r--r--internal/game/aggro.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/internal/game/aggro.go b/internal/game/aggro.go
new file mode 100644
index 0000000..8f4da42
--- /dev/null
+++ b/internal/game/aggro.go
@@ -0,0 +1,54 @@
+package game
+
+import (
+ "fmt"
+
+ "thehouseoficarus/internal/combat"
+ "thehouseoficarus/internal/engine"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func (g *Game) checkAggro(sess *net.Session) {
+ p := sess.Player.(*player.Player)
+
+ if combat.GetCombat(p.Name) != nil {
+ return
+ }
+
+ playerLevel := p.CombatLevel()
+ mobs := g.MobStore.MobsInRoom(p.RoomID)
+
+ for _, mob := range mobs {
+ if !mob.Aggressive || mob.HP <= 0 || mob.Protected {
+ continue
+ }
+ if combat.IsMobInCombat(mob.InstanceID) {
+ continue
+ }
+ mobLevel := mobCombatLevel(mob)
+ if playerLevel > mobLevel*2 {
+ continue
+ }
+ aggMob := mob
+ g.Ticks.Subscribe(engine.ToTicks(1), func() bool {
+ if combat.GetCombat(p.Name) != nil {
+ return false
+ }
+ if aggMob.HP <= 0 || aggMob.RoomID != p.RoomID {
+ return false
+ }
+ if combat.IsMobInCombat(aggMob.InstanceID) {
+ return false
+ }
+ attacker := aggMob.Name
+ if !aggMob.Unique {
+ attacker = "The " + aggMob.Name
+ }
+ sess.WriteLine(fmt.Sprintf("\n%s attacks you!", g.colorize(sess, "mob_name", attacker)))
+ g.startCombat(sess, p, aggMob)
+ return false
+ })
+ break
+ }
+}