HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Movespeed problem in triggered ability

05-26-2006, 08:31 AM#1
The_AwaKening
Any ideas why the hero's movement speed gets reset to 100 sometimes after running this. Seems to be when it is stopped by stun or something before the timer ends.
Collapse JASS:
function Trig_Nuke_Actions takes nothing returns nothing
    local integer i=0
    local unit u=GetTriggerUnit()
    local unit T
    local real range=800
    local real wait=0.25
    local real ms=GetUnitMoveSpeed(u)
    local group g=CreateGroup()
    local effect e
    local boolexpr b
    local timer t=CreateTimer()

    call TriggerSleepAction(.65)
    call TimerStart( t, 45.00, false, null )
    call SetUnitMoveSpeed( u, ( ms + 65.00 ) )
    set b=Condition(function NukeBool)
    set e=AddSpecialEffectTarget("Objects\\InventoryItems\\Rune\\Rune.mdl",u,"overhead")
    call SetUnitVertexColor(u,100,100,100,100)
    loop
        exitwhen TimerGetRemaining(t)<=0 or GetUnitState(u,UNIT_STATE_LIFE)<=0 or unitIsStunned(u)
        call GroupEnumUnitsInRange(g,GetUnitX(u),GetUnitY(u),range,b)
        if CountUnitsInGroup(g)>0 then
            call ForGroup( g, function NukeDamage )
        endif
        loop
            exitwhen i>4 or GetUnitState(u,UNIT_STATE_LIFE)<=0 or unitIsStunned(u)
            set T=GroupPickRandomUnit(g)
            if T!=null then
                call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Flare\\FlareTarget.mdl",GetUnitX(T),GetUnitY(T)-200))
                call GroupRemoveUnit(g,T)
            endif
            set i=i+1
            call TriggerSleepAction(wait)
        endloop
        call GroupClear(g)
        set i=0
    endloop
    call SetUnitVertexColorBJ(u,100,100,100,0)
    call DestroyEffect(e)
    call SetUnitMoveSpeed( u, ms )

    call PauseTimer(t)
    call DestroyTimer(t)
    call DestroyGroup(g)
    call DestroyBoolExpr(b)
    set e=null
    set g=null
    set b=null
    set u=null
    set T=null
    set t=null
endfunction

Could it be that I need to Pause and Destroy the timer before setting movespeed back to normal?
05-26-2006, 11:28 AM#2
Captain Griffen
Using triggers to mess around with unit move speeds can be dangerous, as it tends to be buggy when interacting with anything else. Use an ability if you can.

Oh, and you have a random BJ in there.

call SetUnitVertexColor(u,255,255,255,255)
05-26-2006, 02:39 PM#3
The_AwaKening
Quote:
Originally Posted by Captain Griffen
Oh, and you have a random BJ in there.

call SetUnitVertexColor(u,255,255,255,255)

Ya, thanks I missed that one. Funny, I got the first call but missed the second one.

I guess I'll make it an ability then.
05-26-2006, 09:51 PM#4
Captain Griffen
You could add a self-only slowing aura, from the tornado, and then add that, rather than using a spell. You may have to put it into a disabled spell book, but I don't think it has an item.
05-26-2006, 09:56 PM#5
blu_da_noob
Tornado aura has no icon.
05-27-2006, 12:33 AM#6
The_AwaKening
Damn this is just retarded. Movespeed trigger should be just fine. I'll try the tornado aura, but the problem is I need a speed increase, so hopefully I can change the values that way.
05-28-2006, 03:33 PM#7
BertTheJasser
Use the speed bost ability of the <BootsOfSpeed> (rawcode is 'AIms'). It enables you to bost the speed by any value you want as long it is below the max movespeed of 522. It doesn't even show any abi or buff icon. So in your case it should work perfectly.
But I don't understand why it doesn't work with the movespeed native. I myself use it in a spell and it works as it is supposed to.

