• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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

Status
Not open for further replies.
Level 21
Joined
Mar 2, 2010
Messages
3,069
i am working on a custom training system where units trsin into other units by targetting buidings with channel. the triggers for each version of the ability is more or less the same but only one of them works. i have set different base order ids for each. please help me out.
 

Attachments

  • training system.w3x
    20.1 KB · Views: 39
Level 25
Joined
Sep 26, 2009
Messages
2,390
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.
 
Level 25
Joined
Sep 26, 2009
Messages
2,390
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.
 
Level 21
Joined
Dec 4, 2007
Messages
1,482
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:
Level 8
Joined
Jun 13, 2012
Messages
336
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
 
Level 21
Joined
Dec 4, 2007
Messages
1,482
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.
 
Level 8
Joined
Jun 13, 2012
Messages
336
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.
Top