• 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.

[Solved] Unit in Range Starts a Timer

Status
Not open for further replies.
Alright. I have a problem.
I have a spell that:
Summons an immovable ward that explodes 3 seconds after a unit gets within 350 range of the ward. When the ward explodes, it will banish all units within 350 range for 5 seconds. The ward lasts 60 seconds.

And now, it's based off Healing Ward. I've set most of the Object Editor stuff, so we don't need to worry about that.

Now, I don't know how to do the part that the timer starts when a unit gets in range; let alone every other part of the spell.
I also want a floating text to appear each second after it is activated.

[EDIT]
Two notes:
MUI, and GUI.
 
Last edited:
Level 6
Joined
Dec 9, 2010
Messages
121
I can make this spell for you really quickly, if you'd like, to show you how it could be done.

Edit: Here it is. I didn't put any polish in it, but I'm sure you can add your own special effects if you'd like. Hope this helps!
 

Attachments

  • Banish Ward v.01.w3x
    20.4 KB · Views: 54
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
@def, a few improvement suggestions:
The dying detection trigger should be turned on/off.
I recommend not to use arrays when you only need 1 or 2 indexes.
Why do you save the things for the unit entering the range? Save the things for the ward so it's MUI.
And set the timer durtion in init trigger.


  • WB Check
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in WardedBombGroup and do (Actions)
        • Loop - Actions
          • Set Units[1] = (Picked unit)
          • Set Locations[1] = (Position of Units[1])
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within DetectionAOE of Locations[1]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) belongs to an enemy of (Owner of Units[1])) Equal to True
                • Then - Actions
                  • Custom script: set udg_HandleID = GetHandleId(udg_Units[1])
                  • Hashtable - Save TimerDuration as (Key TimerDuration) of HandleID in Hashtable
                  • Unit Group - Add Units[1] to TimerBombedGroup
                  • Unit Group - Remove Units[1] from WardedBombGroup
                  • Trigger - Turn on WB Explode <gen>
                • Else - Actions
          • Custom script: call RemoveLocation(udg_Locations[1])
  • WB Explode
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TimerBombedGroup and do (Actions)
        • Loop - Actions
          • Set Units[1] = (Picked unit)
          • Set HandleID = (Key (Picked unit))
          • Set TimerDuration = (Load (Key TimerDuration) of HandleID from Hashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimerDuration Greater than 0.00
            • Then - Actions
              • Hashtable - Save (TimerDuration - 1.00) as (Key TimerDuration) of HandleID in Hashtable
              • Floating Text - Create floating text that reads (String((Integer(TimerDuration)))) above Units[1] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
            • Else - Actions
              • Set Locations[1] = (Position of Units[1])
              • Unit - Kill Units[1]
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within ExplodeAOE of Locations[1] matching (((Matching unit) belongs to an enemy of (Owner of Units[1])) Equal to True)) and do (Actions)
                • Loop - Actions
                  • Set Locations[2] = (Position of (Picked unit))
                  • Unit - Create 1 Dummy Banisher for (Owner of Units[1]) at Locations[2] facing Default building facing degrees
                  • Unit - Add a 0.30 second Generic expiration timer to (Last created unit)
                  • Unit - Order (Last created unit) to Human Blood Mage - Banish (Picked unit)
                  • Custom script: call RemoveLocation(udg_Locations[2])
              • Unit Group - Remove (Picked unit) from TimerBombedGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in TimerBombedGroup) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
              • Hashtable - Clear all child hashtables of child HandleID in Hashtable
              • Custom script: call RemoveLocation(udg_Locations[1])
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
The dying detection trigger should be turned on/off.
Once I uploaded the test map (for the first time), I realized this and edited it as soon as I can
But to hell with that, you're god speed to download the test map and I was late, if you download it again you can see the test map has 1 new trigger "WB Remove" although my post doesn't count as "Edited" post

By the way, in its current state, it IS MUI, I tried it 100 times and works perfectly, I wonder why..

And set the timer durtion in init trigger.
The value of TimerDuration is manipulated throughout the game
Manipulated = Either being subtracted, or added, or divided or multiplied

Manipulated data should not be setup in INIT trigger, don't you think ?
Because, for first spell it works (TimerDuration down to 0) but for the second spell ?
The data remains at 0, thus, bugging the spell
That's why for each cast, I renew it.

About setting the Handle ID for the ward itself, you have the point
I didn't know the correct function to call it, that's why I save it to those Peasants, silly me :(
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
if you download it again you can see the test map has 1 new trigger "WB Remove" although my post doesn't count as "Edited" post

The map I downloaded had the WB Remove trigger. And you should turn that on/off. It should not be on all the time.

By the way, in its current state, it IS MUI, I tried it 100 times and works perfectly, I wonder why..

Not necessarily. If there are two wards near each other and only one unit that enters the range of both wards, only one of the wards will start the count down.

The value of TimerDuration is manipulated throughout the game. Manipulated data should not be setup in INIT trigger, don't you think? Because, for first spell it works (TimerDuration down to 0) but for the second spell ? The data remains at 0, thus, bugging the spell. That's why for each cast, I renew it.

A meant a configurable variable in the init trigger so one can change it easily in the init trigger an not in WB check trigger.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
The map I downloaded had the WB Remove trigger. And you should turn that on/off. It should not be on all the time.
Ohhhhh you meant the "WB Remove" trigger that needs to be turn on/off ?
Haha, I thought that WB Check lol
Well, it doesn't occur when it needs to, why did you say it will affect the game's performance ?
Unless the triggers for WB Check and WB Explode are on at all time, that, can reduce the map's efficiency
Why should we need to turn it on/off ?
Curious ^_^

Not necessarily. If there are two wards near each other and only one unit that enters the range of both wards, only one of the wards will start the count down.
Ahhh yes, because it checks the unit is in Unit Group or not
So, by doing the function call of saving Handle ID to the ward itself, it prevents non-MUI trigger, thanks for teaching me that function call !

A meant a configurable variable in the init trigger so one can change it easily in the init trigger an not in WB check trigger.
Also, misunderstood for the first time I read
But I think that you're gonna need 2 variables for that ?
One for INIT, one for cast trigger
You see, INIT = 3.00
Then in Cast Trigger, TimerDuration = INIT, like that ?

Thanks Maker for making my trigger performs at a better speed, +rep !

@indomitable
Follow all the comments and you should optimize the trigger a bit
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Ohhhhh you meant the "WB Remove" trigger that needs to be turn on/off ?
Why should we need to turn it on/off ?

It registers the death of any unit in the map and then calls some functions. There's no sense in doing that if there are no wards alive.

Also, misunderstood for the first time I read
But I think that you're gonna need 2 variables for that ?

Yes, one for the configuration trigger and one to be used in the other trigger.
 
Status
Not open for further replies.
Top