• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Making a unit STOP

Status
Not open for further replies.
Level 9
Joined
May 28, 2007
Messages
365
How do I make a unit STOP an ability, if they are in the middle of channeling it.

IssueImmediateOrder(u, "stop")

Does not work.

EDIT: I fixed this by using SetUnitPosition() twice for the unit... Seemed to work.

There must be a special technique to bypass this bug?

Just to clarify, what I mean is I have a spell based off of Channel (the dummy ability) with a follow through time of 10. But I want to cut it short, so how do I do this?

On another note, how do I get a dummy unit to cast Cluster Rockets?
JASS:
    local unit dummy = CreateUnit(GetOwningPlayer(u), 'h000', GetUnitX(u), GetUnitY(u), 0)
    call UnitAddAbility(dummy, 'A02Z')
    call IssuePointOrder(dummy, "clusterrockets", GetSpellTargetX(), GetSpellTargetY())
does not work.
 
Last edited:
Level 5
Joined
May 10, 2009
Messages
88
  • Unit - Order (Triggering Unit) to stop
Make this jass, dunno how so you do it XD
 
can you post the whole trigger?

In the cluster rockets problem, I believe that you add a hero ability which needs to be learned before you can use it. YOu just add it to the unit so basically the skill is still unlearned by that unit because hero abilities need to be learned. just make it a unit ability in the object editor (Hero Ability - False) because I don't think its possible to make a non-hero unit learn a hero ability because the action for learning a hero ability requires that the unit has unspent skill points...
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Actually, if you use UnitAddAbility the ability will be added to the unit without having to learn the ability. Even if the ability level is set to 0 afterward the hero will still be able to use it. Does anybody know how to make an ability learn-able for a specific unit? I've tried a few functions and did some tests but nothing seems to allow the unit to have the ability but not able to use it until it is learned.
 
Actually, if you use UnitAddAbility the ability will be added to the unit without having to learn the ability. Even if the ability level is set to 0 afterward the hero will still be able to use it.

I don't know it works for HERO Abilities.... but anyway I think his dummy is a non-hero unit so can they use hero abilities?... coz those 2 are the only problems I can think of which makes his dummy unable to cast cluster rockets.. or maybe the dummy don't have enough mana?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I tried doing UnitAddAbility with the 'AHhb' raw-code, which is Holy Light, which is a hero ability. It added the ability (and displayed it as level 1 in UI), but the ability could not be researched further.
 
I tried doing UnitAddAbility with the 'AHhb' raw-code, which is Holy Light, which is a hero ability. It added the ability (and displayed it as level 1 in UI), but the ability could not be researched further.

oh... okay.... so they can use it but cannot level it up... so maybe his dummy really don't have enough mana or maybe he removes his dummy so soon while cluster rocket is a channeling spell...
 
For the unit stop you can use the following function.
I took this from vexorions old hero selection system so credits goes to him or whoever made this function.
JASS:
function StopOrder takes unit u returns nothing
    if GetIssuedOrderId() == OrderId("stop") or GetUnitUserData(u) == 1 then
        return
    endif
    call SetUnitUserData( u, 1 )
    call PauseUnit( u, true )
    call IssueImmediateOrder( u, "stop" )
    call PauseUnit( u, false)
    call SetUnitUserData( u, 0 )
endfunction

As for the clusterrockets, when testing it myself it worked just fine.
JASS:
function CR_Conditions takes nothing returns boolean
    return GetSpellAbilityId(  ) == 'A000' // Channel
endfunction

function CR_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit(  )
    local unit dummy = CreateUnit( GetOwningPlayer( caster ), 'hpea', GetUnitX( caster ), GetUnitY( caster ), GetUnitFacing( caster ) )
    call UnitAddAbility( dummy, 'ANcs' ) // Cluster Rockets
    call IssuePointOrder( dummy, "clusterrockets", GetSpellTargetX(  ), GetSpellTargetY(  ) )
    call SetUnitAbilityLevel( dummy, 'ANcs', 3 )
    call UnitApplyTimedLife( dummy, 'BTLF', 2 )
    set dummy = null
    set caster = null
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_001, Condition( function CR_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function CR_Actions )
endfunction
Make sure your dummy unit has enough mana to cast the ability?
 
Level 9
Joined
May 28, 2007
Messages
365
For the unit stop you can use the following function.
I took this from vexorions old hero selection system so credits goes to him or whoever made this function.
JASS:
function StopOrder takes unit u returns nothing
    if GetIssuedOrderId() == OrderId("stop") or GetUnitUserData(u) == 1 then
        return
    endif
    call SetUnitUserData( u, 1 )
    call PauseUnit( u, true )
    call IssueImmediateOrder( u, "stop" )
    call PauseUnit( u, false)
    call SetUnitUserData( u, 0 )
endfunction

As for the clusterrockets, when testing it myself it worked just fine.
JASS:
function CR_Conditions takes nothing returns boolean
    return GetSpellAbilityId(  ) == 'A000' // Channel
endfunction

function CR_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit(  )
    local unit dummy = CreateUnit( GetOwningPlayer( caster ), 'hpea', GetUnitX( caster ), GetUnitY( caster ), GetUnitFacing( caster ) )
    call UnitAddAbility( dummy, 'ANcs' ) // Cluster Rockets
    call IssuePointOrder( dummy, "clusterrockets", GetSpellTargetX(  ), GetSpellTargetY(  ) )
    call SetUnitAbilityLevel( dummy, 'ANcs', 3 )
    call UnitApplyTimedLife( dummy, 'BTLF', 2 )
    set dummy = null
    set caster = null
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Untitled_Trigger_001, Condition( function CR_Conditions ) )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function CR_Actions )
endfunction
Make sure your dummy unit has enough mana to cast the ability?

I didn't realize that was Vex's method, I've been using it myself for a while now. Regardless, it didn't work which is why I fixed it with moving the unit a bit ahead, then back.

Yes, in a different map I was also able to get the dummy unit to cast clusterrockets, but in my map it just isn't working (using the same code). I'll post the full trigger code in a second.

JASS:
scope ClusterTest initializer Init

globals
    private constant integer spellId = 'A02Z' // You may change this 
    private constant integer unitId  = 'hfoo' // Generic footman 
endglobals

private function Actions takes nothing returns nothing 
    local unit u = CreateUnit(Player(0), unitId, 0, 0, 270)
    call UnitAddAbility(u, spellId)
    if( IssuePointOrder(u, "clusterrockets", 0, 0) ) then
        call BJDebugMsg("- Success! -")
    else
        call BJDebugMsg("- Failed! -")        
    endif
    call BJDebugMsg("- End Test -")   
endfunction

private function Init takes nothing returns nothing 
    local trigger t = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic( t, Player(0) )
    call TriggerAddAction( t, function Actions )
endfunction

endscope

In all the tests, I get -Failed-, -EndTest-. In all the cases, the unit has the cluster rockets ability, and has mana to cast it.

Here is the code for the test I'm doing. It should work if you just CnP into your map. All you have to do is type in thereisnospoon at the start, then press ESC. This test works for all the other spells in my map EXCEPT for cluster rockets. :(
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
You shouldn't have to play around with the code in order for it to work. If it works, it works. There is no question about it. If you're experiencing problems when using "verified" code, then you have other problems.
 
Status
Not open for further replies.
Top