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

[General] unit group array, fixating X units on Y heroes

Status
Not open for further replies.

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Hi forum!

This time, I need help with creating a trigger. What I want achieved is this;

For each Hero on the map, a Dark Reaver will spawn. The Dark Reavers will fixate (ignoring everything else) on their respective heroes, and have same movement speed as the hero minus 5%.

I am assuming I will use unit group arrays, and put each Dark Reaver spawned into a unit group, and give them a number ranging from 1-8. How can I make the trigger see how many heroes there are active on the map, and spawn that number? I am thinking it will be best to give them a dedicated player number, instead of any other way.

I've created four different spawn points, and I am wondering if using the same point variable for all four will cause bugs?

If I am way off, please come with corrections and suggestions to a better way of implementing what I am trying :)

Thanks!
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Wrong forum.

The best way to check if a hero is active (alive I guess?) is just to have a unit group. Add all units to it when they are created. When a unit dies, remove that unit and when it revives, add it again.

Group arrays arent necessary in this case, you just need to create your units and order them to attack the target unit. If it doesnt get any other order or stops (by stun or something) it will be fine. You can give it magic immunity to protect it from stuns and imbolizes.
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Hm, I ain't sure if that is what I am trying to achieve. The Reavers are supposed to spawn after 45 minutes, and only once. And if the Hero they would follow are dead, I am wondering to maybe set it to attack-move to a destination while waiting for the hero to resurrect.

And one more thing, the Reavers will almost constantly be stunned, immobilized, snared, silenced and all there is. Should I make a trigger give the attack command, and then loop it till 1 of the two units are dead?

(and is this the wrong forum? I haven't created the trigger yet, I need help from scratch.)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
If you want spawned reavers to lock onto a hero until it dies...
Create a list of players that are applicable targets. They should have a unit group to hold all the reavers that are assigned to kill that hero.
When you spawn a new reaver (from any spawn point), you randomly choose a player from the list and add it to the group for that player.
Every so often, a trigger loops through all players in the list and orders all reavers assigned to them to attack move towards their position.
When a player dies (no longer applicible target), you remove him from the list and randomly allocate his reavers to new players.
To prevent unfair selection due to randomisation (bad/good luck) you can also just cycle through the list an element per spawn.

+ No resting, all heroes will constantly be hunted once a reaver is assigned to stalk them.
- Reaver behaviour may be stupid including reavers aiming for players on other side of map from where they spawn to being allocated to hunt the player furthest away from them once a player is killed.
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Well, the maximum number of reavers on one player is one, as there will be one each.
I was thinking dedicating reavers to players, as in reavers spawning from point A (two from each of 4 points) will go for player 1 & 5, Reavers from B -> 2 & 6 and so on. How would I do that?

And said death check, is that what you wrote earlier in this thread?
 

Esa

Esa

Level 4
Joined
Nov 10, 2010
Messages
79
Ok, I've written my first tests. I haven't tried it yet, I thought that I'd upload it here before I did that, to hear your thoughts.
Heroes are upon initial spawning placed in their respective unit group, which I have referred to as "TestChased[PlayerNumber]". When "SmallReaverTimer" reaches it's end, Reavers will spawn and attack 1 hero each, and focus on doing ONLY that, even if stunned and so on. There exists 4 spawn locations, which can spawn 2 reavers each with 2 seconds delay. (meaning 4 spawn at a time.)

I've placed the created reavers from the eastern spawn point into the first group, and assigned them the first group for heroes (which should be player 1).

And, if the heros group is empty, the said reaver will spawn, but be paused. I can imagine a problem if two units spawn on top of each other, how can I prevent this? Can I make the first unit spawn by an offset, and another unit spawn by the opposite offset?

  • Spawn
    • Events
      • Time - SmallReaverTimer expires
    • Conditions
      • (TestChased[1] is empty) Equal to False
    • Actions
      • Set Temp_Point = (Center of Dark Reaver East Spawn <gen>)
      • Unit - Create 1 Dark Reaver for Player 10 (Light Blue) at Temp_Point facing 0.00 degrees
      • Unit Group - Add (Last created unit) to TestChaser[1]
      • Custom script: call RemoveLocation (udg_Temp_Point)
  • Attack
    • Events
      • Unit - A unit enters Dark Reaver East Spawn <gen>
    • Conditions
      • ((Entering unit) is in TestChaser[1]) Equal to True
      • (Dark Reaver East Spawn Layer <gen> contains (Triggering unit)) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (All units of TestChaser[1] are in Dark Reaver East Spawn <gen>) Equal to True
          • (TestChased[1] is empty) Equal to False
        • Then - Actions
          • Unit Group - Order TestChaser[1] to Attack (Random unit from TestChased[1])
        • Else - Actions
          • Unit - Pause (Entering unit)
          • Unit - Make (Entering unit) Invulnerable
Ok, go ahead. I'd love tips about this.
 
Last edited:
Status
Not open for further replies.
Top