Instant unit training - one more time

Chjoodge

New Member
Reaction score
14
I need an instant unit training in my map. I came up with few methods and I found some more methods here on the forum which were *almost* instant, but I'd like to get rid event of that *almost*.

To summarize what I tried:

1) Build time = 0.
This does the same as having the building time of 1, just not showing the training bar progress right. The unit is still trained 1 second.

2) Using Units Sold instead of Units Trained.
I don't want to use this - my units should never run out of stock and I don't even want that little black stock info square to show on their button.

3) Ability.
I don't want to create an ability 'Train Unit X' which would create the unit, because the ability cannot easily handle stuff like player being out of gold, player using his max supply etc.

4) Trigger.
Event: Unit begins training.
Condition: ...
Action: Create 1 (Trained unit-type) at ... .

This works fine, but I am unable to stop the training building from finishing training the unit, which results in actually creating two units - one created from the trigger immediately and one created when the building finishes training the unit. Maybe if I would know how to cancel a training of a unit via a trigger, it would help.

Any ideas?
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
As long as you're sure that the building is selected by the player, you can force him to press the Escape key, thus canceling the entire build queue.
 

Silvenon

New Member
Reaction score
19
I don't know much about training units, but in the last method, can you maybe try with a dummy unit, so the dummy unit (which is invisible and have timed life) is created instead of that unit.
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
Try adding this trigger to the trigger above....

Event
Unit Enters Region (Playable map area or the whole map which ever u prefer)
Condition
Unit is Equal to trained unit type
Action
Remove Triggering Unit

Or......

Event
Unit begins training unit
Condition
Unit being trained is equal to (lets say) Footman
Action
Cancel training trained unit type
Create 1 trained unit type at.....

I dunno if the above works...Doesn't hurt to try eh?

Or you could try the Post above...Make the dummy have no model and Locust...so it doesn't show up on the minimap

Edit:This may have to be done in jass....
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
2.
The "1" can't be helped... but "stats - stock replenish interval" set to 0 works wonders on never running out of stock.

4.
Code:
Cancel Training
    Events
        Unit - A unit Begins training a unit
    Conditions
        (Trained unit-type) Equal to Footman
    Actions
        Custom script:   call IssueImmediateOrderById(GetTriggerUnit(), 851976)

However, you'll have to deal with Gold / Lumber cost yourself, as the cancel adds them back.
Or, there's probably some "refund" or so gameplay constant... then again, it would apply to all refunds (just guessing here, never looked for it).
 

BANANAMAN

Resident Star Battle Expert.
Reaction score
150
He could always put a trigger that subtracts the Resources refunded...
 

Chjoodge

New Member
Reaction score
14
Code:
Custom script:   call IssueImmediateOrderById(GetTriggerUnit(), 851976)

Thanks everyone. Forcing Escape didn't help, but this AceHart's line did. Hurraaay :D

I had the refund already handled by setting Cancel Refund Factor - Unit Training in Gameplay Constants to 0.

A simple map where I tried this (and where the thing is actually working now) is attached to this post.

Thanks once again.
 

Attachments

  • InstantTrain.w3x
    12.1 KB · Views: 96
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top