Manifest is a competitive, two-player, turn-based strategy mod for Warcraft III developed by Finn Haverkamp.

Report RSS Display Range Revision

A code revision of the previous post on displaying attack range.

Posted by on

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.

Post comment Comments
Kerloc
Kerloc

There is no need to manipulate the selection of a player!
CODE:

Ping Range
Events
Player - Player 1 (Red) types a chat message containing -range as a sub-string
Player - Player 2 (blue) types a chat message containing -range as a sub-string
Conditions
Actions
-------- ::: --------
-------- System made by Kerloc (CdW) --------
-------- 09.02.2010 --------
-------- made for: MANIFEST --------
-------- ::: --------
-------- ::: --------
-------- ::: --------
-------- ::: --------
Set Ping_Range_TMP_group = (Units currently selected by (Triggering player))
-------- ::: --------
Unitgroup - Pick every unit in Ping_Range_TMP_group and do (Actions)
Loop - action
-------- ::: --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)

'IF'-Condition
((Picked unit) belongs to an ally of (Triggering player)) equal to True
'THEN'-actions
For each (Integer A) from 1 to 360, do (Actions)
Loop - actions
Set Ping_Range_TMP_pkt = ((Position of (Picked unit)) offset by (Current acquisition range of (Picked unit)) towards (Real((Integer A))) degrees)
Unit - Create 1 Range_Marker for (Triggering player) at Ping_Range_TMP_pkt facing 0.00 degrees
Unit - Add a 3.00 second Standard expiration timer to (Last created unit)
Custom script: call RemoveLocation( udg_Ping_Range_TMP_pkt )
'ELSE'-Actions


-------- ::: --------
Custom script: call DestroyGroup( udg_Ping_Range_TMP_group )

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: