• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Solved] i have found a bug in a custom training system that i can not figure out

Status
Not open for further replies.
For "Unit stops casting an ability" event there is no "Target unit of ability being cast". Since "Target of ability being cast" returns null, the condition fails and your unit is not replaced.
Change the event to "Unit starts an effect of an ability" and you will see it works just fine.
 
Unit starts casting an ability: If targeted unit == any of the specified units you want, index the unit into unit array, under same index number index the unit-type into which the unit is supposed to.
Unit stops casting an ability: Find the unit in the unit array and change it into unit-type you saved under same index.

Look at the pseudo-code
Code:
Events
    Unit starts casting
Conditions
   Ability = Basic train ability
Actions
   If - Conditions
      Target = barracks or ..
   Actions
      Set Index = Index + 1
      Set TrainingUnit[Index] = (Triggering unit)
      Set NewUnit[Index] = Grunt //determine this your own way into which he should morph)


/////
Events
   Unit stops casting
Conditions
   Or - Conditions
      Ability = Basic train ability
      Ability = Improved train ability
      Ability = Best train ability
Actions
   For each loop_int from 1 to Index
      Loop
         If - Conditions
            (triggering unit) Equals to TrainingUnit[loop_var]
         Actions
            Change TrainingUnit[loop_var] into NewUnit[loop_var]
            ...deindex here ...

The second pseudo-trigger can take care of all your training units, since he just checks if the caster is in the TrainingUnit array and just changes it to the unit-type you set in first trigger.

Also I would change the event from "Unit stops casting an ability" to "Unit finishes casting an ability" - difference is that the first one fires when your unit is interrupted. For example instead of 30 second "training", if your unit got stunned after 2 seconds, he would change immediately.
 
Here look into my edits, i think it all works like you would want it.

Nevermind, the uploading of files doesn't work...
The following error occurred
The uploaded file is empty.
training system-edit.w3x


Well then have a look at the triggers (where did the trigger editor format go in this forum?):
  • BasicTrainingInit
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to (==) basic unit training
        • Then - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Multiple ConditionsOr - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Great Hall
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Barracks
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: Training started!
            • Else - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: Wrong building!
              • Wait 1.00 seconds
              • Unit - Order (Triggering unit) to Stop
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to (==) improved unit training
            • Then - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Multiple ConditionsOr - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Target unit of ability being cast)) Equal to (==) Stronghold
                      • (Unit-type of (Target unit of ability being cast)) Equal to (==) Barracks
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: Training started!
                • Else - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: Wrong building!
                  • Wait 1.00 seconds
                  • Unit - Order (Triggering unit) to Stop
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability being cast) Equal to (==) Advanced unit training
                • Then - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Multiple ConditionsOr - Any (Conditions) are true
                        • Conditions
                          • (Unit-type of (Target unit of ability being cast)) Equal to (==) Fortress
                          • (Unit-type of (Target unit of ability being cast)) Equal to (==) Barracks
                    • Then - Actions
                      • Game - Display to (Player group((Owner of (Triggering unit)))) the text: Training started!
                    • Else - Actions
                      • Game - Display to (Player group((Owner of (Triggering unit)))) the text: Wrong building!
                      • Wait 1.00 seconds
                      • Unit - Order (Triggering unit) to Stop
                • Else - Actions
  • BasicTrainingFin
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to (==) basic unit training
        • Then - Actions
          • Unit - Replace (Triggering unit) with a Grunt using The old unit's relative life and mana
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to (==) improved unit training
            • Then - Actions
              • Unit - Replace (Triggering unit) with a Troll Headhunter using The old unit's relative life and mana
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Ability being cast) Equal to (==) Advanced unit training
                • Then - Actions
                  • Unit - Replace (Triggering unit) with a Raider using The old unit's relative life and mana
                • Else - Actions

You can also use an indexing system like Nichilus wrote. This would be recommended if you plan on using a multitude of units.

edit: thanks neven1
edit2: i didn't check for leaks
 
Last edited:
Here look into my edits, i think it all works like you would want it.

Nevermind, the uploading of files doesn't work...
The following error occurred
The uploaded file is empty.
training system-edit.w3x

Well then have a look at the triggers (where did the trigger editor format go in this forum?):
BasicTrainingInit
Events
Unit - A unit Begins channeling an ability
Conditions
Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) basic unit training
Then - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Unit-type of (Target unit of ability being cast)) Equal to (==) Great Hall
(Unit-type of (Target unit of ability being cast)) Equal to (==) Barracks
Then - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: Training started!
Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: Wrong building!
Wait 1.00 seconds
Unit - Pause (Triggering unit)
Unit - Unpause (Triggering unit)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) improved unit training
Then - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Unit-type of (Target unit of ability being cast)) Equal to (==) Stronghold
(Unit-type of (Target unit of ability being cast)) Equal to (==) Barracks
Then - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: Training started!
Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: Wrong building!
Wait 1.00 seconds
Unit - Pause (Triggering unit)
Unit - Unpause (Triggering unit)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) Advanced unit training
Then - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Unit-type of (Target unit of ability being cast)) Equal to (==) Fortress
(Unit-type of (Target unit of ability being cast)) Equal to (==) Barracks
Then - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: Training started!
Else - Actions
Game - Display to (Player group((Owner of (Triggering unit)))) the text: Wrong building!
Wait 1.00 seconds
Unit - Pause (Triggering unit)
Unit - Unpause (Triggering unit)
Else - Actions
BasicTrainingFin
Events
Unit - A unit Finishes casting an ability
Conditions
Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) basic unit training
Then - Actions
Unit - Replace (Triggering unit) with a Grunt using The old unit's relative life and mana
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) improved unit training
Then - Actions
Unit - Replace (Triggering unit) with a Troll Headhunter using The old unit's relative life and mana
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) Advanced unit training
Then - Actions
Unit - Replace (Triggering unit) with a Raider using The old unit's relative life and mana
Else - Actions

You just have to nest these triggers. You can also use an indexing system like Nichilus wrote. This would be recommended if you plan on using a multitude of units.

use trigger and /trigger in [] tags to display GUI code
 
I thought so too, but then somehow the "A unit Finishes casting an ability" event fires, or maybe i've overseen another trigger interfering.

Yeah of course you can simply stop the unit, i got too used to workarounds...

Just the wait is necessary.
 
I thought so too, but then somehow the "A unit Finishes casting an ability" event fires, or maybe i've overseen another trigger interfering.

Yeah of course you can simply stop the unit, i got too used to workarounds...

Just the wait is necessary.
oh you read my post? xD i thought i made a mistake so i deleted it lol ;p

yeah i know the feel that makes you make unnecessary complicated triggers ;D
 
Status
Not open for further replies.
Back
Top