Hunt System Game

Reaction score
54
The game goes like this:

Every player gets another player as their target.
When a player is killed by his hunter, he's out of the game.
When a player is killed by someone else, he respawns.
When you kill your target, you get his target.

The issue I have is in the writing of the initial code. I had this in mind:

Add ALL PLAYERS to POOL
Pick every player in ALL PLAYERS and make their target a RANDOM PLAYER from POOL. Remove RANDOM PLAYER from POOL.
Adding a condition. RANDOM PLAYER must not equal PICKED PLAYER.

It seems to work well but... what if the last player only has himself as an option in the POOL? It would have to run itself again.
Is there efficient way to avoid falling into a loop? Thanks in advance.
 
M

Mythic Fr0st

Guest
hmm

Can you please explain a little more detailed of what you are trying to do, and post your trigger attempt if you have one please
 
Reaction score
54
More details?

The mini-game begins.

Say there are 4 players.

Red is assigned Blue as target.
Blue is assigned Green as target.
Green is assigned Yellow as target.
Yellow is assigned Red as target.

Red kills Blue, his target, so Blue is out of the game. Red is now hunting Green. Yellow kills Green, but since Green was not his target, Green respawns.

My question is at the initial assignment, suppose that by the trigger:
Code:
Pick every player in ALL PLAYERS and add picked player to UnitGroup(POOL).
Pick every player in ALL PLAYERS and make their target a RANDOM PLAYER (not equal to picked played) from UnitGroup(POOL). Remove RANDOM PLAYER from UnitGroup(POOL).

It results as this:

Red is assigned Blue as target.
Blue is assigned Green as target.
Green is assigned Red as target.
Yellow is assigned ... as target.


What should be the correct way of writing the trigger to avoid this happening?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Set Players = (All players matching (((Matching player) slot status) Equal to Is playing))
Set TempInteger = 0
For each (Integer A) from 1 to (Number of players in Players), do
- Set Player = (Random player from Players)
- Set TempInteger = (TempInteger + 1)
- Set TempTargets[TempInteger] = Player
- Player Group - Remove Player from Players

Once done,
TempTargets[1] gets assigned TempTargets[2] as target player to kill
TempTargets[2] gets assigned TempTargets[3] as target player to kill
TempTargets[3] gets assigned TempTargets[4] as target player to kill
...
TempTargets[TempInteger] gets assigned TempTargets[1] as target player to kill
 
Reaction score
54
Possible outcome:

Set Players = (All players matching (((Matching player) slot status) Equal to Is playing))
Players = Red,Blue, Green,Yellow

Set TempInteger = 0
For each (Integer A) from 1 to (Number of players in Players), do
- Set Player = (Random player from Players)
- Set TempInteger = (TempInteger + 1)
- Set TempTargets[TempInteger] = Player
- Player Group - Remove Player from Players
Player = Blue
TempTarget[1(Red)] = Blue
Players = Red, Green,Yellow
-
Player = Green
TempTarget[2(Blue)] = Green
Players = Red,Yellow
-
Player = Red
TempTarget[3(Green)] = Red
Players = Yellow
-
Player = Yellow
TempTarget[4(Yellow)] = Yellow
Players = Null

^- This is the outcome I don't know how to prevent.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
You missed the "once done" part.

Only assign the final target players after that loop, not inside.


Based on your example:
...
TempTarget[1] = Blue
...
TempTarget[2] = Green
...
TempTarget[3] = Red
...
TempTarget[4] = Yellow
...

Blue attacks Green attacks Red attacks Yellow attacks Blue.
 
M

Mythic Fr0st

Guest
hmm

in the same trigger

Code:
IF TempTarget[TempInteger] equal to Player
then - game victory "player"
or whatever
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> or whatever

I've seen better ideas from you...

Anyway, I'd recommend to you too to reread post #4 one more time.


Well, I guess I should write a quick "what does it do?":

"Players" will be a list of players... (obviously), let's say players 1, 2, 3 and 4.
Once that loop has ended, TempTargets may hold, for example players 1, 2, 3 and 4 in that order.
Which would mean that
1 attacks 2 attacks 3 attacks 4 attacks 1.

Or, it might hold 2, 4, 3, 1 in that order.
2 attacks 4 attacks 3 attacks 1 attacks 2.

Or, 3, 1, 2, 4:
3 attacks 1 attacks 2 attacks 4 attacks 3.


Basically, it finds some completely random order of the existing players.
Once you have that "order", you just assign them as they come.

The only feature is the result if there's only one single player all alone.
But, in that case, the map isn't really playable anyway...


EDIT:

You can also do everything in one single loop.
Though it's even less readable.

Anyway, did some quick test trigger:
Code:
Prepare Targets
    Events
        Player - Player 1 (Red) skips a cinematic sequence
        Player - Player 2 (Blue) skips a cinematic sequence
        Player - Player 3 (Teal) skips a cinematic sequence
        Player - Player 4 (Purple) skips a cinematic sequence
        Player - Player 5 (Yellow) skips a cinematic sequence
    Conditions
    Actions
        Set Players = (All players matching (((Matching player) slot status) Equal to Is playing))
        Set FirstPlayer = (Random player from Players)
        Set PreviousPlayer = FirstPlayer
        Player Group - Remove FirstPlayer from Players
        For each (Integer A) from 1 to (Number of players in Players), do (Actions)
            Loop - Actions
                Set CurrentPlayer = (Random player from Players)
                Player Group - Remove CurrentPlayer from Players
                Set Targets[(Player number of PreviousPlayer)] = CurrentPlayer
                Set PreviousPlayer = CurrentPlayer
        Set Targets[(Player number of CurrentPlayer)] = FirstPlayer
        Set Players = (All players matching (((Matching player) slot status) Equal to Is playing))
        Player Group - Pick every player in Players and do (Actions)
            Loop - Actions
                Game - Display to (All players) the text: ((Name of (Picked player)) + ( attacks  + (Name of Targets[(Player number of (Picked player))])))

Works as designed.
 
M

Mythic Fr0st

Guest
> or whatever
I've seen better ideas from you...

My life is getting more busy, with less time for TH, and everything else...

My posts are short, quick, and as close to correct as I can get them...

:D, + im exhausted
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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