Sidoine / Ovale

An add-on for World of Warcraft that displays icons based on scripts
MIT License
46 stars 46 forks source link

Implement better pool_resource,for_next=1 functionality #64

Open ShmooDude opened 8 years ago

ShmooDude commented 8 years ago

The current pool_resource,for_next=1 functionality is rather unwieldy. Ovale evaluates the entire action list as opposed to Simulationcraft that stops once it gets a valid action/pool_resource. What pool_resource,for_next=1 means to Ovale is basically to ignore the resource cost when determining the BestAction. It currently does this through an if/unless pair, where the unless portion checks to see if the action will be usable sans the resource cost.

I've implemented a much better way to get this done doing several things: #63

1) I separated out any extra time required to pool resources into it's own variable actionResourceExtend instead of adding it to either the actionCooldownStart or actionCooldownDuration.

2) When computing the action (e.g. the time the action will be usable), I add this value to the starting timestamp of the action if the pool_resource named parameter is not set to 1. If pool_resource is set to 1, then only the cooldown or GCD is considered when determining the starting timestamp of the action.

3) I then modify the Frame to always add actionResourceExtend to the start if the ability is not on cooldown (or only the global cooldown) or actionCooldownDuration if the ability is on cooldown.

4) Because I've now separated any extra time needed to generate a resource, the portion of code that determines if the icon should turn red is greatly simplified. We no longer need to manipulate the starting time of the action in the Frame and can simply run a check in the icon update function directly. This was actually completely non-functional as near as I can tell in version 7.0.14.

5) I added an extraPower variable to TimeToPower and GetTimeToSpell. This allows you to send a direct cost increase to the two functions that is not affected by any cost reductions. It is used through the extra_amount= named parameter in a Spell(). This matches both the way extra_amount works in simulationcraft as well as Ferocious Bite's extra energy consumption (and possibly others that similarly can consume extra resources). This must be a static number as you can't send a script's function as a named parameter.

What is left is to change the simulationcraft translator to take advantage of the new functionality. A simple example:

#pool_resource,for_next=1 #swipe_cat,if=spell_targets.swipe_cat>=8 if Enemies() >= 8 Spell(swipe_cat) unless Enemies() >= 8 and SpellUsable(swipe_cat) and SpellCooldown(swipe_cat) < ...TimeToEnergyFor(swipe_cat) can simply become #pool_resource,for_next=1 #swipe_cat,if=spell_targets.swipe_cat>=8 if Enemies() >= 8 Spell(swipe_cat pool_resource=1)

With extra_amount (which Ovale currently isn't even translating correctly anyhow): #pool_resource,for_next=1,extra_amount=10 #swipe_cat,if=spell_targets.swipe_cat>=8 if Enemies() >= 8 Spell(swipe_cat) doesn't require the extra amount unless Enemies() >= 8 and SpellUsable(swipe_cat) and SpellCooldown(swipe_cat) < ...TimeToEnergy(10) doesn't require the cost of Swipe can simply become #pool_resource,for_next=1,extra_amount=10 #swipe_cat,if=spell_targets.swipe_cat>=8 if Enemies() >= 8 Spell(swipe_cat pool_resource=1 extra_amount=10)

It's probably going to be a while before I can really dig into the translator. Should be explained thoroughly in case someone has the time before I get to it.

ShmooDude commented 6 years ago

Still could potentially be done, although I think there's other things I'd rather do first.