• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unpause not working!

Status
Not open for further replies.
Level 10
Joined
Feb 19, 2006
Messages
237
I made a spell called "personal battle" in which your hero selects an enemy to have a fight with. Every other unit in the map is paused except your hero and its target. The pause works fine, but after 5 seconds i want everyone else to be unpaused, which is not working...

Personal Battle
Events
Unit - A unit Finishes casting an ability
Conditions
(Ability being cast) Equal to Personal Battle
Actions
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked unit) Not equal to (Casting unit)
(Picked unit) Not equal to (Target unit of ability being cast)
Then - Actions
Unit - Pause (Picked unit)
Wait 5.00 seconds
Unit - Unpause (Picked unit)
Else - Actions
Do nothing
 
Level 9
Joined
May 28, 2007
Messages
365
Use 2 triggers, and a unit group.

Make a global Unit Group variable called UnpauseUnits (or whatever)
Then
When you Pick Every Unit, Group AddUnit (Add the picked unit to the UnpauseUnits unitgroup)
Then Wait(5) seconds (make sure those goes OUTSIDE of the loop)
call RunTrigger( another trigger youll create below, lets call it UnpauseTrig)

For unpause trig, it just Pick Every Unit in UnPauseuNits and UnPause Picked Unit.
 
  • Personal Battle
  • Events
    • Unit - A unit Finishes casting an ability
  • Conditions
    • (Ability being cast) Equal to Personal Battle
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
          • (Picked unit) Not equal to (Triggering unit)
          • (Picked unit) Not equal to (Target unit of ability being cast)
        • Then - Actions
          • Unit - Pause (Picked unit)
        • Else - Actions
    • Wait 5.00 seconds
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • Unit - Unpause (Picked unit)
Stop using "Do Nothing" by the way. The engine knows if it's supposed to do anything or not. Use "Do Nothing" only when you use Pick every unit with one action attached.
 
That second bj_want is redundant, isn't it?

JASS:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction

It gets switched back. =D They just use wantDestroy, which is bj_wantDestroyGroup at that instance, and then it sets wantDestroy back to false. So yeah, it is necessary to set it twice.
 
Very cool, I never paid attention to that! As a bonus question, if you set bj_want and have a wait before the group is created, can another event trigger in that waiting period that sets the bj_want to false and then only one group is destroyed?

Yep. But if you put the bj_want right before the ForGroupBJ() call, then it shouldn't be a problem. :thumbs_up:
 
Status
Not open for further replies.
Top