training a unit with condition

Whisp_Rush

Active Member
Reaction score
0
Hi!
I'd like to do the following: If a building has X item (I added the inventory ability to the building, so it can have items) than train Y unit...
I wanted to do it like this:

Trigger:
  • pig make Red
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Young Pig
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Wheat Seeds) Not equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
          • Game - Display to Player Group - Player 1 (Red) the text: You need Wheat Seed...
        • Else - Actions
          • Do nothing


this is not good, because the event is a Unit begins training a unit... so the trigger starts when the building is already training the unit, so the trigger can't spot it... and I didn't find anything wich could interrupt a unit training.... so please help me if u can
thx
 

evilwolf

Member
Reaction score
11
You could replace triggering unit with another one that is exactly like it, I think it should stop the training.
 

hopy

Active Member
Reaction score
64
(Unit-type of (Trained unit)) Equal to Young Pig

That's the problem of the trigger, 'Trained Unit' should only work for 'Unit - A unit Finishes training a unit' events. I was kind of hoping 'Constructing Structure' would fit, but it doesn't either.

Also, this part wont work either from what I've seen during my past testing:
Unit - Order (Triggering unit) to Stop
The construction wont be cancled.

And another small detail:
Do nothing
Doesn't do anything (O'rly?), so it's no use placing it. It only exists for the 'If / Then / Else' action (without the multiple functions).

--
Now ofcourse if I cant find anything an option would be to make the building sell items rather then training units, and triggering the whole production process using timers and everything. The disadvantage of this is that you'll be unable to see a construction bar for the unit.
--

=====================EDIT=====================
Alright... I'm bloody brilliant! :D :D :D
I've made a trigger that worked perfectly, it only has one disadvantage... it doesn't work without a wait. I don't know why it doesn't work without one, but it's a wait of 0.01 seconds.
Trigger:
  • Stop training
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(Footman))
    • Actions
      • Wait 0.01 seconds
      • Game - Force (Owner of (Triggering unit)) to press Escape/Cancel

This will not work if:
1. The player deselects the building within 0.01 seconds of starting to build the unit.
2. The player issuses a new order within 0.01 seconds of starting to build the unit.
3. Your PC explodes.

I'm not sure, but this really is the only way I could find to cancel unit production without having to replace the Barracks every time... <,<
I've been able to make it bug by pressing the Hotkey for Footman and at the same time selecting a different unit.
=====================/EDIT====================
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
I found something on TheHive about how the issued order is actually the unit-type of the unit trained, in this case "young pig". You might try something like that in a trigger with A unit is issued an order with no target events.
 

evilwolf

Member
Reaction score
11
That's the problem of the trigger, 'Trained Unit' should only work for 'Unit - A unit Finishes training a unit' events. I was kind of hoping 'Constructing Structure' would fit, but it doesn't either.

Also, this part wont work either from what I've seen during my past testing:

The construction wont be cancled.

And another small detail:

Doesn't do anything (O'rly?), so it's no use placing it. It only exists for the 'If / Then / Else' action (without the multiple functions).

--
Now ofcourse if I cant find anything an option would be to make the building sell items rather then training units, and triggering the whole production process using timers and everything. The disadvantage of this is that you'll be unable to see a construction bar for the unit.
--

=====================EDIT=====================
Alright... I'm bloody brilliant! :D :D :D
I've made a trigger that worked perfectly, it only has one disadvantage... it doesn't work without a wait. I don't know why it doesn't work without one, but it's a wait of 0.01 seconds.
Trigger:
  • Stop training
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(Footman))
    • Actions
      • Wait 0.01 seconds
      • Game - Force (Owner of (Triggering unit)) to press Escape/Cancel

This will not work if:
1. The player deselects the building within 0.01 seconds of starting to build the unit.
2. The player issuses a new order within 0.01 seconds of starting to build the unit.
3. Your PC explodes.

I'm not sure, but this really is the only way I could find to cancel unit production without having to replace the Barracks every time... <,<
I've been able to make it bug by pressing the Hotkey for Footman and at the same time selecting a different unit.
=====================/EDIT====================
Cool, never thought of that
But you could improve it by forcing the player to select the building if he selects something else...
"This will not work if:
3. Your PC explodes."
What makes you think Osama Bin Laden will blow up your computer...
 

hopy

Active Member
Reaction score
64
Cool, never thought of that
But you could improve it by forcing the player to select the building if he selects something else...
I've tried doing that, but it didn't work. I've placed the forced selection on multiple places in the trigger but though the selection part did work, it did select the building again afther de-selecting, the cancel part wouldn't trigger.

"This will not work if:
3. Your PC explodes."
What makes you think Osama Bin Laden will blow up your computer...
True, that guy always messes up our Warcraft III maps... evil bastard... D:
 
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