Jump to content


Photo
* * * * - 1 votes

Turn Based Tactics: Part 1


  • Please log in to reply
45 replies to this topic

#1 Mnementh

Mnementh

    15151

  • GMC Elder
  • 6400 posts
  • Version:GM:Studio

Posted 06 April 2008 - 07:43 PM

  • Title: Turn-Based Tactics Tutorial
  • Description: Use Dijkstra's algorithm to find out how far the units can travel in your turn-based tactics game.
  • GM Version: 7 / 6
  • Registered: Yup (for both versions)
  • File Type: .zip
  • File Size: 122 KB / 107 KB
  • GM7 Download: box.net host-a.net
  • GM6 Download: box.net host-a.net
This is an advanced tutorial; you should completely understand basic GML and data-structures before you begin.

--------------------

Posted Image Posted Image Posted Image

--------------------

After you complete the tutorial, if you don't understand the algorithm, or you want to know more about path-finding, you should check out this article on the A* algorithm. It's very well written, and was very helpful during the making of this tutorial.

Please feel free to let me know what you think of it, things that could be improved, things that could be added...
  • 2

#2 LRG

LRG

    GMC Member

  • GMC Member
  • 687 posts
  • Version:GM:Studio

Posted 28 April 2008 - 10:25 PM

this is pretty good but you need some commenting for less advanced users. Let's hope you can finish this soon :(
  • 0

...Coming to you May 1, 2012 or later...
Posted Image


#3 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 29 April 2008 - 12:00 AM

This is extremely useful, very informative & clear & well written. Great job. Could be applied readily to tacticalRPGs, Boardgames or games like Advance Wars.

If more people were as willing to spend time sharing what they knew in this manner, the community would benefit so much.
Thanks for putting in your time to make this tutorial.

Please continue with part 2! :unsure:
  • 0

AczgxAZ.png5aj9t5.jpg
 


#4 Sinaz

Sinaz

    MCP Killer

  • GMC Elder
  • 2751 posts
  • Version:GM8

Posted 29 April 2008 - 04:32 AM

this is pretty good but you need some commenting for less advanced users. Let's hope you can finish this soon :unsure:

Don't forget that there is a comprehensive html tutorial included with the .gmk. Reading that is integral to understanding the coded example.
  • 0
S I N A Z

That's SINAZ... He fights for the Users.

I am retired from providing GML Mentorship, but I am available to answer questions about career and educational goals & strategies to members who are interested in pursuing game development as a life long profession. Just PM me!

Please please please: pin a shortcut or link to the GM manual to your Start Menu. Open it up whenever you are offering advice on functions you are not 100% familiar with and refer to it before committing your post.

#5 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 02 May 2008 - 06:11 PM

I see you ask for possible improvements & additions in your post. Here are some..

1. Consider changing the name of the topic if possible. Only a certain amount of people would be looking specifically for a "tactical RPG tutorial", quite a few more people would be looking for "boardgame movement" & "advance wars" tutorials.
I'm not sure exactly what to change the title too.. but perhaps the "sub-title" should be "tacticalRPG/boardgame/advancewars" so people searching for those will find this topic.

2. I don't know what you have planned for part 2, but I would think the most basic elements should be covered. Such as:

Selecting & deselecting characters & actually moving your selected characters.
Various "attack" ranges.

This would result in a great tutorial set that *alot* of people could use as a foundation for their projects.

Best of luck.
  • 0

AczgxAZ.png5aj9t5.jpg
 


#6 LRG

LRG

    GMC Member

  • GMC Member
  • 687 posts
  • Version:GM:Studio

Posted 02 May 2008 - 11:03 PM

this is pretty good but you need some commenting for less advanced users. Let's hope you can finish this soon :whistle:

Don't forget that there is a comprehensive html tutorial included with the .gmk. Reading that is integral to understanding the coded example.


I know, I'm just saying that putting down comments will make the scripts much easier to follow. :D
  • 0

...Coming to you May 1, 2012 or later...
Posted Image


#7 samglo

samglo

    GMC Member

  • GMC Member
  • 75 posts

Posted 03 May 2008 - 04:04 PM

