Hello again!
I'm looking for an efficient way to create a turn-based pathing system. I could link a video directly outlining what I want, but it's a showcase of a WIP and I believe that's technically stealing.
First, my disclaimer: I DO NOT WANT A TURN BASED TRIGGER SYSTEM. JUST A MOVEMENT SYSTEM.
Anyway, here's what I want:
When a player selects his unit to move, the unit has a specific amount of movement tiles it can move before being locked out of movement until the next turn. For example, say a marine can move 10 squares per turn. That means, if he moves 5 squares, he can move 5 more squares before having to wait until the next turn.
I have NO idea how to create this effect. I'm not looking for any fancy graphic effect, I just want a nice, clean and working solution. I'd be very grateful.
Thanks in advance!
Note: I will PM the video to anyone willing to help, and I can expand further in detail if I must.
So after you select the marine do you then click on the destination tile you wish him to move to? If so I'm guessing you would also need to find a path around obsticles as well?
For this you will need what is called a graph. It can represent a series of discrete locations and the connections between them. To find the path from source to destination you will have to run a path finding algorithm such as a breadth first search to discover what path the unit should take.
You would also need an array containing each unit and the number of moves it has left in this turn.
Also I would recomend using hexagons instead of squares. It will not be any harder from a coding perspective and will mean that players can travel diagonally much easier.
This kind of task would be about 2nd year college/university level. So I would not recomend it for someone without a little experience under their belt.
An easier task would be letting the user decide the path that the unit takes by only letting them select the tiles adjacent to the current tile. For your example of the marine that can travel 20 tiles that would involve 20 clicks from start to finish though. Or you could not bother with obsticles and let units travel through eachother and the environment. Both of these tasks would be considerably easier.
Happy to help if you want ideas on how to go about any of this.
Well, actually, your paragraph about making them only be able to select an adjacent tile is exactly what I need. I just didn't think it was possible.
However, I'm only a freshly graduated high school student. I haven't started college yet. But this is probably the hardest system I need to create. I'd like to attempt it.
Hexagons, squares, circles, it doesn't matter to me. It was really only an idea as a visual for the players to know where they could click to. And yes, you guessed correct. The entire system is based on left clicking.
I do need obstacles, as I'm replicating a tile-based game and some tiles were impassable trees or other units. Speaking of which, units should have collision in this example. More than that, my unit should not be able to enter a square that is occupied by another unit.
To Soulcarver, I've already seen his video and he doesn't finish the set. I'm also not an idiot and wasn't looking for somebody to do the work for me. I was looking for someone to shed some light on the subject.
You could make your squares, put beacons in the center of them. While it is not their turn, apply a behavior that suppresses their movement, then when it's their turn. For moving them, when it's their turn, the behavior stays applied, but they select the unit and then right click a beacon for movement, when the beacon is right clicked the behavior is lifted the unit is ordered to move to it, and you make the unit uncommandable while it's moving. and so you allow them them to select adjacent beacons up to the max number of movement allowed.
Does it have to be solely triggered based; I mean if your not using the energy on the units why not just have the movement require energy to move without a regen which is instead replenish each turn by a trigger. I think this would be way more slick.
If you are happy only being able to select adjacent tiles to move to and repeat this 20 times for a unit which can move 20 spaces then I would say it is doable for a freshly graduated highschooler who knows his shit. It's still going to be hard work though.
Obviously there are a million different ways to skin a cat create a program.
Personally I am thinking something like a really basic version of "The Battle for Westnoth" which can be seen here:
(GOD DAMN I love that game!)
Obviously I am biased by how obsessed I was with that game for a while. I'm guessing your vision of what you want would be different in many ways.
Just brainstorming here but if I were to do it I would make all the units unselectable. Instead I would coat the ground with units with the hexagon decals (like what was done in the map cloud kingdom http://i.imgur.com/Hfqlp.jpg ) with a large selection radius. That way if a player clicks inside a hexagon it will select that hexagon.
Make each hex invisible and then when a player clicks a hex with a unit on it then the surrounding hexes become visible. If they click on an empty hex nearby then the unit moves to that hex. If the hex they clicked on had another friendly unit then select that unit instead. If it is impassible terrain then don't move the unit. If it contains an enemy unit then get the unit to attack the enemy unit.
hmmm... giving serious consideration to making a starcraft version of "battle for westnoth" right now! lol
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello again! I'm looking for an efficient way to create a turn-based pathing system. I could link a video directly outlining what I want, but it's a showcase of a WIP and I believe that's technically stealing.
First, my disclaimer: I DO NOT WANT A TURN BASED TRIGGER SYSTEM. JUST A MOVEMENT SYSTEM.
Anyway, here's what I want:
When a player selects his unit to move, the unit has a specific amount of movement tiles it can move before being locked out of movement until the next turn. For example, say a marine can move 10 squares per turn. That means, if he moves 5 squares, he can move 5 more squares before having to wait until the next turn.
I have NO idea how to create this effect. I'm not looking for any fancy graphic effect, I just want a nice, clean and working solution. I'd be very grateful. Thanks in advance!
Note: I will PM the video to anyone willing to help, and I can expand further in detail if I must.
@thequiet: Go
So after you select the marine do you then click on the destination tile you wish him to move to? If so I'm guessing you would also need to find a path around obsticles as well?
For this you will need what is called a graph. It can represent a series of discrete locations and the connections between them. To find the path from source to destination you will have to run a path finding algorithm such as a breadth first search to discover what path the unit should take.
You would also need an array containing each unit and the number of moves it has left in this turn.
Also I would recomend using hexagons instead of squares. It will not be any harder from a coding perspective and will mean that players can travel diagonally much easier.
This kind of task would be about 2nd year college/university level. So I would not recomend it for someone without a little experience under their belt.
An easier task would be letting the user decide the path that the unit takes by only letting them select the tiles adjacent to the current tile. For your example of the marine that can travel 20 tiles that would involve 20 clicks from start to finish though. Or you could not bother with obsticles and let units travel through eachother and the environment. Both of these tasks would be considerably easier.
Happy to help if you want ideas on how to go about any of this.
@thequiet: Go
simple search came up with a bunch of stuff on this.
Look for programer sample map
http://www.sc2mapster.com/forums/resources/tutorials/27510-triggers-turn-based-strategy-grid-movement-setup-looking/
chances are that it is way over your head.
You arn't going to find a simple paste in solution.
Well, actually, your paragraph about making them only be able to select an adjacent tile is exactly what I need. I just didn't think it was possible.
However, I'm only a freshly graduated high school student. I haven't started college yet. But this is probably the hardest system I need to create. I'd like to attempt it.
Hexagons, squares, circles, it doesn't matter to me. It was really only an idea as a visual for the players to know where they could click to. And yes, you guessed correct. The entire system is based on left clicking.
I do need obstacles, as I'm replicating a tile-based game and some tiles were impassable trees or other units. Speaking of which, units should have collision in this example. More than that, my unit should not be able to enter a square that is occupied by another unit.
To Soulcarver, I've already seen his video and he doesn't finish the set. I'm also not an idiot and wasn't looking for somebody to do the work for me. I was looking for someone to shed some light on the subject.
You could make your squares, put beacons in the center of them. While it is not their turn, apply a behavior that suppresses their movement, then when it's their turn. For moving them, when it's their turn, the behavior stays applied, but they select the unit and then right click a beacon for movement, when the beacon is right clicked the behavior is lifted the unit is ordered to move to it, and you make the unit uncommandable while it's moving. and so you allow them them to select adjacent beacons up to the max number of movement allowed.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
Does it have to be solely triggered based; I mean if your not using the energy on the units why not just have the movement require energy to move without a regen which is instead replenish each turn by a trigger. I think this would be way more slick.
If you are happy only being able to select adjacent tiles to move to and repeat this 20 times for a unit which can move 20 spaces then I would say it is doable for a freshly graduated highschooler who knows his shit. It's still going to be hard work though.
Obviously there are a million different ways to
skin a catcreate a program.Personally I am thinking something like a really basic version of "The Battle for Westnoth" which can be seen here:
(GOD DAMN I love that game!)
Obviously I am biased by how obsessed I was with that game for a while. I'm guessing your vision of what you want would be different in many ways.
Just brainstorming here but if I were to do it I would make all the units unselectable. Instead I would coat the ground with units with the hexagon decals (like what was done in the map cloud kingdom http://i.imgur.com/Hfqlp.jpg ) with a large selection radius. That way if a player clicks inside a hexagon it will select that hexagon.
Make each hex invisible and then when a player clicks a hex with a unit on it then the surrounding hexes become visible. If they click on an empty hex nearby then the unit moves to that hex. If the hex they clicked on had another friendly unit then select that unit instead. If it is impassible terrain then don't move the unit. If it contains an enemy unit then get the unit to attack the enemy unit.
hmmm... giving serious consideration to making a starcraft version of "battle for westnoth" right now! lol