• 🏆 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!

[Trigger] A special creating unit system

Status
Not open for further replies.
Level 4
Joined
Apr 22, 2020
Messages
53
I'm making a special system to create unit.

You need mana, golem and specific structure to create it.

For example :

You use a golem to build a structure, a Cottage. Then, you put another golem next to it to turn him into a "metapod" and after 10 secondes, you get a Druid.

I made those triggers :



As you see, I use specific area.
I would like to make several spots for structures. With my system, I have to copy and paste all the triggers (there is a lot, because there are different structures and units linked to them) for each new area/spot I create.

Is it possible to set a trigger per unit-type who can make local effect (create, for example, a druid for a player) for everyone AND everywhere ?
 
Last edited:
Level 4
Joined
Apr 22, 2020
Messages
53
Ok I was working on this. Now I understand more indexing, I try to use it there.
I don't know how to make a duration and then an action. (Not action -duration- action)

I did this... but it's not working, I don't understand my mistake... Do I have to set a variable on the loop for the metapod ? If yes, which one ?

  • Barrack Warrior
    • Evenements
      • Unit - A unit Initie l'effet d'une competence
    • Conditions
      • ((Owner of (Triggering unit)) Or actuel) Superieur ou egal à 20
      • ((Owner of (Triggering unit)) Nourriture utilisee) Inferieur ou egal à 99
      • (Ability being cast) Egal à Create Warrior
    • Actions
      • Joueur - Add -20 to (Owner of (Triggering unit)) Or actuel
      • Set Warrior_Index = (Warrior_Index + 1)
      • Set Warrior_Owner[Warrior_Index] = (Owner of (Triggering unit))
      • Set Warrior_Counter[Warrior_Index] = 0.00
      • Set Warrior_Point[Warrior_Index] = (Position of (Triggering unit))
      • Unit - Create 1 Metapod (Warrior) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Orientation bâtiment par défaut degrees
      • Unit - Add a 10.10 second Générique expiration timer to (Last created unit)
      • Set Warrior_Metapod[Warrior_Index] = (Last created unit)
      • Effet special - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
      • Effet special - Destroy (Last created special effect)
      • Unit - Remove (Triggering unit) from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Warrior_Index Egal à 1
        • Alors - Actions
          • Trigger - Turn on Barrack Warrior Loop <gen>
        • Sinon - Actions
  • Barrack Warrior Loop
    • Evenements
      • Temps - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Warrior_LoopInteger) from 1 to Warrior_Index, do (Actions)
        • Boucle - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Warrior_Metapod[Warrior_LoopInteger] is alive) Egal à TRUE
            • Alors - Actions
              • Set Warrior_Counter[Warrior_LoopInteger] = (Warrior_Counter[Warrior_LoopInteger] + 10.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Counter[Warrior_LoopInteger] Superieur ou egal à 10.00
                • Alors - Actions
                  • Unit - Create 1 Warrior for Warrior_Owner[Warrior_LoopInteger] at Warrior_Point[Warrior_LoopInteger] facing Orientation bâtiment par défaut degrees
                  • Effet special - Create a special effect at Warrior_Point[Warrior_LoopInteger] using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
                  • Effet special - Destroy (Last created special effect)
                  • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
                  • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
                  • Set Warrior_Point[Warrior_LoopInteger] = Warrior_Point[Warrior_Index]
                  • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
                  • Set Warrior_Index = (Warrior_Index - 1)
                  • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • Si - Conditions
                      • Warrior_Index Egal à 0
                    • Alors - Actions
                      • Trigger - Turn off (This trigger)
                    • Sinon - Actions
                • Sinon - Actions
            • Sinon - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Edit:
Touching on your issue with Golems and Regions/different Unit-Types, I'd recommend using a system other than Regions entirely. Instead, you can use an Ability to register when a Golem interacts with a Cottage.

Looking at your current trigger, I think an ability with a 10.00 second Casting Time would serve you best. I attached an example map and here are the triggers:
  • Setup Metapod Types
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Setup the Golems/New Units that they transform into --------
      • -------- Match the Indices - The numbers in the [ ] --------
      • -------- --------
      • Set VariableSet Metapod_Golem[1] = Peasant
      • Set VariableSet Metapod_NewUnit[1] = Knight
      • -------- --------
      • Set VariableSet Metapod_Golem[2] = Wisp
      • Set VariableSet Metapod_NewUnit[2] = Druid of the Talon (Night Elf Form)
      • -------- --------
      • -------- Set this to the total number of Golems that you use --------
      • Set VariableSet Metapod_TotalTypes = 2
  • Cast Metapod Transform
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Metapod Transform
    • Actions
      • -------- This loops through all of the possible Metapod units and finds out which one it is --------
      • -------- Once we know which one it is we can create the matching Unit for it --------
      • For each (Integer A) from 1 to Metapod_TotalTypes, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Metapod_Golem[(Integer A)]
            • Then - Actions
              • Set VariableSet TempPoint = (Position of (Target unit of ability being cast))
              • Unit - Create 1 Metapod_NewUnit[(Integer A)] for (Triggering player) at TempPoint facing Default building facing degrees
              • Custom script: call RemoveLocation (udg_TempPoint)
            • Else - Actions
      • Unit - Remove (Triggering unit) from the game
And an extra trigger that you might like. This will order your Units to cast the Metapod Transform ability when you right click a Cottage. Make sure the Metapod Transform ability has the Base Order ID of "acidbomb".
  • Right Click to Cast
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • (Level of Metapod Transform for (Ordered unit)) Not equal to 0
      • (Unit-type of (Target unit of issued order)) Equal to Cottage
    • Actions
      • Unit - Order (Ordered unit) to Neutral Alchemist - Acid Bomb (Target unit of issued order)
Small note, if your Golem units have their Art - Animation - Cast Point set to a value greater than 0.00, this will cause their abilities to have that much of a delay before they go off. That's because this value is used to make a unit play a portion of it's Spell animation before the spell actually goes off.

You can set the Cast Point to 0 to make the Spell go off instantly, but keep in mind that this will affect EVERY spell that the unit casts.


And here's some Info regarding your Loop triggers and where you were going wrong:
So there's actually an issue when using Reals. Reals lack precision and can end up with the wrong result after some arithmetic.

For instance, when you increase Warrior_Counter by +10.00, you can end up with a result like 9.9999 instead of 10.00.

Why is this a problem? It's a problem because your condition: If "Warrior_Counter is equal to 10.00" is looking for EXACTLY 10.00, not 9.9999.

Solution:
Use Integers instead of Reals. Integers do not suffer from this lack of precision. So instead of increasing Warrior_Counter by 10.00, increase it by 10. And instead of checking if it's equal to 10.00, check if it's equal to 10.
This next issue is regarding your Loop. Your Loop currently runs once every 10.00 seconds.

Meaning, every 10.00 seconds, EVERY Warrior_Metapod will spawn a Warrior. It doesn't matter if that Warrior_Metapod was created 0.50 seconds ago and it doesn't matter if that Warrior_Metapod was created 6.38 seconds ago. Regardless of it's lifetime it will spawn a Warrior.

If you wanted to make this more precise so that each Warrior_Metapod has to actually Wait 10.00 seconds before spawning a Warrior, you should do this:
1) Set the Periodic Event interval to a much smaller number. I recommend something like 0.10.
2) Change your Warrior_Counter to match this new interval. So instead of increasing Warrior_Counter by + 10.00, you'd increase it by + 0.10. (I recommend using an Integer instead of a Real)

  • Example
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet WarriorCounter = (WarriorCounter + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WarriorCounter Equal to 100
        • Then - Actions
          • -------- 10 seconds has passed for this specific unit. Create a Warrior! --------
          • Set VariableSet WarriorCounter = 0
        • Else - Actions
Since it runs every 0.10 seconds it's increasing Counter 10 times per second. So Counter = 100 is the equivalent of 10.00 seconds.
Another issue with your Loop trigger. You're checking if the Metapod is ALIVE, however, you forget to De-Index the Metapod when it's NOT alive.
  • Example
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Metapod is alive) Equal to True
        • Then - Actions
          • -------- Do a bunch of important stuff, Create the Warrior, De-Index the Metapod --------
        • Else - Actions
          • -------- Here's where you need to De-Index the Metapod because it's dead --------
          • -------- So put the same Actions here that you use when Warrior_Counter becomes equal to 10, but delete the stuff about creating a Warrior --------
 

