Trigger becomes bugged when people leave

Xebarsis

New Member
Reaction score
7
I have a trigger that picks a random player and kills all of their units. Later another trigger respawns them, however sometimes it ends up choosing a player that has left the game.

I'm not sure how to make my trigger not only pick a random player and kill their units, but also not pick someone who has left. Here's my trigger:

Code:
The Imploder
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to The Imploder
    Actions
        Set UnluckyPlayer = (Random player from (All enemies of (Owner of (Hero manipulating item))))
        Game - Display to (All players) the text: (PlayerColors[(Player number of (Owner of (Triggering unit)))] + (((Name of (Owner of (Triggering unit))) + |R has used, "The Imploder" on ) + (PlayerColors[(Player number of UnluckyPlayer)] + ((Name of UnluckyPlayer) + ,|R INSTANT KILL!))))
        Unit Group - Pick every unit in (Units owned by UnluckyPlayer) and do (Actions)
            Loop - Actions
                Unit - Explode (Picked unit)
                Sound - Play HeroAlchemistPissed3 <gen>
 
Use Something like this when you create the random number.
Code:
    Events
    Conditions
    Actions
        set num = 1
        For each (Integer num) from 1 to 1, do (Actions)
            Loop - Actions
                Set random = (Random integer number between 1 and 12)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                ((Player(random)) slot status) Equal to Has left the game
                                ((Player(random)) slot status) Equal to Is unused
                    Then - Actions
                        Set num = (num - 1)
                    Else - Actions
 
Code:
Set UnluckyPlayer = (Random player from (All enemies of (Owner of (Hero manipulating item))) matching (matching player controller = user) or (player slot status = is playing) = true)

should do!
 
I wanted to do something like that Don, but I know how to make this

Code:
Set UnluckyPlayer = (Random player from (All enemies of (Owner of (Hero manipulating item))))

look like your code:

Code:
Set UnluckyPlayer = (Random player from (All enemies of (Owner of (Hero manipulating item))) matching (matching player controller = user) or (player slot status = is playing) = true)

Do you think you could walk me through the process of what functions to choose to be able to add on from what I have?
 
there should be something like player matching condition and then u do what he said
 
I believe choosing (matching player controller = user) would still cause users that aren't playing to be chosen, and as for the second suggestion with (player slot status = is playing), I don't know what option to pick to replace "player." I know there's variables and I can also choose a specific player, but I'm still setting the UnluckyPlayer so I'm not sure what to put it as.

I did find the "player matching condition," however I don't know how to get "= true)" at the end of the code. :confused:

Edit: Are (matching player controller = user) and (player slot status = is playing) supposed to be in one code, or are you suggesting I pick one?
 
Edit: Are (matching player controller = user) and (player slot status = is playing) supposed to be in one code, or are you suggesting I pick one?
you can do it seperate or together, it depends on how you feel...
 
Well I'd like to do them together, but I don't understand the order of functions to select in order to achieve that.
 
use ''and'' at the borttom of conditions list.. pretty simple! Use it twice, for ennemies thing, slot status and controller.

If it doesnt work, remove slot status condition and it should work perfectly!
 
Does this look right?
Code:
The Imploder
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to The Imploder
        And - All (Conditions) are true
            Conditions
                ((Matching player) controller) Equal to User
                ((Matching player) slot status) Equal to Is playing
    Actions
        Set UnluckyPlayer = (Random player from (All enemies of (Owner of (Hero manipulating item))))
        Game - Display to (All players) the text: (PlayerColors[(Player number of (Owner of (Triggering unit)))] + (((Name of (Owner of (Triggering unit))) + |R has used, "The Imploder" on ) + (PlayerColors[(Player number of UnluckyPlayer)] + ((Name of UnluckyPlayer) + ,|R INSTANT KILL!))))
        Unit Group - Pick every unit in (Units owned by UnluckyPlayer) and do (Actions)
            Loop - Actions
                Unit - Explode (Picked unit)
        Sound - Play HeroAlchemistPissed3 <gen>
 
Uhhh... turns out that "The Imploder" doesn't work AT ALL now with this new trigger.

Edit: But then again, you did say, "If it doesnt work, remove slot status condition and it should work perfectly!" So I will remove that condition and see what happens.
 
Turns out even when removing the condition you said, it still doesn't work. It's activated by an item, when I use the item it just vanishes (since it's a charge) and nothing happens.
 
well the only way i thought about it is looping till getting the right condition or either keep track of the number of playing players in game in a player group and remove all leavers out of loop.

anyway jass solution:
Code:
The Imploder
    Events
        Unit - A unit Uses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to The Imploder
    Actions
        Custom script:   loop
        Set UnluckyPlayer = (Random player from (All enemies of (Owner of (Hero manipulating item))))
        Custom script:   exitwhen (GetPlayerSlotState(udg_UnluckyPlayer) == PLAYER_SLOT_STATE_PLAYING)
        Custom script:   endloop
        Game - Display to (All players) the text: (PlayerColors[(Player number of (Owner of (Triggering unit)))] + (((Name of (Owner of (Triggering unit))) + |R has used, "The Imploder" on ) + (PlayerColors[(Player number of UnluckyPlayer)] + ((Name of UnluckyPlayer) + ,|R INSTANT KILL!))))
        Unit Group - Pick every unit in (Units owned by UnluckyPlayer) and do (Actions)
            Loop - Actions
                Unit - Explode (Picked unit)
                Sound - Play HeroAlchemistPissed3 <gen>
try that im pretty sure it should work
 
Nice Doom, that's a good way of doing it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top