• 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] Detect units within range with cooldown.

Status
Not open for further replies.
Level 2
Joined
Sep 27, 2015
Messages
9
I wanted to make a spell/ability that check every 1 second around heros that have that spell and detect a unit(not allied) around the hero and when it does detect a unit the spell ping at the unit detected and goes in cooldown of 60 seconds until being able to detect a unit again.

I have tried multiples triggers with "Pick every unit" and variables etc. But none of them work or just do weird stuff. I can try to explain further my ideas if needed.


(Sorry for bad english)
 
Sorry for the caps.

Anyway :
  • Untitled Trigger 001
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 512.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
            • Then - Actions
              • -------- First unit got --------
              • -------- Do actions here --------
              • Skip remaining actions
            • Else - Actions
The basic idea is something like this (note the leaks and this trigger isn't set up properly) for the spell. If there's more than 1 user, it could get a bit complicated depending if it's one per player or multiple unit per player. Also, forgot the integer check for ability level.
 
Level 2
Joined
Sep 27, 2015
Messages
9
Every players in my map got a unit, it's a 5v1 map (Player 1 vs Player 2,3,4,5,6) And they can buy skills/abilities/spells and one of them is the one im trying to do.
Is this correct in someway? I'm confuse with "Triggering unit".
  • Skill 1,1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
              • (Level of War Stomp for (Triggering unit)) Equal to 1
            • Then - Actions
              • Cinematic - Ping minimap for (Player group((Owner of (Triggering unit)))) at (Position of (Picked unit)) for 1.00 seconds, using a Simple ping of color (100.00%, 100.00%, 100.00%)
            • Else - Actions
 
Level 11
Joined
May 16, 2016
Messages
730
I wanted to make a spell/ability that check every 1 second around heros that have that spell and detect a unit(not allied) around the hero and when it does detect a unit the spell ping at the unit detected and goes in cooldown of 60 seconds until being able to detect a unit again.

I have tried multiples triggers with "Pick every unit" and variables etc. But none of them work or just do weird stuff. I can try to explain further my ideas if needed.

You can set all parameters in this template. Set cooldown about 5-10 sec to see the effect and then set the cooldown back to a value you wish.
P.S. This template is general for all units. You can set more units with the periodic detect ability and each of them will have own cooldown.
 

Attachments

  • PERIODIC DETECT.w3x
    18.6 KB · Views: 31
Last edited:
Level 15
Joined
Jul 9, 2008
Messages
1,552
Every players in my map got a unit, it's a 5v1 map (Player 1 vs Player 2,3,4,5,6) And they can buy skills/abilities/spells and one of them is the one im trying to do.
Is this correct in someway? I'm confuse with "Triggering unit".
  • Skill 1,1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
              • (Level of War Stomp for (Triggering unit)) Equal to 1
            • Then - Actions
              • Cinematic - Ping minimap for (Player group((Owner of (Triggering unit)))) at (Position of (Picked unit)) for 1.00 seconds, using a Simple ping of color (100.00%, 100.00%, 100.00%)
            • Else - Actions

that trigger will not work because there is no triggering unit
ull have to make a unit variable and use that
 
Looking from the description of the ability, I think that you would have to use array indexes. To set it up, (all of these must be global) you would need a unit array for units learning that ability, a boolean array to check whether or not they have already detected something, a real array that increments by 1 second should the boolean array return true and exit when it is greater than or equal to 60, and an integer that counts the number of instances. (This is for MUI capability)

(Detection Setup)

(If it is a hero ability)
Now, you would need a trigger that catches the event when the unit learns that ability. After catching the event, you would want to check first if it exists by looping over all possible instances up to the counting integer and add its' data if it is not found.

(If it is a unit ability, assuming that it already has the ability)
You would want to catch the event when it enters the Playable Map Area. If the event would fire, you would check if the ability in question of the unit is not equal to 0, that is, it has the ability. If it does not have the ability, when you add the ability, you should add its' data into the unit array, boolean array and the real array; being that only the unit array is defined.

(Timer Trigger)

Now, as they had previously answered, you would do all of the event processing here, using a loop structure (local integer from your starting integer to your counting integer.)

  • Custom Script: local integer i = 1
  • For something from i to udg_somevar, do actions
I believe that would do.

Now for the optimizations...
I won't include it for now...
 
Status
Not open for further replies.
Top