Attachments

  • Metapod Example.w3m
    18.6 KB · Views: 27
Last edited:
Level 4
Joined
Apr 22, 2020
Messages
53
I turned Warrior-Counter into a Integer but I'm not sure I've correctly understand your advice, I did this :

  • Barrack Warrior
    • Evénements
      • Unité - A unit Initie l'effet d'une compétence
    • Conditions
      • ((Owner of (Triggering unit)) Or actuel) Supérieur ou égal à 20
      • ((Owner of (Triggering unit)) Nourriture utilisée) Inférieur ou égal à 99
      • (Ability being cast) Egal à Create Warrior
    • Actions
      • Joueur - Add -20 to (Owner of (Triggering unit)) Or actuel
      • Set Warrior_Index = (Warrior_Index + 1)
      • Set Warrior_Owner[Warrior_Index] = (Owner of (Triggering unit))
      • Set Warrior_Counter[Warrior_Index] = 0
      • Set Warrior_Point[Warrior_Index] = (Position of (Triggering unit))
      • Unité - Create 1 Metapod (Warrior) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Orientation bâtiment par défaut degrees
      • Set Warrior_Metapod[Warrior_Index] = (Last created unit)
      • Effet spécial - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
      • Effet spécial - Destroy (Last created special effect)
      • Unité - Remove (Triggering unit) from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Warrior_Index Supérieur ou égal à 1
        • Alors - Actions
          • Déclencheur - Turn on Barrack Warrior Loop <gen>
        • Sinon - Actions
  • Barrack Warrior Loop
    • Evénements
      • Temps - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Warrior_LoopInteger) from 1 to Warrior_Index, do (Actions)
        • Boucle - Actions
          • Set Warrior_Counter[Warrior_LoopInteger] = (Warrior_Counter[Warrior_LoopInteger] + 1)
          • Texte flottant - Create floating text that reads 10 seconds above Warrior_Metapod[Warrior_LoopInteger] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Texte flottant - Change (Last created floating text): Désactiver permanence
          • Texte flottant - Change the lifespan of (Last created floating text) to 10.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Warrior_Metapod[Warrior_LoopInteger] is alive) Egal à TRUE
              • Warrior_Counter[Warrior_LoopInteger] Egal à 100
            • Alors - Actions
              • Unité - Remove Warrior_Metapod[Warrior_LoopInteger] from the game
              • Unité - Create 1 Warrior for Warrior_Owner[Warrior_LoopInteger] at Warrior_Point[Warrior_LoopInteger] facing Orientation bâtiment par défaut degrees
              • Effet spécial - Create a special effect at Warrior_Point[Warrior_LoopInteger] using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
              • Effet spécial - Destroy (Last created special effect)
              • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
              • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
              • Set Warrior_Point[Warrior_LoopInteger] = Warrior_Point[Warrior_Index]
              • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
              • Set Warrior_Index = (Warrior_Index - 1)
              • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Index Egal à 0
                • Alors - Actions
                  • Déclencheur - Turn off (This trigger)
                • Sinon - Actions
            • Sinon - Actions
              • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
              • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
              • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
              • Set Warrior_Index = (Warrior_Index - 1)
              • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Index Egal à 0
                • Alors - Actions
                  • Déclencheur - Turn off (This trigger)
                • Sinon - Actions

It doesn't work so I think I made a mistake... I tried to "respect" the way of indexing but in your example there is no indexing so... What do I do ?

BTW : I add floating text, but I don't know if I do it correctly.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Create the floating text in your first trigger when the unit casts the ability. Otherwise you'd be creating it 10 times per second in your Loop.

Also, your conditions are incorrect. With the way it's setup now it'll always run the Else (deindexing it) since WarriorCounter isn't equal to 100.

Im on my phone but i'll try to explain how it should look.

1. Loop through the units
2. Check if Warrior[index] is alive
3. If it's alive then increase its counter and then check If counter is equal to 100. If it's equal to 100 then create the unit and de-index it.

ELSE, if it's Dead then de-index it. This is the ELSE for the "If unit is alive", If Then Else statement.
 
Last edited:
Level 4
Joined
Apr 22, 2020
Messages
53
In fact, I wanted to set the "alive" condition after the countdown of 10 sec but I understand what you told me so I set this :

  • Barrack Warrior Loop
    • Evénements
      • Temps - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Warrior_LoopInteger) from 1 to Warrior_Index, do (Actions)
        • Boucle - Actions
          • Set Warrior_Counter[Warrior_LoopInteger] = (Warrior_Counter[Warrior_LoopInteger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Warrior_Metapod[Warrior_LoopInteger] is alive) Egal à TRUE
              • Warrior_Counter[Warrior_LoopInteger] Egal à 100
            • Alors - Actions
              • Unité - Remove Warrior_Metapod[Warrior_LoopInteger] from the game
              • Unité - Create 1 Warrior for Warrior_Owner[Warrior_LoopInteger] at Warrior_Point[Warrior_LoopInteger] facing Orientation bâtiment par défaut degrees
              • Effet spécial - Create a special effect at Warrior_Point[Warrior_LoopInteger] using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
              • Effet spécial - Destroy (Last created special effect)
              • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
              • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
              • Set Warrior_Point[Warrior_LoopInteger] = Warrior_Point[Warrior_Index]
              • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
              • Set Warrior_Index = (Warrior_Index - 1)
              • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Index Egal à 0
                • Alors - Actions
                  • Déclencheur - Turn off (This trigger)
                • Sinon - Actions
            • Sinon - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Counter[Warrior_LoopInteger] Egal à 100
                • Alors - Actions
                  • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
                  • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
                  • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
                  • Set Warrior_Index = (Warrior_Index - 1)
                  • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • Si - Conditions
                      • Warrior_Index Egal à 0
                    • Alors - Actions
                      • Déclencheur - Turn off (This trigger)
                    • Sinon - Actions
                • Sinon - Actions


And oh miracle, IT'S WORKING :) :) :)

So let me offer you this
Cookies-chocolat-pe%CC%81can-%C2%A9-Steve-Bower-shutterstock.jpg

Thank you for all the help you gave me in this thread or the others ! You're the best ;)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
After reading your triggers again I became confused. What is your goal exactly? What do you want this Loop trigger to do? I thought I understood but if you could go into greater detail that would be great.

But before you do that, this is what I think you want. This trigger creates a Warrior every 10.00 seconds for the rest of the game (or until the Metapod dies).
  • Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Warrior_LoopInteger) from 1 to Warrior_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Warrior_Metapod[Warrior_LoopInteger] is alive) Equal to True
            • Then - Actions
              • Set VariableSet Warrior_Counter[Warrior_LoopInteger] = (Warrior_Counter[Warrior_LoopInteger] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Warrior_Counter[Warrior_LoopInteger] Equal to 100
                • Then - Actions
                  • Set VariableSet Warrior_Counter[Warrior_LoopInteger] = 0
                  • Unit - Create 1 Warrior for (Owner of Warrior_Metapod[Warrior_LoopInteger]) at Warrior_Point[Warrior_LoopInteger] facing Default building facing degrees
                • Else - Actions
            • Else - Actions
              • -------- This runs if Warrior_Metapod is DEAD --------
              • -------- De-Index --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Warrior_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
When I say De-Index I mean this stuff:
  • empty.gif
    empty.gif
    empty.gif
    line.gif
    join.gif
    set.gif
    Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
  • empty.gif
    empty.gif
    empty.gif
    empty.gif
    line.gif
    join.gif
    set.gif
    Set Warrior_Point[Warrior_LoopInteger] = Warrior_Point[Warrior_Index]
  • empty.gif
    empty.gif
    empty.gif
    empty.gif
    line.gif
    join.gif
    set.gif
    Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
  • empty.gif
    empty.gif
    empty.gif
    empty.gif
    line.gif
    join.gif
    set.gif
    Set Warrior_Index = (Warrior_Index - 1)
  • empty.gif
    empty.gif
    empty.gif
    empty.gif
    line.gif
    join.gif
    set.gif
    Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
Also, you could make this trigger work for any Unit-Type, so it could be used to handle ALL of your units not just the Warrior. To do this you would use a Unit-Type Variable to keep track of the unit you want to create when Counter reaches 100. So it would end up doing something like "Create 1 Warrior_UnitType[Warrior_LoopInteger} for owner of..."

And if you want there to be a different Counter requirement than just 100 (Say you want Archers to spawn every 5.00 seconds) you could create an Integer like "TimeRequired" and change the condition in the Loop from "If Counter equal to 100" to "If Counter equal to TimeRequired[Warrior_LoopIndex]". TimeRequired for Archers would be set to 50 (5.00 seconds) and set to 100 (10.00 seconds) for Warriors.

Obviously you'd want to rename ALL of the Variables to something more generic since it'd no longer be used for Warriors only.
 
Last edited:
Level 4
Joined
Apr 22, 2020
Messages
53
I want this trigger to make just one unit when you click on the ability. I'm trying to reproduct gameplay mechanic of a game. (Blood&Magic maybe you know this old game)

In this game, you get a golem, move him around a structure and then, you're able to make certain type of units depending of the structure type you're next to.

For example, to make a "Warrior", you have to be next to a "Barrack". You can also make a Ranger and a Paladin. If you are next to a "Rune Stone", you can make "Wizard", "Gnome",...

When you click on "Make a Warrior", your golem turn into a "Metapod" and during 10 seconds, your Warrior is in the process of creating. When 10 seconds are over, your Warrior is ready.

However, If an ennemy kills the "Metapod" before it turns into a Warrior, it will cancels the transformation.

That's what i'm trying to do.

Also, you could make this trigger work for any Unit-Type, so it could be used to handle ALL of your units not just the Warrior. To do this you would use a Unit-Type Variable to keep track of the unit you want to create when Counter reaches 100. So it would end up doing something like "Create 1 Warrior_UnitType[Warrior_LoopInteger} for owner of..."

It's very interesting, you mean, I can make a trigger like

  • Event
  • A Unit cast an ability
  • Condition
  • Ability being cast is egal to "Create Warrior"
  • or
  • Ability being cast is egal to "Create Ranger"
  • Then action blabla
  • Set a Variable for the ability being cast
And in the loop

  • If ability being cast is "Create Warrior"
  • => make the warrior... etc ?
You think it's possible ?


Fore the de-indexing problem, now I explain you better, maybe I did right for my trigger ? Condition "to be alive" and "counter" are together cause it's what I want to be needed to make a Warrior.

And on the "Else", maybe I don't have to let the "counter condition", right ? [Edit : I have to, without it didn't work anymore]
 
