The Buff Engine manages buffs, debuffs, and status effects detection and tracking for the Game Macro system.
| English Version | 中文版本 |
The Buff Engine provides:
The engine is designed to work with the rotation and rule systems:
Main buff detection and management system.
Manages the detection of buffs and debuffs through pixel recognition.
Buff := {
Id: 1,
Name: "Power Boost",
Type: "buff",
X: 100,
Y: 200,
Width: 30,
Height: 30,
Color: "0xFF0000",
Tolerance: 10,
DurationMs: 15000,
Priority: 1,
Stackable: false,
MaxStacks: 1,
Required: false
}
Tracks active buffs and their remaining durations.
BuffState := {
BuffId: 1,
Name: "Power Boost",
IsActive: true,
StartTime: 0,
EndTime: 15000,
RemainingMs: 12000,
Stacks: 1,
IsExpired: false
}
Handles buff priority for rotation decision making.
BuffPriority := {
High: ["Power Boost", "Critical Strike"],
Medium: ["Haste", "Attack Power"],
Low: ["Minor Buffs", "Defensive Cooldowns"]
}
Initializes the buff engine.
Parameters: None
Returns: Boolean indicating success
Performs buff detection for all configured buffs.
Parameters: None
Returns: Array of detected buff states
Checks if a specific buff is active.
Parameters:
buffId (Integer): Buff identifierReturns: Boolean indicating buff active state
Gets the remaining duration for a buff.
Parameters:
buffId (Integer): Buff identifierReturns: Integer duration in milliseconds
Adds a new buff to the detection system.
Parameters:
buffConfig (Map): Buff configurationReturns: Buff ID
Updates an existing buff configuration.
Parameters:
buffId (Integer): Buff identifierbuffConfig (Map): Updated buff configurationReturns: Boolean indicating success
Removes a buff from the detection system.
Parameters:
buffId (Integer): Buff identifierReturns: Boolean indicating success
Gets all currently active buffs.
Parameters: None
Returns: Array of active buff states
Gets the complete state of a specific buff.
Parameters:
buffId (Integer): Buff identifierReturns: Buff state map
Resets the tracking for a specific buff.
Parameters:
buffId (Integer): Buff identifierReturns: Boolean indicating success
; Configure a simple buff
powerBoost := {
Id: 1,
Name: "Power Boost",
Type: "buff",
X: 100,
Y: 200,
Width: 30,
Height: 30,
Color: "0xFF0000",
Tolerance: 10,
DurationMs: 15000,
Priority: 1,
Stackable: false,
MaxStacks: 1,
Required: false
}
BuffEngine_AddBuff(powerBoost)
; Configure a debuff
slowDebuff := {
Id: 2,
Name: "Slow",
Type: "debuff",
X: 150,
Y: 200,
Width: 30,
Height: 30,
Color: "0x0000FF",
Tolerance: 5,
DurationMs: 10000,
Priority: 2,
Stackable: true,
MaxStacks: 3,
Required: false
}
BuffEngine_AddBuff(slowDebuff)
; Check buff state for rotation decisions
if (BuffEngine_IsBuffActive(powerBoostId)) {
; Buff is active, execute high priority skills
RotationEngine_ExecuteHighPriority()
} else {
; Buff not active, execute normal rotation
RotationEngine_ExecuteNormal()
}
; Create rule based on buff state
rule := {
Condition: {
Type: "buff",
BuffId: powerBoostId,
Operator: "active",
Duration: 5000
},
Action: {
Type: "skill",
SkillId: highDamageSkillId
}
}
RuleEngine_AddRule(rule)
; Continuous buff monitoring
while (App["IsRunning"]) {
activeBuffs := BuffEngine_DetectBuffs()
; Process buff states
for buffState in activeBuffs {
if (buffState["IsActive"]) {
remaining := buffState["RemainingMs"]
Logger_Info("BuffEngine", "Buff active", Map(
"buffId", buffState["BuffId"],
"remaining", remaining
))
}
}
Sleep(100) ; Check every 100ms
}
Buffs are stored in profile data and loaded with profiles:
profile := App["ProfileData"]
profile["Buffs"] := [buff1, buff2, buff3]
Buff priorities can be configured per profile:
profile["BuffPriority"] := {
High: ["Power Boost", "Critical Strike"],
Medium: ["Haste", "Attack Power"],
Low: ["Minor Buffs", "Defensive Cooldowns"]
}
The buff engine includes comprehensive error handling:
The engine provides a debugging interface for real-time monitoring:
; Enable buff debugging
BuffEngine_EnableDebug()
; Get debug information
debugInfo := BuffEngine_GetDebugInfo()
All buff engine activities are logged for troubleshooting: