Jump to content


Photo
- - - - -

Turn Based Tactics: Part 1


  • Please log in to reply
44 replies to this topic

#1 Mnementh

Mnementh

    15151

  • Retired Staff
  • 6263 posts
  • Version:GM:Studio

Posted 06 April 2008 - 07:29 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...
  • 0

#2 LRG

LRG

    GMC Member

  • GMC Member
  • 687 posts

Posted 28 April 2008 - 10:11 PM

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

#3 dadio

dadio

    I miss my cupcake

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

Posted 28 April 2008 - 11:46 PM

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

#4 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 29 April 2008 - 04:18 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

#5 dadio

dadio

    I miss my cupcake

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

Posted 02 May 2008 - 05:57 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

#6 LRG

LRG

    GMC Member

  • GMC Member
  • 687 posts

Posted 02 May 2008 - 10:49 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

#7 samglo

samglo

    GMC Member

  • GMC Member
  • 63 posts

Posted 03 May 2008 - 03:50 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

#8 Mnementh

Mnementh

    15151

  • Retired Staff
  • 6263 posts
  • Version:GM:Studio

Posted 04 May 2008 - 12:17 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, 05 May 2008 - 11:47 PM.

  • 0

#9 dadio

dadio

    I miss my cupcake

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

Posted 05 May 2008 - 07:55 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:35 PM.

  • 0

#10 drt_t1gg3r

drt_t1gg3r

    GMC Member

  • GMC Member
  • 3230 posts
  • Version:Unknown

Posted 05 May 2008 - 11:28 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

#11 nononick

nononick

    GMC Member

  • New Member
  • 34 posts

Posted 09 May 2008 - 03:33 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:15 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 - 08:54 AM.

  • 0

#13 x-death

x-death

    Flash Developer

  • GMC Member
  • 3402 posts

Posted 15 May 2008 - 02:33 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

#14 jpcproductions

jpcproductions

    GMC Member

  • GMC Member
  • 74 posts

Posted 19 May 2008 - 03:15 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

#15 blaketheawesomedude

blaketheawesomedude

    GMC Member

  • New Member
  • 295 posts

Posted 21 May 2008 - 12:47 AM

can make um for unreg?
  • 0

#16 Fractal

Fractal

    GMC Member

  • New Member
  • 849 posts

Posted 21 May 2008 - 07:11 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 - 03:56 AM.

  • 0

#17 cruzer323

cruzer323

    Multimedia Megamix

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

Posted 22 May 2008 - 07:35 AM

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

#18 dadio

dadio

    I miss my cupcake

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

Posted 12 June 2008 - 10:58 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

#19 Overdrive Productions

Overdrive Productions

    GMC Member

  • New Member
  • 18 posts

Posted 17 December 2008 - 10:46 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
  • 190 posts

Posted 19 December 2008 - 03:42 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:39 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users