[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Spells


Reply
 
Thread Tools
The Hive Workshop Spells:
MoveSpeedX for GUI v1.1.0.0
Images
Highslide JS
Details
Uploaded:10:17, 24th Nov 2011
Last Updated:03:28, 12th Jul 2012
Keywords:move, speed, nitro, boost, movespeed, movespeedx, sprint, dash
Type:System
Category:vJASS, GUI / Triggers

Requires JassNewGenPack v5d and JassHelper 0.A.2.B!

This library allows you to set unit move speeds beyond the 522 limit. Special thanks to Jesus4Lyf for the base code. It has been modified from the normal MoveSpeedX to be compatible with GUI. While the system is in vJASS, you can simply use the GUI function to modify the speed and it will do the rest for you. To retrieve speed properly, you can use the global array named "UnitSpeedX". To retrieve it for a specific unit, it would be UnitSpeedX[Custom value of <unit>]. Note that you need a unit indexer for that to work properly.

It has some quirks with very high speeds (beyond ~1000) but otherwise it works perfectly.

*Note*: Please read the documentation.

System:
Jass:
library MoveSpeedXGUI /* v1.1.0.0
*************************************************************************************
*
*   This library allows you to set unit movement speeds beyond 522 without bugs.
*   This is an extension of the library MoveSpeedX, but is formatted for GUI use.
*   Credits to Jesus4Lyf for the original system.
*
************************************************************************************
*
*   SETTINGS
*/
globals
    private constant real PERIOD = 0.03125
        //  This is the period on which all units will be run.
        // If you lower this value, movement bonuses will be smoother,
        // but will require more processing power (lag more).
        //  Also, the lower this is, the higher the move speed can be
        // before it starts bugging on waypoints. The lowest valid
        // period is 0.00125. A period of 0.00625 is very robust.
    private constant real MARGIN = 0.01
        // This is the margin of approximation when comparing reals.
        // You will most likely not need to change this.
endglobals
/*
************************************************************************************
*
*    Functions
*
*        function GetUnitMoveSpeedX takes unit whichUnit returns real
*           - Returns a unit movement speed. The GUI function will
*           - not return the correct value. This function will always
*           - return the correct value regardless of whether the unit
*           - has a movement speed beyond 522.
*
************************************************************************************
*
*   REQUIREMENTS
*
*       1.  JassNewGen Pack v5d
*       2.  JassHelper 0.A.2.B
*       3.  Any unit indexer
*
*   HOW TO IMPLEMENT
*   
*       1.  Copy the 'folder' MoveSpeedX.
*       2.  Paste it into your map.
*       3.  Open "Advanced -> Gameplay Constants".
*       4.  Checkmark "Use Custom Gameplay Constants".
*       5.  Find the field, "Movement - Unit Speed - Maximum", change
*           that to 522.
*       6.  Find the field, "Movement - Unit Speed - Minimum", hold
*           shift and click, and change it to 0.
*       7.  Read HOW TO USE. 
*
************************************************************************************
*
*   HOW TO USE
*
*       This system will automatically work by itself. You can use the
*       normal GUI function for modifying unit movement speeds. Simply
*       use "Unit - Set Movement Speed", input whatever value you want,
*       and you are good to go! It will handle values beyond 522 by itself.
*
*       HOWEVER, the GUI function will not return correct values if a unit
*       has a movement speed greater than 522. To fix this, use the function
*       GetUnitMoveSpeedX to return the correct value. A sample is given in
*       the trigger "Speed Change" in the test map.
*
************************************************************************************
*
*   NOTES
*
*       Units that were issued orders as groups might not *always* end up in the proper
*       "order". (they might not end up in an organized formation) They do sometimes though.
*       This is only for units with speeds above 522.
*
*       This also will not factor in bonuses and probably not slows either.
*
*       Units may waddle around the point for a little bit. Reduce PERIOD to fix
*       it a little bit. I recommend about 0.02 if you have really high speeds.
*
************************************************************************************/

    private function ApproxEqual takes real A, real B returns boolean
        return (A >= (B - MARGIN)) and (A <= (B + MARGIN))
    endfunction
    
    private module M
        private static trigger issued = CreateTrigger()
        
        thistype next 
        thistype prev
        
        boolean enabled
        unit curr
        real speed
        real x
        real y
        real ox
        real oy
        
        method destroy takes nothing returns nothing
            set this.next.prev = this.prev
            set this.prev.next = this.next
            set this.enabled = false
        endmethod
            
        private static method periodic takes nothing returns nothing
            local thistype this = thistype(0).next // first instance in list
            local real nx // the x-coordinate after tick
            local real ny // the y-coordinate after tick
            local real dx // distance between new-x and old-x
            local real dy // distance between new-y and old-y
            local real d  // distance between new point and old point
            local integer order // the unit's current order
            local unit u // unit being affected
            loop
                exitwhen this == 0
                set u  = .curr
                set nx = GetUnitX(u)
                set ny = GetUnitY(u)
                if IsUnitType(u, UNIT_TYPE_DEAD) then
                    call this.destroy()
                elseif not ApproxEqual(nx, .x) or not ApproxEqual(ny, .y) then
                    if (not IsUnitPaused(u)) and GetUnitAbilityLevel(u, 'BSTN') == 0 and GetUnitAbilityLevel(u, 'BPSE') == 0 then
                        set order = GetUnitCurrentOrder(u)
                        set dx = nx - .x
                        set dy = ny - .y
                        set d  = SquareRoot(dx * dx + dy * dy)
                        set dx = dx / d * .speed // move the unit offset-x by this
                        set dy = dy / d * .speed // move the unit offset-y by this
                        
                        if (order == 851986 or order == 851971) and /*
                        */ (this.ox - nx)*(this.ox - nx) < (dx*dx) and /*
                        */ (this.oy - ny)*(this.oy - ny) < (dy*dy) then
                            // if the unit is issued a move or smart order and they are near their destination
                            // then move them there instantly (removes a bit of glitchyness towards the end)
                            call SetUnitX(u, .ox) 
                            call SetUnitY(u, .oy)
                            set .x = .ox
                            set .y = .oy 
                            call IssueImmediateOrderById(u, 851972) // order them to stop
                        else
                            set .x = nx + dx
                            set .y = ny + dy
                            call SetUnitX(u, .x)
                            call SetUnitY(u, .y)
                        endif
                    endif
                endif
                set this = this.next
            endloop
            set u = null
        endmethod
        
        static method create takes unit whichUnit, real newSpeed returns thistype
            local thistype this = GetUnitUserData(whichUnit)
            set this.next = thistype(0).next
            set thistype(0).next.prev = this
            set thistype(0).next = this
            set this.prev  = 0
            set this.curr  = whichUnit
            set this.speed = (newSpeed - 522) * PERIOD
            set this.x     = GetUnitX(whichUnit)
            set this.y     = GetUnitY(whichUnit)
            set this.enabled = true
            return this
        endmethod
        
        static method update takes unit whichUnit, real newSpeed returns nothing
            local thistype this = GetUnitUserData(whichUnit)
            if this.enabled then
                if newSpeed > 522 then
                    set this.speed = (newSpeed - 522) * PERIOD
                else
                    call this.destroy()
                endif
            elseif newSpeed > 522 then
                call thistype.create(whichUnit, newSpeed)
            endif
        endmethod
        
        private static method storeOrderPoint takes nothing returns boolean
            local thistype this = GetUnitUserData(GetTriggerUnit())
            set this.ox = GetOrderPointX()
            set this.oy = GetOrderPointY()
            return false
        endmethod
    
        private static method onInit takes nothing returns nothing
            call TimerStart(CreateTimer(), PERIOD, true, function thistype.periodic)
            call TriggerRegisterAnyUnitEventBJ(issued, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
            call TriggerAddCondition(issued, Condition(function thistype.storeOrderPoint))
        endmethod
    endmodule
    
    private struct MoveSpeedStruct extends array
        implement M
    endstruct
    
    function GetUnitMoveSpeedX takes unit whichUnit returns real
        if MoveSpeedStruct(GetUnitUserData(whichUnit)).enabled then
            return udg_UnitSpeedX[GetUnitUserData(whichUnit)]
        endif
        return GetUnitMoveSpeed(whichUnit)
    endfunction
    
    function SetUnitMoveSpeedX takes unit whichUnit, real newSpeed returns nothing
        call MoveSpeedStruct.update(whichUnit, newSpeed)
        set udg_UnitSpeedX[GetUnitUserData(whichUnit)] = newSpeed
    endfunction

    hook SetUnitMoveSpeed SetUnitMoveSpeedX
endlibrary

Please report any bugs.

Changelog:
1.0.0.0 - Initial release
1.0.0.1 - Minor changes to constants.
1.1.0.0 - No longer requires JASS for retrieving speeds. Updated to use a unit indexer for faster speeds. Also is less prone to glitchy movement towards the end.
Rating - 4.67 (3 votes)
(Hover and click)
Moderator Comments
Highly Recommended
24th Nov 2011
Bribe: Approved and highly recommended.

This spell is approved and works properly.


Download MoveSpeedXGUI.w3x
(38.41 KB, 626 Downloads)

Old 11-24-2011, 10:27 AM   #2 (permalink)
Registered User makai
life ain't joke
 
makai's Avatar
 
Join Date: Apr 2010
Posts: 266
makai has little to show at this moment (26)makai has little to show at this moment (26)makai has little to show at this moment (26)
interesting, lemme check...
__________________
Troll
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to defskull's ultimate
Actions
Set defskull = (Casting unit)
Trigger - Turn on Kill makai <gen>
makai is offline   Reply With Quote
Old 11-24-2011, 10:33 AM   #3 (permalink)
Registered User Ironside
aka. GHH
 
Ironside's Avatar
 
Join Date: Feb 2009
Posts: 2,865
Ironside is just really nice (396)Ironside is just really nice (396)Ironside is just really nice (396)Ironside is just really nice (396)Ironside is just really nice (396)
I'll test it today as well.
__________________
GHH aka. Rikudou Sennin


Ironside is offline   Reply With Quote
Old 11-24-2011, 10:40 AM   #4 (permalink)
Forum Moderator Bribe
Keep it simple
 
Bribe's Avatar
Spells, Help Zones & JASS Moderator
 
Join Date: Sep 2009
Posts: 5,581
Bribe has much of which to be proud (1209)Bribe has much of which to be proud (1209)
PayPal Donor: This user has donated to The Hive. 
Instead of ".rn" use the ".prev" member.

Make a local unit to store ".curr" so you don't spam array referencing.

It doesn't matter but "set thistype(0).next.prev = 0" is faster than "set this.next.prev = 0".

You can initialize "hash" from the globals block and use a library initializer for the timer. This prevents the need of the struct altogether.
__________________
How to post your triggers on the Hive Workshop.
JPAG - Bettering the cause of readable source code.

Bribe is offline   Reply With Quote
Old 11-24-2011, 02:15 PM   #5 (permalink)
Registered User Chaosy
Mr. GUI
 
Chaosy's Avatar
 
Join Date: Jun 2011
Posts: 1,763
Chaosy is just really nice (394)Chaosy is just really nice (394)Chaosy is just really nice (394)Chaosy is just really nice (394)Chaosy is just really nice (394)
PayPal Donor: This user has donated to The Hive. 
downloading it and i will edit this post after

EDIT dont work for me since i got the WE sad i expected it to work when title sais GUI :P
Chaosy is online now   Reply With Quote
Old 11-24-2011, 07:54 PM   #6 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,556
PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)
Quote:
Originally Posted by Bribe View Post
Instead of ".rn" use the ".prev" member.

Make a local unit to store ".curr" so you don't spam array referencing.

It doesn't matter but "set thistype(0).next.prev = 0" is faster than "set this.next.prev = 0".

You can initialize "hash" from the globals block and use a library initializer for the timer. This prevents the need of the struct altogether.
kk I'll update it soon.

Quote:
Originally Posted by Darkgrom View Post
downloading it and i will edit this post after

EDIT dont work for me since i got the WE sad i expected it to work when title sais GUI :P
Sorry, it needs Jass NewGen Pack v5d. You can download it here:
http://www.wc3c.net/showthread.php?t=90999

It is GUI-friendly in the sense that you don't need to use any JASS functions to modify the unit's movement speed. You can just use the normal function as shown in the test map. ;)

