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

Ordering Units to bombard Points

Status
Not open for further replies.
Level 3
Joined
Nov 15, 2012
Messages
32
Hello again Hive, it's me and my random question again

I'm doing a random game where a Red Team fighting against a Blue Team in 1-lane war
each team have the same number of footmens and archers, the Red Team have a slight unit advantage while we play a commanding hero for the Blue Team

enough with the map introduction, the problem rise with the archers: each of them always target the same targets!
either the footmens are killed in a volley of 16 arrows or the hero got hurt severely...
I tried to tend the problem by changing the archers type of attack into non-homing artillery which makes the attack dodgeable, but: computer never dodges!



so here's the idea: I want to make each of the archers to recognize a random foe as their target and shoots into a point nearby its target

and why don't I try to make it myself: thinking how to make such system without any leak? I'd rather ask the specialist first how to do one
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
This one seems to work fine for me:
  • Archer Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Archer
    • Actions
      • Wait 0.00 seconds
      • Set RandReal = (Random real number between 0.00 and 150.00)
      • Custom script: set udg_TempLoc1 = Location(GetUnitX(GetTriggerUnit()) + udg_RandReal * Cos(GetRandomReal(0., bj_PI*2.)), GetUnitY(GetTriggerUnit()) + udg_RandReal * Sin(GetRandomReal(0., bj_PI*2.)))
      • Unit - Order (Attacking unit) to Attack Ground TempLoc1
      • Custom script: call RemoveLocation(udg_TempLoc1)
      • Wait 1.00 seconds
      • Unit - Order (Attacking unit) to Stop
The thing you might want to change is the RandReal.
It's the offset at which the archer might miss (in this trigger, somewhere between 0 and 150 points off-target).

  • Archer Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Archer
    • Actions
      • Custom script: local location udg_TempLoc1 = Location(GetUnitX(GetTriggerUnit()) + GetRandomReal(0., 150.) * Cos(GetRandomReal(0., bj_PI*2.)), GetUnitY(GetTriggerUnit()) + GetRandomReal(0., 150.) * Sin(GetRandomReal(0., bj_PI*2.)))
      • Wait 0.00 seconds
      • Unit - Order (Attacking unit) to Attack Ground TempLoc1
      • Custom script: set udg_TempLoc1 = null
      • Custom script: call RemoveLocation(udg_TempLoc1)
      • Wait 1.00 seconds
      • Unit - Order (Attacking unit) to Stop
 
Last edited:
Level 3
Joined
Nov 15, 2012
Messages
32
I see.. so we're interrupting the attack instead of ordering them to?

but this way, won't they still targeting the same 1 target instead of attacking different target?
should I pick a random unit in playable area owned by the Red Team and get it's location instead? that looks like a leaking problem for me :/

I'm also wondering.. what does Wait 0.00 seconds do? @__@
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I see.. so we're interrupting the attack instead of ordering them to?
No, you order the unit to attack a certain location (somewhere near the actual target).
Then, you order him to stop. This is so he will acquire a new target, instead of attacking the same location over and over (the enemy has probably already moved by then).

I'm also wondering.. what does Wait 0.00 seconds do?
It's because otherwise it doesn't work (the unit won't attack the location).

Uploaded a test-map. Hope that clears things up :).
 

Attachments

  • ArcherAttack.w3x
    17.3 KB · Views: 41
Level 3
Joined
Nov 15, 2012
Messages
32
tested it, it's really close to what I wanted!
there's still a small problem thought, when I separate the footmen into 5 position and hold their position the archers still keep on focusing into 1 footmen...
is there at least a way to limit how many archers are going to gang on 1 target?

*edit
nvm, I've found the limit attackers system at spell section, with your trigger combined with this system I can do just fine
thanks for your help :D

*edit #2
actually not yet, the archers just stopped... they didn't bother to find other footmens to attack...
 
Status
Not open for further replies.
Top