SC2Mapster Forums

Resources > Tutorials

[Tutorial] Lagless WASD System using Data Editor

  • on Thu, 02 Sep 2010 02:24:50

    Fact 1: Delay for hotkey in battlnet is less then delay for detecting key pressed event

    Fact 2: WASD based on trigger is lagging as hell

    ==> Combined: Thread Title

    Updates:

    Set your keyboard repeat delay value to shortest.

    Then lower the value in the offset persistent (from 2 to 1) to get a more responsive system when you release the key.



    Special thanks to prozaicmuze for his tutorials about switch effect and issue order effect. ( All hail the mighty Muze). Thanks to molsterr for testing on battlenet.

    Cons, read this before deciding to use

    • The UI has to be shown in order for hotkey to works. You can put some dialog on top of them. It doesnt matter
    • The current system for 4 ways is rushed out to get the idea. It can be improved further to have better movement or implementation.
    • The system for 8 ways is still in development
    • The 4 ways system is using absolute offset for unit. Another version for offset based on unit facing for FPS map will be developed.
    • Lag go away but delay is not guaranteed. However, noticeable delay decreases noticed compared to trigger based. Local testing show no delay and no lag.
    • Credits Progammer and promote sc2mapster in your map if you used this system (ok not really a con but just put it here for now )

    Pros

    • Reduce workload for trigger, less lag
    • Noticeable delay decreases noticed compared to trigger based. Local testing show no delay and no lag.
    • Further increase findings and showcase of data editor's abilities
    • Make our dreams of FPS come true.


    Note: In here or in the map, I used L R U D interchangeable for left right up down, some name in here is named Left but instead L in the map

    Another Note: Tutorials is covered by logic behind making the systems. Read all the comments to understand how it work.

    4 Ways WASD System

    Effects Tab

    • Create a new Effect named Move To (Issue Order) with Effect Type: Issue Order
      • set Ability: Move
      • set Player +: Source
      • set Target +: Target Point (target of the abilities)
      • set Unit +: Source (source unit of the effect, in this case, the stalker)

    This is the effect that will order the move command to the unit. The target point will be passed by another effect before it. This is the bread of the system

    • Create a new Effect named Move Offset Up (Persistant) with Effect Type: Create Persistent
      • set Effect - Expire: Move To (Issue Order)
      • set Location: Source Unit ( where the effect occurs)
      • set Target - Offset - Expire: (0,2) ( offset coordinate for upward position)

    This is the effect that create an offset point for the above issue order effect. The number 2 value should be adjusted accordingly to your unit size and speed. If you're using normal units in sc2, leave it at that.

    • Duplicate the above effect 3 times and name it Move Offset Left/Right/Down (Persistant) , change offset value accordingly

    Let's jump to Behavior Tab for a moment. We will get back to Effects

    • Create a new Behavior named Moving Up with Behavior Type: Buff
      • set Behavior - Categories: Temporary
      • set Effect - Initial: Move Offset Up (Persistant)
      • set Duration: 0.5
      • set Maximum Stack Count: 1

    This is the behavior that will be applied to the unit. When its first applied, your unit will be ordered to move accordingly. Time out after 0.5 seconds to make sure unit will be stopped when no key pressed.

    • Duplicate the Behavior 3 times and name it Moving Down/Left/Right . Change the Initial Effect accordingly.

    Validators Tab

    • Create a new Validator named Is Moving Up with Type: Unit Compare Behavior Count
      • set Behavior: Moving Up
      • set Compare: Equal To
      • set Unit: Source (again, this refer to source of the effect)
      • set Value: 1
    • Duplicate the Validator 3 times and name it Is Moving Down/Left/Right . Change the Behavior accordingly.

    Now we have the validator to check whether your unit should be heading L/R/U/D

    Button Tab

    • Create a new Button named Move Up
      • set Hotkey: W (this is the up key you will press)
      • set Icon: whatever ... (I use imported ones)
      • set Tint by Race: depends on the above, tint the color green if race is terrant etc...
    • Duplicate the Button 3 times and name it Move Down/Left/Right . Change the Hotkey accordingly.

    Now we back to Effects Tab

    • Create a new Effect named Apply Move Up Behavior with Effect Type: Apply Behavior
      • set Behavior: Moving Up
      • set Count: 1
      • set Target +: Target Point (target of the abilities)
      • set Unit +: Source
    • Duplicate it 3 times and make changes accordingly. You know how to this time

    Now we have the effect that will apply those behavior we created before that mark which direction the unit is moving

    • Create a new Effect named Remove All Temp with Effect Type: Remove Behavior
      • set Behavior Categories: Temporary (this will remove all behavior marked as temporary, no need to specify which behavior below)
      • set Unit +: Source

    Now we have the effect that will destroy all behavior that is not needed

    • Create a new Effect named Move Up (Set) with Effect Type: Set
      • set Effects: Remove All Temp + Apply Move Up Behavior (Add 2 effects to this field. Order does matter )
      • set Target Location Type:Unit
    • Duplicate it 3 times and make changes accordingly. You know how to this time

    Set effect is usually used when you want to combine multiple effect at once (at least that's how it has been used mostly). You have an effect that will remove all existing behavior and apply a new one.

    • Create a new Effect named Switch Direction 4 Ways with Effect Type: Switch
      • set Cases+: Add 4 cases to this field
        • Case 0 > Move Offset Up (Persistent) | Is Moving Up
        • Repeat the same with case 1,2,3 and change accordingly
      • set Target Location Type:Unit

    This is a switch effect that determine which behavior is on the unit and apply an effect to move it accordingly

    Now we back to Behavior Tab. Effect Tab is done

    • Create a new Behavior named Constant Movement with Behavior Type: Buff
      • set Behavior - Categories: Temporary
      • set Effect - Periodic: Switch Direction 4 Ways
      • set Period: 0.1
      • set Flags: Hidden (notice I didn't hide the other behavior for testing purpose)

    Now we have the behavior that act like a periodic trigger that move unit based direction it should be moving

    Almost there, Abilities Tab

    • Create a new Abilities named Move Up with Type: Effect - Instant
      • open Commands+:, set Execute default Button to Move Up
      • set Effect: Move Up (Set)
      • set Period: 0.1
      • set Flags: Transient (this is the most important part for an abilities to be cast without pausing the unit)

    Cooldown for abilities will be defaulted to 0

    • Duplicate it 3 times and make changes accordingly. You know how to this time


    Finally, Unit Tab

    Pick whatever unit you want to apply the system to. I'm using a stalker

    • Select the Stalker
      • open Abilities + and add Move Up, Move Down, Move Left, Move Right
      • open Command Card + and add 4 ability buttons. Remove everything else, most importantly Attack for conflicting hotkeys. Link to abilities correctly
        • (Button: [NAME]; Command Type: Ability Command; Ability: [NAME]; Ability Command: [NAME])

    open Behavior + and add Constant Movement (don't forget this)

    Now we have a stalker with WASD movement.



    8 Ways Movement System

    I will not provide a tutorial for this one since its based on the 4 ways system and the second method is still buggy.

    • Method 1: Adding 4 additional button for moving in 4 diagonal directions. Add four more effect/validator/behavior accordingly. Don't forget the diagonal offset and additional switch cases
    • Method 2 (advanced): Using only current 4 button, adding more behavior/validator to indicate direction. Use combine validator. Remove specific behavior instead of all. Buggy since no 2 abilities button can be hold down at the same time. Attached in the map is the 8 ways system ready but not linked properly.


    Feel free to use the attached Map or contact me via forum post, PM or IRC if you encounter problems. Keep in mind that I'm also a busy person so I may not reply right away, but I'll do my best to answer all questions/concerns that I am aware of :)

    (format cortesy of ProzaicMuze)

    Last edited on 04 Sep 2010 by progammer
    Name Size MD5
    wasd.SC2Map 28.5 KiB b219793dac42...
  • 6 hours later (on Thu, 02 Sep 2010 08:45:52)

    If you keep pressing a key, will the unit keep moving with this system?

  • 7 minutes later (on Thu, 02 Sep 2010 08:53:35)

    @vjeux: Go

    Will, since the abilities is transient. No interrupt to movement

  • 3 minutes later (on Thu, 02 Sep 2010 08:56:36)

    @progammer:

    Wow great work.

  • 118 minutes later (on Thu, 02 Sep 2010 10:54:52)

    I made a 4 way button press via data + triggers (data in the sense that he casts a spell and I use that as an event) and from what I can tell, it doesn't lag any either. The best way I can think of making an 8 way via my method would be to make the W and S a toggle while the A and D are for changing the angle of your unit. I think this wont really be interrupting the nature of moving at all, but it would take some getting used too. I'm thinking there may be a way to reduce the transparency or something similar of the ui that you must keep up via the galaxy editor. Wc3 had custom skins and things for the ui, I'm not positive how they worked, but couldn't someone just replace all the ui with nothing?

    Last edited on 02 Sep 2010 by Skittles17

    I'm very sweet, very colorful, very delicious. What am I? I am pooped by unicorns. Skittles is the name, you eat me daily (or should).

  • 13 minutes later (on Thu, 02 Sep 2010 11:08:25)

    @Skittles17: Go

    Thats sounds nice and relativ easy. The Main Problem is in my opinion not a third person view, it is a intelligent Camera Movement. In a FPS its bad when your cam move in a wall. I created a "dummyboy" a invisible unit fixated to my Real Playerunit. The Follow cam is fixated on the dummy and with waypoint length measurments i can check cliffs and other objects. When a object is in the way the dummy have a new position in relation to the Real Player.

  • 42 minutes later (on Thu, 02 Sep 2010 11:50:54)
    Quote from Skittles17: Go

    I made a 4 way button press via data + triggers (data in the sense that he casts a spell and I use that as an event) and from what I can tell, it doesn't lag any either. The best way I can think of making an 8 way via my method would be to make the W and S a toggle while the A and D are for changing the angle of your unit. I think this wont really be interrupting the nature of moving at all, but it would take some getting used too. I'm thinking there may be a way to reduce the transparency or something similar of the ui that you must keep up via the galaxy editor. Wc3 had custom skins and things for the ui, I'm not positive how they worked, but couldn't someone just replace all the ui with nothing?

    The problem with that is you cannot detect a key up event, just key down is registered when you activate that abilities. If you decided to use the hold down button method as mine, you probably need a periodic trigger of 0.1s. periodic effects can be set to 0.01s with no lag

  • 3 hours later (on Thu, 02 Sep 2010 15:05:05)

    Awwe, I was working on this exact same idea. But I noticed you have a similar issue that I have.

    If you tap a directional button the unit moves but does not stop, travels his entire little distance.

    This is what kept me from posting the idea.

  • 47 minutes later (on Thu, 02 Sep 2010 15:52:05)

    @Lilianna: Go

    I have lagless WoW movement for a while now ^_^, I'll release it in a little bit with my map.

    Nice just OP tho.

    Last edited on 02 Sep 2010 by halfthought
  • 9 minutes later (on Thu, 02 Sep 2010 16:01:22)

    @progammer: Go

    I have 2 questions. One - this looks like you have to have those buttons on your command card correct? and two - if you disable your UI for your map and recode it, this won't work right?

  • 21 minutes later (on Thu, 02 Sep 2010 16:22:44)

    @drummerboy1151: Go

    He says this at the very top lol

  • 9 minutes later (on Thu, 02 Sep 2010 16:31:45)
    Quote from drummerboy1151: Go

    @progammer: Go

    I have 2 questions. One - this looks like you have to have those buttons on your command card correct? and two - if you disable your UI for your map and recode it, this won't work right?

    Quote from Molsterr: Go

    @drummerboy1151: Go

    He says this at the very top lol

    My theory is that big bright yellow letters cause a sudden synaptic shock in the readers' brain so that they're unable to read and process the information properly. At the same time the bright colors desensitize the reader so that the normal-sized and -colored text seem unimportant to the subconscious. It'll thus blind out the text and make the readers psychically unable to read the text. So it's not actually their fault.

    Tl;dr: Read the first post

    Back to da topic: That's pretty interesting, I didn't think you could set-up the abilities in a way it would not stop the movement after the effect has been applied once. But now when I think of it... even the melee game has such buttons in it >.< Using a different mover you can also rigg the pathing in a way they would stop trying to run around cliffs but instead try to move through them (which would fail). That would make the unit less jumpy when running against a wall.

    Last edited on 02 Sep 2010 by s3rius
  • 38 minutes later (on Thu, 02 Sep 2010 17:10:00)

    @halfthought: Go

    I posted a Behavior based 8 way movement last week, I was just unhappy with the workings of Abilities to warrant making it completely triggerless.

    I did test and make something that would cast and continue to cast as long as someone held a button, but That felt clunky and weird, as well as when you release the button, the unit continues to move that way until the Movement effect wears off.

  • 48 minutes later (on Thu, 02 Sep 2010 17:58:14)

    Why not set all the durations to 0.0 to get the minimum time-step of 1/32.

    Then just make the target offset something small like (0,0.1)

    I think it would fix that problem of having the unit continue to move forward even after releasing the move button.

    This method would rely on being able to just hold down the "w" button to reissue the command every time-step, but it sounded like that is what is happening.

  • 11 minutes later (on Thu, 02 Sep 2010 18:10:07)

    @Mathhole: Go

    A buff duration of 0.0 is Infinite/No Duration.

    Also, adjusting buff duration/ steps might be problematic based on a units movement speed. So you would have to make it different with minor tweaks on every unit.

    Last edited on 02 Sep 2010 by Lilianna
  • 57 seconds later (on Thu, 02 Sep 2010 18:11:04)

    This really isn't a viable option, to many requirements and lack of flexibility.

    This was done with the WC3 editor using abilities to.

    Good idea, but actual usefulness isn't that high.

  • 43 minutes later (on Thu, 02 Sep 2010 18:54:04)

    Still very cool to see... let's hope Blizz works on the trigger version's laggyness hehe.

    SC2 video tutorials: http://www.youtube.com/onetwosc

  • 22 minutes later (on Thu, 02 Sep 2010 19:16:18)
    Quote from s3rius: Go

    @drummerboy1151: Go

    @Molsterr: Go Back to da topic: That's pretty interesting, I didn't think you could set-up the abilities in a way it would not stop the movement after the effect has been applied once. But now when I think of it... even the melee game has such buttons in it >.< Using a different mover you can also rigg the pathing in a way they would stop trying to run around cliffs but instead try to move through them (which would fail). That would make the unit less jumpy when running against a wall.

    I can add more validator to check cliff level and such. And remember, this is just a beta system. The data editor is more powerful than you can think.

  • 93 minutes later (on Thu, 02 Sep 2010 20:50:17)

    @progammer: Go

    Actually no, if I hold my key down then it keeps casting the spell again and again and again. And with the 8 way thing I was talking about having the W and S as a toggle, so yeah a toggle would be a while loop, but you can have a lot of stuff going on with the sc2 engine then you probably think. =D

  • 20 hours later (on Fri, 03 Sep 2010 17:44:25)

    Nice work and keep at it. I look forward to seeing the 8 way system. Its more responsive than my trigger based system. I give you props good sir. Is it possible to register when 2 keys are pressed simultaneously in the data editor?

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