Hello mapsters!
I am currently working on a remake of the good old strategy game Commander Z (Bitmap Brothers), which was an awesome gaming experience. I want to recreate that feeling in SC2. The main principle in the game was to capture sectors which contained unit production facilities.
Now i want to trigger following event: If a player captures a flag (atm a xel´naga watch tower) i want to change the owner of the neutral production facilities (barracks, factory, starports), which are in the same sector as the flag, to the triggering player. At first I started with:
If you want to dynamically change it, use array instead ( which is good for an engine that can be ported to any other terrain) Like if Unit in range of Tower[x], change owner of building at region[x]. If you want all production building, use action like pick each unit in unit group and do : Change owner. Your unit group would be "Unit in region matching condition" and so on
Edit: You can use multiple events in one single trigger. Triggering unit will always refer to the one activated its event
Note: This function iterates through all regions of the entire map; will be faster if you store all regions in an array; however, this would require the map makers who use your code to change exactly this array...
I even have a mechanism for sniping and capturing vehicles, but thats far from perfect... :>
Another issue:
I used a bunch of UnitGroup Actions, but these are really slow, you might encounter performance issues depending on how many triggers use them.
First of all thank you! You put really much effort into this. I tried to recreate what you posted, but atm I think i am not able to fully understand custom functions.
So I tried to find a workaround and I came to this solution:
I use arrrays for my Production Facilities [unit group] and my Sectors [region]. I set the integer of the Sector array and the Production Facility array to the same number.
The only problem I have: when i start capturing in region 1 the wrong buildings are picked.
The problem is: EventUnit() is the unit that enters the circle around your Mengsk Statue, not the statue itself.
I changed your map:
3 Arrays: Flags/CapturePoints, Regions, Structures to be converted as UnitGroup array; All have the same length. If you have an index, you know exactly which unit to change.
Note: The Index directly correlates in these arrays; Region 1, the capture point in Region 1, and the UnitGroup of Structures have index 0 in their array, and so on
To get this index i wrote a function that loops through all CapturePoints and returns the closest one.
UnitGetNearestFlagIndexOptions:FunctionReturnType:IntegerParametersflag=NoUnit<Unit>GrammarText:UnitGetNearestFlagIndex(flag)HintText:(None)CustomScriptCodeLocalVariablesretVal=0<Integer>loop_end=(numRegions-1)<Integer>i=0<Integer>ActionsGeneral-Foreachintegerifrom1toloop_endwithincrement1,do(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Distancebetween(Positionofflag)and(Positionofflags[i])) <= (Distance between (Position of flag) and (Position of flags[retVal]))
Then
Variable - Set retVal = i
Else
General - Return retVal
ps: The parameter "flag" is misleading, its not the flag, its the event unit...that one which enters the region
Wow thx! I´ve just checked my map again and I´ve found the problem. The Starport and the Factory where placed in the wrong regions (or in the wrong Production Building array - point of view) . I also did some minor changes in the triggers. Now it works perfectly.
But I definitively going to use your functions for my map.
Hello mapsters! I am currently working on a remake of the good old strategy game Commander Z (Bitmap Brothers), which was an awesome gaming experience. I want to recreate that feeling in SC2. The main principle in the game was to capture sectors which contained unit production facilities.
Now i want to trigger following event: If a player captures a flag (atm a xel´naga watch tower) i want to change the owner of the neutral production facilities (barracks, factory, starports), which are in the same sector as the flag, to the triggering player. At first I started with:
With this method I had to create one trigger for each flag and it doesn´t allow me to dynamicly change production building
@petrov1: Go
If you want to dynamically change it, use array instead ( which is good for an engine that can be ported to any other terrain) Like if Unit in range of Tower[x], change owner of building at region[x]. If you want all production building, use action like pick each unit in unit group and do : Change owner. Your unit group would be "Unit in region matching condition" and so on
Edit: You can use multiple events in one single trigger. Triggering unit will always refer to the one activated its event
Dear god that game was awesome.
You should start by changing (Triggering player) to (Owner of Unit (Triggering Unit)).
Not sure if that fixes it entirely though!
@progammer: Go
Porting the engine to other maps is exactly what i want. Thx for pointing me in the right direction!
@Eiviyn: Go
We all loved it :)
@petrov1: Go actually I already played around with exact the same game type in mind.
Sorry for the wall of text, i miss some kind of spoiler tag Maybe you can use some of these scripts:
I even have a mechanism for sniping and capturing vehicles, but thats far from perfect... :>
Another issue: I used a bunch of UnitGroup Actions, but these are really slow, you might encounter performance issues depending on how many triggers use them.
@Naim2k10: Go
First of all thank you! You put really much effort into this. I tried to recreate what you posted, but atm I think i am not able to fully understand custom functions.
So I tried to find a workaround and I came to this solution:
I use arrrays for my Production Facilities [unit group] and my Sectors [region]. I set the integer of the Sector array and the Production Facility array to the same number.
The only problem I have: when i start capturing in region 1 the wrong buildings are picked.
The problem is: EventUnit() is the unit that enters the circle around your Mengsk Statue, not the statue itself.
I changed your map: 3 Arrays: Flags/CapturePoints, Regions, Structures to be converted as UnitGroup array; All have the same length. If you have an index, you know exactly which unit to change. Note: The Index directly correlates in these arrays; Region 1, the capture point in Region 1, and the UnitGroup of Structures have index 0 in their array, and so on
To get this index i wrote a function that loops through all CapturePoints and returns the closest one.
ps: The parameter "flag" is misleading, its not the flag, its the event unit...that one which enters the region
@Naim2k10: Go
Wow thx! I´ve just checked my map again and I´ve found the problem. The Starport and the Factory where placed in the wrong regions (or in the wrong Production Building array - point of view) . I also did some minor changes in the triggers. Now it works perfectly.
But I definitively going to use your functions for my map.