How do I stop plots being chosen twice

0 favourites
  • 14 posts
  • Hi there people, i've been building a game, a few of you have helped out in the past, this time i have a video to help explain my problem, basically i want to know how to stop one player (or NPC) being able to choose the same plot of land as itself in the previous turn, or choosing the plot of another player (or NPC) to see how my plot selection works i've provided a short video that shows a small amount of the gameplay (specifically the plots being chosen by the player and then the 3 NPCs) to demonstrate what happens when a plot is selected, what i need to know is how to stop selected plots from being re selected during later turns, or by another player/NPC in the same turn.

    this link will take you to the video:

    https://youtu.be/_wQY_g9LMts

  • Kazuato

    Hi

    I'm not sure if I understood properly

    The square Picker stops when picks a Piece of land and highlights it with different colour and moves on to select the next ones doing the same, by the end of the Video they where 4 Picked?? If this is right now the question is what do you use for the Land (TileMaps or Sprites)?

    If you use Sprite as a Tile: Then you can add a Boolean "Selected" to the Tiles, Then when you loop to Pick a piece of land anytime it picks one you set the Boolean "Selected" to true

    So in the Loop you Pick by adding one more condition Tile is "Selected" <<<< and inverted = which means is not Selected

    If you use a TileMap instead: That's different history as you cant use instance variables on a single tile, you gonna have to store their Tile Number Grid where are located example (X1, Y1) = Tile 1,1 and on the loop ad the extra condition (is Tile not equal = To the Tiles selected previously X,Y)

  • I'm using sprites for the plot selector, when a plot is selected it's not changing the colour, it's spawning a separate sprite that is coloured depending on which player owns the plot (red for p1, green p2, blue p3 and yellow p4) would the boolean variable still work in this scenario? i feel like i'd have to run some kind of check with the plot selector so it can check if a sprite has already spawned on the plot or not before it can spawn a new one, but there in lies my problem, I'm not sure how i'd run the check, one suggestion i was given was to use an array instead of my current method, so i've been reading up on arrays in the mean time so i'll know how to implement the array if it turns out to be the best solution

  • I'm using sprites for the plot selector, when a plot is selected it's not changing the colour, it's spawning a separate sprite that is coloured depending on which player owns the plot (red for p1, green p2, blue p3 and yellow p4) would the boolean variable still work in this scenario? i feel like i'd have to run some kind of check with the plot selector so it can check if a sprite has already spawned on the plot or not before it can spawn a new one, but there in lies my problem, I'm not sure how i'd run the check, one suggestion i was given was to use an array instead of my current method, so i've been reading up on arrays in the mean time so i'll know how to implement the array if it turns out to be the best solution

    Kazuato

    I was referring more to how you Map for the Land is build you know (grass, sand, water etc...) if they are all Sprites as Tiles the easiest will be to add a Boolean "Selected" like a mentioned above.

    If you can share a mini Capx just enough to show your problem someone can have a look and give you quickly the Answer you need, other ways it will be more as keep guessing.

    Since you mention this

    [quote:wv8u8ysm]I'm using sprites for the plot selector, when a plot is selected it's not changing the colour, it's spawning a separate sprite that is coloured depending on which player owns the plot (red for p1, green p2, blue p3 and yellow p4)

    I guess "plot selector" the white one is a separate sprite swell so maybe you can try this

    The Loop that you have that goes Tile by Tile

    Subevent: is The white "plot selector" Not Overlapping "coloured already Spawned Sprite"

    Pick Random Tile >>>etc.........

    This way the "plot selector" knows if there is any Tile already selected if that makes sense for you?

  • If I'm understanding the question correctly, It sounds like there is tiles or "Plots" covering the whole view able area. What I don't understand is how the video you shared shows these "Plots" being selected vs how you describe it. You describe it as a player or NPC picking a "Plot" that they want to own(control?), but the video shows a very scripted, left to right, top to bottom method of scrolling through the plots one by one and assigning them to players...

    So, if a player is to click on a "Plot", then be able to take control of it, I would add an instance variable to each plot of whether or not it is owned (picked? most likely be a bool), then another variable for who it is owned by. If owned, then player can not choose to own it. So, clicking on and choosing to own/pick the "Plot" would be two separate actions.

    For the NPC's in this scenerio, I create a condition like:

    If a player or NPC is simply scrolling through each "Plot" (left to Right, Top to Bottom) by a method or using buttons / keys, then simply assign each Tile/Plot an int, and as the Tile/Plot is selected, create a method to check if it is owned (like in the previous method) and if it is, move the selection sprite (the white box sprite) to the next Tile/Plot:

    A pretty crude example that would need editing but, hopefully gives an idea.

    Again, not sure I'f I understand correctly what you're trying to do but, hopefully that helps

  • What I don't understand is how the video you shared shows these "Plots" being selected vs how you describe it. You describe it as a player or NPC picking a "Plot" that they want to own(control?), but the video shows a very scripted, left to right, top to bottom method of scrolling through the plots one by one and assigning them to players...

    the plot selector is designed to run along the screen in this linear fashion and the

    player has to press a button to select a plot once the selector reaches the plot they

    desire, this leaves the possibility of the player selecting the wrong plot open as a way

    of increasing the difficulty, kinda like those machines in an arcade where you have to stop

    a light by pressing a button but it moves so fast you have to time it right to stop the

    light where you want it to stop, and if your timing is off, the light wont land where

    you want it to land, in the final product the plot selector will start back at its original

    position each time a player selects a plot.

    this link:

    Subscribe to Construct videos now

    will take you to a video of the original mule game that we're basing this game on,

    if you skip to 1:10 you'll see the plot selection process happen in the original game,

    hopefully this shows you what i'm trying to explain better than my video or words have

    been able to yet haha

  • tarek2

    the background (grass, sand, water) is made using a sprite, there's no underlying grid attached to it for the plot selector to assign plots to, it just spawns a plot sprite at its current location when a player presses a button, I think I'm gonna try replacing the sprite based map with a tilemap instead now though because the loop the plot selector is on isn't tile by tile, I'm using set position to (self.x+65)(self.y) for horizontal movement and then setting it back to its original x position and moving it down on the y axis to start it on the next line down, this has its drawbacks though as it tends to move further and faster each time it begins a new cycle and I cant figure out why, so using a tilemap would give me a better way to control the plot selectors movement and accuracy

  • https://imgur.com/a/Vn6wc

    link to pics of plot selector events

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Kazuato

    There are many things still not very clear and confuse

    Is the Player allowed to select another NPCs Plot?

    Is the NPCs allowed to select Players Plot?

    Basically, who can choose who, or who cannot choose who, no idea yet

    Are they all can choose Plot at the same time in the same round???

    or

    Are they doing it one by one?

    If they doing it one by one who is first??

    Are they NPCs choosing Random plot from the whole Map or just between a few lines near to them? I see in your events like the NPCs just choosing position every 1.4 secs it looks like each NPCs are limited to a few Lines Max as the White plot selector cant travel very far in 1.4 so they will be most of the times spawn in the same line, that's why I'm asking, it looks everything very linear & in order

    Anyway since are many things unclear this is the Logic I found work best for me

    -Player choose Plot first

    -NPCs they already know player's Plot so it much easier to avoid his plot, and this way they are able to choose any Random plot from the whole Map

    -wait for the Selector pass by their Matching plot then set NPCs positions

    If is not exactly what you were looking for, the best thing is to simplify in steps your logic as shortest as possible like example

    1-press button start the new round

    2-player choose first

    3-NPCs choose after

    4-they cannot choose this but they can do that and so on

    If you keep using the waits like that you gonna end on trouble sooner or later use Timers instead

    [quote:1z9h73t4]

    one suggestion i was given was to use an array instead of my current method, so i've been reading up on arrays in the mean time so i'll know how to implement the array if it turns out to be the best solution

    I think that will be the best Idea

    Capx: https://www.dropbox.com/s/247hdhonuxkyp37/NpcPlotSelector1.capx?dl=0

  • the NPCs are allowed to choose any empty plot, as is the player, the event sheet shows it waiting and randomly selecting the NPC plots but that's only because i haven't gotten round to finishing the method the NPCs use to select their plots, this method only exists for me to be able to test other features are working right, eventually what will happen will be like this:

    -plot selector starts its run over the land

    -player clicks button when selector is over the plot they want

    -plot selector begins its cycle anew

    -NPC chooses its plot when selector is over the plot they want

    -plot selector begins its cycle anew

    -next NPC chooses its plot when selector is over the plot they want

    this continues until all four players have selected one plot each, each plot is only allowed to be selected once, so the player cant choose a plot that an NPC owns, the player also can't choose a plot he/she already owns, the same rules apply to each of the NPCs, as for who goes first, in the final product the game will randomly decide which player or NPC gets to choose the first plot and which order the remaining players get to choose, after the first turn, the player who is in the lead will choose the plot first and then the other players will get to choose in order of how well they're doing.

    so the first turn will have a randomly generated order for who chooses their plots and then all future turns will prioritise the winning player (winning chooses first, then 2nd place followed by 3rd followed by 4th).

    so the limited choices the NPCs currently have will not be limited in the final product, they will have the ability to choose any plot that isn't owned simply by choosing it when the plot selector is over the plot they want

    i hope this has cleared up some of the confusion

  • the NPCs are allowed to choose any empty plot, as is the player, the event sheet shows it waiting and randomly selecting the NPC plots but that's only because i haven't gotten round to finishing the method the NPCs use to select their plots, this method only exists for me to be able to test other features are working right, eventually what will happen will be like this:

    -plot selector starts its run over the land

    -player clicks button when selector is over the plot they want

    -plot selector begins its cycle anew

    -NPC chooses its plot when selector is over the plot they want

    -plot selector begins its cycle anew

    -next NPC chooses its plot when selector is over the plot they want

    this continues until all four players have selected one plot each, each plot is only allowed to be selected once, so the player cant choose a plot that an NPC owns, the player also can't choose a plot he/she already owns, the same rules apply to each of the NPCs, as for who goes first, in the final product the game will randomly decide which player or NPC gets to choose the first plot and which order the remaining players get to choose, after the first turn, the player who is in the lead will choose the plot first and then the other players will get to choose in order of how well they're doing.

    so the first turn will have a randomly generated order for who chooses their plots and then all future turns will prioritise the winning player (winning chooses first, then 2nd place followed by 3rd followed by 4th).

    so the limited choices the NPCs currently have will not be limited in the final product, they will have the ability to choose any plot that isn't owned simply by choosing it when the plot selector is over the plot they want

    i hope this has cleared up some of the confusion

    Kazuato All made perfect sense until I hit This again which contradicts everything

    [quote:1ifd7ngv] the player also can't choose a plot he/she already owns

    How can the Player already be owning a "Plot" if he/she is only allowed to choose one Plot and when the players turn comes to choose a plot it starts fresh there no plots selected yet?

    it looks like you talking about saving all the plot previously chosen Plots by Player & NPCs maybe?? which if is true will change the whole thing about how you build the logic

    And this leads to the "key Question" I think this is the one that is been confusing the whole thread

    How do you define a full round Game

    1-Full Game by (Cycle Rounds)

    Each Player choose his plot on their turns then their plots are saved = end of one cycle

    The second cycle >>the same Each Player choose his plot on their turns (The only difference he cannot choose any of his previously saved plot chosen) then their new plots are saved swell = end of the second cycle

    The third cycle >>>> same but cannot choose any of the whole plots previously saved in previous cycles the same and so on

    The cycles go on until they are no more free Plots to choose in the next round as already they own the whole Plots= End of one "full round Game"

    2-Each player chose their plot on their respective turns and by the end of this choose who is the winner's end and start new and fresh round, but this still leaves the same question (How can the Player already be owning a "Plot")

  • tarek2

    sorry i forgot to mention that you get to choose a new plot each turn, the turn structure goes like this:

    -players acquire plots of land.

    -players then pick up a mule (gull)

    -players then equip the mule(gull) with a resource

    -players take mule (gull) to their chosen plots

    -the mules (gulls) stay in the plots and produce more of their equipped resource

    -the players end this stage by entering a building (pub)

    -the next stage begins in which the players take turns buying and selling resources from one another

    -the turn then ends and the process is repeated beginning with each player selecting a new plot whilst continuing to own the plots from previous turns.

    the turns are preset at 6 or 12 turns for a full game, this stops the game going on long enough that no plots will be available to buy at the start of a new turn, the reason I've neglected to include this information is because I didn't realize how confusing my explanations would be without the full turn structure included, but the moment I read the quote that confused you again, I realized that I should explain how an entire turn works, I got a little lazy in an earlier post by using a youtube video of the original game hoping it would explain it all but in hindsight, it's a long video and i only directed readers to the part that shows plot selection, so i now realize that if i wanted that video to explain all i should have said for readers of my post to watch the video from start to at least the 2nd turn, still, I've explained the full turn structure now and hopefully this will help with the confusion I've caused

  • Kazuato

    [quote:1uv4t38v]sorry i forgot to mention that you get to choose a new plot each turn, the turn structure goes like this:

    -players acquire plots of land.

    -players then pick up a mule (gull)

    -players then equip the mule(gull) with a resource

    -players take mule (gull) to their chosen plots

    -the mules (gulls) stay in the plots and produce more of their equipped resource

    -the players end this stage by entering a building (pub)

    -the next stage begins in which the players take turns buying and selling resources from one another

    -the turn then ends and the process is repeated beginning with each player selecting a new plot whilst continuing to own the plots from previous turns.

    No Problem mate,

    Since we now have a clear view of what you trying to do then the Answer to your Original question will be (Arrays or Sprites) and since you mention earlier that you need to learn Arrays I will recommend you (Sprites as a Tile) because you can add variables & booleans as you need and is much easier to control, for the size of the Land area you don't need many Tiles

    Here is a Demo Capx : https://www.dropbox.com/s/1gtbbw209dcilqf/NpcPlotSelector2.capx?dl=0

    Now on this Capx at the end of every cycle waits 3 seconds and goes directly to the next cycle where they can choose again Land, I left it like this intentionally so you can Debug and see how it works and to check how they chose new Lands without selecting the already Owned from previous Cycles, and the other reason so you can add your own Logic on top of it other ways you will not learn.

    I didn't comment it because I put names to the (Variables, Booleans, Functions & Timers) that they explain by them selfs so it should be easy to follow

    -if you don't wanna use Overlap for the "selector" check my first capx, there I did it without Overlap and copy it

    Now since you already have you Logic it should be very easy to adapt it to your needs

    Example:

    New Cycle Starts

    (Acquire plots)

    -players acquire plots of land.

    -at the End of this cycle when the 4 Players choose Land instead to wait 3 secs and go to Next cycle change it

    to go to (mule (gull)) you need probably a boolean "MuleGull" so is easier to split the States from (Acquire plots) to (MuleGull)

    On (MuleGull)

    -players then pick up a mule (gull)

    -players then equip the mule(gull) with a resource

    -players take mule (gull) to their chosen plots

    -the mules (gulls) stay in the plots and produce more of their equipped resource

    -the players end this stage by entering a building (pub)

    -the next stage begins in which the players take turns buying and selling resources from one another

    -the turn then ends and the process is repeated beginning with each player selecting a new plot whilst

    continuing to own the plots from previous turns.

    -Go to (Acquire plots) Again and so on

    Looks pretty easy you cant get lost,

    Last Thing

    You Mentioned about the turns to choose Plot will be changing constantly at the End of each Cycle, depending on some Variables example Points etc......

    I added a Variable for that too >> Var "MyTurnTo_PlayIs"

    it should be as simple as adding a New Variable called however you wish, example "Points" then before you send them to (Acquire plots) do the assign (Turns to Play )

    Example

    Create a Local Var "Positions" = 1

    For Each Order

    Sub: Pick "NPC" Family >> How you wanna order? enter by >> NPC.Points >>Then Descending

    Actions>>Set NPC >>To the Local Var "Positions"

    Then Add 1 to Local Var "Positions"

    This will assign the turns to play from the NPC that have the highest "Points" which will be = 1 Turn to the Lowest which will be = 4

    One more Last Thing

    a friendly advice, the Next time you asking for help try to go straight to the Point, think what you need before you posting, write it down if you have to, don't add any extras that are unnecessary, clear, precise and as simple as possible, other ways will be like a guessing game were you lose time and the people that trying to help swell making Capx & Examples that after they going to the trash which they took some time to make

  • hi, sorry for taking so long to respond, you've been a massive help so far my dude, i thank you for that, i have a question about the example code, would this also work if i wanted to make all players (including npcs) pick their plot during the same plot cycle? turns out i was wrong about how the plots are meant to be chosen, all players are supposed to pick their plot in the same cycle as only one cycle is meant to happen in each round

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)