• 🏆 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 Help/Question...

Status
Not open for further replies.
Level 2
Joined
May 26, 2010
Messages
6
Not one for making triggers; but is it possible to make a moving unit use resources? Or mana at least?
- For example, a tank moving would cost resources/mana and without them the tank wouldn't be able to move.

Also, could you make abilities cost resources?
 
Level 11
Joined
Feb 11, 2010
Messages
199
Could you teach/show me an example of how to do that?

The first way to do it that comes to my mind is making a periodic loop that sets the position of a unit and activates when said unit goes outside of a short range of that point, then reset the point to new position of unit and drain mana / resources. If Mana / Resources are less than the number required, then set unit movement speed to zero. Set it to normal again when you once again have the requisite mana or resources.

Pretty straightforward. Here's a snippet of an ability I made in the past that demonstrates how to make an effect proc with movement... (note that it's MPI instead of MUI, but you can easily change that)

  • Miasma Loop
    • Events
      • Time - Every 0.06 seconds of game time
    • Conditions
    • Actions
      • For each (Integer MiasmaA) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MiasmaOn[MiasmaA] Equal to True
            • Then - Actions
              • Set MiasmaPoint2[MiasmaA] = (Position of MiasmaCaster[MiasmaA])
              • Set MiasmaRange[MiasmaA] = (Distance between MiasmaPoint1[MiasmaA] and MiasmaPoint2[MiasmaA])
              • Custom script: call RemoveLocation(udg_MiasmaPoint2[udg_MiasmaA])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MiasmaRange[MiasmaA] Greater than or equal to 150.00
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_MiasmaPoint1[udg_MiasmaA])
                  • Set MiasmaPoint1[MiasmaA] = (Position of MiasmaCaster[MiasmaA])
                  • Unit - Create 1 Dummy(Miasma) for MiasmaOwner[MiasmaA] at MiasmaPoint1[MiasmaA] facing Default building facing degrees
                  • Unit - Add a MiasmaDuration[MiasmaA] second Generic expiration timer to (Last created unit)
                  • Unit Group - Add (Last created unit) to MiasmaDummyGroup[MiasmaA]
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Mana of MiasmaCaster[MiasmaA]) Less than or equal to 5.00
            • Then - Actions
              • Set MiasmaOn[MiasmaA] = False
              • Unit Group - Remove MiasmaCaster[MiasmaA] from MiasmaDummyGroup[MiasmaA]
              • Custom script: call RemoveLocation(udg_MiasmaPoint1[udg_MiasmaA])
            • Else - Actions
You would of course want to make your range shorter than 150 just to detect movement. And instead of summoning a unit with movement you'd want to drain mana / resources.

See? Easy.
 
Status
Not open for further replies.
Top