The Cast Engine handles skill execution, casting mechanics, and skill state management for the Game Macro system.
| English Version | 中文版本 |
The Cast Engine provides:
The engine is designed to work with the rotation and rule systems:
Main skill execution and management system.
Manages the actual sending of skill hotkeys and monitoring execution.
Skill := {
Id: 1,
Name: "Fireball",
Key: "1",
X: 100,
Y: 200,
Color: "0xFF0000",
Tolerance: 10,
CooldownMs: 2000,
CastTimeMs: 1500,
CheckReady: true,
ThreadId: 1
}
Monitors cast bars to determine skill execution status.
CastBar := {
Enabled: true,
X: 500,
Y: 600,
Width: 200,
Height: 20,
ActiveColor: "0x00FF00",
InactiveColor: "0x000000",
Tolerance: 5
}
Tracks the current state of all skills.
SkillState := {
IsCasting: false,
CastStartTime: 0,
CastEndTime: 0,
LastUsed: 0,
CooldownEnd: 0,
IsReady: true
}
Initializes the cast engine.
Parameters: None
Returns: Boolean indicating success
Executes a specific skill.
Parameters:
skillId (Integer): Skill identifierthreadId (Integer): Execution thread IDReturns: Boolean indicating execution success
Checks if a skill is ready to use.
Parameters:
skillId (Integer): Skill identifierReturns: Boolean indicating skill readiness
Gets the remaining cooldown for a skill.
Parameters:
skillId (Integer): Skill identifierReturns: Integer cooldown in milliseconds
Adds a new skill to the engine.
Parameters:
skillConfig (Map): Skill configurationReturns: Skill ID
Updates an existing skill configuration.
Parameters:
skillId (Integer): Skill identifierskillConfig (Map): Updated skill configurationReturns: Boolean indicating success
Removes a skill from the engine.
Parameters:
skillId (Integer): Skill identifierReturns: Boolean indicating success
Enables cast bar detection for a skill.
Parameters:
skillId (Integer): Skill identifierconfig (Map): Cast bar configurationReturns: Boolean indicating success
Disables cast bar detection for a skill.
Parameters:
skillId (Integer): Skill identifierReturns: Boolean indicating success
; Configure a simple skill
fireballSkill := {
Id: 1,
Name: "Fireball",
Key: "1",
X: 100,
Y: 200,
Color: "0xFF0000",
Tolerance: 10,
CooldownMs: 2000,
CheckReady: true,
ThreadId: 1
}
CastEngine_AddSkill(fireballSkill)
; Skill with cast bar detection
healSkill := {
Id: 2,
Name: "Heal",
Key: "2",
X: 150,
Y: 200,
Color: "0x00FF00",
Tolerance: 5,
CooldownMs: 3000,
CastTimeMs: 2500,
CheckReady: true,
ThreadId: 1
}
; Add cast bar configuration
castBarConfig := {
Enabled: true,
X: 500,
Y: 600,
Width: 200,
Height: 20,
ActiveColor: "0x00FF00",
InactiveColor: "0x000000",
Tolerance: 5
}
CastEngine_AddSkill(healSkill)
CastEngine_EnableCastBar(2, castBarConfig)
; Execute skill as part of rotation
if (CastEngine_IsSkillReady(skillId)) {
success := CastEngine_ExecuteSkill(skillId, threadId)
if (success) {
; Skill executed successfully
Logger_Info("CastEngine", "Skill executed", Map("skillId", skillId))
}
}
; Check skill state for rule conditions
if (!CastEngine_IsSkillReady(skillId)) {
cooldown := CastEngine_GetSkillCooldown(skillId)
Logger_Info("CastEngine", "Skill on cooldown", Map("skillId", skillId, "cooldown", cooldown))
}
Skills are stored in profile data and loaded with profiles:
profile := App["ProfileData"]
profile["Skills"] := [skill1, skill2, skill3]
Skills can be assigned to different execution threads for parallel processing.
The cast engine includes comprehensive error handling:
The engine provides a debugging interface for real-time monitoring:
; Enable cast debugging
CastEngine_EnableDebug()
; Get debug information
debugInfo := CastEngine_GetDebugInfo()
All cast engine activities are logged for troubleshooting: