Prediction

Prediction

71 Downloads

The aim of Prediction is to take your character's current state (gear, buffs, debuffs, etc) and attempt to predict what abilities you should be using within the next few moments. It does this by keeping an internal database of 'Rules' - similar to SimC - and a list of 'Effects'. These Rules and Effects make use of a simple API that has been exposed for the player to use, and a config frame provided for easy administration.

OPTIONS:

/prediction edit               Brings up the config GUI for priority settings.
/prediction frequency <value> Sets the frequency Prediction's engine runs at.
/prediction latency <value>    Sets your latency, which adjusts Prediction's time calculations.
/prediction overlay off|on    Turns on the diagnostic overlay. NOT RECOMMENDED IN COMBAT.
/prediction ooc off|on      Enables or disables Predictions recommendation GUI when not in combat.

The config frame is restricted to your class and talent specialization, but it allows you to select/make different configs of your own choosing, based on your selected talents and/or named rulesets. The basic API exposed is listed below.

Player {
name The character's name
class The character's class
spec The character's current specialization
talents A list of the character's chosen talents
gear A list of the character's equipped gear
enchants NOT YET IMPLEMENTED
artifact NOT YET IMPLEMENTED
tier NOT YET IMPLEMENTED
haste The character's haste value, where 1 = 100%
hp_percent The character's life, as percent
resources A list of resources the character may have, with associated values
runes For Death Knights, recharge times for each rune
buffs A named list of buffs that the character currently has
debuffs A named list of debuffs that the character currently has
spells A named list of spells that the character has available
}
Target {
name The target's name
hp_percent The target's life, as percent
resources A list of resources the target may have, with associated values
buffs A named list of buffs that the target currently has
debuffs A named list of debuffs that the target currently has
}
Buff/Debuff {
count How many stacks the buff/debuff has
timeRemaining How long the buff/debuff has left till it is exhausted, in seconds
caster Who cast the ability
}
Spell {
spellId The id of the spell
name The name of the spell
icon Path to the icon file
baseCastTime Cast time without haste taken into account
castTime Current cast time
baseCooldown Cooldown without haste and abilities taken into account
maxCharges How many charges this spell may have
currentCharges How many charges the spell currently has
remainingCooldown How long (in seconds) till reusable
}

The author primarily plays an Elemental Shaman, so the data for that is pretty fleshed out, though possibly not optimal, and you are recommended to use it as an example of what to do. For example, the effect of the spell 'Flame Shock' is given below:

  Target.debuffs['Flame Shock'] = { count = 0, timeRemaining = 15, caster = 'player', }
local spent = math.min(20, Player.resources['Maelstrom'])
if Player.talents['Aftershock'] then
spent = spent * 0.7
end
Player.resources['Maelstrom'] = Player.resources['Maelstrom'] - spent

Rules have two fields for you to enter - the name of the ability, and a condition that must evaluate to either TRUE or FALSE, with TRUE indicating that ability should be used. You do not need to check if the ability is available or off cooldown - Prediction will do that for you, before testing any other conditions. For a real example, one of the conditions for 'Totem Mastery' as an Elemental Shaman is

    (not Player.buffs['Totem Mastery'] or Player.buffs['Totem Mastery'].timeRemaining < 1.5)

Rules are evaluated in order of prescription - the first ability found that is both available and matches its condition is the ability that will be recommended at that time. The addon then simulates the use of that ability, via its Effect if defined, and continues to make predictions in this way until a predetermined limit (at the time of writing, 4) is reached.


RECOMMENDATIONS:
When checking the property of an item, particularly gear or debuff, you should check that the gear/debuff first exists. E.g:

 (Target.debuffs['Flame Shock'] and Target.debuffs['Flame Shock'].timeRemaining < 9)


RESTRICTIONS:
It is recommended not to attempt to take into account the possibility of procs. If you wish to however, there is a function boolean Procced(float chance) that you may use.

KNOWN ISSUES:
* GCD is not always taken into account correctly - some abilities have differing base GCDs, and at the moment Prediction doesn't differentiate between them.
* Artifact Traits, Enchants, and Tier bonuses are currently WIP.
* The overlay can cause massive frame drop if enabled during combat, due to scrolling happening with many buffs/debuffs. DON'T ENABLE DURING SERIOUS COMBAT.
* Most classes passive regen not implemented [WIP]