Thanks everyone else for the comments.

EDIT: Updated for Bribe's comments.

Last edited by PurgeandFire; 11-25-2011 at 09:10 PM.
PurgeandFire is offline   Reply With Quote
Old 11-26-2011, 12:18 AM   #7 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,700
Magtheridon96 has a brilliant future (1812)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
Looks pretty good :)
5/5:

- Efficient
- Readable
- Useful
- Bugless
__________________
Magtheridon96 is offline   Reply With Quote
Old 11-29-2011, 01:12 AM   #8 (permalink)
Registered User nerovesper
๑۩۞۩_ENVY_۩۞۩๑
 
nerovesper's Avatar
 
Join Date: Sep 2008
Posts: 700
nerovesper is a jewel in the rough (240)nerovesper is a jewel in the rough (240)nerovesper is a jewel in the rough (240)nerovesper is a jewel in the rough (240)
just a question, when checking for the movement speed through triggers for example the Unit - (current movespeed) will it show the over 522 movespeed or 522 or something?
nerovesper is offline   Reply With Quote
Old 11-29-2011, 01:46 AM   #9 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,556
PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)
When you check it through triggers, it will show 522 speed. Sadly, JassNewGen didn't expand its features much on hooking so I can only detect when functions occur; I can't override them. =(

That's why the JASS function has to be used.
GetUnitMoveSpeedX(unit)

Here are some examples:
Custom script: set udg_TempReal = GetUnitMoveSpeedX(udg_MyUnit)
// Retrieves the movement speed of the unit of "MyUnit" and assigns it to "TempReal"
Custom script: set udg_TempReal = GetUnitMoveSpeedX(GetTriggerUnit())
// Retrieves the movement speed of the triggering unit and assigns it to "TempReal"

However, you can set the movement speed however you want as normal.
Unit - Set <Unit> movement speed to 1043
That would work just fine; my system would detect it and do everything accordingly.
PurgeandFire is offline   Reply With Quote
Old 01-02-2012, 01:50 PM   #10 (permalink)
Registered User Mr_Bean
Where's Teddy?
 
Mr_Bean's Avatar
 
Join Date: Feb 2011
Posts: 1,597
Mr_Bean is a jewel in the rough (242)Mr_Bean is a jewel in the rough (242)Mr_Bean is a jewel in the rough (242)Mr_Bean is a jewel in the rough (242)
Techtree Contest #7 - Winner: The Ancients and The Old One: The incarnation of the World Tree as a Super Unit commences the tides of battle. Nature has found its most precious avenger! A race by Lordkoon & Mr_Bean987. 
Awesome system. Using it in my map!

5/5
__________________
Mr_Bean's Spell Workshop
- Now accepting GUI requests!
- I'm back to work on requests now.
- Need help importing your request? Try this guide I wrote!
Mr_Bean is online now   Reply With Quote
Old 01-04-2012, 09:21 PM   #11 (permalink)
Registered User kStiyl
Newb
 
kStiyl's Avatar
 
Join Date: Oct 2011
Posts: 167
kStiyl has little to show at this moment (29)kStiyl has little to show at this moment (29)kStiyl has little to show at this moment (29)
Would this bug if I use SetUnitX/Y/Position? since it would probably think the unit moved

If so, should i hook those functions
and do something like this?

set MoveSpeedStruct[unit].x = new x
kStiyl is offline   Reply With Quote
Old 01-04-2012, 10:06 PM   #12 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,556
PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)PurgeandFire has much of which to be proud (1106)
Now that I think about it, it may have a slight chance to accelerate the movement if you have something that moves the unit, such as a knockback.

