512 lines
13 KiB
Go
512 lines
13 KiB
Go
package zone
|
|
|
|
import (
|
|
"eq2emu/internal/items"
|
|
"eq2emu/internal/spawn"
|
|
)
|
|
|
|
// Client interface represents a connected player client
|
|
type Client interface {
|
|
GetID() uint32
|
|
GetCharacterID() int32
|
|
GetPlayerName() string
|
|
GetPlayer() Player
|
|
GetClientVersion() int32
|
|
IsLoadingZone() bool
|
|
SendPacket(data []byte) error
|
|
GetPosition() (x, y, z, heading float32, zoneID int32)
|
|
SetPosition(x, y, z, heading float32, zoneID int32)
|
|
GetSpawnRange() float32
|
|
IsInCombat() bool
|
|
CanSeeSpawn(spawn *spawn.Spawn) bool
|
|
GetLanguageID() int32
|
|
GetLanguageSkill(languageID int32) int32
|
|
}
|
|
|
|
// Player interface represents the player entity in the game world
|
|
type Player interface {
|
|
GetID() uint32
|
|
GetCharacterID() int32
|
|
GetName() string
|
|
GetLevel() int16
|
|
GetRace() int16
|
|
GetClass() int16
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetZoneID() int32
|
|
SetZoneID(zoneID int32)
|
|
IsAlive() bool
|
|
GetHP() int32
|
|
GetMaxHP() int32
|
|
GetPower() int32
|
|
GetMaxPower() int32
|
|
GetSkillValue(skillID int32) int16
|
|
AddExperience(amount int32, skillID int32)
|
|
IsTracking() bool
|
|
GetTrackingType() int8
|
|
GetTrackingDistance() float32
|
|
CanCarryItems(count int) bool
|
|
AddItems(items []*items.Item) error
|
|
AddCoins(amount int32) error
|
|
SendMessage(message string) error
|
|
GetGroupID() int32
|
|
GetRaidID() int32
|
|
IsInGroup() bool
|
|
IsInRaid() bool
|
|
GetVisibleSpawns() map[int32]*spawn.Spawn
|
|
AddVisibleSpawn(spawn *spawn.Spawn)
|
|
RemoveVisibleSpawn(spawnID int32)
|
|
GetFactionValue(factionID int32) int32
|
|
SetFactionValue(factionID int32, value int32)
|
|
GetCompletedQuests() map[int32]bool
|
|
HasQuestCompleted(questID int32) bool
|
|
}
|
|
|
|
// NPC interface represents a non-player character
|
|
type NPC interface {
|
|
GetID() int32
|
|
GetDatabaseID() int32
|
|
GetName() string
|
|
GetLevel() int16
|
|
GetRace() int16
|
|
GetClass() int16
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetMaxHP() int32
|
|
GetHP() int32
|
|
SetHP(hp int32)
|
|
GetMaxPower() int32
|
|
GetPower() int32
|
|
SetPower(power int32)
|
|
IsAlive() bool
|
|
GetLootTableID() int32
|
|
GetFactionID() int32
|
|
GetSkills() map[int32]int16
|
|
GetEquipment() map[int32]int32
|
|
GetBrain() NPCBrain
|
|
SetBrain(brain NPCBrain)
|
|
GetAggroList() map[uint32]int32
|
|
AddAggro(playerID uint32, amount int32)
|
|
RemoveAggro(playerID uint32)
|
|
GetMostHated() uint32
|
|
IsInCombat() bool
|
|
CanAttack(target *spawn.Spawn) bool
|
|
GetMovementLocations() []*MovementLocation
|
|
SetMovementLocations(locations []*MovementLocation)
|
|
GetRespawnTime() int32
|
|
SetRespawnTime(seconds int32)
|
|
GetSpawnGroupID() int32
|
|
SetSpawnGroupID(groupID int32)
|
|
GetRandomizedFeatures() map[string]interface{}
|
|
SetRandomizedFeatures(features map[string]interface{})
|
|
}
|
|
|
|
// Object interface represents an interactive world object
|
|
type Object interface {
|
|
GetID() int32
|
|
GetDatabaseID() int32
|
|
GetName() string
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetAppearanceID() int32
|
|
GetSize() float32
|
|
GetDeviceID() int32
|
|
GetCommands() []string
|
|
CanInteract(player Player) bool
|
|
OnInteract(player Player, command string) error
|
|
Copy() Object
|
|
}
|
|
|
|
// Widget interface represents interactive widgets like doors and lifts
|
|
type Widget interface {
|
|
GetID() int32
|
|
GetDatabaseID() int32
|
|
GetName() string
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetAppearanceID() int32
|
|
GetWidgetType() int8
|
|
IsOpen() bool
|
|
SetOpen(open bool)
|
|
GetOpenTime() int32
|
|
GetCloseTime() int32
|
|
GetLinkedSpawnID() int32
|
|
GetActionSpawnID() int32
|
|
GetHouseID() int32
|
|
CanInteract(player Player) bool
|
|
OnInteract(player Player) error
|
|
Copy() Widget
|
|
}
|
|
|
|
// Sign interface represents readable signs in the world
|
|
type Sign interface {
|
|
GetID() int32
|
|
GetDatabaseID() int32
|
|
GetName() string
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetAppearanceID() int32
|
|
GetTitle() string
|
|
GetDescription() string
|
|
GetSignType() int8
|
|
GetZoneID() int32
|
|
GetWidgetID() int32
|
|
CanRead(player Player) bool
|
|
OnRead(player Player) error
|
|
Copy() Sign
|
|
}
|
|
|
|
// GroundSpawn interface represents harvestable ground spawns
|
|
type GroundSpawn interface {
|
|
GetID() int32
|
|
GetDatabaseID() int32
|
|
GetName() string
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetAppearanceID() int32
|
|
GetHarvestType() int8
|
|
GetNumAttempts() int8
|
|
GetMaxAttempts() int8
|
|
GetRespawnTime() int32
|
|
GetSkillRequired() int16
|
|
GetLevelRequired() int16
|
|
CanHarvest(player Player) bool
|
|
OnHarvest(player Player) error
|
|
GetRareTable() int32
|
|
GetBonusTable() int32
|
|
Copy() GroundSpawn
|
|
}
|
|
|
|
// NPCBrain interface represents NPC AI behavior
|
|
type NPCBrain interface {
|
|
Think(npc NPC, zone *ZoneServer) error
|
|
OnAggro(npc NPC, attacker *spawn.Spawn) error
|
|
OnDeath(npc NPC, killer *spawn.Spawn) error
|
|
OnSpawn(npc NPC) error
|
|
OnDespawn(npc NPC) error
|
|
GetBrainType() int8
|
|
}
|
|
|
|
// IPathfinder interface for pathfinding systems
|
|
type IPathfinder interface {
|
|
CalculatePath(startX, startY, startZ, endX, endY, endZ float32) ([]*PathNode, error)
|
|
GetRandomLocation(x, y, z, radius float32) (newX, newY, newZ float32, err error)
|
|
IsLocationAccessible(x, y, z float32) bool
|
|
GetClosestPoint(x, y, z float32) (closestX, closestY, closestZ float32)
|
|
}
|
|
|
|
// Map interface represents zone collision and height data
|
|
type Map interface {
|
|
FindBestZ(x, y, z float32) (bestZ float32, found bool)
|
|
FindClosestZ(x, y, z float32) float32
|
|
CheckLoS(x1, y1, z1, x2, y2, z2 float32) bool
|
|
DoCollisionCheck(x1, y1, z1, x2, y2, z2 float32) (hit bool, hitX, hitY, hitZ float32)
|
|
LineIntersectsZone(x1, y1, z1, x2, y2, z2 float32) bool
|
|
IsLoaded() bool
|
|
GetMapVersion() int32
|
|
GetBounds() (minX, minY, minZ, maxX, maxY, maxZ float32)
|
|
}
|
|
|
|
// RegionMap interface for zone region management
|
|
type RegionMap interface {
|
|
InWater(x, y, z float32) (inWater bool, waterType int8)
|
|
InLava(x, y, z float32) bool
|
|
InPvP(x, y, z float32) bool
|
|
InZoneLine(x, y, z float32) (inZoneLine bool, zoneLineID int32)
|
|
GetRegionType(x, y, z, heading float32) int32
|
|
GetEnvironmentalDamage(x, y, z float32) int32
|
|
IsValidLocation(x, y, z float32) bool
|
|
}
|
|
|
|
// SpellProcess interface for spell processing
|
|
type SpellProcess interface {
|
|
ProcessSpell(spell Spell, caster Entity, target *spawn.Spawn) error
|
|
InterruptSpell(caster Entity, interruptor *spawn.Spawn) error
|
|
AddSpellTimer(caster Entity, spellID int32, duration int32) error
|
|
RemoveSpellTimer(caster Entity, spellID int32) error
|
|
GetActiveSpells(entity Entity) map[int32]*ActiveSpell
|
|
ProcessSpellEffects() error
|
|
LockSpells(entity Entity)
|
|
UnlockSpells(entity Entity)
|
|
IsSpellLocked(entity Entity) bool
|
|
}
|
|
|
|
// TradeskillManager interface for tradeskill processing
|
|
type TradeskillManager interface {
|
|
StartCrafting(player Player, recipeID int32) error
|
|
ProcessCrafting(player Player) error
|
|
CompleteCrafting(player Player) error
|
|
CancelCrafting(player Player) error
|
|
GetRecipe(recipeID int32) Recipe
|
|
GetPlayerRecipes(playerID uint32) []int32
|
|
CanCraftRecipe(player Player, recipeID int32) bool
|
|
}
|
|
|
|
// Entity interface represents any combatable entity
|
|
type Entity interface {
|
|
GetID() uint32
|
|
GetName() string
|
|
GetLevel() int16
|
|
GetRace() int16
|
|
GetClass() int16
|
|
GetPosition() (x, y, z, heading float32)
|
|
SetPosition(x, y, z, heading float32)
|
|
GetHP() int32
|
|
GetMaxHP() int32
|
|
SetHP(hp int32)
|
|
GetPower() int32
|
|
GetMaxPower() int32
|
|
SetPower(power int32)
|
|
IsAlive() bool
|
|
TakeDamage(amount int32, attacker Entity, damageType int8) error
|
|
Heal(amount int32, healer Entity) error
|
|
GetResists() map[int8]int16
|
|
GetStats() map[int8]int32
|
|
GetSkillValue(skillID int32) int16
|
|
GetSpellEffects() map[int32]*SpellEffect
|
|
AddSpellEffect(effect *SpellEffect) error
|
|
RemoveSpellEffect(effectID int32) error
|
|
CanCast() bool
|
|
StartCasting(spell Spell) error
|
|
InterruptCasting() error
|
|
}
|
|
|
|
// Spell interface represents a castable spell
|
|
type Spell interface {
|
|
GetID() int32
|
|
GetName() string
|
|
GetDescription() string
|
|
GetCastTime() int16
|
|
GetRecoveryTime() int16
|
|
GetRecastTime() int32
|
|
GetRange() float32
|
|
GetRadius() float32
|
|
GetPowerCost() int16
|
|
GetHPCost() int16
|
|
GetTargetType() int8
|
|
GetSpellType() int8
|
|
GetLevel() int16
|
|
GetTier() int8
|
|
GetIcon() int16
|
|
GetEffects() []*SpellEffect
|
|
CanCast(caster Entity, target *spawn.Spawn) bool
|
|
GetRequiredComponents() map[int32]int16
|
|
}
|
|
|
|
// SpellEffect interface represents an active spell effect
|
|
type SpellEffect interface {
|
|
GetID() int32
|
|
GetSpellID() int32
|
|
GetEffectType() int8
|
|
GetSubType() int8
|
|
GetValue() float32
|
|
GetDuration() int32
|
|
GetRemainingTime() int32
|
|
GetCasterID() uint32
|
|
GetTargetID() uint32
|
|
IsExpired() bool
|
|
Apply(target Entity) error
|
|
Remove(target Entity) error
|
|
Tick(target Entity) error
|
|
}
|
|
|
|
// ActiveSpell represents a spell being cast or maintained
|
|
type ActiveSpell interface {
|
|
GetSpell() Spell
|
|
GetCaster() Entity
|
|
GetTargets() []*spawn.Spawn
|
|
GetCastTime() int32
|
|
GetRemainingCastTime() int32
|
|
IsChanneling() bool
|
|
IsMaintained() bool
|
|
GetEndTime() int64
|
|
}
|
|
|
|
// Recipe interface for tradeskill recipes
|
|
type Recipe interface {
|
|
GetID() int32
|
|
GetName() string
|
|
GetDescription() string
|
|
GetSkillID() int32
|
|
GetRequiredLevel() int16
|
|
GetDifficulty() int16
|
|
GetComponents() map[int32]int16
|
|
GetProducts() map[int32]int16
|
|
GetExperience() int32
|
|
}
|
|
|
|
// MovementLocation represents a movement waypoint for NPCs
|
|
type MovementLocation struct {
|
|
X float32
|
|
Y float32
|
|
Z float32
|
|
Heading float32
|
|
Speed float32
|
|
Delay int32
|
|
MovementType int8
|
|
}
|
|
|
|
// PathNode represents a single node in a calculated path
|
|
type PathNode struct {
|
|
X float32
|
|
Y float32
|
|
Z float32
|
|
}
|
|
|
|
// SpawnLocation represents a spawn point configuration
|
|
type SpawnLocation struct {
|
|
ID int32
|
|
X float32
|
|
Y float32
|
|
Z float32
|
|
Heading float32
|
|
Pitch float32
|
|
Roll float32
|
|
SpawnType int8
|
|
SpawnEntry *SpawnEntry
|
|
RespawnTime int32
|
|
ExpireTime int32
|
|
ExpireOffset int32
|
|
Conditions int8
|
|
ConditionalValue int32
|
|
SpawnPercentage float32
|
|
Groups []int32
|
|
}
|
|
|
|
// SpawnEntry contains the template data for spawns
|
|
type SpawnEntry struct {
|
|
ID int32
|
|
SpawnType int8
|
|
SpawnEntryID int32
|
|
Name string
|
|
Level int16
|
|
EncounterLevel int16
|
|
Model string
|
|
Size float32
|
|
HP int32
|
|
Power int32
|
|
Heroic int8
|
|
Gender int8
|
|
Race int16
|
|
AdventureClass int16
|
|
TradeskillClass int16
|
|
AttackType int8
|
|
MinLevel int16
|
|
MaxLevel int16
|
|
EncounterType int8
|
|
ShowName int8
|
|
Targetable int8
|
|
ShowLevel int8
|
|
Command string
|
|
LootTier int8
|
|
MinGold int32
|
|
MaxGold int32
|
|
HarvestType string
|
|
Icon int32
|
|
}
|
|
|
|
// EntityCommand represents an available command for an entity
|
|
type EntityCommand struct {
|
|
ID int32
|
|
Name string
|
|
Distance float32
|
|
ErrorText string
|
|
CastTime int16
|
|
SpellVisual int32
|
|
Command string
|
|
DisplayText string
|
|
}
|
|
|
|
// LootTable represents a loot table configuration
|
|
type LootTable struct {
|
|
ID int32
|
|
Name string
|
|
MinCoin int32
|
|
MaxCoin int32
|
|
MaxLootItems int16
|
|
LootDropProbability float32
|
|
CoinProbability float32
|
|
Drops []*LootDrop
|
|
}
|
|
|
|
// LootDrop represents an individual item drop in a loot table
|
|
type LootDrop struct {
|
|
LootTableID int32
|
|
ItemID int32
|
|
ItemCharges int16
|
|
EquipItem bool
|
|
Probability float32
|
|
NoDropQuestCompletedID int32
|
|
}
|
|
|
|
// GlobalLoot represents global loot rules
|
|
type GlobalLoot struct {
|
|
Type string
|
|
TableID int32
|
|
MinLevel int8
|
|
MaxLevel int8
|
|
RaceID int16
|
|
ZoneID int32
|
|
LootTier int32
|
|
}
|
|
|
|
// TransportDestination represents a transport destination
|
|
type TransportDestination struct {
|
|
ID int32
|
|
Type int8
|
|
Name string
|
|
Message string
|
|
DestinationZoneID int32
|
|
DestinationX float32
|
|
DestinationY float32
|
|
DestinationZ float32
|
|
DestinationHeading float32
|
|
Cost int32
|
|
UniqueID int32
|
|
MinLevel int8
|
|
MaxLevel int8
|
|
QuestRequired int32
|
|
QuestStepRequired int16
|
|
QuestCompleted int32
|
|
MapX int32
|
|
MapY int32
|
|
ExpansionFlag int32
|
|
HolidayFlag int32
|
|
MinClientVersion int32
|
|
MaxClientVersion int32
|
|
FlightPathID int32
|
|
MountID int16
|
|
MountRedColor int8
|
|
MountGreenColor int8
|
|
MountBlueColor int8
|
|
}
|
|
|
|
// LocationTransportDestination represents a location-based transport trigger
|
|
type LocationTransportDestination struct {
|
|
ZoneID int32
|
|
Message string
|
|
TriggerX float32
|
|
TriggerY float32
|
|
TriggerZ float32
|
|
TriggerRadius float32
|
|
DestinationZoneID int32
|
|
DestinationX float32
|
|
DestinationY float32
|
|
DestinationZ float32
|
|
DestinationHeading float32
|
|
Cost int32
|
|
UniqueID int32
|
|
ForceZone bool
|
|
}
|
|
|
|
// Location represents a discoverable location
|
|
type Location struct {
|
|
ID int32
|
|
Name string
|
|
X float32
|
|
Y float32
|
|
Z float32
|
|
}
|
|
|
|
// Item placeholder - should import from items package
|
|
type Item = items.Item |