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

[General] Increase the likelihood of ranged units attacking each other

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
tl:dr - How can I make ranged units attack other ranged units more often? (instead of always attacking melee first)

You know how in dota style games (AoS / moba) units from successive creep waves, especially ranged ones, stack up and accumulate over time?

I'm currently playing around with a pretty high spawn rate, units generally spawn faster than they'll die up to a certain point, and this leads to higher proportions of ranged units over time, even though there's spawning a lot less they simply don't die until the end so if it goes on long enough there's eventually more ranged than melee units.


The reason they're not dying is because the creep-waves are simply attack moving and thus they'll attack the first best enemy unit along the way, that means the ranged units are practically always the last to die.

What I want is to increase the likely hood for ranged units to attack each other, ideally ranged units would have a farther acquisition range towards other ranged units.

What are my options? And how feasible are they?
 
Level 12
Joined
May 22, 2015
Messages
1,051
I know of one janky one that was a bug in my map for a long time lol. If you give units the fortified armour, they are prioritized last. If you gave the melee units fortified armour, they will be ignored until the ranged units are dead. The melee units might run past each other, though, and if it's an actual moba, the attack move for heroes will also prioritize the ranged units lol. Probably not what you want, but it is the only thing I can think of without using triggers to have a basic AI to help out with it.
 
Level 12
Joined
Nov 3, 2013
Messages
989
Yeah, the fortified armor didn't work so well, melee units aren't supposed to completely ignore each other to kill the ranged units first.


I've also tried giving ranged units two attacks, one with short range that only target organic, and a second one that only target mechanical, with ranged and caster units having the mechanical classification.

It's working fairly well, a bit stupid to shoot farther only against other ranged units but it's a game so whatever, especially in the middle (I made the test map 1v1v1) but I'm not so sure I like the idea of limiting myself with the classifications.

I could use Ancient or Suicidal instead, but again I'd rather not waste them if I can help it since they can be very useful.

and if anyone's interested here's the test map:
 

Attachments

  • 3 way AoS.w3x
    26.8 KB · Views: 34

sentrywiz

S

sentrywiz

You could use the event "Unit is attacked" to perform some checks if the unit is melee/range and respond in some way.
 
Level 12
Joined
Nov 3, 2013
Messages
989
You could use the event "Unit is attacked" to perform some checks if the unit is melee/range and respond in some way.

Is there a system for something like this?

I tried something similar (each time the units attacked I would check for units within range and compare their HP to select the unit with the least HP as the new target) in another map but what happened was that the units would stand still for roughly a second before attacking.


I think that it might have to be a system that create/destroy triggers with added "specific unit - unit acquires a target" events instead of "generic unit- a player unit is attacked".

But it could just be that I did it wrong as well...

  • attack nearby lowest health
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacking unit)) Not equal to (Triggering player)
    • Actions
      • //Trigger - Turn off (This trigger)
      • Set tempUnit = (Triggering unit)
      • Set tempUnit2 = (Attacking unit)
      • Set tempPoint = (Position of tempUnit2)
      • Set tempReal = (Life of tempUnit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 100.00 of tempPoint matching (((Matching unit) belongs to an enemy of (Owner of tempUnit2)) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set tempUnit3 = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of tempReal) Less than tempReal
            • Then - Actions
              • Set tempReal = (Life of tempUnit3)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_tempPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempUnit Not equal to tempUnit3
        • Then - Actions
          • Game - Display to (All players) the text: New Target!
          • Unit - Order tempUnit2 to Attack tempUnit
        • Else - Actions
          • Game - Display to (All players) the text: Same Target!
      • //Trigger - Turn on (This trigger)
Issuing order attack after the event a unit is attacked simply doesn't seem to work properly for me.

p.s. it came to my mind that it's similar to how you have to have 0 duration timer or wait sometimes so I tried it with a wait, and it worked, kind of, but it obviously messed up with the global variables.

So I guess I'd still need a system like a unit indexer to make it work.
 
Last edited:

sentrywiz

S

sentrywiz

I was thinking something more like this:

  • test
    • Events
    • Unit - A unit Is attacked
    • Conditions
    • (Unit-type of (Attacking unit)) Equal to Your Ranged Attacker
    • Or - Any (Conditions) are true
    • Conditions
    • ((Attacked unit) is A ranged attacker) Equal to True
    • ((Attacked unit) is A melee attacker) Equal to True
    • Actions
    • Set z_loc1 = (Position of (Attacking unit))
    • Set z_loc2 = (Position of (Attacked unit))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Attacked unit) is A melee attacker) Equal to True
    • (Distance between z_loc1 and z_loc2) Greater than Some Range (ex. 150)
    • Then - Actions
    • -------- switch target, do something else here --------
    • Else - Actions
