TriggerSleepAction() breaking Filter()?

Matrixboy

New Member
Reaction score
1
Hey there everyone!

I'm working on this one code, that would round up all the units owned by a single, and to kill them. This will be used when people leave, are kicked, etc. etc. I also have it running at Initialization, in-case slots aren't open. I have it display text that the player has left, or was never present, ping them, and then (should) wait 120.00 seconds and kill them.

This is what I currently have:

JASS:
library Funcs
    function remove takes nothing returns boolean
        local unit character = GetFilterUnit()
        local string name = GetUnitName(character)
        local integer y = 0
        call PingMinimap (GetUnitX(character), GetUnitY(character), 2.00)
        loop
            exitwhen y == 11
                call DisplayTextToPlayer(Player(y), 0.0, 0.0, "The owner of " + name + " has left the game.  His idle character has been pinged, and " + name + " will drop his items in 120 seconds, and die.")
                set y = y+1
        endloop
        call TriggerSleepAction(120.00)
        call KillUnit( character )
        set character = null
        return true
    endfunction
endlibrary


JASS:
function check_empty takes nothing returns nothing
    local group KillGroup = CreateGroup()
    local integer x = 0
    call TriggerSleepAction(0.00)

    loop
        exitwhen x==11
            if ( GetPlayerSlotState(Player(x)) != PLAYER_SLOT_STATE_PLAYING ) then
                call GroupEnumUnitsOfPlayer(KillGroup, Player(x), Filter(function remove))
            endif
            set x = x+1
    endloop
    set x = 0
    call DestroyGroup(KillGroup)
    set KillGroup = null
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
    set gg_trg_Init = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Init, function check_empty )
endfunction


The only thing is, in the function remove, it seems to freeze at the TriggerSleepAction() call. After the alloted time, no character is killed. I've also done a test with simply printing text after the sleep, still to no avail. If I remove the call, it will work perfectly fine. But I really do wish to have the break between it, as to create a little interesting challenge for the corpses' items.

Would anyone know why it's doing this to me? I have a guess that it may have to be using it as the Filter in GroupEnumUnitsOfPlayer(), but have no way to test this (in all honesty, I don't know how any of the *Enum*() triggers work at all, so wouldn't know how to rewrite what I did. I posted here previously and someone graciously helped me out, however was unaware that I planned on adding the TriggerSleepAction() in. ).
 

Builder Bob

Live free or don't
Reaction score
249
I'm a little confused.

The only thing is, in the function remove, it seems to freeze at the TriggerSleepAction() call
Here you say there's a TriggerSleepAction() call in the function remove. In the code you posted the TriggerSleepAction() call is in the check_empty function.

As far as I can see the TriggerSleepAction() in the check_empty should not cause any problems.
However, if you tried using TriggerSleepAction() in the function remove, it would stop responding the way you describe it. This is because TriggerSleepAction() can only be used in Action functions. Not condition functions. Condition functions includes boolexpr, filter and conditionfunc.

If what you wrote was a typo, then I don't know what the problem is.
 

Matrixboy

New Member
Reaction score
1
I'm a little confused.


Here you say there's a TriggerSleepAction() call in the function remove. In the code you posted the TriggerSleepAction() call is in the check_empty function.

As far as I can see the TriggerSleepAction() in the check_empty should not cause any problems.
However, if you tried using TriggerSleepAction() in the function remove, it would stop responding the way you describe it. This is because TriggerSleepAction() can only be used in Action functions. Not condition functions. Condition functions includes boolexpr, filter and conditionfunc.

If what you wrote was a typo, then I don't know what the problem is.
Eek! Thank you for pointing that out. I did have TriggerSleepAction() in the function remove, however I posted the code I was testing (to see if it would work without it).

And thank you for explaining that it wouldn't work within Filter. That must have been why it wasn't working. Do you know of any way I can achieve what I'm attempting without filter? I never knew exactly what GroupEnum did anyways. Should I maybe make KillGroup a global, and pass all of the units owned by the missing player into that group?
 

Builder Bob

Live free or don't
Reaction score
249
Since you're using a library, I can see you have JassHelper. That will make solving this problem very simple.

