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

How to make units travel in diff. directions

Status
Not open for further replies.
Level 39
Joined
Feb 27, 2007
Messages
5,013
Make a dummy unit in the OE with the right model for the arrow. Give it the ability 'locust', which makes it untargetable and unselectable. When you want to make an arrow, create one of the dummy units for the right player facing the right direction. To move it (periodically in some sort of loop probably) use:
  • Set Temp_Point = <some point, however you get it>
  • Unit - Move <arrow unit> to Temp_Point
  • Custom script: call RemoveLocation(udg_Temp_Point) //write udg_ plus your variable name, capitalization matters, use _ for spaces
The above clears the point leak that would naturally occur if you did something like "Center of (Playable map area)". For damaging you will have to use the "cause unit to damage unit" function on groups, and clearing their leaks is similar. We use DamagedGroup to keep track of which units have already taken damage from the spell and don't pick them again.
  • -------- When the spell is first cast --------
  • Unit Group - Clear DamagedGroup
  • -------- In the periodic move trigger --------
  • Set TempGroup = Units within R of TempPoint matching (Matching unit is not in group TempGroup) equal to true AND (matching unit is an enemy blah blah...)
  • Unit Group - Pick every unit in TempGroup and do (actions)
    • Loop - Actions
      • Unit - Cause <arrow unit> to damage (picked unit) for D damage of attack type Spells and damage type Normal
      • Unit - Add (picked unit) to DamagedGroup
  • Custom script: call DestroyGroup(udg_TempGroup)
If you are not going to be saving the group to use later you can instead do:
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick all units within R of TempPoint matching (Matching unit is not in group TempGroup) equal to true AND (matching unit is an enemy blah blah...) and do Actions
    • Loop - Actions
  • -------- Nothing else to do, it cleans itself up automatically --------
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
If you tried for even 15 seconds you would know what you have to do. But yes, polar offset since you know a starting point (the caster's position) and a target angle (either angle to the target point or just the facing angle of the caster).
 
Status
Not open for further replies.
Top