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.
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.
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.
I know its complicated. Its giving me a headache and making me short of scrapping it and starting over with fresh triggers.
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.