68 lines
2.5 KiB
Markdown
68 lines
2.5 KiB
Markdown
# Spells System
|
|
|
|
Complete spell system for EverQuest II server emulation with spell definitions, casting mechanics, effects, and processing.
|
|
|
|
## Components
|
|
|
|
**Core System:**
|
|
- **SpellData/Spell** - Spell definitions with properties, levels, effects, LUA data
|
|
- **SpellEffectManager** - Active effects management (buffs, debuffs, bonuses)
|
|
- **MasterSpellList/SpellBook** - Global registry and per-character spell collections
|
|
|
|
**Spell Processing:**
|
|
- **SpellProcess** - Real-time casting engine (50ms intervals) with timers, queues, interrupts
|
|
- **SpellTargeting** - All target types: self, single, group, AOE, PBAE with validation
|
|
- **SpellResourceChecker** - Power, health, concentration, savagery, dissonance management
|
|
- **SpellManager** - High-level coordinator integrating all systems
|
|
|
|
## Key Features
|
|
|
|
- **Real-time Processing**: Cast/recast timers, active spell tracking, interrupt handling
|
|
- **Comprehensive Targeting**: Range, LOS, spell criteria validation for all target types
|
|
- **Resource Management**: All EQ2 resource types with validation and consumption
|
|
- **Effect System**: 30 maintained effects, 45 spell effects, detrimental effects
|
|
- **Heroic Opportunities**: Solo/group coordination with timing
|
|
- **Thread Safety**: Concurrent access with proper mutexes
|
|
- **80+ Effect Types**: All spell modifications from original C++ system
|
|
|
|
## Usage
|
|
|
|
```go
|
|
// Create and use spell manager
|
|
spellManager := spells.NewSpellManager()
|
|
|
|
// Cast spell with full validation
|
|
err := spellManager.CastSpell(casterID, targetID, spellID)
|
|
if err != nil {
|
|
log.Printf("Spell failed: %v", err)
|
|
}
|
|
|
|
// Check spell readiness
|
|
canCast, reason := spellManager.CanCastSpell(casterID, targetID, spellID)
|
|
|
|
// Process spells in main loop
|
|
spellManager.ProcessSpells()
|
|
|
|
// Manage spell books
|
|
spellBook := spellManager.GetSpellBook(characterID)
|
|
spellBook.AddSpell(spell)
|
|
spellBook.SetSpellBarSlot(0, 1, spell)
|
|
|
|
// Effect management
|
|
sem := spells.NewSpellEffectManager()
|
|
sem.AddMaintainedEffect(maintainedEffect)
|
|
sem.AddSpellEffect(tempEffect)
|
|
```
|
|
|
|
## Files
|
|
|
|
**Core**: `constants.go`, `spell_data.go`, `spell.go`, `spell_effects.go`, `spell_manager.go`
|
|
**Processing**: `process_constants.go`, `spell_process.go`, `spell_targeting.go`, `spell_resources.go`
|
|
**Docs**: `README.md`, `SPELL_PROCESS.md`
|
|
|
|
## Integration
|
|
|
|
**Database**: Spell data loading, character spell book persistence
|
|
**Packet System**: Spell info serialization, effect updates
|
|
**Entity System**: SpellEffectManager embedded, stat integration
|
|
**LUA Scripting**: Custom spell behaviors, effect calculations |