[Solved] Region issue

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
Basically this trigger is designed to when a unit is attacked, if it's not owned by the triggering unit + the owner of triggering unit is Player(Teal)

It searchs the map, and checks the regions the triggering unit is inside and see's if the regions contain both the unit 'Flag' + Triggering Unit.

I've already tested the trigger, and the conditionals go through but it stops working when it gets to the 'Unit Group - Pick every unit' part.

Am I doing this wrong? I'm trying to search the entire map and find any unit matching 'Flag' and also check if the owner of 'Flag/Picked unit' is the owner of the triggering unit/Unit being attacked and then proceed to do the actions. If never gets past the Unit Group conditions though. Even though a flag exists inside the regions + owned by player(Teal) Any idea? Thanks.


  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Start
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Attacking unit)) Not equal to (Owner of (Triggering unit))
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Game - Display to (All players) the text: YesMain
          • Unit Group - Pick every unit in (Units in (Entire map) matching (((Unit-type of (Picked unit)) Equal to Flag) and ((Owner of (Picked unit)) Equal to (Owner of (Triggering unit))))) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Base01a <gen> contains (Triggering unit)) Equal to True) and ((Base01a <gen> contains (Picked unit)) Equal to True)
                      • ((Base01b <gen> contains (Triggering unit)) Equal to True) and ((Base01b <gen> contains (Picked unit)) Equal to True)
                      • ((Base01c <gen> contains (Triggering unit)) Equal to True) and ((Base01c <gen> contains (Picked unit)) Equal to True)
                • Then - Actions
                  • Game - Display to (All players) the text: Yes
                • Else - Actions
                  • Game - Display to (All players) the text: No
        • Else - Actions
  • [/code]
 
inside the filter use matching unit to address the unit currently tested.
inside thed loop - actions use picked unit to address the group unit currently picked.

I would recomment to use pick units of player instead of units of entire map, in case you need units of one player only. It can be quite costly to pick all units of entire map.
 
Level 12
Joined
Dec 2, 2016
Messages
733
inside the filter use matching unit to address the unit currently tested.
inside thed loop - actions use picked unit to address the group unit currently picked.

I would recomment to use pick units of player instead of units of entire map, in case you need units of one player only. It can be quite costly to pick all units of entire map.

Thanks, not sure if I followed what you said 100% but I came up with this

So now when a player attacks the 'Flag' / matched unit it runs the 'Yes' message, and if you attack any other object in those regions not the Flag it runs the 'No' message.
I'm basically trying to check all 3 regions if there is both a flag + the triggering unit inside any of those 3 regions. What exactly am I doing wrong here?
Thanks for the help.


  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Start
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Attacking unit)) Not equal to (Owner of (Triggering unit))
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Game - Display to (All players) the text: YesMain
          • Unit Group - Pick every unit in (Units owned by (Triggering player) of type Flag) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Base01a <gen> contains (Triggering unit)) Equal to True) and ((Base01a <gen> contains (Picked unit)) Equal to True)
                      • ((Base01b <gen> contains (Triggering unit)) Equal to True) and ((Base01b <gen> contains (Picked unit)) Equal to True)
                      • ((Base01c <gen> contains (Triggering unit)) Equal to True) and ((Base01c <gen> contains (Picked unit)) Equal to True)
                • Then - Actions
                  • Game - Display to (All players) the text: Yes
                • Else - Actions
                  • Game - Display to (All players) the text: No
        • Else - Actions
 
Level 42
Joined
Feb 27, 2007
Messages
5,265
The problem with your trigger is that "Triggering Unit" is a flag (it was attacked) and the units looped through in the pick action are also flags. In this case one of the "Picked Unit"s is the flag that triggered the event. You should have used "attacking unit" somewhere, but actually the unit is attacked event is ass and should never be used. Instead:
  • Be aware that the "unit is attacked" event runs when a unit begins its attack (and thus while it can still be cancelled, before a projectile is fired, etc.), not when damage is dealt to a unit by another unit. It is recommended to use a Damage Detection System (there are many in the resource section here) instead of the "unit is attacked" event in pretty much all cases.
  • When a DDS is properly implemented all you will have to change is the event and the way you refer to different units. I have done this below.
  • There should probably be a check to make sure it's the flag that's being attacked, otherwise this whole trigger will run ANY time ANY unit owned by teal takes damage.
  • You can move the "owner of triggering unit equal to Player 3" check to the main trigger conditions, since it has to be true every time anyway.
  • Events
    • Time - Elapsed game time is 0.50 seconds
  • Conditions
  • Actions
    • Set NUM_BASES = 3
    • Set Bases[1] = Base01a <gen>
    • Set Bases[2] = Base01b <gen>
    • Set Bases[3] = Base01c <gen>
    • //continue as necessary to add all bases to loop through
  • Events
    • Game - DamageEventVariable becomes equal to 1.00 //this is the event most DDSes add; it's just a real variable event, but the system sets it all up for you (read documentation and use the proper event here)
  • Conditions
    • //the variables you should use to refer to the damaged unit and the damaging unit are defined in the documentation of the you chose, these are just examples (read documentation and use the proper ones)
    • (Owner of (DamagedUnit)) equal to Player 3 (Teal)
    • (Unit-type of (DamagedUnit)) equal to Flag
    • (DamagingUnit belongs to an enemy of (Owner of DamagedUnit)) equal to true
  • Actions
    • For each (Integer A) from 1 to NUM_BASES do (Actions)
      • Loop - Actions
        • If (conditions) then (actions) else (actions)
          • If - Conditions
            • (Bases[(Integer A)] contains DamagedUnit) equal to true
            • (Bases[(Integer A)] contains DamagingUnit) equal to true
          • Then - Actions
            • -------- Do stuff --------
            • Custom script: exitwhen true //this line causes the loop to end prematurely, which is fine here because we already found the matching region.
          • Else - Actions
 
Status
Not open for further replies.
Top