Brill tutorial. Any ideas on how to impliment a movement to go with it i have tried my self but failed i could make the player move but could not limit the number of spaces it was like they wernt even there...
  • 0
Best signature ever:D

#8 Mnementh

Mnementh

    15151

  • GMC Elder
  • 6400 posts
  • Version:GM:Studio

Posted 04 May 2008 - 12:31 AM

Hey guys.

First off, I really appreciate all of your comments.

Second, I am definitely going to continue making these.

this is pretty good but you need some commenting for less advanced users. Let's hope you can finish this soon


While this tutorial is only intended for those users who are already knowledgeable, I may add some general comments to the code. I will have to think about it, because I really don't want to end up doing this.

i = 1; // set i to 1

Anyone see any use in that comment? I didn't think so.

1. Consider changing the name of the topic if possible. Only a certain amount of people would be looking specifically for a "tactical RPG tutorial", quite a few more people would be looking for "boardgame movement" & "advance wars" tutorials.
I'm not sure exactly what to change the title too.. but perhaps the "sub-title" should be "tacticalRPG/boardgame/advancewars" so people searching for those will find this topic.


Hm... you're right. I'll have to think about that.

Selecting & deselecting characters & actually moving your selected characters.
Various "attack" ranges.


That is exactly what I was going to do in the second one. Possibly with some other stuff.

I have one question for you guys, and I need a graphic to make it. Unfortunately, the computer I'm writing this from doesn't have any image editing program, so...

-----------
| | | |1| |
-----------
| | | |X| |
-----------
| | |P| | |
-----------

Assuming that there is a player at P, and X is impassable, can the player hit 1?

By the way, I have to thank Nailog, who has helped me twice with problems I've had with this. Thanks!

Edited by Mnementh, 06 May 2008 - 12:01 AM.

  • 0

#9 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 05 May 2008 - 08:09 PM

I'm happy to hear you are continuing with this.
I'm sure plenty of people will make use of it once you have added more.
in answer to your question about p x & 1... it depends.
I would say in most normal case the answer would be no..
but it depends entirely on how you are going about implementing your attack range..
& how customisable you want it to be..

I have spent a few minutes here on a graphic illustrating some possible attack ranges for characters.
Perhaps some things you may not have considered. (White=player Red=AttackRange)
Examples include simple directly adjacent squares, single line fire (for cannons/strong magic blasts),gradually falling off attacks (for weapons that lose their effectiveness with distance), etc. Naturally there are plenty more, these are just a few that sprang to mind, typical tactical RPG "direction facing only attacks" should also be implemented.

