- Joined
- Aug 2, 2006
- Messages
- 19
How do u make a unit normally use a ranged attack and if the enemy is within say like 50 range, it do melee attack instead? Btw plz refer me to sumwhere else if this question had been answered some where ele.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
you can use the 2 attacks option and simply give the ranged attack a min range of say 75ish doing this with say a melee model with added effects to the ranged attack should give you the desired effects
Melee

Events


Unit - A unit Is attacked

Conditions


(Unit-type of (Attacked unit)) Equal to Rifleman Elite (ranged)


(Distance between (Position of (Attacking unit)) and (Position of (Attacked unit))) Less than or equal to 250.00

Actions


Custom script: local integer udg_count=1


Unit - Add Chaos (Rifleman Melee) to (Attacked unit)


Custom script: loop


Custom script: exitwhen udg_count==0


Set count = 0


Player Group - Pick every player in (All enemies of (Owner of (Attacked unit))) and do (Set count = (Number of units in (Units in (Region centered at (Position of (Attacked unit)) with size (400.00, 400.00)) owned by (Picked player))))


For each (Integer A) from 1 to 12, do (Actions)



Loop - Actions




If (All Conditions are True) then do (Then Actions) else do (Else Actions)





If - Conditions






((Player((Integer A))) is an enemy of (Owner of (Attacked unit))) Equal to True





Then - Actions






Set count = (count + (Number of units in (Units in (Region centered at (Position of (Attacked unit)) with size (400.00, 400.00)) owned by (Player((Integer A))))))





Else - Actions


Wait 1.00 seconds


Custom script: endloop


Unit - Add Chaos (Rifleman Ranged) to (Attacked unit)