Last edited:
Level 4
Joined
Apr 22, 2020
Messages
53
Well I tired to make different type of unit on the same trigger but I'm stuck.

I made this :

  • Barrack Warrior
    • Evénements
      • Unité - A unit Initie l'effet d'une compétence
    • Conditions
      • ((Owner of (Triggering unit)) Or actuel) Supérieur ou égal à 20
      • ((Owner of (Triggering unit)) Nourriture utilisée) Inférieur ou égal à 99
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Egal à Create Warrior
          • (Ability being cast) Egal à Create Druid
    • Actions
      • Joueur - Add -20 to (Owner of (Triggering unit)) Or actuel
      • Set Warrior_Index = (Warrior_Index + 1)
      • Set Warrior_CastAbility[Warrior_Index] = (Ability being cast)
      • Set Warrior_Owner[Warrior_Index] = (Owner of (Triggering unit))
      • Set Warrior_Counter[Warrior_Index] = 0
      • Set Warrior_Point[Warrior_Index] = (Position of (Triggering unit))
      • Unité - Create 1 Metapod (Warrior) for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Orientation bâtiment par défaut degrees
      • Set Warrior_Metapod[Warrior_Index] = (Last created unit)
      • Effet spécial - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
      • Effet spécial - Destroy (Last created special effect)
      • Texte flottant - Create floating text that reads 25 seconds above (Last created unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Texte flottant - Change (Last created floating text): Désactiver permanence
      • Texte flottant - Change the lifespan of (Last created floating text) to 25.00 seconds
      • Unité - Remove (Triggering unit) from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Warrior_Index Supérieur ou égal à 1
        • Alors - Actions
          • Déclencheur - Turn on Barrack Warrior Loop <gen>
        • Sinon - Actions
  • Barrack Warrior Loop
    • Evénements
      • Temps - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Warrior_LoopInteger) from 1 to Warrior_Index, do (Actions)
        • Boucle - Actions
          • Set Warrior_Counter[Warrior_LoopInteger] = (Warrior_Counter[Warrior_LoopInteger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • (Warrior_Metapod[Warrior_LoopInteger] is alive) Egal à TRUE
              • Warrior_Counter[Warrior_LoopInteger] Egal à 250
            • Alors - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Create Druid Egal à Warrior_CastAbility[Warrior_LoopInteger]
                • Alors - Actions
                  • Unité - Create 1 Druid for Warrior_Owner[Warrior_LoopInteger] at Warrior_Point[Warrior_LoopInteger] facing Orientation bâtiment par défaut degrees
                • Sinon - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Create Warrior Egal à Warrior_CastAbility[Warrior_LoopInteger]
                • Alors - Actions
                  • Unité - Create 1 Warrior for Warrior_Owner[Warrior_LoopInteger] at Warrior_Point[Warrior_LoopInteger] facing Orientation bâtiment par défaut degrees
                • Sinon - Actions
              • Unité - Remove Warrior_Metapod[Warrior_LoopInteger] from the game
              • Effet spécial - Create a special effect at Warrior_Point[Warrior_LoopInteger] using Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
              • Effet spécial - Destroy (Last created special effect)
              • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
              • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
              • Set Warrior_Point[Warrior_LoopInteger] = Warrior_Point[Warrior_Index]
              • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
              • Set Warrior_Index = (Warrior_Index - 1)
              • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Index Egal à 0
                • Alors - Actions
                  • Déclencheur - Turn off (This trigger)
                • Sinon - Actions
            • Sinon - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • Warrior_Counter[Warrior_LoopInteger] Egal à 250
                • Alors - Actions
                  • Custom script: call RemoveLocation( udg_Warrior_Point[udg_Warrior_LoopInteger])
                  • Set Warrior_Metapod[Warrior_LoopInteger] = Warrior_Metapod[Warrior_Index]
                  • Set Warrior_Point[Warrior_LoopInteger] = Warrior_Point[Warrior_Index]
                  • Set Warrior_Counter[Warrior_LoopInteger] = Warrior_Counter[Warrior_Index]
                  • Set Warrior_Index = (Warrior_Index - 1)
                  • Set Warrior_LoopInteger = (Warrior_LoopInteger - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • Si - Conditions
                      • Warrior_Index Egal à 0
                    • Alors - Actions
                      • Déclencheur - Turn off (This trigger)
                    • Sinon - Actions
                • Sinon - Actions

If I cast one ability, wait 25 seconds, I cast the other one, both work well.

But If I cast both under 25 seconds of interval, I make for both, the first unit linked to the spell.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Alright, now I understand. So if that's the case then the Loop is NOT needed at all.

Here's a system that should work exactly how you want it to. The Golems have an ability called Metapod Transform (You can name it whatever). When they cast this ability on a Structure they begin channeling for X seconds (X depends on the Unit the Golem creates). After the Golem finishes channeling the ability, the Golem is removed and the correct Unit is created.

Here are the triggers:
I attached a picture called Variables that explains all of these Variable types.
UDex is an Integer that comes with the Unit Indexer system (explained later on).
  • Metapod Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Setup the Variables used by the system --------
      • -------- Match the Indices --> The number in the [ ] --------
      • -------- --------
      • -------- Unit = The unit the Golem transforms into --------
      • -------- Structure = The structure that creates the unit --------
      • -------- TimeRequired = How long it takes the Golem to transform --------
      • -------- --------
      • Set VariableSet Metapod_Unit[1] = Footman
      • Set VariableSet Metapod_Structure[1] = Farm
      • Set VariableSet Metapod_TimeRequired[1] = 10.00
      • -------- --------
      • Set VariableSet Metapod_Unit[2] = Archer
      • Set VariableSet Metapod_Structure[2] = Moon Well
      • Set VariableSet Metapod_TimeRequired[2] = 5.00
      • -------- --------
      • -------- Set this to the total number of Metapod_Structures used --------
      • Set VariableSet Metapod_TotalStructures = 2
      • -------- --------
      • -------- Set this to the Metapod Transform ability (the ability the Golems cast on Structures) --------
      • Set VariableSet Metapod_Ability = Metapod Transform
  • Metapod Cast
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Metapod_Ability
    • Actions
      • -------- This loops through all of the possible Metapod_Structures and finds out which one it is --------
      • -------- Once we know which one it is we can create the matching Unit for it --------
      • -------- --------
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • For each (Integer A) from 1 to Metapod_TotalStructures, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of Metapod_TargetStructure[UDex]) Equal to Metapod_Structure[(Integer A)]
            • Then - Actions
              • Set VariableSet TempPoint = (Position of Metapod_TargetStructure[UDex])
              • Unit - Create 1 Metapod_Unit[(Integer A)] for (Triggering player) at TempPoint facing Default building facing degrees
              • Custom script: call RemoveLocation (udg_TempPoint)
            • Else - Actions
      • Unit - Remove (Triggering unit) from the game
  • Metapod Order
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Level of Metapod_Ability for (Ordered unit)) Not equal to 0
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(acidbomb))
    • Actions
      • For each (Integer A) from 1 to Metapod_TotalStructures, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Target unit of issued order)) Equal to Metapod_Structure[(Integer A)]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(smart))
                • Then - Actions
                  • -------- If the Order was "smart" (right-click) then order it to cast Metapod Transform instead --------
                  • Unit - Order (Ordered unit) to Neutral Alchemist - Acid Bomb (Target unit of issued order)
                • Else - Actions
                  • -------- If the Order was "acidbomb" (Metapod Transform) then adjust the Golem's Follow Through Time (Channel time) to the TimeRequired --------
                  • Set VariableSet UDex = (Custom value of (Ordered unit))
                  • Set VariableSet Metapod_TargetStructure[UDex] = (Target unit of issued order)
                  • Ability - Set Ability: (Unit: (Ordered unit)'s Ability with Ability Code: Metapod_Ability)'s Real Level Field: Follow Through Time ('Ncl1') of Level: 0 to Metapod_TimeRequired[(Integer A)]
            • Else - Actions

SYSTEM REQUIREMENTS:
GUI Unit Indexer 1.4.0.0
All you have to do is copy the Folder called "Unit Indexer" from the map and then paste it into your map.
This system provides the variable UDex that you'll see a couple of times in my triggers.
If you already have Unit Indexer then you don't need to import it again!

It also requires an Ability based on Channel.
I attached a picture of the settings for the Ability. Make sure your ability matches my ability! You can adjust the Art/Name (visual stuff) but don't mess with it's other values.
Make sure your Golem has this ability added to it!

The triggers used require patch 1.31+ (and you need the latest patch to open my example map) although I could make a modified version for older patches but it'd lose the option to set the Time Required stuff.
 

Attachments

  • Channel Ability.png
    Channel Ability.png
    164 KB · Views: 42
  • Metapod Example 2.w3m
    24 KB · Views: 19
  • Variables.png
    Variables.png
    346.4 KB · Views: 42
  • Setup Instructions.png
    Setup Instructions.png
    294 KB · Views: 42
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Here's another trigger that you may or may not want.

This cancels the Metapod_Ability if you target an invalid structure. So if you target a Structure that isn't meant to transform Golems then it will cancel the cast.
It requires a Boolean variable called Metapod_CancelAbility.
  • Metapod Cancel
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Metapod_Ability
    • Actions
      • Set VariableSet Metapod_CancelAbility = True
      • For each (Integer A) from 1 to Metapod_TotalStructures, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Target unit of ability being cast)) Equal to Metapod_Structure[(Integer A)]
            • Then - Actions
              • Set VariableSet Metapod_CancelAbility = False
            • Else - Actions
      • -------- --------
      • -------- If the target is not a valid Structure then cancel the ability --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Metapod_CancelAbility Equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop.
        • Else - Actions
