HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Line Build

07-21-2008, 03:09 AM#1
Strilanc
I'm working on something to allow you to switch a builder to 'line mode' where if you order them to construct a building they build a line of that building to the point you ordered.

I've run into two issues.
- The 'constructed' events don't give the constructing unit
- Ordering the units ruins order queues (shift+order)

I want to get around both. With humans I use the 'repair' ability ending as the signal for construction ending, but the other races pose a bit of a problem. The only distinguishing feature of the 'building' builder is that it is (probably) nearest to the building and (probably) the only one ordered to make that building there. Is there any other way to detect building?

Ordering the units is a bit trickier. It will probably involve pausing/hiding the unit and using a replacement to do the building, but maybe there's a way to avoid that?
07-21-2008, 10:32 AM#2
Deaod
maybe you can trigger the building process completely.

create an array of units to be built.
then assign the builder to one of the buildings. Now run a high speed periodic timer to simulate the building process (native UnitSetConstructionProgress takes unit whichUnit, integer constructionPercentage returns nothing). When a building is finished constructing, proceed to the next building in the array.
07-21-2008, 06:57 PM#3
Strilanc
Interesting idea, but it would require knowing the build times of every building. I do not want to require that type of information.

Maybe instead of periodically increasing build % I will just periodically check if the builder is idle [instead of hidden/repairing], then order it to the next building. That should take care of the 'building finished' issue.

As for the 'don't ruin the player's order'... I'm still not sure what to do. Pausing and hiding the builder, and using a replacement building, might work but will look clunky and mess with control groups.
07-23-2008, 06:26 AM#4
ToukoAozaki
there's a trick to get the constructor for three races: Human, Orc, and Night Elf.

In case of human, basically what you have done is correct. Checking for repair order targeted to the structure being built is enough.

In case of other races, it is a bit tricky. The following instruction will help you get it:
1. Detect the construction event. From the event you can get the order id, which is identical to the unit id of structure being built. Find all units with the specified order. (just check their current order)
2. Start a 0-sec timer with a callback. (whether other ways would work is not confirmed)
3. At the callback, check each previously found units. What you should check is the unit's location and the current order. The unit's location is completely IDENTICAL to the structure, and the order should remain as the very unit id.

Edit: fixed typos