How to ally a player to a player that controls a unit-type?

Status
Not open for further replies.
Level 1
Joined
Jan 12, 2014
Messages
6
Hi,

In my game you pick a hero and then get control of its faction. I want to make a trigger that when you pick Hero X, it will look if another player has picked Hero Y, and then ally them.

I know it's easy to use condition "Unit is owned by player", however for Unit-Type this is a bit trickier.

Do I have to create a Temp Group variable for this?

Thanks,

Sem
 
Level 1
Joined
Jan 12, 2014
Messages
6
Alright, this is what I cooked up. A small test doesn't prove it's working. Any hints? :)

upload_2020-8-26_10-2-40.png
 
Level 22
Joined
Feb 26, 2008
Messages
892
There's no "Integer A" here - that's typically used when you're using a loop function that will execute the contents several times. This is probably kind of what you want, but it's missing in this code. Consider a trigger like this:

  • Phase 1 Robb
    • Events
      • Unit - A unit enters HeroSelection <gen>
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet tempGroup = (Units owned by (Picked player) of type Edmure Tully)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in tempGroup) Greater than 0
            • Then - Actions
              • Player - Make (Owner of (Entering unit)) treat (Picked player) as an Ally with shared vision
            • Else - Actions
          • Custom script: call DestroyGroup(udg_tempGroup)
Here, we loop through every player, checking to see if that player has any units of type Edmure Tully. If they do, we ally the player who just entered the HeroSelection region with the player that we found who owns the Edmure Tully unit.
 
Status
Not open for further replies.
Top