1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

[GUI-friendly] Movement Speed System 1.0.0

Submitted by _Guhun_
This bundle is marked as pending. It has not been reviewed by a staff member yet.
[GUI-Friendly] Movement Speed System v1.0.0

This system facilitates the modifcation of unit movement speed using the SetUnitMoveSpeed JASS native. The system itself keeps track of modifications to unit movement speed and allows for two types of modifications: bonus (additive) or multiplier (multiplicative). The system does not provide a way to clear bonuses. Instead, the user should keep track of bonuses that have been added and reduce the same amount when it is required.

Additionally, the system offers the possibility to set values for the minimum and maximum movement speed set by the system. These values, however, are still subject to the limits set by the movement Gameplay Constants, which you can edit in the Advanced menu of the World Editor.

There exists a vJASS system with similar functionality to GMSS: Movement Modifier. If you would like to freely alter unit stats, other than move speed, using triggers, check out the Custom Stat System.

Movement Speed:

The formula for unit movement speed is:
speed = (default speed * multiplier + bonus + other1)*other2

The "other" variables are movement speed bonuses offered by the object editor from abilities such as Unholy Aura and Item Movement Speed Bonus. Additive abilities such as the Boots of Speed contribute to "other1" while multiplicative abilities such as Endurance Aura contribute to "other2".

Hashtable addresses:
Positive Unit Handle ID -> Move Bonus
Negative Unit Handle ID -> Move Multiplier

How to Import:

1. Open World Editor. File -> Preferences -> Tick box for "Automatically create unknown variables (...)"
2.
a. If you don't use GUI Unit Event in your map, move the "GMSS Cleanup On Enter Map" trigger to the "GUI Move Speed System" category.
b. If you use GUI Unit Event in your map, move the "GMSS Cleanup On Removal" trigger to the "GUI Move Speed System" category.​
3. Copy the trigger category "GUI Move Speed System" into your map
4. If you want to use an existing hashtable instead of creating a new one, follow the instructions in the GMSS Init trigger
5. Done!​


