• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Turn Footman with the highest Mana into a Captain for a duration and then do it again?

Level 14
Joined
May 9, 2021
Messages
263
Hello HIVE.

I'm trying to work out this Trigger.

Basically, I want to turn a random Footman (owned by any allied Players) into a Captain, with the Footman being chosen based on maximum mana (whichever one has the highest Mana).

There can only be one Captain at a time (for ALL players). The Captain must last for a duration, then return to a Footman afterward, and then the cycle must start again on another Footman.

Help would be greatly appreciated. I've been struggling with this for a while now.
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
you wrote "(owned by any allied Players)" and "(for ALL players)". does this choose the one with the highest mana out of all footmen, or only players allied to X (I'm guessing triggering player)?

also - what event triggers this cycle? if it's just periodic, then when you wrote allied players - allied to who?
 
Level 30
Joined
Aug 29, 2012
Messages
1,383
Here's how you detect the allied footman with the most mana
  • Actions
    • Set VariableSet MaxMana = 0.00
    • Set VariableSet TempGroup = (Units in (Playable map area) matching ((((Matching unit) belongs to an ally of Player 1 (Red).) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman)))
    • 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
            • (Percentage mana of (Picked unit)) Greater than or equal to MaxMana
          • Then - Actions
            • Set VariableSet Captain = (Picked unit)
            • Set VariableSet MaxMana = (Percentage mana of Captain)
          • Else - Actions
For the rest, can't really tell without knowing a/ what/who causes this effect to happen, and b/ what's the duration
 
Level 14
Joined
May 9, 2021
Messages
263
you wrote "(owned by any allied Players)" and "(for ALL players)". does this choose the one with the highest mana out of all footmen, or only players allied to X (I'm guessing triggering player)?

also - what event triggers this cycle? if it's just periodic, then when you wrote allied players - allied to who?
It should choose between all Footmen of Triggering Player and Allied Players (all Players of the same Force).

The trigger is periodic.
Here's how you detect the allied footman with the most mana
  • Actions
    • Set VariableSet MaxMana = 0.00
    • Set VariableSet TempGroup = (Units in (Playable map area) matching ((((Matching unit) belongs to an ally of Player 1 (Red).) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman)))
    • 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
            • (Percentage mana of (Picked unit)) Greater than or equal to MaxMana
          • Then - Actions
            • Set VariableSet Captain = (Picked unit)
            • Set VariableSet MaxMana = (Percentage mana of Captain)
          • Else - Actions
For the rest, can't really tell without knowing a/ what/who causes this effect to happen, and b/ what's the duration
It's just a periodic event. It happens through the whole game (basically a Racial mechanic).

The duration should be... Say about 2 in game minutes. It should be long enough that every Player gets fair control of the Captain.
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
It should choose between all Footmen of Triggering Player and Allied Players
It's just a periodic event.

periodic events don't have a triggering player.

if there are two factions, I'm assuming you have some other variables saved about which players are in each faction. So use that with player groups.

something like (as the action of the periodic trigger) -

for each faction:

set variable (unitGroup) factionFootmen = all units where unit type = footman, and owning player in in faction[factionNumber](playerGroup)

and then using what chaosium sent set a captain for that faction.

(I adlibbed, might not exactly match the GUI syntax...)
 
Level 14
Joined
May 9, 2021
Messages
263
Here's how you detect the allied footman with the most mana
  • Actions
    • Set VariableSet MaxMana = 0.00
    • Set VariableSet TempGroup = (Units in (Playable map area) matching ((((Matching unit) belongs to an ally of Player 1 (Red).) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman)))
    • 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
            • (Percentage mana of (Picked unit)) Greater than or equal to MaxMana
          • Then - Actions
            • Set VariableSet Captain = (Picked unit)
            • Set VariableSet MaxMana = (Percentage mana of Captain)
          • Else - Actions
For the rest, can't really tell without knowing a/ what/who causes this effect to happen, and b/ what's the duration
Where do you find the "and" in the Condition regarding "set Variable"?
 
Level 30
Joined
Aug 29, 2012
Messages
1,383
At the bottom of the list, hit A a few times and you'll reach it automatically

1722686338922.png
 
Level 14
Joined
May 9, 2021
Messages
263
Here's how you detect the allied footman with the most mana
  • Actions
    • Set VariableSet MaxMana = 0.00
    • Set VariableSet TempGroup = (Units in (Playable map area) matching ((((Matching unit) belongs to an ally of Player 1 (Red).) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman)))
    • 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
            • (Percentage mana of (Picked unit)) Greater than or equal to MaxMana
          • Then - Actions
            • Set VariableSet Captain = (Picked unit)
            • Set VariableSet MaxMana = (Percentage mana of Captain)
          • Else - Actions
For the rest, can't really tell without knowing a/ what/who causes this effect to happen, and b/ what's the duration
Okay, I've got everything you wrote down here down, but to be honest I'm not sure what to do next (I'm bad with Triggers)...

Can you help me finish it, please?

Edit: Okay, I got it to turn Footmen into Captains, but how do you limit the amount of Captains...?
 
Last edited:
Top