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

Custom call to arms

Level 3
Joined
Mar 11, 2014
Messages
26
Hi, guys. I'm trying to create a custom 'call to arms' mechanic where a unit transforms into another unit when it goes to a specific building.

I've been trying to replicate this, but it doesn't seem to work.

  • Transforming Units - Permanent
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to YOUR ABILITY
    • Actions
      • Unit Group - Pick every unit in (Units within 400.00 of (Position of (Casting unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to (Casting unit)
              • (Unit-type of (Picked unit)) Equal to OLD UNIT
            • Then - Actions
              • Unit - Order (Picked unit) to Move To (Position of (Casting unit))
              • Wait 0.10 seconds
              • Unit - Replace (Picked unit) with a NEW UNIT using The old unit's relative life and mana
            • Else - Actions
I have this

1695630206733.png
 
Last edited by a moderator:
Level 25
Joined
Sep 26, 2009
Messages
2,388
Your two triggers are not the same.
In the screenshot, you use 'Pick every unit and do (Action)' where the action is (Do nothing). As such, the If/Then/Else will never work, because it is outside the 'Pick every unit' loop and as a result there is no (Picked unit), so the conditions will always fail.
To fix this, you would need to use 'Pick every unit and do (Actions)' and drag the entire If/Then/Else block under the 'Loop - Actions'
 
Level 3
Joined
Mar 11, 2014
Messages
26
Your two triggers are not the same.
In the screenshot, you use 'Pick every unit and do (Action)' where the action is (Do nothing). As such, the If/Then/Else will never work, because it is outside the 'Pick every unit' loop and as a result there is no (Picked unit), so the conditions will always fail.
To fix this, you would need to use 'Pick every unit and do (Actions)' and drag the entire If/Then/Else block under the 'Loop - Actions'
Thanks,
I corrected the trigger

1695657320847.png


Now, when the Barrack cast the spell the Footman goes to it, but dont transforme in to Rifleman :(
 

Remixer

Map Reviewer
Level 31
Joined
Feb 19, 2011
Messages
1,957
I would recommend, instead of using a wait, order the Footman to cast an ability with low range (50) on the Barracks. You can hide the ability by using button position (0, -11) so there is no other way to cast it than by through a code telling the unit to cast it.

When a footman casts that ability, transform it into a rifleman. That way you don't need to use any waits, and its easy to interrupt the order if needed.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,584
Hi, guys. I'm trying to create a custom 'call to arms' mechanic where a unit transforms into another unit when it goes to a specific building.


I second what Remixer said, an Event based approach is always best since you get the expected outcome using existing Warcraft 3 mechanics. The only issue I can think of is what happens when the unit becomes Silenced while trying to cast this hidden ability. But I think the Channel ability has an option to make a spell "silence immune", if so, that's the ideal ability.

Also, Waits are generally a bad solution - mainly in custom spells, so you should try to steer away from them in those situations. Waits need to be synced between all players when playing online and as a result will always be at least ~0.25 seconds in duration and will always be imprecise. Timers are the preferred and precise solution since they don't suffer from syncing issues. Unfortunately, Timers are a little clunky to use in GUI (the standard Trigger Editor) but there are methods/systems to make them easier to work with.

Speaking of which, I attached a map with some systems that make designing triggers in GUI much easier. I recommend mastering these since they enable you to do pretty much anything you want with ease. Oh and I didn't include this one in the map but it's another great addition: New Bonus [vJASS][LUA]
 

Attachments

  • Useful GUI Systems 1.w3m
    96.7 KB · Views: 3
Last edited:
Level 3
Joined
Mar 11, 2014
Messages
26

I second what Remixer said, an Event based approach is always best since you get the expected outcome using existing Warcraft 3 mechanics. The only issue I can think of is what happens when the unit becomes Silenced while trying to cast this hidden ability. But I think the Channel ability has an option to make a spell "silence immune", if so, that's the ideal ability.

Also, Waits are generally a bad solution - mainly in custom spells, so you should try to steer away from them in those situations. Waits need to be synced between all players when playing online and as a result will always be at least ~0.25 seconds in duration and will always be imprecise. Timers are the preferred and precise solution since they don't suffer from syncing issues. Unfortunately, Timers are a little clunky to use in GUI (the standard Trigger Editor) but there are methods/systems to make them easier to work with.

Speaking of which, I attached a map with some systems that make designing triggers in GUI much easier. I recommend mastering these since they enable you to do pretty much anything you want with ease. Oh and I didn't include this one in the map but it's another great addition: New Bonus [vJASS][LUA]
Thanks Uncle,

Your both proposal seems interesting.

I'm very noob at the moment but I would like to know more about "GTS" and your "New Bonus" example.

Right now, for me they are like in Chinese, so I don't know how to use them in my case.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,584
Thanks Uncle,

Your both proposal seems interesting.

I'm very noob at the moment but I would like to know more about "GTS" and your "New Bonus" example.

Right now, for me they are like in Chinese, so I don't know how to use them in my case.
New Bonus comes with a demo map and some examples to learn from (see the thread). My GTS system has triggered examples inside of the "Examples" folder and a trigger called Tutorial which teaches you how to use it. Researching those should help clear things up.

The breakdown:

New Bonus gives you a lot of control over modifying unit's stats. For example, in a single Action you can add +5 attack damage to a unit for 5.00 seconds. The system will then handle everything from there and alleviate you from the stress of having to track the unit, the damage, the timer, etc...

GTS (GUI Timer System) is something I made for myself which is not up to Hive standards yet (imo). It allows you to to create and start a Timer with just a few Actions and allows you to attach data (units, items, integers, reals, etc) to the Timer which you can then reference again once the Timer expires. This is done "locally" so that you don't have to worry about your variables being overwritten or changed. This system pairs nicely with a Unit Indexer to create powerful custom spells.

Relativistic Missiles or Missile System gives you the ability to launch Missiles just like Death Coil or Storm Bolt easily inside of your triggers, and similar to New Bonus and GTS, the missile's can have data attached to them which you can then reference later on. This allows you to create interesting custom spells in only a matter of minutes, for example:
Launch a Shockwave missile which chases after a designated target. The missile damages any enemy units it passes through just like Shockwave. However, once the Missile reaches it's target it explodes and the target is stunned for 5.00 seconds.

These systems are made using Jass (code) but are designed to be easily accessible in GUI so that users that are unfamiliar with code can use them as well.

Of course it takes time to learn and understand how to use these systems, but don't be intimidated by the 1000's of lines of code, you should only concern yourself with HOW TO USE the system, not how it works. The examples are there to show you what YOU need to know, everything else can be ignored.
 
Last edited:
Level 3
Joined
Mar 11, 2014
Messages
26
New Bonus comes with a demo map and some examples to learn from (see the thread). My GTS system has triggered examples inside of the "Examples" folder and a trigger called Tutorial which teaches you how to use it. Researching those should help clear things up.

The breakdown:

New Bonus gives you a lot of control over modifying unit's stats. For example, in a single Action you can add +5 attack damage to a unit for 5.00 seconds. The system will then handle everything from there and alleviate you from the stress of having to track the unit, the damage, the timer, etc...

GTS (GUI Timer System) is something I made for myself which is not up to Hive standards yet (imo). It allows you to to create and start a Timer with just a few Actions and allows you to attach data (units, items, integers, reals, etc) to the Timer which you can then reference again once the Timer expires. This is done "locally" so that you don't have to worry about your variables being overwritten or changed. This system pairs nicely with a Unit Indexer to create powerful custom spells.

Relativistic Missiles or Missile System gives you the ability to launch Missiles just like Death Coil or Storm Bolt easily inside of your triggers, and similar to New Bonus and GTS, the missile's can have data attached to them which you can then reference later on. This allows you to create interesting custom spells in only a matter of minutes, for example:


These systems are made using Jass (code) but are designed to be easily accessible in GUI so that users that are unfamiliar with code can use them as well.

Of course it takes time to learn and understand how to use these systems, but don't be intimidated by the 1000's of lines of code, you should only concern yourself with HOW TO USE the system, not how it works. The examples are there to show you what YOU need to know, everything else can be ignored.
I Copy GTS to my map and have the next issues
1695682629836.png


Issue detected when pick to Validate Map Triggers

1695682659501.png
 
Level 3
Joined
Mar 11, 2014
Messages
26
Make sure that you enable JassHelper, there's a drop down menu for it in the Trigger Editor. Also, always put your Jass code at the very top of the Trigger Editor. So your GUI Simple Timers folder would be at the very top of the Trigger Editor above the other folders.
Hi Uncle, long time I wasn't around here (Too much work). I did that you said and the validation is success. but now i try this

  • Cambio de arma axe
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to To Arms Axe
    • Actions
      • Unit Group - Pick every unit in (Units within 1200.00 of (Position of (Casting unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to (Casting unit)
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Unit - Order (Picked unit) to Right-Click (Position of (Casting unit))
            • Else - Actions
      • Set VariableSet GST_Trigger = Cambio de arma axe Expire <gen>
      • Custom script: call GST_Simple(false, 1.00)

  • Cambio de arma axe Expire
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 1200.00 of (Position of (Casting unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to (Casting unit)
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Unit - Replace (Picked unit) with a Rifleman using The old unit's relative life and mana
            • Else - Actions

It doesn't work :(
The Footman just come to the Barrack and dont turn to Rifleman
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,584
Hello, I'm glad it worked. So I see a few problems:

1) You should almost always use the Starts casting event since it runs at the exact moment the ability fires:
  • Unit - A unit Starts the effect of an ability

2) You're using the wrong GST() function.
Since you want to track the (Casting unit) over time you want to use the GST_Unit() function and put your caster inside of it like this:
  • Custom script: call GST_Unit( GetTriggerUnit(), false, 1.00 )

3) Inside of Cambio de arma axe Expire replace (Casting unit) with the variable GST_Unit1:
  • Actions
    • Unit Group - Pick every unit in (Units within 1200.00 of (Position of GST_Unit1).) and do (Actions)
Just make sure that you do that for ALL of the (Casting unit) event responses in this trigger.

The GST system allows you to attach data to a brand new Timer. You can then reference this data when your Timer expires. To reference this data you need to use the correct GST_() function and the correct GST_ variables that go along with it.

Also, your current trigger doesn't really need to rely on the GST() system. You could easily accomplish it with a Wait action and by using (Triggering unit) as the Event Response instead of (Casting unit). But this is still a nice way to learn the system and get that exact precision that Timers offer.
 
Last edited:
Level 3
Joined
Mar 11, 2014
Messages
26
Hello, I'm glad it worked. So I see a few problems:

1) You should almost always use the Starts casting event since it runs at the exact moment the ability fires:
  • Unit - A unit Starts the effect of an ability

2) You're using the wrong GST() function.
Since you want to track the (Casting unit) over time you want to use the GST_Unit() function and put your caster inside of it like this:
  • Custom script: call GST_Unit( GetTriggerUnit(), false, 1.00 )

3) Inside of Cambio de arma axe Expire replace (Casting unit) with the variable GST_Unit1:
  • Actions
    • Unit Group - Pick every unit in (Units within 1200.00 of (Position of GST_Unit1).) and do (Actions)
Just make sure that you do that for ALL of the (Casting unit) event responses in this trigger.

The GST system allows you to attach data to a brand new Timer. You can then reference this data when your Timer expires. To reference this data you need to use the correct GST_() function and the correct GST_ variables that go along with it.

Also, your current trigger doesn't really need to rely on the GST() system. You could easily accomplish it with a Wait action and by using (Triggering unit) as the Event Response instead of (Casting unit). But this is still a nice way to learn the system and get that exact precision that Timers offer.

Thank you very much for your patience and lessons Uncle, the GUI is now working but not exactly as I imagined, because the footman does not end up going to the Barracks and is replaced by the rifleman. I need that no matter the distance or the time, the footman has to be replaced by the rifleman when he finishes going to the barracks.

  • Cambio de arma axe
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to To Arms Axe
    • Actions
      • Unit Group - Pick every unit in (Units within 1200.00 of (Position of (Casting unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to (Casting unit)
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Unit - Order (Picked unit) to Right-Click (Position of (Casting unit))
            • Else - Actions
      • Set VariableSet GST_Trigger = Cambio de arma axe Expire <gen>
      • Custom script: call GST_Unit( GetTriggerUnit(), false, 1.00 )

  • Cambio de arma axe Expire
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 1200.00 of (Position of GST_Unit1).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to (Casting unit)
              • (Unit-type of (Picked unit)) Equal to Footman
            • Then - Actions
              • Unit - Replace (Picked unit) with a Rifleman using The old unit's relative life and mana
            • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,584
You've set the duration of the timer to 1.00 second which is probably not enough time for any units to reach the barracks.

Anyway, I think what you want to do is remove the GST stuff and instead do the following:

Add a hidden and free to cast ability to each of your picked units and order them to cast said ability on the Barracks (casting unit). Then you can detect when this ability is cast using the "Begins casting" event and replace the casting unit. This hidden ability should have short cast range so the unit can only cast it in melee range of the barracks.
 
Level 3
Joined
Mar 11, 2014
Messages
26
You've set the duration of the timer to 1.00 second which is probably not enough time for any units to reach the barracks.

Anyway, I think what you want to do is remove the GST stuff and instead do the following:

Add a hidden and free to cast ability to each of your picked units and order them to cast said ability on the Barracks (casting unit). Then you can detect when this ability is cast using the "Begins casting" event and replace the casting unit. This hidden ability should have short cast range so the unit can only cast it in melee range of the barracks.

Sorry by the ignorance, but how can I make a hidden ability ?
 
Top