diff options
Diffstat (limited to 'internal/game/cmd_attack.go')
| -rw-r--r-- | internal/game/cmd_attack.go | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/internal/game/cmd_attack.go b/internal/game/cmd_attack.go index 401837f..29bff30 100644 --- a/internal/game/cmd_attack.go +++ b/internal/game/cmd_attack.go @@ -124,24 +124,39 @@ func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobIn combat.EnterCombat(p.Name, mob.InstanceID) + autocastActive := p.AutocastMod != "" playerSpeed := g.playerWeaponSpeed(p) - - attBonus, strBonus, defBonus := combat.AttackStyleBonus(string(p.AttackStyle)) - var styleParts []string - if attBonus > 0 { - styleParts = append(styleParts, fmt.Sprintf("+%d atk", attBonus)) - } - if strBonus > 0 { - styleParts = append(styleParts, fmt.Sprintf("+%d str", strBonus)) + if autocastActive { + playerSpeed = 5.0 } - if defBonus > 0 { - styleParts = append(styleParts, fmt.Sprintf("+%d def", defBonus)) - } - styleStr := "" - if len(styleParts) > 0 { - styleStr = " Style: " + string(p.AttackStyle) + " (" + strings.Join(styleParts, ", ") + ")" + + if !autocastActive { + attBonus, strBonus, defBonus := combat.AttackStyleBonus(string(p.AttackStyle)) + var styleParts []string + if attBonus > 0 { + styleParts = append(styleParts, fmt.Sprintf("+%d atk", attBonus)) + } + if strBonus > 0 { + styleParts = append(styleParts, fmt.Sprintf("+%d str", strBonus)) + } + if defBonus > 0 { + styleParts = append(styleParts, fmt.Sprintf("+%d def", defBonus)) + } + styleStr := "" + if len(styleParts) > 0 { + styleStr = " Style: " + string(p.AttackStyle) + " (" + strings.Join(styleParts, ", ") + ")" + } + sess.WriteLine(fmt.Sprintf("\nYou attack %s!%s", g.colorize(sess, "mob_name", mobDisplayName(mob, true)), styleStr)) + } else { + mod := GetMod(p.AutocastMod) + modName := p.AutocastMod + if mod != nil { + modName = mod.Name + } + sess.WriteLine(fmt.Sprintf("\nYou attack %s with %s!", + g.colorize(sess, "mob_name", mobDisplayName(mob, true)), + g.colorize(sess, "science_mod", modName))) } - sess.WriteLine(fmt.Sprintf("\nYou attack %s!%s", g.colorize(sess, "mob_name", mobDisplayName(mob, true)), styleStr)) p.ActionState = &ActionState{Type: ActionCombating, TargetName: mob.Name} g.Ticks.Subscribe(engine.ToTicks(playerSpeed), func() bool { @@ -154,7 +169,21 @@ func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobIn g.endCombat(sess, p, currentMob) return false } - g.playerAttack(sess, p, currentMob) + if p.AutocastMod != "" { + mod := GetMod(p.AutocastMod) + if mod != nil { + if !g.scienceAttack(sess, p, currentMob, mod) { + p.AutocastMod = "" + sess.WriteLine("You've run out of junk. Switching to melee.") + g.playerAttack(sess, p, currentMob) + } + } else { + p.AutocastMod = "" + g.playerAttack(sess, p, currentMob) + } + } else { + g.playerAttack(sess, p, currentMob) + } if currentMob.HP <= 0 { g.endCombat(sess, p, currentMob) return false |
