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 The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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