• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Automatic building construction

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Hello, Hive.

So I want to make structures automatically construct themselves, just like undead buildings do, but at the same time I want them to be built faster when the worker constructs aswell, just like human buildings do. This has been done in Castle Fight and I wonder how is it done. I based my structures on human buildings. The question is how do I make them auto-construct? Thanks in advance.

P.S: I believe this is Object Editor related. In case it's not, this thread can be moved to Triggers and Scripts.
 
Level 9
Joined
May 21, 2014
Messages
580
I guess you will have to trigger Undead-Style, since it's easier than how you'll trigger Human-Style building.

Since you based it off Human-Style, your best bet is to create a dummy unit which also has the same skill repair with your workers and order it to "right click" the currently constructing structure, so it seems like the structure is automatically building, yet your peasant can build it too for a faster rate.
 
Level 19
Joined
Jul 14, 2011
Messages
875
You could use:
  • Unit - Set Unit construction progress to 50%
and a timer but there isnt a 'Get Unit construction progress', I think.

A better way would be to create an invisible builder that builds the structure, then gets removed when it is finished.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
I guess you will have to trigger Undead-Style, since it's easier than how you'll trigger Human-Style building.

Since you based it off Human-Style, your best bet is to create a dummy unit which also has the same skill repair with your workers and order it to "right click" the currently constructing structure, so it seems like the structure is automatically building, yet your peasant can build it too for a faster rate.

The idea about a dummy worker is great, however I can have only 1 peasant repairing at a time. My main worker starts construction and the dummy attempts to go at it aswell, but it stops since only 1 worker seems to be able to repair. I decided to switch them (I take off the main worker from the construction and order the dummy to repair). That way the dummy starts, but the main worker can't go help.

This seems to have been encountered before: click
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
You could use:
  • Unit - Set Unit construction progress to 50%
and a timer but there isnt a 'Get Unit construction progress', I think.

A better way would be to create an invisible builder that builds the structure, then gets removed when it is finished.

Added to this, you could look at the building's hit points to determine construction progress. This breaks if the building takes damage - progress will be reverted to the health percentage.
 
Level 9
Joined
May 21, 2014
Messages
580
The idea about a dummy worker is great, however I can have only 1 peasant repairing at a time. My main worker starts construction and the dummy attempts to go at it aswell, but it stops since only 1 worker seems to be able to repair. I decided to switch them (I take off the main worker from the construction and order the dummy to repair). That way the dummy starts, but the main worker can't go help.

This seems to have been encountered before: click

Ah... Ah..... I encountered this before... I need to be reminded of what I did since it was 4 years ago...
Let me create some in the object editor.

One qualification is that the Race of Both the Structure and and Worker must be Human Race, and the Repair must be Human as well. And I mean not only by basing them from a Human structure, but also set the Race Stat to Human. That's just one. Ummm.... I'll just edit this post if I can still see something. (This is not fully tested though but the qualification worked for me.)

EDIT:
Second Qualification is the Dummy Repairer must not engage in Gold Cost and Lumber Cost. Else it won't actually repair the structure. If you still want costs though you need order the dummy unit to right click the constructing structure again once you have the right resources for repair costs.

EDIT 2:
Third Qualification is that the Dummy Unit must also have the constructing structure listed on Structures Built field so that the dummy unit and the actual builder can switch places of repairing or building. Take note these two are very different from each other when two units build a structure. What else..

EDIT 3:
Okay, right clicking the constructing structure as well as ordering the dummy to repair doesn't make the dummy unit repair the structure, but within the qualifications above, the peasants (actual and dummy) seems to be interchangeable.
 
Last edited:

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Changing the race seems to have made them able to construct together. However, the problem of the dummy unit not constructing is still there. It faces the structure but doesn't begin assisting construction unless manually ordered by me. The trigger doesn't seem to force it, it only makes the dummy face the structure. Here is the trigger:

[trigger=""]AutoConstruction
Events
Unit - A unit Begins construction
Conditions
Actions
Set Building_Point = (Position of (Triggering unit))
Unit - Create 1 Dummy Worker for (Owner of (Constructing structure)) at Building_Point facing Default building facing degrees
Unit - Order (Last created unit) to Right-Click (Constructing structure)
Unit - Add a 10.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation (udg_Building_Point)
[/trigger]

Notes:
-Both Workers are set to Human.
-Both Workers are exact copies of eachother.
-Workers can work together if it's me who orders them.
 
Level 9
Joined
May 21, 2014
Messages
580
Changing the race seems to have made them able to construct together. However, the problem of the dummy unit not constructing is still there. It faces the structure but doesn't begin assisting construction unless manually ordered by me. The trigger doesn't seem to force it, it only makes the dummy face the structure. Here is the trigger:

[trigger=""]AutoConstruction
Events
Unit - A unit Begins construction
Conditions
Actions
Set Building_Point = (Position of (Triggering unit))
Unit - Create 1 Dummy Worker for (Owner of (Constructing structure)) at Building_Point facing Default building facing degrees
Unit - Order (Last created unit) to Right-Click (Constructing structure)
Unit - Add a 10.00 second Generic expiration timer to (Last created unit)
Custom script: call RemoveLocation (udg_Building_Point)
[/trigger]

Notes:
-Both Workers are set to Human.
-Both Workers are exact copies of eachother.
-Workers can work together if it's me who orders them.

I was just going to edit my post. xD

I was gunna post that ordering them to repair the structure will not work since the order in the trigger will be issued first before the actual building of the actual unit. There needs to be a short interval before you can order them.

EDIT:

My theory was correct. This worked:

  • build halp
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Unit - Create 1 Peasant (Dummy) for Player 1 (Red) at (Position of (Constructing structure)) facing Default building facing degrees
      • Wait 0.05 seconds
      • Unit - Order (Last created unit) to Right-Click (Constructing structure)
But of course, edit the trigger because that trigger is messy XD
Edit 2: Even 0.01 Wait works.
 
Status
Not open for further replies.
Top