Use this:
JASS:
library Funcs
    
    private function Enum takes nothing returns nothing
        local unit character = GetFilterUnit()
        local string name = GetUnitName(character)
        local integer y = 0
        call PingMinimap (GetUnitX(character), GetUnitY(character), 2.00)
        loop
            exitwhen y == 11
                call DisplayTextToPlayer(Player(y), 0.0, 0.0, "The owner of " + name + " has left the game.  His idle character has been pinged, and " + name + " will drop his items in 120 seconds, and die.")
                set y = y+1
        endloop
        call TriggerSleepAction(120.00)
        call KillUnit( character )
        set character = null
    endfunction
    
    function remove takes nothing returns boolean
        call Enum.execute()
        return true
    endfunction
endlibrary


By adding the extension .execute to a function call you can simulates an action function to allow you to use TriggerSleepAction().


Btw: You should start privatizing your functions (like I've done with the function Enum) so you can use the same function names in different scopes and libraries.
 

Matrixboy

New Member
Reaction score
1
Since you're using a library, I can see you have JassHelper. That will make solving this problem very simple.

Use this:
JASS:
....


By adding the extension .execute to a function call you can simulates an action function to allow you to use TriggerSleepAction().


Btw: You should start privatizing your functions (like I've done with the function Enum) so you can use the same function names in different scopes and libraries.
Thank you for all of your help! It works perfect now, thank you.

The .execute, that is working with it-as an object, correct? I was reading through the vjass manual, but most of it went right over my head. I never even noticed anything similar to what it said, and how you explained it. (I went back now, and did notice it mentioning something about execute, but in a lot more formal terms than you put it). Thanks for your explanation of it, made it a lot easier! I guess I'll have to go through and rad that manual again, if it'll help me avoid problems that make me bash my head against the wall.

Thanks, I just started putting everything into scopes, and privatizing things that I know won't be used outside of that library/scope. :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • jonas jonas:
    That sounds like fun!
    +1
  • The Helper The Helper:
    it was a blast!
  • The Helper The Helper:
    I am going to post the Youtube of the investigation in the forums when it is ready
    +1
  • jonas jonas:
    cool!
  • vypur85 vypur85:
    Sounds cool TH.
  • tom_mai78101 tom_mai78101:
    I was on a Legend of Zelda marathon...
  • tom_mai78101 tom_mai78101:
    Am still doing it now
    +1
  • jonas jonas:
    which one(s) are you playing?
  • jonas jonas:
    I played a little bit of the switch title two weeks ago and found it quite boring
  • The Helper The Helper:
    just got back from San Antonio this weekend had the best Buffalo Chicken Cheesesteak sandwhich in Universal City, TX - place was called Yous Guys freaking awesome! Hope everyone had a fantastic weekend!
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • The Helper The Helper:
    We have been getting crazy numbers reported by the forum of people online the bots are going crazy on us I think it is AI training bots going at it at least that is what it looks like to me.
  • The Helper The Helper:
    Most legit traffic is tracked on multiple Analytics and we have Cloud Flare setup to block a ton of stuff but still there is large amount of bots that seem to escape detection and show up in the user list of the forum. I have been watching this bullshit for a year and still cannot figure it out it is drving me crazy lol.
    +1
  • Ghan Ghan:
    Beep boop
    +1
  • The Helper The Helper:
    hears robot sounds while 250 bots are on the forum lol
  • The Helper The Helper:
    Happy Saturday!
    +1
  • The Helper The Helper:
    and then it was Thursday...
    +2
  • tom_mai78101 tom_mai78101:
    And then Monday
    +1
  • The Helper The Helper:
    I got the day off today!
    +1
  • tom_mai78101 tom_mai78101:
    How...? (T-T)
  • The Helper The Helper:
    I took the day off. I work for myself so I can do that.
    +1
  • Varine Varine:
    Well I'm already over summer
  • jonas jonas:
    varine! good to see you
  • jonas jonas:
    what's going on, what's got you going
  • The Helper The Helper:
    good to see you varine hope you are well my friend

    The Helper Discord

    Members online

    No members online now.

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top