The logic behind this is to stop the attacking unit (the ranged unit) if the range between its location and the target it auto-acquires is some value. Like if the value is 150 or less which is near melee distance, then for example the ranged unit will continue to fire. If the value is greater, then you could order the ranged unit to pick a ranged attacker.

This is just a rough example though.
 
Level 12
Joined
May 22, 2015
Messages
1,051
You'll could try increasing the
Value: Stats - Priority (Integer)
of your Ranged Units in Object-Editor
this will make them more likly be first targets in combat, but it is rather inaccurate.
This stat is a trap. It actually just changes the order that the units appear when you have multiple different types of units selected. Higher priority will just put them closer to the start of the list. This makes sense for casters and other units with abilities. Other than that, it doesn't do anything.
 
Level 12
Joined
Nov 3, 2013
Messages
989
This stat is a trap. It actually just changes the order that the units appear when you have multiple different types of units selected. Higher priority will just put them closer to the start of the list. This makes sense for casters and other units with abilities. Other than that, it doesn't do anything.
Yeah, it's like those urban rumours that never go away and live on for years.

Some guy make some assumption on the helper dot net or whatever and voila half the community is misinformed for over a decade.

I was thinking something more like this:

The logic behind this is to stop the attacking unit (the ranged unit) if the range between its location and the target it auto-acquires is some value. Like if the value is 150 or less which is near melee distance, then for example the ranged unit will continue to fire. If the value is greater, then you could order the ranged unit to pick a ranged attacker.

This is just a rough example though and is full of leaks so don't copy paste it as is.

It turned out the real problem was that I needed a 0.00 second timer before issuing an attack order for the attacking unit.

Afaik I'd still have to use a hashtable or unit indexer to make the units attack move afterwards though.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Priority does change which units get targeted first. I have a map that's based on specifically exploiting that. However, there are many considerations:
1. Units without an attack always get prioritized less no matter what number you set them.
2. Units closer to you are prioritized if they're attacking something you're allied with(or you).
3. The priority thing only works within acquisition range. (In that map I had 99999 acquisition range on all units, thus why priority working the way I describe has such a large effect)
 
Level 12
Joined
Nov 3, 2013
Messages
989
Priority does change which units get targeted first. I have a map that's based on specifically exploiting that. However, there are many considerations:
1. Units without an attack always get prioritized less no matter what number you set them.
2. Units closer to you are prioritized if they're attacking something you're allied with(or you).
3. The priority thing only works within acquisition range. (In that map I had 99999 acquisition range on all units, thus why priority working the way I describe has such a large effect)
Oh really? I haven't ever tried it in depth, but from what I've been able to tell I haven't seen any noticeable difference.

Do you have that map? If it does work it's obviously better to have it than not.
 
Level 23
Joined
Oct 12, 2008
Messages
1,783
Call me insane, but Ive noticed armour type also seems to affect the chances of being attacked.
Large/Hero seems to take precedence over medium/light armour.

Neutral Hostile player also seems to behave differently from standard AIs.
 
Status
Not open for further replies.
Top