By the way: This script is not 100% safe. Replace
Collapse JASS:
GetUnitState(u,UNIT_STATE_LIFE)<=0
with
Collapse JASS:
GetWidgetLife(u)<=0.405
(The change to GetWidgetLife isn't required but it makes the script easier to read)
05-29-2006, 05:01 AM#8
The_AwaKening
Quote:
GetWidgetLife(u)<=0.405
Ya, I saw that code in one of Blade's spell triggers and wondered what the hell. I haven't had problems with my way yet, but if it is possible, then I'll change it.

The problem I'm having with using the boots of speed ability is that it is not stacking if the hero has that item also. I can think of some work arounds like checking the hero to see if it has that item and then if so, making another ability that is double the speed. Unless there is another way.

Btw, I've had a few people tell me now that triggers involving movespeed is bugged.
05-29-2006, 07:22 AM#9
Pheonix-IV
i'd suggest use tornado slow aura with a negative %, slow aura stacks.
05-29-2006, 01:05 PM#10
BertTheJasser
But he does not want a % bonus! Got it now?

I thought of the mentioned ability by creating a dublicated one, not to use the that same one.
05-29-2006, 05:21 PM#11
The_AwaKening
Tornado aura might not be a bad idea if I can negative the value. True I didn't want to use a percentage, but it will get me close enough. Thanks for all the input guys

One more thing about units life. Would that also mean that
Collapse JASS:
GetUnitState(u,UNIT_STATE_LIFE) > 0
is also inaccurate and should be replaced with
Collapse JASS:
GetWidgetLife(u) > 0.405
05-29-2006, 07:25 PM#12
Rising_Dusk
For all intensive purposes in game, the difference is insignificant.
If you have 1 life and take any damage from any real damage source, you will die and it will register properly.

Doesn't cause any problems using either way, but may as well just use the former (Or the latter if you like it being a smidge shorter).
05-29-2006, 08:00 PM#13
blu_da_noob
Quote:
Originally Posted by Rising_Dusk
(Or the latter if you like not having things bugging at random times for a stupid reason).

You could try replacing your end thing with:
Collapse JASS:
call SetUnitMoveSpeed(u,GetUnitDefaultMoveSpeed(u))
05-30-2006, 05:29 AM#14
BDSM
Collapse JASS:
constant native GetUnitMoveSpeed    takes unit whichUnit returns real

This native gets the unit's current move speed; bonuses from abilities applied. Items in the end use abilities, so just think of them as such in regards to move speed.

Collapse JASS:
constant native GetUnitDefaultMoveSpeed takes unit whichUnit returns real

This gets the unit's default move speed as dictated by the player in the object editor or the slk file.

Collapse JASS:
native          SetUnitMoveSpeed    takes unit whichUnit, real newSpeed returns nothing

This sets the unit's base move speed, not their current. This is where most people error, as they store the current and replace the base (in error) with the current. With positive bonuses (boots, auras, etc.) it is possible to have the unit's move speed creep up towards the maximum limit; with negative bonuses (cold arrows, auras, etc.) it is possible to have the unit's move speed works towards the minimum limit.

However, since boots do not stack (only static -- not percent based -- move speed ability I know of), I would recommend using a percent based ability (such as tornado). You'll get a much tighter spread:

+65 move speed (through triggers) with 0-100% bonus: +0-130 move speed
+20% move speed on a hero with 270-330 base and any % of bonuses: +54-66 move speed

Edit: Forget to mention how to fix the OP's function.

Change to the following lines:

Collapse JASS:
//	local real ms=GetUnitMoveSpeed(u)    --- safe to comment it as it is not needed
....
    call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed () + 65.00 ) // **note below
....
    call SetUnitMoveSpeed( u, GetUnitDefaultMoveSpeed () )

***This assumes of course that this is your only function using the natives to change move speed. Otherwise you'll want to store a value in order to keep accuracy between them.