combattwitch

package
v0.9.6-combat-as-module.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2025 License: GPL-3.0 Imports: 19 Imported by: 0

README

Combat-Twitch Module

Action-based combat system with cooldowns/balance mechanics for GoMud.

Configuration

This module uses the main game configuration for timing:

  • Base round duration is derived from Timing.RoundSeconds in the main config
  • Combat style selection is controlled by GamePlay.CombatStyle

No module-specific configuration is required.

Features

  • Action-based combat with balance/unbalance mechanics
  • Weapon speed affects balance recovery time
  • Speed stat reduces balance recovery time (up to 50%)
  • Real-time GMCP balance updates
  • "You are balanced" notifications

Commands

  • attack <target> - Attack a target (requires balance)
  • flee - Attempt to escape from combat
  • consider <target> - Evaluate a potential opponent

Balance Mechanics

  • Base balance recovery: 2 seconds for unarmed, varies by weapon
  • Weapon wait rounds add 4 seconds per round to recovery time
  • Speed stat can reduce recovery time by up to 50%
  • GMCP updates sent every 100ms during unbalance

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorCooldown

type ActorCooldown struct {
	NextAction  time.Time
	Callback    func()
	OffBalance  bool
	ActorId     int
	ActorType   combat.SourceTarget
	MaxDuration time.Duration // Total cooldown duration
}

ActorCooldown tracks cooldown state for an actor

type CooldownTimer

type CooldownTimer struct {
	*combat.BaseTimer
	// contains filtered or unexported fields
}

CooldownTimer implements a timer system for twitch-based combat

func NewCooldownTimer

func NewCooldownTimer(c *TwitchCombat) *CooldownTimer

NewCooldownTimer creates a new cooldown timer

func (*CooldownTimer) CanPerformAction

func (ct *CooldownTimer) CanPerformAction(actorId int, actorType combat.SourceTarget) bool

CanPerformAction checks if an actor can perform an action

func (*CooldownTimer) ClearActorCooldown

func (ct *CooldownTimer) ClearActorCooldown(actorId int, actorType combat.SourceTarget)

ClearActorCooldown removes an actor's cooldown

func (*CooldownTimer) GetNextActionTime

func (ct *CooldownTimer) GetNextActionTime(actorId int, actorType combat.SourceTarget) time.Time

GetNextActionTime returns when an actor can next act

func (*CooldownTimer) GetRemainingCooldown

func (ct *CooldownTimer) GetRemainingCooldown(actorId int, actorType combat.SourceTarget) time.Duration

GetRemainingCooldown returns remaining cooldown time

func (*CooldownTimer) RegisterActor

func (ct *CooldownTimer) RegisterActor(actorId int, actorType combat.SourceTarget)

RegisterActor ensures an actor is tracked (no-op for cooldown timer)

func (*CooldownTimer) SetActorCallback

func (ct *CooldownTimer) SetActorCallback(actorId int, actorType combat.SourceTarget, duration time.Duration, callback func())

SetActorCallback sets a callback to execute when cooldown expires

func (*CooldownTimer) SetActorCooldown

func (ct *CooldownTimer) SetActorCooldown(actorId int, actorType combat.SourceTarget, duration time.Duration)

SetActorCooldown sets a cooldown for an actor

func (*CooldownTimer) Start

func (ct *CooldownTimer) Start() error

Start implements ICombatTimer

func (*CooldownTimer) Stop

func (ct *CooldownTimer) Stop() error

Stop implements ICombatTimer

type TwitchCalculator

type TwitchCalculator struct{}

TwitchCalculator implements combat calculations for twitch-based combat

func NewTwitchCalculator

func NewTwitchCalculator() *TwitchCalculator

NewTwitchCalculator creates a new calculator instance

func (*TwitchCalculator) CalculateAttackCount

func (calc *TwitchCalculator) CalculateAttackCount(attacker, defender *characters.Character) int

CalculateAttackCount determines number of attacks (not used in twitch combat)

func (*TwitchCalculator) CalculateCriticalChance

func (calc *TwitchCalculator) CalculateCriticalChance(attacker, defender *characters.Character) bool

CalculateCriticalChance determines if an attack is critical

func (*TwitchCalculator) CalculateDamage

func (calc *TwitchCalculator) CalculateDamage(attacker, defender *characters.Character, weapon *items.Item) int

CalculateDamage computes damage for an attack

func (*TwitchCalculator) CalculateDefense

func (calc *TwitchCalculator) CalculateDefense(defender *characters.Character) int

CalculateDefense computes defensive value

func (*TwitchCalculator) CalculateHitChance

func (calc *TwitchCalculator) CalculateHitChance(attacker, defender *characters.Character) bool

CalculateHitChance determines if an attack hits

func (*TwitchCalculator) CalculateInitiative

func (calc *TwitchCalculator) CalculateInitiative(actor *characters.Character) int

CalculateInitiative determines action order (not used in twitch combat)

func (*TwitchCalculator) PowerRanking

func (calc *TwitchCalculator) PowerRanking(attacker, defender *characters.Character) float64

PowerRanking calculates relative power between actors

type TwitchCombat

type TwitchCombat struct {
	// contains filtered or unexported fields
}

TwitchCombat implements a cooldown-based combat system

func NewTwitchCombat

func NewTwitchCombat(plug *plugins.Plugin) *TwitchCombat

NewTwitchCombat creates a new twitch-based combat system

func (*TwitchCombat) ClearUserTarget

func (tc *TwitchCombat) ClearUserTarget(userId int)

ClearUserTarget removes the stored target for a user

func (*TwitchCombat) GetCalculator

func (tc *TwitchCombat) GetCalculator() combat.ICombatCalculator

GetCalculator returns the combat calculator

func (*TwitchCombat) GetName

func (tc *TwitchCombat) GetName() string

GetName returns the name of this combat system

func (*TwitchCombat) GetTimer

func (tc *TwitchCombat) GetTimer() combat.ICombatTimer

GetTimer returns the combat timer

func (*TwitchCombat) GetUserTarget

func (tc *TwitchCombat) GetUserTarget(userId int) string

GetUserTarget retrieves the last target name for a user

func (*TwitchCombat) Initialize

func (tc *TwitchCombat) Initialize() error

Initialize sets up the combat system

func (*TwitchCombat) ProcessCombatRound

func (tc *TwitchCombat) ProcessCombatRound()

ProcessCombatRound is called each round but twitch combat doesn't use rounds

func (*TwitchCombat) SendBalanceNotification

func (tc *TwitchCombat) SendBalanceNotification(actorId int, actorType combat.SourceTarget)

SendBalanceNotification sends a balance regained message to a user

func (*TwitchCombat) SendCombatUpdate

func (tc *TwitchCombat) SendCombatUpdate(userId int)

SendCombatUpdate sends GMCP updates for a player involved in combat This should be called after any combat action that might change HP

func (*TwitchCombat) SendGMCPBalanceUpdate

func (tc *TwitchCombat) SendGMCPBalanceUpdate(userId int, remainingSeconds float64, maxSeconds float64)

SendGMCPBalanceUpdate sends GMCP balance information

func (*TwitchCombat) SetUserTarget

func (tc *TwitchCombat) SetUserTarget(userId int, targetName string)

SetUserTarget stores the last target name for a user

func (*TwitchCombat) Shutdown

func (tc *TwitchCombat) Shutdown() error

Shutdown cleanly shuts down the combat system

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL