fiftypence
New Member
- Joined
- Jul 28, 2011
- Messages
- 235
- Reaction score
- 13
Energy values seem to take a long time to be updated by Honorbuddy. This means that when evaluating a condition such as Me.CurrentEnergy > 90 using a decorator, the action will not be completed when energy hits /90/ but rather one or two seconds after.
Take, for example, the following code:
this produces a log output similar to:
I use the following code to fix this:
which results in the following log output:
Is there any way to force an update of the player's energy resource without using Lua? I have a sneaky suspicion that constantly calling lua to update energy values every time the tree-walker visits a node will slow things down considerably, and waiting one/two seconds per energy update simply isn't acceptable for my CC.
Cheers
fiftypence
Take, for example, the following code:
Code:
private Composite BuildBehaviorTree()
{
return new PrioritySelector(
new Sequence(
new Action(ret => Logging.Write("Visit" + i + " Energy: " + Me.CurrentEnergy)),
new Action(ret => i++))
);
}
this produces a log output similar to:
Code:
Visit0 Energy: 120
Visit1 Energy: 120
Visit2 Energy: 120
Visit3 Energy: 120
Visit4 Energy: 120
Visit5 Energy: 120
Visit6 Energy: 120
Visit7 Energy: 65
Visit8 Energy: 65
Visit9 Energy: 65
Visit10 Energy: 70
Visit11 Energy: 70
Visit12 Energy: 70
Visit13 Energy: 70
Visit14 Energy: 70
Visit15 Energy: 70
Visit16 Energy: 70
Visit17 Energy: 70
Visit18 Energy: 70
Visit19 Energy: 70
Visit20 Energy: 91
Visit21 Energy: 91
Visit22 Energy: 91
Visit23 Energy: 91
Visit24 Energy: 91
Visit25 Energy: 91
Visit26 Energy: 91
Visit27 Energy: 91
Visit28 Energy: 91
Visit29 Energy: 91
Visit30 Energy: 91
Visit31 Energy: 113
Visit32 Energy: 113
Visit33 Energy: 113
Visit34 Energy: 113
Visit35 Energy: 113
Visit36 Energy: 113
I use the following code to fix this:
Code:
private Composite BuildBehaviorTree()
{
return new PrioritySelector(
new Sequence(
new Action(ret => UpdateEnergyValues()),
new Action(ret => Logging.Write("Visit" + i + " Energy: " + energy)),
new Action(ret => i++))
);
}
private void UpdateEnergyValues()
{
energy = Lua.GetReturnVal<int>("return UnitMana(\"player\");", 0);
}
which results in the following log output:
Code:
Visit0 Energy: 120
Visit1 Energy: 120
Visit2 Energy: 120
Visit3 Energy: 120
Visit4 Energy: 120
Visit5 Energy: 120
Visit6 Energy: 120
Visit7 Energy: 67
Visit8 Energy: 69
Visit9 Energy: 71
Visit10 Energy: 73
Visit11 Energy: 74
Visit12 Energy: 78
Visit13 Energy: 80
Visit14 Energy: 81
Visit15 Energy: 83
Visit16 Energy: 85
Visit17 Energy: 87
Visit18 Energy: 90
Visit19 Energy: 92
Visit20 Energy: 93
Visit21 Energy: 95
Visit22 Energy: 97
Visit23 Energy: 101
Visit24 Energy: 103
Visit25 Energy: 105
Visit26 Energy: 107
Visit27 Energy: 108
Is there any way to force an update of the player's energy resource without using Lua? I have a sneaky suspicion that constantly calling lua to update energy values every time the tree-walker visits a node will slow things down considerably, and waiting one/two seconds per energy update simply isn't acceptable for my CC.
Cheers
fiftypence