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

Random raid

Status
Not open for further replies.
Level 12
Joined
Jun 1, 2010
Messages
747
Some triggers do not work in my map when I made them. I need to have a raid, example a Centaur horde. I want the Centaurs to move to random point in Playable Map Area with time elapsed 30. I do not know how to trigger to move them, on action: with unit group or what?

I mean random as random point in map, they all randomly migrate to one point.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
This would make all footmen attack random point.
  • Untitled Trigger 036
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman))) and do (Actions)
        • Loop - Actions
          • Set point = (Random point in (Playable map area))
          • Unit - Order (Picked unit) to Attack-Move To point
          • Custom script: call RemoveLocation(udg_point)
 

noj

noj

Level 4
Joined
Jan 16, 2006
Messages
89
This would make all footmen attack random point.
  • Untitled Trigger 036
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman))) and do (Actions)
        • Loop - Actions
          • Set point = (Random point in (Playable map area))
          • Unit - Order (Picked unit) to Attack-Move To point
          • Custom script: call RemoveLocation(udg_point)

This trigger appears to me, that each foorman will attack a differeant random location, because a random location is set each time the loop is run.
To fit his needs move this after the loop:
Custom script: call RemoveLocation(udg_point)

And this before it:
Set point = (Random point in (Playable map area))
 

noj

noj

Level 4
Joined
Jan 16, 2006
Messages
89
What do you mean by loop? Do you mean unit group?

Yes:

Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman))) and do (Actions)
Loop - Actions

It processes the code within the loop for each unit individually, not as a group.

Edit: example
Code:
Set point = (Random point in (Playable map area))

Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman))) and do (Actions)
 Loop - Actions
 Unit - Order (Picked unit) to Attack-Move To point

Custom script: call RemoveLocation(udg_point)
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Set point = (Random point in (Playable map area))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Centaur Drudge) and ((Owner of (Matching unit)) Equal to Neutral Hostile))) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To point
      • Custom script: call RemoveLocation(udg_point)
 
Honestly leaks don't make big problems these-days, sometimes we make them on purpose (in GUI mostly).
But it would be really great if you reduce them or remove completely in systems (that are used by few players or few times in game), great loops and timers (like each 0.03 sec do something or unit/player groups).
Also spells should be leak free as well.

RPG or AOS types of maps should be leak free because those games can last long and usually run long scripts in background (especially if you use GUI that is by default converted to jass).
But some mini games can have few leaks.

This above, is related to map section!
Spell section require clean code!
 
Status
Not open for further replies.
Top