HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

GetAboutToBeTrainedUnit ()

08-30-2008, 10:15 AM#1
krambuhl
So I'm working on a training system where i can dynamically change the training time so an ability will give the player a 10 second chance to have instant training.

This is what have so far:

Trigger:
Training
Collapse Events
Unit - A unit Begins training a unit
Collapse Conditions
Triggering unit has buff War Time Equal to == True
Collapse Actions
Wait 1.00 seconds
Unit - Order (Triggering unit) to Cancel
Unit - Create 1 (Unit-type of (#######)) for (Triggering player) at (Position of (Triggering unit)) facing 0.00 degrees

where i have ######## i want to get the trained unit, except (trained Unit) gets the unit only if the training is finished. Is there a 'GetAboutToBeTrainedUnit ()' function that i am not aware of? If only in JASS im completely comfortable in that.

Thanks, Krambuhl
08-30-2008, 10:53 AM#2
DioD
There is only one way to do it...

Personal building for every unit.
08-30-2008, 11:41 AM#3
Tide-Arc Ephemera
There's a method but it's not the cleanest.

1. Give the building a spell book with the list of trainable units but DO NOT let it be able to train any
2. When it uses a training order, allow it to train a unit
3. Train that unit > If it's X then give money back
4. Disallow it from training that unit

I don't have World Editor with me at the moment, but I hope that helps. By the way, your current method encourages spam because if you cancel training, you get money back.
08-31-2008, 01:00 AM#4
aquilla
I would assume that the unit beginning the training is issued an order where the unit to trained would be its OrderId. Did you try this approach? If it is indeed so it would be fairly simple to catch the id

edit: it wouldn't be as simple to make it unexploitable
08-31-2008, 10:47 AM#5
krambuhl
Trigger:
Training
Collapse Events
Unit - A unit Begins training a unit
Collapse Conditions
((Triggering unit) has buff War Time ) Equal to (==) True
Collapse Actions
Unit - Order (Triggering unit) to Cancel
Unit - Create 1 (Trained unit-type) for Player 9 (Gray) at (Center of rect_in[110]) facing 0.00 degrees
Unit - Turn collision for (Last created unit) Off
Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - spawn_cost[(Integer((String((Trained unit-type)))))])

I figured a way to do this, the trained unit-type doesnt take into consideration whether the unit is canceled. And i took into concideration the gold cost of the unit by setting up a array with the index of the unitId like this:

Code:
    
     set udg_spawn_type[0] = 'h000'
    set udg_spawn_cost['h000'] = 5

Thanks for the help guys, and I hope this solution can help you.