531 lines
13 KiB
Go
531 lines
13 KiB
Go
package zone
|
|
|
|
// Configuration keys for zone rules and settings
|
|
const (
|
|
// Zone configuration keys
|
|
ConfigTreasureChestEnabled = "treasure_chest_enabled"
|
|
ConfigPvPEnabled = "pvp_enabled"
|
|
ConfigDeathPenalty = "death_penalty_enabled"
|
|
ConfigSafeZone = "safe_zone"
|
|
ConfigGroupSpawns = "group_spawns_allowed"
|
|
ConfigInstanced = "instanced"
|
|
ConfigMaxPlayers = "max_players"
|
|
ConfigMinLevel = "min_level"
|
|
ConfigMaxLevel = "max_level"
|
|
ConfigLockoutTime = "lockout_time"
|
|
ConfigReenterTime = "reenter_time"
|
|
ConfigResetTime = "reset_time"
|
|
ConfigWeatherEnabled = "weather_enabled"
|
|
ConfigWeatherType = "weather_type"
|
|
ConfigSpawnRates = "spawn_rate_modifier"
|
|
ConfigLootRates = "loot_rate_modifier"
|
|
ConfigExperienceRates = "experience_rate_modifier"
|
|
)
|
|
|
|
// Logging prefixes for consistent log formatting
|
|
const (
|
|
LogPrefixZone = "[ZONE]"
|
|
LogPrefixMap = "[MAP]"
|
|
LogPrefixPathfind = "[PATHFIND]"
|
|
LogPrefixMovement = "[MOVEMENT]"
|
|
LogPrefixRegion = "[REGION]"
|
|
LogPrefixWeather = "[WEATHER]"
|
|
LogPrefixTransport = "[TRANSPORT]"
|
|
LogPrefixFlight = "[FLIGHT]"
|
|
LogPrefixProximity = "[PROXIMITY]"
|
|
LogPrefixGrid = "[GRID]"
|
|
LogPrefixScript = "[SCRIPT]"
|
|
LogPrefixCombat = "[COMBAT]"
|
|
LogPrefixSpawn = "[SPAWN]"
|
|
LogPrefixClient = "[CLIENT]"
|
|
)
|
|
|
|
// Map version constants
|
|
const (
|
|
MapVersionV1 = 1
|
|
MapVersionV2 = 2
|
|
MapVersionV2Deflated = 3
|
|
MapVersionV3Deflated = 4
|
|
)
|
|
|
|
// Map loading states
|
|
const (
|
|
MapStateUnloaded = iota
|
|
MapStateLoading
|
|
MapStateLoaded
|
|
MapStateFailed
|
|
)
|
|
|
|
// Pathfinding backend types
|
|
const (
|
|
PathfinderTypeNull = iota
|
|
PathfinderTypeWaypoint
|
|
PathfinderTypeNavmesh
|
|
)
|
|
|
|
// Pathfinding poly flags for terrain types
|
|
const (
|
|
PathingPolyFlagWalk = 0x01
|
|
PathingPolyFlagSwim = 0x02
|
|
PathingPolyFlagDoor = 0x04
|
|
PathingPolyFlagJump = 0x08
|
|
PathingPolyFlagDisabled = 0x10
|
|
PathingPolyFlagAll = 0xFFFF
|
|
)
|
|
|
|
// Water types for region detection
|
|
const (
|
|
WaterTypeNone = iota
|
|
WaterTypeNormal
|
|
WaterTypeLava
|
|
WaterTypeSlime
|
|
WaterTypeIce
|
|
WaterTypeVirtual
|
|
)
|
|
|
|
// Region types
|
|
const (
|
|
RegionTypeNormal = iota
|
|
RegionTypeWater
|
|
RegionTypeLava
|
|
RegionTypePvP
|
|
RegionTypeZoneLine
|
|
RegionTypeNoSpawn
|
|
RegionTypeEnvironmentalDamage
|
|
)
|
|
|
|
// Environmental damage types
|
|
const (
|
|
EnvironmentalDamageNone = iota
|
|
EnvironmentalDamageLava
|
|
EnvironmentalDamagePoison
|
|
EnvironmentalDamageCold
|
|
EnvironmentalDamageHeat
|
|
)
|
|
|
|
// Movement command types
|
|
const (
|
|
MovementCommandMoveTo = iota
|
|
MovementCommandSwimTo
|
|
MovementCommandTeleportTo
|
|
MovementCommandRotateTo
|
|
MovementCommandStop
|
|
MovementCommandEvadeCombat
|
|
MovementCommandFollowPath
|
|
)
|
|
|
|
// Movement modes
|
|
const (
|
|
MovementModeWalk = iota
|
|
MovementModeRun
|
|
MovementModeSwim
|
|
MovementModeFly
|
|
)
|
|
|
|
// Stuck behaviors for movement
|
|
const (
|
|
StuckBehaviorNone = iota
|
|
StuckBehaviorRun
|
|
StuckBehaviorWarp
|
|
StuckBehaviorEvade
|
|
)
|
|
|
|
// Movement speeds (units per second)
|
|
const (
|
|
DefaultWalkSpeed = 2.5
|
|
DefaultRunSpeed = 7.0
|
|
DefaultSwimSpeed = 3.5
|
|
DefaultFlySpeed = 10.0
|
|
)
|
|
|
|
// NPC brain types
|
|
const (
|
|
BrainTypeNone = iota
|
|
BrainTypeBasic
|
|
BrainTypeCombatPet
|
|
BrainTypeNonCombatPet
|
|
BrainTypeBlank
|
|
BrainTypeLua
|
|
BrainTypeDumbFire
|
|
)
|
|
|
|
// Combat states
|
|
const (
|
|
CombatStateNone = iota
|
|
CombatStateInCombat
|
|
CombatStateEvading
|
|
CombatStateReturning
|
|
)
|
|
|
|
// NPC AI timing constants (in milliseconds)
|
|
const (
|
|
AIThinkInterval = 100 // How often AI thinks
|
|
AggroCheckInterval = 1000 // How often to check for new targets
|
|
MovementUpdateInterval = 250 // How often to update movement
|
|
CombatTickInterval = 1000 // How often to process combat
|
|
SpellCheckInterval = 500 // How often to check for spell casting
|
|
HateDecayInterval = 5000 // How often hate decays
|
|
)
|
|
|
|
// Combat ranges
|
|
const (
|
|
DefaultMeleeRange = 5.0 // Default melee attack range
|
|
DefaultSpellRange = 30.0 // Default spell casting range
|
|
DefaultAggroRange = 25.0 // Default aggro acquisition range
|
|
DefaultLeashRange = 100.0 // Default leash range before reset
|
|
DefaultSocialRange = 15.0 // Range for social aggro
|
|
)
|
|
|
|
// Hate system constants
|
|
const (
|
|
MaxHateValue = 2000000000 // Maximum hate value
|
|
MinHateValue = -MaxHateValue
|
|
InitialHateValue = 1 // Starting hate for new targets
|
|
HateDecayAmount = 1 // How much hate decays per interval
|
|
HateDecayMinimum = 1 // Minimum hate before removal
|
|
)
|
|
|
|
// Spell targeting types
|
|
const (
|
|
SpellTargetSelf = iota
|
|
SpellTargetSingle
|
|
SpellTargetGroup
|
|
SpellTargetRaid
|
|
SpellTargetAOE
|
|
SpellTargetPBAOE
|
|
SpellTargetPet
|
|
)
|
|
|
|
// Spell effect types
|
|
const (
|
|
SpellEffectHeal = iota
|
|
SpellEffectDamage
|
|
SpellEffectBuff
|
|
SpellEffectDebuff
|
|
SpellEffectSummon
|
|
SpellEffectTeleport
|
|
SpellEffectResurrect
|
|
)
|
|
|
|
// Damage types
|
|
const (
|
|
DamageTypeSlashing = iota
|
|
DamageTypeCrushing
|
|
DamageTypePiercing
|
|
DamageTypeHeat
|
|
DamageTypeCold
|
|
DamageTypeMagic
|
|
DamageTypeMental
|
|
DamageTypePoison
|
|
DamageTypeDisease
|
|
)
|
|
|
|
// Resist types
|
|
const (
|
|
ResistElemental = iota
|
|
ResistNoxious
|
|
ResistArcane
|
|
ResistPhysical
|
|
)
|
|
|
|
// Timer intervals (in milliseconds)
|
|
const (
|
|
DefaultTimerInterval = 1000 // 1 second
|
|
FastTimerInterval = 100 // 100ms for high-frequency updates
|
|
SlowTimerInterval = 5000 // 5 seconds for infrequent updates
|
|
SpawnRangeUpdateInterval = 1000 // How often to update spawn ranges
|
|
SpawnVisibilityInterval = 500 // How often to check spawn visibility
|
|
CharsheetUpdateInterval = 30000 // How often to update character sheets
|
|
ClientSaveInterval = 300000 // How often to save client data
|
|
WeatherUpdateInterval = 60000 // How often to update weather
|
|
LocationProximityInterval = 1000 // How often to check location proximity
|
|
PlayerProximityInterval = 500 // How often to check player proximity
|
|
TrackingUpdateInterval = 2000 // How often to update tracking
|
|
WidgetUpdateInterval = 100 // How often to update widgets
|
|
RespawnCheckInterval = 5000 // How often to check respawns
|
|
DeadSpawnCleanupInterval = 30000 // How often to clean up dead spawns
|
|
ScriptTimerCheckInterval = 100 // How often to check script timers
|
|
)
|
|
|
|
// Packet opcodes and types
|
|
const (
|
|
PacketTypeUpdateLoot = "UpdateLoot"
|
|
PacketTypeLootResponse = "LootResponse"
|
|
PacketTypeStoppedLooting = "StoppedLooting"
|
|
PacketTypeSpawnUpdate = "SpawnUpdate"
|
|
PacketTypeRemoveSpawn = "RemoveSpawn"
|
|
PacketTypeAddSpawn = "AddSpawn"
|
|
PacketTypeZoneInfo = "ZoneInfo"
|
|
PacketTypeWeatherUpdate = "WeatherUpdate"
|
|
PacketTypeTimeUpdate = "TimeUpdate"
|
|
PacketTypeChatMessage = "ChatMessage"
|
|
PacketTypeEmote = "Emote"
|
|
PacketTypeAnimation = "Animation"
|
|
)
|
|
|
|
// Chat channel types
|
|
const (
|
|
ChatChannelSay = iota
|
|
ChatChannelTell
|
|
ChatChannelGroup
|
|
ChatChannelRaid
|
|
ChatChannelGuild
|
|
ChatChannelBroadcast
|
|
ChatChannelAnnouncement
|
|
ChatChannelOOC
|
|
ChatChannelYell
|
|
ChatChannelAuction
|
|
)
|
|
|
|
// Animation types
|
|
const (
|
|
AnimationTypeStandard = iota
|
|
AnimationTypeLooping
|
|
AnimationTypeTriggered
|
|
)
|
|
|
|
// Visual state types
|
|
const (
|
|
VisualStateStun = iota
|
|
VisualStateRoot
|
|
VisualStateFear
|
|
VisualStateMezz
|
|
VisualStateStifle
|
|
VisualStateInvisible
|
|
VisualStateStealth
|
|
)
|
|
|
|
// Emote types
|
|
const (
|
|
EmoteTypeStandard = iota
|
|
EmoteTypeTargeted
|
|
EmoteTypeUntargeted
|
|
)
|
|
|
|
// Tradeskill recipe difficulty levels
|
|
const (
|
|
RecipeDifficultyTrivial = iota
|
|
RecipeDifficultyEasy
|
|
RecipeDifficultyMedium
|
|
RecipeDifficultyHard
|
|
RecipeDifficultyExpert
|
|
)
|
|
|
|
// Harvest skill names
|
|
const (
|
|
HarvestSkillMining = "Mining"
|
|
HarvestSkillForesting = "Foresting"
|
|
HarvestSkillFishing = "Fishing"
|
|
HarvestSkillTrapping = "Trapping"
|
|
HarvestSkillGathering = "Gathering"
|
|
)
|
|
|
|
// Transport types
|
|
const (
|
|
TransportTypeNormal = iota
|
|
TransportTypeGuild
|
|
TransportTypeBoat
|
|
TransportTypeFlight
|
|
TransportTypeTeleporter
|
|
)
|
|
|
|
// Flight path states
|
|
const (
|
|
FlightPathStateNone = iota
|
|
FlightPathStateStarting
|
|
FlightPathStateFlying
|
|
FlightPathStateLanding
|
|
FlightPathStateCompleted
|
|
)
|
|
|
|
// Widget types
|
|
const (
|
|
WidgetTypeDoor = iota
|
|
WidgetTypeLift
|
|
WidgetTypeTransporter
|
|
WidgetTypeGeneric
|
|
)
|
|
|
|
// Widget states
|
|
const (
|
|
WidgetStateClosed = iota
|
|
WidgetStateOpen
|
|
WidgetStateMoving
|
|
)
|
|
|
|
// Sign types
|
|
const (
|
|
SignTypeGeneric = iota
|
|
SignTypeZoneTransport
|
|
)
|
|
|
|
// Ground spawn states
|
|
const (
|
|
GroundSpawnStateAvailable = iota
|
|
GroundSpawnStateHarvesting
|
|
GroundSpawnStateDepeted
|
|
GroundSpawnStateRespawning
|
|
)
|
|
|
|
// Group loot methods
|
|
const (
|
|
GroupLootMethodFFA = iota
|
|
GroupLootMethodRoundRobin
|
|
GroupLootMethodMasterLooter
|
|
GroupLootMethodNeedGreed
|
|
GroupLootMethodLotto
|
|
)
|
|
|
|
// Default configuration values
|
|
const (
|
|
DefaultMaxPlayers = 100
|
|
DefaultInstanceLockoutTime = 18000 // 5 hours in seconds
|
|
DefaultInstanceReenterTime = 3600 // 1 hour in seconds
|
|
DefaultInstanceResetTime = 259200 // 72 hours in seconds
|
|
DefaultRespawnTime = 600 // 10 minutes in seconds
|
|
DefaultSpawnDeleteTimer = 300 // 5 minutes in seconds
|
|
DefaultWeatherFrequency = 600 // 10 minutes in seconds
|
|
DefaultWeatherMinSeverity = 0.0
|
|
DefaultWeatherMaxSeverity = 1.0
|
|
DefaultWeatherChangeAmount = 0.1
|
|
DefaultWeatherDynamicOffset = 0.2
|
|
DefaultWeatherChangeChance = 50 // 50% chance
|
|
)
|
|
|
|
// Error messages
|
|
const (
|
|
ErrZoneNotFound = "zone not found"
|
|
ErrZoneShuttingDown = "zone is shutting down"
|
|
ErrZoneNotInitialized = "zone not initialized"
|
|
ErrMapNotLoaded = "map not loaded"
|
|
ErrPathfindingFailed = "pathfinding failed"
|
|
ErrInvalidPosition = "invalid position"
|
|
ErrSpawnNotFound = "spawn not found"
|
|
ErrPlayerNotFound = "player not found"
|
|
ErrClientNotFound = "client not found"
|
|
ErrInvalidSpawnType = "invalid spawn type"
|
|
ErrInvalidMovementCommand = "invalid movement command"
|
|
ErrNoPathAvailable = "no path available"
|
|
ErrTargetTooFar = "target too far away"
|
|
ErrNotInRange = "not in range"
|
|
ErrInvalidTarget = "invalid target"
|
|
ErrCannotCast = "cannot cast spell"
|
|
ErrInsufficientPower = "insufficient power"
|
|
ErrSpellOnCooldown = "spell on cooldown"
|
|
ErrInterrupted = "spell interrupted"
|
|
)
|
|
|
|
// File extensions
|
|
const (
|
|
MapFileExtension = ".map"
|
|
RegionFileExtension = ".rgn"
|
|
NavmeshFileExtension = ".nav"
|
|
WaypointFileExtension = ".wpt"
|
|
)
|
|
|
|
// Default file paths
|
|
const (
|
|
DefaultMapsPath = "maps/"
|
|
DefaultRegionsPath = "regions/"
|
|
DefaultNavmeshPath = "navmesh/"
|
|
DefaultWaypointsPath = "waypoints/"
|
|
)
|
|
|
|
// Grid system constants
|
|
const (
|
|
DefaultGridSize = 100.0 // Grid cell size in world units
|
|
MaxGridID = 1000 // Maximum grid ID
|
|
GridUpdateRadius = 2 // How many grid cells to update around player
|
|
)
|
|
|
|
// Proximity system constants
|
|
const (
|
|
MaxProximityDistance = 500.0 // Maximum proximity detection distance
|
|
ProximityUpdateRadius = 250.0 // Radius for proximity updates
|
|
LocationProximityRadius = 10.0 // Default radius for location proximity
|
|
)
|
|
|
|
// Memory and performance constants
|
|
const (
|
|
MaxSpawnsPerGrid = 100 // Maximum spawns per grid cell
|
|
MaxClientsPerZone = 200 // Maximum clients per zone
|
|
MaxTrackedSpawns = 500 // Maximum tracked spawns per client
|
|
SpawnPoolSize = 1000 // Size of spawn object pool
|
|
PacketBufferSize = 4096 // Size of packet buffers
|
|
MaxConcurrentLoaders = 4 // Maximum concurrent map loaders
|
|
)
|
|
|
|
// Version compatibility
|
|
const (
|
|
MinSupportedClientVersion = 1
|
|
MaxSupportedClientVersion = 60114
|
|
DefaultClientVersion = 60114
|
|
)
|
|
|
|
// Database query limits
|
|
const (
|
|
MaxSpawnLocationsPerQuery = 1000
|
|
MaxLootTablesPerQuery = 100
|
|
MaxNPCsPerQuery = 500
|
|
MaxObjectsPerQuery = 200
|
|
DatabaseQueryTimeout = 30 // seconds
|
|
)
|
|
|
|
// Thread pool sizes
|
|
const (
|
|
DefaultWorkerThreads = 4
|
|
IOWorkerThreads = 2
|
|
NetworkWorkerThreads = 2
|
|
DatabaseWorkerThreads = 2
|
|
)
|
|
|
|
// Cache sizes
|
|
const (
|
|
SpawnCacheSize = 10000
|
|
PlayerCacheSize = 1000
|
|
ItemCacheSize = 50000
|
|
SpellCacheSize = 10000
|
|
QuestCacheSize = 5000
|
|
)
|
|
|
|
// Cleanup intervals
|
|
const (
|
|
DeadSpawnCleanupTime = 300 // 5 minutes before dead spawn cleanup
|
|
ExpiredTimersCleanup = 60 // 1 minute to clean expired timers
|
|
InactiveClientCleanup = 3600 // 1 hour for inactive client cleanup
|
|
MemoryCleanupInterval = 300 // 5 minutes for general memory cleanup
|
|
)
|
|
|
|
// Language system constants
|
|
const (
|
|
CommonLanguageID = 0 // Common tongue (understood by all)
|
|
MaxLanguageSkill = 100 // Maximum language skill value
|
|
DefaultLanguageSkill = 25 // Default language skill for racial languages
|
|
)
|
|
|
|
// Quest system constants
|
|
const (
|
|
MaxActiveQuests = 75 // Maximum active quests per player
|
|
MaxCompletedQuests = 1000 // Maximum completed quests to track
|
|
QuestUpdateRadius = 50.0 // Radius for quest update notifications
|
|
)
|
|
|
|
// PvP system constants
|
|
const (
|
|
PvPSafeZoneRadius = 100.0 // Radius around safe zones where PvP is disabled
|
|
PvPCombatTimeout = 30 // Seconds before PvP combat timeout
|
|
PvPFlagDuration = 300 // Duration of PvP flag in seconds
|
|
)
|
|
|
|
// Housing system constants
|
|
const (
|
|
MaxHouseItems = 800 // Maximum items per house
|
|
HouseMaintenanceDays = 30 // Days before house maintenance due
|
|
MaxHouseSize = 100.0 // Maximum house dimensions
|
|
)
|
|
|
|
// Achievement system constants
|
|
const (
|
|
MaxAchievementPoints = 50000 // Maximum achievement points
|
|
AchievementUpdateRadius = 100.0 // Radius for achievement notifications
|
|
) |