Hm... Workers make troops from corpses? Do you mean, kind of like "Raise Dead"? But using the "Build Structure ability"? That can't be done at my knowledge, but I can give you a solution that's close to it.
Create an ability based on "Raise Dead" for your workers. This will fill the 'need corpse to train' condition. Empty its data slots, leave nothing except the casting requirements (the unit will need a corpse). I'll name it "Animate". Just have a tooltip that says, 'Creates a unit from a corpse. Each unit requires resources to be trained.'
Then the triggers come in.
Note Create a variable before, as a Dialog Box (named Dialog in the variables menu). Then make one for each type of units, of type Dialog Button. One variable of type "Point" (remember this one, it's needed!). Finally, one for the player owner of the building unit and one Boolean for a True/False function (create one Boolean for each type of unit).
Code:
Events -
A unit (Initializes the effect of an ability)
Conditions -
Ability being cast = (Animate)
*We do not need to specify the type of unit, as only the workers will have the ability.
Actions -
Set (Animator) = (Owner of casting unit)
*Here is the "Point" variable.
Set (AnimateTarget) = (Target point of ability being cast)
Dialog - Clear (DialogBox)
*As to make sure we don't have impurities in our dialog.
Dialog - Create Dialog Button for (DialogBox) labelled (Footman)
*Create Dialog Buttons for every unit, and label them as you call your units.
Dialog - Change title of (DialogBox) to (Animate units:)
Dialog - Show (DialogBox) for (Owner of casting unit)
This creates the Dialog Box. Now, the player choose the unit to train.
Code:
Events -
A Dialog Button is clicked for (DialogBox)
Conditions -
Clicked Dialog Button = (FootmanButton)
Actions -
*Here is our Boolean.
Set (FootmanTrain) = True
If (Animator)'s current gold is (Inferior to 135), then (Game - Display to (Animator) the text: (Insufficient resources.)), else (Do nothing).
If (Animator)'s current gold is (Superior or equal to 135), then (Trigger - Run (TrainingMultiboard) <gen>, else (Do nothing).
*If the gold required is equal to 135.
*I'm introducing a new trigger here, TrainingMultiboard. We'll create it shortly.
There goes the conditions. The last action will run a multiboard that will show the training progress.
<Catches breath back, saving text.>
[I'd like to thank Nemesis[DK] for his helpful
Multiboard Tutorial, and Sansui for translating it.]
Have a new trigger, name it TrainingMultiboard (as we named it previously). Put it as off at the game start.
Create variables (again).
-one named
TrainMultiboard, of type Multiboard -.-;
-one named
TrainBar, of type Real, for each unit.
-the last named
TrainProgress, of type Real with array.
All with 0 (default) initial value.
This is a very long and complicated trigger, pay attention, I may have done mistakes. If you want, I'll create a map including the triggers.
Code:
Events -
*None, as the previous trigger will launch the trigger.
Conditions -
*None either.
Actions -
*Creating the Multiboard.
Multiboard - Create a multiboard with (20) colums and (2) rows, titled (TrainingMultiboard)
Set (TrainMultiboard) = (Last created multiboard)
*Changing display style.
Multiboard - Set the display style for (TrainMultiboard) item in column 0, row 1 to (Show text) and (Hide icons)
Multiboard - Set the display Style for (TrainMultiboard) item in column 0, row 2 to (Hide text) and (Show icons)
*Changing the width of the items.
Multiboard - Set the width for (TrainMultiboard) item in column 0, row 1 to 0.50% of the total screen width
Multiboard - Set the width for (TrainMultiboard) item in column 0, row 2 to 0.50% of the total screen width
*Changing the display icon. You'll have created two display icons types: one which states current progress, for example a yellow square, and another for the remaining training time, maybe a lighter yellow square. Then you convert them to BLP files using the many converters that are here in the [url=http://www.wc3sear.ch/index.php?p=Tools&sid=80fc423b85cd621d77151d5e7e993c0d]Tools Section[/url].
Set the icon for (TrainMultiboard) item in column 0, row 2 to (*\TrainProgress.blp)
*Changing the text display.
Multiboard - Set the width for (TrainMultiboard) item in column 1, row 1 to (6.00%) of the total screen width
Multiboard - Set the width for (TrainMultiboard) item in column 2, row 1 to (4.00%) of the total screen width
Multiboard - Set the text for (TrainMultiboard) item in column 1, row 1 to (Training Progress: [Footman])
*Note: Here, you need to make an If/Then/Else action for each type of unit. Yup!
If (FootmanTrain) = True, then (Multiboard - Set the text for (TrainMultiboard) item in column 2, row 1 to (String((Integer([TrainBarFootman]) + /) + (35)), else (Do nothing).
*If training time is equal to 35.
*Again, same function for every unit.
If (FootmanTrain) = True, then (Trigger - Run (TrainNumberFootman) <gen>, else (Do nothing)
Multiboard - Show (TrainMultiboard).
<Gasp! Save text before it's erased!> <Whew...>
Are you still there?... There's still the biggest part to come...
Multiboard update (the progress will change the bar's width)!
In the previous (huge) trigger, I said we would run a
TrainNumberFootman trigger. This will set the string of the multiboard. Then make that trigger now, it's short (promised)! Put to to "Off at game start".
Code:
Events -
Time - Every (1.00) seconds of game time
Conditions -
*None, as the multiboard trigger runs this one only if the Footman is trained. If another unit is trained, then create another trigger for it with the required training time. Are you still following?
Actions -
Set (TrainBarFootman) = (TrainBarFootman) + (1.00)
*Let's add an effect!
Special effect - Create a special effect at (AnimateTarget) using (*Your choice.)
Yet another trigger to close the previous one and create the Footman we have waited so much for it.
Code:
Events -
Game - (TrainBarFootman) becomes (Equal to) 35
Conditions -
*None!
Actions -
Trigger - Turn (off) (TrainNumberFootman)
Unit - Create (1) unit of type (Footman) for (Animator) at (AnimateTarget) facing (*We'll say (Random Angle))
Setting the progress bar, now.
Code:
Events -
Time - Every 0.10 seconds of game time
Conditions -
*None.
Actions -
*Icons.
For each integer A from (1) to (20), do actions:
Multiboard - Set the icon for (TrainMultiboard) item in column (Integer A), row 2 to (*Texture you chose previously.)
*Progress.
Set (TrainProgress[1]) = ((35) / (20))
Set (TrainProgress[2]) = 0.00
For each integer A from (1) to (20), do actions:
Set (TrainProgress[2]) = ((TrainProgress[2]) + (TrainProgress[1]))
If (All conditions are True), then (Do Actions), else (Do Actions):
If (TrainBarFootman) is (Superior or equal) to (TrainProgress[2])
Then Multiboard - Set the icon for (TrainMultiboard) item in column (Integer A), row 2 to (*Lighter texture you chose.)
Else Multiboard - Set the icon for (TrainMultiboard) item in column (Integer A), row 2 to (*Texture you chose previously.)
Multiboard - Set the text for (TrainMultiboard) item in column 2, row 1 to (String((Integer([TrainBarFootman]) + /) + (35))
Whew! Not that bad, wasn't it? I think there's all... I hope!