• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Add-on to rebuilding structures

Status
Not open for further replies.
Level 24
Joined
Oct 12, 2008
Messages
1,783
Secondly, what if all the peasants are dead or there're not enough peasants to handle the situation? The reconstruction will also fail. Do i have to check this trigger periodically?

Thirdly, any other limitations to point out?

Pretty much that.
Periodic checks will be needed.

Other limitations include if the peasant gets killed or gets disabled by stun or something.
 
Level 14
Joined
Aug 30, 2004
Messages
909
This problem could get very complicated if more than one building can die at a time. I think I'd do something like this. First you'll need variables:

Builders = unit [array size 10]
//this is a unit array. You put your builders in here when they are given an order to build a structure. The number in the array corresponds to the spot and structure type (see below).

BuildSpots = point [array size 10]
//this is a point array. It stores the location of all new buildings that you have ordered.

BuildStructureType = unit-type [array size 10]
//this is a unit-type array. It stores the type of structure that you've ordered to be built.

CurrentBuilder = unit group
//this is a unit group that stores all peasants that are currently being ordered to build a structure

BuildCounter = integer
//this is a temporary integer variable

You'll need triggers for these situations:

1. Structure dies
When this happens, go through all 10 BuildUnits until you find an empty spot. For each integer A do... if BuildUnit[A] = no unit, then set BuildCounter = A. If you do that, BuildCounter will store a number from 1-10 that is empty. Then assign BuildUnit[BuildCounter] = random peasant not in CurrentBuilder. Then store BuildSpots = position of dying structure. Then store BuildStructureType = unit-type of dying unit.

2. Repeat trigger - periodic trigger (every .75 seconds or so)
For each Integer B do...if BuildUnit = no unit equal to false, then order BuildUnit to build BuildStructure at BuildSpots.

3. Peasant starts construction
Remove unit from CurrentBuilder. For each integer A do... if BuildUnit[A] = triggering unit, then set BuildUnit[A] = no unit.

That set up should do nicely, though there will be problems if a peasant is killed while building a building.
 
Level 4
Joined
Aug 7, 2010
Messages
77
An easy solution is to give the buildings the Reincarnation ability (modified slightly of course). Buildings can then rebuild themselves.

First of all, thanks for replying to this thread. +rep.

But i dun understand the reincarnation part. Wont it be weird when no peasants are there to build and the structure will re-spawn? I will try ur above method.

Edited*
All my units/structures are preset in the map.
I am working on this because recently i am trying out with AI editor. As for the editor, i've found out that the system of replacements of dying units is pretty well done. Like for example, footman is dead at spot (x,y) and rifleman is dead at spot(x2,y2), the barracks will automatically rebuild the fallen units and rally them at the same guarding spot by issuing default build orders at the AI editor tab. However, the system cannot handle rebuilding of structures at the same spot that had being destroyed, the peasant will just build at a random spot. Because of this, i am worried that the AI's structure will be cramped together and what if units are stucked in between structures? This will affect the attacking wave.
 
Level 14
Joined
Aug 30, 2004
Messages
909
The reincarnation ability will look a bit weird... a unit will essentially just spring back up. I used that in my BfT map to replace the guns on the Star Destroyer. But in a regular map you may not want to use that.

I know nothing about the AI editor, sorry.
 
Status
Not open for further replies.
Top