If anybody could help me out here with this rather ambitious idea for a trigger, iv'e tried a few things myself but I'm having trouble getting it off the ground.
Essentially in my map I want players to have to build a 3x3 4x4 or 5x5 block of buildings, and in return a unit spawns in a region.
In other words
[Pool][Pool][Pool] [gate][gate][gate]
[Pool][Pool][Pool] = Spawn a zergling or [gate][gate][gate] = Spawn a zealot
[Pool][Pool][Pool] [gate][gate][gate]
The idea I had was to create a global unit group variable and then for the game to add last created units to it, everytime a structure was built it would CONDITION[check the number of that structure stored within the unit group] and then spawn the unit and emptied the unit group if it was = to 9 (the amount of buildings in a 3x3 cube) I havnt had much success so far, I have been unable to get the variable to store more than one building despite building many.
I know its a challenge but please help if you could =D
Not really a challenge, just need more info. Please post the text of your current version of the trigger. Also make sure your using the add unit to unit group action.
What are the requirement too. Do the building have to be in a certain order or is it just the number of buildings and types. Be very specific.
Hmmmm my graphical explanation didnt really happen because of the tabbing... I suspect my current trigger is garbage so I will just be very specific about what I want the trigger to do.
In my map players are required to build "rooms" by making square configurations of the same building. For example a 3x3 square made out of 9 spawning pools.
I also want these rooms to be able to expand to a maximum of a 5x5 area. Obviously in the context of the game, the larger room will cost more but will yield a larger reward (i.e. more units, stronger units etc)
So the idea trigger would detect when a player builds (lets just say a spawning pool for now), if the game sees that this has created a 3x3 block of 9 spawning pools, the game will spawn a unit (lets say a zergling) in a given region (on my map its region 24, not particularly relevant).
Then say the player builds around this 3x3 square of pools to make a 4x4 square of pools. Most probably a second trigger (or the same one I don't really know the limits on these triggers) will see that a 4x4 block has emerged and will correspondingly spawn 2 zerglings in the given region.
Then they build a 5x5 block and it spawns 5 zerglings
I plan to duplicate the logic of this trigger to apply to many different buildings i.e warp gate to zealot, cyber core to stalker, hydra den to hydra so on and so forth.
If anything is unclear let me know and i'll be happy to explain what iv'e got in my head
Well, this might be an overly simplistic solution. But if say you have a 9x9 room, I would just run a periodic trigger checking every second to see whats in the room and then when the correct number of buildings are in there, do something about it... IE a trigger like:
event:
every 1 seconds of real time
action:
for each spawning pool in building room add 1 to variable spawning pool
for each gateway in building room add 1 to variable gateway
ect...
and lastly a long trigger of if statements to make everything happen.
If
variable spawning pool = 9
then
create 3 zerglings
else
If
variable spawning pool = 3
variable gateway = 6
then
create 1 zergling
create 2 zealots
ect... just keep putting the next if statement inside the else statement of the previous one with the else of the final if statement clearing all the variables if it runs though all of them and no combination is found. Soo:
else:
set variable spawning pool = 0
set variable gateway = 0
Obviously this does not account for building placement, and nothing would happen until one of the if-then-else statements became true.
The "complicated" part would be instead of just checking a single region covering the whole building room for whats inside, there would be 9 regions in the building room and checking them all independently. Then if region a b and c all had spawning pools then variable spawning pool = 3 ect... That just becomes more grunt work of if statements then complex though.
I have considered that sort of solution, effectively brute forcing every placement combination, however, this would require me to substantially limit where the players can play the buildings as it would be otherwise far too difficult to code in. I am also not optimistic as to the load it would put on the game if I was to have say 50 or so of those triggers going constantly
You could make things easier for you by defining some central core to build around, this way you only need to check around the cores. Checking every possible combination for a free space would probably be too performance-heavy, also if you build like one 5x5 construct, it would also be 9 3x3 constructs, so how would you determine, which one is actually registered?
A very good point, I was thinking that if it detects a 5x5 it stops all the 3x3 triggers? I like the idea of having a central core, but I still wouldnt know how to code triggers to detect units being built around the core
OK so far this is just for the 3x3 setup, but I can run a seperate group of triggers for the 4x4 and 5x5 respectively
There are two global variables:
typedef Unit Group Room_3x3
typedef Region Room_3x3_Proxy_Check
Lair_Add
Events
Unit - ("Spawning Pool" from the Global data table) construction progress is Completed
Local Variables
Conditions
(Owner of (Triggering unit)) == 1
Actions
Trigger - Add (Actions) to the action queue
Actions
Variable - Set Room_3x3_Lair_Region = (Region((Center of Room_3x3), 3.5))
Unit Group - Add (Triggering progress unit) to Room_3x3
Trigger - Run Lair_Unit_Count_Check (Check Conditions, Don't Wait until it finishes)
Lair_Unit_Count_Check
Events
Local Variables
Conditions
(Number of Living units in Room_3x3) == 9
((Center of Room_3x3) is in Room_3x3_Lair_Region) == True
((Position of (Unit 1 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 2 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 3 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 4 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 5 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 6 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 7 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 8 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 9 from Room_3x3)) is in Room_3x3_Lair_Region) == True
Actions
Unit - Create 1 Zergling for player 1 at (Center of Region 024) facing 270.0 degrees (Ignore Placement)
Unit Group - Remove all units from Room_3x3
Essentially every time a spawning Pool is created the first trigger:
-adds it to the unit group Room_3x3
-creates a region with radius just big enough to accomadate a 3x3 block of buildings around the centre of the units within the unit group, then assigns region to Room_3x3_Proxy_Check
-Passes control to the next trigger
The next trigger
-counts the units in the unit group, if there is 9
AND
-if each of the units within the group are located within the region
It
-Spawns a zergling
-empties the unit group
I have tested this trigger by making configurations that are slightly off a 3x3 square but it only works if the player constructs the exact 3x3. So that's one success. I'm out of town for the next few days but if anyone can see any potential bugs or flaws in my triggers please feel free to let me know.
I am also aware that if a player makes a mistake and builds outside of the 3x3 block that they will never be able to spawn a zergling again O.O. I plan to implement some sort of trigger whereby if a unit is created that is outside the bounds of the region or located a certain distance away from another pool or something, that it removes that unit from the unit group so the player can still finish off their room and have the only punishment be a wasted building.
Also sorry about how spaced out the stuff is I couldnt get the tabbing or shift+enter new lines to show up so I had to just make every line a new paragraph =(
Would it be easier to just limit where they can build in each "room"? or do players need to be able to build rooms anywhere they want to, on the map? For example, if you have a timer that continually counts down from say 5, and each time it hits 0 it checks each room for a configuration. If a configuration matches one that you've defined in a master list, then it spawns the unit associated with that configuration. That way, you only need one list of combo's and it checks each room for each combo every 5 seconds.
Yer but then Ive got like 100 of those triggers all running at the same time and putting unnecessary load on the game and that would also take ages to code.
I have another problem though...
I have realised that my event (for some bizzare reason) is triggering whenever anything at all is built, not just a spawning pool. At the moment I am using the:
Unit - "Spawning Pool" from the Global Data table construction progress is Completed
Event. But it seems upon some testing that no matter what I put as the string identifier (even like command centre or something stupid) whenever I build anything, it starts the trigger. Has anyone got a better way to make an event that triggers whenever a spawning pool is built?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi
If anybody could help me out here with this rather ambitious idea for a trigger, iv'e tried a few things myself but I'm having trouble getting it off the ground.
Essentially in my map I want players to have to build a 3x3 4x4 or 5x5 block of buildings, and in return a unit spawns in a region. In other words
[Pool][Pool][Pool] [gate][gate][gate] [Pool][Pool][Pool] = Spawn a zergling or [gate][gate][gate] = Spawn a zealot [Pool][Pool][Pool] [gate][gate][gate]
The idea I had was to create a global unit group variable and then for the game to add last created units to it, everytime a structure was built it would CONDITION[check the number of that structure stored within the unit group] and then spawn the unit and emptied the unit group if it was = to 9 (the amount of buildings in a 3x3 cube) I havnt had much success so far, I have been unable to get the variable to store more than one building despite building many.
I know its a challenge but please help if you could =D
Not really a challenge, just need more info. Please post the text of your current version of the trigger. Also make sure your using the add unit to unit group action.
What are the requirement too. Do the building have to be in a certain order or is it just the number of buildings and types. Be very specific.
Hmmmm my graphical explanation didnt really happen because of the tabbing... I suspect my current trigger is garbage so I will just be very specific about what I want the trigger to do.
In my map players are required to build "rooms" by making square configurations of the same building. For example a 3x3 square made out of 9 spawning pools. I also want these rooms to be able to expand to a maximum of a 5x5 area. Obviously in the context of the game, the larger room will cost more but will yield a larger reward (i.e. more units, stronger units etc)
So the idea trigger would detect when a player builds (lets just say a spawning pool for now), if the game sees that this has created a 3x3 block of 9 spawning pools, the game will spawn a unit (lets say a zergling) in a given region (on my map its region 24, not particularly relevant). Then say the player builds around this 3x3 square of pools to make a 4x4 square of pools. Most probably a second trigger (or the same one I don't really know the limits on these triggers) will see that a 4x4 block has emerged and will correspondingly spawn 2 zerglings in the given region. Then they build a 5x5 block and it spawns 5 zerglings
I plan to duplicate the logic of this trigger to apply to many different buildings i.e warp gate to zealot, cyber core to stalker, hydra den to hydra so on and so forth.
If anything is unclear let me know and i'll be happy to explain what iv'e got in my head
IIRC, the origin of the coordinate system is in the lower left corner. A photon cannon for example has a footprint size of 2x2 in in-game units.
Well, this might be an overly simplistic solution. But if say you have a 9x9 room, I would just run a periodic trigger checking every second to see whats in the room and then when the correct number of buildings are in there, do something about it... IE a trigger like:
event: every 1 seconds of real time action: for each spawning pool in building room add 1 to variable spawning pool for each gateway in building room add 1 to variable gateway ect...
and lastly a long trigger of if statements to make everything happen.
If variable spawning pool = 9 then create 3 zerglings else If variable spawning pool = 3 variable gateway = 6 then create 1 zergling create 2 zealots
ect... just keep putting the next if statement inside the else statement of the previous one with the else of the final if statement clearing all the variables if it runs though all of them and no combination is found. Soo: else: set variable spawning pool = 0 set variable gateway = 0
Obviously this does not account for building placement, and nothing would happen until one of the if-then-else statements became true. The "complicated" part would be instead of just checking a single region covering the whole building room for whats inside, there would be 9 regions in the building room and checking them all independently. Then if region a b and c all had spawning pools then variable spawning pool = 3 ect... That just becomes more grunt work of if statements then complex though.
I have considered that sort of solution, effectively brute forcing every placement combination, however, this would require me to substantially limit where the players can play the buildings as it would be otherwise far too difficult to code in. I am also not optimistic as to the load it would put on the game if I was to have say 50 or so of those triggers going constantly
You could make things easier for you by defining some central core to build around, this way you only need to check around the cores. Checking every possible combination for a free space would probably be too performance-heavy, also if you build like one 5x5 construct, it would also be 9 3x3 constructs, so how would you determine, which one is actually registered?
A very good point, I was thinking that if it detects a 5x5 it stops all the 3x3 triggers? I like the idea of having a central core, but I still wouldnt know how to code triggers to detect units being built around the core
After a bit more fiddling round I think I may have solved this, I'll post up the code once its complete. Suggestions still welcome
OK so far this is just for the 3x3 setup, but I can run a seperate group of triggers for the 4x4 and 5x5 respectively
There are two global variables:
typedef Unit Group Room_3x3
typedef Region Room_3x3_Proxy_Check
Lair_Add
Events
Unit - ("Spawning Pool" from the Global data table) construction progress is Completed
Local Variables
Conditions
(Owner of (Triggering unit)) == 1
Actions
Trigger - Add (Actions) to the action queue
Actions
Variable - Set Room_3x3_Lair_Region = (Region((Center of Room_3x3), 3.5))
Unit Group - Add (Triggering progress unit) to Room_3x3
Trigger - Run Lair_Unit_Count_Check (Check Conditions, Don't Wait until it finishes)
Lair_Unit_Count_Check
Events
Local Variables
Conditions
(Number of Living units in Room_3x3) == 9
((Center of Room_3x3) is in Room_3x3_Lair_Region) == True
((Position of (Unit 1 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 2 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 3 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 4 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 5 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 6 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 7 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 8 from Room_3x3)) is in Room_3x3_Lair_Region) == True
((Position of (Unit 9 from Room_3x3)) is in Room_3x3_Lair_Region) == True
Actions
Unit - Create 1 Zergling for player 1 at (Center of Region 024) facing 270.0 degrees (Ignore Placement)
Unit Group - Remove all units from Room_3x3
Essentially every time a spawning Pool is created the first trigger:
-adds it to the unit group Room_3x3
-creates a region with radius just big enough to accomadate a 3x3 block of buildings around the centre of the units within the unit group, then assigns region to Room_3x3_Proxy_Check
-Passes control to the next trigger
The next trigger
-counts the units in the unit group, if there is 9
AND
-if each of the units within the group are located within the region
It
-Spawns a zergling
-empties the unit group
I have tested this trigger by making configurations that are slightly off a 3x3 square but it only works if the player constructs the exact 3x3. So that's one success. I'm out of town for the next few days but if anyone can see any potential bugs or flaws in my triggers please feel free to let me know.
I am also aware that if a player makes a mistake and builds outside of the 3x3 block that they will never be able to spawn a zergling again O.O. I plan to implement some sort of trigger whereby if a unit is created that is outside the bounds of the region or located a certain distance away from another pool or something, that it removes that unit from the unit group so the player can still finish off their room and have the only punishment be a wasted building.
Also sorry about how spaced out the stuff is I couldnt get the tabbing or shift+enter new lines to show up so I had to just make every line a new paragraph =(
Would it be easier to just limit where they can build in each "room"? or do players need to be able to build rooms anywhere they want to, on the map? For example, if you have a timer that continually counts down from say 5, and each time it hits 0 it checks each room for a configuration. If a configuration matches one that you've defined in a master list, then it spawns the unit associated with that configuration. That way, you only need one list of combo's and it checks each room for each combo every 5 seconds.
@playpong: Go
Yer but then Ive got like 100 of those triggers all running at the same time and putting unnecessary load on the game and that would also take ages to code.
I have another problem though...
I have realised that my event (for some bizzare reason) is triggering whenever anything at all is built, not just a spawning pool. At the moment I am using the:
Unit - "Spawning Pool" from the Global Data table construction progress is Completed
Event. But it seems upon some testing that no matter what I put as the string identifier (even like command centre or something stupid) whenever I build anything, it starts the trigger. Has anyone got a better way to make an event that triggers whenever a spawning pool is built?