Although, if you pause the unit before moving them, it will not cause any problems.

I'll run tests eventually and update this system if I find any problems. Thanks for bringing that to my attention. :) I could either add an option to disable the system for a unit (in case you need to move the unit), or I suppose i could also check if the unit is issued an order or not.

I based this off of MoveSpeedX by Jesus4Lyf so I didn't do too much bug testing aside from the actual system.
PurgeandFire is offline   Reply With Quote
Old 01-05-2012, 04:38 PM   #13 (permalink)
Registered User kStiyl
Newb
 
kStiyl's Avatar
 
Join Date: Oct 2011
Posts: 167
kStiyl has little to show at this moment (29)kStiyl has little to show at this moment (29)kStiyl has little to show at this moment (29)
the system also bugs when you order a group of units to move (they will try to allign in movement)
kStiyl is offline   Reply With Quote
Old 04-13-2012, 12:31 AM   #14 (permalink)
Registered User .OmG.
Hive - my life
 
.OmG.'s Avatar
 
Join Date: May 2010
Posts: 197
.OmG. has little to show at this moment (8)
A flying units are stopping on every unit o decoration...
.OmG. is offline   Reply With Quote
Old 06-20-2012, 08:54 PM   #15 (permalink)
Registered User SDM
User
 
Join Date: May 2012
Posts: 2
SDM is an unknown quantity at this point (0)
hey an author i have a little question.Why does hero moves after he reach the target point.The model moves right and left some times and then stops.How can we skip that?
SDM is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 07:17 PM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle