wownerds
New Member
- Joined
- Feb 15, 2011
- Messages
- 1,385
- Reaction score
- 30
Hey there,
while coding my CC, I just came across the following problem: How can I switch between 3 internal behaviours, depending on the add count?
As an intro, here are the relevant code snippets:
From which I am able to retrieve the number of adds by calling
When the CombatBehaviour looks like this:
When using that script, the CC will always use "CreateAoetankingBehavior()".
I tried adding the switch command into "CreateAoetankingBehavior()" and the "CreateBossTankingBehavior()" to determine whether ot not to switch after executing a PrioritySelector. This ended up crashing HB on startup.
My original idea would have looked like this:
Which does not work, because Switch(T) does not accept "int" as a switch argument. But that would not have changed the problem I'm currently experiencing anyway.
All in all, my question is: How can I make the CC evaluate a Switch argument each time a PrioritySelector was run through?
I already tried workaraound like adding
to all decorators in the PrioritySelector, but they seem to be ignored.
Thank you very much in advance.
while coding my CC, I just came across the following problem: How can I switch between 3 internal behaviours, depending on the add count?
As an intro, here are the relevant code snippets:
Code:
private List<WoWUnit> adds = new List<WoWUnit>();
private List<WoWUnit> detectAdds()
{
List<WoWUnit> addList = ObjectManager.GetObjectsOfType<WoWUnit>(false).FindAll(unit =>
unit.Guid != Me.Guid &&
unit.Distance < 10.00 &&
(unit.IsTargetingMyPartyMember || unit.IsTargetingMyRaidMember || unit.IsTargetingMeOrPet) &&
!unit.IsFriendly &&
!unit.IsPet &&
!Styx.Logic.Blacklist.Contains(unit.Guid));
return addList;
}
From which I am able to retrieve the number of adds by calling
Code:
adds.Count
When the CombatBehaviour looks like this:
Code:
protected Composite CreateBossBehavior()
{
adds = detectAdds();
return new Switch(bool) (ret => adds.Count == 1,
CreateBossTankingBehavior(),
new SwitchArgument(bool) (adds.Count > 1,
CreateAoetankingBehavior()));
}
When using that script, the CC will always use "CreateAoetankingBehavior()".
I tried adding the switch command into "CreateAoetankingBehavior()" and the "CreateBossTankingBehavior()" to determine whether ot not to switch after executing a PrioritySelector. This ended up crashing HB on startup.
My original idea would have looked like this:
Code:
protected Composite CreateBossBehavior()
{
adds = detectAdds();
return new Switch(int) (ret => adds.Count == 1,
CreateBossTankingBehavior(),
new SwitchArgument(int) (adds.Count > 1,
CreateAoetankingBehavior())
new SwitchArgument(int) (adds.Count > 1 && adds.Count < 6,
CreateMegaAoetankingBehavior())
);
}
Which does not work, because Switch(T) does not accept "int" as a switch argument. But that would not have changed the problem I'm currently experiencing anyway.
All in all, my question is: How can I make the CC evaluate a Switch argument each time a PrioritySelector was run through?
I already tried workaraound like adding
Code:
=> ret adds.Count >= 6
Thank you very much in advance.