I would suggest, if possible, that the attack ranges be made easily customisable rather than tied to a specific routine.
However, I think in most cases that expanding the tutorial to include selection & movement within the established movement ranges would suffice for most. (As I would guess perhaps that many people might want to use their own "attack system".

Very best of luck with this. The Movement range finding is a lovely piece of code. I eagerly await the actual movement. :ph34r:

Edited by dadio, 27 March 2009 - 11:49 PM.

  • 0

AczgxAZ.png5aj9t5.jpg
 


#10 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3734 posts
  • Version:GM:Studio

Posted 05 May 2008 - 11:42 PM

Hey guys.

I have one question for you guys, and I need a graphic to make it. Unfortunatly, the computer I'm writing this from doesn't have any image editing program, so...

-----------
| | | |1| |
-----------
| | | |X| |
-----------
| | |P| | |
-----------

Assuming that there is a player at P, and X is impassable, can the player hit 1?

By the way, I have to thank Nailog, who has helped me twice with problems I've had with this. Thanks!

Well in TSR's Advanced Dungeon and Dragons and other D20 type dice rolling adventures they would call that shooting around a corner or only being able to see a part of the target's body...to simulate the hit they decrease the chance to hit by penalizing the roll by a certain constant.
Ex:
A 20 side die (1 - 20) is used to simulate hit dice (a number to roll to see if player hit another)
The NPC is standing around a corner and the player can only see 25% of him...so he subtracts 1 point for every 25% that he can not see. so a total of (-3) to the roll. due to armor and defense -vs- attack and power he has to roll a seventeen to hit the NPC.
BUT-- at the end of the roll the player must minus the 3 from his roll due to the character around the corner.....lets hope he hits it huh?

anyway, that was just a simulation to what I was thinking about.. your pic shows that (1) seems to be partially unattainable due to the fact that (X) might be covering it or something...that would be my solution:
subtract a rate from the player's normal hit rate depending on how much he can see the NPC>

:ph34r:
  • 0

Those who can, ...do. - Those who can't, ... teach, .. or probably took an arrow to the knee.

Avatar created by Stewart. They take avitar requests here


#11 nononick

nononick

    GMC Member

  • New Member
  • 34 posts

Posted 09 May 2008 - 03:47 PM

-----------
| | | |1| |
-----------
| | | |X| |
-----------
| | |P| | |
-----------


well, relies on the game.

in Advance Wars it would be possible, because the tank moves to the spot next to it before shooting, and it would probably
be water anyway, so ranged attacks would be possible too.

never played a game like Dungeons&Dragons, so I can't meddle with other ideas.

and thanks, I always wanted to know how to do something like this :P
  • 0

#12 Slugby

Slugby

    GMC Member

  • New Member
  • 1 posts

Posted 14 May 2008 - 12:29 PM

Very nice work. You just what I've been looking for. {Well I've been looking for like 24 hours.} Back in the day I made the "my first game" thing but without the tutorial. =P I came back seeking to do bigger and better things. I wanted to make a turn-based strategies game. {like advance wars} I wanted to make a game kinda similar to Star Wars Miniatures but with an army theme and with advance strats and techniques.
Seeing as this is my first "major" game on GM all that stuff was a bit over my head. I have done some simple programs in Visual Basic at school and I was wondering if anyone had a link for a tutorial with more of the basics.

Just so people know this si my first post and I hope I'll stay with this forum for quite some time.

Edited by Slugby, 16 May 2008 - 09:08 AM.

  • 0

#13 x-death

x-death

    Flash Developer

  • GMC Member
  • 3402 posts

Posted 15 May 2008 - 02:47 AM

this is good but would have been better showing users how to select the player objects and maving them within the ranges or if theres another object you could even show attacking.
  • 0
If your interested in having a flash website programmed for you at a cheap price. you can message me!

Resources: My Pack
My Galleries: Deviant Art, Pixel Joint
Examples: Pausing System, External Loading
Guides: Pixel Art, Creating Games, Reviewing Games
Games: A.C.W, Thunder God, Ip Utility, Rocketive

#14 jpcproductions

jpcproductions

    GMC Member

  • GMC Member
  • 74 posts

Posted 19 May 2008 - 03:29 AM

Looks sweet. For part 2, you should make enemies that move and attack once you finish moving and attacking.
Keep up the good work.
  • 0
Posted Image

#15 blaketheawesomedude

blaketheawesomedude

    GMC Member

  • New Member
  • 295 posts

Posted 21 May 2008 - 01:01 AM

can make um for unreg?
  • 0

#16 Fractal

Fractal

    GMC Member

  • New Member
  • 849 posts

Posted 21 May 2008 - 07:25 PM

EDIT: I'm hoping to release the second one by the time this one hits 500 downloads.

Again, thanks for you replies. They do help.

@dadio, that graphic is great! I hadn't thought of that, because I really haven't played any games like this except Fire Emblem, so that thought hadn't even occurred to me. Thanks.

I would suggest, if possible, that the attack ranges be made easily customisable rather than tied to a specific routine.


Definitely so. I don't really like the code, but I think I'm going with a system where the attack range is created in an array, by hand, and then at execution, the game checks each of the designated squares.

One thing that I am going to try to make clear, is that as much of the attack code as possible should be in the weapon objects, and not the player objects. Generally, the attack range of a player is defined primarily by the weapon that they are using, so this would allow different weapons to be made quite easily.

EDIT: Changed my mind about this, and I am no longer going with weapon objects... I think.

@drt_t1gg3r and nononick, thanks for your input. I'm going with the line-of-sight method. If the player can see from the center of one cell to the center of the other, it's good.

@x-death and jpcproductions, part 2 will have:
  • Selection
  • Movement
  • Weapons
  • Attack Range
