SC2Mapster Forums

Development > Triggers

Very Simple traceline (Unit is Highlighted)

  • 6 posts
    #1 Dec 01, 2012 at 19:35 UTC - 1 like

    Ever notice that when your mouse hovers over a unit, it changes from a pointer to a box. This is event is known as "Unit is Highlighted."

    So, besides for a few special cases, we can make a traceline that detects collision with units, collision with doodads and collision with terrain, all in one, very simple function.

    Ready?

    Event - Unit is Highlighted

    Set TraceTarget[unit variable] = Triggering unit

    -----------------

    Event 2 - Unit is Unhilighted

    Set Trace Target = No unit

    -----------------

    When shooting your weapon:

    Event 3 - [Player shoots their weapon]

    If/Then/Else- If: Tracetarget is NOT equal to No Unit

    Then: Order[weapon unit] to attack Trace Target

    Else: Create a Dummy Unit at (Point - Position of Camera) offset by Distance(Cosine(Pitch of Camera) towards (Yaw of Camera degrees)

    Set Last created unit Height to { Distance(Sine(Pitch of Camera)) - [Ground Height at Position of Dummy Unit - Ground Height at Position of Player Camera] + Height Offset of Player Cam }

    Else (same else): Set TraceTarget = Last Created Unit

    Else(same else): Order[weapon unit] to attack Trace Target

    --------------------

    Congratuations, You Won!

    (don't forget to have a system that deletes the dummy units after a particular time expiration)

    Each unit in the data editor has the flag "Cannot be Highlighted" be default. So every unit you intend to use (that can be shot at) needs to have this unchecked in Unit Flags.

    Last edited Dec 01, 2012 by EdwardSolomon
    #2 Dec 01, 2012 at 20:00 UTC - 1 like

    @EdwardSolomon: Go

    One obstacle remains: If they player holds their left click down, in an attempt to select something, the highlight function becomes disabled until they release their left click, hmm how to fix?

    Solution 1:

    Do not use mouse event Left Click for shooting. Use Right click

    Make your Left Click the special fire ability, perhps some sort of projectile with slow a slow rate of fire, this way your player won't hold the Left Mouse down for more than a split second.

    Last edited Dec 01, 2012 by EdwardSolomon
    #3 Dec 02, 2012 at 01:14 UTC - 0 likes

    genius...

    #4 Dec 19, 2012 at 09:21 UTC - 0 likes

    So close to my system) Thanks for this tutorial!

    BTW - for highlight state i use trigger, that turn on highlight state on all units every 2 seconds :D

    PS: One request, please! Could someone create a blank map with a trigger for these lines? :

    --

    Else: Create a Dummy Unit at (Point - Position of Camera) offset by Distance(Cosine(Pitch of Camera) towards (Yaw of Camera degrees)

    Set Last created unit Height to { Distance(Sine(Pitch of Camera)) - [Ground Height at Position of Dummy Unit - Ground Height at Position of Player Camera] + Height Offset of Player Cam }

    ---

    Last edited Dec 22, 2012 by iWaNN

    http://images.gameru.net/image/direct/aa6e573f5b.gif
    Milk for the Khorne Flakes!

    #5 Feb 08, 2013 at 11:39 UTC - 0 likes

    No one can help? Ehh... :(

    #6 Apr 21, 2013 at 09:28 UTC - 0 likes
    Quote from iWaNN: Go

    No one can help? Ehh... :(

    I was on Starcraft 2 vacation, now I'm back, what's up?

  • 6 posts

You must login to post a comment. Don't have an account? Register to get one!