The other day, I posted about the ability to display the attack range of a selected unit. Though the code worked mostly properly, ModDB's Kerloc, being his helpful self pitched in on the idea and helped me to write a far superior version of the command.
Check it out:
Ping Range Events Player - Player 1 (Red) types a chat message containing range as An exact match Player - Player 2 (Blue) types a chat message containing range as An exact match Conditions Actions Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is selected by (Triggering player)) Equal to False)) and do (Actions) Loop - Actions Unit Group - Remove (Picked unit) from (Units currently selected by (Triggering player)) Unit Group - Pick every unit in (Units currently selected by (Triggering player)) and do (Actions) Loop - Actions Set SelectedUnitOrigin = (Position of (Picked unit)) Set SelectedUnit = (Picked unit) For each (Integer A) from 1 to 360, do (Actions) Loop - Actions Unit - Create 1 Circle of Power [effect] for Neutral Passive at (SelectedUnitOrigin offset by (Current acquisition range of SelectedUnit) towards (Real((Integer A))) degrees) facing 0.00 degrees Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
Now, when players type range into chat, a helpful ring will display the attack range of the currently selected unit. The unit "circle of power" is nothing more than the special effect model for the Paladin's Holy Light. The best part of this trigger, in my opinion, is the genius expiration timer following the unit's creation. The guarantees both that the special effect's are destroyed and that players will not break the code by requesting multiple range displays in short succession.
Sadly, however, in its present form, this code sometimes glitches. The glitch comes from the "remove units from selection" action, which, somehow, causes previously selected units to remain selected and to break all sorts of triggers essential to the functioning of my turn-based infrastructure. I think the glitch has to do with the lag in the game's recognizing of the presently selected unit. I'm currently working on solutions.
In the meantime, take a look at this stellar video of the display range command in action.