The Daily Click ::. Forums ::. Klik Coding Help ::. Detecting things next to an object, and a Grid object problem
 

Post Reply  Post Oekaki 
 

Posted By Message

Tristan Clark



Registered
  28/07/2003
Points
  159
3rd March, 2005 at 22:31:38 -

Hi guys,

I'm making a turn-based strategy RPG, where you point and click to move your characters, who can move within a certain amount of squares. Here's a couple of problems I've run into:

1. I'm using the Grid object. When you have selected a character to move, a number of movement squares will appear around him. What I'd like is to have the Grid object detect which squares have movement squares on them, and which ones don't, and change the weight of the latter to impassable. Is this possible?

2. I've got land effect in the battle engine, where basically certain squares are harder to pass through than others (like marshlands or forest). Right now, movement squares are destroyed if they are further away from the player and overlapping some marshland etc. Problem is, this sometimes results in movement squares that are isolated and unreachable by the player. Is there any way to have these detected and destroyed? Say, each movement square will detect whether there is any other movement square directly above, below, to the left and to the right. If there isn't in any of these four places, it'd be destroyed. Is there a way to do this?

Thanks for your help!

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
3rd March, 2005 at 23:19:36 -

not sure i understand what you're trying to do, and to be honest, it doesnt sound to me like you know quite what the grid object is for. you have my apologies if i'm wrong.

would i be right in thinking that these "movement squares" are active objects that show up when you select a character, at every location which that character can get to, that turn (taking into account movement costs and "time units")? the idea being that the player clicks on a square and the character moves there?

if this is the case, you should only be setting a square to unpassable if it is always an unpassable type of terrain (like water or something). you would use the grid object to work out where to put the movement squares, only creating one if the object finds a path to its location. you would then also use the grid object to find the path to the selected square, and move the character sprite along it.

i was making a kind of xcom / advance wars hybrid myself a while ago. it used this kind of movement with the grid object. i'll see if i have the file on my other computer.

 
n/a

Tristan Clark



Registered
  28/07/2003
Points
  159
4th March, 2005 at 00:38:49 -

Umm, nope, I don't think that's what I'm looking for. I'll try and explain better:

Basically, like in any turn-based game, a character can move a set number of squares. In this particular instance, you have an area of squares that pop up that you can move around in. This pops up as a diamond of squares around the character. For that turn, the character can ONLY move in the area of the squares. When their next turn comes around, the squares will pop again, and be recentered on the character, so they can move a bit further.
I'd basically be using the grid object normally, but would like movement to be restricted to the area defined by those squares that pop up. This would change each turn, as each character would be in a different place and have a different amount of squares pop up. So I need something that can detect where those squares are, and make everywhere else impassable.
If I try and make it so that the grid object's path just ends when you get to the edge of the area of squares, but it doesn't actually work if there's some obstacle within the area of squares - read my first post about land effect. Basically, if there's something there which isn't an obstacle, but still causes a particular movement square to be destroyed, then the character will not try and move around it, but will get stuck.

So yeh,the movement squares are active objects that pop up, but only in a short area around the character. Forget any idea of time units or movement costs - they can move freely within the area defined by the movement squares around them, but not anywhere else.
Hope that explains things better.

 
n/a

Johan Hargne (Wartagon)

Lover Of Circys

Registered
  15/06/2003
Points
  1289

Game of the Week WinnerCROBASOFTVIP MemberPS3 OwnerWii OwnerMushroom
4th March, 2005 at 05:35:23 -

This reminds me of the movement engine they have in the Heroes of Might and Magic-games.

 
Music Composer.
http://johan.hargne.se

Crobasoft
www.crobasoft.com

Vaynes



Registered
  27/01/2005
Points
  15
4th March, 2005 at 06:29:55 -

i'm trying to do something which sound very similar, do any of you know how to show the grid as an overlay while programming, it would make it easier to get the grid co-ordinates for setting weights

is there any chance I could have a look at your engine as well spacecadet, plz

thx

 
Ever bitten off more than you can chew?

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
4th March, 2005 at 14:26:12 -

are you sure we're not on about the same thing (minus the movement costs)?

you're out of luck as far as my old example goes anyway - i can't find it.
heres something i just knocked up though (uses the pathfinding object instead of the grid one though, as that doesn't have an expression to find the length of a path, and i couldn't be bothered to make it loop through every step of the path to work it out) let me know if you really need it with the grid extension, but if you're not using weights i don't see the point unless you've already done heaps of work using it.

http://free.angeltowns.com/spacecadet/MoveSq.zip
(you dont need to click now, press f2 to reset - also doesnt crash)

Vaynes; what do you mean by an overlay? a picture in the overlay object with different colours representing weights, or some kind of grid of active/background objects? neither is hard - i can make an example if you can explain a bit better (sorry, i don't seem to be too good at getting what people are talking about)

Image Edited by the Author.

 
n/a

Tristan Clark



Registered
  28/07/2003
Points
  159
4th March, 2005 at 17:22:04 -

Here's my code as it stands at the moment:
http://www.geocities.com/mcalphabet/b4.zip

Right-click to bring up a bunch of squares you can move in. Note how it doesnt make a perfect diamond - squares on the periphary are destroyed by the darker green stuff that is harder to walk through. Now try and navigate around the squares you can't go in - the grid object doesn't take that into account, which is what I want it to do. The only command stopping the character from moving out of the blue squares is one telling it to end the path when it isnt overlapping one of em, which doesnt cut it when trying to move around inside the blue area.
Hope this makes this clearer, thanks for yer help!

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
4th March, 2005 at 19:51:17 -

nope. i'm probably being dumb but i really don't see the problem with what you've got (besides the inconsistency in which movement squares are destroyed).

let me get this straight;

* on normal grass, the character should be able to move 4 squares max.

* the dark green stuff is harder to walk through (hence it's inaccesible when at the edge of the normal movement range).

* the blue squares are meant to show up everywhere that the character can reach in one turn, and the player is meant to be able to see them.

if this is right, you just need to decide how much harder it is to walk on dark green stuff, and give those squares a higher weight than the normal grass. you then get the grid object to work out which squares can be reached, and stick a movement square on them. thats how i'd do it anyway. i'm gonna convert my example to using the grid extension and weights (i've been meaning to do something like this for ages, only i keep putting it off because i know it's going to be hard work).

 
n/a

Tristan Clark



Registered
  28/07/2003
Points
  159
4th March, 2005 at 20:31:17 -

Try moving about before right-clicking, and making the blue squares pop up so that an inside one gets destroyed by the darker green squares. Then try moving around or through that green square - the grid object ought to move around it (thats what Im after), but it just gets sorta stuck next to it at the mo.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click