Using the System:


  • With this system, each unit has it's own movement speed bonus (additive) and multiplier (multiplicative). This function allows you to either add a value to the bonus of a given unit and/or multiply its multiplier by another value. After you make a change, if you want to restore the unit's movement speed, simply reduce the bonus by the opposite amount and/or multiply the multiplier by the inverse amount.

    This function will also set the unit's speed to a value between the default limits of the system, which you can configure with the Configure Limits function.

    • Actions
      • Set GMSS_MoveBonus = YourBonus
      • Set GMSS_MoveMultiplier = YourMultiplier
      • Set GMSS_Target = YourUnit
      • Trigger - Run GMSS Main <gen> (checking conditions)


    After your run the "GMSS Main" trigger, the GMSS_MoveBonus variable will be set to the current total bonus of the unit and the GMSS_MoveMultiplier will be set to its current total multiplier.

  • This function is similar to Change Bonus/Multiplier, however, you can also specify the minimum and maximum value that the unit's movement speed can take after applying the change. You can also limit the unit's speed without changing the bonus or multiplier. To do so, simply set GMSS_Bonus to 0 and GMSS_Multiplier to 1 before running the trigger, while setting the limit variables to the values you wish.

    • Actions
      • Set GMSS_MoveBonus = YourBonus
      • Set GMSS_MoveMultiplier = YourMultiplier
      • Set GMSS_MinimumSpeed = YourMinSpeed
      • Set GMSS_MaximumSpeed = YourMaxSpeed
      • Set GMSS_Target = YourUnit
      • Trigger - Run GMSS Main <gen> (ignoring conditions)


    After your run the "GMSS Main" trigger, the GMSS_MoveBonus variable will be set to the current total bonus of the unit and the GMSS_MoveMultiplier will be set to its current total multiplier.


  • This function allows you to get the current bonus and multiplier of a unit. After you run the "GMSS Main" trigger, the values will be stored in GMSS_MoveBonus and GMSS_MoveMultiplier. The default bonus is 0 and the default multiplier is 1.

    • Actions
      • Set GMSS_MoveMultiplier = NegativeNumber
      • Set GMSS_Target = YourUnit
      • Trigger - Run GMSS Main <gen> (ignoring conditions)



  • When you select the "GMSS Main" trigger, you will find the following code:

    Code (vJASS):

    //===================================================
    //Easy configuration for GUI users
    //Just change these numbers to whatever you want, you can also set them to a variable (remember to put "udg_" in front of the variable)

    function GMSS_GetDefaultMaxSpeed takes nothing returns real

    return 522.0

    endfunction

    function GMSS_GetDefaultMinSpeed takes nothing returns real

    return 0.0

    endfunction

    //Advanced users who want more performance can instead edit the values in the "Trig_GMSS_Main_Conditions" function
    //End of Easy configuration
    //===================================================
     


    To configure the system's default limits, simply change the numbers 0.0 and 522.0 to whatever you need. You can also use a GUI real variable instead, and the system's default limits will be the values of the variables you set. Please note that, if you do this, the limit's will not be constant, since you can change the values of the variables.


  • You can use this system without changing the hashtable. If you have little experience with hashtables, you can ignore this method if you are unsure.

    Since this system only requires the usage of 1 Child Hashtable, it is not necessary to create a whole need Parent Hashtable for the system. Therefore, you can configure the system to use another hashtable instead of creating a new one, by changing the value of the GMSS_Hashtable variable. Please note that you need to make sure that the Child Hashtable of number equal to GMSS_HASHTABLE_ADDRESS is free and will not be written to except by the system.

    This is how the configurable part of the initialization trigger looks like:
    • Actions
      • -------- YOU DON'T NEED TO CREATE A HASHTABLE, YOU CAN USE ONE YOU ALREADY HAVE --------
      • Hashtable - Create a hashtable
      • -------- ------------------------------------- --------
      • -------- If you don't want to create a hashtable, delete the line above and set the value of the GMSS_Hashtable to that of another hashtable --------
      • Set GMSS_Hashtable = (Last created hashtable)
      • -------- ------------------------------------- --------
      • -------- This is the child hashtable used by the system. Make sure it has free addresses in the range of Unit Handle IDs --------
      • Set GMSS_HASHTABLE_ADDRESS = 0


    To use another hashtable, you would change it to this:
    • Actions
      • Set GMSS_Hashtable = YOUR_HASHTABLE
      • -------- ------------------------------------- --------
      • -------- This is the child hashtable used by the system. Make sure it has free addresses in the range of Unit Handle IDs --------
      • Set GMSS_HASHTABLE_ADDRESS = YOUR_FREE_CHILD_HASHTABLE_NUMBER


    Please note that YOUR_HASHTABLE must have been created before GMSS_Hashtable is set to it. If GMSS_Hashtable is not properly initialized, the system will throw an error when the "GMSS Init" trigger is run. If this happens, you may need to put the line below in another trigger (the one where YOUR_HASHTABLE is created), or change the Event of the "GMSS Init" trigger so that it fires after the hashtable is created.

    • Set GMSS_Hashtable = YOUR_HASHTABLE



  • The system is built so it can also be used by calling JASS functions.To use the JASS API, simply move the code between the following tags from the "GMSS Main" trigger to your map header after importing the system. GUI users that want to use Custom Scripts can also follow this guide.

    Code (vJASS):

    //////////////////////////////////////////////////////
    //Guhun's Move Speed System v1.0.0
    //-----------------------------------
    //Copy from here to the "End of Move Speed System" label to use JASS API
    //Hashtable addresses:
    //Positive Unit Handle ID > Move Bonus
    //Negative Unit Handle ID > Move Multiplier
    //////////////////////////////////////////////////////
    CODY TO COPY TO YOUR MAP (I recommend including the comment tags above and below)
    //////////////////////////////////////////////////////
    //End of Move Speed System
    //////////////////////////////////////////////////////
     


    Provided functions:
    Code (vJASS):

    //Adds "amount" to unit speed bonus and sets unit speed between "minSpeed" and "maxSpeed"
    function GMSS_UnitAddMoveSpeed takes unit whichUnit, real amount, real minSpeed, real maxSpeed returns real

    //Multiplies unit move multiplier by "amount" and sets unit speed between "minSpeed" and "maxSpeed"
    function GMSS_UnitMultiplyMoveSpeed takes unit whichUnit, real amount, real minSpeed, real maxSpeed returns real

    function GMSS_UnitGetMoveBonus takes unit whichUnit returns real

    function GMSS_UnitGetMoveMultiplier takes unit whichUnit returns real
     





Test Map:

Command Action
add x add x stacking bonus to unit movement (can be negative)
mul x multiply unit movement by x stacking
get show unit move speed
mod show unit move bonus and multiplier

The Test Map is currently very simple, featuring only a few hero units (including DK for Unholy Aura and TC for Endurance Aura) and two boots of speed. To test the system, use the above commands.



Updates and Version History:
v1:
1.0.0 > Initial Release​
Upcoming:
Better testmap with more examples and use cases.​
Contents

Guhun's Movement Speed System (Map)