• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Disable Movement

Status
Not open for further replies.
Level 13
Joined
Nov 22, 2006
Messages
1,260
Hi, I wanted to disable the movement of a certain unit......but that unit is still moving normally. I just know there's a catch somewhere.....

JASS:
function MovementDisable_Conditions takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("smart")
endfunction

function MovementDisable_Actions takes nothing returns nothing
    call IssueImmediateOrder(F, "stop")
endfunction

//===========================================================================
function InitTrig_Movement_Disable takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterUnitEvent(t, F, EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(t, F, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition(function MovementDisable_Conditions))
    call TriggerAddAction(t, function MovementDisable_Actions)
    
    set t = null
endfunction


F is just a global variable (in vJass you don't have to add udg_s).

Well, 'nuff said, any ideas?
 
Level 11
Joined
Aug 25, 2006
Messages
971
Remove the ability 'move' I'm not sure what its orderID is (Though that might be it) but check it out. Ordering a unit to stop will stop them until there given another order.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Wow, so much replies.....I gotta answer them all.....

(why does he use a condition for that)

Was that a question? If it was, try to make it without the condition and test it. Good luck :)

Remove the ability 'move' I'm not sure what its orderID is (Though that might be it) but check it out. Ordering a unit to stop will stop them until there given another order.

I just want to stop it, there won't be any nearby units in range.

I dont know if there is one but try a hold-position order. If you just make the unit stop it will attack nearby enemies, but that wont trigger your function since in this case there is no order given by a player.

Just wanna stop it....... There won't be any nearby units it can attack.

Can't you just lower their movement speed to 0?

Ahem.... I fell for that one before, seting MS to 0 isn't as pretty as it sounds like.

Try to replace F in the actions function with GetTriggerUnit() see if it helps somehow. If not add a DebugMsg in actions function and see if it shows. If it doesn't you got a problem with the conditions.

I don't see a reason why that should work, but yeah, I'll try with BJDebugMsg and will edit this post in couple of minutes......

EDIT: Yap, it's fired alright...... but for some reason it's not stopping. I'm gonna try with Hold Positions.....

EDIT2: Hehe, doesn't work like that, but this way it does work:

JASS:
function MovementDisable_Conditions takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("smart")
endfunction

function MovementDisable_Execute takes nothing returns nothing
    call DestroyTimer(GetExpiredTimer())
    call IssueImmediateOrder(F, "stop")
endfunction

function MovementDisable_Actions takes nothing returns nothing
    call TimerStart(CreateTimer(), 0, false, function MovementDisable_Execute)
endfunction

//===========================================================================
function InitTrig_Movement_Disable takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterUnitEvent(t, F, EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(t, F, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition(function MovementDisable_Conditions))
    call TriggerAddAction(t, function MovementDisable_Actions)
    
    set t = null
endfunction


Hehe, no bug will stop me! :)

Thanks for help guys ;)

One extra vJass question, if I have an uninitialized constant value and if I initialize it later, will it normally return that given value?

JASS:
library SetConst initializer Init_SetConst
globals
     constant real SomeReal
endglobals
function Init_SetConst takes nothing returns nothing
    set SomeReal = 2.5
endfunction
endlibrary


Will SomeReal always return 2.5 normally?
 
Last edited:
Level 19
Joined
Aug 24, 2007
Messages
2,888
I guess it should be fine if you remove the constant :p
my english is not soo good but my dictionary tells me constant means unchangeable
how do you expect to change it then ? :p
 
Level 11
Joined
Feb 18, 2004
Messages
394
One extra vJass question, if I have an uninitialized constant value and if I initialize it later, will it normally return that given value?

JASS:
library SetConst initializer Init_SetConst
globals
     constant real SomeReal
endglobals
function Init_SetConst takes nothing returns nothing
    set SomeReal = 2.5
endfunction
endlibrary


Will SomeReal always return 2.5 normally?

constants aren't vJASS. constants are normal JASS. (vJASS just lets us see them.) Constants are constant. Their value must be initialized in the variable declaration, as their value can not be changed. (Except, of course, by editing the code.) The "set" statement doesn't work on constants, as that would really defeat the purpose.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
constants aren't vJASS. constants are normal JASS. (vJASS just lets us see them.) Constants are constant. Their value must be initialized in the variable declaration, as their value can not be changed. (Except, of course, by editing the code.) The "set" statement doesn't work on constants, as that would really defeat the purpose.