Edit:
Also, I realized I could optimize the Metapod Cast and Metapod Order triggers. Sorry if this is too much!
I deleted the Metapod_TargetStructure variable and replaced it with an Integer called Metapod_Id. This is more efficient as it makes our Metapod Cast trigger run without needing to Loop through all of the possible Metapod_Structures.
  • Metapod Cast
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Metapod_Ability
    • Actions
      • -------- This loops through all of the possible Metapod_Structures and finds out which one it is --------
      • -------- Once we know which one it is we can create the matching Unit for it --------
      • -------- --------
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • Set VariableSet TempPoint = (Position of (Triggering unit))
      • Unit - Remove (Triggering unit) from the game
      • Unit - Create 1 Metapod_Unit[Metapod_Id[UDex]] for (Triggering player) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempPoint)
  • Metapod Order
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Level of Metapod_Ability for (Ordered unit)) Not equal to 0
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(acidbomb))
    • Actions
      • For each (Integer A) from 1 to Metapod_TotalStructures, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Target unit of issued order)) Equal to Metapod_Structure[(Integer A)]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Issued order) Equal to (Order(smart))
                • Then - Actions
                  • -------- If the Order was "smart" (right-click) then order it to cast Metapod Transform instead --------
                  • Unit - Order (Ordered unit) to Neutral Alchemist - Acid Bomb (Target unit of issued order)
                • Else - Actions
                  • -------- If the Order was "acidbomb" (Metapod Transform) then adjust the Golem's Follow Through Time (Channel time) to the TimeRequired --------
                  • Set VariableSet UDex = (Custom value of (Ordered unit))
                  • Set VariableSet Metapod_Id[UDex] = (Integer A)
                  • Ability - Set Ability: (Unit: (Ordered unit)'s Ability with Ability Code: Metapod_Ability)'s Real Level Field: Follow Through Time ('Ncl1') of Level: 0 to Metapod_TimeRequired[(Integer A)]
            • Else - Actions
I can also update the Cancel trigger to be optimized like the cast trigger. I'll update it when I get home.
 

Attachments

  • Metapod Example 3.w3m
    24.7 KB · Views: 19
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Good! It makes it a lot easier when you can just copy and paste everything :p

Anyway, I attached v.4 of the system. I optimized the Cast/Cancel triggers and cleaned some things up.

I promise i'm done updating it lol, unless of course you want some specific features added to it.

Feel free to request ANY additions/changes to the system!
 

Attachments

  • Metapod v.4.w3m
    24.3 KB · Views: 17
Status
Not open for further replies.
Top