@blaketheawesomedude, it would be possible, but that would require me to reproduce all of the data structures in pure GML, which I definitely don't want to do. Sorry.

Edited by Fractal, 08 June 2008 - 04:10 AM.

  • 0

#17 everydayghost

everydayghost

    Break Free

  • GMC Member
  • 582 posts
  • Version:GM:Studio

Posted 22 May 2008 - 07:49 AM

you should make it so that you can move the selected player around within the range
  • 0

Watching the world burn.
Dancing in the flames.


#18 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 12 June 2008 - 11:12 AM

Glad to hear you're still working on this :GM026:
"Line of sight method" eh? - I'm interested to see how you go about it.

To be honest, I have a feeling (as I said earlier) alot of people would want to create their own "attack range + attacking +damage calc. etc", or possibly stick to very simple "next tile" attacks..
so I kind of feel that the real important bit of what you're doing now is the actual "selection & movement within the range"
(or at least that's the bit that I'm eagerly awaiting! :GM075:
Though, I appreciate that you're putting the time & effort into making it a very "complete" package!

I'm quite excited about this now, as I have not seen *any* turn based games created with GameMaker..
& if this example is as clear & informative as your 1st one, then we might see quite a few original turn based games popping up - which is great!

Well, keep us up to date & very best of luck with it! :GM006:

PS: Will your attack range stick to simple setups or include the likes of "bomb throwing" (1 tile out + wide damage area) & "distance weapons" (+2 tiles out only for example), will it take into account different terrain (long range losing range through trees, long range not going through hills at all etc?) - just curious - none of this is needed, & personally I'm most interested in the movement -
but the more complete the package, the more the average user is going to use it.
If there is alot of work going into the weapons/attacks then it might be an idea to split the package into 2?
Have selection & movement in one... & another part with weapons/attacks? Just an idea.
Keep up the great work!
  • 0

AczgxAZ.png5aj9t5.jpg
 


#19 Overdrive Productions

Overdrive Productions

    GMC Member

  • New Member
  • 18 posts

Posted 17 December 2008 - 11:00 AM

I'm just going to throw this out in the open, do you think it'd be possible to create a tutorial like this, but as you're designing it, you explain it piece by piece - just for us newbies?

It's just because I'd love to be able to understand it better as I've checked this one and nailog's...and it's still kinda Russian to me.

Just once you finally understand coding completely, there's tons of ideas that I have - they're just all stuck in my head because I can't really do anything with them - yet...
  • 0

#20 Incon

Incon

    GMC Member

  • GMC Member
  • 192 posts

Posted 19 December 2008 - 03:56 PM

Nice tutorial.

My idea for the next part would be: When you mouseover a cell, it should highlight the path to that cell and then move the unit along the path and not just teleport it.
The attack range and line of sight check is rather easy, if you ask me.

Another thing that would be handy:
Lets say we have 2 terrain types: grass and mud. When you place them next to each other the transistion will be green tile... next pixel brown tile. You can check all grass cells if a neighbouring tile is mud and then draw another sprite to make it a smooth transistion between both terrain types.

And you made a mistake in the html file:

{
with ( objCell )
{
if ( Active )
exit;
}

Active = true;

FindMovementRange( instance_position( x, y, objCell ), MoveRange, AttackRange );
with ( objCell )
{
if ( Reachable )
image_index = 1;
}
}


Should be objPlayer

Edited by Incon, 20 December 2008 - 12:53 PM.

  • 0

#21 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 10 January 2009 - 05:08 AM

Me again :lol:
(Sorry things couldn`t go as planned with that project I mentioned
- I`m still 100% interested in it -
just finding it very hard to find the time to work on my own stuff lately (just so busy with work)...
but I will have a load of free time from March onwards when I plan to put serious hours into that project & a few others).

Yeah so just wondering when/if part 2 of this tutorial is coming out?
Well past the 500 downloads at this stage ^_^
It`s really nice & if the 2nd part was up too, I`d love to see all the GM AdvanceWars-ish type games that get made, as I *love* those games!

(Really curious to see how you go about the movement & attacks etc - hope you haven`t abandoned the tutorials)
Goodluck!
  • 0

AczgxAZ.png5aj9t5.jpg
 


#22 Mnementh

Mnementh

    15151

  • GMC Elder
  • 6400 posts
  • Version:GM:Studio

Posted 10 January 2009 - 03:56 PM

Yeah so just wondering when/if part 2 of this tutorial is coming out?

I've been wanting to make the next part. However, I've learned a lot about software architecture since I made this tutorial. I have this picture in my head of a beautiful piece of software, which would be extraordinarily flexible. However, my last tutorial falls far short. I've been thinking about writing the next tutorial more from this perspective, so I would probably include movement, but only as an after-thought.

Well past the 500 downloads at this stage

I think it's past 1000... I've switched hosts (don't trust WHFF anymore), and changed the files a few times, so the count is incorrect, but I'm pretty sure.

Sorry things couldn`t go as planned with that project I mentioned
- I`m still 100% interested in it -

Me too. :)

Edited by Mnementh, 10 January 2009 - 03:59 PM.

  • 0

#23 Roar_Man

Roar_Man

    GMC Member

  • New Member
  • 8 posts

Posted 12 January 2009 - 03:24 AM

Great little thing you got here, extremely helpful, and I'm very looking forward to part 2.
  • 0

#24 zblade

zblade

    GMC Member

  • New Member
  • 23 posts

Posted 18 January 2009 - 10:04 PM

I must say the tutorial is extreamly well written, great job. looking forward to part II.
  • 0

#25 lightemup

lightemup

    GMC Member

  • New Member
  • 3 posts

Posted 20 January 2009 - 01:05 AM

This example is perfect for checking movement range, but would be much better with some additions.
Incon said

When you mouseover a cell, it should highlight the path to that cell and then move the unit along the path and not just teleport it.

This would be a very good improvement. Make the example similar to how AdvanceWars works, cell by cell so you can choose the exact path you wish to go. Including movement of the unit to the target cell would be good and sprite switches depending on movement direction.
  • 0

#26 dariusk

dariusk

    GMC Member

  • New Member
  • 5 posts
  • Version:Unknown

Posted 21 July 2009 - 05:35 PM

Hey, this is a fantastic tutorial, but I just found a bug in the code. The problem I was having was that if you take the example code and attempt to add a ds_map to the objPlayer object, you get the "Data structure with index does not exist" error when you attempt to run the FindMovementRange function. The reason is that there's code in the function that attempts to evaluate the handle of a ds_map as a ds_priority. To fix it, you should find every instance of:

if ( _dist < ds_priority_find_priority( _mapDist, id ) )

And replace it with

if ( _dist < ds_priority_find_priority( _priorityOpen, id ) )

That will fix the problem!
  • 0

#27 Hellflame Games

Hellflame Games

    GMC Member

  • New Member
  • 36 posts

Posted 21 July 2009 - 09:33 PM

This tutorial was incredible, though it's a little short.

I got a small tip to improve a little thing that's actually pretty easy to add.
The selection, when you select a character/square then make us automatically deselecting our target, and able to switch target by just
pressing on a new.

I hope you understood this, though I'm not that good in english.
However, I really hope part 2 comes, and if you remember, please, PM me when you've done it.
Good luck!

Regards
  • 0
╔╦═╦┤
╠╬═╬┤ New profile, Warcry Online.
╚╩═╩┤

#28 Mnementh

Mnementh

    15151

  • GMC Elder
  • 6400 posts
  • Version:GM:Studio

Posted 22 July 2009 - 03:19 AM

Wow... looking back, there are a few things about this tutorial that I really don't like. :) I think I'm going to clean the code up a little, do a little refactoring, and possibly add movement as well. Attack range... we'll see.

Edit: I wish there was somewhere I could incorporate one of the more advanced pathfinding algorithms into this tutorial, but I really can't think of any situations in which the AI is not aware of the entire map.

Hey, this is a fantastic tutorial, but I just found a bug in the code. The problem I was having was that if you take the example code and attempt to add a ds_map to the objPlayer object, you get the "Data structure with index does not exist" error when you attempt to run the FindMovementRange function. The reason is that there's code in the function that attempts to evaluate the handle of a ds_map as a ds_priority. To fix it, you should find every instance of:

<snip>

Thanks. It's hard to catch those bugs, since everything works correctly until you try to extend the tutorial.

I got a small tip to improve a little thing that's actually pretty easy to add.
The selection, when you select a character/square then make us automatically deselecting our target, and able to switch target by just
pressing on a new.

Although I that wasn't really part of what I intended to teach with this, there's really no reason not to add that feature.
  • 0

#29 dariusk

dariusk

    GMC Member

  • New Member
  • 5 posts
  • Version:Unknown

Posted 22 July 2009 - 09:55 PM

Edit: I wish there was somewhere I could incorporate one of the more advanced pathfinding algorithms into this tutorial, but I really can't think of any situations in which the AI is not aware of the entire map.


What about a fog of war scenario? In that case, the AI would be constrained to not knowing what's in the "dark" squares but could conceivably attempt to move there.
  • 0

#30 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3734 posts
  • Version:GM:Studio

Posted 24 July 2009 - 03:13 PM

Hey mnementh, now that your education has grown beyond the scope of this tutorial, what about giving us a tutorial on the basic structure of turn based systems. You could incorporate small tid-bits here and there, but get more of the idea and not so much the detail down. I know when I think "turn based" it brings up a whole mess of ideas. However, I think what I lack most is the stucture.

Being an intermediate student of game design (2 years of college) I am finding the structure of things totally out weighs all the minor detail. I can remember when my programming and problem solving teach said "scripting is the easiest part of game design" I thought he was crazy. Now, a year and a half later I realize what he ment. I now spend 85% of my time putting my game(s) down on paper and working out the "flow" of the game, 14% hashing and re-hashing the mechanics and 1% scripting.

Still waiting patiently for your next one to come. ^_^
  • 0

Those who can, ...do. - Those who can't, ... teach, .. or probably took an arrow to the knee.

Avatar created by Stewart. They take avitar requests here


#31 Wildroses

Wildroses

    GMC Member

  • New Member
  • 4 posts

Posted 30 July 2009 - 04:40 PM

First of all I'd like to say that even if this is only V1 it was still an excellent tutorial and helped me a lot.

I have a quick question for you. Currently implemented you have 'easy', 'medium', and 'impassable' tile squares. I was wondering if it would be possible to create a square that is impassable to units unless they have a certain tag (say 'Can Fly' or 'Can Swim' or something of the sort). Basically, make water impassable unless you have a ship or some such thing. (I've got an idea but I'm pretty sure it's way more code than I need and I thought it might be something you would want to include in your tutorial to make it even better.)
  • 0

#32 dariusk

dariusk

    GMC Member

  • New Member
  • 5 posts
  • Version:Unknown

Posted 30 July 2009 - 04:50 PM

I was wondering if it would be possible to create a square that is impassable to units unless they have a certain tag (say 'Can Fly' or 'Can Swim' or something of the sort). Basically, make water impassable unless you have a ship or some such thing


I did exactly that when I worked from this tutorial. What I did was I created a ds_map inside the Create statement for each Unit. The ds_map contains overrides for the terrain costs. The code inside the object looks like this:

terrain = ds_map_create();
ds_map_add(terrain,"water",0.5);
ds_map_add(terrain,"grass",2);
ds_map_add(terrain,"road",2);

Then in the Tile objects I added a type field. So the create statement for a grass tile would have

type = "Grass";

When I call FindMovementRange, I'm sure to pass in the terrain overrides:

FindMovementRange( instance_position( x , y , objCell ), MoveRange, terrain);

In the actual FindMovementRange function, the variable declarations look like this:

var _start, _moverange, _terrain;
	_start = argument0;
	_moverange = argument1;
	_terrain = argument2;

And for each up/right/left/down direction the code inside the with statement looks like this, where it's only the first few lines that are different from the tutorial code:

with ( _current.Right )
		{
			var _dist, _cost;
			if (ds_map_exists(_terrain,_current.type)) _cost = ds_map_find_value(_terrain,_current.type);
				else _cost = Cost;
				
			_dist = _predist + _cost;
				
			if ( ds_list_find_index( _listClosed, id ) == -1 && _cost && _dist <= _moverange )
			{
				if ( ds_priority_find_priority( _priorityOpen, id ) == 0 )
				{
					ds_priority_add( _priorityOpen, id, _dist );
					ds_map_add( _mapDist, id, _dist );
					Parent = _current;
					Reachable = true;
				}
				else
				{
					if ( _dist < ds_priority_find_priority( _priorityOpen, id ) )
					{
						ds_priority_change_priority( _priorityOpen, id, _dist );
						ds_map_replace( _mapDist, id, _dist );
						Parent = _current;
					}
				}
			}
		}

What it does is when it's reading the cost of a tile, it looks inside the terrain overrides it was passed by the object to see if there's an override. If there is an override, it uses that cost. Otherwise it uses the default tile movement cost.
  • 0

#33 Wildroses

Wildroses

    GMC Member

  • New Member
  • 4 posts

Posted 30 July 2009 - 05:18 PM

Groovy, much better than what I was thinking of doing. Thanks!

Edit: Not so groovy. I keep getting an error, I thought I could figure it out on my own, but no luck. Here's the error;

ERROR in
action number 1
of Mouse Event for Left Button
for object objPlayer:

Data structure with index does not exist.

Pretty much just copied and pasted what you had above, any ideas?

Edit 2: Groovy again, got it to work.

Edited by Wildroses, 31 July 2009 - 04:43 AM.

  • 0

#34 DragonicHeritage

DragonicHeritage

    GMC Member

  • New Member
  • 19 posts

Posted 14 August 2009 - 06:00 AM

Hey pretty good tutorial here, I've learned a lot from it.

However, one thing that has been bugging me is my inability to expand it with movement etc. I really can't figure out what goes to what list, and it seems that the list is destroyed after the map is created. I think I have been appraoching it the wrong way.
After considering the problem, I think I should create a control object that checks if a player object is selected. If one is selcted, return the id. Next, when a cell is highlighted, check if it is active, and if so, move the player to the cell. My question is: how would I go about doing this, or is there a better(or easier since speed is no problem for these games) way of doing this?


Cheers mate
  • 0

#35 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 25 August 2009 - 02:53 PM

Really hope to see this updated with selection & especially movement someday.
Would be so useful to so many I think!
Goodluck! :whistle:

PS: Been up to my eyes with work, haven't had a chance to get back to that game at all :(
  • 0

AczgxAZ.png5aj9t5.jpg
 


#36 waronmars

waronmars

    GMC Member

  • GMC Member
  • 6 posts

Posted 15 September 2009 - 08:56 AM

Is it possible to use this in an isometric game?
  • 0

#37 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 16 September 2009 - 12:36 PM

I imagine so, with alot of tweaks.
But bear in mind that this example has no actual *movement* or anything - it does just what is does very well... but it's very "bare bones"...
these turn based engines involve alot of coding that's really complicated (for most) -
which is why there has yet to be any GM TBS games released

Hopefully, Mnementh will be kind enough to get back to this someday & add selection & movement (as I think there are many people who'd benefit).

It's a shame that GM doesn't come with a more extensive set of "framework" examples for all types of games that people could build on.

Edited by dadio, 16 September 2009 - 12:37 PM.

  • 0

AczgxAZ.png5aj9t5.jpg
 


#38 Joross21

Joross21

    GMC Member

  • New Member
  • 2 posts

Posted 17 September 2009 - 01:48 PM

Hey pretty good tutorial here, I've learned a lot from it. Groovy, much better than what I was thinking of doing. Thanks!



Regards


Albert

_______
Pret immobilier
  • 0

#39 LurchBrick

LurchBrick

    GMC Member

  • GMC Member
  • 141 posts

Posted 18 September 2009 - 03:53 AM

Actually there have been GM TBS games released before. Here is one I created quite a while ago:

http://gmc.yoyogames...showtopic=77669

I'm using a similar TBS engine to work on a science fiction game and a war game also.

Hovendale Tactics is another one that used to be on the old GM website.
  • 0

#40 dadio

dadio

    Potato King

  • YoYo Games Staff
  • 2740 posts
  • Version:GM:Studio

Posted 18 September 2009 - 10:07 PM

Nifty!
Didn't know about that...
loved Heroquest back in the day :P
Man, I regret selling it off years ago.

So I'll hafta change what I said to..."Apart from 1 or 2 exceptions" no TBS GM games have been released :P

My real point is that TBS games are generally out of reach of the masses, because the coding required is complicated & there are no/few examples/frameworks to work from. I think it's a *real* shame, because I *love* TBS games & would love to see many more pop up. Hopefully someone will eventually get around to a skeletal framework example that would help a whole lot of people out...

Mnementh *almost* has done it here, (& it's appreciated!) but it leaves some essentials out.
If the selection & movement were implemented, that would be the ultimate TBS example...
& I'm positive that most people could "take it from there" & we'd see a whole lot more GM TBS games.

Edited by dadio, 18 September 2009 - 10:08 PM.

  • 0

AczgxAZ.png5aj9t5.jpg
 


#41 Lexsonn

Lexsonn

    Bishop

  • New Member
  • 391 posts

Posted 31 October 2009 - 10:23 PM

Haha thanks! I made my own Fire emblem like movement system and I was getting all confused because my code was 10000x more complicated xD I'm gonna borrow from your example cause mine is so messy :S
  • 0
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.

#42 ComicGaming

ComicGaming

    Adequate at best

  • GMC Member
  • 75 posts

Posted 13 January 2010 - 12:43 AM

I just stumbled upon this while searching for Tactics style movement, and I'm glad I did! My old method of doing it ended up checking over 70,000 possible routes and didn't account for terrain cost or help plan a route. Your method only needed to check about 100 routes with no lag!

Your method was very easy to understand and really got me out of a bind! The pictures you included made it much easier to grasp the general concepts as well. I like to (think) that I'm a fairly advanced GML user and some of this was so simple it hurt my head to think that I couldn't figure it out on my own...

Posted Image

I would hug you, but I don't hug people, so I'll just leave with a knowing nod and a firm handshake.
  • 0
Comic Gaming Home Page
Current Project:
Crimson Aura: ~30%
Other Projects:
Quantum Gear: ~20%
C.O.I.L: ~49%
Super Marx Brothers ~ 10%

#43 kickassgames

kickassgames

    GMC Member

  • GMC Member
  • 230 posts

Posted 23 January 2010 - 04:02 PM

Sweet, its pretty easy to implement, i worked off this to make movement and i also used used same basic method to create an "attacking" system ^_^

9/10 so far, hoping for next part :)
  • 0
Come fight me fool:
Click HERE

#44 Gino Zaccardelli

Gino Zaccardelli

    GMC Member

  • New Member
  • 1 posts

Posted 17 May 2011 - 07:45 AM

I'm having a lot of difficulty with this script. I've boiled down the problem to one simple thing. If I change the primary subimage in sprEasy to opaque, I get an error:

ERROR in
action number 1
of Mouse Event for Left Pressed
for object objPlayer:

In script FindMovementRange:
Error in code at line 18:
_start.Parent = 0;
^
at position 6: Cannot assign to the variable

I don't understand this. What relevance does the opacity of a sprite have to any of the code used here? I haven't changed ANYTHING other than the opacity and I can do nothing to fix this. Anyone have any clues whats going on here? From what I can tell the code shouldn't even care if a sprite is used at all, which makes it all the more frustrating.
  • 0

#45 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 05 July 2011 - 11:56 PM

Std Msg: please fix the error so people can see your tutorial/example in action (The Tutorial Clean Up Crew).

___________________________________________
FATAL ERROR in
action number 1
of Draw Event
for object objPlayer:

COMPILATION ERROR in code action
Error in code at line 25:
}
^
at position 2: Symbol } expected.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#46 Paragon257

Paragon257

    GMC Member

  • New Member
  • 1 posts
  • Version:GM:Studio

Posted 21 June 2014 - 01:48 PM

I apprciate this tutorial. I have been searching for this information for sometime. I wish you would revisit this project and continue. It has helped me trememdously and I am sure anything else you had to add


  • 0