Yeah, I figured that out....but it would be cool if uninitialized constants could be initialized later, and then not be able to change (like they're supposed to). Uninitialized constants aren't worth anything then.

I know constants aren't vJass :)

EDIT: Oh crap, I didn't see this one:

I guess it should be fine if you remove the constant :p
my english is not soo good but my dictionary tells me constant means unchangeable
how do you expect to change it then ? :p

Thanks dude.
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
Wow, so much replies.....I gotta answer them all.....



Was that a question? If it was, try to make it without the condition and test it. Good luck :)



I just want to stop it, there won't be any nearby units in range.



Just wanna stop it....... There won't be any nearby units it can attack.



Ahem.... I fell for that one before, seting MS to 0 isn't as pretty as it sounds like.



I don't see a reason why that should work, but yeah, I'll try with BJDebugMsg and will edit this post in couple of minutes......

EDIT: Yap, it's fired alright...... but for some reason it's not stopping. I'm gonna try with Hold Positions.....

EDIT2: Hehe, doesn't work like that, but this way it does work:

JASS:
function MovementDisable_Conditions takes nothing returns boolean
    return GetIssuedOrderId() == OrderId("smart")
endfunction

function MovementDisable_Execute takes nothing returns nothing
    call DestroyTimer(GetExpiredTimer())
    call IssueImmediateOrder(F, "stop")
endfunction

function MovementDisable_Actions takes nothing returns nothing
    call TimerStart(CreateTimer(), 0, false, function MovementDisable_Execute)
endfunction

//===========================================================================
function InitTrig_Movement_Disable takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterUnitEvent(t, F, EVENT_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterUnitEvent(t, F, EVENT_UNIT_ISSUED_TARGET_ORDER)
    call TriggerAddCondition(t, Condition(function MovementDisable_Conditions))
    call TriggerAddAction(t, function MovementDisable_Actions)
    
    set t = null
endfunction
Hehe, no bug will stop me! :)

Thanks for help guys ;)

One extra vJass question, if I have an uninitialized constant value and if I initialize it later, will it normally return that given value?

JASS:
library SetConst initializer Init_SetConst
globals
     constant real SomeReal
endglobals
function Init_SetConst takes nothing returns nothing
    set SomeReal = 2.5
endfunction
endlibrary
Will SomeReal always return 2.5 normally?
What is the problem with setting the unit's ms to 0?
I feel so stupid having never really used ms manipulation through coding, before.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
What is the problem with setting the unit's ms to 0?

I'm not sure about trigger ms setting, but I think it's same as setting ms in object editor. Well, there is no big problem, but the unit is not able to turn and when you move it with SetUnitX/Y* (I don't know about SetUnitPosition - Move unit (instantly) in GUI) it just stands still and it's shadow moves instead of it........weird, huh?

There are probably more bugs when doing that.

I feel so stupid having never really used ms manipulation through coding, before.

Don't. You just never had to, it's ok, some people never have that situation, it depends on the map you're making.

*if you don't know JASS, those are just functions that manually move unit's x /y and have some abilities that Move unit (instantly) (GUI) doesn't.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
I'm not sure about trigger ms setting, but I think it's same as setting ms in object editor. Well, there is no big problem, but the unit is not able to turn and when you move it with SetUnitX/Y* (I don't know about SetUnitPosition - Move unit (instantly) in GUI) it just stands still and it's shadow moves instead of it........weird, huh?
Actually, the unit moves, but the model stays.

Don't. You just never had to, it's ok, some people never have that situation, it depends on the map you're making.

*if you don't know JASS, those are just functions that manually move unit's x /y and have some abilities that Move unit (instantly) (GUI) doesn't.
SetUnitMoveSpeed() has some really nasty bugs anyways.
 
Level 7
Joined
Oct 5, 2007
Messages
118
What about the ability 'Ensnare'? The targeted victim can't move for some time, and when you set the duration of this ability to 0 it's permanent... until you remove the buff.
 
Status
Not open for further replies.
Top