The original post before I fixed it:
Then there is a second problem (now the current problem). When I learn Battle orders all units get the normal buff, but I have to cast the spell exactly three times before the buffs start revolving. :banghead: What's up with that? How can I fix it? They do in fact receive the bonuses from the buffs, and they revolve correctly, but unless I cast it 3 times they don't have a buff icon.
Triggers:
Update: The updating buff trigger is it fool proof?
The condition is a boolean array and switches the value from false to true if they pick this hero.
So I have a spell called Battle Orders. It is based off war stomp and does absolutely nothing just to be used for ability level comparison and a trigger event.
When this spell is learned TempGroup is assigned to be matching units in playable map area non hero, non structure, alive. Then given Normal Order, told to cast it, then remove it from them.
When Battle Orders is cast it sets TempGroup again to the same as above. Then there are three if/then/elses if the unit has normal order buff then it gives them offensive order, levels it to the level of battle orders, casts it and removes it. If they have the offensive buff they get a defensive one instead. It they have the defensive one then they get the normal buff. So effectively it cycles between 3 combat styles.
Now here is the problem I'm stumped on:
Only units present when the spell is learned receive the Normal Order spell to use to get the normal buff the whole system revolves around. how do I get the trained units to be updated to the current order and keep it MPI.
I thought about having the trigger check all units alive and decide to give them the current order matching the other units of the same owner, but what if all units are dead and there is nothing to compare to? I think I figured out a way while typing this....When a unit is finished training pick all units matching the same owner and check for all 3 buffs and give it the same one and the final else will default it to normal should cover if all units are dead. Anyone see a problem with that?
When this spell is learned TempGroup is assigned to be matching units in playable map area non hero, non structure, alive. Then given Normal Order, told to cast it, then remove it from them.
When Battle Orders is cast it sets TempGroup again to the same as above. Then there are three if/then/elses if the unit has normal order buff then it gives them offensive order, levels it to the level of battle orders, casts it and removes it. If they have the offensive buff they get a defensive one instead. It they have the defensive one then they get the normal buff. So effectively it cycles between 3 combat styles.
Now here is the problem I'm stumped on:
Only units present when the spell is learned receive the Normal Order spell to use to get the normal buff the whole system revolves around. how do I get the trained units to be updated to the current order and keep it MPI.
I thought about having the trigger check all units alive and decide to give them the current order matching the other units of the same owner, but what if all units are dead and there is nothing to compare to? I think I figured out a way while typing this....When a unit is finished training pick all units matching the same owner and check for all 3 buffs and give it the same one and the final else will default it to normal should cover if all units are dead. Anyone see a problem with that?
Then there is a second problem (now the current problem). When I learn Battle orders all units get the normal buff, but I have to cast the spell exactly three times before the buffs start revolving. :banghead: What's up with that? How can I fix it? They do in fact receive the bonuses from the buffs, and they revolve correctly, but unless I cast it 3 times they don't have a buff icon.
Triggers:
Code:
Battle Orders Learned
Events
Unit - A unit Learns a skill
Conditions
(Learned Hero Skill) Equal to Battle Orders
Actions
Set TempGroup = (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A Hero) Equal to False)) and ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit)))))
Unit Group - Pick every unit in TempGroup and do (Actions)
Loop - Actions
Unit - Add Normal Order to (Picked unit)
Unit - Set level of Normal Order for (Picked unit) to (Level of Battle Orders for (Triggering unit))
Unit - Order (Picked unit) to Orc Troll Berserker - Berserk
Unit - Remove Normal Order from (Picked unit)
Custom script: call DestroyGroup (udg_TempGroup)
Code:
Battle Orders
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Battle Orders
Actions
Set TempGroup = (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A Hero) Equal to False)) and ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit)))))
Unit Group - Pick every unit in TempGroup and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff Normal Order ) Equal to True
Then - Actions
Unit - Add Offensive Order to (Picked unit)
Unit - Set level of Offensive Order for (Picked unit) to (Level of Battle Orders for (Triggering unit))
Unit - Order (Picked unit) to Orc Troll Berserker - Berserk
Unit - Remove Offensive Order from (Picked unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff Offensive Order ) Equal to True
Then - Actions
Unit - Add Defensive Order to (Picked unit)
Unit - Set level of Defensive Order for (Picked unit) to (Level of Battle Orders for (Triggering unit))
Unit - Order (Picked unit) to Orc Troll Berserker - Berserk
Unit - Remove Defensive Order from (Picked unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) has buff Defensive Order ) Equal to True
Then - Actions
Unit - Add Normal Order to (Picked unit)
Unit - Set level of Normal Order for (Picked unit) to (Level of Battle Orders for (Triggering unit))
Unit - Order (Picked unit) to Orc Troll Berserker - Berserk
Unit - Remove Normal Order from (Picked unit)
Else - Actions
Do nothing
Custom script: call DestroyGroup (udg_TempGroup)
Code:
Update Trained Units
Events
Unit - A unit Finishes training a unit
Conditions
And - All (Conditions) are true
Conditions
VeterancyArray[(Player number of (Owner of (Trained unit)))] Equal to True
((Trained unit) is A Hero) Equal to False
Actions
Set TempGroup = (Units in (Playable map area) matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is A Hero) Equal to False)) and ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit)))))
Unit Group - Remove (Trained unit) from TempGroup
Set TempGroup2 = (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Random unit from TempGroup) has buff Normal Order ) Equal to True
Then - Actions
Unit - Add Normal Order to (Trained unit)
Unit - Set level of Normal Order for (Trained unit) to (Level of Battle Orders for (Random unit from TempGroup2))
Unit - Order (Trained unit) to Orc Troll Berserker - Berserk
Unit - Remove Normal Order from (Trained unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Random unit from TempGroup) has buff Offensive Order ) Equal to True
Then - Actions
Unit - Add Offensive Order to (Trained unit)
Unit - Set level of Offensive Order for (Trained unit) to (Level of Battle Orders for (Random unit from TempGroup2))
Unit - Order (Trained unit) to Orc Troll Berserker - Berserk
Unit - Remove Offensive Order from (Trained unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Random unit from TempGroup) has buff Defensive Order ) Equal to True
Then - Actions
Unit - Add Defensive Order to (Trained unit)
Unit - Set level of Defensive Order for (Trained unit) to (Level of Battle Orders for (Random unit from TempGroup2))
Unit - Order (Trained unit) to Orc Troll Berserker - Berserk
Unit - Remove Defensive Order from (Trained unit)
Else - Actions
Unit - Add Normal Order to (Trained unit)
Unit - Set level of Normal Order for (Trained unit) to (Level of Battle Orders for (Trained unit))
Unit - Order (Trained unit) to Orc Troll Berserker - Berserk
Unit - Remove Normal Order from (Trained unit)
Custom script: call DestroyGroup (udg_TempGroup)
Custom script: call DestroyGroup (udg_TempGroup2)