Castle Assault Map Gate Trigger Problem...

Effane

Save/Load Code Tutorial
Reaction score
51
I am working on a map similar to Castle Fight in alot of respects. I have it down to a working map, with 2 sides, full pathing, terrain and 1 race in game.

Now the problem I am having is I have off and on been working on a very irritating bug I have been having from the beginning. My gate will open sometimes, and close other times, but they are far from reliable, in fact closer to unreliable. The flip side of this, units are having serious issues attacking the gate, especially when it gets stuck shut. Gates wont open for the opposite team (which is good).

This is what I would like to have.

Team West unit nears gate in Castle west and it opens allowing them out.
-May want it to not open when Team East is in area (I havent tried anything like this yet, I am still trying to get it to work)
-Dont want it to open for Team East
-Do want it to close after the unit leaves the area or if there are no units in the region of the gate or all units in the region have been killed that are friendly to the gate.


Here is my open code that continues pathing. Seems to work fine without enemies, but when combat starts it goes to pieces. (I think this has to do with dead units in the region not allowing close, I need a fix).

BuilderListUnitArray contains all the builders for the map. I dont want them opening gates while they move about.

-WestCastleMiddleGate1Out is a region inside the castle walls.
-MiddlePath4West is outside and down the path.
-The custom value doesnt affect this, its for making sure players cant control the movement of units. It works great.

Code:
MiddlePath3WestW
    Events
        Unit - A unit enters WestCastleMiddleGate1Out <gen>
    Conditions
        ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to BuilderListUnitArray[1]
    Actions
        Destructible - Open Iron Gate (Vertical Level 1) 0112 <gen>
        Destructible - Open Iron Gate (Vertical Level 1) 1104 <gen>
        Wait 0.30 seconds
        Set TempPoint = (Random point in MiddlePath4West <gen>)
        Unit - Order (Triggering unit) to Attack-Move To TempPoint
        Custom script:   call RemoveLocation(udg_TempPoint)
        Unit - Set the custom value of (Triggering unit) to 24

This is my gate close trigger. This is where I think 90% of the issues are. I have a feeling that units dont leave a region when they die.

Code:
MiddleGate1WestClose
    Events
        Unit - A unit leaves WestCastleMiddleGate1Out <gen>
    Conditions
        ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to BuilderListUnitArray[1]
    Actions
        Set TempUnitGroup = (Units in WestCastleMiddleGate1Out <gen> matching (((Matching unit) belongs to an ally of Player 1 (Red)) Equal to True))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in TempUnitGroup) Less than or equal to 0
            Then - Actions
                Destructible - Close Iron Gate (Vertical Level 1) 0112 <gen>
                Destructible - Close Iron Gate (Vertical Level 1) 1104 <gen>
            Else - Actions
        Custom script:   call DestroyGroup (udg_TempUnitGroup)

Here is my gate attack code from the East team. This thing is totally broken. It may be due to gates being open when told to attack them. I wonder if that is an issue at all.

MiddlePath3West is the pathing region for the east team units to reach the gate. It barely overlaps the gate and some of the MiddleGateWest1Out.

Code:
MiddlePath3WestE
    Events
        Unit - A unit enters MiddlePath3West <gen>
    Conditions
        ((Triggering unit) belongs to an ally of Player 2 (Blue)) Equal to True
        And - All (Conditions) are true
            Conditions
                (Unit-type of (Triggering unit)) Not equal to BuilderListUnitArray[1]
    Actions
        Set TempUnitGroup = (Units in MiddlePath3East <gen> matching (((Matching unit) belongs to an ally of Player 2 (Blue)) Equal to True))
        Set TempUnitGroup2 = (Units in MiddlePath3East <gen> matching (((Matching unit) belongs to an ally of Player 1 (Red)) Equal to True))
        Unit Group - Pick every unit in TempUnitGroup 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
                                (Number of units in TempUnitGroup2) Less than or equal to 0
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Iron Gate (Vertical Level 1) 0112 <gen> is alive) Equal to True
                            Then - Actions
                                Unit - Order (Picked unit) to Attack Iron Gate (Vertical Level 1) 0112 <gen>
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Iron Gate (Vertical Level 1) 1104 <gen> is alive) Equal to True
                                    Then - Actions
                                        Unit - Order (Picked unit) to Attack Iron Gate (Vertical Level 1) 1104 <gen>
                                    Else - Actions
                                        Set TempPoint = (Random point in MiddlePath2West <gen>)
                                        Unit - Order (Triggering unit) to Attack-Move To TempPoint
                                        Custom script:   call RemoveLocation(udg_TempPoint)
                    Else - Actions
                        Set TempPoint = (Random point in MiddlePath2West <gen>)
                        Unit - Order (Triggering unit) to Attack-Move To TempPoint
                        Custom script:   call RemoveLocation(udg_TempPoint)
        Unit - Set the custom value of (Triggering unit) to 22
        Custom script:   call DestroyGroup (udg_TempUnitGroup)
        Custom script:   call DestroyGroup (udg_TempUnitGroup2)

I know its complicated. Its giving me a headache and making me short of scrapping it and starting over with fresh triggers.
 

Tom Jones

N/A
Reaction score
437
Maybe try something like this:
Code:
Gate Test
    Events
        Unit - A unit enters *RegionA*
        Unit - A unit leaves *RegionA*
    Conditions
    Actions
        Custom script:   set bj_wantDestroyGroup = true
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (*RegionA* contains (Triggering unit)) Equal to True
                ((Units within 512.00 of (Center of (*RegionA*)) matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) is empty) Equal to True
            Then - Actions
                Destructible - Open *SomeGate*
            Else - Actions
                Game - Display to (All players) the text: Enemies Nearby!
        Custom script:   set bj_wantDestroyGroup = true
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (*RegionA*) contains (Triggering unit)) Equal to False
                ((Units in (*RegionA*) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True))) is empty) Equal to True
            Then - Actions
                Destructible - Close *SomeGate*
            Else - Actions
 

Effane

Save/Load Code Tutorial
Reaction score
51
Thank you for the trigger. I am trying to work it into the map right now.
We will see what I get out of it.
 

Effane

Save/Load Code Tutorial
Reaction score
51
Well it worked and it didnt work.
It caused a whole new issue which was units getting very confused on who to attack and when near the castles. In the end if one group was large enough to hold the gate region from the outside it would end up a pure ranged fight and no one would attack the gates to knock them down.

I found a different solution. I wouldnt call it better, but it solves all the misery of destructibles.

I am using a tower to act as the control point for the gate. Tower exist and gates open, tower dies and gates go to condition destroyed.

All the problems seem to be with Gates being considered dead when open as well as destroyed, and closing a destroyed gate actually ressurects it at full health.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> open as well as destroyed, and closing a destroyed gate actually ressurects it at full health.

That can be helped though.
Some boolean that is true when you open it and false when it's opened by death.
And some extra "memory" that knows the health when you open it.
 

Effane

Save/Load Code Tutorial
Reaction score
51
I thought about that, but gates overhead was getting outrageous.

The tower solution is neat though, it added an element that wasnt in the map before, you can repair "gates" by repairing the towers. While before getting the gates repaired would have taken some unusual work.

Also, it shorten my triggers by overhalf, even if it added an extra for each towers death scene. Cant complain about that.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top