• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Auto Training Units Problem

Status
Not open for further replies.
Level 11
Joined
May 7, 2008
Messages
321
So I'm having a bit of a difficulty sorting this out and I will try to explain it in easiest manner possible.

So I have a building that can train units (soldiers, knights) and cast abilities such as Upgrade Troops (which is basically an ability based on Berserk to allow me to immediately replace existing units with better ones) as well as having the ability to upgrade Building 1 into Building 2, etc.

Here's how Auto Training ability works in my map:

1) You press the button ''Activate Auto Train Troops'' and it activates the ability based on Mana Shield (trigger below):

  • Auto Train ON
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(manashieldon))
    • Actions
      • -------- --------
      • Set VariableSet IsAutoTraining[(Custom value of (Triggering unit))] = True
      • -------- --------
      • Set VariableSet TempPG = (Player group((Owner of (Triggering unit))))
      • -------- --------
      • Game - Display to TempPG for 3.00 seconds the text: (You have |cff80ff80activated|r the auto training function for + (Name of (Triggering unit)))
      • -------- --------
      • Custom script: call DestroyForce (udg_TempPG)

This forces the building to keep training units after you've clicked on let's say Soldier and it won't stop until you deactivate it.


2) To deactivate the spell - ability you can order it via ''Deactivate Auto Train Troops'' which is also the same ability (Mana Shield), example below;

  • Auto Train OFF
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(manashieldoff))
    • Actions
      • Set VariableSet IsAutoTraining[(Custom value of (Triggering unit))] = False
      • -------- --------
      • Set VariableSet TempPG = (Player group((Owner of (Triggering unit))))
      • -------- --------
      • Game - Display to TempPG for 3.00 seconds the text: (You have |cffff0000deactivated|r the auto training function for + (Name of (Triggering unit)))
      • -------- --------
      • Custom script: call DestroyForce (udg_TempPG)


3) And finally - the auto upgrade trigger;


  • Auto Train
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • IsAutoTraining[(Custom value of (Triggering unit))] Equal to True
    • Actions
      • -------- Order --------
      • Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
      • -------- --------


Everything works well except for the fact that after ''Auto Train'' trigger is activated, the triggering building blanks out all of the upgrades (as in makes them unavailable) since I think that the triggering building still thinks it is somehow training units.


Also tried using example below, it does nothing.

  • Player - Make Surge Tower |cffff8080IV 4 Available for training/construction by Player 1 (Red)

I tried using ''order triggering unit to stop or hold'' and it does nothing.


PS - I'm attaching a small map in case anyone wonders what exactly is the problem OR if you want to see it for yourself!

Any help is appreciated!
 

Attachments

  • Bug.w3m
    22.6 KB · Views: 15
Last edited by a moderator:
Level 21
Joined
Dec 4, 2007
Messages
1,476
Had to dig into some old maps of mine and found the solution:

  • Auto Train Process
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • IsAutoTraining[(Custom value of (Triggering unit))] Equal to True
    • Actions
      • Unit - Remove Auto Train Units from (Triggering unit)
      • Wait 0.00 seconds
      • Unit - Add Auto Train Units to (Triggering unit)
      • Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
I made this a bit different back then:
  • AutoUnitTrainON
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to #Auto Train
    • Actions
      • Set VariableSet temp_playergroup = (All players matching ((Matching player) Not equal to (Owner of (Triggering unit))).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of #Auto Train (State) for (Triggering unit)) Equal to 1
        • Then - Actions
          • Unit - Set level of #Auto Train (State) for (Triggering unit) to 2
          • Floating Text - Create floating text that reads Auto Training Active above (Triggering unit) with Z offset 0.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
        • Else - Actions
          • Unit - Set level of #Auto Train (State) for (Triggering unit) to 1
          • Floating Text - Create floating text that reads Auto Training Inact... above (Triggering unit) with Z offset 0.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Set the velocity of (Last created floating text) to 48.00 towards 90.00 degrees
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
      • Floating Text - Hide (Last created floating text) for temp_playergroup
      • Custom script: call DestroyForce(udg_temp_playergroup)
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,495
I just PMed him the same fix about 5 minutes ago... Weird!

Anyway, adding onto what A]mun said. To permanently fix the disabled ability issue you can do this:
  • Auto Train Fix
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • IsAbilityEnabled[(Custom value of (Triggering unit))] Equal to False
    • Actions
      • Unit - For (Triggering unit), Ability Auto Train Units , Disable ability: False, Hide UI: False
      • Set VariableSet IsAbilityEnabled[(Custom value of (Triggering unit))] = True
And then all you need is the Wait!
  • Auto Train Process
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • IsAutoTraining[(Custom value of (Triggering unit))] Equal to True
    • Actions
      • Wait 0.00 seconds
      • Unit - Order (Triggering unit) to train/upgrade to a (Unit-type of (Trained unit))
Edit: Apparently the Wait removes the need for the Auto Train Fix trigger since the ability can still be used while training. I was under the impression that a building couldn't use abilities while training and this fix was needed to change that.
 
Last edited:
Status
Not open for further replies.
Top